* [PATCH] ibmveth: Add function to enable live MAC address changes
@ 2015-02-26 0:34 Thomas Falcon
2015-02-26 13:08 ` Brian King
2015-02-27 22:22 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Falcon @ 2015-02-26 0:34 UTC (permalink / raw)
To: netdev; +Cc: linuxppc-dev
Add a function that will enable changing the MAC address
of an ibmveth interface while it is still running.
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 21978cc..6e44357 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
return ret;
}
+static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
+{
+ struct ibmveth_adapter *adapter = netdev_priv(dev);
+ struct sockaddr *addr = p;
+ u64 mac_address;
+ int rc;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
+ ether_addr_copy(dev->dev_addr, addr->sa_data);
+
+ mac_address = ibmveth_encode_mac_addr(dev->dev_addr);
+ rc = h_change_logical_lan_mac(adapter->vdev->unit_address, mac_address);
+
+ return rc;
+}
+
static const struct net_device_ops ibmveth_netdev_ops = {
.ndo_open = ibmveth_open,
.ndo_stop = ibmveth_close,
@@ -1337,7 +1355,7 @@ static const struct net_device_ops ibmveth_netdev_ops = {
.ndo_fix_features = ibmveth_fix_features,
.ndo_set_features = ibmveth_set_features,
.ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = eth_mac_addr,
+ .ndo_set_mac_address = ibmveth_set_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = ibmveth_poll_controller,
#endif
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ibmveth: Add function to enable live MAC address changes
2015-02-26 0:34 [PATCH] ibmveth: Add function to enable live MAC address changes Thomas Falcon
@ 2015-02-26 13:08 ` Brian King
2015-02-26 15:55 ` Jiri Pirko
2015-02-27 22:22 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Brian King @ 2015-02-26 13:08 UTC (permalink / raw)
To: Thomas Falcon, netdev; +Cc: linuxppc-dev
On 02/25/2015 06:34 PM, Thomas Falcon wrote:
> @@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
> return ret;
> }
>
> +static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
> +{
> + struct ibmveth_adapter *adapter = netdev_priv(dev);
> + struct sockaddr *addr = p;
> + u64 mac_address;
> + int rc;
> +
> + if (!is_valid_ether_addr(addr->sa_data))
> + return -EADDRNOTAVAIL;
> +
> + ether_addr_copy(dev->dev_addr, addr->sa_data);
> +
> + mac_address = ibmveth_encode_mac_addr(dev->dev_addr);
> + rc = h_change_logical_lan_mac(adapter->vdev->unit_address, mac_address);
> +
> + return rc;
Do you still want to be changing dev->dev_addr if h_change_logical_lan_mac
returns a failure?
-Brian
--
Brian King
Power Linux I/O
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ibmveth: Add function to enable live MAC address changes
2015-02-26 13:08 ` Brian King
@ 2015-02-26 15:55 ` Jiri Pirko
0 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2015-02-26 15:55 UTC (permalink / raw)
To: Brian King; +Cc: netdev, Thomas Falcon, linuxppc-dev
Thu, Feb 26, 2015 at 02:08:06PM CET, brking@linux.vnet.ibm.com wrote:
>On 02/25/2015 06:34 PM, Thomas Falcon wrote:
>> @@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
>> return ret;
>> }
>>
>> +static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
>> +{
>> + struct ibmveth_adapter *adapter = netdev_priv(dev);
>> + struct sockaddr *addr = p;
>> + u64 mac_address;
>> + int rc;
>> +
>> + if (!is_valid_ether_addr(addr->sa_data))
>> + return -EADDRNOTAVAIL;
>> +
>> + ether_addr_copy(dev->dev_addr, addr->sa_data);
>> +
>> + mac_address = ibmveth_encode_mac_addr(dev->dev_addr);
>> + rc = h_change_logical_lan_mac(adapter->vdev->unit_address, mac_address);
>> +
>> + return rc;
>
>Do you still want to be changing dev->dev_addr if h_change_logical_lan_mac
>returns a failure?
That should not be done. dev_addr should be in sync with real hw addr.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ibmveth: Add function to enable live MAC address changes
2015-02-26 0:34 [PATCH] ibmveth: Add function to enable live MAC address changes Thomas Falcon
2015-02-26 13:08 ` Brian King
@ 2015-02-27 22:22 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-27 22:22 UTC (permalink / raw)
To: tlfalcon; +Cc: netdev, linuxppc-dev
From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Wed, 25 Feb 2015 18:34:24 -0600
> Add a function that will enable changing the MAC address
> of an ibmveth interface while it is still running.
>
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
> ---
> drivers/net/ethernet/ibm/ibmveth.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index 21978cc..6e44357 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
> return ret;
> }
>
> +static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
> +{
> + struct ibmveth_adapter *adapter = netdev_priv(dev);
> + struct sockaddr *addr = p;
> + u64 mac_address;
> + int rc;
> +
> + if (!is_valid_ether_addr(addr->sa_data))
> + return -EADDRNOTAVAIL;
> +
> + ether_addr_copy(dev->dev_addr, addr->sa_data);
> +
> + mac_address = ibmveth_encode_mac_addr(dev->dev_addr);
> + rc = h_change_logical_lan_mac(adapter->vdev->unit_address, mac_address);
As others have said, if this hypervisor call fails you must not change
dev->dev_addr. It must always be in sync with "the hardware."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-27 22:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-26 0:34 [PATCH] ibmveth: Add function to enable live MAC address changes Thomas Falcon
2015-02-26 13:08 ` Brian King
2015-02-26 15:55 ` Jiri Pirko
2015-02-27 22:22 ` David Miller
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).