From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7DF801CB7C for ; Thu, 5 Apr 2018 14:25:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 05:25:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,411,1517904000"; d="scan'208";a="40909152" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2018 05:24:59 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 5 Apr 2018 05:24:59 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.241]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.88]) with mapi id 14.03.0319.002; Thu, 5 Apr 2018 20:24:57 +0800 From: "Zhang, Qi Z" To: Adrien Mazarguil , Thomas Monjalon , "Yigit, Ferruh" , "dev@dpdk.org" CC: "Doherty, Declan" Thread-Topic: [PATCH v1 16/16] ethdev: add port ID item and action to flow API Thread-Index: AQHTzC2guNCMr/ob50+oGrRHm7xKBKPyGBrQ Date: Thu, 5 Apr 2018 12:24:56 +0000 Message-ID: <039ED4275CED7440929022BC67E7061153182E8A@SHSMSX103.ccr.corp.intel.com> References: <20180404150312.12304-1-adrien.mazarguil@6wind.com> <20180404150312.12304-17-adrien.mazarguil@6wind.com> In-Reply-To: <20180404150312.12304-17-adrien.mazarguil@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v1 16/16] ethdev: add port ID item and action to flow API 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, 05 Apr 2018 12:25:04 -0000 > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Wednesday, April 4, 2018 11:57 PM > To: Thomas Monjalon ; Yigit, Ferruh > ; dev@dpdk.org > Cc: Zhang, Qi Z ; Doherty, Declan > > Subject: [PATCH v1 16/16] ethdev: add port ID item and action to flow API >=20 > RTE_FLOW_ACTION_TYPE_PORT_ID brings the ability to inject matching traffi= c > into a different device, as identified by its DPDK port ID. >=20 > This is normally only supported when the target port ID has some kind of > relationship with the port ID the flow rule is created against, such as b= eing > exposed by a common physical device (e.g. a different port of an Ethernet > switch). >=20 > The converse pattern item, RTE_FLOW_ITEM_TYPE_PORT_ID, makes the > resulting flow rule match traffic whose origin is the specified port ID. = Note that > specifying a port ID that differs from the one the flow rule is created a= gainst is > normally meaningless (if even accepted), but can make sense if combined w= ith > the transfer attribute. >=20 > These must not be confused with their PHY_PORT counterparts, which refer = to > physical ports using device-specific indices, but unlike PORT_ID are not > necessarily tied to DPDK port IDs. >=20 > Signed-off-by: Adrien Mazarguil > Cc: "Zhang, Qi Z" > Cc: Declan Doherty Reviewed-by: Qi Zhang This patch cover=20 http://dpdk.org/dev/patchwork/patch/36839/ >=20 > --- >=20 > This patch provides the same functionality and supersedes Qi Zhang's > "ether: add flow action to redirect packet to a port" [1]. >=20 > The main differences are: >=20 > - Action is named PORT_ID instead of PORT. > - Addition of a PORT_ID pattern item. > - More extensive documentation. > - Testpmd support. > - rte_flow_copy() support. >=20 > [1] http://dpdk.org/ml/archives/dev/2018-April/094648.html > --- > app/test-pmd/cmdline_flow.c | 57 > ++++++++++++++++++++++++ > app/test-pmd/config.c | 2 + > doc/guides/prog_guide/rte_flow.rst | 48 ++++++++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ > lib/librte_ether/rte_flow.c | 2 + > lib/librte_ether/rte_flow.h | 56 > +++++++++++++++++++++++ > 6 files changed, 174 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index c77525ad9..f85c1c57f 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -89,6 +89,8 @@ enum index { > ITEM_VF_ID, > ITEM_PHY_PORT, > ITEM_PHY_PORT_INDEX, > + ITEM_PORT_ID, > + ITEM_PORT_ID_ID, > ITEM_RAW, > ITEM_RAW_RELATIVE, > ITEM_RAW_SEARCH, > @@ -185,6 +187,9 @@ enum index { > ACTION_PHY_PORT, > ACTION_PHY_PORT_ORIGINAL, > ACTION_PHY_PORT_INDEX, > + ACTION_PORT_ID, > + ACTION_PORT_ID_ORIGINAL, > + ACTION_PORT_ID_ID, > ACTION_METER, > ACTION_METER_ID, > }; > @@ -445,6 +450,7 @@ static const enum index next_item[] =3D { > ITEM_PF, > ITEM_VF, > ITEM_PHY_PORT, > + ITEM_PORT_ID, > ITEM_RAW, > ITEM_ETH, > ITEM_VLAN, > @@ -491,6 +497,12 @@ static const enum index item_phy_port[] =3D { > ZERO, > }; >=20 > +static const enum index item_port_id[] =3D { > + ITEM_PORT_ID_ID, > + ITEM_NEXT, > + ZERO, > +}; > + > static const enum index item_raw[] =3D { > ITEM_RAW_RELATIVE, > ITEM_RAW_SEARCH, > @@ -627,6 +639,7 @@ static const enum index next_action[] =3D { > ACTION_PF, > ACTION_VF, > ACTION_PHY_PORT, > + ACTION_PORT_ID, > ACTION_METER, > ZERO, > }; > @@ -668,6 +681,13 @@ static const enum index action_phy_port[] =3D { > ZERO, > }; >=20 > +static const enum index action_port_id[] =3D { > + ACTION_PORT_ID_ORIGINAL, > + ACTION_PORT_ID_ID, > + ACTION_NEXT, > + ZERO, > +}; > + > static const enum index action_meter[] =3D { > ACTION_METER_ID, > ACTION_NEXT, > @@ -1084,6 +1104,20 @@ static const struct token token_list[] =3D { > .next =3D NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), > item_param), > .args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)), > }, > + [ITEM_PORT_ID] =3D { > + .name =3D "port_id", > + .help =3D "match traffic from/to a given DPDK port ID", > + .priv =3D PRIV_ITEM(PORT_ID, > + sizeof(struct rte_flow_item_port_id)), > + .next =3D NEXT(item_port_id), > + .call =3D parse_vc, > + }, > + [ITEM_PORT_ID_ID] =3D { > + .name =3D "id", > + .help =3D "DPDK port ID", > + .next =3D NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), > + .args =3D ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), > + }, > [ITEM_RAW] =3D { > .name =3D "raw", > .help =3D "match an arbitrary byte string", @@ -1749,6 +1783,29 @@ > static const struct token token_list[] =3D { > index)), > .call =3D parse_vc_conf, > }, > + [ACTION_PORT_ID] =3D { > + .name =3D "port_id", > + .help =3D "direct matching traffic to a given DPDK port ID", > + .priv =3D PRIV_ACTION(PORT_ID, > + sizeof(struct rte_flow_action_port_id)), > + .next =3D NEXT(action_port_id), > + .call =3D parse_vc, > + }, > + [ACTION_PORT_ID_ORIGINAL] =3D { > + .name =3D "original", > + .help =3D "use original DPDK port ID if possible", > + .next =3D NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)), > + .args =3D ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id, > + original, 1)), > + .call =3D parse_vc_conf, > + }, > + [ACTION_PORT_ID_ID] =3D { > + .name =3D "id", > + .help =3D "DPDK port ID", > + .next =3D NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)), > + .args =3D ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)), > + .call =3D parse_vc_conf, > + }, > [ACTION_METER] =3D { > .name =3D "meter", > .help =3D "meter the directed packets at given id", diff --git > a/app/test-pmd/config.c b/app/test-pmd/config.c index effb4ff81..4a273eff= 7 > 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -961,6 +961,7 @@ static const struct { > MK_FLOW_ITEM(PF, 0), > MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), > MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), > + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), > MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), > MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), > MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -1059,6 > +1060,7 @@ static const struct { > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), > MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), }; >=20 > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index 941285495..a94b84fb5 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -607,6 +607,36 @@ associated with a port_id should be retrieved by > other means. > | ``mask`` | ``index`` | zeroed to match any port index | > +----------+-----------+--------------------------------+ >=20 > +Item: ``PORT_ID`` > +^^^^^^^^^^^^^^^^^ > + > +Matches traffic originating from (ingress) or going to (egress) a given > +DPDK port ID. > + > +Normally only supported if the port ID in question is known by the > +underlying PMD and related to the device the flow rule is created agains= t. > + > +This must not be confused with `Item: PHY_PORT`_ which refers to the > +physical port of a device, whereas `Item: PORT_ID`_ refers to a > +``struct rte_eth_dev`` object on the application side (also known as > +"port representor" depending on the kind of underlying device). > + > +- Default ``mask`` matches the specified DPDK port ID. > + > +.. _table_rte_flow_item_phy_port: > + > +.. table:: PORT_ID > + > + +----------+----------+-----------------------------+ > + | 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+ > + | ``spec`` | ``id`` | DPDK port ID | > + +----------+----------+-----------------------------+ > + | ``last`` | ``id`` | upper range value | > + +----------+----------+-----------------------------+ > + | ``mask`` | ``id`` | zeroed to match any port ID | > + +----------+----------+-----------------------------+ > + > Data matching item types > ~~~~~~~~~~~~~~~~~~~~~~~~ >=20 > @@ -1436,6 +1466,24 @@ See `Item: PHY_PORT`_. > | ``index`` | physical port index | > +--------------+-------------------------------------+ >=20 > +Action: ``PORT_ID`` > +^^^^^^^^^^^^^^^^^^^ > +Directs matching traffic to a given DPDK port ID. > + > +See `Item: PORT_ID`_. > + > +.. _table_rte_flow_action_phy_port: > + > +.. table:: PORT_ID > + > + +--------------+---------------------------------------+ > + | 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+ > + | ``original`` | use original DPDK port ID if possible | > + +--------------+---------------------------------------+ > + | ``id`` | DPDK port ID | > + +--------------+---------------------------------------+ > + > Action: ``METER`` > ^^^^^^^^^^^^^^^^^ >=20 > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index ca23ba146..e78f26dce 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3212,6 +3212,10 @@ This section lists supported pattern items and the= ir > attributes, if any. >=20 > - ``index {unsigned}``: physical port index. >=20 > +- ``port_id``: match traffic from/to a given DPDK port ID. > + > + - ``id {unsigned}``: DPDK port ID. > + > - ``raw``: match an arbitrary byte string. >=20 > - ``relative {boolean}``: look for pattern after the previous item. > @@ -3426,6 +3430,11 @@ This section lists supported actions and their > attributes, if any. > - ``original {boolean}``: use original port index if possible. > - ``index {unsigned}``: physical port index. >=20 > +- ``port_id``: direct matching traffic to a given DPDK port ID. > + > + - ``original {boolean}``: use original DPDK port ID if possible. > + - ``id {unsigned}``: DPDK port ID. > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ >=20 > diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c in= dex > e0fd78dd5..3d8116ebd 100644 > --- a/lib/librte_ether/rte_flow.c > +++ b/lib/librte_ether/rte_flow.c > @@ -39,6 +39,7 @@ static const struct rte_flow_desc_data > rte_flow_desc_item[] =3D { > MK_FLOW_ITEM(PF, 0), > MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)), > MK_FLOW_ITEM(PHY_PORT, sizeof(struct rte_flow_item_phy_port)), > + MK_FLOW_ITEM(PORT_ID, sizeof(struct rte_flow_item_port_id)), > MK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), > MK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)), > MK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)), @@ -77,6 > +78,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = =3D { > MK_FLOW_ACTION(PF, 0), > MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), > MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), > + MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), > }; >=20 > static int > diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h in= dex > 49845ec35..af9bf3f25 100644 > --- a/lib/librte_ether/rte_flow.h > +++ b/lib/librte_ether/rte_flow.h > @@ -176,6 +176,16 @@ enum rte_flow_item_type { > RTE_FLOW_ITEM_TYPE_PHY_PORT, >=20 > /** > + * [META] > + * > + * Matches traffic originating from (ingress) or going to (egress) a > + * given DPDK port ID. > + * > + * See struct rte_flow_item_port_id. > + */ > + RTE_FLOW_ITEM_TYPE_PORT_ID, > + > + /** > * Matches a byte string of a given length at a given offset. > * > * See struct rte_flow_item_raw. > @@ -410,6 +420,32 @@ static const struct rte_flow_item_phy_port > rte_flow_item_phy_port_mask =3D { #endif >=20 > /** > + * RTE_FLOW_ITEM_TYPE_PORT_ID > + * > + * Matches traffic originating from (ingress) or going to (egress) a > +given > + * DPDK port ID. > + * > + * Normally only supported if the port ID in question is known by the > + * underlying PMD and related to the device the flow rule is created > + * against. > + * > + * This must not be confused with @p PHY_PORT which refers to the > +physical > + * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev > + * object on the application side (also known as "port representor" > + * depending on the kind of underlying device). > + */ > +struct rte_flow_item_port_id { > + uint32_t id; /**< DPDK port ID. */ > +}; > + > +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ #ifndef __cplusplus > +static const struct rte_flow_item_port_id rte_flow_item_port_id_mask =3D= { > + .id =3D 0xffffffff, > +}; > +#endif > + > +/** > * RTE_FLOW_ITEM_TYPE_RAW > * > * Matches a byte string of a given length at a given offset. > @@ -992,6 +1028,13 @@ enum rte_flow_action_type { > RTE_FLOW_ACTION_TYPE_PHY_PORT, >=20 > /** > + * Directs matching traffic to a given DPDK port ID. > + * > + * See struct rte_flow_action_port_id. > + */ > + RTE_FLOW_ACTION_TYPE_PORT_ID, > + > + /** > * Traffic metering and policing (MTR). > * > * See struct rte_flow_action_meter. > @@ -1123,6 +1166,19 @@ struct rte_flow_action_phy_port { }; >=20 > /** > + * RTE_FLOW_ACTION_TYPE_PORT_ID > + * > + * Directs matching traffic to a given DPDK port ID. > + * > + * @see RTE_FLOW_ITEM_TYPE_PORT_ID > + */ > +struct rte_flow_action_port_id { > + uint32_t original:1; /**< Use original DPDK port ID if possible. */ > + uint32_t reserved:31; /**< Reserved, must be zero. */ > + uint32_t id; /**< DPDK port ID. */ > +}; > + > +/** > * RTE_FLOW_ACTION_TYPE_METER > * > * Traffic metering and policing (MTR). > -- > 2.11.0