From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B3A46A0C43;
	Mon, 18 Oct 2021 14:41:46 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 99A5240142;
	Mon, 18 Oct 2021 14:41:46 +0200 (CEST)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by mails.dpdk.org (Postfix) with ESMTP id 38ACA40141
 for <dev@dpdk.org>; Mon, 18 Oct 2021 14:41:44 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="228186585"
X-IronPort-AV: E=Sophos;i="5.85,382,1624345200"; d="scan'208";a="228186585"
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 18 Oct 2021 05:41:43 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.85,382,1624345200"; d="scan'208";a="526233686"
Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81])
 by orsmga001.jf.intel.com with ESMTP; 18 Oct 2021 05:41:43 -0700
Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by
 fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12; Mon, 18 Oct 2021 05:41:40 -0700
Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by
 SHSMSX606.ccr.corp.intel.com (10.109.6.216) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12; Mon, 18 Oct 2021 20:41:38 +0800
Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by
 SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2242.012;
 Mon, 18 Oct 2021 20:41:38 +0800
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: Ori Kam <orika@nvidia.com>, "Wang, Jie1X" <jie1x.wang@intel.com>,
 "dev@dpdk.org" <dev@dpdk.org>
CC: "Yigit, Ferruh" <ferruh.yigit@intel.com>, NBU-Contact-Thomas Monjalon
 <thomas@monjalon.net>, "andrew.rybchenko@oktetlabs.ru"
 <andrew.rybchenko@oktetlabs.ru>, "Li, Xiaoyun" <xiaoyun.li@intel.com>, "Yang, 
 SteveX" <stevex.yang@intel.com>, "Wu, Jingjing" <jingjing.wu@intel.com>,
 "Xing, Beilei" <beilei.xing@intel.com>, "Wu, Wenjun1" <wenjun1.wu@intel.com>
