From: alvinx.zhang@intel.com
To: dev@dpdk.org
Cc: haiyue.wang@intel.com, xiaolong.ye@intel.com,
qi.z.zhang@intel.com, beilei.xing@intel.com,
Alvin Zhang <alvinx.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v1 13/15] net/igc: implement TCP SYN filter
Date: Mon, 9 Mar 2020 16:24:05 +0800 [thread overview]
Message-ID: <1583742247-370386-13-git-send-email-alvinx.zhang@intel.com> (raw)
In-Reply-To: <1583742247-370386-1-git-send-email-alvinx.zhang@intel.com>
From: Alvin Zhang <alvinx.zhang@intel.com>
Support putting all TCP SYN packets into a specified queue.
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
drivers/net/igc/igc_ethdev.h | 18 ++++++
drivers/net/igc/igc_filter.c | 129 +++++++++++++++++++++++++++++++++++++++++++
drivers/net/igc/igc_filter.h | 3 +
3 files changed, 150 insertions(+)
diff --git a/drivers/net/igc/igc_ethdev.h b/drivers/net/igc/igc_ethdev.h
index 639782c..68237aa 100644
--- a/drivers/net/igc/igc_ethdev.h
+++ b/drivers/net/igc/igc_ethdev.h
@@ -102,6 +102,11 @@
#define IGC_MAX_2TUPLE_FILTERS 8
#define IGC_2TUPLE_MAX_PRI 7
+#define IGC_SYN_FILTER_ENABLE 0x01 /* syn filter enable field */
+#define IGC_SYN_FILTER_QUEUE_SHIFT 1 /* syn filter queue field */
+#define IGC_SYN_FILTER_QUEUE 0x0000000E /* syn filter queue field */
+#define IGC_RFCTL_SYNQFP 0x00080000 /* SYNQFP in RFCTL register */
+
/* structure for interrupt relative data */
struct igc_interrupt {
uint32_t flags;
@@ -176,6 +181,18 @@ struct igc_2tuple_filter {
uint8_t queue;
};
+/* Structure of TCP SYN filter */
+struct igc_syn_filter {
+ uint8_t queue;
+ /*
+ * Defines the priority between SYNQF and 2 tuple filter
+ * 0b = 2-tuple filter priority
+ * 1b = SYN filter priority
+ */
+ uint8_t priority:1,
+ enable:1; /* 1-enable; 0-disable */
+};
+
/*
* Structure to store private data for each driver instance (for each port).
*/
@@ -192,6 +209,7 @@ struct igc_adapter {
struct igc_ethertype_filter ethertype_filters[IGC_MAX_ETQF_FILTERS];
struct igc_2tuple_filter tuple2_filters[IGC_MAX_2TUPLE_FILTERS];
+ struct igc_syn_filter syn_filter;
};
#define IGC_DEV_PRIVATE(_dev) ((_dev)->data->dev_private)
diff --git a/drivers/net/igc/igc_filter.c b/drivers/net/igc/igc_filter.c
index 340dbee..5203d82 100644
--- a/drivers/net/igc/igc_filter.c
+++ b/drivers/net/igc/igc_filter.c
@@ -546,11 +546,136 @@
return ret;
}
+int
+igc_set_syn_filter(struct rte_eth_dev *dev,
+ const struct rte_eth_syn_filter *filter)
+{
+ struct igc_hw *hw;
+ struct igc_adapter *igc;
+ struct igc_syn_filter *syn_filter;
+ uint32_t synqf, rfctl;
+
+ if (filter->queue >= IGC_QUEUE_PAIRS_NUM) {
+ PMD_DRV_LOG(ERR, "out of range queue %u(max is %u)",
+ filter->queue, IGC_QUEUE_PAIRS_NUM);
+ return -EINVAL;
+ }
+
+ igc = IGC_DEV_PRIVATE(dev);
+ syn_filter = &igc->syn_filter;
+
+ if (syn_filter->enable) {
+ PMD_DRV_LOG(ERR, "SYN filter has been enabled before!");
+ return -EEXIST;
+ }
+
+ hw = IGC_DEV_PRIVATE_HW(dev);
+ synqf = (uint32_t)filter->queue << IGC_SYN_FILTER_QUEUE_SHIFT;
+ synqf |= IGC_SYN_FILTER_ENABLE;
+
+ rfctl = IGC_READ_REG(hw, IGC_RFCTL);
+ if (filter->hig_pri) {
+ syn_filter->priority = 1;
+ rfctl |= IGC_RFCTL_SYNQFP;
+ } else {
+ syn_filter->priority = 0;
+ rfctl &= ~IGC_RFCTL_SYNQFP;
+ }
+
+ syn_filter->enable = 1;
+ syn_filter->queue = filter->queue;
+ IGC_WRITE_REG(hw, IGC_RFCTL, rfctl);
+ IGC_WRITE_REG(hw, IGC_SYNQF(0), synqf);
+ IGC_WRITE_FLUSH(hw);
+ return 0;
+}
+
+int
+igc_del_syn_filter(struct rte_eth_dev *dev)
+{
+ struct igc_hw *hw = IGC_DEV_PRIVATE_HW(dev);
+ struct igc_adapter *igc = IGC_DEV_PRIVATE(dev);
+ struct igc_syn_filter *syn_filter = &igc->syn_filter;
+
+ if (syn_filter->enable == 0)
+ return 0;
+
+ syn_filter->enable = 0;
+
+ IGC_WRITE_REG(hw, IGC_SYNQF(0), 0);
+ IGC_WRITE_FLUSH(hw);
+ return 0;
+}
+
+static int
+igc_syn_filter_get(struct rte_eth_dev *dev, struct rte_eth_syn_filter *filter)
+{
+ struct igc_adapter *igc = IGC_DEV_PRIVATE(dev);
+ struct igc_syn_filter *syn_filter = &igc->syn_filter;
+
+ if (syn_filter->enable == 0) {
+ PMD_DRV_LOG(ERR, "syn filter not been set.\n");
+ return -ENOENT;
+ }
+
+ filter->hig_pri = syn_filter->priority;
+ filter->queue = syn_filter->queue;
+ return 0;
+}
+
+/* clear the SYN filter */
+static void
+igc_clear_syn_filter(struct rte_eth_dev *dev)
+{
+ struct igc_hw *hw = IGC_DEV_PRIVATE_HW(dev);
+ struct igc_adapter *igc = IGC_DEV_PRIVATE(dev);
+
+ IGC_WRITE_REG(hw, IGC_SYNQF(0), 0);
+ IGC_WRITE_FLUSH(hw);
+
+ memset(&igc->syn_filter, 0, sizeof(igc->syn_filter));
+}
+
+static int
+igc_syn_filter_handle(struct rte_eth_dev *dev, enum rte_filter_op filter_op,
+ struct rte_eth_syn_filter *filter)
+{
+ int ret;
+
+ if (filter_op == RTE_ETH_FILTER_NOP)
+ return 0;
+
+ if (filter == NULL) {
+ PMD_DRV_LOG(ERR, "filter shouldn't be NULL for operation %u",
+ filter_op);
+ return -EINVAL;
+ }
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = igc_set_syn_filter(dev, filter);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = igc_del_syn_filter(dev);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = igc_syn_filter_get(dev, filter);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
void
igc_clear_all_filter(struct rte_eth_dev *dev)
{
igc_clear_all_ethertype_filter(dev);
igc_clear_all_ntuple_filter(dev);
+ igc_clear_syn_filter(dev);
}
int
@@ -568,6 +693,10 @@
ret = igc_ntuple_filter_handle(dev, filter_op,
(struct rte_eth_ntuple_filter *)arg);
break;
+ case RTE_ETH_FILTER_SYN:
+ ret = igc_syn_filter_handle(dev, filter_op,
+ (struct rte_eth_syn_filter *)arg);
+ break;
default:
PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
filter_type);
diff --git a/drivers/net/igc/igc_filter.h b/drivers/net/igc/igc_filter.h
index 7c5e843..4fad8e0 100644
--- a/drivers/net/igc/igc_filter.h
+++ b/drivers/net/igc/igc_filter.h
@@ -20,6 +20,9 @@ int igc_del_ethertype_filter(struct rte_eth_dev *dev,
int igc_add_del_ntuple_filter(struct rte_eth_dev *dev,
const struct rte_eth_ntuple_filter *ntuple,
bool add);
+int igc_set_syn_filter(struct rte_eth_dev *dev,
+ const struct rte_eth_syn_filter *filter);
+int igc_del_syn_filter(struct rte_eth_dev *dev);
void
igc_clear_all_filter(struct rte_eth_dev *dev);
--
1.8.3.1
next prev parent reply other threads:[~2020-03-09 8:31 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 8:23 [dpdk-dev] [PATCH v1 01/15] net/igc: add igc PMD alvinx.zhang
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 02/15] net/igc: update base share codes alvinx.zhang
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 03/15] net/igc: device initialization alvinx.zhang
2020-03-12 4:42 ` Ye Xiaolong
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 04/15] net/igc: implement device base ops alvinx.zhang
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 05/15] net/igc: support reception and transmission of packets alvinx.zhang
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 06/15] net/igc: implement status API alvinx.zhang
2020-03-09 8:23 ` [dpdk-dev] [PATCH v1 07/15] net/igc: enable Rx queue interrupts alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 08/15] net/igc: implement flow control ops alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 09/15] net/igc: implement RSS API alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 10/15] net/igc: implement feature of VLAN alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 11/15] net/igc: implement ether-type filter alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 12/15] net/igc: implement 2-tuple filter alvinx.zhang
2020-03-09 8:24 ` alvinx.zhang [this message]
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 14/15] net/igc: implement hash filter configure alvinx.zhang
2020-03-09 8:24 ` [dpdk-dev] [PATCH v1 15/15] net/igc: implement flow API alvinx.zhang
2020-03-09 8:35 ` [dpdk-dev] [PATCH v1 01/15] net/igc: add igc PMD Ye Xiaolong
2020-03-12 3:09 ` Ye Xiaolong
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 00/14] " alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 01/14] net/igc: add " alvinx.zhang
2020-04-03 12:21 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 02/14] net/igc: support device initialization alvinx.zhang
2020-04-03 12:23 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 03/14] net/igc: implement device base ops alvinx.zhang
2020-04-03 12:24 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 04/14] net/igc: support reception and transmission of packets alvinx.zhang
2020-04-03 12:27 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 05/14] net/igc: implement status API alvinx.zhang
2020-04-03 12:24 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 06/14] net/igc: enable Rx queue interrupts alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 07/14] net/igc: implement flow control ops alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 08/14] net/igc: implement RSS API alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 09/14] net/igc: implement feature of VLAN alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 10/14] net/igc: implement ether-type filter alvinx.zhang
2020-04-03 12:26 ` Ferruh Yigit
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 11/14] net/igc: implement 2-tuple filter alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 12/14] net/igc: implement TCP SYN filter alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 13/14] net/igc: implement hash filter configure alvinx.zhang
2020-03-20 2:46 ` [dpdk-dev] [PATCH v2 14/14] net/igc: implement flow API alvinx.zhang
2020-04-03 12:26 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1583742247-370386-13-git-send-email-alvinx.zhang@intel.com \
--to=alvinx.zhang@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=haiyue.wang@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=xiaolong.ye@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).