From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 736D7A0352; Mon, 23 Dec 2019 08:30:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFA8F1C01; Mon, 23 Dec 2019 08:30:17 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 80F8B1252 for ; Mon, 23 Dec 2019 08:30:15 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2019 23:30:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,346,1571727600"; d="scan'208";a="268081732" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by FMSMGA003.fm.intel.com with ESMTP; 22 Dec 2019 23:30:13 -0800 Date: Mon, 23 Dec 2019 15:25:12 +0800 From: Ye Xiaolong To: Guinan Sun Cc: dev@dpdk.org, Wenzhuo Lu , Qiming Yang , Beilei Xing Message-ID: <20191223072512.GC14498@intel.com> References: <20191203145457.72154-1-guinanx.sun@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191203145457.72154-1-guinanx.sun@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address 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" Hi, guinan For the title, better to use Add support for vf MAC address add and remove or something like so. On 12/03, Guinan Sun wrote: >Ixgbe PMD pf host code needs to support ixgbevf mac address >add and remove. For this purpose, a response was added >between pf and vf to update the mac address. Does this mean each one vf can have multiple MAC addresses after this patch, or this `add` actually means to replace the old mac address with the new one? > >Signed-off-by: Guinan Sun >--- > drivers/net/ixgbe/ixgbe_ethdev.h | 1 + > drivers/net/ixgbe/ixgbe_pf.c | 35 ++++++++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+) > >diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h >index 76a1b9d18..e1cd8fd16 100644 >--- a/drivers/net/ixgbe/ixgbe_ethdev.h >+++ b/drivers/net/ixgbe/ixgbe_ethdev.h >@@ -270,6 +270,7 @@ struct ixgbe_vf_info { > uint8_t api_version; > uint16_t switch_domain_id; > uint16_t xcast_mode; >+ uint16_t mac_count; How is this mac_count initialized? > }; > > /* >diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c >index d0d85e138..76dbed2ab 100644 >--- a/drivers/net/ixgbe/ixgbe_pf.c >+++ b/drivers/net/ixgbe/ixgbe_pf.c >@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) > return 0; > } > >+static int >+ixgbe_set_vf_macvlan_msg(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) >+{ >+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); >+ struct ixgbe_vf_info *vf_info = >+ *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); >+ uint8_t *new_mac = (uint8_t *)(&msgbuf[1]); >+ int index = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >> >+ IXGBE_VT_MSGINFO_SHIFT; >+ >+ if (index) { >+ if (!rte_is_valid_assigned_ether_addr( >+ (struct rte_ether_addr *)new_mac)) { >+ RTE_LOG(ERR, PMD, "set invalid mac vf:%d\n", vf); >+ return -1; >+ } >+ >+ if (new_mac == NULL) >+ return -1; I feel the null check should be in front of valid ether addr check, otherwise there might be null pointer reference issue. Thanks, Xiaolong >+ >+ vf_info[vf].mac_count++; >+ >+ hw->mac.ops.set_rar(hw, vf_info[vf].mac_count, >+ new_mac, vf, IXGBE_RAH_AV); >+ } else { >+ hw->mac.ops.clear_rar(hw, vf_info[vf].mac_count); >+ vf_info[vf].mac_count = 0; >+ } >+ return 0; >+} >+ > static int > ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) > { >@@ -835,6 +866,10 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) > if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED) > retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf); > break; >+ case IXGBE_VF_SET_MACVLAN: >+ if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED) >+ retval = ixgbe_set_vf_macvlan_msg(dev, vf, msgbuf); >+ break; > default: > PMD_DRV_LOG(DEBUG, "Unhandled Msg %8.8x", (unsigned)msgbuf[0]); > retval = IXGBE_ERR_MBX; >-- >2.17.1 >