* [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy
@ 2019-04-04 18:46 Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 1/2] r8152: remove extra action copying ethernet address Mario Limonciello
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mario Limonciello @ 2019-04-04 18:46 UTC (permalink / raw)
To: linux-usb
Cc: davem, netdev, linux-kernel, hayeswang, sjg, campello, Ryan Hong,
Crag Wang, Mario Limonciello
On some platforms ACPI method `\\_SB.AMAC` is dynamic and changes to it can
influence changing the behavior of MAC pass through and what MAC address is used.
When running USB reset, re-read the MAC address to use to support tools that
change the policy.
This is quite similar to using `SIOCSIFHWADDR` except that the actual MAC to use
comes from ASL rather than from userspace.
Changes from v1:
* Remove an extra unneeded `ether_addr_copy` call
* Use `dev_set_mac_address` to ensure all notifiers are called
* Shuffle functions to allow code re-use.
Mario Limonciello (2):
r8152: remove extra action copying ethernet address
r8152: Refresh MAC address during USBDEVFS_RESET
drivers/net/usb/r8152.c | 51 +++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 16 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] r8152: remove extra action copying ethernet address
2019-04-04 18:46 [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy Mario Limonciello
@ 2019-04-04 18:46 ` Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 2/2] r8152: Refresh MAC address during USBDEVFS_RESET Mario Limonciello
2019-04-07 1:22 ` [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2019-04-04 18:46 UTC (permalink / raw)
To: linux-usb
Cc: davem, netdev, linux-kernel, hayeswang, sjg, campello, Ryan Hong,
Crag Wang, Mario Limonciello
This already happens later on in `rtl8152_set_mac_address`
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
drivers/net/usb/r8152.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 86c8c64..dc1bfff 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1212,7 +1212,6 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
goto amacout;
}
memcpy(sa->sa_data, buf, 6);
- ether_addr_copy(tp->netdev->dev_addr, sa->sa_data);
netif_info(tp, probe, tp->netdev,
"Using pass-thru MAC addr %pM\n", sa->sa_data);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] r8152: Refresh MAC address during USBDEVFS_RESET
2019-04-04 18:46 [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 1/2] r8152: remove extra action copying ethernet address Mario Limonciello
@ 2019-04-04 18:46 ` Mario Limonciello
2019-04-07 1:22 ` [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2019-04-04 18:46 UTC (permalink / raw)
To: linux-usb
Cc: davem, netdev, linux-kernel, hayeswang, sjg, campello, Ryan Hong,
Crag Wang, Mario Limonciello
On some platforms it is possible to dynamically change the policy
of what MAC address is selected from the ASL at runtime.
These tools will reset the USB device and expect the change to be
made immediately.
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
drivers/net/usb/r8152.c | 50 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index dc1bfff..6d63dcb 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1220,43 +1220,55 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
return ret;
}
-static int set_ethernet_addr(struct r8152 *tp)
+static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
{
struct net_device *dev = tp->netdev;
- struct sockaddr sa;
int ret;
if (tp->version == RTL_VER_01) {
- ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
} else {
/* if device doesn't support MAC pass through this will
* be expected to be non-zero
*/
- ret = vendor_mac_passthru_addr_read(tp, &sa);
+ ret = vendor_mac_passthru_addr_read(tp, sa);
if (ret < 0)
- ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data);
+ ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa->sa_data);
}
if (ret < 0) {
netif_err(tp, probe, dev, "Get ether addr fail\n");
- } else if (!is_valid_ether_addr(sa.sa_data)) {
+ } else if (!is_valid_ether_addr(sa->sa_data)) {
netif_err(tp, probe, dev, "Invalid ether addr %pM\n",
- sa.sa_data);
+ sa->sa_data);
eth_hw_addr_random(dev);
- ether_addr_copy(sa.sa_data, dev->dev_addr);
- ret = rtl8152_set_mac_address(dev, &sa);
+ ether_addr_copy(sa->sa_data, dev->dev_addr);
netif_info(tp, probe, dev, "Random ether addr %pM\n",
- sa.sa_data);
- } else {
- if (tp->version == RTL_VER_01)
- ether_addr_copy(dev->dev_addr, sa.sa_data);
- else
- ret = rtl8152_set_mac_address(dev, &sa);
+ sa->sa_data);
+ return 0;
}
return ret;
}
+static int set_ethernet_addr(struct r8152 *tp)
+{
+ struct net_device *dev = tp->netdev;
+ struct sockaddr sa;
+ int ret;
+
+ ret = determine_ethernet_addr(tp, &sa);
+ if (ret < 0)
+ return ret;
+
+ if (tp->version == RTL_VER_01)
+ ether_addr_copy(dev->dev_addr, sa.sa_data);
+ else
+ ret = rtl8152_set_mac_address(dev, &sa);
+
+ return ret;
+}
+
static void read_bulk_callback(struct urb *urb)
{
struct net_device *netdev;
@@ -4263,10 +4275,18 @@ static int rtl8152_post_reset(struct usb_interface *intf)
{
struct r8152 *tp = usb_get_intfdata(intf);
struct net_device *netdev;
+ struct sockaddr sa;
if (!tp)
return 0;
+ /* reset the MAC adddress in case of policy change */
+ if (determine_ethernet_addr(tp, &sa) >= 0) {
+ rtnl_lock();
+ dev_set_mac_address (tp->netdev, &sa, NULL);
+ rtnl_unlock();
+ }
+
netdev = tp->netdev;
if (!netif_running(netdev))
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy
2019-04-04 18:46 [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 1/2] r8152: remove extra action copying ethernet address Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 2/2] r8152: Refresh MAC address during USBDEVFS_RESET Mario Limonciello
@ 2019-04-07 1:22 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-07 1:22 UTC (permalink / raw)
To: mario.limonciello
Cc: linux-usb, netdev, linux-kernel, hayeswang, sjg, campello,
Ryan.Hong, Crag.Wang
From: Mario Limonciello <mario.limonciello@dell.com>
Date: Thu, 4 Apr 2019 13:46:51 -0500
> On some platforms ACPI method `\\_SB.AMAC` is dynamic and changes to it can
> influence changing the behavior of MAC pass through and what MAC address is used.
>
> When running USB reset, re-read the MAC address to use to support tools that
> change the policy.
>
> This is quite similar to using `SIOCSIFHWADDR` except that the actual MAC to use
> comes from ASL rather than from userspace.
>
> Changes from v1:
> * Remove an extra unneeded `ether_addr_copy` call
> * Use `dev_set_mac_address` to ensure all notifiers are called
> * Shuffle functions to allow code re-use.
Series applied to net-next.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-07 1:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04 18:46 [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 1/2] r8152: remove extra action copying ethernet address Mario Limonciello
2019-04-04 18:46 ` [PATCH v2 2/2] r8152: Refresh MAC address during USBDEVFS_RESET Mario Limonciello
2019-04-07 1:22 ` [PATCH v2 0/2] Support runtime changes of vendor mac passthu policy 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).