From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id E60E91D8A for ; Tue, 28 Aug 2018 12:57:50 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 6CA0EB4005B; Tue, 28 Aug 2018 10:57:49 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 28 Aug 2018 11:57:43 +0100 To: Rahul Lakkireddy , CC: , , References: <1535374462-6490-1-git-send-email-rahul.lakkireddy@chelsio.com> From: Andrew Rybchenko Message-ID: <14727d6f-8d03-84d6-5cac-60f89c0227ec@solarflare.com> Date: Tue, 28 Aug 2018 13:57:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1535374462-6490-1-git-send-email-rahul.lakkireddy@chelsio.com> Content-Language: en-US X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24058.003 X-TM-AS-Result: No-13.969800-8.000000-10 X-TMASE-MatchedRID: 6lay9u8oTUMOwH4pD14DsPHkpkyUphL9WjWsWQUWzVoNmPMcsvd5FuDp 1KSIzrhhaM/uHzh3sixYo3G+rvxrNW94Ipa1otxoDB+ErBr0bAMflbDua3yEDgqiCYa6w8tvb7d y3FffNk0fWUTBltu12hHcWjVrsVyHn9MuXTlykl6JQ9k+Ypk5CdSqEluSYtV7BthzL1hCXp7OK9 xcJmgY9vS5wxPAGo07myvNVNyi/SzQbuOL+OEbWnen8w+f00WRf6/Md8Lb2l9iWbvsVhqiCkaFM Iz/3JwCscdby12QVvW9ryuU2vZyQk/4kRVhthv6wbRQ2BpmliqZEoWHC6Rh/R9Oluq8LbzVzdlo 26al4KH2vPhulcaXWIFoPFs7wHUtBawxeDgsyEmprpImTnz4ti2VljVYB9GN2Yajy1P9W1XdKUS BW7I322+5ieh24ZYRkZOl7WKIImrvXOvQVlExsFZ0V5tYhzdWbGVEmIfjf3tn0KlE5wmXjUs2QQ bs43XX3dAaVS+Dw8oZpkBxNPNn82QEWMbMIaG02RwBgB8S7S/6eFLuAlB37RceiKp/1LQ54L9ho Np0dkE= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--13.969800-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24058.003 X-MDID: 1535453870-a53MKwswvTDG Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [RFC] ethdev: add action to swap source and destination MAC 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: Tue, 28 Aug 2018 10:57:51 -0000 On 08/27/2018 03:54 PM, Rahul Lakkireddy wrote: > From: Shagun Agrawal > > This action is useful for offloading loopback mode, where the hardware > will swap source and destination MAC address before looping back the > packet. This action can be used in conjunction with other rewrite > actions to achieve MAC layer transparent NAT where the MAC addresses > are swapped before either the source or destination MAC address > is rewritten and NAT is performed. > > Signed-off-by: Shagun Agrawal > Signed-off-by: Rahul Lakkireddy > --- > app/test-pmd/cmdline_flow.c | 9 +++++++++ > app/test-pmd/config.c | 1 + > doc/guides/prog_guide/rte_flow.rst | 15 +++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 ++ > lib/librte_ethdev/rte_flow.c | 1 + > lib/librte_ethdev/rte_flow.h | 7 +++++++ > 6 files changed, 35 insertions(+) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index f9260600e..4b83b55c4 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -243,6 +243,7 @@ enum index { > ACTION_VXLAN_DECAP, > ACTION_NVGRE_ENCAP, > ACTION_NVGRE_DECAP, > + ACTION_MAC_SWAP, > }; > > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -816,6 +817,7 @@ static const enum index next_action[] = { > ACTION_VXLAN_DECAP, > ACTION_NVGRE_ENCAP, > ACTION_NVGRE_DECAP, > + ACTION_MAC_SWAP, > ZERO, > }; > > @@ -2470,6 +2472,13 @@ static const struct token token_list[] = { > .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), > .call = parse_vc, > }, > + [ACTION_MAC_SWAP] = { > + .name = "mac_swap", > + .help = "swap source and destination mac address", > + .priv = PRIV_ACTION(MAC_SWAP, 0), > + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), > + .call = parse_vc, > + }, > }; > > /** Remove and return last entry from argument stack. */ > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index 14ccd6864..b7393967a 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1153,6 +1153,7 @@ static const struct { > sizeof(struct rte_flow_action_of_pop_mpls)), > MK_FLOW_ACTION(OF_PUSH_MPLS, > sizeof(struct rte_flow_action_of_push_mpls)), > + MK_FLOW_ACTION(MAC_SWAP, 0), > }; > > /** 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 b305a72a5..530dbc504 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -2076,6 +2076,21 @@ RTE_FLOW_ERROR_TYPE_ACTION error should be returned. > > This action modifies the payload of matched flows. > > +Action: ``MAC_SWAP`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Swap source and destination mac address. > + > +.. _table_rte_flow_action_mac_swap: > + > +.. table:: MAC_SWAP > + > + +---------------+ > + | Field | > + +===============+ > + | no properties | > + +---------------+ > + > Negative types > ~~~~~~~~~~~~~~ > > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index dde205a2b..4f0da4fb6 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -3697,6 +3697,8 @@ This section lists supported actions and their attributes, if any. > - ``nvgre_decap``: Performs a decapsulation action by stripping all headers of > the NVGRE tunnel network overlay from the matched flow. > > +- ``mac_swap``: Swap source and destination mac address. > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index cff4b5209..04b0b40ea 100644 > --- a/lib/librte_ethdev/rte_flow.c > +++ b/lib/librte_ethdev/rte_flow.c > @@ -109,6 +109,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { > sizeof(struct rte_flow_action_of_pop_mpls)), > MK_FLOW_ACTION(OF_PUSH_MPLS, > sizeof(struct rte_flow_action_of_push_mpls)), > + MK_FLOW_ACTION(MAC_SWAP, 0), > }; > > static int > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index f8ba71cdb..e1fa17b7e 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -1505,6 +1505,13 @@ enum rte_flow_action_type { > * error. > */ > RTE_FLOW_ACTION_TYPE_NVGRE_DECAP, > + > + /** > + * swap the source and destination mac address in ethernet header Swap the source and destination MAC address in Ethernet header. May be it is useful to highlight that outermost Ethernet header is edited. MAC address rewrite actions require Ethernet pattern item. Is it required here? > + * > + * No associated configuration structure. > + */ > + RTE_FLOW_ACTION_TYPE_MAC_SWAP, > }; > > /**