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 CD101A2EDB for ; Sat, 7 Sep 2019 00:00:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6DCA01F496; Fri, 6 Sep 2019 23:59:52 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id CD3FD1F4AD; Fri, 6 Sep 2019 23:59:49 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id x86Lxi2U004199; Fri, 6 Sep 2019 14:59:45 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: nirranjan@chelsio.com, stable@dpdk.org Date: Sat, 7 Sep 2019 03:22:25 +0530 Message-Id: X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 04/12] net/cxgbe: fix parsing VLAN ID rewrite action 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" Set VLAN action mode to VLAN_REWRITE only if VLAN_INSERT has not been set yet. Otherwise, the resulting VLAN packets will have their VLAN header rewritten, instead of pushing a new outer VLAN header. Also fix the VLAN ID extraction logic and endianness issues. Cc: stable@dpdk.org Fixes: 1decc62b1cbe ("net/cxgbe: add flow operations to offload VLAN actions") Signed-off-by: Rahul Lakkireddy --- drivers/net/cxgbe/cxgbe_flow.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c index 8a5d06ff3..4c8553039 100644 --- a/drivers/net/cxgbe/cxgbe_flow.c +++ b/drivers/net/cxgbe/cxgbe_flow.c @@ -446,18 +446,27 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a, const struct rte_flow_action_set_tp *tp_port; const struct rte_flow_action_phy_port *port; int item_index; + u16 tmp_vlan; switch (a->type) { case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: vlanid = (const struct rte_flow_action_of_set_vlan_vid *) a->conf; - fs->newvlan = VLAN_REWRITE; - fs->vlan = vlanid->vlan_vid; + /* If explicitly asked to push a new VLAN header, + * then don't set rewrite mode. Otherwise, the + * incoming VLAN packets will get their VLAN fields + * rewritten, instead of adding an additional outer + * VLAN header. + */ + if (fs->newvlan != VLAN_INSERT) + fs->newvlan = VLAN_REWRITE; + tmp_vlan = fs->vlan & 0xe000; + fs->vlan = (be16_to_cpu(vlanid->vlan_vid) & 0xfff) | tmp_vlan; break; case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: pushvlan = (const struct rte_flow_action_of_push_vlan *) a->conf; - if (pushvlan->ethertype != RTE_ETHER_TYPE_VLAN) + if (be16_to_cpu(pushvlan->ethertype) != RTE_ETHER_TYPE_VLAN) return rte_flow_error_set(e, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, a, "only ethertype 0x8100 " -- 2.18.0