From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C123FA00B8; Sun, 27 Oct 2019 17:56:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DCD991BF08; Sun, 27 Oct 2019 17:56:22 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50064.outbound.protection.outlook.com [40.107.5.64]) by dpdk.org (Postfix) with ESMTP id 6F04C1BEE5 for ; Sun, 27 Oct 2019 17:56:21 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1o/0h6uTxVdJ2HHSOMN1G66+axseo+SMw6nEBRbEcpdNCN6xX+VOGmz1lPrBwgsk9xh5iQdoWKIVi0dVMWidIYhsCf+fqy8/zQdeKeiQv6ibB92HEPNLJu5pvcTGqSXLMcr4SrL/g54jel7ezYxePGLRYlMMSV5sWIj/zibtf6qp0a72sTkwQCyJTu/UDGS6ak9OdWcWkZVHm2X/+oVUeslUG9yj2ULCPf2NzvlHHhUJzxrI5is2JLAaHmVZXtn9nR5FOcFhY1nsV6sFZB1lSAPvyfIyy6QTcPuOLIMeaXkA1gRdVVyMv8lMw6LXqwfmaHuy7DGaRNNIZrkVzH2qA== 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-SenderADCheck; bh=Gx5+viV3Z7zZyugcDoMsCW7tJbz2k5cf5KzlP3ha2BE=; b=J+evRYNskpX7qjl/E4UHsi2YlhsWqN0Jgx9Qaa0tQ7zUHR50exBOgJB7OftCyOXtvx/RcGwLZH62WDH5i2pyD/5PGWpoBGaXit3eolPQ1XjAEbX/igNpxrHy0a3+a6Snkoyv5mlyKff0Qai7VXCttqVzkg2/YmMtdsDD4FYFa+BcY50n+e3VIzoAlnoWGbkQa9VaDBUuWK+Yk+9Gyil+O6cWPd9OQnuK6p7g9W7v8lYmp/7aoGM3UIZmlZILVYEApn6wwt59Fm8srga9CdcL/9MWj0wv6XLGGjXY1Cj5K//SgsOgfDUGHXaITjYT8ssOkKvuGHZVzQwBQfHcmnzVLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gx5+viV3Z7zZyugcDoMsCW7tJbz2k5cf5KzlP3ha2BE=; b=FGIetCQ0XAKyLjS9U/G5qCnVNgQ5euWuRuDRp6B31VEDMaHirAakV1Fi5xaQjeJCNtxTL+pKM6AstdsRL03svCyUnlC1JoJ8yYyOd0Tmsv0c4pYKIj1Oax7sTqK2W/FRLsfbKgaQU2m6VdKi7PWn5cjTvovmA+ozZG4NxSnNj1w= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.190.15) by AM4PR05MB3427.eurprd05.prod.outlook.com (10.171.187.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.24; Sun, 27 Oct 2019 16:56:19 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::70a7:a312:cbc6:d178]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::70a7:a312:cbc6:d178%7]) with mapi id 15.20.2387.025; Sun, 27 Oct 2019 16:56:19 +0000 From: Ori Kam To: Slava Ovsiienko , "dev@dpdk.org" CC: Thomas Monjalon , "olivier.matz@6wind.com" , Matan Azrad , Raslan Darawsheh , Yongseok Koh Thread-Topic: [dpdk-dev] [PATCH v3] ethdev: extend flow metadata Thread-Index: AQHVimwgRMzXtTyIok2RZFiqzlr22adutsbQ Date: Sun, 27 Oct 2019 16:56:18 +0000 Message-ID: References: <1570723359-24650-1-git-send-email-viacheslavo@mellanox.com> <1571922495-4588-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1571922495-4588-1-git-send-email-viacheslavo@mellanox.com> 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-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ff9d36ab-a234-4ffa-dfab-08d75afe96b8 x-ms-traffictypediagnostic: AM4PR05MB3427:|AM4PR05MB3427: x-ms-exchange-purlcount: 1 x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0203C93D51 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(376002)(136003)(39860400002)(346002)(396003)(189003)(199004)(13464003)(45080400002)(6246003)(316002)(478600001)(52536014)(66066001)(14454004)(966005)(25786009)(33656002)(55016002)(229853002)(74316002)(7736002)(305945005)(86362001)(6436002)(8936002)(76176011)(66476007)(66556008)(64756008)(66446008)(71190400001)(71200400001)(2906002)(76116006)(66946007)(4326008)(6506007)(256004)(14444005)(107886003)(7696005)(3846002)(6116002)(102836004)(186003)(26005)(476003)(2501003)(486006)(446003)(11346002)(99286004)(8676002)(5660300002)(81166006)(81156014)(54906003)(110136005)(30864003)(6306002)(9686003)(21314003)(579004)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3427; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gHM+Fpy0hYvCiptjkLewN7sSLRi/zlQ6yidDW+dXisLSRQhPb7TYa6G4cXZDZnoiXLg+UmDWDH/SerVQDlHmgQmcYlLqM1aOwl6ON9vnXrNjCYBL38aV6FcegSISGRUYsgYlvkvuQsZV315nnjdjZ89rOSkWnqruHPxuGbW63OP/wrLWMBIdWA00Z7Ai4Cgu9zTOtp8V1F7irCd1FVkRqDX90LTCXs9tAoTbcZxOZRzwrQ4ITtydbxaWGNZ1nDWHPpAENTynNyWMNYe9pSmNh0kDV93xxxIWwBDansXtCcWZZo1iCsGICWtcRV2Vafyi0Js6toR/r7Tp5rM1jI9TwmXur8I1Fjs2m1L/UFx8DZUrTJYQRKNi2X3WXm1uDA03rTCYM/VWPLUs3m/0HCihsQb331EzeaNx6qXl12M3Atd76D3VHrZm1jH6i40iEEyvuGJQgiX7oxcJra7WPqWJi1XuW3rM0GUXUhApv/f+I4c= 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: ff9d36ab-a234-4ffa-dfab-08d75afe96b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2019 16:56:19.0047 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MRYi2Hba10H2UbgcvRRumys0eaMD2zFZXTIviFpXpZzsMVVZ0yEPLV+YqzLi5Xs3h6ISZL3rYwxcynJtb3+8sQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3427 Subject: Re: [dpdk-dev] [PATCH v3] ethdev: extend flow metadata 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Slava, Some small comments inline. Please also add deprication for the META cap on TX.=20 > -----Original Message----- > From: dev On Behalf Of Viacheslav Ovsiienko > Subject: [dpdk-dev] [PATCH v3] ethdev: extend flow metadata >=20 > Currently, metadata can be set on egress path via mbuf tx_metadata field > with PKT_TX_METADATA flag and RTE_FLOW_ITEM_TYPE_META matches > metadata. >=20 > This patch extends the metadata feature usability. >=20 > 1) RTE_FLOW_ACTION_TYPE_SET_META >=20 > When supporting multiple tables, Tx metadata can also be set by a rule an= d > matched by another rule. This new action allows metadata to be set as a > result of flow match. >=20 > 2) Metadata on ingress >=20 > There's also need to support metadata on ingress. Metadata can be set by > SET_META action and matched by META item like Tx. The final value set by > the action will be delivered to application via metadata dynamic field of > mbuf which can be accessed by RTE_FLOW_DYNF_METADATA(). > PKT_RX_DYNF_METADATA flag will be set along with the data. >=20 > The mbuf dynamic field must be registered by calling > rte_flow_dynf_metadata_register() prior to use SET_META action. >=20 > The availability of dynamic mbuf metadata field can be checked > with rte_flow_dynf_metadata_avail() routine. >=20 > For loopback/hairpin packet, metadata set on Rx/Tx may or may not be > propagated to the other path depending on hardware capability. >=20 > Signed-off-by: Yongseok Koh > Signed-off-by: Viacheslav Ovsiienko > --- > v3: - removed MBUF_DYNF_METADATA_xxx definitions, only > MBUF_DYNF_METADATA_NAME remains in rte_mbuf_dyn.h's > centralizing point > - added rte_flow_dynf_metadata_set/get helpers (Olivier) > - updated rte_ethdev_version.map > - name follows dynamic field name conventions > - rebased >=20 > v2: - > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatche= s.dp > dk.org%2Fpatch%2F60908%2F&data=3D02%7C01%7Corika%40mellanox.com > %7C71a0c68aa47f482cf44c08d75883425e%7Ca652971c7d2e4d9ba6a4d149256 > f461b%7C0%7C0%7C637075193088507126&sdata=3DV4aOinownen1dLOddq > pAzTp4GuTFL02BtMv08JCvZYY%3D&reserved=3D0 > - rebased > - relies on dynamic mbuf field feature >=20 > v1: > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatche= s.dp > dk.org%2Fpatch%2F56103%2F&data=3D02%7C01%7Corika%40mellanox.com > %7C71a0c68aa47f482cf44c08d75883425e%7Ca652971c7d2e4d9ba6a4d149256 > f461b%7C0%7C0%7C637075193088507126&sdata=3DtznGLMEFGEqKsSnbjUd > aQSHc%2BEh3%2FxTJwWt5fnZ7lK4%3D&reserved=3D0 >=20 > rfc: > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatche= s.dp > dk.org%2Fpatch%2F54270%2F&data=3D02%7C01%7Corika%40mellanox.com > %7C71a0c68aa47f482cf44c08d75883425e%7Ca652971c7d2e4d9ba6a4d149256 > f461b%7C0%7C0%7C637075193088507126&sdata=3DrRu5Rt1AV14qXhMlPi5 > H%2FVSOM%2F3JGGNhVZw7P3SfuzY%3D&reserved=3D0 >=20 > app/test-pmd/cmdline_flow.c | 57 +++++++++++++++++- > app/test-pmd/util.c | 5 ++ > doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++----- > doc/guides/rel_notes/release_19_11.rst | 15 +++++ > lib/librte_ethdev/rte_ethdev.h | 1 - > lib/librte_ethdev/rte_ethdev_version.map | 3 + > lib/librte_ethdev/rte_flow.c | 41 +++++++++++++ > lib/librte_ethdev/rte_flow.h | 99 > +++++++++++++++++++++++++++++++- > lib/librte_mbuf/rte_mbuf_dyn.h | 8 ++- > 9 files changed, 279 insertions(+), 22 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index f48f4eb..bc89bf9 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -308,6 +308,9 @@ enum index { > ACTION_DEC_TCP_ACK_VALUE, > ACTION_RAW_ENCAP, > ACTION_RAW_DECAP, > + ACTION_SET_META, > + ACTION_SET_META_DATA, > + ACTION_SET_META_MASK, > }; >=20 > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -1005,6 +1008,7 @@ struct parse_action_priv { > ACTION_DEC_TCP_ACK, > ACTION_RAW_ENCAP, > ACTION_RAW_DECAP, > + ACTION_SET_META, > ZERO, > }; >=20 > @@ -1191,6 +1195,13 @@ struct parse_action_priv { > ZERO, > }; >=20 > +static const enum index action_set_meta[] =3D { > + ACTION_SET_META_DATA, > + ACTION_SET_META_MASK, > + ACTION_NEXT, > + ZERO, > +}; > + > static int parse_set_raw_encap_decap(struct context *, const struct toke= n *, > const char *, unsigned int, > void *, unsigned int); > @@ -1249,6 +1260,10 @@ static int parse_vc_action_raw_encap(struct > context *, > static int parse_vc_action_raw_decap(struct context *, > const struct token *, const char *, > unsigned int, void *, unsigned int); > +static int parse_vc_action_set_meta(struct context *ctx, > + const struct token *token, const char *str, > + unsigned int len, void *buf, > + unsigned int size); > static int parse_destroy(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -3255,7 +3270,31 @@ static int comp_vc_action_rss_queue(struct context > *, const struct token *, > .help =3D "set raw decap data", > .next =3D NEXT(next_item), > .call =3D parse_set_raw_encap_decap, > - } > + }, > + [ACTION_SET_META] =3D { > + .name =3D "set_meta", > + .help =3D "set metadata", > + .priv =3D PRIV_ACTION(SET_META, > + sizeof(struct rte_flow_action_set_meta)), > + .next =3D NEXT(action_set_meta), > + .call =3D parse_vc_action_set_meta, > + }, > + [ACTION_SET_META_DATA] =3D { > + .name =3D "data", > + .help =3D "metadata value", > + .next =3D NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY_HTON > + (struct rte_flow_action_set_meta, data)), > + .call =3D parse_vc_conf, > + }, > + [ACTION_SET_META_MASK] =3D { > + .name =3D "mask", > + .help =3D "mask for metadata value", > + .next =3D NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY_HTON > + (struct rte_flow_action_set_meta, mask)), > + .call =3D parse_vc_conf, > + }, > }; >=20 > /** Remove and return last entry from argument stack. */ > @@ -4625,6 +4664,22 @@ static int comp_vc_action_rss_queue(struct context > *, const struct token *, > return ret; > } >=20 > +static int > +parse_vc_action_set_meta(struct context *ctx, const struct token *token, > + const char *str, unsigned int len, void *buf, > + unsigned int size) > +{ > + int ret; > + > + ret =3D parse_vc(ctx, token, str, len, buf, size); > + if (ret < 0) > + return ret; > + ret =3D rte_flow_dynf_metadata_register(); > + if (ret < 0) > + return -1; > + return len; > +} > + > /** Parse tokens for destroy command. */ > static int > parse_destroy(struct context *ctx, const struct token *token, > diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c > index 1570270..39ff07b 100644 > --- a/app/test-pmd/util.c > +++ b/app/test-pmd/util.c > @@ -81,6 +81,11 @@ > mb->vlan_tci, mb->vlan_tci_outer); > else if (ol_flags & PKT_RX_VLAN) > printf(" - VLAN tci=3D0x%x", mb->vlan_tci); > + if (ol_flags & PKT_TX_METADATA) > + printf(" - Tx metadata: 0x%x", mb->tx_metadata); > + if (ol_flags & PKT_RX_DYNF_METADATA) > + printf(" - Rx metadata: 0x%x", > + *RTE_FLOW_DYNF_METADATA(mb)); > if (mb->packet_type) { > rte_get_ptype_name(mb->packet_type, buf, > sizeof(buf)); > printf(" - hw ptype: %s", buf); > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index 6e6d44d..2b49baa 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -658,6 +658,32 @@ the physical device, with virtual groups in the PMD = or > not at all. > | ``mask`` | ``id`` | zeroed to match any value | > +----------+----------+---------------------------+ >=20 > +Item: ``META`` > +^^^^^^^^^^^^^^^^^ > + > +Matches 32 bit metadata item set. > + > +On egress, metadata can be set either by mbuf metadata field with > +PKT_TX_METADATA flag or ``SET_META`` action. On ingress, ``SET_META`` > +action sets metadata for a packet and the metadata will be reported via > +``metadata`` dynamic field of ``rte_mbuf`` with PKT_RX_DYNF_METADATA > flag. > + > +- Default ``mask`` matches the specified Rx metadata value. > + > +.. _table_rte_flow_item_meta: > + > +.. table:: META > + > + +----------+----------+---------------------------------------+ > + | Field | Subfield | 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=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > + | ``spec`` | ``data`` | 32 bit metadata value | > + +----------+----------+---------------------------------------+ > + | ``last`` | ``data`` | upper range value | I don't think this field should be used. > + +----------+----------+---------------------------------------+ > + | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | > + +----------+----------+---------------------------------------+ > + > Data matching item types > ~~~~~~~~~~~~~~~~~~~~~~~~ >=20 > @@ -1232,21 +1258,6 @@ Matches a PPPoE session protocol identifier. > - ``proto_id``: PPP protocol identifier. > - Default ``mask`` matches proto_id only. >=20 Why this lines are changed? > - > -.. _table_rte_flow_item_meta: > - > -.. table:: META > - > - +----------+----------+---------------------------------------+ > - | Field | Subfield | 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=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > - | ``spec`` | ``data`` | 32 bit metadata value | > - +----------+--------------------------------------------------+ > - | ``last`` | ``data`` | upper range value | > - +----------+----------+---------------------------------------+ > - | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | > - +----------+----------+---------------------------------------+ > - > Item: ``NSH`` > ^^^^^^^^^^^^^^^^^^^ >=20 > @@ -2466,6 +2477,37 @@ Value to decrease TCP acknowledgment number by > is a big-endian 32 bit integer. >=20 > Using this action on non-matching traffic will result in undefined behav= ior. >=20 > +Action: ``SET_META`` > +^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set metadata. Item ``META`` matches metadata. > + > +Metadata set by mbuf metadata field with PKT_TX_METADATA flag on egress > will be > +overridden by this action. On ingress, the metadata will be carried by > +``metadata`` dynamic field of ``rte_mbuf`` which can be accessed by > +``RTE_FLOW_DYNF_METADATA()``. PKT_RX_DYNF_METADATA flag will be set > along > +with the data. > + > +The mbuf dynamic field must be registered by calling > +``rte_flow_dynf_metadata_register()`` prior to use ``SET_META`` action. > + > +Altering partial bits is supported with ``mask``. For bits which have ne= ver been > +set, unpredictable value will be seen depending on driver implementation= . For > +loopback/hairpin packet, metadata set on Rx/Tx may or may not be > propagated to > +the other path depending on HW capability. > + > +.. _table_rte_flow_action_set_meta: > + > +.. table:: SET_META > + > + +----------+----------------------------+ > + | 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+ > + | ``data`` | 32 bit metadata value | > + +----------+----------------------------+ > + | ``mask`` | bit-mask applies to "data" | > + +----------+----------------------------+ > + > Negative types > ~~~~~~~~~~~~~~ >=20 > diff --git a/doc/guides/rel_notes/release_19_11.rst > b/doc/guides/rel_notes/release_19_11.rst > index 206d287..2c51426 100644 > --- a/doc/guides/rel_notes/release_19_11.rst > +++ b/doc/guides/rel_notes/release_19_11.rst > @@ -193,6 +193,21 @@ New Features > gives ability to print port supported ptypes in different protocol l= ayers. >=20 >=20 > +* **Add support of support dynamic fields and flags in mbuf.** > + > + This new feature adds the ability to dynamically register some room > + for a field or a flag in the mbuf structure. This is typically used > + for specific offload features, where adding a static field or flag > + in the mbuf is not justified. > + > +* **Extended metadata support in rte_flow.** > + > + Flow metadata is extended to both Rx and Tx. > + > + * Tx metadata can also be set by SET_META action of rte_flow. > + * Rx metadata is delivered to host via a dynamic field of ``rte_mbuf``= with > + PKT_RX_DYNF_METADATA. > + > Removed Items > ------------- >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.h > index 33c528b..6ad5e1b 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -1048,7 +1048,6 @@ struct rte_eth_conf { > #define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000 > #define DEV_RX_OFFLOAD_SCTP_CKSUM 0x00020000 > #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM 0x00040000 > - > #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \ > DEV_RX_OFFLOAD_UDP_CKSUM | \ > DEV_RX_OFFLOAD_TCP_CKSUM) > diff --git a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index e59d516..a5bf643 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -288,4 +288,7 @@ EXPERIMENTAL { > rte_eth_rx_burst_mode_get; > rte_eth_tx_burst_mode_get; > rte_eth_burst_mode_option_name; > + rte_flow_dynf_metadata_offs; > + rte_flow_dynf_metadata_mask; > + rte_flow_dynf_metadata_register; > }; > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index ca0f680..6090177 100644 > --- a/lib/librte_ethdev/rte_flow.c > +++ b/lib/librte_ethdev/rte_flow.c > @@ -12,10 +12,18 @@ > #include > #include > #include > +#include > +#include > #include "rte_ethdev.h" > #include "rte_flow_driver.h" > #include "rte_flow.h" >=20 > +/* Mbuf dynamic field name for metadata. */ > +int rte_flow_dynf_metadata_offs =3D -1; > + > +/* Mbuf dynamic field flag bit number for metadata. */ > +uint64_t rte_flow_dynf_metadata_mask; > + > /** > * Flow elements description tables. > */ > @@ -157,8 +165,41 @@ struct rte_flow_desc_data { > MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)), > MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)), > MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)), > + MK_FLOW_ACTION(SET_META, sizeof(struct > rte_flow_action_set_meta)), > }; >=20 > +int > +rte_flow_dynf_metadata_register(void) > +{ > + int offset; > + int flag; > + > + static const struct rte_mbuf_dynfield desc_offs =3D { > + .name =3D MBUF_DYNF_METADATA_NAME, > + .size =3D sizeof(uint32_t), > + .align =3D __alignof__(uint32_t), > + .flags =3D 0, > + }; > + static const struct rte_mbuf_dynflag desc_flag =3D { > + .name =3D MBUF_DYNF_METADATA_NAME, > + }; > + > + offset =3D rte_mbuf_dynfield_register(&desc_offs); > + if (offset < 0) > + goto error; > + flag =3D rte_mbuf_dynflag_register(&desc_flag); > + if (flag < 0) > + goto error; > + rte_flow_dynf_metadata_offs =3D offset; > + rte_flow_dynf_metadata_mask =3D (1ULL << flag); > + return 0; > + > +error: > + rte_flow_dynf_metadata_offs =3D -1; > + rte_flow_dynf_metadata_mask =3D 0ULL; > + return -rte_errno; > +} > + > static int > flow_err(uint16_t port_id, int ret, struct rte_flow_error *error) > { > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 4fee105..b821557 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -28,6 +28,8 @@ > #include > #include > #include > +#include > +#include >=20 > #ifdef __cplusplus > extern "C" { > @@ -418,7 +420,8 @@ enum rte_flow_item_type { > /** > * [META] > * > - * Matches a metadata value specified in mbuf metadata field. > + * Matches a metadata value. > + * > * See struct rte_flow_item_meta. > */ > RTE_FLOW_ITEM_TYPE_META, > @@ -1263,9 +1266,17 @@ struct rte_flow_item_icmp6_nd_opt_tla_eth { > #endif >=20 > /** > - * RTE_FLOW_ITEM_TYPE_META. > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > * > - * Matches a specified metadata value. > + * RTE_FLOW_ITEM_TYPE_META > + * > + * Matches a specified metadata value. On egress, metadata can be set ei= ther > by > + * mbuf tx_metadata field with PKT_TX_METADATA flag or > + * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, > RTE_FLOW_ACTION_TYPE_SET_META sets > + * metadata for a packet and the metadata will be reported via mbuf > metadata > + * dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf field > must be > + * registered in advance by rte_flow_dynf_metadata_register(). > */ > struct rte_flow_item_meta { > rte_be32_t data; > @@ -1942,6 +1953,13 @@ enum rte_flow_action_type { > * undefined behavior. > */ > RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK, > + > + /** > + * Set metadata on ingress or egress path. > + * > + * See struct rte_flow_action_set_meta. > + */ > + RTE_FLOW_ACTION_TYPE_SET_META, > }; >=20 > /** > @@ -2429,6 +2447,55 @@ struct rte_flow_action_set_mac { > uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; > }; >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > + * RTE_FLOW_ACTION_TYPE_SET_META > + * > + * Set metadata. Metadata set by mbuf tx_metadata field with > + * PKT_TX_METADATA flag on egress will be overridden by this action. On > + * ingress, the metadata will be carried by mbuf metadata dynamic field > + * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must b= e > + * registered in advance by rte_flow_dynf_metadata_register(). > + * > + * Altering partial bits is supported with mask. For bits which have nev= er > + * been set, unpredictable value will be seen depending on driver > + * implementation. For loopback/hairpin packet, metadata set on Rx/Tx ma= y > + * or may not be propagated to the other path depending on HW capability= . > + * > + * RTE_FLOW_ITEM_TYPE_META matches metadata. > + */ > +struct rte_flow_action_set_meta { > + rte_be32_t data; > + rte_be32_t mask; > +}; > + > +/* Mbuf dynamic field offset for metadata. */ > +extern int rte_flow_dynf_metadata_offs; > + > +/* Mbuf dynamic field flag mask for metadata. */ > +extern uint64_t rte_flow_dynf_metadata_mask; > + > +/* Mbuf dynamic field pointer for metadata. */ > +#define RTE_FLOW_DYNF_METADATA(m) \ > + RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) > + > +/* Mbuf dynamic flag for metadata. */ > +#define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask) > + > +__rte_experimental > +static inline uint32_t > +rte_flow_dynf_metadata_get(struct rte_mbuf *m) { > + return *RTE_FLOW_DYNF_METADATA(m); > +} > + > +__rte_experimental > +static inline void > +rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) { > + *RTE_FLOW_DYNF_METADATA(m) =3D v; > +} > + > /* > * Definition of a single action. > * > @@ -2662,6 +2729,32 @@ enum rte_flow_conv_op { > }; >=20 > /** > + * Check if mbuf dynamic field for metadata is registered. > + * > + * @return > + * True if registered, false otherwise. > + */ > +__rte_experimental > +static inline int > +rte_flow_dynf_metadata_avail(void) { > + return !!rte_flow_dynf_metadata_mask; > +} > + > +/** > + * Register mbuf dynamic field and flag for metadata. > + * > + * This function must be called prior to use SET_META action in order to > + * register the dynamic mbuf field. Otherwise, the data cannot be delive= red to > + * application. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +__rte_experimental > +int > +rte_flow_dynf_metadata_register(void); > + > +/** > * Check whether a flow rule can be created on a given port. > * > * The flow rule is validated for correctness and whether it could be ac= cepted > diff --git a/lib/librte_mbuf/rte_mbuf_dyn.h b/lib/librte_mbuf/rte_mbuf_dy= n.h > index 2e9d418..a4a0cf5 100644 > --- a/lib/librte_mbuf/rte_mbuf_dyn.h > +++ b/lib/librte_mbuf/rte_mbuf_dyn.h > @@ -234,6 +234,10 @@ int rte_mbuf_dynflag_lookup(const char *name, > __rte_experimental > void rte_mbuf_dyn_dump(FILE *out); >=20 > -/* Placeholder for dynamic fields and flags declarations. */ > - > +/* > + * Placeholder for dynamic fields and flags declarations. > + * This is centralizing point to gather all field names > + * and parameters together. > + */ > +#define MBUF_DYNF_METADATA_NAME "rte_flow_dynfield_metadata" > #endif > -- > 1.8.3.1 Thanks, Ori