From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C73BA0547; Sun, 17 Oct 2021 10:19:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16D7A40041; Sun, 17 Oct 2021 10:19:28 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by mails.dpdk.org (Postfix) with ESMTP id 6CA364003C for ; Sun, 17 Oct 2021 10:19:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MN1UgW8RIgjDc65uP9s7cNsoW2qNfGPweAB8Uw7G5s6Ltte88N2bbpvkOSxJ0PeUm+xzfljhWIUMgj2A666nGKcC2+FNEiKKAqrCW5IKMXxefKExQ2JbZkRA40geGDrwMVMq69It79EVY1EP1ZZSjZyjQc9yopgXMmfvu1jOd6BUCv+/R9YV0Vh2izHja415mTIIq0C1fZPDMWKAaYZ0AW8U6hv+E4hpmynAhHDLZCOfD/+fvwEhSaAVPH8m4IhYEoOe+oikCOvVLeFajbm/Y55KKh9qAGc7UEjvq0Af8hLQTV2jDR62n6xwpfW9ES3/ncMT56dOahKNt/gtZZAHFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/9knH+IzW2icHOGxQRfVrnj2d9+8M9Ch0ycpjc1HcGM=; b=WduaRBZZJmZu6xnEXc9BMkdIbvKd5AjbG67rwQ5bo90IBULJMwRBsdXABNSzG+jbWElJJgwrZrfBa1ZIhU0VkUvfSsNiPI0/t8stmmZZPbuXdN568xYY/ivGVqhozz7EaUvwDuDf/4TTFzo16YjaOob6Zvv1celoIjaYlYKynAyKkDsHmtXihz2TNIaOmTRLKvVGUBLybSD5KQp7UMfpiqyKNn21IoLw1+u/QDaKyxecZ5htz15hGJPcyyhioCCxnVTiHVQJUqUXpPwevaJiQMvksdoXTVo/RkOP1P/O2Q2sCbuMuQepRVvyITQgAMKtm3b85X/4TnUHw/Hl6XKfNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/9knH+IzW2icHOGxQRfVrnj2d9+8M9Ch0ycpjc1HcGM=; b=g3C9G6uKGM0BfjHwL2XuGncszO2MxAdMrBwHg4uYfPJMnmkC6ilh/MEPeCsEeItdoip/7NFdlu0PKXYX1+3uUPmmYTdvTy5fgDVBp9mairriSwYLyCUViafnesIGL0yNNw5hIdVc90/bt6Rk2EP3MBRrRqvtlonLqP0a/UcCN0A5njacyi9OcNR9qf7FOYiLC8fuW+aLQwQ+beLGuyL8L8fo7QlUkLL8xKZgwMZqbAlu9sB6vz02maWrlshYyYf8cFRjQY3BQZ2QlYM57Zw28bRx+wtGc+9YU0t2HwuwOSNvEpgxY8nQm22CA8NoU607ykio+QZ/wgQORqoEesV9IA== Received: from DM8PR12MB5400.namprd12.prod.outlook.com (2603:10b6:8:3b::12) by DM4PR12MB5310.namprd12.prod.outlook.com (2603:10b6:5:39e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Sun, 17 Oct 2021 08:19:23 +0000 Received: from DM8PR12MB5400.namprd12.prod.outlook.com ([fe80::d03d:1f75:ca20:6a32]) by DM8PR12MB5400.namprd12.prod.outlook.com ([fe80::d03d:1f75:ca20:6a32%7]) with mapi id 15.20.4608.018; Sun, 17 Oct 2021 08:19:23 +0000 From: Ori Kam To: Jie Wang , "dev@dpdk.org" CC: "ferruh.yigit@intel.com" , NBU-Contact-Thomas Monjalon , "andrew.rybchenko@oktetlabs.ru" , "xiaoyun.li@intel.com" , "stevex.yang@intel.com" , "jingjing.wu@intel.com" , "beilei.xing@intel.com" , "wenjun1.wu@intel.com" Thread-Topic: [PATCH v3 1/3] ethdev: support PPP and L2TPV2 procotol Thread-Index: AQHXwatBiYGY8uyvw0qbSM22qYx5BqvW2hMA Date: Sun, 17 Oct 2021 08:19:23 +0000 Message-ID: References: <20211012102508.275790-1-jie1x.wang@intel.com> <20211015095823.701188-1-jie1x.wang@intel.com> <20211015095823.701188-2-jie1x.wang@intel.com> In-Reply-To: <20211015095823.701188-2-jie1x.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 31fc5a75-bb5f-4d6c-d087-08d99146d3f2 x-ms-traffictypediagnostic: DM4PR12MB5310: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2089; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ertdLzSrf3LOHzhfGUssiRKGGe1b6EyQ0Efz0X3mPnb5ZoJh60QvITIiZdB7RZVZT9KHXNpZs+FJh1exKLJQ8ZAbCXyhI9+ClzjatC7LssSTPzlZyeapZhV6bKQQMwibp9lxKneSazgpY+RrHISD9dY7vYBnyM6iqROTDOKqiotOXQNh000TlbuvmzgKNX8cLw21fPk+gOjzCvXVw1Tl5pY46MgXuXkGJRyZQ0vJFr/YE0F+U95AjRKxSOERWds0FExC6z7LHvNWG5bD2bUw5Mf9VRmLDhp9hfyf5SI7byC/s6tpq1sPRxB96dYwUQ1OwluafGwtH/Ao2PPgHxF4ZP5xkXJnnk4vGyp6GXd2oq9J26mqZr6LUHh/oaPVVBkNa7jVss1dknfUNj0tiYCnKj47gLhyofhfH+zaPMcUvDU2lJDhuJCtDP15FUYlvvddT1+B7yGDXvZdEDJDvpzjJpDwbYKDTjk95V6TuQoinIrHwmC3RimhWt6DSEB9yCea++rlCI1Rw+eVCRgkHQW4LgHWCGz6qUEPj+J5BAvoBSXEs/CZ9iQypCoVOsGbyjIgVpSlRsz5U3T0xv/J5Uuf6oaZ50ilVSlUTZZpLLb7Ju3S6zWOHsBLmYIFYLT00cb1gIrthZl9x5IPQq4WZcAP+6AsggDApGr2f4CYTfTDcPy2lAT6UywaIzOjKNIaqAFc7QPmucTb/l5IBY0H7O8/NA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR12MB5400.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66556008)(64756008)(66446008)(76116006)(38070700005)(4326008)(66476007)(52536014)(66946007)(7416002)(86362001)(38100700002)(8676002)(2906002)(8936002)(54906003)(110136005)(83380400001)(316002)(508600001)(71200400001)(9686003)(186003)(53546011)(6506007)(55016002)(122000001)(5660300002)(7696005)(30864003)(33656002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?xfD8InnLnr+xkDaD4jmJDx1Q9Dq4UjHOWwr7csXfD7Cu+AGhRNXV++DMAIT9?= =?us-ascii?Q?DnUd+BrlACRfSEbm4Js8QxX+sIurkd319T9x/eAZ3eT8KnRY8lQQM7PyIoIn?= =?us-ascii?Q?aklrThPOoGfpmQSIOzarsXyvtt+gnW80F2/ajsugjvkgrEWPr0YS8XNNYxov?= =?us-ascii?Q?pkF26xkqoxTvHz9Ls3D5Lw6EGlKpwicQNektH6b2Rcn73Ad/IF46Tnb39KSj?= =?us-ascii?Q?6bS2cvaDJd7HNsqNyXKSQcRAdTOWXtzvaAH0bEM041fHBgL7OV6Xx6GrvxP9?= =?us-ascii?Q?oEbzRWAkb+lsseFEgi/A4CoZBR3lviTXmf6KhMxNE9dwgJTTIRRUGMi22XPu?= =?us-ascii?Q?0lqPBYccgAo1nPSEobhQZ7xnNym1YmKMJRyY22kF/0i1RtylbIXkDWwOXCSh?= =?us-ascii?Q?5SHLVpI1MK0HBaTum0QwvfIE3JTSiUQcp86QEVqozNqk/ofc3qDNcoQ1Kscb?= =?us-ascii?Q?kiLBEMzdtE3TUAgzDqnAVuysKHdzq0JUx/535lZG7yxi88YF1mcqaem4bPK2?= =?us-ascii?Q?u6v+qkmPuDjgWH5ZOxZMsAC1ykhPz7aYJPLgx3uRecj25coAyvDr/A0GLx93?= =?us-ascii?Q?1113Y/2ewqfAflQ9B7r9BoaTPqbt7NH6ZiIJd5DaeVYr+v6hebxZBd55T+bb?= =?us-ascii?Q?W2rNHH7q/W8QvbFwMvsdMrq6pSg4JFed+GG4QgKG46sPwpPHnWVCPtJY+EVs?= =?us-ascii?Q?rvy3HqZ3L5KkRcFcKFL/w6Y9p+D0zsekvnLXBgtvfw0GJTpXcKmB5kP4O2JM?= =?us-ascii?Q?0+CnUPRSEhS9WeBWeHFttelz11KZMThoGYuSPSp/9myoBToNwikyjK+rdvT/?= =?us-ascii?Q?uvWgywl4dnkmsPJptu3slEdx/UwwtJF0WOM22GHJYa3v17/dhOOF1DahhCZr?= =?us-ascii?Q?b/pGIv3hAhE5fyagL1lP8dZFrnMVcx84ZqxfOztejYDdM+jtPxMvhMzqSaEE?= =?us-ascii?Q?avZDmwQlssSde4AgNZs4TR7YXquR2uLcIYLL0AolJ/59wmRDa5D959liCaSt?= =?us-ascii?Q?mUxB5xstgRp10iA2ewSFX4G5KMq6++66qdLjXjGM8DLbzolyeBjP2KlWLV93?= =?us-ascii?Q?/k79ueBvEs2vFl5ic9b1Dxvq7D0l+6YxLOMu5l4JCDurm/KUcQ7axITdSBHq?= =?us-ascii?Q?QcEcW1/n+6+0xK6leUCJuJyXaMI3xbJi4mLFTI64TAcAAojxP4cXHlWuZrOZ?= =?us-ascii?Q?HP6VVe0Co4J9YXff5FXAqVWylIfz5nLQK+QMkGCc++CQXoMB01P8opM8zw5b?= =?us-ascii?Q?+YoXLVrLQHtuzCPazq1GzfhOpE7KQSxMthPxfI6+CPqaMItE9i6uIgxgU+Kn?= =?us-ascii?Q?zlKakj20H5bxW7E1TNFGTrnCWp9+nJQ/bpWE744IgApqzd23FDSeee9PoYYE?= =?us-ascii?Q?p1yKF6szVAg6MbQ7zn0LWclR37/Z?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR12MB5400.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31fc5a75-bb5f-4d6c-d087-08d99146d3f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2021 08:19:23.7995 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MmnIh2J5Rr2HQ/aFcZCZ0LlJz64BEWfxZDdEB1skxQh4yuTCVX0kiPaec0Kv02fEL1gbKYKV2ApvAW8MZyty7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5310 Subject: Re: [dpdk-dev] [PATCH v3 1/3] ethdev: support PPP and L2TPV2 procotol X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Jie, > -----Original Message----- > From: Jie Wang > Sent: Friday, October 15, 2021 12:58 PM > To: dev@dpdk.org > Wang > Subject: [PATCH v3 1/3] ethdev: support PPP and L2TPV2 procotol >=20 > Added flow pattern items and header formats of L2TPv2 and PPP to support = PPP over L2TPv2 over > UDP protocol RSS Hash. >=20 Like in the subject you are not talking about RSS you are talking about mat= ching on items. > Signed-off-by: Wenjun Wu > Signed-off-by: Jie Wang > --- > doc/guides/prog_guide/rte_flow.rst | 25 +++ > doc/guides/rel_notes/release_21_11.rst | 5 + > lib/ethdev/rte_flow.c | 2 + > lib/ethdev/rte_flow.h | 117 ++++++++++++++ > lib/net/rte_l2tpv2.h | 214 +++++++++++++++++++++++++ > 5 files changed, 363 insertions(+) > create mode 100644 lib/net/rte_l2tpv2.h >=20 > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/r= te_flow.rst > index 3cb014c1fa..59fe7e79b5 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1425,6 +1425,31 @@ Matches a conntrack state after conntrack action. > - ``flags``: conntrack packet state flags. > - Default ``mask`` matches all state bits. >=20 > +Item: ``L2TPV2`` > +^^^^^^^^^^^^^^^^^^^ > + > +Matches a L2TPv2 header. > + > +- ``flags_version``: flags(12b), version(4b). > +- ``length``: total length of the message. > +- ``tunnel_id``: identifier for the control connection. > +- ``session_id``: identifier for a session within a tunnel. > +- ``ns``: sequence number for this date or control message. > +- ``nr``: sequence number expected in the next control message to be rec= eived. > +- ``offset_size``: offset of payload data. > +- ``offset_padding``: offset padding, variable length. > +- Default ``mask`` matches flags_version only. > + > +Item: ``PPP`` > +^^^^^^^^^^^^^^^^^^^ > + > +Matches a PPP header. > + > +- ``addr``: ppp address. > +- ``ctrl``: ppp control. > +- ``proto_id``: ppp protocol identifier. > +- Default ``mask`` matches addr, ctrl, proto_id. > + > Actions > ~~~~~~~ >=20 > diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_note= s/release_21_11.rst > index d5c762df62..503f6dd828 100644 > --- a/doc/guides/rel_notes/release_21_11.rst > +++ b/doc/guides/rel_notes/release_21_11.rst > @@ -81,6 +81,11 @@ New Features > * Default VLAN strip behavior was changed. VLAN tag won't be stripped > unless ``DEV_RX_OFFLOAD_VLAN_STRIP`` offload is enabled. >=20 > +* **Added L2TPV2 and PPP protocol support in rte_flow.** > + > + Added flow pattern items and header formats of L2TPv2 and PPP to > + support PPP over L2TPv2 over UDP protocol RSS Hash. > + > * **Updated AF_XDP PMD.** >=20 > * Disabled secondary process support. > diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069= c8..1ec739a031 100644 > --- a/lib/ethdev/rte_flow.c > +++ b/lib/ethdev/rte_flow.c > @@ -100,6 +100,8 @@ static const struct rte_flow_desc_data rte_flow_desc_= item[] =3D { > MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)), > MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), > MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), > + MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), > + MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), > }; >=20 > /** Generate flow_action[] entry. */ > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 5f87851f= 8c..f8fcf9c1f8 100644 > --- a/lib/ethdev/rte_flow.h > +++ b/lib/ethdev/rte_flow.h > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include >=20 > #ifdef __cplusplus > extern "C" { > @@ -574,6 +575,21 @@ enum rte_flow_item_type { > * @see struct rte_flow_item_conntrack. > */ > RTE_FLOW_ITEM_TYPE_CONNTRACK, > + > + /** > + * Matches L2TPV2 Header. > + * > + * See struct rte_flow_item_l2tpv2. > + */ > + RTE_FLOW_ITEM_TYPE_L2TPV2, > + > + /** > + * Matches PPP Header. > + * > + * See struct rte_flow_item_ppp. > + */ > + RTE_FLOW_ITEM_TYPE_PPP, > + > }; >=20 > /** > @@ -1799,6 +1815,55 @@ static const struct rte_flow_item_conntrack > rte_flow_item_conntrack_mask =3D { }; #endif >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * RTE_FLOW_ITEM_TYPE_L2TPV2 > + * > + * Matches L2TPv2 Header > + */ > +struct rte_flow_item_l2tpv2 { > + struct rte_l2tpv2_combined_msg_hdr hdr; }; > + > +/** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */ #ifndef __cplusplus > +static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask =3D { > + /* > + * flags and version bit mask > + * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 > + * T L x x S x O P x x x x V V V V > + */ > + .hdr =3D { > + .common =3D { > + .flags_version =3D 0xcb0f, > + }, > + }, > +}; > +#endif > + > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * RTE_FLOW_ITEM_TYPE_PPP > + * > + * Matches PPP Header > + */ > +struct rte_flow_item_ppp { > + uint8_t addr; /**< ppp address(8) */ > + uint8_t ctrl; /**< ppp control(8) */ > + rte_be16_t proto_id; /**< ppp protocol id(16) */ }; > + > +/** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */ #ifndef __cplusplus > +static const struct rte_flow_item_ppp rte_flow_item_ppp_mask =3D { > + .addr =3D 0xff, > + .ctrl =3D 0xff, > + .proto_id =3D 0xffff, > +}; > +#endif > + > /** > * Matching pattern item definition. > * > @@ -2417,6 +2482,23 @@ enum rte_flow_action_type { > * See struct rte_flow_action_meter_color. > */ > RTE_FLOW_ACTION_TYPE_METER_COLOR, > + > + /** > + * Encapsulate flow in L2TPV2 tunnel defined in the > + * rte_flow_action_l2tpv2_encap action structure. > + * > + * See struct rte_flow_action_l2tpv2_encap. > + */ > + RTE_FLOW_ACTION_TYPE_L2TPV2_ENCAP, Does action are not needed, to encap you have the raw encap. My comment about the encap was in the testpmd patch. Where you should see that when you are trying to encap using the raw command it works correctly. This comment is for all encap/decap additions in this patch. > + > + /** > + * Decapsulate outer most L2TPV2 tunnel from matched flow. > + * > + * If flow pattern does not define a valid L2TPV2 tunnel (as specified > + * by RFC2661) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION > + * error. > + */ > + RTE_FLOW_ACTION_TYPE_L2TPV2_DECAP, See comment above. > }; >=20 > /** > @@ -3162,6 +3244,41 @@ struct rte_flow_action_meter_color { > enum rte_color color; /**< Packet color. */ }; >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > + * RTE_FLOW_ACTION_TYPE_L2TPV2_ENCAP > + * > + * L2TPV2 tunnel end-point encapsulation data definition > + * > + * The tunnel definition is provided through the flow item pattern the > + * provided pattern must conform with RFC7637. The flow definition must > +be > + * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the > +end item > + * which is specified by RTE_FLOW_ITEM_TYPE_END. > + * > + * The mask field allows user to specify which fields in the flow item > + * definitions can be ignored and which have valid data and can be used > + * verbatim. > + * > + * Note: the last field is not used in the definition of a tunnel and > +can be > + * ignored. > + * > + * Valid flow definition for RTE_FLOW_ACTION_TYPE_L2TPV2_ENCAP include: > + * > + * - ETH / IPV4 / UDP / L2TPV2 / END > + * - ETH / IPV6 / UDP / L2TPV2 / END > + * - ETH / VLAN / IPV4 / UDP / L2TPV2 / END > + * > + */ > +struct rte_flow_action_l2tpv2_encap { > + /** > + * Encapsulating l2tpv2 tunnel definition > + * (terminated by the END pattern item). > + */ > + struct rte_flow_item *definition; > +}; > + > /** > * Field IDs for MODIFY_FIELD action. > */ > diff --git a/lib/net/rte_l2tpv2.h b/lib/net/rte_l2tpv2.h new file mode 10= 0644 index > 0000000000..aea3c689be > --- /dev/null > +++ b/lib/net/rte_l2tpv2.h > @@ -0,0 +1,214 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2021 Mellanox Technologies, Ltd */ > + > +#ifndef _RTE_L2TPV2_H_ > +#define _RTE_L2TPV2_H_ > + > +/** > + * @file > + * > + * L2TP header: > + * 0 1 2 3 > + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 > + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > + * |T|L|x|x|S|x|O|P|x|x|x|x| Ver | Length (opt) | > + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > + * | Tunnel ID | Session ID | > + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > + * | Ns (opt) | Nr (opt) | > + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > + * | Offset Size (opt) | Offset pad... (opt) > + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > + * > + * The Type (T) bit indicates the type of message. It is set to 0 for a > +data > + * message and 1 for a control message. > + * > + * If the Length (L) bit is 1, the Length field is present. This bit > +MUST be > + * set to 1 for control messages. > + * > + * The x bits are reserved for future extensions. All reserved bits > +MUST > + * be set to 0 on outgoing messages and ignored on incoming messages. > + * > + * If the Sequence (S) bit is set to 1 the Ns and Nr fields are present. > + * The S bit MUST be set to 1 for control messages. > + * > + * If the Offset (O) bit is 1, the Offset Size field is present. The O > + * bit MUST be set to 0 for control messages. > + * > + * If the Priority (P) bit is 1, this data message should receive > + * preferential treatment in its local queuing and transmission. > + * The P bit MUST be set to 0 for control messages. > + * > + * Ver MUST be 2, indicating the version of the L2TP data message header= . > + * > + * The Length field indicates the total length of the message in octets. > + * > + * Tunnel ID indicates the identifier for the control connection. > + * > + * Session ID indicates the identifier for a session within a tunnel. > + * > + * Ns indicates the sequence number for this data or control message. > + * > + * Nr indicates the sequence number expected in the next control > +message > + * to be received. > + * > + * The Offset Size field, if present, specifies the number of octets > + * past the L2TP header at which the payload data is expected to start. > + * Actual data within the offset padding is undefined. If the offset > + * field is present, the L2TP header ends after the last octet of the > + * offset padding. > + */ > + > +#include > +#include > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/** > + * L2TPv2 Common Header > + */ > +RTE_STD_C11 > +struct rte_l2tpv2_common_hdr { > + union { > + rte_be16_t flags_version; > + struct { > +#if RTE_BYTE_ORDER =3D=3D RTE_LITTLE_ENDIAN > + rte_be16_t t:1; /**< message Type */ > + rte_be16_t l:1; /**< length option bit*/ > + rte_be16_t res1:2; /**< reserved */ > + rte_be16_t s:1; /**< ns/nr option bit*/ > + rte_be16_t res2:1; /**< reserved */ > + rte_be16_t o:1; /**< offset option bit*/ > + rte_be16_t p:1; /**< priority option bit*/ > + rte_be16_t res3:4; /**< reserved */ > + rte_be16_t ver:4; /**< protocol version */ > +#elif RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN > + rte_be16_t ver:4; /**< protocol version */ > + rte_be16_t res3:4; /**< reserved */ > + rte_be16_t p:1; /**< priority option bit*/ > + rte_be16_t o:1; /**< offset option bit*/ > + rte_be16_t res2:1; /**< reserved */ > + rte_be16_t s:1; /**< ns/nr option bit*/ > + rte_be16_t res1:2; /**< reserved */ > + rte_be16_t l:1; /**< length option bit*/ > + rte_be16_t t:1; /**< message Type */ > +#endif > + }; > + }; > +}; > + > +/* > + * L2TPv2 message Header contains all options(length, ns, nr, > + * offset size, offset padding). > + */ > +struct rte_l2tpv2_msg_with_all_options { > + rte_be16_t length; /**< length(16) */ > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t ns; /**< Ns(16) */ > + rte_be16_t nr; /**< Nr(16) */ > + rte_be16_t offset_size; /**< offset size(16) */ > + uint8_t *offset_padding; /**< offset padding(variable length) */ > +}; > + > +/* > + * L2TPv2 message Header contains all options except length(ns, nr, > + * offset size, offset padding). > + */ > +struct rte_l2tpv2_msg_without_length { > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t ns; /**< Ns(16) */ > + rte_be16_t nr; /**< Nr(16) */ > + rte_be16_t offset_size; /**< offset size(16) */ > + uint8_t *offset_padding; /**< offset padding(variable length) */ > +}; > + > +/* > + * L2TPv2 message Header contains all options except ns_nr(length, > + * offset size, offset padding). > + * Ns and Nr MUST be toghter. > + */ > +struct rte_l2tpv2_msg_without_ns_nr { > + rte_be16_t length; /**< length(16) */ > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t offset_size; /**< offset size(16) */ > + uint8_t *offset_padding; /**< offset padding(variable length) */ > +}; > + > +/* > + * L2TPv2 message Header contains all options except ns_nr(length, ns, n= r). > + * offset size and offset padding MUST be toghter. > + */ > +struct rte_l2tpv2_msg_without_offset { > + rte_be16_t length; /**< length(16) */ > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t ns; /**< Ns(16) */ > + rte_be16_t nr; /**< Nr(16) */ > +}; > + > +/* > + * L2TPv2 message Header contains options offset size and offset padding= . > + */ > +struct rte_l2tpv2_msg_with_offset { > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t offset_size; /**< offset size(16) */ > + uint8_t *offset_padding; /**< offset padding(variable length) */ > +}; > + > +/* > + * L2TPv2 message Header contains options ns and nr. > + */ > +struct rte_l2tpv2_msg_with_ns_nr { > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > + rte_be16_t ns; /**< Ns(16) */ > + rte_be16_t nr; /**< Nr(16) */ > +}; > + > +/* > + * L2TPv2 message Header contains option length. > + */ > +struct rte_l2tpv2_msg_with_length { > + rte_be16_t length; /**< length(16) */ > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > +}; > + > +/* > + * L2TPv2 message Header without all options. > + */ > +struct rte_l2tpv2_msg_without_all_options { > + rte_be16_t tunnel_id; /**< tunnel id(16) */ > + rte_be16_t session_id; /**< session id(16) */ > +}; > + > +/** > + * L2TPv2 Combined Message Header Format: Common Header + Options */ > +RTE_STD_C11 > +struct rte_l2tpv2_combined_msg_hdr { > + struct rte_l2tpv2_common_hdr common; > + union { > + struct rte_l2tpv2_msg_with_all_options type0; > + struct rte_l2tpv2_msg_without_length type1; > + struct rte_l2tpv2_msg_without_ns_nr type2; > + struct rte_l2tpv2_msg_without_offset type3; > + struct rte_l2tpv2_msg_with_offset type4; > + struct rte_l2tpv2_msg_with_ns_nr type5; > + struct rte_l2tpv2_msg_with_length type6; > + struct rte_l2tpv2_msg_without_all_options type7; > + }; > +}; > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTE_L2TPV2_H_ */ > -- > 2.25.1 Best, Ori