blob: f2fe52e12f9feef250ac346d7e1920cf3bb25780 [file] [log] [blame]
Chenmin Sun7f837382020-03-28 00:34:19 +08001From e69d36c549609c02b6814cd06232e340fe0b873b Mon Sep 17 00:00:00 2001
2From: Leyi Rong <leyi.rong@intel.com>
3Date: Wed, 8 Apr 2020 14:22:05 +0800
4Subject: [DPDK 11/17] net/iavf: add flow director enabled switch value
5
6The commit adds fdir_enabled flag into iavf_rx_queue structure
7to identify if fdir id is active. Rx data path can be benefit if
8fdir id parsing is not needed, especially in vector path.
9
10Signed-off-by: Leyi Rong <leyi.rong@intel.com>
11---
12 drivers/net/iavf/iavf.h | 1 +
13 drivers/net/iavf/iavf_rxtx.h | 30 ++++++++++++++++++++++++++++++
14 2 files changed, 31 insertions(+)
15
16diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
17index 67d625053..0cd0117c2 100644
18--- a/drivers/net/iavf/iavf.h
19+++ b/drivers/net/iavf/iavf.h
20@@ -134,6 +134,7 @@ struct iavf_adapter {
21 bool tx_vec_allowed;
22 const uint32_t *ptype_tbl;
23 bool stopped;
24+ uint16_t fdir_ref_cnt;
25 };
26
27 /* IAVF_DEV_PRIVATE_TO */
28diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
29index 8e1db2588..f37438953 100644
30--- a/drivers/net/iavf/iavf_rxtx.h
31+++ b/drivers/net/iavf/iavf_rxtx.h
32@@ -103,6 +103,7 @@ struct iavf_rx_queue {
33
34 uint16_t port_id; /* device port ID */
35 uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */
36+ uint8_t fdir_enabled; /* 0 if FDIR disabled, 1 when enabled */
37 uint16_t queue_id; /* Rx queue index */
38 uint16_t rx_buf_len; /* The packet buffer size */
39 uint16_t rx_hdr_len; /* The header buffer size */
40@@ -485,6 +486,35 @@ void iavf_dump_tx_descriptor(const struct iavf_tx_queue *txq,
41 tx_desc->cmd_type_offset_bsz);
42 }
43
44+#define FDIR_PROC_ENABLE_PER_QUEUE(ad, on) do { \
45+ int i; \
46+ for (i = 0; i < (ad)->eth_dev->data->nb_rx_queues; i++) { \
47+ struct iavf_rx_queue *rxq = (ad)->eth_dev->data->rx_queues[i]; \
48+ if (!rxq) \
49+ continue; \
50+ rxq->fdir_enabled = on; \
51+ } \
52+ PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
53+} while (0)
54+
55+/* Enable/disable flow director Rx processing in data path. */
56+static inline
57+void iavf_fdir_rx_proc_enable(struct iavf_adapter *ad, bool on)
58+{
59+ if (on) {
60+ /* enable flow director processing */
61+ if (ad->fdir_ref_cnt++ == 0)
62+ FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
63+ } else {
64+ if (ad->fdir_ref_cnt >= 1) {
65+ ad->fdir_ref_cnt--;
66+
67+ if (ad->fdir_ref_cnt == 0)
68+ FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
69+ }
70+ }
71+}
72+
73 #ifdef RTE_LIBRTE_IAVF_DEBUG_DUMP_DESC
74 #define IAVF_DUMP_RX_DESC(rxq, desc, rx_id) \
75 iavf_dump_rx_descriptor(rxq, desc, rx_id)
76--
772.17.1
78