From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50069.outbound.protection.outlook.com [40.107.5.69]) by dpdk.org (Postfix) with ESMTP id DAFAC1B456 for ; Thu, 4 Oct 2018 15:55:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ccyK7FGQW0IVIx/3/o4Bp6WV/9SG2d2ixkG7miUgenU=; b=AiBGsP4qtjA+oer2WxnwJHsF+fk+Q6FGgMGBXJB+oXHunkFu0Ms+RorToBWmNDHrQZVCqhD5b5ZfFJ791kpIhOn+fPsczYaVSdESfMMIMp9WHYABG14Wwlq6IioZ48/xlPwliXBUj2SNp/AwtdAVwYXovKyrdfbdG4WsqND9fXo= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.187.142) by AM4PR05MB1603.eurprd05.prod.outlook.com (10.165.245.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Thu, 4 Oct 2018 13:55:13 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::fdeb:3890:f0f0:2202]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::fdeb:3890:f0f0:2202%4]) with mapi id 15.20.1207.022; Thu, 4 Oct 2018 13:55:13 +0000 From: Ori Kam To: Rahul Lakkireddy , "dev@dpdk.org" CC: "indranil@chelsio.com" , "nirranjan@chelsio.com" Thread-Topic: [dpdk-dev] [PATCH 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers Thread-Index: AQHUU+CpDPk176Vj6kmNxJkG4fQnUaUPK10g Date: Thu, 4 Oct 2018 13:55:13 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB1603; 6:3YNeIPJIfiYhu77d/XqzJ5NyMasdBFRTATsit5Yb8GVaO4u1iQsdKIIFg5SyB1PfaBynCzksHgMEsT2xsgcPybdvVjwCiMw8aBoCoHiiNsJKYtfJP8Ec4fFCJheZ8o+aFGhc7QFXdxyAVs1AW7TqMV3Yp9YpzNaxLP29eIr+cEQ9GAZdaBHDHTBAVgB45saIRlwz5NcPXqJZvdkXV3uSuSqclMMRclrjOTdMdhj7VWxGPX/nz89pUZYb+XJrL+YyeWqk/V++RfcTWSH0FZee32rO9IHY81HCWyDsQR1r3NBEwiKIBT+UrzsgQd9LfHld+PLtLQV07sHCjbUGZdXvSxqkPtvQyF92Uy0P3vfOyPptQey1NmiN2j67m7ymhSJgXvrd+vmYWK/9JyvdBAmy2V9+ca7UJFgGznixIsgquWsRAn2DQiVg6SIpAlM/jrZAJm667bXkkIElxJU6XxZqOQ==; 5:X1J8KR+pKi7LSYFpXSbuya75etmOdx5rjCf2mpX9cs45/CQrxkR/RvwV9KagGxwAwUs1QrUqEguMTu/lnbYJi16OyxVTHvUbFUz+LNhtc2Lb72kGiVJq8kA/6+n24oNKhOvRjezmfE7Tw1VfBqRylves+ihx2v2PLD6ulynqu4w=; 7:8BJQfpKkMc9+96hLQG904putnBD/oKrLtdM5hPfwU4El+QJ9ZpFW8LPFpsiO/quyQt/muAIUBZMT6WHwAHNdrvHrUbiAUC8PTgBIezZs/O1XfWv41XYBD74/cKn9QsfOv170ww+HeaYBDL+GjBig1ZpfS405sxEuzbCfltZGpoWariyf9J39g8LBlXQcsyzBcKrVcYTj8dp+qW4afIk/I+v31TtG2wrFRjyymVm6RoLCcDnFJNLQKqJUDZMIjozK x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: de3beef3-d290-4587-3fa3-08d62a010213 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB1603; x-ms-traffictypediagnostic: AM4PR05MB1603: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991048); SRVR:AM4PR05MB1603; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB1603; x-forefront-prvs: 0815F8251E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(396003)(376002)(39860400002)(189003)(199004)(13464003)(81156014)(102836004)(105586002)(26005)(11346002)(2906002)(305945005)(14444005)(316002)(25786009)(3846002)(6116002)(74316002)(99286004)(7736002)(186003)(229853002)(476003)(7696005)(4326008)(54906003)(5250100002)(71200400001)(110136005)(71190400001)(575784001)(86362001)(486006)(66066001)(478600001)(8936002)(2900100001)(106356001)(2501003)(53936002)(55016002)(33656002)(81166006)(76176011)(446003)(6246003)(6436002)(5660300001)(9686003)(68736007)(256004)(53546011)(6506007)(14454004)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1603; H:AM4PR05MB3425.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: mS4ijlBI5O/3MOD6vMaQuzy4zmFXLf+wNRxZwmQ7z2ceF6LRsWCWEGL1tLGFRESPNpIsWFwT5IiNjHJMBs4rsE0JbNnpIaxjXDiSPrZbApLeKd/+Q782szMpJdzRZlcdxMp282JNvH+iH2Gy0jlJg8ERQCm0aL76wtaQaBNx4GtlNvL+ODKX4qPNZMPIHkqcR7uuohaqJ9+pbbIwvZMoQSifIaSfJJDozdXwxzw/zVNX3sTcUH2WMJ9DscyeOCmqyl2dKmMrBndPESa9VaZsMuTwMLu5hNXVnkg6cNjT3IW6bHMy3jgbe8kVWd8qAIn+LjHjgQN8iQGFynayQkHb7eVPrsn/4f7yboXcdFi2XLA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: de3beef3-d290-4587-3fa3-08d62a010213 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Oct 2018 13:55:13.6559 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1603 Subject: Re: [dpdk-dev] [PATCH 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Oct 2018 13:55:16 -0000 > -----Original Message----- > From: dev On Behalf Of Rahul Lakkireddy > Sent: Monday, September 24, 2018 11:28 AM > To: dev@dpdk.org > Cc: indranil@chelsio.com; nirranjan@chelsio.com > Subject: [dpdk-dev] [PATCH 2/3] ethdev: add flow api actions to modify > TCP/UDP port numbers >=20 > Add actions: > - SET_TP_SRC - set a new TCP/UDP source port number. > - SET_TP_DST - set a new TCP/UDP destination port number. >=20 > Original work by Shagun Agrawal >=20 > Signed-off-by: Rahul Lakkireddy > --- > Changes since RFC v2: > - Updated comments, help messages, and doc to indicate that IP/TCP/UDP > of the outermost headers are modified. > - Updated comments and doc to indicate that a corresponding valid flow > pattern item must be specified to offload corresponding header rewrite > action. > - Updated release notes. >=20 > app/test-pmd/cmdline_flow.c | 52 +++++++++++++++++++++ > app/test-pmd/config.c | 4 ++ > doc/guides/prog_guide/rte_flow.rst | 36 ++++++++++++++ > doc/guides/rel_notes/release_18_11.rst | 2 + > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 ++++ > lib/librte_ethdev/rte_flow.c | 4 ++ > lib/librte_ethdev/rte_flow.h | 37 +++++++++++++++ > 7 files changed, 145 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 1432498a3..a9888cacf 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -251,6 +251,10 @@ enum index { > ACTION_SET_IPV6_SRC_IPV6_SRC, > ACTION_SET_IPV6_DST, > ACTION_SET_IPV6_DST_IPV6_DST, > + ACTION_SET_TP_SRC, > + ACTION_SET_TP_SRC_TP_SRC, > + ACTION_SET_TP_DST, > + ACTION_SET_TP_DST_TP_DST, > }; >=20 > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -828,6 +832,8 @@ static const enum index next_action[] =3D { > ACTION_SET_IPV4_DST, > ACTION_SET_IPV6_SRC, > ACTION_SET_IPV6_DST, > + ACTION_SET_TP_SRC, > + ACTION_SET_TP_DST, > ZERO, > }; >=20 > @@ -954,6 +960,18 @@ static const enum index action_set_ipv6_dst[] =3D { > ZERO, > }; >=20 > +static const enum index action_set_tp_src[] =3D { > + ACTION_SET_TP_SRC_TP_SRC, > + ACTION_NEXT, > + ZERO, > +}; > + > +static const enum index action_set_tp_dst[] =3D { > + ACTION_SET_TP_DST_TP_DST, > + ACTION_NEXT, > + ZERO, > +}; > + > static const enum index action_jump[] =3D { > ACTION_JUMP_GROUP, > ACTION_NEXT, > @@ -2574,6 +2592,40 @@ static const struct token token_list[] =3D { > (struct rte_flow_action_set_ipv6, ipv6_addr)), > .call =3D parse_vc_conf, > }, > + [ACTION_SET_TP_SRC] =3D { > + .name =3D "set_tp_src", > + .help =3D "set a new source port number in the outermost" > + " TCP/UDP header", > + .priv =3D PRIV_ACTION(SET_TP_SRC, > + sizeof(struct rte_flow_action_set_tp)), > + .next =3D NEXT(action_set_tp_src), > + .call =3D parse_vc, > + }, > + [ACTION_SET_TP_SRC_TP_SRC] =3D { > + .name =3D "port", > + .help =3D "new source port number to set", > + .next =3D NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY_HTON > + (struct rte_flow_action_set_tp, port)), > + .call =3D parse_vc_conf, > + }, > + [ACTION_SET_TP_DST] =3D { > + .name =3D "set_tp_dst", > + .help =3D "set a new destination port number in the outermost" > + " TCP/UDP header", > + .priv =3D PRIV_ACTION(SET_TP_DST, > + sizeof(struct rte_flow_action_set_tp)), > + .next =3D NEXT(action_set_tp_dst), > + .call =3D parse_vc, > + }, > + [ACTION_SET_TP_DST_TP_DST] =3D { > + .name =3D "port", > + .help =3D "new destination port number to set", > + .next =3D NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY_HTON > + (struct rte_flow_action_set_tp, port)), > + .call =3D parse_vc_conf, > + }, > }; >=20 > /** Remove and return last entry from argument stack. */ > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index 14dbdf7a3..1629a6d7a 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1180,6 +1180,10 @@ static const struct { > sizeof(struct rte_flow_action_set_ipv6)), > MK_FLOW_ACTION(SET_IPV6_DST, > sizeof(struct rte_flow_action_set_ipv6)), > + MK_FLOW_ACTION(SET_TP_SRC, > + sizeof(struct rte_flow_action_set_tp)), > + MK_FLOW_ACTION(SET_TP_DST, > + sizeof(struct rte_flow_action_set_tp)), > }; >=20 > /** Compute storage space needed by action configuration and copy it. */ > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index b9bcaa3d1..4be160209 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -2148,6 +2148,42 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error > will be returned. > | ``ipv6_addr`` | new IPv6 destination address | > +---------------+------------------------------+ >=20 > +Action: ``SET_TP_SRC`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set a new source port number in the outermost TCP/UDP header. > + > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or > RTE_FLOW_ITEM_TYPE_UDP > +flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be > returned. > + > +.. _table_rte_flow_action_set_tp_src: > + > +.. table:: SET_TP_SRC > + > + +----------+-------------------------+ > + | Field | Value | > + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > + | ``port`` | new TCP/UDP source port | > + +---------------+--------------------+ > + > +Action: ``SET_TP_DST`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set a new destination port number in the outermost TCP/UDP header. > + > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or > RTE_FLOW_ITEM_TYPE_UDP > +flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be > returned. > + > +.. _table_rte_flow_action_set_tp_dst: > + > +.. table:: SET_TP_DST > + > + +----------+------------------------------+ > + | Field | Value | > + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > + | ``port`` | new TCP/UDP destination port | > + +---------------+-------------------------+ > + > Negative types > ~~~~~~~~~~~~~~ >=20 > diff --git a/doc/guides/rel_notes/release_18_11.rst > b/doc/guides/rel_notes/release_18_11.rst > index 782722318..84b0a6a4b 100644 > --- a/doc/guides/rel_notes/release_18_11.rst > +++ b/doc/guides/rel_notes/release_18_11.rst > @@ -93,6 +93,8 @@ New Features >=20 > * Modify source and destination IP addresses in the outermost IPv4/IPv= 6 > headers. > + * Modify source and destination port numbers in the outermost TCP/UDP > + headers. >=20 > API Changes > ----------- > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 97d91f066..ffec7013b 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3722,6 +3722,16 @@ This section lists supported actions and their > attributes, if any. >=20 > - ``ipv6_addr``: New IPv6 destination address. >=20 > +- ``of_set_tp_src``: Set a new source port number in the outermost TCP/U= DP > + header. > + > + - ``port``: New TCP/UDP source port number. > + > +- ``of_set_tp_dst``: Set a new destination port number in the outermost > TCP/UDP > + header. > + > + - ``port``: New TCP/UDP destination port number. > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ >=20 > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index d4f1b9a05..409c79741 100644 > --- a/lib/librte_ethdev/rte_flow.c > +++ b/lib/librte_ethdev/rte_flow.c > @@ -117,6 +117,10 @@ static const struct rte_flow_desc_data > rte_flow_desc_action[] =3D { > sizeof(struct rte_flow_action_set_ipv6)), > MK_FLOW_ACTION(SET_IPV6_DST, > sizeof(struct rte_flow_action_set_ipv6)), > + MK_FLOW_ACTION(SET_TP_SRC, > + sizeof(struct rte_flow_action_set_tp)), > + MK_FLOW_ACTION(SET_TP_DST, > + sizeof(struct rte_flow_action_set_tp)), > }; >=20 > static int > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 0fe91ae89..cf5cecf42 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -1545,6 +1545,28 @@ enum rte_flow_action_type { > * See struct rte_flow_action_set_ipv6. > */ > RTE_FLOW_ACTION_TYPE_SET_IPV6_DST, > + > + /** > + * Modify source port number in the outermost TCP/UDP header. > + * > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP > + * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a > + * RTE_FLOW_ERROR_TYPE_ACTION error. > + * > + * See struct rte_flow_action_set_tp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_TP_SRC, > + > + /** > + * Modify destination port number in the outermost TCP/UDP header. > + * > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP > + * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a > + * RTE_FLOW_ERROR_TYPE_ACTION error. > + * > + * See struct rte_flow_action_set_tp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_TP_DST, > }; >=20 > /** > @@ -1938,6 +1960,21 @@ struct rte_flow_action_set_ipv6 { > uint8_t ipv6_addr[16]; > }; >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > + * RTE_FLOW_ACTION_TYPE_SET_TP_SRC > + * RTE_FLOW_ACTION_TYPE_SET_TP_DST > + * > + * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC) > + * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers > + * in the specified outermost TCP/UDP header. > + */ > +struct rte_flow_action_set_tp { > + uint16_t port; > +}; > + > /* > * Definition of a single action. > * > -- > 2.18.0 Acked-by: Ori Kam