From: Jingjing Wu <jingjing.wu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 2/6] ixgbe: new functions replace old ones for syn filter
Date: Wed, 11 Feb 2015 15:51:46 +0800 [thread overview]
Message-ID: <1423641110-658-3-git-send-email-jingjing.wu@intel.com> (raw)
In-Reply-To: <1423641110-658-1-git-send-email-jingjing.wu@intel.com>
This patch defines new functions dealing with syn filter.
It removes old functions which deal with syn filter.
Syn filter is dealt with through entrance ixgbe_dev_filter_ctrl.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 167 +++++++++++++++++-------------------
1 file changed, 81 insertions(+), 86 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index b341dd0..0616c8f 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -226,11 +226,14 @@ static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
struct ether_addr *mac_addr,
uint32_t index, uint32_t pool);
static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
-static int ixgbe_add_syn_filter(struct rte_eth_dev *dev,
- struct rte_syn_filter *filter, uint16_t rx_queue);
-static int ixgbe_remove_syn_filter(struct rte_eth_dev *dev);
-static int ixgbe_get_syn_filter(struct rte_eth_dev *dev,
- struct rte_syn_filter *filter, uint16_t *rx_queue);
+static int ixgbe_syn_filter_set(struct rte_eth_dev *dev,
+ struct rte_eth_syn_filter *filter,
+ bool add);
+static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
+ struct rte_eth_syn_filter *filter);
+static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg);
static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev, uint16_t index,
struct rte_5tuple_filter *filter, uint16_t rx_queue);
static int ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
@@ -383,9 +386,6 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
#endif /* RTE_NIC_BYPASS */
.rss_hash_update = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
- .add_syn_filter = ixgbe_add_syn_filter,
- .remove_syn_filter = ixgbe_remove_syn_filter,
- .get_syn_filter = ixgbe_get_syn_filter,
.add_5tuple_filter = ixgbe_add_5tuple_filter,
.remove_5tuple_filter = ixgbe_remove_5tuple_filter,
.get_5tuple_filter = ixgbe_get_5tuple_filter,
@@ -3682,107 +3682,105 @@ ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
}
}
-/*
- * add syn filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * filter: ponter to the filter that will be added.
- * rx_queue: the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
+
+#define MAC_TYPE_FILTER_SUP(type) do {\
+ if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\
+ (type) != ixgbe_mac_X550)\
+ return -ENOTSUP;\
+} while (0)
+
static int
-ixgbe_add_syn_filter(struct rte_eth_dev *dev,
- struct rte_syn_filter *filter, uint16_t rx_queue)
+ixgbe_syn_filter_set(struct rte_eth_dev *dev,
+ struct rte_eth_syn_filter *filter,
+ bool add)
{
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
uint32_t synqf;
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (rx_queue >= IXGBE_MAX_RX_QUEUE_NUM)
+ if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
return -EINVAL;
synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
- if (synqf & IXGBE_SYN_FILTER_ENABLE)
- return -EINVAL;
-
- synqf = (uint32_t)(((rx_queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
- IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
-
- if (filter->hig_pri)
- synqf |= IXGBE_SYN_FILTER_SYNQFP;
- else
- synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
+ if (add) {
+ if (synqf & IXGBE_SYN_FILTER_ENABLE)
+ return -EINVAL;
+ synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
+ IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
+ if (filter->hig_pri)
+ synqf |= IXGBE_SYN_FILTER_SYNQFP;
+ else
+ synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
+ } else {
+ if (!(synqf & IXGBE_SYN_FILTER_ENABLE))
+ return -ENOENT;
+ synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
+ }
IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
+ IXGBE_WRITE_FLUSH(hw);
return 0;
}
-/*
- * remove syn filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
static int
-ixgbe_remove_syn_filter(struct rte_eth_dev *dev)
+ixgbe_syn_filter_get(struct rte_eth_dev *dev,
+ struct rte_eth_syn_filter *filter)
{
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t synqf;
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
+ uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
- synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
-
- synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
-
- IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
- return 0;
+ if (synqf & IXGBE_SYN_FILTER_ENABLE) {
+ filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
+ filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
+ return 0;
+ }
+ return -ENOENT;
}
-/*
- * get the syn filter's info
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * filter: ponter to the filter that returns.
- * *rx_queue: pointer to the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
static int
-ixgbe_get_syn_filter(struct rte_eth_dev *dev,
- struct rte_syn_filter *filter, uint16_t *rx_queue)
-
+ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg)
{
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t synqf;
+ int ret;
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
- synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
- if (synqf & IXGBE_SYN_FILTER_ENABLE) {
- filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
- *rx_queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
+ if (filter_op == RTE_ETH_FILTER_NOP)
return 0;
+
+ if (arg == NULL) {
+ PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
+ filter_op);
+ return -EINVAL;
}
- return -ENOENT;
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = ixgbe_syn_filter_set(dev,
+ (struct rte_eth_syn_filter *)arg,
+ TRUE);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = ixgbe_syn_filter_set(dev,
+ (struct rte_eth_syn_filter *)arg,
+ FALSE);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = ixgbe_syn_filter_get(dev,
+ (struct rte_eth_syn_filter *)arg);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u\n", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
}
+
static inline enum ixgbe_5tuple_protocol
convert_protocol_type(uint8_t protocol_value)
{
@@ -4009,12 +4007,6 @@ ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
return 0;
}
-#define MAC_TYPE_FILTER_SUP(type) do {\
- if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\
- (type) != ixgbe_mac_X550)\
- return -ENOTSUP;\
-} while (0)
-
static inline int
ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
uint16_t ethertype)
@@ -4213,6 +4205,9 @@ ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
case RTE_ETH_FILTER_ETHERTYPE:
ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
break;
+ case RTE_ETH_FILTER_SYN:
+ ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
+ break;
default:
PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
filter_type);
--
1.9.3
next prev parent reply other threads:[~2015-02-11 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 1:42 [dpdk-dev] [PATCH] ixgbe/igb: integrate syn filter to new API zhida zang
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 0/6] Integrate syn filter in igb/ixgbe driver " Jingjing Wu
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 1/6] ethdev: define syn filter type and its structure Jingjing Wu
2015-02-11 7:51 ` Jingjing Wu [this message]
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 3/6] e1000: new functions replace old ones for syn filter Jingjing Wu
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 4/6] testpmd: new commands " Jingjing Wu
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 5/6] ethdev: remove old APIs and structures of " Jingjing Wu
2015-02-11 7:51 ` [dpdk-dev] [PATCH v2 6/6] doc: commands changed in testpmd_funcs for " Jingjing Wu
2015-02-12 5:41 ` [dpdk-dev] [PATCH v2 0/6] Integrate syn filter in igb/ixgbe driver to new API Wu, Jingjing
2015-02-22 2:10 ` Thomas Monjalon
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=1423641110-658-3-git-send-email-jingjing.wu@intel.com \
--to=jingjing.wu@intel.com \
--cc=dev@dpdk.org \
/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).