From: Wei Zhao <wei.zhao1@intel.com>
To: dev@dpdk.org
Cc: wenzhuo.lu@intel.com, Wei Zhao <wei.zhao1@intel.com>
Subject: [PATCH v3 06/11] net/e1000: parse ethertype filter
Date: Fri, 9 Jun 2017 11:11:43 +0800 [thread overview]
Message-ID: <1496977908-2149-7-git-send-email-wei.zhao1@intel.com> (raw)
In-Reply-To: <1496977908-2149-1-git-send-email-wei.zhao1@intel.com>
check if the rule is a ethertype rule, and get the ethertype info.
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
drivers/net/e1000/igb_flow.c | 263 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 263 insertions(+)
diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c
index fad5583..d2f8946 100644
--- a/drivers/net/e1000/igb_flow.c
+++ b/drivers/net/e1000/igb_flow.c
@@ -482,6 +482,262 @@ igb_parse_ntuple_filter(struct rte_eth_dev *dev,
}
/**
+ * Parse the rule to see if it is a ethertype rule.
+ * And get the ethertype filter info BTW.
+ * pattern:
+ * The first not void item can be ETH.
+ * The next not void item must be END.
+ * action:
+ * The first not void action should be QUEUE.
+ * The next not void action should be END.
+ * pattern example:
+ * ITEM Spec Mask
+ * ETH type 0x0807 0xFFFF
+ * END
+ * other members in mask and spec should set to 0x00.
+ * item->last should be NULL.
+ */
+static int
+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,
+ struct rte_flow_error *error)
+{
+ 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 index;
+
+ if (!pattern) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM_NUM,
+ NULL, "NULL pattern.");
+ return -rte_errno;
+ }
+
+ if (!actions) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION_NUM,
+ NULL, "NULL action.");
+ return -rte_errno;
+ }
+
+ if (!attr) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ NULL, "NULL attribute.");
+ return -rte_errno;
+ }
+
+ /* Parse pattern */
+ index = 0;
+
+ /* The first non-void item should be MAC. */
+ NEXT_ITEM_OF_PATTERN(item, pattern, index);
+ if (item->type != RTE_FLOW_ITEM_TYPE_ETH) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item, "Not supported by ethertype filter");
+ return -rte_errno;
+ }
+
+ /*Not supported last point for range*/
+ if (item->last) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ item, "Not supported last point for range");
+ return -rte_errno;
+ }
+
+ /* Get the MAC info. */
+ if (!item->spec || !item->mask) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item, "Not supported by ethertype filter");
+ return -rte_errno;
+ }
+
+ eth_spec = (const struct rte_flow_item_eth *)item->spec;
+ eth_mask = (const struct rte_flow_item_eth *)item->mask;
+
+ /* Mask bits of source MAC address must be full of 0.
+ * Mask bits of destination MAC address must be full
+ * of 1 or full of 0.
+ */
+ if (!is_zero_ether_addr(ð_mask->src) ||
+ (!is_zero_ether_addr(ð_mask->dst) &&
+ !is_broadcast_ether_addr(ð_mask->dst))) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item, "Invalid ether address mask");
+ return -rte_errno;
+ }
+
+ if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item, "Invalid ethertype mask");
+ return -rte_errno;
+ }
+
+ /* If mask bits of destination MAC address
+ * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
+ */
+ if (is_broadcast_ether_addr(ð_mask->dst)) {
+ filter->mac_addr = eth_spec->dst;
+ filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
+ } else {
+ filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
+ }
+ filter->ether_type = rte_be_to_cpu_16(eth_spec->type);
+
+ /* Check if the next non-void item is END. */
+ index++;
+ NEXT_ITEM_OF_PATTERN(item, pattern, index);
+ if (item->type != RTE_FLOW_ITEM_TYPE_END) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ item, "Not supported by ethertype filter.");
+ return -rte_errno;
+ }
+
+ /* Parse action */
+
+ index = 0;
+ /* Check if the first non-void action is QUEUE or DROP. */
+ NEXT_ITEM_OF_ACTION(act, actions, index);
+ if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
+ act->type != RTE_FLOW_ACTION_TYPE_DROP) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ act, "Not supported action.");
+ return -rte_errno;
+ }
+
+ 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 non-void item is END */
+ index++;
+ NEXT_ITEM_OF_ACTION(act, actions, index);
+ if (act->type != RTE_FLOW_ACTION_TYPE_END) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ act, "Not supported action.");
+ return -rte_errno;
+ }
+
+ /* Parse attr */
+ /* Must be input direction */
+ if (!attr->ingress) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
+ attr, "Only support ingress.");
+ return -rte_errno;
+ }
+
+ /* Not supported */
+ if (attr->egress) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
+ attr, "Not support egress.");
+ return -rte_errno;
+ }
+
+ /* Not supported */
+ if (attr->priority) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
+ attr, "Not support priority.");
+ return -rte_errno;
+ }
+
+ /* Not supported */
+ if (attr->group) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
+ attr, "Not support group.");
+ return -rte_errno;
+ }
+
+ return 0;
+}
+
+static int
+igb_parse_ethertype_filter(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_eth_ethertype_filter *filter,
+ struct rte_flow_error *error)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int ret;
+
+ MAC_TYPE_FILTER_SUP(hw->mac.type);
+
+ ret = cons_parse_ethertype_filter(attr, pattern,
+ actions, filter, error);
+
+ if (ret)
+ return ret;
+
+ if (hw->mac.type == e1000_82576) {
+ if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576) {
+ memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "queue number not supported "
+ "by ethertype filter");
+ return -rte_errno;
+ }
+ } else {
+ if (filter->queue >= IGB_MAX_RX_QUEUE_NUM) {
+ memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "queue number not supported "
+ "by ethertype filter");
+ return -rte_errno;
+ }
+ }
+
+ if (filter->ether_type == ETHER_TYPE_IPv4 ||
+ filter->ether_type == ETHER_TYPE_IPv6) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "IPv4/IPv6 not supported by ethertype filter");
+ return -rte_errno;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "mac compare is unsupported");
+ return -rte_errno;
+ }
+
+ if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
+ memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "drop option is unsupported");
+ return -rte_errno;
+ }
+
+ return 0;
+}
+
+/**
* Check if the flow rule is supported by igb.
* 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.
@@ -494,6 +750,7 @@ igb_flow_validate(__rte_unused struct rte_eth_dev *dev,
struct rte_flow_error *error)
{
struct rte_eth_ntuple_filter ntuple_filter;
+ struct rte_eth_ethertype_filter ethertype_filter;
int ret;
memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter));
@@ -502,6 +759,12 @@ igb_flow_validate(__rte_unused struct rte_eth_dev *dev,
if (!ret)
return 0;
+ memset(ðertype_filter, 0, sizeof(struct rte_eth_ethertype_filter));
+ ret = igb_parse_ethertype_filter(dev, attr, pattern,
+ actions, ðertype_filter, error);
+ if (!ret)
+ return 0;
+
return ret;
}
--
2.9.3
next prev parent reply other threads:[~2017-06-09 3:21 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 7:12 [PATCH 00/11] net/e1000: Consistent filter API Wei Zhao
2017-05-23 7:12 ` [PATCH 01/11] net/e1000: store and restore TCP SYN filter Wei Zhao
2017-05-23 7:12 ` [PATCH 02/11] net/e1000: restore n-tuple filter Wei Zhao
2017-05-23 7:12 ` [PATCH 03/11] net/e1000: restore ether type filter Wei Zhao
2017-05-23 7:12 ` [PATCH 04/11] net/e1000: restore flex " Wei Zhao
2017-05-23 7:12 ` [PATCH 05/11] net/e1000: parse n-tuple filter Wei Zhao
2017-05-23 7:12 ` [PATCH 06/11] net/e1000: parse ethertype filter Wei Zhao
2017-05-23 7:12 ` [PATCH 07/11] net/e1000: parse TCP SYN filter Wei Zhao
2017-05-23 7:12 ` [PATCH 08/11] net/e1000: parse flex filter Wei Zhao
2017-05-23 7:12 ` [PATCH 09/11] net/e1000: create consistent filter Wei Zhao
2017-05-23 7:13 ` [PATCH 10/11] net/e1000: destroy " Wei Zhao
2017-05-23 7:13 ` [PATCH 11/11] net/e1000: flush all the filter Wei Zhao
2017-05-29 11:01 ` [PATCH 00/11] net/e1000: Consistent filter API Ferruh Yigit
2017-05-31 3:17 ` Zhao1, Wei
2017-06-02 6:36 ` Wei Zhao
2017-06-02 6:36 ` [PATCH v2 01/11] net/e1000: store and restore TCP SYN filter Wei Zhao
2017-06-02 7:51 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 02/11] net/e1000: restore n-tuple filter Wei Zhao
2017-06-02 7:56 ` Lu, Wenzhuo
2017-06-02 8:00 ` Zhao1, Wei
2017-06-02 6:36 ` [PATCH v2 03/11] net/e1000: restore ether type filter Wei Zhao
2017-06-02 8:08 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 04/11] net/e1000: restore flex " Wei Zhao
2017-06-02 8:17 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 05/11] net/e1000: parse n-tuple filter Wei Zhao
2017-06-05 1:21 ` Lu, Wenzhuo
2017-06-05 1:55 ` Zhao1, Wei
2017-06-05 2:36 ` Lu, Wenzhuo
2017-06-05 2:39 ` Zhao1, Wei
2017-06-02 6:36 ` [PATCH v2 06/11] net/e1000: parse ethertype filter Wei Zhao
2017-06-05 3:13 ` Lu, Wenzhuo
2017-06-05 3:26 ` Zhao1, Wei
2017-06-02 6:36 ` [PATCH v2 07/11] net/e1000: parse TCP SYN filter Wei Zhao
2017-06-05 3:16 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 08/11] net/e1000: parse flex filter Wei Zhao
2017-06-05 3:38 ` Lu, Wenzhuo
2017-06-05 3:41 ` Zhao1, Wei
2017-06-02 6:36 ` [PATCH v2 09/11] net/e1000: create consistent filter Wei Zhao
2017-06-05 5:14 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 10/11] net/e1000: destroy " Wei Zhao
2017-06-05 5:41 ` Lu, Wenzhuo
2017-06-05 6:00 ` Zhao1, Wei
2017-06-05 6:08 ` Lu, Wenzhuo
2017-06-02 6:36 ` [PATCH v2 11/11] net/e1000: flush all the filter Wei Zhao
2017-06-05 6:09 ` Lu, Wenzhuo
2017-06-09 3:11 ` [PATCH 00/11] net/e1000: Consistent filter API Wei Zhao
2017-06-09 3:11 ` [PATCH v3 01/11] net/e1000: store and restore TCP SYN filter Wei Zhao
2017-06-09 3:11 ` [PATCH v3 02/11] net/e1000: restore n-tuple filter Wei Zhao
2017-06-09 3:11 ` [PATCH v3 03/11] net/e1000: restore ether type filter Wei Zhao
2017-06-09 3:11 ` [PATCH v3 04/11] net/e1000: restore flex " Wei Zhao
2017-06-09 3:11 ` [PATCH v3 05/11] net/e1000: parse n-tuple filter Wei Zhao
2017-06-09 12:29 ` Ferruh Yigit
2017-06-12 7:47 ` Zhao1, Wei
2017-06-09 3:11 ` Wei Zhao [this message]
2017-06-09 3:11 ` [PATCH v3 07/11] net/e1000: parse TCP SYN filter Wei Zhao
2017-06-09 3:11 ` [PATCH v3 08/11] net/e1000: parse flex filter Wei Zhao
2017-06-09 12:23 ` Ferruh Yigit
2017-06-12 3:25 ` Zhao1, Wei
2017-06-09 3:11 ` [PATCH v3 09/11] net/e1000: create consistent filter Wei Zhao
2017-06-09 3:11 ` [PATCH v3 10/11] net/e1000: destroy " Wei Zhao
2017-06-09 3:11 ` [PATCH v3 11/11] net/e1000: flush all the filter Wei Zhao
2017-06-12 6:30 ` [PATCH 00/11] net/e1000: Consistent filter API Wei Zhao
2017-06-12 6:30 ` [PATCH v4] net/e1000: parse n-tuple filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 01/11] net/e1000: store and restore TCP SYN filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 02/11] net/e1000: restore n-tuple filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 03/11] net/e1000: restore ether type filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 04/11] net/e1000: restore flex " Wei Zhao
2017-06-12 6:30 ` [PATCH v4 05/11] net/e1000: parse n-tuple filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 06/11] net/e1000: parse ethertype filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 07/11] net/e1000: parse TCP SYN filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 08/11] net/e1000: parse flex filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 09/11] net/e1000: create consistent filter Wei Zhao
2017-06-12 6:30 ` [PATCH v4 10/11] net/e1000: destroy " Wei Zhao
2017-06-12 6:30 ` [PATCH v4 11/11] net/e1000: flush all the filter Wei Zhao
2017-06-12 6:48 ` [PATCH 00/11] net/e1000: Consistent filter API Wei Zhao
2017-06-12 6:48 ` [PATCH v5 01/11] net/e1000: store and restore TCP SYN filter Wei Zhao
2017-06-12 10:45 ` Ferruh Yigit
2017-06-14 8:59 ` Zhao1, Wei
2017-06-12 6:48 ` [PATCH v5 02/11] net/e1000: restore n-tuple filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 03/11] net/e1000: restore ether type filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 04/11] net/e1000: restore flex " Wei Zhao
2017-06-12 6:48 ` [PATCH v5 05/11] net/e1000: parse n-tuple filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 06/11] net/e1000: parse ethertype filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 07/11] net/e1000: parse TCP SYN filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 08/11] net/e1000: parse flex filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 09/11] net/e1000: create consistent filter Wei Zhao
2017-06-12 6:48 ` [PATCH v5 10/11] net/e1000: destroy " Wei Zhao
2017-06-12 6:48 ` [PATCH v5 11/11] net/e1000: flush all the filter Wei Zhao
2017-06-12 10:47 ` [PATCH 00/11] net/e1000: Consistent filter API Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496977908-2149-7-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.