diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 7615c715e66e..6fc42cd30729 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -501,6 +501,44 @@ static void netxen_init_msix_entries(struct netxen_adapter *adapter) | |||
501 | adapter->msix_entries[i].entry = i; | 501 | adapter->msix_entries[i].entry = i; |
502 | } | 502 | } |
503 | 503 | ||
504 | static int | ||
505 | netxen_read_mac_addr(struct netxen_adapter *adapter) | ||
506 | { | ||
507 | int i; | ||
508 | unsigned char *p; | ||
509 | __le64 mac_addr; | ||
510 | DECLARE_MAC_BUF(mac); | ||
511 | struct net_device *netdev = adapter->netdev; | ||
512 | struct pci_dev *pdev = adapter->pdev; | ||
513 | |||
514 | if (netxen_is_flash_supported(adapter) != 0) | ||
515 | return -EIO; | ||
516 | |||
517 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | ||
518 | if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0) | ||
519 | return -EIO; | ||
520 | } else { | ||
521 | if (netxen_get_flash_mac_addr(adapter, &mac_addr) != 0) | ||
522 | return -EIO; | ||
523 | } | ||
524 | |||
525 | p = (unsigned char *)&mac_addr; | ||
526 | for (i = 0; i < 6; i++) | ||
527 | netdev->dev_addr[i] = *(p + 5 - i); | ||
528 | |||
529 | memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len); | ||
530 | |||
531 | /* set station address */ | ||
532 | |||
533 | if (!is_valid_ether_addr(netdev->perm_addr)) { | ||
534 | dev_warn(&pdev->dev, "Bad MAC address %s.\n", | ||
535 | print_mac(mac, netdev->dev_addr)); | ||
536 | } else | ||
537 | adapter->macaddr_set(adapter, netdev->dev_addr); | ||
538 | |||
539 | return 0; | ||
540 | } | ||
541 | |||
504 | /* | 542 | /* |
505 | * netxen_nic_probe() | 543 | * netxen_nic_probe() |
506 | * | 544 | * |
@@ -529,10 +567,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
529 | unsigned long mem_base, mem_len, db_base, db_len, pci_len0 = 0; | 567 | unsigned long mem_base, mem_len, db_base, db_len, pci_len0 = 0; |
530 | int i = 0, err; | 568 | int i = 0, err; |
531 | int first_driver, first_boot; | 569 | int first_driver, first_boot; |
532 | __le64 mac_addr[FLASH_NUM_PORTS + 1]; | ||
533 | u32 val; | 570 | u32 val; |
534 | int pci_func_id = PCI_FUNC(pdev->devfn); | 571 | int pci_func_id = PCI_FUNC(pdev->devfn); |
535 | DECLARE_MAC_BUF(mac); | ||
536 | struct netxen_legacy_intr_set *legacy_intrp; | 572 | struct netxen_legacy_intr_set *legacy_intrp; |
537 | uint8_t revision_id; | 573 | uint8_t revision_id; |
538 | 574 | ||
@@ -904,28 +940,9 @@ request_msi: | |||
904 | INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); | 940 | INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); |
905 | INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task); | 941 | INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task); |
906 | 942 | ||
907 | if (netxen_is_flash_supported(adapter) == 0 && | 943 | err = netxen_read_mac_addr(adapter); |
908 | netxen_get_flash_mac_addr(adapter, mac_addr) == 0) { | 944 | if (err) |
909 | unsigned char *p; | 945 | dev_warn(&pdev->dev, "failed to read mac addr\n"); |
910 | |||
911 | p = (unsigned char *)&mac_addr[adapter->portnum]; | ||
912 | netdev->dev_addr[0] = *(p + 5); | ||
913 | netdev->dev_addr[1] = *(p + 4); | ||
914 | netdev->dev_addr[2] = *(p + 3); | ||
915 | netdev->dev_addr[3] = *(p + 2); | ||
916 | netdev->dev_addr[4] = *(p + 1); | ||
917 | netdev->dev_addr[5] = *(p + 0); | ||
918 | |||
919 | memcpy(netdev->perm_addr, netdev->dev_addr, | ||
920 | netdev->addr_len); | ||
921 | if (!is_valid_ether_addr(netdev->perm_addr)) { | ||
922 | printk(KERN_ERR "%s: Bad MAC address %s.\n", | ||
923 | netxen_nic_driver_name, | ||
924 | print_mac(mac, netdev->dev_addr)); | ||
925 | } else { | ||
926 | adapter->macaddr_set(adapter, netdev->dev_addr); | ||
927 | } | ||
928 | } | ||
929 | 946 | ||
930 | netif_carrier_off(netdev); | 947 | netif_carrier_off(netdev); |
931 | netif_stop_queue(netdev); | 948 | netif_stop_queue(netdev); |