Date: Fri, 11 Nov 2016 15:48:22 +0100 From: Hans Petter Selasky <hps@selasky.org> To: John.Kitz@xs4all.nl, freebsd-arm@freebsd.org Subject: Re: How to change MAC address on RPI-B? Message-ID: <445c56a4-2c35-cb4c-f729-950d4e758d8d@selasky.org> In-Reply-To: <000f01d23c14$da3a6c00$8eaf4400$@Kitz@xs4all.nl> References: <005701d23a7d$71400630$53c01290$@Kitz@xs4all.nl> <20161110065105.77a19e3b@X220.alogt.com> <000c01d23b3a$c06e1ef0$414a5cd0$@Kitz@xs4all.nl> <20161111094930.46f55a60@X220.alogt.com> <000f01d23c14$da3a6c00$8eaf4400$@Kitz@xs4all.nl>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Hi,
Does the attached patch solve the problem?
--HPS
[-- Attachment #2 --]
Index: sys/dev/usb/net/if_smsc.c
===================================================================
--- sys/dev/usb/net/if_smsc.c (revision 308426)
+++ sys/dev/usb/net/if_smsc.c (working copy)
@@ -152,7 +152,7 @@
device_printf((sc)->sc_ue.ue_dev, "debug: " fmt, ##args); \
} while(0)
#else
-#define smsc_dbg_printf(sc, fmt, args...)
+#define smsc_dbg_printf(sc, fmt, args...) do { } while (0)
#endif
#define smsc_warn_printf(sc, fmt, args...) \
@@ -187,6 +187,7 @@
static uether_fn_t smsc_stop;
static uether_fn_t smsc_start;
static uether_fn_t smsc_tick;
+static uether_fn_t smsc_setmac;
static uether_fn_t smsc_setmulti;
static uether_fn_t smsc_setpromisc;
@@ -234,6 +235,7 @@
.ue_init = smsc_init,
.ue_stop = smsc_stop,
.ue_tick = smsc_tick,
+ .ue_setmac = smsc_setmac,
.ue_setmulti = smsc_setmulti,
.ue_setpromisc = smsc_setpromisc,
.ue_mii_upd = smsc_ifmedia_upd,
@@ -822,7 +824,6 @@
return (0);
}
-
/**
* smsc_setmacaddress - Sets the mac address in the device
* @sc: driver soft context
@@ -860,6 +861,25 @@
}
/**
+ * smsc_setmac - Setup new MAC address
+ * @ue: usb ethernet device context
+ *
+ * LOCKING:
+ * Should be called with the SMSC lock held.
+ */
+static void
+smsc_setmac(struct usb_ether *ue)
+{
+ struct smsc_softc *sc = uether_getsc(ue);
+ struct ifnet *ifp = uether_getifp(ue);
+
+ SMSC_LOCK_ASSERT(sc, MA_OWNED);
+
+ if (smsc_setmacaddress(sc, IF_LLADDR(ifp)))
+ smsc_dbg_printf(sc, "setting MAC address failed\n");
+}
+
+/**
* smsc_reset - Reset the SMSC chip
* @sc: device soft context
*
Index: sys/dev/usb/net/usb_ethernet.c
===================================================================
--- sys/dev/usb/net/usb_ethernet.c (revision 308426)
+++ sys/dev/usb/net/usb_ethernet.c (working copy)
@@ -72,6 +72,7 @@
static usb_proc_callback_t ue_attach_post_task;
static usb_proc_callback_t ue_promisc_task;
+static usb_proc_callback_t ue_setmac_task;
static usb_proc_callback_t ue_setmulti_task;
static usb_proc_callback_t ue_ifmedia_task;
static usb_proc_callback_t ue_tick_task;
@@ -410,7 +411,8 @@
(struct usb_ether_cfg_task *)_task;
struct usb_ether *ue = task->ue;
- ue->ue_methods->ue_setpromisc(ue);
+ if (ue->ue_methods->ue_setpromisc != NULL)
+ ue->ue_methods->ue_setpromisc(ue);
}
static void
@@ -420,9 +422,21 @@
(struct usb_ether_cfg_task *)_task;
struct usb_ether *ue = task->ue;
- ue->ue_methods->ue_setmulti(ue);
+ if (ue->ue_methods->ue_setmulti != NULL)
+ ue->ue_methods->ue_setmulti(ue);
}
+static void
+ue_setmac_task(struct usb_proc_msg *_task)
+{
+ struct usb_ether_cfg_task *task =
+ (struct usb_ether_cfg_task *)_task;
+ struct usb_ether *ue = task->ue;
+
+ if (ue->ue_methods->ue_setmac != NULL)
+ ue->ue_methods->ue_setmac(ue);
+}
+
int
uether_ifmedia_upd(struct ifnet *ifp)
{
@@ -529,6 +543,16 @@
} else
error = ether_ioctl(ifp, command, data);
break;
+ case SIOCGIFADDR:
+ error = ether_ioctl(ifp, command, data);
+ if (error == 0) {
+ UE_LOCK(ue);
+ ue_queue_command(ue, ue_setmac_task,
+ &ue->ue_mac_task[0].hdr,
+ &ue->ue_mac_task[1].hdr);
+ UE_UNLOCK(ue);
+ }
+ break;
default:
error = ether_ioctl(ifp, command, data);
break;
Index: sys/dev/usb/net/usb_ethernet.h
===================================================================
--- sys/dev/usb/net/usb_ethernet.h (revision 308426)
+++ sys/dev/usb/net/usb_ethernet.h (working copy)
@@ -61,6 +61,7 @@
uether_fn_t *ue_start;
uether_fn_t *ue_init;
uether_fn_t *ue_stop;
+ uether_fn_t *ue_setmac;
uether_fn_t *ue_setmulti;
uether_fn_t *ue_setpromisc;
uether_fn_t *ue_tick;
@@ -96,6 +97,7 @@
struct usb_ether_cfg_task ue_multi_task[2];
struct usb_ether_cfg_task ue_promisc_task[2];
struct usb_ether_cfg_task ue_tick_task[2];
+ struct usb_ether_cfg_task ue_mac_task[2];
int ue_unit;
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?445c56a4-2c35-cb4c-f729-950d4e758d8d>
