From: Jie Wang <jie1x.wang@intel.com>
To: dev@dpdk.org
Cc: orika@nvidia.com, ferruh.yigit@intel.com, thomas@monjalon.net,
andrew.rybchenko@oktetlabs.ru, xiaoyun.li@intel.com,
stevex.yang@intel.com, jingjing.wu@intel.com,
beilei.xing@intel.com, wenjun1.wu@intel.com,
qi.z.zhang@intel.com, Jie Wang <jie1x.wang@intel.com>
Subject: [dpdk-dev] [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP protocol pattern
Date: Mon, 18 Oct 2021 17:33:52 +0800 [thread overview]
Message-ID: <20211018093352.892788-4-jie1x.wang@intel.com> (raw)
In-Reply-To: <20211018093352.892788-1-jie1x.wang@intel.com>
Add support for test-pmd to parse protocol pattern L2TPv2 and PPP.
Signed-off-by: Wenjun Wu <wenjun1.wu@intel.com>
Signed-off-by: Jie Wang <jie1x.wang@intel.com>
---
app/test-pmd/cmdline_flow.c | 251 ++++++++++++++++++++++++++++++++++++
1 file changed, 251 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a90822b660..c1046e3e28 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -310,6 +310,23 @@ enum index {
ITEM_PORT_REPRESENTOR_PORT_ID,
ITEM_REPRESENTED_PORT,
ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
+ ITEM_L2TPV2,
+ ITEM_L2TPV2_COMMON,
+ ITEM_L2TPV2_COMMON_TYPE,
+ ITEM_L2TPV2_COMMON_TYPE_DATA_L,
+ ITEM_L2TPV2_COMMON_TYPE_CTRL,
+ ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_MSG_CTRL_NR,
+ ITEM_PPP,
+ ITEM_PPP_ADDR,
+ ITEM_PPP_CTRL,
+ ITEM_PPP_PROTO_ID,
/* Validate/create actions. */
ACTIONS,
@@ -1018,6 +1035,8 @@ static const enum index next_item[] = {
ITEM_CONNTRACK,
ITEM_PORT_REPRESENTOR,
ITEM_REPRESENTED_PORT,
+ ITEM_L2TPV2,
+ ITEM_PPP,
END_SET,
ZERO,
};
@@ -1398,6 +1417,31 @@ static const enum index item_represented_port[] = {
ZERO,
};
+static const enum index item_l2tpv2[] = {
+ ITEM_L2TPV2_COMMON,
+ ITEM_NEXT,
+ ZERO,
+};
+
+static const enum index item_l2tpv2_common[] = {
+ ITEM_L2TPV2_COMMON_TYPE,
+ ZERO,
+};
+
+static const enum index item_l2tpv2_common_type[] = {
+ ITEM_L2TPV2_COMMON_TYPE_DATA_L,
+ ITEM_L2TPV2_COMMON_TYPE_CTRL,
+ ZERO,
+};
+
+static const enum index item_ppp[] = {
+ ITEM_PPP_ADDR,
+ ITEM_PPP_CTRL,
+ ITEM_PPP_PROTO_ID,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index next_action[] = {
ACTION_END,
ACTION_VOID,
@@ -1781,6 +1825,9 @@ static int parse_vc_conf(struct context *, const struct token *,
static int parse_vc_item_ecpri_type(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
+ const char *, unsigned int,
+ void *, unsigned int);
static int parse_vc_action_meter_color_type(struct context *,
const struct token *,
const char *, unsigned int, void *,
@@ -3682,6 +3729,153 @@ static const struct token token_list[] = {
item_param),
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
},
+ [ITEM_L2TPV2] = {
+ .name = "l2tpv2",
+ .help = "match l2tpv2 header",
+ .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
+ .next = NEXT(item_l2tpv2),
+ .call = parse_vc,
+ },
+ [ITEM_L2TPV2_COMMON] = {
+ .name = "common",
+ .help = "l2tpv2 common header",
+ .next = NEXT(item_l2tpv2_common),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE] = {
+ .name = "type",
+ .help = "type of common header",
+ .next = NEXT(item_l2tpv2_common_type),
+ .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE_DATA_L] = {
+ .name = "data_l",
+ .help = "Type #6: data message with length option",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_NEXT)),
+ .call = parse_vc_item_l2tpv2_type,
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
+ .name = "length",
+ .help = "message length",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.length)),
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
+ .name = "tunnel_id",
+ .help = "tunnel identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.tunnel_id)),
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
+ .name = "session_id",
+ .help = "session identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.session_id)),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE_CTRL] = {
+ .name = "control",
+ .help = "Type #3: conrtol message contains length, ns, nr options",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_MSG_CTRL_NR,
+ ITEM_NEXT)),
+ .call = parse_vc_item_l2tpv2_type,
+ },
+ [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
+ .name = "length",
+ .help = "message length",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.length)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
+ .name = "tunnel_id",
+ .help = "tunnel identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.tunnel_id)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
+ .name = "session_id",
+ .help = "session identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.session_id)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_NS] = {
+ .name = "ns",
+ .help = "sequence number for message",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.ns)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_NR] = {
+ .name = "nr",
+ .help = "sequence number for next receive message",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.nr)),
+ },
+ [ITEM_PPP] = {
+ .name = "ppp",
+ .help = "match ppp header",
+ .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
+ .next = NEXT(item_ppp),
+ .call = parse_vc,
+ },
+ [ITEM_PPP_ADDR] = {
+ .name = "addr",
+ .help = "ppp address",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
+ },
+ [ITEM_PPP_CTRL] = {
+ .name = "ctrl",
+ .help = "ppp control",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
+ },
+ [ITEM_PPP_PROTO_ID] = {
+ .name = "proto_id",
+ .help = "ppp protocol id",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
+ hdr.proto_id)),
+ },
/* Validate/create actions. */
[ACTIONS] = {
.name = "actions",
@@ -5569,6 +5763,57 @@ parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
return len;
}
+/** Parse L2TPV2 common header type field. */
+static int
+parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len,
+ void *buf, unsigned int size)
+{
+ struct rte_flow_item_l2tpv2 *l2tpv2;
+ struct rte_flow_item_l2tpv2 *l2tpv2_mask;
+ struct rte_flow_item *item;
+ uint32_t data_size;
+ uint8_t msg_type = 0;
+ struct buffer *out = buf;
+ const struct arg *arg;
+
+ (void)size;
+ /* Token name must match. */
+ if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+ return -1;
+ switch (ctx->curr) {
+ case ITEM_L2TPV2_COMMON_TYPE_DATA_L:
+ msg_type |= 0x4000;
+ break;
+ case ITEM_L2TPV2_COMMON_TYPE_CTRL:
+ msg_type |= 0xC800;
+ break;
+ default:
+ return -1;
+ }
+ if (!ctx->object)
+ return len;
+ arg = pop_args(ctx);
+ if (!arg)
+ return -1;
+ l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
+ l2tpv2->hdr.common.flags_version |= msg_type;
+ data_size = ctx->objdata / 3; /* spec, last, mask */
+ l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
+ (data_size * 2));
+ l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
+ if (arg->hton) {
+ l2tpv2->hdr.common.flags_version =
+ rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
+ l2tpv2_mask->hdr.common.flags_version =
+ rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
+ }
+ item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
+ item->spec = l2tpv2;
+ item->mask = l2tpv2_mask;
+ return len;
+}
+
/** Parse meter color action type. */
static int
parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -8461,6 +8706,12 @@ flow_item_default_mask(const struct rte_flow_item *item)
case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
mask = &rte_flow_item_ethdev_mask;
break;
+ case RTE_FLOW_ITEM_TYPE_L2TPV2:
+ mask = &rte_flow_item_l2tpv2_mask;
+ break;
+ case RTE_FLOW_ITEM_TYPE_PPP:
+ mask = &rte_flow_item_ppp_mask;
+ break;
default:
break;
}
--
2.25.1
next prev parent reply other threads:[~2021-10-18 9:34 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 15:17 [dpdk-dev] [PATCH 0/4] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-09-24 15:17 ` [dpdk-dev] [PATCH 1/4] net/iavf: support PPPoL2TPv2oUDP over IPv4 " Jie Wang
2021-09-24 15:17 ` [dpdk-dev] [PATCH 2/4] app/testpmd: support PPPoL2TPv2oUDP " Jie Wang
2021-09-24 15:17 ` [dpdk-dev] [PATCH 3/4] ethdev: " Jie Wang
2021-09-30 14:38 ` Ori Kam
2021-10-05 14:42 ` Ferruh Yigit
2021-10-05 15:06 ` Ori Kam
2021-09-24 15:17 ` [dpdk-dev] [PATCH 4/4] net/iavf: support PPPoL2TPv2oUDP over IPv6 " Jie Wang
2021-10-12 10:25 ` [dpdk-dev] [PATCH v2 0/3] support PPPoL2TPv2oUDP " Jie Wang
2021-10-12 10:25 ` [dpdk-dev] [PATCH v2 1/3] net/iavf: " Jie Wang
2021-10-12 10:25 ` [dpdk-dev] [PATCH v2 2/3] app/testpmd: " Jie Wang
2021-10-12 15:31 ` Ori Kam
2021-10-13 8:15 ` Wang, Jie1X
2021-10-13 9:15 ` Ori Kam
2021-10-13 9:54 ` Wang, Jie1X
2021-10-13 10:19 ` Ori Kam
2021-10-12 10:25 ` [dpdk-dev] [PATCH v2 3/3] ethdev: " Jie Wang
2021-10-12 15:28 ` Ori Kam
2021-10-15 9:58 ` [dpdk-dev] [PATCH v3 0/3] " Jie Wang
2021-10-15 9:58 ` [dpdk-dev] [PATCH v3 1/3] ethdev: support PPP and L2TPV2 procotol Jie Wang
2021-10-15 11:10 ` Ferruh Yigit
2021-10-17 8:12 ` Ori Kam
2021-10-17 8:19 ` Ori Kam
2021-10-15 9:58 ` [dpdk-dev] [PATCH v3 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-15 9:58 ` [dpdk-dev] [PATCH v3 3/3] app/testpmd: support L2TPV2 and PPP protocol pattern Jie Wang
2021-10-17 8:51 ` Ori Kam
2021-10-18 9:33 ` [dpdk-dev] [PATCH v4 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-18 9:33 ` [dpdk-dev] [PATCH v4 1/3] ethdev: support PPP and L2TPV2 procotol Jie Wang
2021-10-18 10:56 ` Ori Kam
2021-10-18 12:39 ` Zhang, Qi Z
2021-10-18 9:33 ` [dpdk-dev] [PATCH v4 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-18 9:33 ` Jie Wang [this message]
2021-10-18 11:03 ` [dpdk-dev] [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP protocol pattern Ori Kam
2021-10-18 12:41 ` Zhang, Qi Z
2021-10-19 3:08 ` [dpdk-dev] [PATCH v5 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-19 3:08 ` [dpdk-dev] [PATCH v5 1/3] ethdev: support PPP and L2TPV2 procotol Jie Wang
2021-10-19 6:17 ` Ori Kam
2021-10-19 10:30 ` Ferruh Yigit
2021-10-19 3:08 ` [dpdk-dev] [PATCH v5 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-20 1:57 ` Xing, Beilei
2021-10-19 3:08 ` [dpdk-dev] [PATCH v5 3/3] app/testpmd: support L2TPV2 and PPP protocol pattern Jie Wang
2021-10-19 9:41 ` Ferruh Yigit
2021-10-20 9:32 ` [dpdk-dev] [PATCH v6 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-20 9:32 ` [dpdk-dev] [PATCH v6 1/3] ethdev: support PPP and L2TPV2 procotol Jie Wang
2021-10-20 9:53 ` Andrew Rybchenko
2021-10-20 9:32 ` [dpdk-dev] [PATCH v6 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 2:07 ` Xing, Beilei
2021-10-20 9:32 ` [dpdk-dev] [PATCH v6 3/3] app/testpmd: support L2TPV2 and PPP protocol pattern Jie Wang
2021-10-21 6:26 ` [dpdk-dev] [PATCH v7 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 6:26 ` [dpdk-dev] [PATCH v7 1/3] ethdev: support L2TPv2 and PPP procotol Jie Wang
2021-10-21 7:50 ` Ori Kam
2021-10-21 7:52 ` Andrew Rybchenko
2021-10-21 8:28 ` Wang, Jie1X
2021-10-21 8:30 ` Andrew Rybchenko
2021-10-21 8:41 ` Wang, Jie1X
2021-10-21 13:18 ` Ori Kam
2021-10-21 9:26 ` Ferruh Yigit
2021-10-21 9:29 ` Ferruh Yigit
2021-10-21 6:26 ` [dpdk-dev] [PATCH v7 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 6:26 ` [dpdk-dev] [PATCH v7 3/3] app/testpmd: support L2TPv2 and PPP protocol pattern Jie Wang
2021-10-21 10:05 ` [dpdk-dev] [PATCH v8 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 10:05 ` [dpdk-dev] [PATCH v8 1/3] ethdev: support L2TPv2 and PPP procotol Jie Wang
2021-10-21 10:13 ` Andrew Rybchenko
2021-10-21 10:05 ` [dpdk-dev] [PATCH v8 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 10:05 ` [dpdk-dev] [PATCH v8 3/3] app/testpmd: support L2TPv2 and PPP protocol pattern Jie Wang
2021-10-21 10:49 ` [dpdk-dev] [PATCH v9 0/3] support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 10:49 ` [dpdk-dev] [PATCH v9 1/3] ethdev: support L2TPv2 and PPP procotol Jie Wang
2021-10-21 12:16 ` Ferruh Yigit
2021-10-21 10:49 ` [dpdk-dev] [PATCH v9 2/3] net/iavf: support PPPoL2TPv2oUDP RSS Hash Jie Wang
2021-10-21 10:49 ` [dpdk-dev] [PATCH v9 3/3] app/testpmd: support L2TPv2 and PPP protocol pattern Jie Wang
2021-10-21 12:17 ` [dpdk-dev] [PATCH v9 0/3] support PPPoL2TPv2oUDP RSS Hash 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=20211018093352.892788-4-jie1x.wang@intel.com \
--to=jie1x.wang@intel.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=jingjing.wu@intel.com \
--cc=orika@nvidia.com \
--cc=qi.z.zhang@intel.com \
--cc=stevex.yang@intel.com \
--cc=thomas@monjalon.net \
--cc=wenjun1.wu@intel.com \
--cc=xiaoyun.li@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).