From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/3] vmxnet3: support setting mac address
Date: Fri, 4 Mar 2016 10:08:02 -0800 [thread overview]
Message-ID: <1457114882-22125-4-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1457114882-22125-1-git-send-email-stephen@networkplumber.org>
Allow overriding the base mac address of the device.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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
next prev parent reply other threads:[~2016-03-04 18:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 18:07 [dpdk-dev] [PATCH 0/3 v3] vmxnet3 driver patches Stephen Hemminger
2016-03-04 18:08 ` [dpdk-dev] [PATCH 1/3] vmxnet3: support jumbo frames Stephen Hemminger
2016-03-04 18:08 ` [dpdk-dev] [PATCH 2/3] vmxnet3: Fix VLAN filtering Stephen Hemminger
2016-03-04 18:08 ` Stephen Hemminger [this message]
2016-03-07 17:06 ` [dpdk-dev] [PATCH 0/3 v3] vmxnet3 driver patches Remy Horton
2016-03-11 16:25 ` Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457114882-22125-4-git-send-email-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).