From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 45F222BE5 for ; Fri, 4 Mar 2016 19:07:59 +0100 (CET) Received: by mail-pf0-f178.google.com with SMTP id 124so39395530pfg.0 for ; Fri, 04 Mar 2016 10:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q0hz5QdjQIxcOOKJY2EpgQjqoKjfaK4V9alNAeBLHrY=; b=nZ8AvRPwXb8CUGwiC3kc2B2hNlpT9QMg3O16LdonMZ3wfM9lH2I1B5F1+fJDpRGIg5 EZDyqG5Fe7tnRqDHkFjYDgtcABGLUeOHKHYfnWs65J1ItJy1NHhksURanpfizxm8Vl0K M73F6BW2kupqlww6vx/ObApqXQVF5jlekMeUqB1EMrkNxLAn5FWhwnLu/7Vbns6LjJ8l X1SLM8o18TP2msZAqfpiof4aUlLG2NTWOucANSNyue1CAg7CljH9Cgak0Ti+BSJqOfWb lgxr5VqPeyUFrysSJ4LSbutAsTX/j71zaCfJ3qOgy2Ew1Ibtw2/ALrNVkByPDo3xT8nj y3YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q0hz5QdjQIxcOOKJY2EpgQjqoKjfaK4V9alNAeBLHrY=; b=M0Qt5b+aIcHH3mYdYoK7AUkUUQu7hJYdFy4UbVSj6sVr/QQiWlkHmg+sdNZkf1iz+5 aGgcFjpGM/ts+K8NJ4R7RjVWUw0YlwAkyJ6dk0ePl1jb5+7ffINjGBEnm5aJyuZui7HS qu4cJ40UUwZ4EPTFlfpQ2J28g+7Q992x0sxDR1IP1Y1MjvIEwOnJjLQwqpVHkq1KMzLd 1m1SZAHusc9LIOMnnAulil5oYv9U6fUKMUaScE3eP7HT77sWB9b/6exeiDBhIzsSfLzE LNBLy4o2PhW8phH2tzeqPXPSVx9h7rk1/2RHVJxyGTYByOnPdG+XsdJkGKe13lENFx2o fKqQ== X-Gm-Message-State: AD7BkJLR3rktbSk9q14swYQJSR/GOPqEpu5k0LTsqiws4STjoTn/xpZXkrh9oTlHqUMxSA== X-Received: by 10.98.13.154 with SMTP id 26mr14053895pfn.164.1457114878727; Fri, 04 Mar 2016 10:07:58 -0800 (PST) Received: from xeon-e3.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id f8sm7014701pfj.49.2016.03.04.10.07.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Mar 2016 10:07:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Date: Fri, 4 Mar 2016 10:08:02 -0800 Message-Id: <1457114882-22125-4-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457114882-22125-1-git-send-email-stephen@networkplumber.org> References: <1457114882-22125-1-git-send-email-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 3/3] vmxnet3: support setting 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: Fri, 04 Mar 2016 18:07:59 -0000 Allow overriding the base mac address of the device. Signed-off-by: Stephen Hemminger --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 44 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 111ec8e..d863a30 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -89,6 +89,8 @@ static void vmxnet3_dev_info_get(struct rte_eth_dev *dev, static int vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vid, int on); static void vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask); +static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev, + struct ether_addr *mac_addr); #if PROCESS_SYS_EVENTS == 1 static void vmxnet3_process_events(struct vmxnet3_hw *); @@ -115,6 +117,7 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops = { .allmulticast_disable = vmxnet3_dev_allmulticast_disable, .link_update = vmxnet3_dev_link_update, .stats_get = vmxnet3_dev_stats_get, + .mac_addr_set = vmxnet3_mac_addr_set, .dev_infos_get = vmxnet3_dev_info_get, .vlan_filter_set = vmxnet3_dev_vlan_filter_set, .vlan_offload_set = vmxnet3_dev_vlan_offload_set, @@ -421,6 +424,23 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev) return 0; } +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 = *(const uint32_t *)addr; + VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, val); + + val = (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) { @@ -429,8 +449,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) uint32_t mtu = dev->data->mtu; Vmxnet3_DriverShared *shared = hw->shared; Vmxnet3_DSDevRead *devRead = &shared->devRead; - uint32_t *mac_ptr; - uint32_t val, i; + uint32_t i; int ret; shared->magic = VMXNET3_REV1_MAGIC; @@ -516,18 +535,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) vmxnet3_dev_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK); - 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 = (uint32_t *)hw->perm_addr; - val = *mac_ptr; - VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, val); - - val = (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); return VMXNET3_SUCCESS; } @@ -714,6 +722,14 @@ vmxnet3_dev_info_get(__attribute__((unused))struct rte_eth_dev *dev, struct rte_ }; } +static void +vmxnet3_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) +{ + struct vmxnet3_hw *hw = 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)) int wait_to_complete) -- 2.1.4