From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 414ECA0096 for ; Mon, 3 Jun 2019 23:45:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B083F1B9AB; Mon, 3 Jun 2019 23:45:44 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00085.outbound.protection.outlook.com [40.107.0.85]) by dpdk.org (Postfix) with ESMTP id AAAE91B9A8 for ; Mon, 3 Jun 2019 23:45:42 +0200 (CEST) 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=AIrZ1Dt7NRpapluSyhMRwwZl4PRjIEKVx7kLOJKuwQM=; b=G35DFz1ce7zZMGJA+zojFejUEt4ZvaC96VGHA3XitN50z7l82gTUOZICQFBuSaLvOz+d3OYA+yfnv06Y4x/VR3a5CGsBGgOjHqJCeLvrdr7BaxB/63bG1L0FWDTys20icU6Yqh5yJ8f0YZ0Gpt/uOrTfJ9kFOtlvYzkmS+45Zm8= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4010.eurprd05.prod.outlook.com (52.134.66.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1943.22; Mon, 3 Jun 2019 21:44:40 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::24ee:49a5:d686:cbc4]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::24ee:49a5:d686:cbc4%3]) with mapi id 15.20.1943.018; Mon, 3 Jun 2019 21:44:40 +0000 From: Yongseok Koh To: Adrien Mazarguil CC: "dev@dpdk.org" , Moti Haimovsky Thread-Topic: [dpdk-dev] [RFC] ethdev: enhance metadata as flow rule criteria Thread-Index: AQHVC/x/bWn2UWBEc02agWyl9xQWXKaKkx2A Date: Mon, 3 Jun 2019 21:44:40 +0000 Message-ID: References: <1558020695-157009-1-git-send-email-motih@mellanox.com> In-Reply-To: <1558020695-157009-1-git-send-email-motih@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=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4f75496e-39db-4f2a-ea51-08d6e86caeef x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DB3PR0502MB4010; x-ms-traffictypediagnostic: DB3PR0502MB4010: x-ms-exchange-purlcount: 1 x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0057EE387C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(396003)(366004)(39860400002)(346002)(189003)(199004)(66066001)(99286004)(966005)(68736007)(14454004)(6436002)(6512007)(86362001)(6486002)(6916009)(54906003)(229853002)(8676002)(4326008)(25786009)(6246003)(107886003)(6306002)(316002)(91956017)(5024004)(81166006)(8936002)(71190400001)(83716004)(256004)(14444005)(81156014)(186003)(76176011)(26005)(33656002)(446003)(2616005)(476003)(11346002)(53936002)(71200400001)(486006)(82746002)(36756003)(6116002)(3846002)(102836004)(30864003)(2906002)(76116006)(66946007)(64756008)(305945005)(66556008)(66446008)(53546011)(66476007)(73956011)(5660300002)(7736002)(6506007)(508600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4010; H:DB3PR0502MB3980.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-message-info: xP8DEiMaFpl48MfxGRk+1ogcjVGEZ/Dh1HYqsBbSYevDVrIqn0Uv76L+NTxEERF8hfKC8r9/hhzmcez7crI/lWoRB5825y07AZ5TZRhGyiSiWxdhzGlfjxrpTg2GoMFbEcCWuXduM3+fb82trQovWzIP/qrNR0baXEgnBqSGo/vZ0nm/bHenr0jCbsxVqQaJ3ZN/nIc0Sy1qW1G+ow5rSpWBoqGG10HrYQfsKZMbDc/qB/b1xDQVib7TS9bZoYLzcXDbHRZsEXiEltsuAff4g74uvesdwjxLA0fUsPtoHntC+54Sn1iEYL3w1Dr6dXG2ckYjk/hmPEk/WGQo5Izo4z43hai/jbH1MhSF2d29AfqdULj0M0grw9UjzswaQ8iZcCHK1G+e2TlsAfh6W0xQpqJq/K18x1ZOIhblR4XtBSU= Content-Type: text/plain; charset="us-ascii" Content-ID: <568F7D6610D9D9459736F0475AA04FEB@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f75496e-39db-4f2a-ea51-08d6e86caeef X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jun 2019 21:44:40.6865 (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: yskoh@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4010 Subject: Re: [dpdk-dev] [RFC] ethdev: enhance metadata as flow rule criteria 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" This has been overridden by another RFC. http://patches.dpdk.org/project/dpdk/list/?series=3D4875 Thanks, Yongseok > On May 16, 2019, at 8:31 AM, Moti Haimovsky wrote: >=20 > Current implementation of rte_flow metadata match sets metadata only > for egress traffic leaving the need for such feature in ingress > flows unsatisfied and the lack of metadata index or ID limits it to > a single metadata action and match per flow which is a drawback in > several scenarios we would like to address. >=20 > This RFC proposes an enhancement of the existing implementation of > "[RFC,v2] ethdev: support metadata as flow rule criteria" without > breaking the API or ABI of the existing implementation. > We will do so by introducing new metadata item 'RTE_FLOW_ITEM_METADATA' > with a corresponding 'rte_flow_item_metadata' data structure, > and a new metadata action 'RTE_FLOW_ACTION_TYPE_SET_METADATA' with > a corresponding 'rte_flow_action_set_metadata' data structure. >=20 > These new action and item will be super-set of the existing > implementation allowing us to deprecate it later on. >=20 > Application will set and match on the new metadata action and item > respectively via the standard rte_flow rules, letting the PMD to worry > about the implementation details. >=20 > For example suppose an ingress flow packet has to traverse several > flow-groups before reaching its destination (fate), during this > traversal the packet may be changed several times by the flow rules, > like encap or decap headers, mac address modification, etc. making > the primary match on the packet header useless. How will we track the > flow making sure that the correct rules are applied to it ? > We can do so by setting a unique flow ID to each flow, setting the > metadata of each packet in that flow to that value, and now the rest > of the flow table will match on this unique value. > testpmd commands for such flow could look like: >=20 > testpmd> flow create 0 ingress pattern eth ... / end actions > set_meta_data id 1 data 5 / vxlan_decap / jump group 1 / end >=20 > testpmd> flow create 0 ingress group 1 pattern metadata id is 1 data > is 5 / end actions .... / end >=20 > Comments are welcome. >=20 > Signed-off-by: Moti Haimovsky > --- > app/test-pmd/cmdline_flow.c | 68 +++++++++++++++++++++++++++++++++= +++++ > doc/guides/prog_guide/rte_flow.rst | 50 ++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_flow.c | 3 ++ > lib/librte_ethdev/rte_flow.h | 61 +++++++++++++++++++++++++++++++++= + > 4 files changed, 182 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 3070e0e..d10f511 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -181,6 +181,9 @@ enum index { > ITEM_ICMP6_ND_OPT_TLA_ETH_TLA, > ITEM_META, > ITEM_META_DATA, > + ITEM_METADATA, > + ITEM_METADATA_ID, > + ITEM_METADATA_DATA, >=20 > /* Validate/create actions. */ > ACTIONS, > @@ -272,6 +275,9 @@ enum index { > ACTION_SET_MAC_SRC_MAC_SRC, > ACTION_SET_MAC_DST, > ACTION_SET_MAC_DST_MAC_DST, > + ACTION_SET_METADATA, > + ACTION_SET_METADATA_ID, > + ACTION_SET_METADATA_DATA, > }; >=20 > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -610,6 +616,7 @@ struct parse_action_priv { > ITEM_ICMP6_ND_OPT_SLA_ETH, > ITEM_ICMP6_ND_OPT_TLA_ETH, > ITEM_META, > + ITEM_METADATA, > ZERO, > }; >=20 > @@ -836,6 +843,13 @@ struct parse_action_priv { > ZERO, > }; >=20 > +static const enum index item_metadata[] =3D { > + ITEM_METADATA_ID, > + ITEM_METADATA_DATA, > + ITEM_NEXT, > + ZERO, > +}; > + > static const enum index next_action[] =3D { > ACTION_END, > ACTION_VOID, > @@ -885,6 +899,7 @@ struct parse_action_priv { > ACTION_SET_TTL, > ACTION_SET_MAC_SRC, > ACTION_SET_MAC_DST, > + ACTION_SET_METADATA, > ZERO, > }; >=20 > @@ -1047,6 +1062,14 @@ struct parse_action_priv { > ZERO, > }; >=20 > +static const enum index action_set_metadata[] =3D { > + ACTION_SET_METADATA, > + ACTION_SET_METADATA_ID, > + ACTION_SET_METADATA_DATA, > + ACTION_NEXT, > + ZERO, > +}; > + > static int parse_init(struct context *, const struct token *, > const char *, unsigned int, > void *, unsigned int); > @@ -2147,6 +2170,27 @@ static int comp_vc_action_rss_queue(struct context= *, const struct token *, > .name =3D "data", > .help =3D "metadata value", > .next =3D NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param), > + .args =3D ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta, > + data, "\xff\xff\xff\xff")), > + }, > + [ITEM_METADATA] =3D { > + .name =3D "metadata", > + .help =3D "match on metadata info", > + .priv =3D PRIV_ITEM(METADATA, > + sizeof(struct rte_flow_item_metadata)), > + .next =3D NEXT(item_metadata), > + .call =3D parse_vc, > + }, > + [ITEM_METADATA_ID] =3D { > + .name =3D "id", > + .help =3D " device-specific location of metadata", > + .next =3D NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param), > + .args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_metadata, id)), > + }, > + [ITEM_METADATA_DATA] =3D { > + .name =3D "data", > + .help =3D "metadata data value", > + .next =3D NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param), > .args =3D ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_meta, > data, "\xff\xff\xff\xff")), > }, > @@ -2854,6 +2898,30 @@ static int comp_vc_action_rss_queue(struct context= *, const struct token *, > (struct rte_flow_action_set_mac, mac_addr)), > .call =3D parse_vc_conf, > }, > + [ACTION_SET_METADATA] =3D { > + .name =3D "set_meta_data", > + .help =3D "attach metadata info to flow packets", > + .priv =3D PRIV_ACTION(SET_METADATA, > + sizeof(struct rte_flow_action_set_metadata)), > + .next =3D NEXT(action_set_metadata), > + .call =3D parse_vc, > + }, > + [ACTION_SET_METADATA_ID] =3D { > + .name =3D "id", > + .help =3D "device-specific metadata id to use", > + .next =3D NEXT(action_set_metadata, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY(struct rte_flow_action_set_metadata, > + id)), > + .call =3D parse_vc_conf, > + }, > + [ACTION_SET_METADATA_DATA] =3D { > + .name =3D "data", > + .help =3D "data to use", > + .next =3D NEXT(action_set_metadata, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY(struct rte_flow_action_set_metadata, > + data)), > + .call =3D parse_vc_conf, > + }, > }; >=20 > /** Remove and return last entry from argument stack. */ > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/r= te_flow.rst > index 937f52b..743c357 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1210,6 +1210,30 @@ Matches an application specific 32 bit metadata it= em. > | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | > +----------+----------+---------------------------------------+ >=20 > +Item: ``METADATA`` > +^^^^^^^^^^^^^^^^^^ > + > +Matches an application specific 32 bit metadata item present in the spec= ified > +location of a device-specific, per-packet metadata information. > +This information is set either by a ``METADATA`` action in a previously = matched > +rule or by the device hardware itself. > + > +This item may be specified several times as a match criteria on several = metadata > +fields. > + > +Note the value of the data field is arbitrary and is PMD or application = defined. > +The value of the id field is device-dependent. > + > +Depending on the underlying implementation the METADATA item may be supp= orted > +as a set of registers or a memory region on the physical device, > +with virtual groups in the PMD or not supported at all. > + > +- ``id``: The metadata field id to match. > +- ``data``: The data to match against. > + > +- Default ``mask`` matches the specified integer value in the specified > + metadata location. > + > Actions > ~~~~~~~ >=20 > @@ -1476,6 +1500,32 @@ sets the ``PKT_RX_FDIR`` mbuf flag. > | no properties | > +---------------+ >=20 > +Action: ``METADATA`` > +^^^^^^^^^^^^^^^^^^^^ > + > +Insetrs a 32 bit integer value in the specified location of a device-spe= cific > +metadata information attached to each packet of a flow. > + > +This value is arbitrary and is application or PMD defined. > +Maximum allowed value depends on the underlying implementation. > + > +Depending on the underlying implementation the METADATA action may be su= pported > +as a set of registers or a memory region on the physical device, with vi= rtual > +groups in the PMD or not supported at all. > + > +.. _table_rte_flow_action_metadata: > + > +.. table:: METADATA > + > + +----------+---------------------------------------------------------= --+ > + | 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=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+ > + | ``id`` | unsigned integer value indicating where to write the dat= a | > + | | in the metadata info. = | > + +----------+---------------------------------------------------------= --+ > + | ``data`` | unsigned integer value of data to write = | > + +----------+---------------------------------------------------------= --+ > + > Action: ``QUEUE`` > ^^^^^^^^^^^^^^^^^ >=20 > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index 3277be1..ea2b9a0 100644 > --- a/lib/librte_ethdev/rte_flow.c > +++ b/lib/librte_ethdev/rte_flow.c > @@ -74,6 +74,7 @@ struct rte_flow_desc_data { > sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)), > MK_FLOW_ITEM(MARK, sizeof(struct rte_flow_item_mark)), > MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)), > + MK_FLOW_ITEM(METADATA, sizeof(struct rte_flow_item_metadata)), > }; >=20 > /** Generate flow_action[] entry. */ > @@ -143,6 +144,8 @@ struct rte_flow_desc_data { > MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)), > MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)), > MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)), > + MK_FLOW_ACTION(SET_METADATA, > + sizeof(struct rte_flow_action_set_metadata)), > }; >=20 > static int > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 63f84fc..801831f 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -421,6 +421,15 @@ enum rte_flow_item_type { > * See struct rte_flow_item_meta. > */ > RTE_FLOW_ITEM_TYPE_META, > + > + /** > + * [METADATA] > + * > + * Matches a metadata value specified in device-specific metadata field > + * attached to each flow. > + * See struct rte_flow_item_metadata. > + */ > + RTE_FLOW_ITEM_TYPE_METADATA, > }; >=20 > /** > @@ -1183,6 +1192,33 @@ struct rte_flow_item_meta { > * @warning > * @b EXPERIMENTAL: this structure may change without prior notice > * > + * RTE_FLOW_ITEM_TYPE_METADATA. > + * > + * Matches an arbitrary integer value in the device-specific per-flow me= tadata > + * location identified by the given id. > + * This data value may have been set using the `METADATA` action in a pr= eviously > + * matched rule or by the underlying hardware itself. > + * > + * The offset field is device-specific and its interpretation may change > + * according to the device in use and its current configuration. > + */ > +struct rte_flow_item_metadata { > + uint32_t id; > + rte_be32_t data; > +}; > + > +/** Default mask for RTE_FLOW_ITEM_TYPE_METADATA. */ > +#ifndef __cplusplus > +static const struct rte_flow_item_metadata rte_flow_item_metadata_mask = =3D { > + .id =3D UINT32_MAX, > + .data =3D RTE_BE32(UINT32_MAX), > +}; > +#endif > + > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > * RTE_FLOW_ITEM_TYPE_MARK > * > * Matches an arbitrary integer value which was set using the ``MARK`` ac= tion > @@ -1650,6 +1686,14 @@ enum rte_flow_action_type { > * See struct rte_flow_action_set_mac. > */ > RTE_FLOW_ACTION_TYPE_SET_MAC_DST, > + > + /** > + * Attaches an integer value to device-specific metadata info attached > + * to each packet in a flow. > + * > + * See struct rte_flow_action_set_metadata. > + */ > + RTE_FLOW_ACTION_TYPE_SET_METADATA, > }; >=20 > /** > @@ -2131,6 +2175,23 @@ struct rte_flow_action_set_mac { > uint8_t mac_addr[ETHER_ADDR_LEN]; > }; >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > + * RTE_FLOW_ACTION_TYPE_SET_METADATA. > + * > + * Attaches an integer value to device-specific metadata info attached > + * to each packet in a flow. > + * > + * The offset field is device-specific and its interpretation may change > + * according to the device in use and its current configuration. > + */ > +struct rte_flow_action_set_metadata { > + uint32_t id; > + rte_be32_t data; > +}; > + > /* > * Definition of a single action. > * > --=20 > 1.8.3.1 >=20