11
11
#include <linux/netdevice.h>
12
12
#include <linux/mii.h>
13
13
#include <linux/usb.h>
14
+ #include <linux/if_vlan.h>
14
15
#include <linux/usb/cdc.h>
15
16
#include <linux/usb/usbnet.h>
16
17
@@ -204,11 +205,43 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
204
205
aqc111_write32_cmd (dev , AQ_PHY_OPS , 0 , 0 , & aqc111_data -> phy_cfg );
205
206
}
206
207
208
+ static int aqc111_set_mac_addr (struct net_device * net , void * p )
209
+ {
210
+ struct usbnet * dev = netdev_priv (net );
211
+ int ret = 0 ;
212
+
213
+ ret = eth_mac_addr (net , p );
214
+ if (ret < 0 )
215
+ return ret ;
216
+
217
+ /* Set the MAC address */
218
+ return aqc111_write_cmd (dev , AQ_ACCESS_MAC , SFR_NODE_ID , ETH_ALEN ,
219
+ ETH_ALEN , net -> dev_addr );
220
+ }
221
+
207
222
static const struct net_device_ops aqc111_netdev_ops = {
208
223
.ndo_open = usbnet_open ,
209
224
.ndo_stop = usbnet_stop ,
225
+ .ndo_set_mac_address = aqc111_set_mac_addr ,
226
+ .ndo_validate_addr = eth_validate_addr ,
210
227
};
211
228
229
+ static int aqc111_read_perm_mac (struct usbnet * dev )
230
+ {
231
+ u8 buf [ETH_ALEN ];
232
+ int ret ;
233
+
234
+ ret = aqc111_read_cmd (dev , AQ_FLASH_PARAMETERS , 0 , 0 , ETH_ALEN , buf );
235
+ if (ret < 0 )
236
+ goto out ;
237
+
238
+ ether_addr_copy (dev -> net -> perm_addr , buf );
239
+
240
+ return 0 ;
241
+ out :
242
+ return ret ;
243
+ }
244
+
212
245
static void aqc111_read_fw_version (struct usbnet * dev ,
213
246
struct aqc111_data * aqc111_data )
214
247
{
@@ -251,6 +284,12 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
251
284
/* store aqc111_data pointer in device data field */
252
285
dev -> driver_priv = aqc111_data ;
253
286
287
+ /* Init the MAC address */
288
+ ret = aqc111_read_perm_mac (dev );
289
+ if (ret )
290
+ goto out ;
291
+
292
+ ether_addr_copy (dev -> net -> dev_addr , dev -> net -> perm_addr );
254
293
dev -> net -> netdev_ops = & aqc111_netdev_ops ;
255
294
256
295
aqc111_read_fw_version (dev , aqc111_data );
@@ -259,6 +298,10 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
259
298
SPEED_5000 : SPEED_1000 ;
260
299
261
300
return 0 ;
301
+
302
+ out :
303
+ kfree (aqc111_data );
304
+ return ret ;
262
305
}
263
306
264
307
static void aqc111_unbind (struct usbnet * dev , struct usb_interface * intf )
@@ -467,6 +510,10 @@ static int aqc111_reset(struct usbnet *dev)
467
510
aqc111_write32_cmd (dev , AQ_PHY_OPS , 0 , 0 ,
468
511
& aqc111_data -> phy_cfg );
469
512
513
+ /* Set the MAC address */
514
+ aqc111_write_cmd (dev , AQ_ACCESS_MAC , SFR_NODE_ID , ETH_ALEN ,
515
+ ETH_ALEN , dev -> net -> dev_addr );
516
+
470
517
reg8 = 0xFF ;
471
518
aqc111_write_cmd (dev , AQ_ACCESS_MAC , SFR_BM_INT_MASK , 1 , 1 , & reg8 );
472
519
0 commit comments