Thread-Topic: [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP protocol
 pattern
Thread-Index: AQHXxANdeg4q8SRhAkCUOHCa9ZohIKvYEWOAgACf/JA=
Date: Mon, 18 Oct 2021 12:41:38 +0000
Message-ID: <2ccd94ba6ade4f739ce2b25689f2117b@intel.com>
References: <20211015095823.701188-1-jie1x.wang@intel.com>
 <20211018093352.892788-1-jie1x.wang@intel.com>
 <20211018093352.892788-4-jie1x.wang@intel.com>
 <DM8PR12MB54006123A16ED5CE907D042DD6BC9@DM8PR12MB5400.namprd12.prod.outlook.com>
In-Reply-To: <DM8PR12MB54006123A16ED5CE907D042DD6BC9@DM8PR12MB5400.namprd12.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-reaction: no-action
dlp-version: 11.6.200.16
dlp-product: dlpe-windows
x-originating-ip: [10.239.127.36]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP
 protocol pattern
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>



> -----Original Message-----
> From: Ori Kam <orika@nvidia.com>
> Sent: Monday, October 18, 2021 7:03 PM
> To: Wang, Jie1X <jie1x.wang@intel.com>; dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; NBU-Contact-Thomas Monjalon
> <thomas@monjalon.net>; andrew.rybchenko@oktetlabs.ru; Li, Xiaoyun
> <xiaoyun.li@intel.com>; Yang, SteveX <stevex.yang@intel.com>; Wu, Jingjin=
g
> <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu, Wenjun=
1
> <wenjun1.wu@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: RE: [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP protocol
> pattern
>=20
> Hi Jie,
>=20
>=20
> > -----Original Message-----
> > From: Jie Wang <jie1x.wang@intel.com>
> > Sent: Monday, October 18, 2021 12:34 PM
> > To: dev@dpdk.org
> > Subject: [PATCH v4 3/3] app/testpmd: support L2TPV2 and PPP protocol
> > pattern
> >
> > 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>
> > ---
>=20
>=20
>=20
> >  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[] =3D {
> >  	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[]
> =3D {
> >  	ZERO,
> >  };
> >
> > +static const enum index item_l2tpv2[] =3D {
> > +	ITEM_L2TPV2_COMMON,
> > +	ITEM_NEXT,
> > +	ZERO,
> > +};
> > +
> > +static const enum index item_l2tpv2_common[] =3D {
> > +	ITEM_L2TPV2_COMMON_TYPE,
> > +	ZERO,
> > +};
> > +
> > +static const enum index item_l2tpv2_common_type[] =3D {
> > +	ITEM_L2TPV2_COMMON_TYPE_DATA_L,
> > +	ITEM_L2TPV2_COMMON_TYPE_CTRL,
> > +	ZERO,
> > +};
> > +
> > +static const enum index item_ppp[] =3D {
> > +	ITEM_PPP_ADDR,
> > +	ITEM_PPP_CTRL,
> > +	ITEM_PPP_PROTO_ID,
> > +	ITEM_NEXT,
> > +	ZERO,
> > +};
> > +
> >  static const enum index next_action[] =3D {
> >  	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 to=
ken *,
> > +				    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[] =3D {
> >  			     item_param),
> >  		.args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
> >  	},
> > +	[ITEM_L2TPV2] =3D {
> > +		.name =3D "l2tpv2",
> > +		.help =3D "match l2tpv2 header",
> > +		.priv =3D PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
> > +		.next =3D NEXT(item_l2tpv2),
> > +		.call =3D parse_vc,
> > +	},
> > +	[ITEM_L2TPV2_COMMON] =3D {
> > +		.name =3D "common",
> > +		.help =3D "l2tpv2 common header",
> > +		.next =3D NEXT(item_l2tpv2_common),
> > +	},
> > +	[ITEM_L2TPV2_COMMON_TYPE] =3D {
> > +		.name =3D "type",
> > +		.help =3D "type of common header",
> > +		.next =3D NEXT(item_l2tpv2_common_type),
> > +		.args =3D ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
> > +	},
> > +	[ITEM_L2TPV2_COMMON_TYPE_DATA_L] =3D {
> > +		.name =3D "data_l",
> > +		.help =3D "Type #6: data message with length option",
> > +		.next =3D 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 =3D parse_vc_item_l2tpv2_type,
> > +	},
> > +	[ITEM_L2TPV2_MSG_DATA_L_LENGTH] =3D {
> > +		.name =3D "length",
> > +		.help =3D "message length",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type6.length)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] =3D {
> > +		.name =3D "tunnel_id",
> > +		.help =3D "tunnel identifier",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type6.tunnel_id)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] =3D {
> > +		.name =3D "session_id",
> > +		.help =3D "session identifier",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type6.session_id)),
> > +	},
> > +	[ITEM_L2TPV2_COMMON_TYPE_CTRL] =3D {
> > +		.name =3D "control",
> > +		.help =3D "Type #3: conrtol message contains length, ns, nr options"=
,
> > +		.next =3D 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 =3D parse_vc_item_l2tpv2_type,
> > +	},
> > +	[ITEM_L2TPV2_MSG_CTRL_LENGTH] =3D {
> > +		.name =3D "length",
> > +		.help =3D "message length",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type3.length)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] =3D {
> > +		.name =3D "tunnel_id",
> > +		.help =3D "tunnel identifier",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type3.tunnel_id)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_CTRL_SESSION_ID] =3D {
> > +		.name =3D "session_id",
> > +		.help =3D "session identifier",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type3.session_id)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_CTRL_NS] =3D {
> > +		.name =3D "ns",
> > +		.help =3D "sequence number for message",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type3.ns)),
> > +	},
> > +	[ITEM_L2TPV2_MSG_CTRL_NR] =3D {
> > +		.name =3D "nr",
> > +		.help =3D "sequence number for next receive message",
> > +		.next =3D NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
> > +					ITEM_L2TPV2_COMMON, ITEM_NEXT),
> > +			     NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
> > +					     hdr.type3.nr)),
> > +	},
> > +	[ITEM_PPP] =3D {
> > +		.name =3D "ppp",
> > +		.help =3D "match ppp header",
> > +		.priv =3D PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
> > +		.next =3D NEXT(item_ppp),
> > +		.call =3D parse_vc,
> > +	},
> > +	[ITEM_PPP_ADDR] =3D {
> > +		.name =3D "addr",
> > +		.help =3D "ppp address",
> > +		.next =3D NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
> > +	},
> > +	[ITEM_PPP_CTRL] =3D {
> > +		.name =3D "ctrl",
> > +		.help =3D "ppp control",
> > +		.next =3D NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
> > +	},
> > +	[ITEM_PPP_PROTO_ID] =3D {
> > +		.name =3D "proto_id",
> > +		.help =3D "ppp protocol id",
> > +		.next =3D NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
> > +			     item_param),
> > +		.args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
> > +					hdr.proto_id)),
> > +	},
> >  	/* Validate/create actions. */
> >  	[ACTIONS] =3D {
> >  		.name =3D "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 *tok=
en,
> > +			 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 =3D 0;
> > +	struct buffer *out =3D 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 |=3D 0x4000;
> > +		break;
> > +	case ITEM_L2TPV2_COMMON_TYPE_CTRL:
> > +		msg_type |=3D 0xC800;
> > +		break;
> > +	default:
> > +		return -1;
> > +	}
> > +	if (!ctx->object)
> > +		return len;
> > +	arg =3D pop_args(ctx);
> > +	if (!arg)
> > +		return -1;
> > +	l2tpv2 =3D (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
> > +	l2tpv2->hdr.common.flags_version |=3D msg_type;
> > +	data_size =3D ctx->objdata / 3; /* spec, last, mask */
> > +	l2tpv2_mask =3D (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
> > +						    (data_size * 2));
> > +	l2tpv2_mask->hdr.common.flags_version =3D 0xFFFF;
> > +	if (arg->hton) {
> > +		l2tpv2->hdr.common.flags_version =3D
> > +			rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
> > +		l2tpv2_mask->hdr.common.flags_version =3D
> > +		    rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
> > +	}
> > +	item =3D &out->args.vc.pattern[out->args.vc.pattern_n - 1];
> > +	item->spec =3D l2tpv2;
> > +	item->mask =3D 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 =3D &rte_flow_item_ethdev_mask;
> >  		break;
> > +	case RTE_FLOW_ITEM_TYPE_L2TPV2:
> > +		mask =3D &rte_flow_item_l2tpv2_mask;
> > +		break;
> > +	case RTE_FLOW_ITEM_TYPE_PPP:
> > +		mask =3D &rte_flow_item_ppp_mask;
> > +		break;
> >  	default:
> >  		break;
> >  	}
> > --
> > 2.25.1
>=20
> I see that you are missing updating the cmd_set_raw_parsed function, with=
out
> it raw encap/decap will not work for your new tunnel header.

Hi Ori:

	We are not going to enable encap / decap feature for L2TPv2 (at least in t=
his release), our goal is to create RSS / FDIR rule for packet with L2PTv2 =
header.=20

Thanks
Qi

>=20
> Best,
> Ori