* [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
@ 2014-12-25 3:14 Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Jingjing Wu @ 2014-12-25 3:14 UTC (permalink / raw)
To: dev
The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
It uses new functions and structure to replace old ones in igb/ixgbe driver,
new commands to replace old ones in testpmd, and removes the old APIs.
Jingjing Wu (4):
ixgbe: new functions replaces old ones for ethertype filters
e1000: new functions replaces old ones for ethertype filters
testpmd: new commands for ethertype filter
ethdev: remove old APIs and structures of ethertype filters
app/test-pmd/cmdline.c | 253 ++++++++++++--------------
app/test-pmd/config.c | 27 ---
lib/librte_ether/rte_ethdev.c | 57 ------
lib/librte_ether/rte_ethdev.h | 88 ---------
lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354 +++++++++++++++++++++++-------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
8 files changed, 579 insertions(+), 558 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
@ 2014-12-25 3:14 ` Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters Jingjing Wu
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2014-12-25 3:14 UTC (permalink / raw)
To: dev
This patch removes old functions which deal with ethertype filter in ixgbe driver.
It also defines ixgbe_dev_filter_ctrl which is binding to filter_ctrl API,
and ethertype filter can be dealt with through this new entrance.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354 +++++++++++++++++++++++-------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
2 files changed, 239 insertions(+), 128 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 3fc3738..99cbbfb 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -231,12 +231,6 @@ static int ixgbe_add_syn_filter(struct rte_eth_dev *dev,
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_add_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-static int ixgbe_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index);
-static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
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,
@@ -245,6 +239,18 @@ static int ixgbe_get_5tuple_filter(struct rte_eth_dev *dev, uint16_t index,
struct rte_5tuple_filter *filter, uint16_t *rx_queue);
static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
+static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add);
+static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg);
+static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter);
+static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg);
/*
* Define VF Stats MACRO for Non "cleared on read" register
@@ -380,12 +386,10 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
.add_syn_filter = ixgbe_add_syn_filter,
.remove_syn_filter = ixgbe_remove_syn_filter,
.get_syn_filter = ixgbe_get_syn_filter,
- .add_ethertype_filter = ixgbe_add_ethertype_filter,
- .remove_ethertype_filter = ixgbe_remove_ethertype_filter,
- .get_ethertype_filter = ixgbe_get_ethertype_filter,
.add_5tuple_filter = ixgbe_add_5tuple_filter,
.remove_5tuple_filter = ixgbe_remove_5tuple_filter,
.get_5tuple_filter = ixgbe_get_5tuple_filter,
+ .filter_ctrl = ixgbe_dev_filter_ctrl,
};
/*
@@ -3774,125 +3778,6 @@ ixgbe_get_syn_filter(struct rte_eth_dev *dev,
return -ENOENT;
}
-/*
- * add an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * 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.
- */
-static int
-ixgbe_add_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t rx_queue)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf, etqs = 0;
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS ||
- rx_queue >= IXGBE_MAX_RX_QUEUE_NUM)
- return -EINVAL;
-
- etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(index));
- if (etqf & IXGBE_ETQF_FILTER_EN)
- return -EINVAL; /* filter index is in use. */
-
- etqf = 0;
- etqf |= IXGBE_ETQF_FILTER_EN;
- etqf |= (uint32_t)filter->ethertype;
-
- if (filter->priority_en) {
- if (filter->priority > IXGBE_ETQF_MAX_PRI)
- return -EINVAL;
- etqf |= (uint32_t)((filter->priority << IXGBE_ETQF_SHIFT) & IXGBE_ETQF_UP);
- etqf |= IXGBE_ETQF_UP_EN;
- }
- etqs |= (uint32_t)((rx_queue << IXGBE_ETQS_RX_QUEUE_SHIFT) & IXGBE_ETQS_RX_QUEUE);
- etqs |= IXGBE_ETQS_QUEUE_EN;
-
- IXGBE_WRITE_REG(hw, IXGBE_ETQF(index), etqf);
- IXGBE_WRITE_REG(hw, IXGBE_ETQS(index), etqs);
- return 0;
-}
-
-/*
- * remove an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-ixgbe_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- IXGBE_WRITE_REG(hw, IXGBE_ETQF(index), 0);
- IXGBE_WRITE_REG(hw, IXGBE_ETQS(index), 0);
-
- return 0;
-}
-
-/*
- * get an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * filter: ponter to the filter that will be gotten.
- * *rx_queue: the ponited of the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t *rx_queue)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf, etqs;
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(index));
- etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(index));
- if (etqf & IXGBE_ETQF_FILTER_EN) {
- filter->ethertype = etqf & IXGBE_ETQF_ETHERTYPE;
- filter->priority_en = (etqf & IXGBE_ETQF_UP_EN) ? 1 : 0;
- if (filter->priority_en)
- filter->priority = (etqf & IXGBE_ETQF_UP) >> 16;
- *rx_queue = (etqs & IXGBE_ETQS_RX_QUEUE) >> IXGBE_ETQS_RX_QUEUE_SHIFT;
- return 0;
- }
- return -ENOENT;
-}
-
static inline enum ixgbe_5tuple_protocol
convert_protocol_type(uint8_t protocol_value)
{
@@ -4119,6 +4004,219 @@ 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)
+{
+ int i;
+
+ for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
+ if (filter_info->ethertype_filters[i] == ethertype &&
+ (filter_info->ethertype_mask & (1 << i)))
+ return i;
+ }
+ return -1;
+}
+
+static inline int
+ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
+ if (!(filter_info->ethertype_mask & (1 << i))) {
+ filter_info->ethertype_mask |= 1 << i;
+ filter_info->ethertype_filters[i] = ethertype;
+ return i;
+ }
+ }
+ return -1;
+}
+
+static inline int
+ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info,
+ uint8_t idx)
+{
+ if (idx >= IXGBE_MAX_ETQF_FILTERS)
+ return -1;
+ filter_info->ethertype_mask &= ~(1 << idx);
+ filter_info->ethertype_filters[idx] = 0;
+ return idx;
+}
+
+static int
+ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add)
+{
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct ixgbe_filter_info *filter_info =
+ IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf = 0;
+ uint32_t etqs = 0;
+ int ret;
+
+ if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
+ return -EINVAL;
+
+ if (filter->ether_type == ETHER_TYPE_IPv4 ||
+ filter->ether_type == ETHER_TYPE_IPv6) {
+ PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
+ " ethertype filter.", filter->ether_type);
+ return -EINVAL;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ PMD_DRV_LOG(ERR, "mac compare is unsupported.");
+ return -EINVAL;
+ }
+ if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
+ PMD_DRV_LOG(ERR, "drop option is unsupported.");
+ return -EINVAL;
+ }
+
+ ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret >= 0 && add) {
+ PMD_DRV_LOG(WARNING, "ethertype (0x%04x) filter exists.",
+ filter->ether_type);
+ return ret;
+ }
+ if (ret < 0 && !add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ if (add) {
+ ret = ixgbe_ethertype_filter_insert(filter_info,
+ filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype filters are full.");
+ return -ENOSYS;
+ }
+ etqf = IXGBE_ETQF_FILTER_EN;
+ etqf |= (uint32_t)filter->ether_type;
+ etqs |= (uint32_t)((filter->queue <<
+ IXGBE_ETQS_RX_QUEUE_SHIFT) &
+ IXGBE_ETQS_RX_QUEUE);
+ etqs |= IXGBE_ETQS_QUEUE_EN;
+ } else {
+ ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
+ if (ret < 0)
+ return -ENOSYS;
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
+ IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
+ IXGBE_WRITE_FLUSH(hw);
+
+ return 0;
+}
+
+static int
+ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter)
+{
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct ixgbe_filter_info *filter_info =
+ IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf, etqs;
+ int ret;
+
+ ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
+ if (etqf & IXGBE_ETQF_FILTER_EN) {
+ etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
+ filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
+ filter->flags = 0;
+ filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
+ IXGBE_ETQS_RX_QUEUE_SHIFT;
+ return 0;
+ }
+ return -ENOENT;
+}
+
+/*
+ * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
+ * @dev: pointer to rte_eth_dev structure
+ * @filter_op:operation will be taken.
+ * @arg: a pointer to specific structure corresponding to the filter_op
+ */
+static int
+ixgbe_ethertype_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);
+ int ret;
+
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
+
+ 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;
+ }
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = ixgbe_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ TRUE);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = ixgbe_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ FALSE);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = ixgbe_get_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
+static int
+ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ int ret = -EINVAL;
+
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
+ break;
+ default:
+ PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+ filter_type);
+ break;
+ }
+
+ return ret;
+}
+
static struct rte_driver rte_ixgbe_driver = {
.type = PMD_PDEV,
.init = rte_ixgbe_pmd_init,
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index ca99170..35c7704 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -162,6 +162,15 @@ struct ixgbe_vf_info {
};
/*
+ * Structure to store filters' info.
+ */
+struct ixgbe_filter_info {
+ uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
+ /* store used ethertype filters*/
+ uint16_t ethertype_filters[IXGBE_MAX_ETQF_FILTERS];
+};
+
+/*
* Structure to store private data for each driver instance (for each port).
*/
struct ixgbe_adapter {
@@ -179,6 +188,7 @@ struct ixgbe_adapter {
#ifdef RTE_NIC_BYPASS
struct ixgbe_bypass_info bps;
#endif /* RTE_NIC_BYPASS */
+ struct ixgbe_filter_info filter;
};
/*
@@ -224,6 +234,9 @@ enum ixgbe_5tuple_protocol {
#define IXGBE_DEV_PRIVATE_TO_UTA(adapter) \
(&((struct ixgbe_adapter *)adapter)->uta_info)
+#define IXGBE_DEV_PRIVATE_TO_FILTER_INFO(adapter) \
+ (&((struct ixgbe_adapter *)adapter)->filter)
+
/*
* RX/TX function prototypes
*/
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
@ 2014-12-25 3:14 ` Jingjing Wu
2015-01-12 1:32 ` Zhang, Helin
2014-12-25 3:14 ` [dpdk-dev] [PATCH 3/4] testpmd: new commands for ethertype filter Jingjing Wu
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Jingjing Wu @ 2014-12-25 3:14 UTC (permalink / raw)
To: dev
This patch removes old functions which deal with ethertype filters in ixgbe driver.
It also defines eth_igb_filter_ctrl which is binding to filter_ctrl API,
and ethertype filter can be dealt with through this new entrance.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++++-------------
2 files changed, 228 insertions(+), 117 deletions(-)
diff --git a/lib/librte_pmd_e1000/e1000_ethdev.h b/lib/librte_pmd_e1000/e1000_ethdev.h
index 71eb5fb..d155e77 100644
--- a/lib/librte_pmd_e1000/e1000_ethdev.h
+++ b/lib/librte_pmd_e1000/e1000_ethdev.h
@@ -132,6 +132,15 @@ struct e1000_vf_info {
};
/*
+ * Structure to store filters' info.
+ */
+struct e1000_filter_info {
+ uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
+ /* store used ethertype filters*/
+ uint16_t ethertype_filters[E1000_MAX_ETQF_FILTERS];
+};
+
+/*
* Structure to store private data for each driver instance (for each port).
*/
struct e1000_adapter {
@@ -140,6 +149,7 @@ struct e1000_adapter {
struct e1000_interrupt intr;
struct e1000_vfta shadow_vfta;
struct e1000_vf_info *vfdata;
+ struct e1000_filter_info filter;
};
#define E1000_DEV_PRIVATE_TO_HW(adapter) \
@@ -157,6 +167,9 @@ struct e1000_adapter {
#define E1000_DEV_PRIVATE_TO_P_VFDATA(adapter) \
(&((struct e1000_adapter *)adapter)->vfdata)
+#define E1000_DEV_PRIVATE_TO_FILTER_INFO(adapter) \
+ (&((struct e1000_adapter *)adapter)->filter)
+
/*
* RX/TX IGB function prototypes
*/
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index 873d65e..3c549aa 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -154,14 +154,6 @@ static int eth_igb_add_syn_filter(struct rte_eth_dev *dev,
static int eth_igb_remove_syn_filter(struct rte_eth_dev *dev);
static int eth_igb_get_syn_filter(struct rte_eth_dev *dev,
struct rte_syn_filter *filter, uint16_t *rx_queue);
-static int eth_igb_add_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-static int eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index);
-static int eth_igb_get_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
static int eth_igb_add_2tuple_filter(struct rte_eth_dev *dev,
uint16_t index,
struct rte_2tuple_filter *filter, uint16_t rx_queue);
@@ -186,6 +178,18 @@ static int eth_igb_remove_5tuple_filter(struct rte_eth_dev *dev,
static int eth_igb_get_5tuple_filter(struct rte_eth_dev *dev,
uint16_t index,
struct rte_5tuple_filter *filter, uint16_t *rx_queue);
+static int igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add);
+static int igb_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg);
+static int igb_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter);
+static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg);
/*
* Define VF Stats MACRO for Non "cleared on read" register
@@ -264,9 +268,6 @@ static struct eth_dev_ops eth_igb_ops = {
.add_syn_filter = eth_igb_add_syn_filter,
.remove_syn_filter = eth_igb_remove_syn_filter,
.get_syn_filter = eth_igb_get_syn_filter,
- .add_ethertype_filter = eth_igb_add_ethertype_filter,
- .remove_ethertype_filter = eth_igb_remove_ethertype_filter,
- .get_ethertype_filter = eth_igb_get_ethertype_filter,
.add_2tuple_filter = eth_igb_add_2tuple_filter,
.remove_2tuple_filter = eth_igb_remove_2tuple_filter,
.get_2tuple_filter = eth_igb_get_2tuple_filter,
@@ -276,6 +277,7 @@ static struct eth_dev_ops eth_igb_ops = {
.add_5tuple_filter = eth_igb_add_5tuple_filter,
.remove_5tuple_filter = eth_igb_remove_5tuple_filter,
.get_5tuple_filter = eth_igb_get_5tuple_filter,
+ .filter_ctrl = eth_igb_filter_ctrl,
};
/*
@@ -2388,7 +2390,7 @@ eth_igb_rss_reta_query(struct rte_eth_dev *dev,
#define MAC_TYPE_FILTER_SUP(type) do {\
if ((type) != e1000_82580 && (type) != e1000_i350 &&\
(type) != e1000_82576)\
- return -ENOSYS;\
+ return -ENOTSUP;\
} while (0)
/*
@@ -2485,111 +2487,6 @@ eth_igb_get_syn_filter(struct rte_eth_dev *dev,
return -ENOENT;
}
-/*
- * add an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * 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.
- */
-static int
-eth_igb_add_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf;
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS || rx_queue >= IGB_MAX_RX_QUEUE_NUM)
- return -EINVAL;
-
- etqf = E1000_READ_REG(hw, E1000_ETQF(index));
- if (etqf & E1000_ETQF_FILTER_ENABLE)
- return -EINVAL; /* filter index is in use. */
- else
- etqf = 0;
-
- etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
- etqf |= (uint32_t)(filter->ethertype & E1000_ETQF_ETHERTYPE);
- etqf |= rx_queue << E1000_ETQF_QUEUE_SHIFT;
-
- if (filter->priority_en) {
- PMD_INIT_LOG(ERR, "vlan and priority (%d) is not supported"
- " in E1000.", filter->priority);
- return -EINVAL;
- }
-
- E1000_WRITE_REG(hw, E1000_ETQF(index), etqf);
- return 0;
-}
-
-/*
- * remove an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev, uint16_t index)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- E1000_WRITE_REG(hw, E1000_ETQF(index), 0);
- return 0;
-}
-
-/*
- * get an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * filter: ponter to the filter that will be gotten.
- * *rx_queue: the ponited of the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-eth_igb_get_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf;
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- etqf = E1000_READ_REG(hw, E1000_ETQF(index));
- if (etqf & E1000_ETQF_FILTER_ENABLE) {
- filter->ethertype = etqf & E1000_ETQF_ETHERTYPE;
- filter->priority_en = 0;
- *rx_queue = (etqf & E1000_ETQF_QUEUE) >> E1000_ETQF_QUEUE_SHIFT;
- return 0;
- }
- return -ENOENT;
-}
-
#define MAC_TYPE_FILTER_SUP_EXT(type) do {\
if ((type) != e1000_82580 && (type) != e1000_i350)\
return -ENOSYS; \
@@ -3149,6 +3046,207 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
return 0;
}
+static inline int
+igb_ethertype_filter_lookup(struct e1000_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
+ if (filter_info->ethertype_filters[i] == ethertype &&
+ (filter_info->ethertype_mask & (1 << i)))
+ return i;
+ }
+ return -1;
+}
+
+static inline int
+igb_ethertype_filter_insert(struct e1000_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
+ if (!(filter_info->ethertype_mask & (1 << i))) {
+ filter_info->ethertype_mask |= 1 << i;
+ filter_info->ethertype_filters[i] = ethertype;
+ return i;
+ }
+ }
+ return -1;
+}
+
+static inline int
+igb_ethertype_filter_remove(struct e1000_filter_info *filter_info,
+ uint8_t idx)
+{
+ if (idx >= E1000_MAX_ETQF_FILTERS)
+ return -1;
+ filter_info->ethertype_mask &= ~(1 << idx);
+ filter_info->ethertype_filters[idx] = 0;
+ return idx;
+}
+
+
+static int
+igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_filter_info *filter_info =
+ E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf = 0;
+ int ret;
+
+ if (filter->ether_type == ETHER_TYPE_IPv4 ||
+ filter->ether_type == ETHER_TYPE_IPv6) {
+ PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
+ " ethertype filter.", filter->ether_type);
+ return -EINVAL;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ PMD_DRV_LOG(ERR, "mac compare is unsupported.");
+ return -EINVAL;
+ }
+ if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
+ PMD_DRV_LOG(ERR, "drop option is unsupported.");
+ return -EINVAL;
+ }
+
+ ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret >= 0 && add) {
+ PMD_DRV_LOG(WARNING, "ethertype (0x%04x) filter exists.",
+ filter->ether_type);
+ return ret;
+ }
+ if (ret < 0 && !add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ if (add) {
+ ret = igb_ethertype_filter_insert(filter_info,
+ filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype filters are full.");
+ return -ENOSYS;
+ }
+
+ etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
+ etqf |= (uint32_t)(filter->ether_type & E1000_ETQF_ETHERTYPE);
+ etqf |= filter->queue << E1000_ETQF_QUEUE_SHIFT;
+ } else {
+ ret = igb_ethertype_filter_remove(filter_info, (uint8_t)ret);
+ if (ret < 0)
+ return -ENOSYS;
+ }
+ E1000_WRITE_REG(hw, E1000_ETQF(ret), etqf);
+ E1000_WRITE_FLUSH(hw);
+
+ return 0;
+}
+
+static int
+igb_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_filter_info *filter_info =
+ E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf;
+ int ret;
+
+ ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ etqf = E1000_READ_REG(hw, E1000_ETQF(ret));
+ if (etqf & E1000_ETQF_FILTER_ENABLE) {
+ filter->ether_type = etqf & E1000_ETQF_ETHERTYPE;
+ filter->flags = 0;
+ filter->queue = (etqf & E1000_ETQF_QUEUE) >>
+ E1000_ETQF_QUEUE_SHIFT;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+/*
+ * igb_ethertype_filter_handle - Handle operations for ethertype filter.
+ * @dev: pointer to rte_eth_dev structure
+ * @filter_op:operation will be taken.
+ * @arg: a pointer to specific structure corresponding to the filter_op
+ */
+static int
+igb_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int ret;
+
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
+
+ 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;
+ }
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = igb_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ TRUE);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = igb_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ FALSE);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = igb_get_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
+static int
+eth_igb_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ int ret = -EINVAL;
+
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ ret = igb_ethertype_filter_handle(dev, filter_op, arg);
+ break;
+ default:
+ PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+ filter_type);
+ break;
+ }
+
+ return ret;
+}
+
static struct rte_driver pmd_igb_drv = {
.type = PMD_PDEV,
.init = rte_igb_pmd_init,
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH 3/4] testpmd: new commands for ethertype filter
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters Jingjing Wu
@ 2014-12-25 3:14 ` Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
` (2 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2014-12-25 3:14 UTC (permalink / raw)
To: dev
Following commands of ethertype filter are removed:
- add_ethertype_filter (port_id) ethertype (eth_value)
- remove_ethertype_filter (port_id) index (idx)
- get_ethertype_filter (port_id) index (idx)
New command is added for ethertype filter by using filter_ctrl API and new
ethertype filter structure:
- ethertype_filter (port_id) (add|del) (mac_addr|mac_ignr)
(mac_address) ethertype (ether_type) (drop|fwd) queue (queue_id)
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
app/test-pmd/cmdline.c | 253 ++++++++++++++++++++++---------------------------
app/test-pmd/config.c | 27 ------
2 files changed, 112 insertions(+), 168 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 882a5a2..f0c7d5f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -654,15 +654,10 @@ static void cmd_help_long_parsed(void *parsed_result,
"filters:\n"
"--------\n\n"
- "add_ethertype_filter (port_id) ethertype (eth_value)"
- " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
- " add an ethertype filter.\n\n"
-
- "remove_ethertype_filter (port_id) index (idx)\n"
- " remove an ethertype filter.\n\n"
-
- "get_ethertype_filter (port_id) index (idx)\n"
- " get info of a ethertype filter.\n\n"
+ "ethertype_filter (port_id) (add|del)"
+ " (mac_addr|mac_ignr) (mac_address) ethertype"
+ " (ether_type) (drop|fwd) queue (queue_id)\n"
+ " Add/Del an ethertype filter.\n\n"
"add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
" dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
@@ -7264,135 +7259,6 @@ cmdline_parse_inst_t cmd_dump_one = {
},
};
-/* *** ADD/REMOVE an ethertype FILTER *** */
-struct cmd_ethertype_filter_result {
- cmdline_fixed_string_t filter;
- uint8_t port_id;
- cmdline_fixed_string_t ethertype;
- uint16_t ethertype_value;
- cmdline_fixed_string_t priority;
- cmdline_fixed_string_t priority_en;
- uint8_t priority_value;
- cmdline_fixed_string_t queue;
- uint16_t queue_id;
- cmdline_fixed_string_t index;
- uint16_t index_value;
-};
-
-static void
-cmd_ethertype_filter_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- int ret = 0;
- struct cmd_ethertype_filter_result *res = parsed_result;
- struct rte_ethertype_filter filter;
-
- memset(&filter, 0, sizeof(struct rte_ethertype_filter));
- filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
- filter.priority = res->priority_value;
-
- if (!strcmp(res->priority_en, "enable"))
- filter.priority_en = 1;
- if (!strcmp(res->filter, "add_ethertype_filter"))
- ret = rte_eth_dev_add_ethertype_filter(res->port_id,
- res->index_value,
- &filter, res->queue_id);
- else if (!strcmp(res->filter, "remove_ethertype_filter"))
- ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
- res->index_value);
- else if (!strcmp(res->filter, "get_ethertype_filter"))
- get_ethertype_filter(res->port_id, res->index_value);
-
- if (ret < 0)
- printf("ethertype filter setting error: (%s)\n",
- strerror(-ret));
-}
-
-cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- port_id, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype, "ethertype");
-cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_priority =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- priority, "priority");
-cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- priority_en, "enable#disable");
-cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- priority_value, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- queue, "queue");
-cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- queue_id, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_index =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- index, "index");
-cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- index_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "add_ethertype_filter");
-cmdline_parse_inst_t cmd_add_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "add an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_add_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_ethertype,
- (void *)&cmd_ethertype_filter_ethertype_value,
- (void *)&cmd_ethertype_filter_priority,
- (void *)&cmd_ethertype_filter_priority_en,
- (void *)&cmd_ethertype_filter_priority_value,
- (void *)&cmd_ethertype_filter_queue,
- (void *)&cmd_ethertype_filter_queue_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-
-cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "remove_ethertype_filter");
-cmdline_parse_inst_t cmd_remove_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "remove an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_remove_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "get_ethertype_filter");
-cmdline_parse_inst_t cmd_get_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "get an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_get_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-
/* *** set SYN filter *** */
struct cmd_set_syn_filter_result {
cmdline_fixed_string_t filter;
@@ -8096,6 +7962,113 @@ cmdline_parse_inst_t cmd_get_flex_filter = {
/* *** Filters Control *** */
+/* *** deal with ethertype filter *** */
+struct cmd_ethertype_filter_result {
+ cmdline_fixed_string_t filter;
+ uint8_t port_id;
+ cmdline_fixed_string_t ops;
+ cmdline_fixed_string_t mac;
+ struct ether_addr mac_addr;
+ cmdline_fixed_string_t ethertype;
+ uint16_t ethertype_value;
+ cmdline_fixed_string_t drop;
+ cmdline_fixed_string_t queue;
+ uint16_t queue_id;
+};
+
+cmdline_parse_token_string_t cmd_ethertype_filter_filter =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ filter, "ethertype_filter");
+cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ port_id, UINT8);
+cmdline_parse_token_string_t cmd_ethertype_filter_ops =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ ops, "add#del");
+cmdline_parse_token_string_t cmd_ethertype_filter_mac =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ mac, "mac_addr#mac_ignr");
+cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
+ TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
+ mac_addr);
+cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ ethertype, "ethertype");
+cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ ethertype_value, UINT16);
+cmdline_parse_token_string_t cmd_ethertype_filter_drop =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ drop, "drop#fwd");
+cmdline_parse_token_string_t cmd_ethertype_filter_queue =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ queue, "queue");
+cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ queue_id, UINT16);
+
+static void
+cmd_ethertype_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_ethertype_filter_result *res = parsed_result;
+ struct rte_eth_ethertype_filter filter;
+ int ret = 0;
+
+ ret = rte_eth_dev_filter_supported(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE);
+ if (ret < 0) {
+ printf("ethertype filter is not supported on port %u.\n",
+ res->port_id);
+ return;
+ }
+
+ memset(&filter, 0, sizeof(filter));
+ if (!strcmp(res->mac, "mac_addr")) {
+ filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
+ (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
+ sizeof(struct ether_addr));
+ }
+ if (!strcmp(res->drop, "drop"))
+ filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
+ filter.ether_type = res->ethertype_value;
+ filter.queue = res->queue_id;
+
+ if (!strcmp(res->ops, "add"))
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE,
+ RTE_ETH_FILTER_ADD,
+ &filter);
+ else
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE,
+ RTE_ETH_FILTER_DELETE,
+ &filter);
+ if (ret < 0)
+ printf("ethertype filter programming error: (%s)\n",
+ strerror(-ret));
+}
+
+cmdline_parse_inst_t cmd_ethertype_filter = {
+ .f = cmd_ethertype_filter_parsed,
+ .data = NULL,
+ .help_str = "add or delete an ethertype filter entry",
+ .tokens = {
+ (void *)&cmd_ethertype_filter_filter,
+ (void *)&cmd_ethertype_filter_port_id,
+ (void *)&cmd_ethertype_filter_ops,
+ (void *)&cmd_ethertype_filter_mac,
+ (void *)&cmd_ethertype_filter_mac_addr,
+ (void *)&cmd_ethertype_filter_ethertype,
+ (void *)&cmd_ethertype_filter_ethertype_value,
+ (void *)&cmd_ethertype_filter_drop,
+ (void *)&cmd_ethertype_filter_queue,
+ (void *)&cmd_ethertype_filter_queue_id,
+ NULL,
+ },
+};
+
/* *** deal with flow director filter *** */
struct cmd_flow_director_result {
cmdline_fixed_string_t flow_director_filter;
@@ -8815,9 +8788,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_dump,
(cmdline_parse_inst_t *)&cmd_dump_one,
- (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
- (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
- (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
+ (cmdline_parse_inst_t *)&cmd_ethertype_filter,
(cmdline_parse_inst_t *)&cmd_add_syn_filter,
(cmdline_parse_inst_t *)&cmd_remove_syn_filter,
(cmdline_parse_inst_t *)&cmd_get_syn_filter,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97b6525..c40f819 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2166,33 +2166,6 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk)
}
void
-get_ethertype_filter(uint8_t port_id, uint16_t index)
-{
- struct rte_ethertype_filter filter;
- int ret = 0;
- uint16_t rx_queue;
-
- memset(&filter, 0, sizeof(filter));
- ret = rte_eth_dev_get_ethertype_filter(port_id, index,
- &filter, &rx_queue);
- if (ret < 0) {
- if (ret == (-ENOENT))
- printf("filter[%d] is not enabled\n", index);
- else
- printf("get ethertype filter fails(%s)\n", strerror(-ret));
- return;
- } else {
- printf("filter[%d]:\n", index);
- printf(" ethertype: 0x%04x\n",
- rte_le_to_cpu_32(filter.ethertype));
- printf(" priority: %s, %d\n",
- filter.priority_en ? "enable" : "disable",
- filter.priority);
- printf(" queue: %d\n", rx_queue);
- }
-}
-
-void
get_syn_filter(uint8_t port_id)
{
struct rte_syn_filter filter;
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH 4/4] ethdev: remove old APIs and structures of ethertype filter
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
` (2 preceding siblings ...)
2014-12-25 3:14 ` [dpdk-dev] [PATCH 3/4] testpmd: new commands for ethertype filter Jingjing Wu
@ 2014-12-25 3:14 ` Jingjing Wu
2014-12-25 3:27 ` [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Qiu, Michael
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
5 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2014-12-25 3:14 UTC (permalink / raw)
To: dev
Struct rte_ethertype_filter is removed.
Following APIs are removed:
- rte_eth_dev_add_ethertype_filter
- rte_eth_dev_remove_ethertype_filter
- rte_eth_dev_get_ethertype_filter
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_ether/rte_ethdev.c | 57 ----------------------------
lib/librte_ether/rte_ethdev.h | 88 -------------------------------------------
2 files changed, 145 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 95f2ceb..b55fab2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3015,63 +3015,6 @@ rte_eth_dev_get_syn_filter(uint8_t port_id,
}
int
-rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
- if (filter->ethertype == ETHER_TYPE_IPv4 ||
- filter->ethertype == ETHER_TYPE_IPv6){
- PMD_DEBUG_TRACE("IP and IPv6 are not supported"
- " in ethertype filter\n");
- return -EINVAL;
- }
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->add_ethertype_filter)(dev, index,
- filter, rx_queue);
-}
-
-int
-rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->remove_ethertype_filter)(dev, index);
-}
-
-int
-rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue)
-{
- struct rte_eth_dev *dev;
-
- if (filter == NULL || rx_queue == NULL)
- return -EINVAL;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->get_ethertype_filter)(dev, index,
- filter, rx_queue);
-}
-
-int
rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,
struct rte_2tuple_filter *filter, uint16_t rx_queue)
{
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ce0528f..1200c1c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -972,15 +972,6 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
#define TCP_FLAG_ALL 0x3F
/**
- * A structure used to define an ethertype filter.
- */
-struct rte_ethertype_filter {
- uint16_t ethertype; /**< little endian. */
- uint8_t priority_en; /**< compare priority enable. */
- uint8_t priority;
-};
-
-/**
* A structure used to define an syn filter.
*/
struct rte_syn_filter {
@@ -1372,20 +1363,6 @@ typedef int (*eth_get_syn_filter_t)(struct rte_eth_dev *dev,
struct rte_syn_filter *filter, uint16_t *rx_queue);
/**< @internal Get syn filter rule on an Ethernet device */
-typedef int (*eth_add_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t rx_queue);
-/**< @internal Setup a new ethertype filter rule on an Ethernet device */
-
-typedef int (*eth_remove_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index);
-/**< @internal Remove an ethertype filter rule on an Ethernet device */
-
-typedef int (*eth_get_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t *rx_queue);
-/**< @internal Get an ethertype filter rule on an Ethernet device */
-
typedef int (*eth_add_2tuple_filter_t)(struct rte_eth_dev *dev,
uint16_t index, struct rte_2tuple_filter *filter,
uint16_t rx_queue);
@@ -1532,9 +1509,6 @@ struct eth_dev_ops {
eth_add_syn_filter_t add_syn_filter; /**< add syn filter. */
eth_remove_syn_filter_t remove_syn_filter; /**< remove syn filter. */
eth_get_syn_filter_t get_syn_filter; /**< get syn filter. */
- eth_add_ethertype_filter_t add_ethertype_filter; /**< add ethertype filter. */
- eth_remove_ethertype_filter_t remove_ethertype_filter; /**< remove ethertype filter. */
- eth_get_ethertype_filter_t get_ethertype_filter; /**< get ethertype filter. */
eth_add_2tuple_filter_t add_2tuple_filter; /**< add 2tuple filter. */
eth_remove_2tuple_filter_t remove_2tuple_filter; /**< remove 2tuple filter. */
eth_get_2tuple_filter_t get_2tuple_filter; /**< get 2tuple filter. */
@@ -3474,68 +3448,6 @@ int rte_eth_dev_get_syn_filter(uint8_t port_id,
struct rte_syn_filter *filter, uint16_t *rx_queue);
/**
- * Add a new ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @param filter
- * The pointer to the structure describing the ethertype filter rule.
- * The *rte_ethertype_filter* structure includes the values of the different
- * fields to match: ethertype and priority in vlan tag.
- * priority in vlan tag is not supported for E1000 dev.
- * @param rx_queue
- * The index of the RX queue where to store RX packets matching the added
- * ethertype filter.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- */
-int rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-
-/**
- * remove an ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- */
-int rte_eth_dev_remove_ethertype_filter(uint8_t port_id,
- uint16_t index);
-
-/**
- * Get an ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @param filter
- * A pointer to a structure of type *rte_ethertype_filter* to be filled with
- * the information of the Ethertype filter.
- * @param rx_queue
- * A pointer to get the queue index.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- * - (-ENOENT) if no enabled filter in this index.
- */
-int rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
-
-/**
* Add a new 2tuple filter rule on an Ethernet device.
*
* @param port_id
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
` (3 preceding siblings ...)
2014-12-25 3:14 ` [dpdk-dev] [PATCH 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
@ 2014-12-25 3:27 ` Qiu, Michael
2014-12-25 3:39 ` Wu, Jingjing
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
5 siblings, 1 reply; 17+ messages in thread
From: Qiu, Michael @ 2014-12-25 3:27 UTC (permalink / raw)
To: Wu, Jingjing, dev
Hi Jingjing,
Would you mind to tell me why need new APIs? Any functional or
performance increase?
Better to state in commit log.
You know it should be careful to change APIs, especially for user
interface.
Thanks,
Michael
On 12/25/2014 11:14 AM, Jingjing Wu wrote:
> The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
> It uses new functions and structure to replace old ones in igb/ixgbe driver,
> new commands to replace old ones in testpmd, and removes the old APIs.
>
> Jingjing Wu (4):
> ixgbe: new functions replaces old ones for ethertype filters
> e1000: new functions replaces old ones for ethertype filters
> testpmd: new commands for ethertype filter
> ethdev: remove old APIs and structures of ethertype filters
>
> app/test-pmd/cmdline.c | 253 ++++++++++++--------------
> app/test-pmd/config.c | 27 ---
> lib/librte_ether/rte_ethdev.c | 57 ------
> lib/librte_ether/rte_ethdev.h | 88 ---------
> lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
> lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++------------
> lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354 +++++++++++++++++++++++-------------
> lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
> 8 files changed, 579 insertions(+), 558 deletions(-)
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2014-12-25 3:27 ` [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Qiu, Michael
@ 2014-12-25 3:39 ` Wu, Jingjing
2014-12-25 4:57 ` Qiu, Michael
0 siblings, 1 reply; 17+ messages in thread
From: Wu, Jingjing @ 2014-12-25 3:39 UTC (permalink / raw)
To: Qiu, Michael, dev
Hi, Michael
It's a long discuss in community.
Due to in the development in i40e driver, we defined a new common API used for kinds of filters. In R1.8, because of time limit and compatibility, we just used the new API for i40e driver. While other driver still use old ones.
We have planned to integrate filter to this new API to make the APIs generic for different types of NICs.
Jingjing
> -----Original Message-----
> From: Qiu, Michael
> Sent: Thursday, December 25, 2014 11:27 AM
> To: Wu, Jingjing; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe
> driver to new API
>
> Hi Jingjing,
>
> Would you mind to tell me why need new APIs? Any functional or
> performance increase?
> Better to state in commit log.
>
> You know it should be careful to change APIs, especially for user interface.
>
> Thanks,
> Michael
> On 12/25/2014 11:14 AM, Jingjing Wu wrote:
> > The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
> > It uses new functions and structure to replace old ones in igb/ixgbe
> > driver, new commands to replace old ones in testpmd, and removes the
> old APIs.
> >
> > Jingjing Wu (4):
> > ixgbe: new functions replaces old ones for ethertype filters
> > e1000: new functions replaces old ones for ethertype filters
> > testpmd: new commands for ethertype filter
> > ethdev: remove old APIs and structures of ethertype filters
> >
> > app/test-pmd/cmdline.c | 253 ++++++++++++--------------
> > app/test-pmd/config.c | 27 ---
> > lib/librte_ether/rte_ethdev.c | 57 ------
> > lib/librte_ether/rte_ethdev.h | 88 ---------
> > lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
> > lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++-----
> -------
> > lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354
> > +++++++++++++++++++++++-------------
> > lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
> > 8 files changed, 579 insertions(+), 558 deletions(-)
> >
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2014-12-25 3:39 ` Wu, Jingjing
@ 2014-12-25 4:57 ` Qiu, Michael
0 siblings, 0 replies; 17+ messages in thread
From: Qiu, Michael @ 2014-12-25 4:57 UTC (permalink / raw)
To: Wu, Jingjing, dev
On 12/25/2014 11:39 AM, Wu, Jingjing wrote:
> Hi, Michael
>
> It's a long discuss in community.
>
> Due to in the development in i40e driver, we defined a new common API used for kinds of filters. In R1.8, because of time limit and compatibility, we just used the new API for i40e driver. While other driver still use old ones.
> We have planned to integrate filter to this new API to make the APIs generic for different types of NICs.
OK, got it, sorry for missing the old thread :)
If you will have new version patch, I would like you add the statement
to the commit log, it could be better for other to understand why :)
Thanks,
Michael
> Jingjing
>
>
>> -----Original Message-----
>> From: Qiu, Michael
>> Sent: Thursday, December 25, 2014 11:27 AM
>> To: Wu, Jingjing; dev@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe
>> driver to new API
>>
>> Hi Jingjing,
>>
>> Would you mind to tell me why need new APIs? Any functional or
>> performance increase?
>> Better to state in commit log.
>>
>> You know it should be careful to change APIs, especially for user interface.
>>
>> Thanks,
>> Michael
>> On 12/25/2014 11:14 AM, Jingjing Wu wrote:
>>> The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
>>> It uses new functions and structure to replace old ones in igb/ixgbe
>>> driver, new commands to replace old ones in testpmd, and removes the
>> old APIs.
>>> Jingjing Wu (4):
>>> ixgbe: new functions replaces old ones for ethertype filters
>>> e1000: new functions replaces old ones for ethertype filters
>>> testpmd: new commands for ethertype filter
>>> ethdev: remove old APIs and structures of ethertype filters
>>>
>>> app/test-pmd/cmdline.c | 253 ++++++++++++--------------
>>> app/test-pmd/config.c | 27 ---
>>> lib/librte_ether/rte_ethdev.c | 57 ------
>>> lib/librte_ether/rte_ethdev.h | 88 ---------
>>> lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
>>> lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++-----
>> -------
>>> lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354
>>> +++++++++++++++++++++++-------------
>>> lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
>>> 8 files changed, 579 insertions(+), 558 deletions(-)
>>>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters
2014-12-25 3:14 ` [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters Jingjing Wu
@ 2015-01-12 1:32 ` Zhang, Helin
0 siblings, 0 replies; 17+ messages in thread
From: Zhang, Helin @ 2015-01-12 1:32 UTC (permalink / raw)
To: Wu, Jingjing, dev
> -----Original Message-----
> From: Wu, Jingjing
> Sent: Thursday, December 25, 2014 11:14 AM
> To: dev@dpdk.org
> Cc: Wu, Jingjing; Zhang, Helin; Cao, Waterman
> Subject: [PATCH 2/4] e1000: new functions replace old ones for ethertype filters
>
> This patch removes old functions which deal with ethertype filters in ixgbe
> driver.
> It also defines eth_igb_filter_ctrl which is binding to filter_ctrl API, and
> ethertype filter can be dealt with through this new entrance.
>
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
> lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
> lib/librte_pmd_e1000/igb_ethdev.c | 332
> +++++++++++++++++++++++-------------
> 2 files changed, 228 insertions(+), 117 deletions(-)
>
> diff --git a/lib/librte_pmd_e1000/e1000_ethdev.h
> b/lib/librte_pmd_e1000/e1000_ethdev.h
> index 71eb5fb..d155e77 100644
> --- a/lib/librte_pmd_e1000/e1000_ethdev.h
> +++ b/lib/librte_pmd_e1000/e1000_ethdev.h
> @@ -132,6 +132,15 @@ struct e1000_vf_info { };
>
> /*
> + * Structure to store filters' info.
> + */
> +struct e1000_filter_info {
> + uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
> + /* store used ethertype filters*/
> + uint16_t ethertype_filters[E1000_MAX_ETQF_FILTERS];
> +};
> +
> +/*
> * Structure to store private data for each driver instance (for each port).
> */
> struct e1000_adapter {
> @@ -140,6 +149,7 @@ struct e1000_adapter {
> struct e1000_interrupt intr;
> struct e1000_vfta shadow_vfta;
> struct e1000_vf_info *vfdata;
> + struct e1000_filter_info filter;
> };
>
> #define E1000_DEV_PRIVATE_TO_HW(adapter) \ @@ -157,6 +167,9 @@
> struct e1000_adapter { #define E1000_DEV_PRIVATE_TO_P_VFDATA(adapter)
> \
> (&((struct e1000_adapter *)adapter)->vfdata)
>
> +#define E1000_DEV_PRIVATE_TO_FILTER_INFO(adapter) \
> + (&((struct e1000_adapter *)adapter)->filter)
> +
> /*
> * RX/TX IGB function prototypes
> */
> diff --git a/lib/librte_pmd_e1000/igb_ethdev.c
> b/lib/librte_pmd_e1000/igb_ethdev.c
> index 873d65e..3c549aa 100644
> --- a/lib/librte_pmd_e1000/igb_ethdev.c
> +++ b/lib/librte_pmd_e1000/igb_ethdev.c
> @@ -154,14 +154,6 @@ static int eth_igb_add_syn_filter(struct rte_eth_dev
> *dev, static int eth_igb_remove_syn_filter(struct rte_eth_dev *dev); static
> int eth_igb_get_syn_filter(struct rte_eth_dev *dev,
> struct rte_syn_filter *filter, uint16_t *rx_queue); -static int
> eth_igb_add_ethertype_filter(struct rte_eth_dev *dev,
> - uint16_t index,
> - struct rte_ethertype_filter *filter, uint16_t rx_queue);
> -static int eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev,
> - uint16_t index);
> -static int eth_igb_get_ethertype_filter(struct rte_eth_dev *dev,
> - uint16_t index,
> - struct rte_ethertype_filter *filter, uint16_t *rx_queue);
> static int eth_igb_add_2tuple_filter(struct rte_eth_dev *dev,
> uint16_t index,
> struct rte_2tuple_filter *filter, uint16_t rx_queue); @@ -186,6
> +178,18 @@ static int eth_igb_remove_5tuple_filter(struct rte_eth_dev *dev,
> static int eth_igb_get_5tuple_filter(struct rte_eth_dev *dev,
> uint16_t index,
> struct rte_5tuple_filter *filter, uint16_t *rx_queue);
> +static int igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
> + struct rte_eth_ethertype_filter *filter,
> + bool add);
> +static int igb_ethertype_filter_handle(struct rte_eth_dev *dev,
> + enum rte_filter_op filter_op,
> + void *arg);
> +static int igb_get_ethertype_filter(struct rte_eth_dev *dev,
> + struct rte_eth_ethertype_filter *filter); static int
> +eth_igb_filter_ctrl(struct rte_eth_dev *dev,
> + enum rte_filter_type filter_type,
> + enum rte_filter_op filter_op,
> + void *arg);
>
> /*
> * Define VF Stats MACRO for Non "cleared on read" register @@ -264,9
> +268,6 @@ static struct eth_dev_ops eth_igb_ops = {
> .add_syn_filter = eth_igb_add_syn_filter,
> .remove_syn_filter = eth_igb_remove_syn_filter,
> .get_syn_filter = eth_igb_get_syn_filter,
> - .add_ethertype_filter = eth_igb_add_ethertype_filter,
> - .remove_ethertype_filter = eth_igb_remove_ethertype_filter,
> - .get_ethertype_filter = eth_igb_get_ethertype_filter,
> .add_2tuple_filter = eth_igb_add_2tuple_filter,
> .remove_2tuple_filter = eth_igb_remove_2tuple_filter,
> .get_2tuple_filter = eth_igb_get_2tuple_filter,
> @@ -276,6 +277,7 @@ static struct eth_dev_ops eth_igb_ops = {
> .add_5tuple_filter = eth_igb_add_5tuple_filter,
> .remove_5tuple_filter = eth_igb_remove_5tuple_filter,
> .get_5tuple_filter = eth_igb_get_5tuple_filter,
> + .filter_ctrl = eth_igb_filter_ctrl,
> };
>
> /*
> @@ -2388,7 +2390,7 @@ eth_igb_rss_reta_query(struct rte_eth_dev *dev,
> #define MAC_TYPE_FILTER_SUP(type) do {\
> if ((type) != e1000_82580 && (type) != e1000_i350 &&\
> (type) != e1000_82576)\
> - return -ENOSYS;\
> + return -ENOTSUP;\
> } while (0)
>
> /*
> @@ -2485,111 +2487,6 @@ eth_igb_get_syn_filter(struct rte_eth_dev *dev,
> return -ENOENT;
> }
>
> -/*
> - * add an ethertype filter
> - *
> - * @param
> - * dev: Pointer to struct rte_eth_dev.
> - * index: the index the filter allocates.
> - * 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.
> - */
> -static int
> -eth_igb_add_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
> - struct rte_ethertype_filter *filter, uint16_t rx_queue)
> -{
> - struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> - uint32_t etqf;
> -
> - MAC_TYPE_FILTER_SUP(hw->mac.type);
> -
> - if (index >= E1000_MAX_ETQF_FILTERS || rx_queue >=
> IGB_MAX_RX_QUEUE_NUM)
> - return -EINVAL;
> -
> - etqf = E1000_READ_REG(hw, E1000_ETQF(index));
> - if (etqf & E1000_ETQF_FILTER_ENABLE)
> - return -EINVAL; /* filter index is in use. */
> - else
> - etqf = 0;
> -
> - etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
> - etqf |= (uint32_t)(filter->ethertype & E1000_ETQF_ETHERTYPE);
> - etqf |= rx_queue << E1000_ETQF_QUEUE_SHIFT;
> -
> - if (filter->priority_en) {
> - PMD_INIT_LOG(ERR, "vlan and priority (%d) is not supported"
> - " in E1000.", filter->priority);
> - return -EINVAL;
> - }
> -
> - E1000_WRITE_REG(hw, E1000_ETQF(index), etqf);
> - return 0;
> -}
> -
> -/*
> - * remove an ethertype filter
> - *
> - * @param
> - * dev: Pointer to struct rte_eth_dev.
> - * index: the index the filter allocates.
> - *
> - * @return
> - * - On success, zero.
> - * - On failure, a negative value.
> - */
> -static int
> -eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev, uint16_t index) -{
> - struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> -
> - MAC_TYPE_FILTER_SUP(hw->mac.type);
> -
> - if (index >= E1000_MAX_ETQF_FILTERS)
> - return -EINVAL;
> -
> - E1000_WRITE_REG(hw, E1000_ETQF(index), 0);
> - return 0;
> -}
> -
> -/*
> - * get an ethertype filter
> - *
> - * @param
> - * dev: Pointer to struct rte_eth_dev.
> - * index: the index the filter allocates.
> - * filter: ponter to the filter that will be gotten.
> - * *rx_queue: the ponited of the queue id the filter assigned to.
> - *
> - * @return
> - * - On success, zero.
> - * - On failure, a negative value.
> - */
> -static int
> -eth_igb_get_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
> - struct rte_ethertype_filter *filter, uint16_t *rx_queue)
> -{
> - struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> - uint32_t etqf;
> -
> - MAC_TYPE_FILTER_SUP(hw->mac.type);
> -
> - if (index >= E1000_MAX_ETQF_FILTERS)
> - return -EINVAL;
> -
> - etqf = E1000_READ_REG(hw, E1000_ETQF(index));
> - if (etqf & E1000_ETQF_FILTER_ENABLE) {
> - filter->ethertype = etqf & E1000_ETQF_ETHERTYPE;
> - filter->priority_en = 0;
> - *rx_queue = (etqf & E1000_ETQF_QUEUE) >>
> E1000_ETQF_QUEUE_SHIFT;
> - return 0;
> - }
> - return -ENOENT;
> -}
> -
> #define MAC_TYPE_FILTER_SUP_EXT(type) do {\
> if ((type) != e1000_82580 && (type) != e1000_i350)\
> return -ENOSYS; \
> @@ -3149,6 +3046,207 @@ eth_igb_mtu_set(struct rte_eth_dev *dev,
> uint16_t mtu)
> return 0;
> }
>
> +static inline int
> +igb_ethertype_filter_lookup(struct e1000_filter_info *filter_info,
> + uint16_t ethertype)
> +{
> + int i;
> +
> + for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
> + if (filter_info->ethertype_filters[i] == ethertype &&
> + (filter_info->ethertype_mask & (1 << i)))
> + return i;
> + }
> + return -1;
> +}
> +
> +static inline int
> +igb_ethertype_filter_insert(struct e1000_filter_info *filter_info,
> + uint16_t ethertype)
> +{
> + int i;
> +
> + for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
> + if (!(filter_info->ethertype_mask & (1 << i))) {
> + filter_info->ethertype_mask |= 1 << i;
> + filter_info->ethertype_filters[i] = ethertype;
> + return i;
> + }
> + }
> + return -1;
> +}
> +
> +static inline int
> +igb_ethertype_filter_remove(struct e1000_filter_info *filter_info,
> + uint8_t idx)
> +{
> + if (idx >= E1000_MAX_ETQF_FILTERS)
> + return -1;
> + filter_info->ethertype_mask &= ~(1 << idx);
> + filter_info->ethertype_filters[idx] = 0;
> + return idx;
> +}
> +
> +
> +static int
> +igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
> + struct rte_eth_ethertype_filter *filter,
> + bool add)
> +{
> + struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + struct e1000_filter_info *filter_info =
> + E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
> + uint32_t etqf = 0;
> + int ret;
> +
> + if (filter->ether_type == ETHER_TYPE_IPv4 ||
> + filter->ether_type == ETHER_TYPE_IPv6) {
> + PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
> + " ethertype filter.", filter->ether_type);
> + return -EINVAL;
> + }
> +
> + if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
> + PMD_DRV_LOG(ERR, "mac compare is unsupported.");
> + return -EINVAL;
> + }
> + if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
> + PMD_DRV_LOG(ERR, "drop option is unsupported.");
> + return -EINVAL;
> + }
> +
> + ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
> + if (ret >= 0 && add) {
> + PMD_DRV_LOG(WARNING, "ethertype (0x%04x) filter exists.",
> + filter->ether_type);
> + return ret;
Will the value be returned to the top-most user application? If yes, what's the
meaning of the return value for application?
It might be better to just return 0 or negative values to the top-most interfaces.
> + }
> + if (ret < 0 && !add) {
> + PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
> + filter->ether_type);
> + return -ENOENT;
> + }
> +
> + if (add) {
> + ret = igb_ethertype_filter_insert(filter_info,
> + filter->ether_type);
> + if (ret < 0) {
> + PMD_DRV_LOG(ERR, "ethertype filters are full.");
> + return -ENOSYS;
> + }
> +
> + etqf |= E1000_ETQF_FILTER_ENABLE |
> E1000_ETQF_QUEUE_ENABLE;
> + etqf |= (uint32_t)(filter->ether_type & E1000_ETQF_ETHERTYPE);
> + etqf |= filter->queue << E1000_ETQF_QUEUE_SHIFT;
> + } else {
> + ret = igb_ethertype_filter_remove(filter_info, (uint8_t)ret);
> + if (ret < 0)
> + return -ENOSYS;
> + }
> + E1000_WRITE_REG(hw, E1000_ETQF(ret), etqf);
> + E1000_WRITE_FLUSH(hw);
> +
> + return 0;
> +}
> +
> +static int
> +igb_get_ethertype_filter(struct rte_eth_dev *dev,
> + struct rte_eth_ethertype_filter *filter) {
> + struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + struct e1000_filter_info *filter_info =
> + E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
> + uint32_t etqf;
> + int ret;
> +
> + ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
> + if (ret < 0) {
> + PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
> + filter->ether_type);
> + return -ENOENT;
> + }
> +
> + etqf = E1000_READ_REG(hw, E1000_ETQF(ret));
> + if (etqf & E1000_ETQF_FILTER_ENABLE) {
> + filter->ether_type = etqf & E1000_ETQF_ETHERTYPE;
> + filter->flags = 0;
> + filter->queue = (etqf & E1000_ETQF_QUEUE) >>
> + E1000_ETQF_QUEUE_SHIFT;
> + return 0;
> + }
> +
> + return -ENOENT;
> +}
> +
> +/*
> + * igb_ethertype_filter_handle - Handle operations for ethertype filter.
> + * @dev: pointer to rte_eth_dev structure
> + * @filter_op:operation will be taken.
> + * @arg: a pointer to specific structure corresponding to the filter_op
> +*/ static int igb_ethertype_filter_handle(struct rte_eth_dev *dev,
> + enum rte_filter_op filter_op,
> + void *arg)
> +{
> + struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + int ret;
> +
> + MAC_TYPE_FILTER_SUP(hw->mac.type);
> +
> + 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;
> + }
> +
> + switch (filter_op) {
> + case RTE_ETH_FILTER_ADD:
> + ret = igb_add_del_ethertype_filter(dev,
> + (struct rte_eth_ethertype_filter *)arg,
> + TRUE);
> + break;
> + case RTE_ETH_FILTER_DELETE:
> + ret = igb_add_del_ethertype_filter(dev,
> + (struct rte_eth_ethertype_filter *)arg,
> + FALSE);
> + break;
> + case RTE_ETH_FILTER_GET:
> + ret = igb_get_ethertype_filter(dev,
> + (struct rte_eth_ethertype_filter *)arg);
> + break;
> + default:
> + PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
> + ret = -EINVAL;
> + break;
> + }
> + return ret;
> +}
> +
> +static int
> +eth_igb_filter_ctrl(struct rte_eth_dev *dev,
> + enum rte_filter_type filter_type,
> + enum rte_filter_op filter_op,
> + void *arg)
> +{
> + int ret = -EINVAL;
> +
> + switch (filter_type) {
> + case RTE_ETH_FILTER_ETHERTYPE:
> + ret = igb_ethertype_filter_handle(dev, filter_op, arg);
> + break;
> + default:
> + PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
> + filter_type);
> + break;
> + }
> +
> + return ret;
> +}
> +
> static struct rte_driver pmd_igb_drv = {
> .type = PMD_PDEV,
> .init = rte_igb_pmd_init,
> --
> 1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
` (4 preceding siblings ...)
2014-12-25 3:27 ` [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Qiu, Michael
@ 2015-01-12 7:16 ` Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
` (4 more replies)
5 siblings, 5 replies; 17+ messages in thread
From: Jingjing Wu @ 2015-01-12 7:16 UTC (permalink / raw)
To: dev
v2 changes:
change the return value if adding an existing filter from the filter's index to negative value.
The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
It uses new functions and structure to replace old ones in igb/ixgbe driver, new commands to replace old ones in testpmd, and removes the old APIs.
Jingjing Wu (4):
ixgbe: new functions replace old ones for ethertype filter
e1000: new functions replace old ones for ethertype filter
testpmd: new commands for ethertype filter
ethdev: remove old APIs and structures of ethertype filter
app/test-pmd/cmdline.c | 253 ++++++++++++--------------
app/test-pmd/config.c | 27 ---
lib/librte_ether/rte_ethdev.c | 57 ------
lib/librte_ether/rte_ethdev.h | 88 ---------
lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354 +++++++++++++++++++++++-------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
8 files changed, 579 insertions(+), 558 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
@ 2015-01-12 7:16 ` Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 2/4] e1000: " Jingjing Wu
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2015-01-12 7:16 UTC (permalink / raw)
To: dev
This patch removes old functions which deal with ethertype filter in ixgbe driver.
It also defines ixgbe_dev_filter_ctrl which is binding to filter_ctrl API,
and ethertype filter can be dealt with through this new entrance.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354 +++++++++++++++++++++++-------------
lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
2 files changed, 239 insertions(+), 128 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 3fc3738..b58ec45 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -231,12 +231,6 @@ static int ixgbe_add_syn_filter(struct rte_eth_dev *dev,
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_add_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-static int ixgbe_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index);
-static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
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,
@@ -245,6 +239,18 @@ static int ixgbe_get_5tuple_filter(struct rte_eth_dev *dev, uint16_t index,
struct rte_5tuple_filter *filter, uint16_t *rx_queue);
static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
+static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add);
+static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg);
+static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter);
+static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg);
/*
* Define VF Stats MACRO for Non "cleared on read" register
@@ -380,12 +386,10 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
.add_syn_filter = ixgbe_add_syn_filter,
.remove_syn_filter = ixgbe_remove_syn_filter,
.get_syn_filter = ixgbe_get_syn_filter,
- .add_ethertype_filter = ixgbe_add_ethertype_filter,
- .remove_ethertype_filter = ixgbe_remove_ethertype_filter,
- .get_ethertype_filter = ixgbe_get_ethertype_filter,
.add_5tuple_filter = ixgbe_add_5tuple_filter,
.remove_5tuple_filter = ixgbe_remove_5tuple_filter,
.get_5tuple_filter = ixgbe_get_5tuple_filter,
+ .filter_ctrl = ixgbe_dev_filter_ctrl,
};
/*
@@ -3774,125 +3778,6 @@ ixgbe_get_syn_filter(struct rte_eth_dev *dev,
return -ENOENT;
}
-/*
- * add an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * 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.
- */
-static int
-ixgbe_add_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t rx_queue)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf, etqs = 0;
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS ||
- rx_queue >= IXGBE_MAX_RX_QUEUE_NUM)
- return -EINVAL;
-
- etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(index));
- if (etqf & IXGBE_ETQF_FILTER_EN)
- return -EINVAL; /* filter index is in use. */
-
- etqf = 0;
- etqf |= IXGBE_ETQF_FILTER_EN;
- etqf |= (uint32_t)filter->ethertype;
-
- if (filter->priority_en) {
- if (filter->priority > IXGBE_ETQF_MAX_PRI)
- return -EINVAL;
- etqf |= (uint32_t)((filter->priority << IXGBE_ETQF_SHIFT) & IXGBE_ETQF_UP);
- etqf |= IXGBE_ETQF_UP_EN;
- }
- etqs |= (uint32_t)((rx_queue << IXGBE_ETQS_RX_QUEUE_SHIFT) & IXGBE_ETQS_RX_QUEUE);
- etqs |= IXGBE_ETQS_QUEUE_EN;
-
- IXGBE_WRITE_REG(hw, IXGBE_ETQF(index), etqf);
- IXGBE_WRITE_REG(hw, IXGBE_ETQS(index), etqs);
- return 0;
-}
-
-/*
- * remove an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-ixgbe_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- IXGBE_WRITE_REG(hw, IXGBE_ETQF(index), 0);
- IXGBE_WRITE_REG(hw, IXGBE_ETQS(index), 0);
-
- return 0;
-}
-
-/*
- * get an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * filter: ponter to the filter that will be gotten.
- * *rx_queue: the ponited of the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t *rx_queue)
-{
- struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf, etqs;
-
- if (hw->mac.type != ixgbe_mac_82599EB)
- return -ENOSYS;
-
- if (index >= IXGBE_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(index));
- etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(index));
- if (etqf & IXGBE_ETQF_FILTER_EN) {
- filter->ethertype = etqf & IXGBE_ETQF_ETHERTYPE;
- filter->priority_en = (etqf & IXGBE_ETQF_UP_EN) ? 1 : 0;
- if (filter->priority_en)
- filter->priority = (etqf & IXGBE_ETQF_UP) >> 16;
- *rx_queue = (etqs & IXGBE_ETQS_RX_QUEUE) >> IXGBE_ETQS_RX_QUEUE_SHIFT;
- return 0;
- }
- return -ENOENT;
-}
-
static inline enum ixgbe_5tuple_protocol
convert_protocol_type(uint8_t protocol_value)
{
@@ -4119,6 +4004,219 @@ 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)
+{
+ int i;
+
+ for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
+ if (filter_info->ethertype_filters[i] == ethertype &&
+ (filter_info->ethertype_mask & (1 << i)))
+ return i;
+ }
+ return -1;
+}
+
+static inline int
+ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
+ if (!(filter_info->ethertype_mask & (1 << i))) {
+ filter_info->ethertype_mask |= 1 << i;
+ filter_info->ethertype_filters[i] = ethertype;
+ return i;
+ }
+ }
+ return -1;
+}
+
+static inline int
+ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info,
+ uint8_t idx)
+{
+ if (idx >= IXGBE_MAX_ETQF_FILTERS)
+ return -1;
+ filter_info->ethertype_mask &= ~(1 << idx);
+ filter_info->ethertype_filters[idx] = 0;
+ return idx;
+}
+
+static int
+ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add)
+{
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct ixgbe_filter_info *filter_info =
+ IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf = 0;
+ uint32_t etqs = 0;
+ int ret;
+
+ if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
+ return -EINVAL;
+
+ if (filter->ether_type == ETHER_TYPE_IPv4 ||
+ filter->ether_type == ETHER_TYPE_IPv6) {
+ PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
+ " ethertype filter.", filter->ether_type);
+ return -EINVAL;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ PMD_DRV_LOG(ERR, "mac compare is unsupported.");
+ return -EINVAL;
+ }
+ if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
+ PMD_DRV_LOG(ERR, "drop option is unsupported.");
+ return -EINVAL;
+ }
+
+ ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret >= 0 && add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
+ filter->ether_type);
+ return -EEXIST;
+ }
+ if (ret < 0 && !add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ if (add) {
+ ret = ixgbe_ethertype_filter_insert(filter_info,
+ filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype filters are full.");
+ return -ENOSYS;
+ }
+ etqf = IXGBE_ETQF_FILTER_EN;
+ etqf |= (uint32_t)filter->ether_type;
+ etqs |= (uint32_t)((filter->queue <<
+ IXGBE_ETQS_RX_QUEUE_SHIFT) &
+ IXGBE_ETQS_RX_QUEUE);
+ etqs |= IXGBE_ETQS_QUEUE_EN;
+ } else {
+ ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
+ if (ret < 0)
+ return -ENOSYS;
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
+ IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
+ IXGBE_WRITE_FLUSH(hw);
+
+ return 0;
+}
+
+static int
+ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter)
+{
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct ixgbe_filter_info *filter_info =
+ IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf, etqs;
+ int ret;
+
+ ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
+ if (etqf & IXGBE_ETQF_FILTER_EN) {
+ etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
+ filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
+ filter->flags = 0;
+ filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
+ IXGBE_ETQS_RX_QUEUE_SHIFT;
+ return 0;
+ }
+ return -ENOENT;
+}
+
+/*
+ * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
+ * @dev: pointer to rte_eth_dev structure
+ * @filter_op:operation will be taken.
+ * @arg: a pointer to specific structure corresponding to the filter_op
+ */
+static int
+ixgbe_ethertype_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);
+ int ret;
+
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
+
+ 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;
+ }
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = ixgbe_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ TRUE);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = ixgbe_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ FALSE);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = ixgbe_get_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
+static int
+ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ int ret = -EINVAL;
+
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
+ break;
+ default:
+ PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+ filter_type);
+ break;
+ }
+
+ return ret;
+}
+
static struct rte_driver rte_ixgbe_driver = {
.type = PMD_PDEV,
.init = rte_ixgbe_pmd_init,
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index ca99170..35c7704 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -162,6 +162,15 @@ struct ixgbe_vf_info {
};
/*
+ * Structure to store filters' info.
+ */
+struct ixgbe_filter_info {
+ uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
+ /* store used ethertype filters*/
+ uint16_t ethertype_filters[IXGBE_MAX_ETQF_FILTERS];
+};
+
+/*
* Structure to store private data for each driver instance (for each port).
*/
struct ixgbe_adapter {
@@ -179,6 +188,7 @@ struct ixgbe_adapter {
#ifdef RTE_NIC_BYPASS
struct ixgbe_bypass_info bps;
#endif /* RTE_NIC_BYPASS */
+ struct ixgbe_filter_info filter;
};
/*
@@ -224,6 +234,9 @@ enum ixgbe_5tuple_protocol {
#define IXGBE_DEV_PRIVATE_TO_UTA(adapter) \
(&((struct ixgbe_adapter *)adapter)->uta_info)
+#define IXGBE_DEV_PRIVATE_TO_FILTER_INFO(adapter) \
+ (&((struct ixgbe_adapter *)adapter)->filter)
+
/*
* RX/TX function prototypes
*/
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v2 2/4] e1000: new functions replace old ones for ethertype filter
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
@ 2015-01-12 7:16 ` Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 3/4] testpmd: new commands " Jingjing Wu
` (2 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2015-01-12 7:16 UTC (permalink / raw)
To: dev
This patch removes old functions which deal with ethertype filter in igb driver.
It also defines eth_igb_filter_ctrl which is binding to filter_ctrl API,
and ethertype filter can be dealt with through this new entrance.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
lib/librte_pmd_e1000/igb_ethdev.c | 332 +++++++++++++++++++++++-------------
2 files changed, 228 insertions(+), 117 deletions(-)
diff --git a/lib/librte_pmd_e1000/e1000_ethdev.h b/lib/librte_pmd_e1000/e1000_ethdev.h
index 71eb5fb..d155e77 100644
--- a/lib/librte_pmd_e1000/e1000_ethdev.h
+++ b/lib/librte_pmd_e1000/e1000_ethdev.h
@@ -132,6 +132,15 @@ struct e1000_vf_info {
};
/*
+ * Structure to store filters' info.
+ */
+struct e1000_filter_info {
+ uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
+ /* store used ethertype filters*/
+ uint16_t ethertype_filters[E1000_MAX_ETQF_FILTERS];
+};
+
+/*
* Structure to store private data for each driver instance (for each port).
*/
struct e1000_adapter {
@@ -140,6 +149,7 @@ struct e1000_adapter {
struct e1000_interrupt intr;
struct e1000_vfta shadow_vfta;
struct e1000_vf_info *vfdata;
+ struct e1000_filter_info filter;
};
#define E1000_DEV_PRIVATE_TO_HW(adapter) \
@@ -157,6 +167,9 @@ struct e1000_adapter {
#define E1000_DEV_PRIVATE_TO_P_VFDATA(adapter) \
(&((struct e1000_adapter *)adapter)->vfdata)
+#define E1000_DEV_PRIVATE_TO_FILTER_INFO(adapter) \
+ (&((struct e1000_adapter *)adapter)->filter)
+
/*
* RX/TX IGB function prototypes
*/
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index 873d65e..81b2ca7 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -154,14 +154,6 @@ static int eth_igb_add_syn_filter(struct rte_eth_dev *dev,
static int eth_igb_remove_syn_filter(struct rte_eth_dev *dev);
static int eth_igb_get_syn_filter(struct rte_eth_dev *dev,
struct rte_syn_filter *filter, uint16_t *rx_queue);
-static int eth_igb_add_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-static int eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index);
-static int eth_igb_get_ethertype_filter(struct rte_eth_dev *dev,
- uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
static int eth_igb_add_2tuple_filter(struct rte_eth_dev *dev,
uint16_t index,
struct rte_2tuple_filter *filter, uint16_t rx_queue);
@@ -186,6 +178,18 @@ static int eth_igb_remove_5tuple_filter(struct rte_eth_dev *dev,
static int eth_igb_get_5tuple_filter(struct rte_eth_dev *dev,
uint16_t index,
struct rte_5tuple_filter *filter, uint16_t *rx_queue);
+static int igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add);
+static int igb_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg);
+static int igb_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter);
+static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg);
/*
* Define VF Stats MACRO for Non "cleared on read" register
@@ -264,9 +268,6 @@ static struct eth_dev_ops eth_igb_ops = {
.add_syn_filter = eth_igb_add_syn_filter,
.remove_syn_filter = eth_igb_remove_syn_filter,
.get_syn_filter = eth_igb_get_syn_filter,
- .add_ethertype_filter = eth_igb_add_ethertype_filter,
- .remove_ethertype_filter = eth_igb_remove_ethertype_filter,
- .get_ethertype_filter = eth_igb_get_ethertype_filter,
.add_2tuple_filter = eth_igb_add_2tuple_filter,
.remove_2tuple_filter = eth_igb_remove_2tuple_filter,
.get_2tuple_filter = eth_igb_get_2tuple_filter,
@@ -276,6 +277,7 @@ static struct eth_dev_ops eth_igb_ops = {
.add_5tuple_filter = eth_igb_add_5tuple_filter,
.remove_5tuple_filter = eth_igb_remove_5tuple_filter,
.get_5tuple_filter = eth_igb_get_5tuple_filter,
+ .filter_ctrl = eth_igb_filter_ctrl,
};
/*
@@ -2388,7 +2390,7 @@ eth_igb_rss_reta_query(struct rte_eth_dev *dev,
#define MAC_TYPE_FILTER_SUP(type) do {\
if ((type) != e1000_82580 && (type) != e1000_i350 &&\
(type) != e1000_82576)\
- return -ENOSYS;\
+ return -ENOTSUP;\
} while (0)
/*
@@ -2485,111 +2487,6 @@ eth_igb_get_syn_filter(struct rte_eth_dev *dev,
return -ENOENT;
}
-/*
- * add an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * 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.
- */
-static int
-eth_igb_add_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf;
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS || rx_queue >= IGB_MAX_RX_QUEUE_NUM)
- return -EINVAL;
-
- etqf = E1000_READ_REG(hw, E1000_ETQF(index));
- if (etqf & E1000_ETQF_FILTER_ENABLE)
- return -EINVAL; /* filter index is in use. */
- else
- etqf = 0;
-
- etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
- etqf |= (uint32_t)(filter->ethertype & E1000_ETQF_ETHERTYPE);
- etqf |= rx_queue << E1000_ETQF_QUEUE_SHIFT;
-
- if (filter->priority_en) {
- PMD_INIT_LOG(ERR, "vlan and priority (%d) is not supported"
- " in E1000.", filter->priority);
- return -EINVAL;
- }
-
- E1000_WRITE_REG(hw, E1000_ETQF(index), etqf);
- return 0;
-}
-
-/*
- * remove an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-eth_igb_remove_ethertype_filter(struct rte_eth_dev *dev, uint16_t index)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- E1000_WRITE_REG(hw, E1000_ETQF(index), 0);
- return 0;
-}
-
-/*
- * get an ethertype filter
- *
- * @param
- * dev: Pointer to struct rte_eth_dev.
- * index: the index the filter allocates.
- * filter: ponter to the filter that will be gotten.
- * *rx_queue: the ponited of the queue id the filter assigned to.
- *
- * @return
- * - On success, zero.
- * - On failure, a negative value.
- */
-static int
-eth_igb_get_ethertype_filter(struct rte_eth_dev *dev, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue)
-{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t etqf;
-
- MAC_TYPE_FILTER_SUP(hw->mac.type);
-
- if (index >= E1000_MAX_ETQF_FILTERS)
- return -EINVAL;
-
- etqf = E1000_READ_REG(hw, E1000_ETQF(index));
- if (etqf & E1000_ETQF_FILTER_ENABLE) {
- filter->ethertype = etqf & E1000_ETQF_ETHERTYPE;
- filter->priority_en = 0;
- *rx_queue = (etqf & E1000_ETQF_QUEUE) >> E1000_ETQF_QUEUE_SHIFT;
- return 0;
- }
- return -ENOENT;
-}
-
#define MAC_TYPE_FILTER_SUP_EXT(type) do {\
if ((type) != e1000_82580 && (type) != e1000_i350)\
return -ENOSYS; \
@@ -3149,6 +3046,207 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
return 0;
}
+static inline int
+igb_ethertype_filter_lookup(struct e1000_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
+ if (filter_info->ethertype_filters[i] == ethertype &&
+ (filter_info->ethertype_mask & (1 << i)))
+ return i;
+ }
+ return -1;
+}
+
+static inline int
+igb_ethertype_filter_insert(struct e1000_filter_info *filter_info,
+ uint16_t ethertype)
+{
+ int i;
+
+ for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
+ if (!(filter_info->ethertype_mask & (1 << i))) {
+ filter_info->ethertype_mask |= 1 << i;
+ filter_info->ethertype_filters[i] = ethertype;
+ return i;
+ }
+ }
+ return -1;
+}
+
+static inline int
+igb_ethertype_filter_remove(struct e1000_filter_info *filter_info,
+ uint8_t idx)
+{
+ if (idx >= E1000_MAX_ETQF_FILTERS)
+ return -1;
+ filter_info->ethertype_mask &= ~(1 << idx);
+ filter_info->ethertype_filters[idx] = 0;
+ return idx;
+}
+
+
+static int
+igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter,
+ bool add)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_filter_info *filter_info =
+ E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf = 0;
+ int ret;
+
+ if (filter->ether_type == ETHER_TYPE_IPv4 ||
+ filter->ether_type == ETHER_TYPE_IPv6) {
+ PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
+ " ethertype filter.", filter->ether_type);
+ return -EINVAL;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ PMD_DRV_LOG(ERR, "mac compare is unsupported.");
+ return -EINVAL;
+ }
+ if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
+ PMD_DRV_LOG(ERR, "drop option is unsupported.");
+ return -EINVAL;
+ }
+
+ ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret >= 0 && add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
+ filter->ether_type);
+ return -EEXIST;
+ }
+ if (ret < 0 && !add) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ if (add) {
+ ret = igb_ethertype_filter_insert(filter_info,
+ filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype filters are full.");
+ return -ENOSYS;
+ }
+
+ etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
+ etqf |= (uint32_t)(filter->ether_type & E1000_ETQF_ETHERTYPE);
+ etqf |= filter->queue << E1000_ETQF_QUEUE_SHIFT;
+ } else {
+ ret = igb_ethertype_filter_remove(filter_info, (uint8_t)ret);
+ if (ret < 0)
+ return -ENOSYS;
+ }
+ E1000_WRITE_REG(hw, E1000_ETQF(ret), etqf);
+ E1000_WRITE_FLUSH(hw);
+
+ return 0;
+}
+
+static int
+igb_get_ethertype_filter(struct rte_eth_dev *dev,
+ struct rte_eth_ethertype_filter *filter)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_filter_info *filter_info =
+ E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+ uint32_t etqf;
+ int ret;
+
+ ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
+ filter->ether_type);
+ return -ENOENT;
+ }
+
+ etqf = E1000_READ_REG(hw, E1000_ETQF(ret));
+ if (etqf & E1000_ETQF_FILTER_ENABLE) {
+ filter->ether_type = etqf & E1000_ETQF_ETHERTYPE;
+ filter->flags = 0;
+ filter->queue = (etqf & E1000_ETQF_QUEUE) >>
+ E1000_ETQF_QUEUE_SHIFT;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+/*
+ * igb_ethertype_filter_handle - Handle operations for ethertype filter.
+ * @dev: pointer to rte_eth_dev structure
+ * @filter_op:operation will be taken.
+ * @arg: a pointer to specific structure corresponding to the filter_op
+ */
+static int
+igb_ethertype_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int ret;
+
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
+
+ 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;
+ }
+
+ switch (filter_op) {
+ case RTE_ETH_FILTER_ADD:
+ ret = igb_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ TRUE);
+ break;
+ case RTE_ETH_FILTER_DELETE:
+ ret = igb_add_del_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg,
+ FALSE);
+ break;
+ case RTE_ETH_FILTER_GET:
+ ret = igb_get_ethertype_filter(dev,
+ (struct rte_eth_ethertype_filter *)arg);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
+static int
+eth_igb_filter_ctrl(struct rte_eth_dev *dev,
+ enum rte_filter_type filter_type,
+ enum rte_filter_op filter_op,
+ void *arg)
+{
+ int ret = -EINVAL;
+
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ ret = igb_ethertype_filter_handle(dev, filter_op, arg);
+ break;
+ default:
+ PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+ filter_type);
+ break;
+ }
+
+ return ret;
+}
+
static struct rte_driver pmd_igb_drv = {
.type = PMD_PDEV,
.init = rte_igb_pmd_init,
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v2 3/4] testpmd: new commands for ethertype filter
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 2/4] e1000: " Jingjing Wu
@ 2015-01-12 7:16 ` Jingjing Wu
2015-01-20 10:14 ` Thomas Monjalon
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
2015-01-12 7:23 ` [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Zhang, Helin
4 siblings, 1 reply; 17+ messages in thread
From: Jingjing Wu @ 2015-01-12 7:16 UTC (permalink / raw)
To: dev
Following commands of ethertype filter are removed:
- add_ethertype_filter (port_id) ethertype (eth_value)
- remove_ethertype_filter (port_id) index (idx)
- get_ethertype_filter (port_id) index (idx)
New command is added for ethertype filter by using filter_ctrl API and new
ethertype filter structure:
- ethertype_filter (port_id) (add|del) (mac_addr|mac_ignr)
(mac_address) ethertype (ether_type) (drop|fwd) queue (queue_id)
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
app/test-pmd/cmdline.c | 253 ++++++++++++++++++++++---------------------------
app/test-pmd/config.c | 27 ------
2 files changed, 112 insertions(+), 168 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 882a5a2..f0c7d5f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -654,15 +654,10 @@ static void cmd_help_long_parsed(void *parsed_result,
"filters:\n"
"--------\n\n"
- "add_ethertype_filter (port_id) ethertype (eth_value)"
- " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
- " add an ethertype filter.\n\n"
-
- "remove_ethertype_filter (port_id) index (idx)\n"
- " remove an ethertype filter.\n\n"
-
- "get_ethertype_filter (port_id) index (idx)\n"
- " get info of a ethertype filter.\n\n"
+ "ethertype_filter (port_id) (add|del)"
+ " (mac_addr|mac_ignr) (mac_address) ethertype"
+ " (ether_type) (drop|fwd) queue (queue_id)\n"
+ " Add/Del an ethertype filter.\n\n"
"add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
" dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
@@ -7264,135 +7259,6 @@ cmdline_parse_inst_t cmd_dump_one = {
},
};
-/* *** ADD/REMOVE an ethertype FILTER *** */
-struct cmd_ethertype_filter_result {
- cmdline_fixed_string_t filter;
- uint8_t port_id;
- cmdline_fixed_string_t ethertype;
- uint16_t ethertype_value;
- cmdline_fixed_string_t priority;
- cmdline_fixed_string_t priority_en;
- uint8_t priority_value;
- cmdline_fixed_string_t queue;
- uint16_t queue_id;
- cmdline_fixed_string_t index;
- uint16_t index_value;
-};
-
-static void
-cmd_ethertype_filter_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- int ret = 0;
- struct cmd_ethertype_filter_result *res = parsed_result;
- struct rte_ethertype_filter filter;
-
- memset(&filter, 0, sizeof(struct rte_ethertype_filter));
- filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
- filter.priority = res->priority_value;
-
- if (!strcmp(res->priority_en, "enable"))
- filter.priority_en = 1;
- if (!strcmp(res->filter, "add_ethertype_filter"))
- ret = rte_eth_dev_add_ethertype_filter(res->port_id,
- res->index_value,
- &filter, res->queue_id);
- else if (!strcmp(res->filter, "remove_ethertype_filter"))
- ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
- res->index_value);
- else if (!strcmp(res->filter, "get_ethertype_filter"))
- get_ethertype_filter(res->port_id, res->index_value);
-
- if (ret < 0)
- printf("ethertype filter setting error: (%s)\n",
- strerror(-ret));
-}
-
-cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- port_id, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype, "ethertype");
-cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_priority =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- priority, "priority");
-cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- priority_en, "enable#disable");
-cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- priority_value, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- queue, "queue");
-cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- queue_id, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_index =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- index, "index");
-cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- index_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "add_ethertype_filter");
-cmdline_parse_inst_t cmd_add_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "add an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_add_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_ethertype,
- (void *)&cmd_ethertype_filter_ethertype_value,
- (void *)&cmd_ethertype_filter_priority,
- (void *)&cmd_ethertype_filter_priority_en,
- (void *)&cmd_ethertype_filter_priority_value,
- (void *)&cmd_ethertype_filter_queue,
- (void *)&cmd_ethertype_filter_queue_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-
-cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "remove_ethertype_filter");
-cmdline_parse_inst_t cmd_remove_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "remove an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_remove_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "get_ethertype_filter");
-cmdline_parse_inst_t cmd_get_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "get an ethertype filter",
- .tokens = {
- (void *)&cmd_ethertype_filter_get_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_index,
- (void *)&cmd_ethertype_filter_index_value,
- NULL,
- },
-};
-
/* *** set SYN filter *** */
struct cmd_set_syn_filter_result {
cmdline_fixed_string_t filter;
@@ -8096,6 +7962,113 @@ cmdline_parse_inst_t cmd_get_flex_filter = {
/* *** Filters Control *** */
+/* *** deal with ethertype filter *** */
+struct cmd_ethertype_filter_result {
+ cmdline_fixed_string_t filter;
+ uint8_t port_id;
+ cmdline_fixed_string_t ops;
+ cmdline_fixed_string_t mac;
+ struct ether_addr mac_addr;
+ cmdline_fixed_string_t ethertype;
+ uint16_t ethertype_value;
+ cmdline_fixed_string_t drop;
+ cmdline_fixed_string_t queue;
+ uint16_t queue_id;
+};
+
+cmdline_parse_token_string_t cmd_ethertype_filter_filter =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ filter, "ethertype_filter");
+cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ port_id, UINT8);
+cmdline_parse_token_string_t cmd_ethertype_filter_ops =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ ops, "add#del");
+cmdline_parse_token_string_t cmd_ethertype_filter_mac =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ mac, "mac_addr#mac_ignr");
+cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
+ TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
+ mac_addr);
+cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ ethertype, "ethertype");
+cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ ethertype_value, UINT16);
+cmdline_parse_token_string_t cmd_ethertype_filter_drop =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ drop, "drop#fwd");
+cmdline_parse_token_string_t cmd_ethertype_filter_queue =
+ TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+ queue, "queue");
+cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+ queue_id, UINT16);
+
+static void
+cmd_ethertype_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_ethertype_filter_result *res = parsed_result;
+ struct rte_eth_ethertype_filter filter;
+ int ret = 0;
+
+ ret = rte_eth_dev_filter_supported(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE);
+ if (ret < 0) {
+ printf("ethertype filter is not supported on port %u.\n",
+ res->port_id);
+ return;
+ }
+
+ memset(&filter, 0, sizeof(filter));
+ if (!strcmp(res->mac, "mac_addr")) {
+ filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
+ (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
+ sizeof(struct ether_addr));
+ }
+ if (!strcmp(res->drop, "drop"))
+ filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
+ filter.ether_type = res->ethertype_value;
+ filter.queue = res->queue_id;
+
+ if (!strcmp(res->ops, "add"))
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE,
+ RTE_ETH_FILTER_ADD,
+ &filter);
+ else
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_ETHERTYPE,
+ RTE_ETH_FILTER_DELETE,
+ &filter);
+ if (ret < 0)
+ printf("ethertype filter programming error: (%s)\n",
+ strerror(-ret));
+}
+
+cmdline_parse_inst_t cmd_ethertype_filter = {
+ .f = cmd_ethertype_filter_parsed,
+ .data = NULL,
+ .help_str = "add or delete an ethertype filter entry",
+ .tokens = {
+ (void *)&cmd_ethertype_filter_filter,
+ (void *)&cmd_ethertype_filter_port_id,
+ (void *)&cmd_ethertype_filter_ops,
+ (void *)&cmd_ethertype_filter_mac,
+ (void *)&cmd_ethertype_filter_mac_addr,
+ (void *)&cmd_ethertype_filter_ethertype,
+ (void *)&cmd_ethertype_filter_ethertype_value,
+ (void *)&cmd_ethertype_filter_drop,
+ (void *)&cmd_ethertype_filter_queue,
+ (void *)&cmd_ethertype_filter_queue_id,
+ NULL,
+ },
+};
+
/* *** deal with flow director filter *** */
struct cmd_flow_director_result {
cmdline_fixed_string_t flow_director_filter;
@@ -8815,9 +8788,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_dump,
(cmdline_parse_inst_t *)&cmd_dump_one,
- (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
- (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
- (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
+ (cmdline_parse_inst_t *)&cmd_ethertype_filter,
(cmdline_parse_inst_t *)&cmd_add_syn_filter,
(cmdline_parse_inst_t *)&cmd_remove_syn_filter,
(cmdline_parse_inst_t *)&cmd_get_syn_filter,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97b6525..c40f819 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2166,33 +2166,6 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk)
}
void
-get_ethertype_filter(uint8_t port_id, uint16_t index)
-{
- struct rte_ethertype_filter filter;
- int ret = 0;
- uint16_t rx_queue;
-
- memset(&filter, 0, sizeof(filter));
- ret = rte_eth_dev_get_ethertype_filter(port_id, index,
- &filter, &rx_queue);
- if (ret < 0) {
- if (ret == (-ENOENT))
- printf("filter[%d] is not enabled\n", index);
- else
- printf("get ethertype filter fails(%s)\n", strerror(-ret));
- return;
- } else {
- printf("filter[%d]:\n", index);
- printf(" ethertype: 0x%04x\n",
- rte_le_to_cpu_32(filter.ethertype));
- printf(" priority: %s, %d\n",
- filter.priority_en ? "enable" : "disable",
- filter.priority);
- printf(" queue: %d\n", rx_queue);
- }
-}
-
-void
get_syn_filter(uint8_t port_id)
{
struct rte_syn_filter filter;
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [dpdk-dev] [PATCH v2 4/4] ethdev: remove old APIs and structures of ethertype filter
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
` (2 preceding siblings ...)
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 3/4] testpmd: new commands " Jingjing Wu
@ 2015-01-12 7:16 ` Jingjing Wu
2015-01-12 7:23 ` [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Zhang, Helin
4 siblings, 0 replies; 17+ messages in thread
From: Jingjing Wu @ 2015-01-12 7:16 UTC (permalink / raw)
To: dev
Structure rte_ethertype_filter is removed.
Following APIs are removed:
- rte_eth_dev_add_ethertype_filter
- rte_eth_dev_remove_ethertype_filter
- rte_eth_dev_get_ethertype_filter
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
lib/librte_ether/rte_ethdev.c | 57 ----------------------------
lib/librte_ether/rte_ethdev.h | 88 -------------------------------------------
2 files changed, 145 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 95f2ceb..b55fab2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3015,63 +3015,6 @@ rte_eth_dev_get_syn_filter(uint8_t port_id,
}
int
-rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
- if (filter->ethertype == ETHER_TYPE_IPv4 ||
- filter->ethertype == ETHER_TYPE_IPv6){
- PMD_DEBUG_TRACE("IP and IPv6 are not supported"
- " in ethertype filter\n");
- return -EINVAL;
- }
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->add_ethertype_filter)(dev, index,
- filter, rx_queue);
-}
-
-int
-rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->remove_ethertype_filter)(dev, index);
-}
-
-int
-rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue)
-{
- struct rte_eth_dev *dev;
-
- if (filter == NULL || rx_queue == NULL)
- return -EINVAL;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ethertype_filter, -ENOTSUP);
- return (*dev->dev_ops->get_ethertype_filter)(dev, index,
- filter, rx_queue);
-}
-
-int
rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,
struct rte_2tuple_filter *filter, uint16_t rx_queue)
{
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ce0528f..1200c1c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -972,15 +972,6 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
#define TCP_FLAG_ALL 0x3F
/**
- * A structure used to define an ethertype filter.
- */
-struct rte_ethertype_filter {
- uint16_t ethertype; /**< little endian. */
- uint8_t priority_en; /**< compare priority enable. */
- uint8_t priority;
-};
-
-/**
* A structure used to define an syn filter.
*/
struct rte_syn_filter {
@@ -1372,20 +1363,6 @@ typedef int (*eth_get_syn_filter_t)(struct rte_eth_dev *dev,
struct rte_syn_filter *filter, uint16_t *rx_queue);
/**< @internal Get syn filter rule on an Ethernet device */
-typedef int (*eth_add_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t rx_queue);
-/**< @internal Setup a new ethertype filter rule on an Ethernet device */
-
-typedef int (*eth_remove_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index);
-/**< @internal Remove an ethertype filter rule on an Ethernet device */
-
-typedef int (*eth_get_ethertype_filter_t)(struct rte_eth_dev *dev,
- uint16_t index, struct rte_ethertype_filter *filter,
- uint16_t *rx_queue);
-/**< @internal Get an ethertype filter rule on an Ethernet device */
-
typedef int (*eth_add_2tuple_filter_t)(struct rte_eth_dev *dev,
uint16_t index, struct rte_2tuple_filter *filter,
uint16_t rx_queue);
@@ -1532,9 +1509,6 @@ struct eth_dev_ops {
eth_add_syn_filter_t add_syn_filter; /**< add syn filter. */
eth_remove_syn_filter_t remove_syn_filter; /**< remove syn filter. */
eth_get_syn_filter_t get_syn_filter; /**< get syn filter. */
- eth_add_ethertype_filter_t add_ethertype_filter; /**< add ethertype filter. */
- eth_remove_ethertype_filter_t remove_ethertype_filter; /**< remove ethertype filter. */
- eth_get_ethertype_filter_t get_ethertype_filter; /**< get ethertype filter. */
eth_add_2tuple_filter_t add_2tuple_filter; /**< add 2tuple filter. */
eth_remove_2tuple_filter_t remove_2tuple_filter; /**< remove 2tuple filter. */
eth_get_2tuple_filter_t get_2tuple_filter; /**< get 2tuple filter. */
@@ -3474,68 +3448,6 @@ int rte_eth_dev_get_syn_filter(uint8_t port_id,
struct rte_syn_filter *filter, uint16_t *rx_queue);
/**
- * Add a new ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @param filter
- * The pointer to the structure describing the ethertype filter rule.
- * The *rte_ethertype_filter* structure includes the values of the different
- * fields to match: ethertype and priority in vlan tag.
- * priority in vlan tag is not supported for E1000 dev.
- * @param rx_queue
- * The index of the RX queue where to store RX packets matching the added
- * ethertype filter.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- */
-int rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t rx_queue);
-
-/**
- * remove an ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- */
-int rte_eth_dev_remove_ethertype_filter(uint8_t port_id,
- uint16_t index);
-
-/**
- * Get an ethertype filter rule on an Ethernet device.
- *
- * @param port_id
- * The port identifier of the Ethernet device.
- * @param index
- * The identifier of ethertype filter.
- * @param filter
- * A pointer to a structure of type *rte_ethertype_filter* to be filled with
- * the information of the Ethertype filter.
- * @param rx_queue
- * A pointer to get the queue index.
- * @return
- * - (0) if successful.
- * - (-ENOTSUP) if hardware doesn't support ethertype filter.
- * - (-ENODEV) if *port_id* invalid.
- * - (-EINVAL) if the filter information is not correct.
- * - (-ENOENT) if no enabled filter in this index.
- */
-int rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
- struct rte_ethertype_filter *filter, uint16_t *rx_queue);
-
-/**
* Add a new 2tuple filter rule on an Ethernet device.
*
* @param port_id
--
1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
` (3 preceding siblings ...)
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
@ 2015-01-12 7:23 ` Zhang, Helin
2015-01-20 8:17 ` Thomas Monjalon
4 siblings, 1 reply; 17+ messages in thread
From: Zhang, Helin @ 2015-01-12 7:23 UTC (permalink / raw)
To: Wu, Jingjing, dev
Acked-by: Helin Zhang <helin.zhang@intel.com>
> -----Original Message-----
> From: Wu, Jingjing
> Sent: Monday, January 12, 2015 3:16 PM
> To: dev@dpdk.org
> Cc: Wu, Jingjing; Zhang, Helin; Cao, Min
> Subject: [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
>
> v2 changes:
> change the return value if adding an existing filter from the filter's index to
> negative value.
>
> The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
> It uses new functions and structure to replace old ones in igb/ixgbe driver, new
> commands to replace old ones in testpmd, and removes the old APIs.
>
> Jingjing Wu (4):
> ixgbe: new functions replace old ones for ethertype filter
> e1000: new functions replace old ones for ethertype filter
> testpmd: new commands for ethertype filter
> ethdev: remove old APIs and structures of ethertype filter
>
> app/test-pmd/cmdline.c | 253 ++++++++++++--------------
> app/test-pmd/config.c | 27 ---
> lib/librte_ether/rte_ethdev.c | 57 ------
> lib/librte_ether/rte_ethdev.h | 88 ---------
> lib/librte_pmd_e1000/e1000_ethdev.h | 13 ++
> lib/librte_pmd_e1000/igb_ethdev.c | 332
> +++++++++++++++++++++------------
> lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 354
> +++++++++++++++++++++++-------------
> lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 13 ++
> 8 files changed, 579 insertions(+), 558 deletions(-)
>
> --
> 1.9.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API
2015-01-12 7:23 ` [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Zhang, Helin
@ 2015-01-20 8:17 ` Thomas Monjalon
0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2015-01-20 8:17 UTC (permalink / raw)
To: Wu, Jingjing; +Cc: dev
> > v2 changes:
> > change the return value if adding an existing filter from the filter's index to
> > negative value.
> >
> > The patch set uses new filter_ctrl API to replace old ethertype filter APIs.
> > It uses new functions and structure to replace old ones in igb/ixgbe driver, new
> > commands to replace old ones in testpmd, and removes the old APIs.
> >
> > Jingjing Wu (4):
> > ixgbe: new functions replace old ones for ethertype filter
> > e1000: new functions replace old ones for ethertype filter
> > testpmd: new commands for ethertype filter
> > ethdev: remove old APIs and structures of ethertype filter
>
> Acked-by: Helin Zhang <helin.zhang@intel.com>
Applied
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [dpdk-dev] [PATCH v2 3/4] testpmd: new commands for ethertype filter
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 3/4] testpmd: new commands " Jingjing Wu
@ 2015-01-20 10:14 ` Thomas Monjalon
0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2015-01-20 10:14 UTC (permalink / raw)
To: Jingjing Wu; +Cc: dev
2015-01-12 15:16, Jingjing Wu:
> Following commands of ethertype filter are removed:
> - add_ethertype_filter (port_id) ethertype (eth_value)
> - remove_ethertype_filter (port_id) index (idx)
> - get_ethertype_filter (port_id) index (idx)
> New command is added for ethertype filter by using filter_ctrl API and new
> ethertype filter structure:
> - ethertype_filter (port_id) (add|del) (mac_addr|mac_ignr)
> (mac_address) ethertype (ether_type) (drop|fwd) queue (queue_id)
Please update doc accordingly:
http://dpdk.org/browse/dpdk/tree/doc/guides/testpmd_app_ug/testpmd_funcs.rst
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-01-20 10:14 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-25 3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters Jingjing Wu
2015-01-12 1:32 ` Zhang, Helin
2014-12-25 3:14 ` [dpdk-dev] [PATCH 3/4] testpmd: new commands for ethertype filter Jingjing Wu
2014-12-25 3:14 ` [dpdk-dev] [PATCH 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
2014-12-25 3:27 ` [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Qiu, Michael
2014-12-25 3:39 ` Wu, Jingjing
2014-12-25 4:57 ` Qiu, Michael
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 2/4] e1000: " Jingjing Wu
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 3/4] testpmd: new commands " Jingjing Wu
2015-01-20 10:14 ` Thomas Monjalon
2015-01-12 7:16 ` [dpdk-dev] [PATCH v2 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
2015-01-12 7:23 ` [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Zhang, Helin
2015-01-20 8:17 ` Thomas Monjalon
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).