From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2300A04A4; Wed, 2 Mar 2022 07:35:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F23A542707; Wed, 2 Mar 2022 07:35:49 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id BC29B40141 for ; Wed, 2 Mar 2022 07:35:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646202947; x=1677738947; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J0/zk9G03ayAOxGrhdcXfhMR+O7p3c/DLKGim7uRL1s=; b=ZzTFaeQHFpGGH0Q1KGovdXnE5ToJqfNa+wyf6baEQ6hz36vBgvXxcV8q cBPo1aXCG+zWjVymDeE6/LnU4+9B7npNdfMUKVjuimtBkVBoRV7nqogqA DtUCQoFVqG+mVbX8xJ7cAIzT4gn+5BQeTrjJuFLEbK7QUdp0+yC0tc82c NiMVCSLNQR/JT8nfHijlp097JnACl26YS+/RLEFzcNnP+ePUTyXchiUxH G02o8i2M15urJWDUBLV0GqBHidAN/llLtQLNvPZ1UwG7pYM6u+nm/9YO3 Fb0SYtNP8f0QW7hs6ThsekJE6jiNnA2dcRDLfmoBTzn01r/Nhola3gpur w==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="236832533" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="236832533" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 22:35:47 -0800 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641583294" Received: from intel-corei7-64.sh.intel.com (HELO localhost.localdomain) ([10.239.251.104]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 22:35:45 -0800 From: Ke Zhang To: dev@dpdk.org, qiming.yang@intel.com, qi.z.zhang@intel.com Cc: Ke Zhang Subject: [PATCH v6 4/4] net/ice: add support to configure the VLAN filter by DCF Date: Wed, 2 Mar 2022 06:30:52 +0000 Message-Id: <20220302063052.347122-5-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302063052.347122-1-ke1x.zhang@intel.com> References: <20220302063052.347122-1-ke1x.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 allow to configure the VLAN filter over VF0. this feature need to update ice kernel driver (newer than v1.8.0) Signed-off-by: Ke Zhang --- drivers/net/ice/ice_dcf_vf_representor.c | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index 8a387461c4..eca2710735 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -612,6 +612,56 @@ ice_dcf_vf_repr_del_mac_addr(struct rte_eth_dev *dev, uint32_t index) repr->mac_num--; } +static int +ice_dcf_add_del_vlan_v2(struct rte_eth_dev *dev, uint16_t vlanid, bool add) +{ + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + struct ice_dcf_hw *hw = ice_dcf_vf_repr_hw(repr); + struct virtchnl_vlan_filter_list_v2 vlan_filter; + struct dcf_virtchnl_cmd args; + struct virtchnl_vlan *vlan_setting; + int err; + + vlan_setting = &vlan_filter.filters[0].outer; + memset(&vlan_filter, 0, sizeof(vlan_filter)); + vlan_filter.vport_id = hw->vf_vsi_map[repr->vf_id] & ~VIRTCHNL_DCF_VF_VSI_VALID; + vlan_filter.num_elements = 1; + vlan_setting->tpid = RTE_ETHER_TYPE_VLAN; + vlan_setting->tci = vlanid; + + memset(&args, 0, sizeof(args)); + args.v_op = add ? VIRTCHNL_OP_ADD_VLAN_V2 : VIRTCHNL_OP_DEL_VLAN_V2; + args.req_msg = (uint8_t *)&vlan_filter; + args.req_msglen = sizeof(vlan_filter); + + err = ice_dcf_execute_virtchnl_cmd(hw, &args); + if (err) { + PMD_DRV_LOG(ERR, "Fail to execute command %s", + add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR"); + return err; + } + return 0; +} + +static int +ice_dcf_vf_repr_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) +{ + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + int err; + + if (!ice_dcf_vlan_offload_ena(repr)) { + PMD_DRV_LOG(ERR, "It is not VLAN_V2"); + return -ENOTSUP; + } + + err = ice_dcf_add_del_vlan_v2(dev, vlan_id, on); + if (err) { + PMD_DRV_LOG(ERR, "Failed to set vlan filter, err:%d", err); + return -ENOTSUP; + } + return 0; +} + static const struct eth_dev_ops ice_dcf_vf_repr_dev_ops = { .dev_configure = ice_dcf_vf_repr_dev_configure, .dev_start = ice_dcf_vf_repr_dev_start, @@ -632,6 +682,7 @@ static const struct eth_dev_ops ice_dcf_vf_repr_dev_ops = { .stats_get = ice_dcf_vf_repr_stats_get, .mac_addr_add = ice_dcf_vf_repr_add_mac_addr, .mac_addr_remove = ice_dcf_vf_repr_del_mac_addr, + .vlan_filter_set = ice_dcf_vf_repr_vlan_filter_set, }; int -- 2.25.1