From: Wei Zhao <wei.zhao1@intel.com>
To: dev@dpdk.org
Cc: wenzhuo.lu@intel.com, wei zhao1 <wei.zhao1@intel.com>
Subject: [dpdk-dev] [PATCH 12/18] net/ixgbe: parse ethertype filter
Date: Fri, 2 Dec 2016 18:43:08 +0800 [thread overview]
Message-ID: <1480675394-59179-13-git-send-email-wei.zhao1@intel.com> (raw)
In-Reply-To: <1480675394-59179-1-git-send-email-wei.zhao1@intel.com>
From: wei zhao1 <wei.zhao1@intel.com>
check if the rule is a ethertype rule, and get the ethertype info.
Signed-off-by: wei zhao1 <wei.zhao1@intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 166 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 162 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index d3768c6..a421062 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -405,11 +405,21 @@ rte_flow_error_type ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
struct rte_eth_ntuple_filter *filter);
+static enum rte_flow_error_type
+cons_parse_ethertype_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_ethertype_filter *filter);
+static enum rte_flow_error_type
+ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_ethertype_filter *filter);
enum rte_flow_error_type
ixgbe_flow_rule_validate(__rte_unused struct rte_eth_dev *dev,
- const struct rte_flow_attr *attr,
- const struct rte_flow_item pattern[],
- const struct rte_flow_action actions[]);
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[]);
int ixgbe_flow_validate(struct rte_eth_dev *dev,
const struct rte_flow_attr *attr,
const struct rte_flow_item pattern[],
@@ -8306,6 +8316,149 @@ ixgbe_parse_ntuple_filter(const struct rte_flow_attr *attr,
}
/**
+ * Parse the rule to see if it is a ethertype rule.
+ * And get the ethertype filter info BTW.
+ */
+static enum rte_flow_error_type
+cons_parse_ethertype_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_ethertype_filter *filter)
+{
+ const struct rte_flow_item *item;
+ const struct rte_flow_action *act;
+ const struct rte_flow_item_eth *eth_spec;
+ const struct rte_flow_item_eth *eth_mask;
+ const struct rte_flow_action_queue *act_q;
+ uint32_t i, j;
+
+ /************************************************
+ * parse pattern
+ ************************************************/
+ i = 0;
+
+ /* the first not void item should be MAC */
+ PATTERN_SKIP_VOID(filter, struct rte_eth_ethertype_filter,
+ RTE_FLOW_ERROR_TYPE_ITEM_NUM);
+ if (item->type != RTE_FLOW_ITEM_TYPE_ETH)
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+
+ /* get the MAC info */
+ if (!item->spec || !item->mask)
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+ eth_spec = (const struct rte_flow_item_eth *)item->spec;
+ eth_mask = (const struct rte_flow_item_eth *)item->mask;
+ /**
+ * Source MAC address must be masked.
+ * Destination MAC address must be totally masked or not.
+ */
+ if (eth_mask->src.addr_bytes[0] ||
+ (eth_mask->dst.addr_bytes[0] != 0xFF &&
+ eth_mask->dst.addr_bytes[0]))
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+ for (j = 1; j < ETHER_ADDR_LEN; j++) {
+ if (eth_mask->src.addr_bytes[j] !=
+ eth_mask->src.addr_bytes[0] ||
+ eth_mask->dst.addr_bytes[j] !=
+ eth_mask->dst.addr_bytes[0])
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+ }
+ if ((rte_be_to_cpu_32(eth_mask->type) & 0xFFFF) != 0xFFFF)
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+
+ if (eth_mask->dst.addr_bytes[0]) {
+ filter->mac_addr = eth_spec->dst;
+ filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
+ } else {
+ filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
+ }
+ filter->ether_type = (uint16_t)rte_be_to_cpu_32(eth_spec->type);
+
+ /* check if the next not void item is END */
+ i++;
+ PATTERN_SKIP_VOID(filter, struct rte_eth_ethertype_filter,
+ RTE_FLOW_ERROR_TYPE_ITEM);
+ if (item->type != RTE_FLOW_ITEM_TYPE_END) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+ }
+
+ /************************************************
+ * parse action
+ ************************************************/
+ i = 0;
+
+ /* check if the first not void action is QUEUE or DROP. */
+ ACTION_SKIP_VOID(filter, struct rte_eth_ethertype_filter,
+ RTE_FLOW_ERROR_TYPE_ACTION_NUM);
+ if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
+ act->type != RTE_FLOW_ACTION_TYPE_DROP) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ACTION;
+ }
+
+ if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
+ act_q = (const struct rte_flow_action_queue *)act->conf;
+ filter->queue = act_q->index;
+ } else {
+ filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
+ }
+
+ /* check if the next not void item is END */
+ i++;
+ ACTION_SKIP_VOID(filter, struct rte_eth_ethertype_filter,
+ RTE_FLOW_ERROR_TYPE_ACTION);
+ if (act->type != RTE_FLOW_ACTION_TYPE_END) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ACTION;
+ }
+
+ /************************************************
+ * parse attr
+ ************************************************/
+ /* must be input direction */
+ if (!attr->ingress) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ATTR_INGRESS;
+ }
+
+ /* not supported */
+ if (attr->egress) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ATTR_EGRESS;
+ }
+
+ /* not supported */
+ if (attr->priority) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY;
+ }
+
+ return 0;
+}
+static enum rte_flow_error_type
+ixgbe_parse_ethertype_filter(const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_ethertype_filter *filter)
+{
+ int ret;
+
+ ret = cons_parse_ethertype_filter(attr, pattern, actions, filter);
+
+ if (ret)
+ return ret;
+
+ /* Ixgbe doesn't support MAC address. */
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ return RTE_FLOW_ERROR_TYPE_ITEM;
+ }
+
+ return 0;
+}
+
+/**
* Check if the flow rule is supported by ixgbe.
* It only checkes the format. Don't guarantee the rule can be programmed into
* the HW. Because there can be no enough room for the rule.
@@ -8318,12 +8471,17 @@ ixgbe_flow_rule_validate(__rte_unused struct rte_eth_dev *dev,
{
int ret;
struct rte_eth_ntuple_filter ntuple_filter;
+ struct rte_eth_ethertype_filter ethertype_filter;
memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter));
ret = ixgbe_parse_ntuple_filter(attr, pattern, actions, &ntuple_filter);
if (!ret)
return RTE_FLOW_ERROR_TYPE_NONE;
-
+ memset(ðertype_filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ ret = ixgbe_parse_ethertype_filter(attr, pattern,
+ actions, ðertype_filter);
+ if (!ret)
+ return RTE_FLOW_ERROR_TYPE_NONE;
return ret;
}
--
2.5.5
next prev parent reply other threads:[~2016-12-02 10:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 10:42 [dpdk-dev] [PATCH 00/18] net/ixgbe: Consistent filter API Wei Zhao
2016-12-02 10:42 ` [dpdk-dev] [PATCH 01/18] net/ixgbe: store SYN filter Wei Zhao
2016-12-20 16:55 ` Ferruh Yigit
2016-12-22 9:48 ` Zhao1, Wei
2017-01-06 16:26 ` Ferruh Yigit
2017-01-10 6:48 ` Zhao1, Wei
2016-12-26 1:47 ` Zhao1, Wei
2016-12-02 10:42 ` [dpdk-dev] [PATCH 02/18] net/ixgbe: store flow director filter Wei Zhao
2016-12-20 16:58 ` Ferruh Yigit
2016-12-26 2:50 ` Zhao1, Wei
2016-12-02 10:42 ` [dpdk-dev] [PATCH 03/18] net/ixgbe: store L2 tunnel filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 04/18] net/ixgbe: restore n-tuple filter Wei Zhao
2016-12-20 16:58 ` Ferruh Yigit
2016-12-26 3:32 ` Zhao1, Wei
2016-12-02 10:43 ` [dpdk-dev] [PATCH 05/18] net/ixgbe: restore ether type filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 06/18] net/ixgbe: restore SYN filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 07/18] net/ixgbe: restore flow director filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 08/18] net/ixgbe: restore L2 tunnel filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 09/18] net/ixgbe: store and restore L2 tunnel configuration Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 10/18] net/ixgbe: flush all the filters Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 11/18] net/ixgbe: parse n-tuple filter Wei Zhao
2016-12-20 17:23 ` Ferruh Yigit
2016-12-02 10:43 ` Wei Zhao [this message]
2016-12-02 10:43 ` [dpdk-dev] [PATCH 13/18] net/ixgbe: parse SYN filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 14/18] net/ixgbe: parse L2 tunnel filter Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 15/18] net/ixgbe: parse flow director filter Wei Zhao
2016-12-20 17:00 ` Ferruh Yigit
2016-12-22 9:19 ` Zhao1, Wei
2016-12-22 10:44 ` Ferruh Yigit
2016-12-23 8:13 ` Adrien Mazarguil
2016-12-27 3:31 ` Zhao1, Wei
2016-12-02 10:43 ` [dpdk-dev] [PATCH 16/18] net/ixgbe: create consistent filter Wei Zhao
2016-12-20 17:25 ` Ferruh Yigit
2016-12-23 6:26 ` Zhao1, Wei
2016-12-02 10:43 ` [dpdk-dev] [PATCH 17/18] net/ixgbe: destroy " Wei Zhao
2016-12-02 10:43 ` [dpdk-dev] [PATCH 18/18] net/ixgbe: flush " Wei Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480675394-59179-13-git-send-email-wei.zhao1@intel.com \
--to=wei.zhao1@intel.com \
--cc=dev@dpdk.org \
--cc=wenzhuo.lu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).