From patchwork Tue Jan 24 02:44:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 19925 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D89472A5B; Tue, 24 Jan 2017 03:45:42 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id D83A3108F for ; Tue, 24 Jan 2017 03:45:40 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 23 Jan 2017 18:45:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,276,1477983600"; d="scan'208";a="56445566" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by orsmga005.jf.intel.com with ESMTP; 23 Jan 2017 18:45:38 -0800 From: Beilei Xing To: jingjing.wu@intel.com Cc: wenzhuo.lu@intel.com, dev@dpdk.org Date: Tue, 24 Jan 2017 10:44:27 +0800 Message-Id: <1485225867-116610-1-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue 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" VNI of VXLAN is parsed wrongly. The root cause is that array vni in item VXLAN also uses network byte ordering. Fixes: d416530e6358 ("net/i40e: parse tunnel filter") Signed-off-by: Beilei Xing Acked-by: Wenzhuo Lu --- drivers/net/i40e/i40e_flow.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 76bb332..51b3223 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1196,6 +1196,20 @@ i40e_check_tenant_id_mask(const uint8_t *mask) return is_masked; } +static uint32_t +i40e_flow_set_tenant_id(const uint8_t *vni) +{ + uint32_t tenant_id; + +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + tenant_id = (vni[0] << 16) | (vni[1] << 8) | vni[2]; +#else + tenant_id = vni[0] | (vni[1] << 8) | (vni[2] << 16); +#endif + + return tenant_id; +} + /* 1. Last in item should be NULL as range is not supported. * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN, * IMAC_TENID, OMAC_TENID_IMAC and IMAC. @@ -1364,8 +1378,8 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern, & I40E_TCI_MASK; if (vxlan_spec && vxlan_mask && !is_vni_masked) { /* If there's vxlan */ - rte_memcpy(&filter->tenant_id, vxlan_spec->vni, - RTE_DIM(vxlan_spec->vni)); + filter->tenant_id = + i40e_flow_set_tenant_id(vxlan_spec->vni); if (!o_eth_spec && !o_eth_mask && i_eth_spec && i_eth_mask) filter->filter_type = @@ -1402,8 +1416,8 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern, /* If there's no inner vlan */ if (vxlan_spec && vxlan_mask && !is_vni_masked) { /* If there's vxlan */ - rte_memcpy(&filter->tenant_id, vxlan_spec->vni, - RTE_DIM(vxlan_spec->vni)); + filter->tenant_id = + i40e_flow_set_tenant_id(vxlan_spec->vni); if (!o_eth_spec && !o_eth_mask && i_eth_spec && i_eth_mask) filter->filter_type =