diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/usb/asix.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/usb/asix.c')
-rw-r--r-- | drivers/net/usb/asix.c | 168 |
1 files changed, 100 insertions, 68 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 6ce7f775bb74..35f56fc82803 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include <linux/crc32.h> | 35 | #include <linux/crc32.h> |
36 | #include <linux/usb/usbnet.h> | 36 | #include <linux/usb/usbnet.h> |
37 | #include <linux/slab.h> | ||
37 | 38 | ||
38 | #define DRIVER_VERSION "14-Jun-2006" | 39 | #define DRIVER_VERSION "14-Jun-2006" |
39 | static const char driver_name [] = "asix"; | 40 | static const char driver_name [] = "asix"; |
@@ -54,6 +55,7 @@ static const char driver_name [] = "asix"; | |||
54 | #define AX_CMD_WRITE_IPG0 0x12 | 55 | #define AX_CMD_WRITE_IPG0 0x12 |
55 | #define AX_CMD_WRITE_IPG1 0x13 | 56 | #define AX_CMD_WRITE_IPG1 0x13 |
56 | #define AX_CMD_READ_NODE_ID 0x13 | 57 | #define AX_CMD_READ_NODE_ID 0x13 |
58 | #define AX_CMD_WRITE_NODE_ID 0x14 | ||
57 | #define AX_CMD_WRITE_IPG2 0x14 | 59 | #define AX_CMD_WRITE_IPG2 0x14 |
58 | #define AX_CMD_WRITE_MULTI_FILTER 0x16 | 60 | #define AX_CMD_WRITE_MULTI_FILTER 0x16 |
59 | #define AX88172_CMD_READ_NODE_ID 0x17 | 61 | #define AX88172_CMD_READ_NODE_ID 0x17 |
@@ -165,6 +167,7 @@ static const char driver_name [] = "asix"; | |||
165 | /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ | 167 | /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ |
166 | struct asix_data { | 168 | struct asix_data { |
167 | u8 multi_filter[AX_MCAST_FILTER_SIZE]; | 169 | u8 multi_filter[AX_MCAST_FILTER_SIZE]; |
170 | u8 mac_addr[ETH_ALEN]; | ||
168 | u8 phymode; | 171 | u8 phymode; |
169 | u8 ledmode; | 172 | u8 ledmode; |
170 | u8 eeprom_len; | 173 | u8 eeprom_len; |
@@ -184,8 +187,8 @@ static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, | |||
184 | void *buf; | 187 | void *buf; |
185 | int err = -ENOMEM; | 188 | int err = -ENOMEM; |
186 | 189 | ||
187 | devdbg(dev,"asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d", | 190 | netdev_dbg(dev->net, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n", |
188 | cmd, value, index, size); | 191 | cmd, value, index, size); |
189 | 192 | ||
190 | buf = kmalloc(size, GFP_KERNEL); | 193 | buf = kmalloc(size, GFP_KERNEL); |
191 | if (!buf) | 194 | if (!buf) |
@@ -217,8 +220,8 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, | |||
217 | void *buf = NULL; | 220 | void *buf = NULL; |
218 | int err = -ENOMEM; | 221 | int err = -ENOMEM; |
219 | 222 | ||
220 | devdbg(dev,"asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d", | 223 | netdev_dbg(dev->net, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n", |
221 | cmd, value, index, size); | 224 | cmd, value, index, size); |
222 | 225 | ||
223 | if (data) { | 226 | if (data) { |
224 | buf = kmalloc(size, GFP_KERNEL); | 227 | buf = kmalloc(size, GFP_KERNEL); |
@@ -264,15 +267,15 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, | |||
264 | int status; | 267 | int status; |
265 | struct urb *urb; | 268 | struct urb *urb; |
266 | 269 | ||
267 | devdbg(dev,"asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d", | 270 | netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n", |
268 | cmd, value, index, size); | 271 | cmd, value, index, size); |
269 | if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { | 272 | if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { |
270 | deverr(dev, "Error allocating URB in write_cmd_async!"); | 273 | netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n"); |
271 | return; | 274 | return; |
272 | } | 275 | } |
273 | 276 | ||
274 | if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { | 277 | if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { |
275 | deverr(dev, "Failed to allocate memory for control request"); | 278 | netdev_err(dev->net, "Failed to allocate memory for control request\n"); |
276 | usb_free_urb(urb); | 279 | usb_free_urb(urb); |
277 | return; | 280 | return; |
278 | } | 281 | } |
@@ -289,8 +292,8 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, | |||
289 | asix_async_cmd_callback, req); | 292 | asix_async_cmd_callback, req); |
290 | 293 | ||
291 | if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { | 294 | if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { |
292 | deverr(dev, "Error submitting the control message: status=%d", | 295 | netdev_err(dev->net, "Error submitting the control message: status=%d\n", |
293 | status); | 296 | status); |
294 | kfree(req); | 297 | kfree(req); |
295 | usb_free_urb(urb); | 298 | usb_free_urb(urb); |
296 | } | 299 | } |
@@ -314,7 +317,7 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
314 | while (skb->len > 0) { | 317 | while (skb->len > 0) { |
315 | if ((short)(header & 0x0000ffff) != | 318 | if ((short)(header & 0x0000ffff) != |
316 | ~((short)((header & 0xffff0000) >> 16))) { | 319 | ~((short)((header & 0xffff0000) >> 16))) { |
317 | deverr(dev,"asix_rx_fixup() Bad Header Length"); | 320 | netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n"); |
318 | } | 321 | } |
319 | /* get the packet length */ | 322 | /* get the packet length */ |
320 | size = (u16) (header & 0x0000ffff); | 323 | size = (u16) (header & 0x0000ffff); |
@@ -322,7 +325,8 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
322 | if ((skb->len) - ((size + 1) & 0xfffe) == 0) | 325 | if ((skb->len) - ((size + 1) & 0xfffe) == 0) |
323 | return 2; | 326 | return 2; |
324 | if (size > ETH_FRAME_LEN) { | 327 | if (size > ETH_FRAME_LEN) { |
325 | deverr(dev,"asix_rx_fixup() Bad RX Length %d", size); | 328 | netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", |
329 | size); | ||
326 | return 0; | 330 | return 0; |
327 | } | 331 | } |
328 | ax_skb = skb_clone(skb, GFP_ATOMIC); | 332 | ax_skb = skb_clone(skb, GFP_ATOMIC); |
@@ -348,7 +352,8 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
348 | } | 352 | } |
349 | 353 | ||
350 | if (skb->len < 0) { | 354 | if (skb->len < 0) { |
351 | deverr(dev,"asix_rx_fixup() Bad SKB Length %d", skb->len); | 355 | netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d\n", |
356 | skb->len); | ||
352 | return 0; | 357 | return 0; |
353 | } | 358 | } |
354 | return 1; | 359 | return 1; |
@@ -365,8 +370,8 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
365 | 370 | ||
366 | padlen = ((skb->len + 4) % 512) ? 0 : 4; | 371 | padlen = ((skb->len + 4) % 512) ? 0 : 4; |
367 | 372 | ||
368 | if ((!skb_cloned(skb)) | 373 | if ((!skb_cloned(skb)) && |
369 | && ((headroom + tailroom) >= (4 + padlen))) { | 374 | ((headroom + tailroom) >= (4 + padlen))) { |
370 | if ((headroom < 4) || (tailroom < padlen)) { | 375 | if ((headroom < 4) || (tailroom < padlen)) { |
371 | skb->data = memmove(skb->head + 4, skb->data, skb->len); | 376 | skb->data = memmove(skb->head + 4, skb->data, skb->len); |
372 | skb_set_tail_pointer(skb, skb->len); | 377 | skb_set_tail_pointer(skb, skb->len); |
@@ -409,7 +414,7 @@ static void asix_status(struct usbnet *dev, struct urb *urb) | |||
409 | usbnet_defer_kevent (dev, EVENT_LINK_RESET ); | 414 | usbnet_defer_kevent (dev, EVENT_LINK_RESET ); |
410 | } else | 415 | } else |
411 | netif_carrier_off(dev->net); | 416 | netif_carrier_off(dev->net); |
412 | devdbg(dev, "Link Status is: %d", link); | 417 | netdev_dbg(dev->net, "Link Status is: %d\n", link); |
413 | } | 418 | } |
414 | } | 419 | } |
415 | 420 | ||
@@ -418,7 +423,7 @@ static inline int asix_set_sw_mii(struct usbnet *dev) | |||
418 | int ret; | 423 | int ret; |
419 | ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); | 424 | ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); |
420 | if (ret < 0) | 425 | if (ret < 0) |
421 | deverr(dev, "Failed to enable software MII access"); | 426 | netdev_err(dev->net, "Failed to enable software MII access\n"); |
422 | return ret; | 427 | return ret; |
423 | } | 428 | } |
424 | 429 | ||
@@ -427,7 +432,7 @@ static inline int asix_set_hw_mii(struct usbnet *dev) | |||
427 | int ret; | 432 | int ret; |
428 | ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); | 433 | ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); |
429 | if (ret < 0) | 434 | if (ret < 0) |
430 | deverr(dev, "Failed to enable hardware MII access"); | 435 | netdev_err(dev->net, "Failed to enable hardware MII access\n"); |
431 | return ret; | 436 | return ret; |
432 | } | 437 | } |
433 | 438 | ||
@@ -436,13 +441,14 @@ static inline int asix_get_phy_addr(struct usbnet *dev) | |||
436 | u8 buf[2]; | 441 | u8 buf[2]; |
437 | int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf); | 442 | int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf); |
438 | 443 | ||
439 | devdbg(dev, "asix_get_phy_addr()"); | 444 | netdev_dbg(dev->net, "asix_get_phy_addr()\n"); |
440 | 445 | ||
441 | if (ret < 0) { | 446 | if (ret < 0) { |
442 | deverr(dev, "Error reading PHYID register: %02x", ret); | 447 | netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret); |
443 | goto out; | 448 | goto out; |
444 | } | 449 | } |
445 | devdbg(dev, "asix_get_phy_addr() returning 0x%04x", *((__le16 *)buf)); | 450 | netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n", |
451 | *((__le16 *)buf)); | ||
446 | ret = buf[1]; | 452 | ret = buf[1]; |
447 | 453 | ||
448 | out: | 454 | out: |
@@ -455,7 +461,7 @@ static int asix_sw_reset(struct usbnet *dev, u8 flags) | |||
455 | 461 | ||
456 | ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); | 462 | ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); |
457 | if (ret < 0) | 463 | if (ret < 0) |
458 | deverr(dev,"Failed to send software reset: %02x", ret); | 464 | netdev_err(dev->net, "Failed to send software reset: %02x\n", ret); |
459 | 465 | ||
460 | return ret; | 466 | return ret; |
461 | } | 467 | } |
@@ -466,7 +472,7 @@ static u16 asix_read_rx_ctl(struct usbnet *dev) | |||
466 | int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v); | 472 | int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v); |
467 | 473 | ||
468 | if (ret < 0) { | 474 | if (ret < 0) { |
469 | deverr(dev, "Error reading RX_CTL register: %02x", ret); | 475 | netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret); |
470 | goto out; | 476 | goto out; |
471 | } | 477 | } |
472 | ret = le16_to_cpu(v); | 478 | ret = le16_to_cpu(v); |
@@ -478,11 +484,11 @@ static int asix_write_rx_ctl(struct usbnet *dev, u16 mode) | |||
478 | { | 484 | { |
479 | int ret; | 485 | int ret; |
480 | 486 | ||
481 | devdbg(dev,"asix_write_rx_ctl() - mode = 0x%04x", mode); | 487 | netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode); |
482 | ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); | 488 | ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); |
483 | if (ret < 0) | 489 | if (ret < 0) |
484 | deverr(dev, "Failed to write RX_CTL mode to 0x%04x: %02x", | 490 | netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n", |
485 | mode, ret); | 491 | mode, ret); |
486 | 492 | ||
487 | return ret; | 493 | return ret; |
488 | } | 494 | } |
@@ -493,7 +499,8 @@ static u16 asix_read_medium_status(struct usbnet *dev) | |||
493 | int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); | 499 | int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); |
494 | 500 | ||
495 | if (ret < 0) { | 501 | if (ret < 0) { |
496 | deverr(dev, "Error reading Medium Status register: %02x", ret); | 502 | netdev_err(dev->net, "Error reading Medium Status register: %02x\n", |
503 | ret); | ||
497 | goto out; | 504 | goto out; |
498 | } | 505 | } |
499 | ret = le16_to_cpu(v); | 506 | ret = le16_to_cpu(v); |
@@ -505,11 +512,11 @@ static int asix_write_medium_mode(struct usbnet *dev, u16 mode) | |||
505 | { | 512 | { |
506 | int ret; | 513 | int ret; |
507 | 514 | ||
508 | devdbg(dev,"asix_write_medium_mode() - mode = 0x%04x", mode); | 515 | netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode); |
509 | ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); | 516 | ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); |
510 | if (ret < 0) | 517 | if (ret < 0) |
511 | deverr(dev, "Failed to write Medium Mode mode to 0x%04x: %02x", | 518 | netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n", |
512 | mode, ret); | 519 | mode, ret); |
513 | 520 | ||
514 | return ret; | 521 | return ret; |
515 | } | 522 | } |
@@ -518,11 +525,11 @@ static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep) | |||
518 | { | 525 | { |
519 | int ret; | 526 | int ret; |
520 | 527 | ||
521 | devdbg(dev,"asix_write_gpio() - value = 0x%04x", value); | 528 | netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value); |
522 | ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL); | 529 | ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL); |
523 | if (ret < 0) | 530 | if (ret < 0) |
524 | deverr(dev, "Failed to write GPIO value 0x%04x: %02x", | 531 | netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n", |
525 | value, ret); | 532 | value, ret); |
526 | 533 | ||
527 | if (sleep) | 534 | if (sleep) |
528 | msleep(sleep); | 535 | msleep(sleep); |
@@ -541,30 +548,28 @@ static void asix_set_multicast(struct net_device *net) | |||
541 | 548 | ||
542 | if (net->flags & IFF_PROMISC) { | 549 | if (net->flags & IFF_PROMISC) { |
543 | rx_ctl |= AX_RX_CTL_PRO; | 550 | rx_ctl |= AX_RX_CTL_PRO; |
544 | } else if (net->flags & IFF_ALLMULTI | 551 | } else if (net->flags & IFF_ALLMULTI || |
545 | || net->mc_count > AX_MAX_MCAST) { | 552 | netdev_mc_count(net) > AX_MAX_MCAST) { |
546 | rx_ctl |= AX_RX_CTL_AMALL; | 553 | rx_ctl |= AX_RX_CTL_AMALL; |
547 | } else if (net->mc_count == 0) { | 554 | } else if (netdev_mc_empty(net)) { |
548 | /* just broadcast and directed */ | 555 | /* just broadcast and directed */ |
549 | } else { | 556 | } else { |
550 | /* We use the 20 byte dev->data | 557 | /* We use the 20 byte dev->data |
551 | * for our 8 byte filter buffer | 558 | * for our 8 byte filter buffer |
552 | * to avoid allocating memory that | 559 | * to avoid allocating memory that |
553 | * is tricky to free later */ | 560 | * is tricky to free later */ |
554 | struct dev_mc_list *mc_list = net->mc_list; | 561 | struct dev_mc_list *mc_list; |
555 | u32 crc_bits; | 562 | u32 crc_bits; |
556 | int i; | ||
557 | 563 | ||
558 | memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); | 564 | memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); |
559 | 565 | ||
560 | /* Build the multicast hash filter. */ | 566 | /* Build the multicast hash filter. */ |
561 | for (i = 0; i < net->mc_count; i++) { | 567 | netdev_for_each_mc_addr(mc_list, net) { |
562 | crc_bits = | 568 | crc_bits = |
563 | ether_crc(ETH_ALEN, | 569 | ether_crc(ETH_ALEN, |
564 | mc_list->dmi_addr) >> 26; | 570 | mc_list->dmi_addr) >> 26; |
565 | data->multi_filter[crc_bits >> 3] |= | 571 | data->multi_filter[crc_bits >> 3] |= |
566 | 1 << (crc_bits & 7); | 572 | 1 << (crc_bits & 7); |
567 | mc_list = mc_list->next; | ||
568 | } | 573 | } |
569 | 574 | ||
570 | asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, | 575 | asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, |
@@ -588,7 +593,8 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) | |||
588 | asix_set_hw_mii(dev); | 593 | asix_set_hw_mii(dev); |
589 | mutex_unlock(&dev->phy_mutex); | 594 | mutex_unlock(&dev->phy_mutex); |
590 | 595 | ||
591 | devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res)); | 596 | netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", |
597 | phy_id, loc, le16_to_cpu(res)); | ||
592 | 598 | ||
593 | return le16_to_cpu(res); | 599 | return le16_to_cpu(res); |
594 | } | 600 | } |
@@ -599,7 +605,8 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) | |||
599 | struct usbnet *dev = netdev_priv(netdev); | 605 | struct usbnet *dev = netdev_priv(netdev); |
600 | __le16 res = cpu_to_le16(val); | 606 | __le16 res = cpu_to_le16(val); |
601 | 607 | ||
602 | devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); | 608 | netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", |
609 | phy_id, loc, val); | ||
603 | mutex_lock(&dev->phy_mutex); | 610 | mutex_lock(&dev->phy_mutex); |
604 | asix_set_sw_mii(dev); | 611 | asix_set_sw_mii(dev); |
605 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); | 612 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); |
@@ -728,6 +735,30 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) | |||
728 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); | 735 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); |
729 | } | 736 | } |
730 | 737 | ||
738 | static int asix_set_mac_address(struct net_device *net, void *p) | ||
739 | { | ||
740 | struct usbnet *dev = netdev_priv(net); | ||
741 | struct asix_data *data = (struct asix_data *)&dev->data; | ||
742 | struct sockaddr *addr = p; | ||
743 | |||
744 | if (netif_running(net)) | ||
745 | return -EBUSY; | ||
746 | if (!is_valid_ether_addr(addr->sa_data)) | ||
747 | return -EADDRNOTAVAIL; | ||
748 | |||
749 | memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); | ||
750 | |||
751 | /* We use the 20 byte dev->data | ||
752 | * for our 6 byte mac buffer | ||
753 | * to avoid allocating memory that | ||
754 | * is tricky to free later */ | ||
755 | memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); | ||
756 | asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, | ||
757 | data->mac_addr); | ||
758 | |||
759 | return 0; | ||
760 | } | ||
761 | |||
731 | /* We need to override some ethtool_ops so we require our | 762 | /* We need to override some ethtool_ops so we require our |
732 | own structure so we don't interfere with other usbnet | 763 | own structure so we don't interfere with other usbnet |
733 | devices that may be connected at the same time. */ | 764 | devices that may be connected at the same time. */ |
@@ -753,30 +784,28 @@ static void ax88172_set_multicast(struct net_device *net) | |||
753 | 784 | ||
754 | if (net->flags & IFF_PROMISC) { | 785 | if (net->flags & IFF_PROMISC) { |
755 | rx_ctl |= 0x01; | 786 | rx_ctl |= 0x01; |
756 | } else if (net->flags & IFF_ALLMULTI | 787 | } else if (net->flags & IFF_ALLMULTI || |
757 | || net->mc_count > AX_MAX_MCAST) { | 788 | netdev_mc_count(net) > AX_MAX_MCAST) { |
758 | rx_ctl |= 0x02; | 789 | rx_ctl |= 0x02; |
759 | } else if (net->mc_count == 0) { | 790 | } else if (netdev_mc_empty(net)) { |
760 | /* just broadcast and directed */ | 791 | /* just broadcast and directed */ |
761 | } else { | 792 | } else { |
762 | /* We use the 20 byte dev->data | 793 | /* We use the 20 byte dev->data |
763 | * for our 8 byte filter buffer | 794 | * for our 8 byte filter buffer |
764 | * to avoid allocating memory that | 795 | * to avoid allocating memory that |
765 | * is tricky to free later */ | 796 | * is tricky to free later */ |
766 | struct dev_mc_list *mc_list = net->mc_list; | 797 | struct dev_mc_list *mc_list; |
767 | u32 crc_bits; | 798 | u32 crc_bits; |
768 | int i; | ||
769 | 799 | ||
770 | memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); | 800 | memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); |
771 | 801 | ||
772 | /* Build the multicast hash filter. */ | 802 | /* Build the multicast hash filter. */ |
773 | for (i = 0; i < net->mc_count; i++) { | 803 | netdev_for_each_mc_addr(mc_list, net) { |
774 | crc_bits = | 804 | crc_bits = |
775 | ether_crc(ETH_ALEN, | 805 | ether_crc(ETH_ALEN, |
776 | mc_list->dmi_addr) >> 26; | 806 | mc_list->dmi_addr) >> 26; |
777 | data->multi_filter[crc_bits >> 3] |= | 807 | data->multi_filter[crc_bits >> 3] |= |
778 | 1 << (crc_bits & 7); | 808 | 1 << (crc_bits & 7); |
779 | mc_list = mc_list->next; | ||
780 | } | 809 | } |
781 | 810 | ||
782 | asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, | 811 | asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, |
@@ -800,7 +829,8 @@ static int ax88172_link_reset(struct usbnet *dev) | |||
800 | if (ecmd.duplex != DUPLEX_FULL) | 829 | if (ecmd.duplex != DUPLEX_FULL) |
801 | mode |= ~AX88172_MEDIUM_FD; | 830 | mode |= ~AX88172_MEDIUM_FD; |
802 | 831 | ||
803 | devdbg(dev, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode); | 832 | netdev_dbg(dev->net, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", |
833 | ecmd.speed, ecmd.duplex, mode); | ||
804 | 834 | ||
805 | asix_write_medium_mode(dev, mode); | 835 | asix_write_medium_mode(dev, mode); |
806 | 836 | ||
@@ -902,7 +932,8 @@ static int ax88772_link_reset(struct usbnet *dev) | |||
902 | if (ecmd.duplex != DUPLEX_FULL) | 932 | if (ecmd.duplex != DUPLEX_FULL) |
903 | mode &= ~AX_MEDIUM_FD; | 933 | mode &= ~AX_MEDIUM_FD; |
904 | 934 | ||
905 | devdbg(dev, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode); | 935 | netdev_dbg(dev->net, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", |
936 | ecmd.speed, ecmd.duplex, mode); | ||
906 | 937 | ||
907 | asix_write_medium_mode(dev, mode); | 938 | asix_write_medium_mode(dev, mode); |
908 | 939 | ||
@@ -915,7 +946,7 @@ static const struct net_device_ops ax88772_netdev_ops = { | |||
915 | .ndo_start_xmit = usbnet_start_xmit, | 946 | .ndo_start_xmit = usbnet_start_xmit, |
916 | .ndo_tx_timeout = usbnet_tx_timeout, | 947 | .ndo_tx_timeout = usbnet_tx_timeout, |
917 | .ndo_change_mtu = usbnet_change_mtu, | 948 | .ndo_change_mtu = usbnet_change_mtu, |
918 | .ndo_set_mac_address = eth_mac_addr, | 949 | .ndo_set_mac_address = asix_set_mac_address, |
919 | .ndo_validate_addr = eth_validate_addr, | 950 | .ndo_validate_addr = eth_validate_addr, |
920 | .ndo_do_ioctl = asix_ioctl, | 951 | .ndo_do_ioctl = asix_ioctl, |
921 | .ndo_set_multicast_list = asix_set_multicast, | 952 | .ndo_set_multicast_list = asix_set_multicast, |
@@ -1059,10 +1090,10 @@ static int marvell_phy_init(struct usbnet *dev) | |||
1059 | struct asix_data *data = (struct asix_data *)&dev->data; | 1090 | struct asix_data *data = (struct asix_data *)&dev->data; |
1060 | u16 reg; | 1091 | u16 reg; |
1061 | 1092 | ||
1062 | devdbg(dev,"marvell_phy_init()"); | 1093 | netdev_dbg(dev->net, "marvell_phy_init()\n"); |
1063 | 1094 | ||
1064 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS); | 1095 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS); |
1065 | devdbg(dev,"MII_MARVELL_STATUS = 0x%04x", reg); | 1096 | netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg); |
1066 | 1097 | ||
1067 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL, | 1098 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL, |
1068 | MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY); | 1099 | MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY); |
@@ -1070,7 +1101,7 @@ static int marvell_phy_init(struct usbnet *dev) | |||
1070 | if (data->ledmode) { | 1101 | if (data->ledmode) { |
1071 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, | 1102 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, |
1072 | MII_MARVELL_LED_CTRL); | 1103 | MII_MARVELL_LED_CTRL); |
1073 | devdbg(dev,"MII_MARVELL_LED_CTRL (1) = 0x%04x", reg); | 1104 | netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg); |
1074 | 1105 | ||
1075 | reg &= 0xf8ff; | 1106 | reg &= 0xf8ff; |
1076 | reg |= (1 + 0x0100); | 1107 | reg |= (1 + 0x0100); |
@@ -1079,7 +1110,7 @@ static int marvell_phy_init(struct usbnet *dev) | |||
1079 | 1110 | ||
1080 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, | 1111 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, |
1081 | MII_MARVELL_LED_CTRL); | 1112 | MII_MARVELL_LED_CTRL); |
1082 | devdbg(dev,"MII_MARVELL_LED_CTRL (2) = 0x%04x", reg); | 1113 | netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg); |
1083 | reg &= 0xfc0f; | 1114 | reg &= 0xfc0f; |
1084 | } | 1115 | } |
1085 | 1116 | ||
@@ -1090,7 +1121,7 @@ static int marvell_led_status(struct usbnet *dev, u16 speed) | |||
1090 | { | 1121 | { |
1091 | u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL); | 1122 | u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL); |
1092 | 1123 | ||
1093 | devdbg(dev, "marvell_led_status() read 0x%04x", reg); | 1124 | netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg); |
1094 | 1125 | ||
1095 | /* Clear out the center LED bits - 0x03F0 */ | 1126 | /* Clear out the center LED bits - 0x03F0 */ |
1096 | reg &= 0xfc0f; | 1127 | reg &= 0xfc0f; |
@@ -1106,7 +1137,7 @@ static int marvell_led_status(struct usbnet *dev, u16 speed) | |||
1106 | reg |= 0x02f0; | 1137 | reg |= 0x02f0; |
1107 | } | 1138 | } |
1108 | 1139 | ||
1109 | devdbg(dev, "marvell_led_status() writing 0x%04x", reg); | 1140 | netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg); |
1110 | asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg); | 1141 | asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg); |
1111 | 1142 | ||
1112 | return 0; | 1143 | return 0; |
@@ -1118,7 +1149,7 @@ static int ax88178_link_reset(struct usbnet *dev) | |||
1118 | struct ethtool_cmd ecmd; | 1149 | struct ethtool_cmd ecmd; |
1119 | struct asix_data *data = (struct asix_data *)&dev->data; | 1150 | struct asix_data *data = (struct asix_data *)&dev->data; |
1120 | 1151 | ||
1121 | devdbg(dev,"ax88178_link_reset()"); | 1152 | netdev_dbg(dev->net, "ax88178_link_reset()\n"); |
1122 | 1153 | ||
1123 | mii_check_media(&dev->mii, 1, 1); | 1154 | mii_check_media(&dev->mii, 1, 1); |
1124 | mii_ethtool_gset(&dev->mii, &ecmd); | 1155 | mii_ethtool_gset(&dev->mii, &ecmd); |
@@ -1138,7 +1169,8 @@ static int ax88178_link_reset(struct usbnet *dev) | |||
1138 | else | 1169 | else |
1139 | mode &= ~AX_MEDIUM_FD; | 1170 | mode &= ~AX_MEDIUM_FD; |
1140 | 1171 | ||
1141 | devdbg(dev, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode); | 1172 | netdev_dbg(dev->net, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", |
1173 | ecmd.speed, ecmd.duplex, mode); | ||
1142 | 1174 | ||
1143 | asix_write_medium_mode(dev, mode); | 1175 | asix_write_medium_mode(dev, mode); |
1144 | 1176 | ||
@@ -1188,7 +1220,7 @@ static int ax88178_change_mtu(struct net_device *net, int new_mtu) | |||
1188 | struct usbnet *dev = netdev_priv(net); | 1220 | struct usbnet *dev = netdev_priv(net); |
1189 | int ll_mtu = new_mtu + net->hard_header_len + 4; | 1221 | int ll_mtu = new_mtu + net->hard_header_len + 4; |
1190 | 1222 | ||
1191 | devdbg(dev, "ax88178_change_mtu() new_mtu=%d", new_mtu); | 1223 | netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); |
1192 | 1224 | ||
1193 | if (new_mtu <= 0 || ll_mtu > 16384) | 1225 | if (new_mtu <= 0 || ll_mtu > 16384) |
1194 | return -EINVAL; | 1226 | return -EINVAL; |
@@ -1208,7 +1240,7 @@ static const struct net_device_ops ax88178_netdev_ops = { | |||
1208 | .ndo_stop = usbnet_stop, | 1240 | .ndo_stop = usbnet_stop, |
1209 | .ndo_start_xmit = usbnet_start_xmit, | 1241 | .ndo_start_xmit = usbnet_start_xmit, |
1210 | .ndo_tx_timeout = usbnet_tx_timeout, | 1242 | .ndo_tx_timeout = usbnet_tx_timeout, |
1211 | .ndo_set_mac_address = eth_mac_addr, | 1243 | .ndo_set_mac_address = asix_set_mac_address, |
1212 | .ndo_validate_addr = eth_validate_addr, | 1244 | .ndo_validate_addr = eth_validate_addr, |
1213 | .ndo_set_multicast_list = asix_set_multicast, | 1245 | .ndo_set_multicast_list = asix_set_multicast, |
1214 | .ndo_do_ioctl = asix_ioctl, | 1246 | .ndo_do_ioctl = asix_ioctl, |
@@ -1327,7 +1359,7 @@ static const struct driver_info ax8817x_info = { | |||
1327 | .status = asix_status, | 1359 | .status = asix_status, |
1328 | .link_reset = ax88172_link_reset, | 1360 | .link_reset = ax88172_link_reset, |
1329 | .reset = ax88172_link_reset, | 1361 | .reset = ax88172_link_reset, |
1330 | .flags = FLAG_ETHER, | 1362 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
1331 | .data = 0x00130103, | 1363 | .data = 0x00130103, |
1332 | }; | 1364 | }; |
1333 | 1365 | ||
@@ -1337,7 +1369,7 @@ static const struct driver_info dlink_dub_e100_info = { | |||
1337 | .status = asix_status, | 1369 | .status = asix_status, |
1338 | .link_reset = ax88172_link_reset, | 1370 | .link_reset = ax88172_link_reset, |
1339 | .reset = ax88172_link_reset, | 1371 | .reset = ax88172_link_reset, |
1340 | .flags = FLAG_ETHER, | 1372 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
1341 | .data = 0x009f9d9f, | 1373 | .data = 0x009f9d9f, |
1342 | }; | 1374 | }; |
1343 | 1375 | ||
@@ -1347,7 +1379,7 @@ static const struct driver_info netgear_fa120_info = { | |||
1347 | .status = asix_status, | 1379 | .status = asix_status, |
1348 | .link_reset = ax88172_link_reset, | 1380 | .link_reset = ax88172_link_reset, |
1349 | .reset = ax88172_link_reset, | 1381 | .reset = ax88172_link_reset, |
1350 | .flags = FLAG_ETHER, | 1382 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
1351 | .data = 0x00130103, | 1383 | .data = 0x00130103, |
1352 | }; | 1384 | }; |
1353 | 1385 | ||
@@ -1357,7 +1389,7 @@ static const struct driver_info hawking_uf200_info = { | |||
1357 | .status = asix_status, | 1389 | .status = asix_status, |
1358 | .link_reset = ax88172_link_reset, | 1390 | .link_reset = ax88172_link_reset, |
1359 | .reset = ax88172_link_reset, | 1391 | .reset = ax88172_link_reset, |
1360 | .flags = FLAG_ETHER, | 1392 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
1361 | .data = 0x001f1d1f, | 1393 | .data = 0x001f1d1f, |
1362 | }; | 1394 | }; |
1363 | 1395 | ||
@@ -1367,7 +1399,7 @@ static const struct driver_info ax88772_info = { | |||
1367 | .status = asix_status, | 1399 | .status = asix_status, |
1368 | .link_reset = ax88772_link_reset, | 1400 | .link_reset = ax88772_link_reset, |
1369 | .reset = ax88772_link_reset, | 1401 | .reset = ax88772_link_reset, |
1370 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1402 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR, |
1371 | .rx_fixup = asix_rx_fixup, | 1403 | .rx_fixup = asix_rx_fixup, |
1372 | .tx_fixup = asix_tx_fixup, | 1404 | .tx_fixup = asix_tx_fixup, |
1373 | }; | 1405 | }; |
@@ -1378,7 +1410,7 @@ static const struct driver_info ax88178_info = { | |||
1378 | .status = asix_status, | 1410 | .status = asix_status, |
1379 | .link_reset = ax88178_link_reset, | 1411 | .link_reset = ax88178_link_reset, |
1380 | .reset = ax88178_link_reset, | 1412 | .reset = ax88178_link_reset, |
1381 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1413 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR, |
1382 | .rx_fixup = asix_rx_fixup, | 1414 | .rx_fixup = asix_rx_fixup, |
1383 | .tx_fixup = asix_tx_fixup, | 1415 | .tx_fixup = asix_tx_fixup, |
1384 | }; | 1416 | }; |