From patchwork Mon Jan 25 04:30:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Haiyue" X-Patchwork-Id: 87169 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6912CA052A; Mon, 25 Jan 2021 05:47:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3347140D34; Mon, 25 Jan 2021 05:47:01 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 3EFBF140D29 for ; Mon, 25 Jan 2021 05:46:59 +0100 (CET) IronPort-SDR: C/W3toGw9bk8uhGm99oPIsXwhz84IwmbaoOUrSj/X+xBOKJ2GWgI1bHiaf4M2l9SFAUxtuYT2m 6DA2FC9/WXdQ== X-IronPort-AV: E=McAfee;i="6000,8403,9874"; a="166763069" X-IronPort-AV: E=Sophos;i="5.79,372,1602572400"; d="scan'208";a="166763069" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2021 20:46:58 -0800 IronPort-SDR: LnfcVliFPcjWdO82vy9F2hhTaRVq8SdUhZRkv9CVQ/H/C5fZ/diat7zxuFIxPblIdVsAZYY/By g0a0iFdw5BqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,372,1602572400"; d="scan'208";a="387153260" Received: from npg-dpdk-haiyue-3.sh.intel.com ([10.67.118.189]) by orsmga008.jf.intel.com with ESMTP; 24 Jan 2021 20:46:56 -0800 From: Haiyue Wang To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, Haiyue Wang , Jingjing Wu , Beilei Xing Date: Mon, 25 Jan 2021 12:30:54 +0800 Message-Id: <20210125043054.4998-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1] net/iavf: fix unsupported VLAN offload requested X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" If the underlying PF doesn't support a specific ethertype or the ability to toggle VLAN insertion and/or stripping, then the VF prevents sending an invalid message to the PF. Fixes: 1c301e8c3cff ("net/iavf: support new VLAN capabilities") Signed-off-by: Haiyue Wang Acked-by: Qi Zhang --- drivers/net/iavf/iavf_vchnl.c | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index c82925eceb..9b8c4d113a 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -528,23 +528,21 @@ int iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - struct virtchnl_vlan_supported_caps *supported_caps; + struct virtchnl_vlan_supported_caps *stripping_caps; struct virtchnl_vlan_setting vlan_strip; struct iavf_cmd_info args; - uint32_t stripping_caps; uint32_t *ethertype; int ret; - supported_caps = &vf->vlan_v2_caps.offloads.stripping_support; - if (supported_caps->outer) { - stripping_caps = supported_caps->outer; + stripping_caps = &vf->vlan_v2_caps.offloads.stripping_support; + + if ((stripping_caps->outer & VIRTCHNL_VLAN_ETHERTYPE_8100) && + (stripping_caps->outer & VIRTCHNL_VLAN_TOGGLE)) ethertype = &vlan_strip.outer_ethertype_setting; - } else { - stripping_caps = supported_caps->inner; + else if ((stripping_caps->inner & VIRTCHNL_VLAN_ETHERTYPE_8100) && + (stripping_caps->inner & VIRTCHNL_VLAN_TOGGLE)) ethertype = &vlan_strip.inner_ethertype_setting; - } - - if (!(stripping_caps & VIRTCHNL_VLAN_ETHERTYPE_8100)) + else return -ENOTSUP; memset(&vlan_strip, 0, sizeof(vlan_strip)); @@ -570,23 +568,21 @@ int iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - struct virtchnl_vlan_supported_caps *supported_caps; + struct virtchnl_vlan_supported_caps *insertion_caps; struct virtchnl_vlan_setting vlan_insert; struct iavf_cmd_info args; - uint32_t insertion_caps; uint32_t *ethertype; int ret; - supported_caps = &vf->vlan_v2_caps.offloads.insertion_support; - if (supported_caps->outer) { - insertion_caps = supported_caps->outer; + insertion_caps = &vf->vlan_v2_caps.offloads.insertion_support; + + if ((insertion_caps->outer & VIRTCHNL_VLAN_ETHERTYPE_8100) && + (insertion_caps->outer & VIRTCHNL_VLAN_TOGGLE)) ethertype = &vlan_insert.outer_ethertype_setting; - } else { - insertion_caps = supported_caps->inner; + else if ((insertion_caps->inner & VIRTCHNL_VLAN_ETHERTYPE_8100) && + (insertion_caps->inner & VIRTCHNL_VLAN_TOGGLE)) ethertype = &vlan_insert.inner_ethertype_setting; - } - - if (!(insertion_caps & VIRTCHNL_VLAN_ETHERTYPE_8100)) + else return -ENOTSUP; memset(&vlan_insert, 0, sizeof(vlan_insert));