From patchwork Wed Sep 2 06:38:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiming Yang X-Patchwork-Id: 76293 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 dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 692D2A04B5; Wed, 2 Sep 2020 08:59:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C50C51C0B6; Wed, 2 Sep 2020 08:59:32 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 31E9A1C07D for ; Wed, 2 Sep 2020 08:59:30 +0200 (CEST) IronPort-SDR: 3sFe6EhnF3RuZonyl4krWkx7JmkPpSXZmvhByKOBsd5a3w0DPj0UczNYBMDhuk3B1fmqBUleeQ bx6/tjihD+nQ== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="156593272" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="156593272" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2020 23:59:28 -0700 IronPort-SDR: hmcYWKwEUodhiBU0CA7RGj33ZYnEdpZTnWW7BrLXRMKc5N1baqHezvDalGv7eC7KE8/G4KGTYS B1iseVWkF7kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="325664236" Received: from dpdk-qiming1.sh.intel.com ([10.67.119.9]) by fmsmga004.fm.intel.com with ESMTP; 01 Sep 2020 23:59:27 -0700 From: Qiming Yang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, Qiming Yang Date: Wed, 2 Sep 2020 14:38:02 +0800 Message-Id: <20200902063802.102428-3-qiming.yang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200902063802.102428-1-qiming.yang@intel.com> References: <20200902063802.102428-1-qiming.yang@intel.com> Subject: [dpdk-dev] [PATCH 2/2] net/ice: add VLAN config for DCF 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" This patch add support for VF VLAN offload, port VLAN id set and VLAN ethertype set in DCF. This patch depend on base code update. Signed-off-by: Qiming Yang --- drivers/net/ice/ice_dcf.h | 1 + drivers/net/ice/ice_dcf_vf_representor.c | 120 +++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index a44a01e90..b960cf7cf 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -59,6 +59,7 @@ struct ice_dcf_hw { uint16_t nb_msix; uint16_t rxq_map[16]; struct virtchnl_eth_stats eth_stats_offset; + struct virtchnl_dcf_vlan_offload vlan_config; }; int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw, diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index ceb54ab15..53d0db85f 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -185,6 +185,123 @@ ice_dcf_representor_dev_info_get(struct rte_eth_dev *dev, return 0; } +static int +ice_dcf_config_vlan_offload(struct ice_dcf_hw *hw, + struct virtchnl_dcf_vlan_offload *vlan_config) +{ + struct dcf_virtchnl_cmd args; + int err; + + memset(&args, 0, sizeof(args)); + args.v_op = VIRTCHNL_OP_DCF_VLAN_OFFLOAD; + args.req_msg = (uint8_t *)vlan_config; + args.req_msglen = sizeof(vlan_config); + err = ice_dcf_execute_virtchnl_cmd(hw, &args); + if (err) + PMD_DRV_LOG(ERR, "fail to execute command %s", + "VIRTCHNL_OP_DCF_VLAN_OFFLOAD"); + return err; +} + +static int +ice_dcf_representor_vlan_offload_set(struct rte_eth_dev *dev, int mask) +{ + struct ice_dcf_vf_representor *representor = dev->data->dev_private; + struct ice_dcf_hw *hw = &representor->adapter->real_hw; + struct virtchnl_dcf_vlan_offload vlan_config; + int ret = 0; + + vlan_config.vf_id = representor->vf_id; + + if (hw->vlan_config.tx_flags == VIRTCHNL_VLAN_TX_INSERT) { + PMD_DRV_LOG(ERR, "Please clear pvid before set vlan offload."); + return -EINVAL; + } + + if (mask & ETH_VLAN_STRIP_MASK) { + if (hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) { + vlan_config.type = VIRTCHNL_VLAN_OUTER_TYPE; + vlan_config.rx_flags = VIRTCHNL_VLAN_RX_STRIP_IN_DESC; + vlan_config.tx_flags = VIRTCHNL_VLAN_TX_INSERT_BY_DESC; + } else { + vlan_config.type = VIRTCHNL_VLAN_OUTER_TYPE; + vlan_config.rx_flags = VIRTCHNL_VLAN_RX_NO_STRIP; + vlan_config.tx_flags = VIRTCHNL_VLAN_TX_INSERT_BY_DESC; + } + ret = ice_dcf_config_vlan_offload(hw, &vlan_config); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Failed to set vlan offload."); + return -EINVAL; + } + } + + rte_memcpy(&hw->vlan_config, &vlan_config, sizeof(vlan_config)); + + return ret; +} + +static int +ice_dcf_representor_vlan_pvid_set(struct rte_eth_dev *dev, + uint16_t pvid, int on) +{ + struct ice_dcf_vf_representor *representor = dev->data->dev_private; + struct ice_dcf_hw *hw = &representor->adapter->real_hw; + struct virtchnl_dcf_vlan_offload vlan_config; + int ret; + + vlan_config.vf_id = representor->vf_id; + vlan_config.type = VIRTCHNL_VLAN_OUTER_TYPE; + vlan_config.vlan_id = pvid; + if (on) { + vlan_config.rx_flags = VIRTCHNL_VLAN_RX_STRIP_ONLY; + vlan_config.tx_flags = VIRTCHNL_VLAN_TX_INSERT; + } else { + vlan_config.rx_flags = VIRTCHNL_VLAN_RX_NO_STRIP; + vlan_config.tx_flags = VIRTCHNL_VLAN_TX_INSERT_BY_DESC; + } + + ret = ice_dcf_config_vlan_offload(hw, &vlan_config); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Failed to set pvid."); + return -EINVAL; + } + + rte_memcpy(&hw->vlan_config, &vlan_config, sizeof(vlan_config)); + + return 0; +} + +static int +ice_dcf_representor_vlan_tpid_set(struct rte_eth_dev *dev, + enum rte_vlan_type vlan_type, + uint16_t tpid) +{ + struct ice_dcf_vf_representor *representor = dev->data->dev_private; + struct ice_dcf_hw *hw = &representor->adapter->real_hw; + struct virtchnl_dcf_vlan_offload vlan_config; + int ret; + + if (vlan_type != ETH_VLAN_TYPE_INNER && + vlan_type != ETH_VLAN_TYPE_OUTER) { + PMD_DRV_LOG(ERR, + "Unsupported vlan type."); + return -EINVAL; + } + + vlan_config.vf_id = representor->vf_id; + vlan_config.ether_type = tpid; + ret = ice_dcf_config_vlan_offload(hw, &vlan_config); + if (ret < 0) { + PMD_DRV_LOG(ERR, + "Set tpid fail\n"); + return ret; + } + + rte_memcpy(&hw->vlan_config, &vlan_config, sizeof(vlan_config)); + + return ret; +} + static const struct eth_dev_ops ice_dcf_representor_dev_ops = { .dev_configure = ice_dcf_representor_dev_configure, .dev_start = ice_dcf_representor_dev_start, @@ -195,6 +312,9 @@ static const struct eth_dev_ops ice_dcf_representor_dev_ops = { .promiscuous_enable = ice_dcf_representor_promiscuous_enable, .promiscuous_disable = ice_dcf_representor_promiscuous_disable, .link_update = ice_dcf_representor_link_update, + .vlan_offload_set = ice_dcf_representor_vlan_offload_set, + .vlan_pvid_set = ice_dcf_representor_vlan_pvid_set, + .vlan_tpid_set = ice_dcf_representor_vlan_tpid_set, }; int