diff options
author | Matheos Worku <matheos.worku@sun.com> | 2008-04-25 00:02:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-25 00:02:37 -0400 |
commit | 7f7c4072ea552f97a0898331322f71986a97299c (patch) | |
tree | e63fabff36f9e4c849346e3beabdde0cc2f23947 /drivers/net/niu.c | |
parent | c5835df9716bdb1af8e25e9a452f717e54e02ed0 (diff) |
niu: Determine the # of ports from the card's VPD data
[ Fix minor whitespace and coding style stuff... -DaveM ]
Signed-off-by: Matheos Worku <matheos.worku@sun.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/niu.c')
-rw-r--r-- | drivers/net/niu.c | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 7565c2d7f30e..c7c173c3f808 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -6773,6 +6773,37 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np, | |||
6773 | return 0; | 6773 | return 0; |
6774 | } | 6774 | } |
6775 | 6775 | ||
6776 | /* niu board models have a trailing dash version incremented | ||
6777 | * with HW rev change. Need to ingnore the dash version while | ||
6778 | * checking for match | ||
6779 | * | ||
6780 | * for example, for the 10G card the current vpd.board_model | ||
6781 | * is 501-5283-04, of which -04 is the dash version and have | ||
6782 | * to be ignored | ||
6783 | */ | ||
6784 | static int niu_board_model_match(struct niu *np, const char *model) | ||
6785 | { | ||
6786 | return !strncmp(np->vpd.board_model, model, strlen(model)); | ||
6787 | } | ||
6788 | |||
6789 | static int niu_pci_vpd_get_nports(struct niu *np) | ||
6790 | { | ||
6791 | int ports = 0; | ||
6792 | |||
6793 | if ((niu_board_model_match(np, NIU_QGC_LP_BM_STR)) || | ||
6794 | (niu_board_model_match(np, NIU_QGC_PEM_BM_STR)) || | ||
6795 | (niu_board_model_match(np, NIU_ALONSO_BM_STR))) { | ||
6796 | ports = 4; | ||
6797 | } else if ((niu_board_model_match(np, NIU_2XGF_LP_BM_STR)) || | ||
6798 | (niu_board_model_match(np, NIU_2XGF_PEM_BM_STR)) || | ||
6799 | (niu_board_model_match(np, NIU_FOXXY_BM_STR)) || | ||
6800 | (niu_board_model_match(np, NIU_2XGF_MRVL_BM_STR))) { | ||
6801 | ports = 2; | ||
6802 | } | ||
6803 | |||
6804 | return ports; | ||
6805 | } | ||
6806 | |||
6776 | static void __devinit niu_pci_vpd_validate(struct niu *np) | 6807 | static void __devinit niu_pci_vpd_validate(struct niu *np) |
6777 | { | 6808 | { |
6778 | struct net_device *dev = np->dev; | 6809 | struct net_device *dev = np->dev; |
@@ -6987,11 +7018,17 @@ static int __devinit niu_get_and_validate_port(struct niu *np) | |||
6987 | if (parent->plat_type == PLAT_TYPE_NIU) { | 7018 | if (parent->plat_type == PLAT_TYPE_NIU) { |
6988 | parent->num_ports = 2; | 7019 | parent->num_ports = 2; |
6989 | } else { | 7020 | } else { |
6990 | parent->num_ports = nr64(ESPC_NUM_PORTS_MACS) & | 7021 | parent->num_ports = niu_pci_vpd_get_nports(np); |
6991 | ESPC_NUM_PORTS_MACS_VAL; | 7022 | if (!parent->num_ports) { |
6992 | 7023 | /* Fall back to SPROM as last resort. | |
6993 | if (!parent->num_ports) | 7024 | * This will fail on most cards. |
6994 | parent->num_ports = 4; | 7025 | */ |
7026 | parent->num_ports = nr64(ESPC_NUM_PORTS_MACS) & | ||
7027 | ESPC_NUM_PORTS_MACS_VAL; | ||
7028 | |||
7029 | if (!parent->num_ports) | ||
7030 | return -ENODEV; | ||
7031 | } | ||
6995 | } | 7032 | } |
6996 | } | 7033 | } |
6997 | 7034 | ||
@@ -7733,15 +7770,16 @@ static int __devinit niu_get_invariants(struct niu *np) | |||
7733 | 7770 | ||
7734 | have_props = !err; | 7771 | have_props = !err; |
7735 | 7772 | ||
7736 | err = niu_get_and_validate_port(np); | ||
7737 | if (err) | ||
7738 | return err; | ||
7739 | |||
7740 | err = niu_init_mac_ipp_pcs_base(np); | 7773 | err = niu_init_mac_ipp_pcs_base(np); |
7741 | if (err) | 7774 | if (err) |
7742 | return err; | 7775 | return err; |
7743 | 7776 | ||
7744 | if (!have_props) { | 7777 | if (have_props) { |
7778 | err = niu_get_and_validate_port(np); | ||
7779 | if (err) | ||
7780 | return err; | ||
7781 | |||
7782 | } else { | ||
7745 | if (np->parent->plat_type == PLAT_TYPE_NIU) | 7783 | if (np->parent->plat_type == PLAT_TYPE_NIU) |
7746 | return -EINVAL; | 7784 | return -EINVAL; |
7747 | 7785 | ||
@@ -7753,10 +7791,17 @@ static int __devinit niu_get_invariants(struct niu *np) | |||
7753 | niu_pci_vpd_fetch(np, offset); | 7791 | niu_pci_vpd_fetch(np, offset); |
7754 | nw64(ESPC_PIO_EN, 0); | 7792 | nw64(ESPC_PIO_EN, 0); |
7755 | 7793 | ||
7756 | if (np->flags & NIU_FLAGS_VPD_VALID) | 7794 | if (np->flags & NIU_FLAGS_VPD_VALID) { |
7757 | niu_pci_vpd_validate(np); | 7795 | niu_pci_vpd_validate(np); |
7796 | err = niu_get_and_validate_port(np); | ||
7797 | if (err) | ||
7798 | return err; | ||
7799 | } | ||
7758 | 7800 | ||
7759 | if (!(np->flags & NIU_FLAGS_VPD_VALID)) { | 7801 | if (!(np->flags & NIU_FLAGS_VPD_VALID)) { |
7802 | err = niu_get_and_validate_port(np); | ||
7803 | if (err) | ||
7804 | return err; | ||
7760 | err = niu_pci_probe_sprom(np); | 7805 | err = niu_pci_probe_sprom(np); |
7761 | if (err) | 7806 | if (err) |
7762 | return err; | 7807 | return err; |