From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: dev@dpdk.org
Cc: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>,
Andy Moreton <amoreton@xilinx.com>
Subject: [dpdk-dev] [PATCH] net/sfc: allow PPPoE flow pattern items
Date: Tue, 16 Mar 2021 15:51:44 +0300 [thread overview]
Message-ID: <20210316125144.1016727-1-andrew.rybchenko@oktetlabs.ru> (raw)
From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
These items allow the user to avoid having to set the EtherType field in an
ETH item to match PPPoE traffic. Using a PPPoED (PPPoE discovery) or PPPoES
(PPPoE session) item will lead to EtherType filter being set up with
a corresponding value. If an ETH item provides its own EtherType value,
it will be checked for correctness.
Matching on PPPoE fields is not supported.
Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
drivers/net/sfc/sfc_flow.c | 72 ++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index ab1d2cc595..5fea57250c 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -96,6 +96,7 @@ static sfc_flow_item_parse sfc_flow_parse_udp;
static sfc_flow_item_parse sfc_flow_parse_vxlan;
static sfc_flow_item_parse sfc_flow_parse_geneve;
static sfc_flow_item_parse sfc_flow_parse_nvgre;
+static sfc_flow_item_parse sfc_flow_parse_pppoex;
typedef int (sfc_flow_spec_set_vals)(struct sfc_flow_spec *spec,
unsigned int filters_count_for_one_val,
@@ -1063,6 +1064,63 @@ sfc_flow_parse_nvgre(const struct rte_flow_item *item,
return rc;
}
+/**
+ * Convert PPPoEx item to EFX filter specification.
+ *
+ * @param item[in]
+ * Item specification.
+ * Matching on PPPoEx fields is not supported.
+ * This item can only be used to set or validate the EtherType filter.
+ * Only zero masks are allowed.
+ * Ranging is not supported.
+ * @param efx_spec[in, out]
+ * EFX filter specification to update.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL.
+ */
+static int
+sfc_flow_parse_pppoex(const struct rte_flow_item *item,
+ struct sfc_flow_parse_ctx *parse_ctx,
+ struct rte_flow_error *error)
+{
+ efx_filter_spec_t *efx_spec = parse_ctx->filter;
+ const struct rte_flow_item_pppoe *spec = NULL;
+ const struct rte_flow_item_pppoe *mask = NULL;
+ const struct rte_flow_item_pppoe supp_mask = {};
+ const struct rte_flow_item_pppoe def_mask = {};
+ uint16_t ether_type;
+ int rc;
+
+ rc = sfc_flow_parse_init(item,
+ (const void **)&spec,
+ (const void **)&mask,
+ &supp_mask,
+ &def_mask,
+ sizeof(struct rte_flow_item_pppoe),
+ error);
+ if (rc != 0)
+ return rc;
+
+ if (item->type == RTE_FLOW_ITEM_TYPE_PPPOED)
+ ether_type = RTE_ETHER_TYPE_PPPOE_DISCOVERY;
+ else
+ ether_type = RTE_ETHER_TYPE_PPPOE_SESSION;
+
+ if ((efx_spec->efs_match_flags & EFX_FILTER_MATCH_ETHER_TYPE) != 0) {
+ if (efx_spec->efs_ether_type != ether_type) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM, item,
+ "Invalid EtherType for a PPPoE flow item");
+ return -rte_errno;
+ }
+ } else {
+ efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
+ efx_spec->efs_ether_type = ether_type;
+ }
+
+ return 0;
+}
+
static const struct sfc_flow_item sfc_flow_items[] = {
{
.type = RTE_FLOW_ITEM_TYPE_VOID,
@@ -1085,6 +1143,20 @@ static const struct sfc_flow_item sfc_flow_items[] = {
.ctx_type = SFC_FLOW_PARSE_CTX_FILTER,
.parse = sfc_flow_parse_vlan,
},
+ {
+ .type = RTE_FLOW_ITEM_TYPE_PPPOED,
+ .prev_layer = SFC_FLOW_ITEM_L2,
+ .layer = SFC_FLOW_ITEM_L2,
+ .ctx_type = SFC_FLOW_PARSE_CTX_FILTER,
+ .parse = sfc_flow_parse_pppoex,
+ },
+ {
+ .type = RTE_FLOW_ITEM_TYPE_PPPOES,
+ .prev_layer = SFC_FLOW_ITEM_L2,
+ .layer = SFC_FLOW_ITEM_L2,
+ .ctx_type = SFC_FLOW_PARSE_CTX_FILTER,
+ .parse = sfc_flow_parse_pppoex,
+ },
{
.type = RTE_FLOW_ITEM_TYPE_IPV4,
.prev_layer = SFC_FLOW_ITEM_L2,
--
2.30.1
next reply other threads:[~2021-03-16 12:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 12:51 Andrew Rybchenko [this message]
2021-03-24 12:28 ` 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=20210316125144.1016727-1-andrew.rybchenko@oktetlabs.ru \
--to=andrew.rybchenko@oktetlabs.ru \
--cc=amoreton@xilinx.com \
--cc=dev@dpdk.org \
--cc=viacheslav.galaktionov@oktetlabs.ru \
/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).