From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-f53.google.com (mail-qg0-f53.google.com [209.85.192.53]) by dpdk.org (Postfix) with ESMTP id 66080C34A for ; Tue, 2 Jun 2015 16:51:55 +0200 (CEST) Received: by qgf2 with SMTP id 2so59719630qgf.3 for ; Tue, 02 Jun 2015 07:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=oZzrbN3QY1EScJAPr4KZWTBePZBZaXoQcfxfzN/TvlM=; b=F6vC1f1emqLkI0qRzDtYo54VVNEAlvczYQX99Gp7C11RRHcW0mChZVgrI4UNro5Xi4 Qxs9N3I+AS6DA0m5a6Ml1rinHF4IeYJBHok6CfbapYdjnYloJfBMCimS/5K5VD5IwH+j qma9bVvIVK4vnLPY3EYc+ldHJi46Ol08Ssq6Z1lxm7e0xOa5cLljkCNIHQZrQnIyt2QB fS2M5CAR1XGguWRzQKACj94ZXKTNbIWaPhXhWmT5EXpoD6c07ck9YOcahoAEiT4oVCIy pCFRXmzBzqCiK6nL9G99ZN3FjVqCRUe07dOh2F3FIr+1ARY+l1yiakbDmImAlHbzp6kD K4Lw== X-Gm-Message-State: ALoCoQmXLobM+Ke0WFqXnCZlyo9Sppd71XO5Nly1dGh7d8hsRCd72uCJJhJQjo+a0qup5tgFRt8R X-Received: by 10.55.24.167 with SMTP id 39mr47911807qky.43.1433256714864; Tue, 02 Jun 2015 07:51:54 -0700 (PDT) Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id d10sm7409377qhc.9.2015.06.02.07.51.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:51:54 -0700 (PDT) Date: Tue, 2 Jun 2015 07:51:50 -0700 From: Stephen Hemminger To: Thomas Monjalon Message-ID: <20150602075150.4139cdaf@urahara> In-Reply-To: <1821700.XUk45KJcQp@xps13> References: <1432927612-12244-1-git-send-email-liang-min.wang@intel.com> <1432927612-12244-2-git-send-email-liang-min.wang@intel.com> <2601191342CEEE43887BDE71AB977258214345AB@irsmsx105.ger.corp.intel.com> <1821700.XUk45KJcQp@xps13> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org, "Wang, Liang-min" Subject: Re: [dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2015 14:51:55 -0000 On Tue, 02 Jun 2015 14:23:22 +0200 Thomas Monjalon wrote: > 2015-06-02 10:52, Ananyev, Konstantin: > > From: Wang, Liang-min =20 > > > int > > > +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr = *addr) > > > +{ > > > + struct rte_eth_dev *dev; > > > + > > > + if (!rte_eth_dev_is_valid_port(port_id)) { > > > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > > > + return -ENODEV; > > > + } > > > + > > > + dev =3D &rte_eth_devices[port_id]; > > > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); > > > + > > > + return (*dev->dev_ops->mac_addr_set)(dev, addr); > > > +} =20 > >=20 > > As I can see mac_addr_set() is implemented now only for virtio. > > Which means that for all Intel HW your new rte_eth_dev_default_mac_addr= _set() > > would not work right now? > > Probably rte_eth_dev_default_mac_addr_set() should combine both approac= hes: > > If mac_addr_set() is implemented by dev, then use it, otherwise try to = use addr_remove()/addr_add() > > (as your first version did)? > > Konstantin =20 >=20 > Not sure it is a good idea to use remove/add to set the default unicast m= ac address. > It would be clearer to add comments to remove/add functions to specify th= at > they don't apply to the default adress but only to secondary ones. Then u= se > the same logic for both API and driver ops. > It is the responsibility of the driver implementation to use common funct= ions > for default_set and remove/add functions. Only vmxnet3 and virtio need special treatment. virtio is already covered. Here is patch for vmxnet3. We have used this for several releases. =46rom eef188102338c5687b9075d468eabbe87693b075 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 2 Jun 2015 07:49:53 -0700 Subject: [PATCH] vmxnet3: support setting primary MAC address This allows setting primary MAC address on VMXNET3. Signed-off-by: Stephen Hemminger --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 45 +++++++++++++++++++++++++-------= ---- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmx= net3_ethdev.c index 1685ce4..6515f74 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -85,6 +85,9 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void vmxnet3_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); +static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev, + struct ether_addr *mac_addr); + #if PROCESS_SYS_EVENTS =3D=3D 1 static void vmxnet3_process_events(struct vmxnet3_hw *); #endif @@ -110,6 +113,7 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops =3D= { .allmulticast_disable =3D vmxnet3_dev_allmulticast_disable, .link_update =3D vmxnet3_dev_link_update, .stats_get =3D vmxnet3_dev_stats_get, + .mac_addr_set =3D vmxnet3_mac_addr_set, .dev_infos_get =3D vmxnet3_dev_info_get, .rx_queue_setup =3D vmxnet3_dev_rx_queue_setup, .rx_queue_release =3D vmxnet3_dev_rx_queue_release, @@ -359,6 +363,23 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev) return 0; } =20 +static void +vmxnet3_write_mac(struct vmxnet3_hw *hw, const uint8_t *addr) +{ + uint32_t val; + + PMD_INIT_LOG(DEBUG, + "Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x", + addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5]); + + val =3D *(const uint32_t *)addr; + VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, val); + + val =3D (addr[5] << 8) | addr[4]; + VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACH, val); +} + static int vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) { @@ -366,8 +387,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) struct vmxnet3_hw *hw =3D dev->data->dev_private; Vmxnet3_DriverShared *shared =3D hw->shared; Vmxnet3_DSDevRead *devRead =3D &shared->devRead; - uint32_t *mac_ptr; - uint32_t val, i; + uint32_t i; int ret; =20 shared->magic =3D VMXNET3_REV1_MAGIC; @@ -459,18 +479,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) return ret; } =20 - PMD_INIT_LOG(DEBUG, - "Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x", - hw->perm_addr[0], hw->perm_addr[1], hw->perm_addr[2], - hw->perm_addr[3], hw->perm_addr[4], hw->perm_addr[5]); - - /* Write MAC Address back to device */ - mac_ptr =3D (uint32_t *)hw->perm_addr; - val =3D *mac_ptr; - VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, val); - - val =3D (hw->perm_addr[5] << 8) | hw->perm_addr[4]; - VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACH, val); + vmxnet3_write_mac(hw, hw->perm_addr); =20 return VMXNET3_SUCCESS; } @@ -645,6 +654,14 @@ vmxnet3_dev_info_get(__attribute__((unused))struct rte= _eth_dev *dev, struct rte_ dev_info->flow_type_rss_offloads =3D VMXNET3_RSS_OFFLOAD_ALL; } =20 +static void +vmxnet3_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) +{ + struct vmxnet3_hw *hw =3D dev->data->dev_private; + + vmxnet3_write_mac(hw, mac_addr->addr_bytes); +} + /* return 0 means link status changed, -1 means not changed */ static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) i= nt wait_to_complete) --=20 2.1.4