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 BFD81A04A4; Wed, 2 Mar 2022 07:35:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15E7D4270D; Wed, 2 Mar 2022 07:35:48 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id CA05B4270D for ; Wed, 2 Mar 2022 07:35:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646202945; x=1677738945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hcQi0nGUqTBc7KqsdUJtE3AlDAReleOQP4k0LZb8KTg=; b=EhE4tgxRZfCccXP2S0w/51sCU7O4Xe0Myhjt+Rb2AuMZrtsungDU0x71 HlHbtDxYxWl4iybjYWVLb3jgBMO3P90LXuq074vddRxIq+sLDhSPfx8xa 15GStQXARLD62gktluNHOwQDWwmiJfwioXKfG1gSKeu8wJ7bvjhiVTMGP ojSIl8iJaj3MLWucS20FXbupX4Igau6aOp82kRW/MWEbNRwOxD3qlY7Aw FiHrsszvY5zq6bkBz6Xtm6AQZfWCFPt4kJ6Kbnd95j6OFkDvzPSfOmmSn LDWQugok+HgwfvKIyaCRPSHbsCtrmlDM7baDxQ8X+5INR58UcqC7YWSIB A==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="236832531" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="236832531" 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:45 -0800 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641583290" 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:43 -0800 From: Ke Zhang To: dev@dpdk.org, qiming.yang@intel.com, qi.z.zhang@intel.com Cc: Ke Zhang Subject: [PATCH v6 3/4] net/ice: add support for add/remove mac addr by DCF Date: Wed, 2 Mar 2022 06:30:51 +0000 Message-Id: <20220302063052.347122-4-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 add/remove VF's mac addr 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_ethdev.h | 1 + drivers/net/ice/ice_dcf_vf_representor.c | 81 +++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 11a1305038..ea5c020d61 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -50,6 +50,7 @@ struct ice_dcf_vf_repr { struct rte_ether_addr mac_addr; uint16_t switch_domain_id; uint16_t vf_id; + uint16_t mac_num; /* Number of MAC addresses */ struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */ }; diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index 765f5d4c95..8a387461c4 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -159,7 +159,7 @@ ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev, return -EIO; dev_info->device = dev->device; - dev_info->max_mac_addrs = 1; + dev_info->max_mac_addrs = ICE_NUM_MACADDR_MAX; dev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs; dev_info->max_tx_queues = dcf_hw->vsi_res->num_queue_pairs; dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN; @@ -536,6 +536,82 @@ ice_dcf_vf_repr_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) } return ret; } +static int +ice_dcf_repr_add_del_eth_addr(struct ice_dcf_hw *hw, + uint16_t vf_id, + struct rte_ether_addr *addr, + bool add, uint8_t type) +{ + struct virtchnl_ether_addr_list *list; + struct dcf_virtchnl_cmd args; + uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) + + sizeof(struct virtchnl_ether_addr)]; + int err; + + list = (struct virtchnl_ether_addr_list *)cmd_buffer; + list->vsi_id = hw->vf_vsi_map[vf_id] & ~VIRTCHNL_DCF_VF_VSI_VALID; + list->num_elements = 1; + list->list[0].type = type; + rte_memcpy(list->list[0].addr, addr->addr_bytes, + sizeof(addr->addr_bytes)); + + args.v_op = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR; + args.req_msg = cmd_buffer; + args.req_msglen = sizeof(cmd_buffer); + + 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_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr, + __rte_unused uint32_t index, + __rte_unused uint32_t pool) +{ + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + struct ice_dcf_hw *hw = ice_dcf_vf_repr_hw(repr); + int err; + + if (rte_is_zero_ether_addr(addr)) { + PMD_DRV_LOG(ERR, "Invalid Ethernet Address"); + return -EINVAL; + } + + err = ice_dcf_repr_add_del_eth_addr(hw, repr->vf_id, addr, true, VIRTCHNL_ETHER_ADDR_EXTRA); + if (err) { + PMD_DRV_LOG(ERR, "fail to add MAC address"); + return -EIO; + } + + repr->mac_num++; + + return 0; +} + +static void +ice_dcf_vf_repr_del_mac_addr(struct rte_eth_dev *dev, uint32_t index) +{ + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + struct ice_dcf_hw *hw = ice_dcf_vf_repr_hw(repr); + struct rte_ether_addr *addr; + int err; + + addr = &dev->data->mac_addrs[index]; + + err = ice_dcf_repr_add_del_eth_addr(hw, repr->vf_id, addr, + false, VIRTCHNL_ETHER_ADDR_EXTRA); + if (err) + PMD_DRV_LOG(ERR, "fail to del MAC address"); + + repr->mac_num--; +} + 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, @@ -554,6 +630,8 @@ static const struct eth_dev_ops ice_dcf_vf_repr_dev_ops = { .vlan_tpid_set = ice_dcf_vf_repr_vlan_tpid_set, .stats_reset = ice_dcf_vf_repr_stats_reset, .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, }; int @@ -568,6 +646,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param) repr->outer_vlan_info.port_vlan_ena = false; repr->outer_vlan_info.stripping_ena = false; repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN; + repr->mac_num = 1; vf_rep_eth_dev->dev_ops = &ice_dcf_vf_repr_dev_ops; -- 2.25.1