net/iavf: add flow director enabled switch value
authorLeyi Rong <leyi.rong@intel.com>
Mon, 20 Apr 2020 06:16:20 +0000 (14:16 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:09 +0000 (13:57 +0200)
The commit adds fdir_enabled flag into iavf_rx_queue structure
to identify if fdir id is active. Rx data path can be benefit if
fdir id parsing is not needed, especially in vector path.

Signed-off-by: Leyi Rong <leyi.rong@intel.com>
Reviewed-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf.h
drivers/net/iavf/iavf_rxtx.h

index fdb31b9..17ceff7 100644 (file)
@@ -144,6 +144,7 @@ struct iavf_adapter {
        bool tx_vec_allowed;
        const uint32_t *ptype_tbl;
        bool stopped;
+       uint16_t fdir_ref_cnt;
 };
 
 /* IAVF_DEV_PRIVATE_TO */
index 9bc8573..7396884 100644 (file)
@@ -104,6 +104,7 @@ struct iavf_rx_queue {
 
        uint16_t port_id;        /* device port ID */
        uint8_t crc_len;        /* 0 if CRC stripped, 4 otherwise */
+       uint8_t fdir_enabled;   /* 0 if FDIR disabled, 1 when enabled */
        uint16_t queue_id;      /* Rx queue index */
        uint16_t rx_buf_len;    /* The packet buffer size */
        uint16_t rx_hdr_len;    /* The header buffer size */
@@ -491,6 +492,35 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq,
               tx_desc->cmd_type_offset_bsz);
 }
 
+#define FDIR_PROC_ENABLE_PER_QUEUE(ad, on) do { \
+       int i; \
+       for (i = 0; i < (ad)->eth_dev->data->nb_rx_queues; i++) { \
+               struct iavf_rx_queue *rxq = (ad)->eth_dev->data->rx_queues[i]; \
+               if (!rxq) \
+                       continue; \
+               rxq->fdir_enabled = on; \
+       } \
+       PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
+} while (0)
+
+/* Enable/disable flow director Rx processing in data path. */
+static inline
+void iavf_fdir_rx_proc_enable(struct iavf_adapter *ad, bool on)
+{
+       if (on) {
+               /* enable flow director processing */
+               if (ad->fdir_ref_cnt++ == 0)
+                       FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
+       } else {
+               if (ad->fdir_ref_cnt >= 1) {
+                       ad->fdir_ref_cnt--;
+
+                       if (ad->fdir_ref_cnt == 0)
+                               FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
+               }
+       }
+}
+
 #ifdef RTE_LIBRTE_IAVF_DEBUG_DUMP_DESC
 #define IAVF_DUMP_RX_DESC(rxq, desc, rx_id) \
        iavf_dump_rx_descriptor(rxq, desc, rx_id)