aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-07-13 05:27:30 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-14 11:41:59 -0400
commit69f11c9936ba310ed3620072983da6ed95e86cc0 (patch)
tree5cf0983f0e22f368d573b22c94ee10932dc9490e
parentbed9829f3ec4b30d5cbec6511a11368ba5f169fb (diff)
tg3: Determine PCI function number in one place
tg3 devices will need to know exactly what function number they are so that they can communicate their status to the other functions. In a KVM environment, the function number of a device presented by the kernel might not be the true function number, so an alternative method to determine the function number is needed. This patch used to contain an implementation for the alternative method, but recently we discovered a hardware bug that renders it incorrect. While new method is not yet known, it is still useful to consolidate the code that determines the PCI function to one location and use the results throughout the code. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tg3.c14
-rw-r--r--drivers/net/tg3.h1
2 files changed, 12 insertions, 3 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 5d4283e7be7a..6f1f36c89055 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1170,7 +1170,7 @@ static int tg3_mdio_init(struct tg3 *tp)
1170 if (tg3_flag(tp, 5717_PLUS)) { 1170 if (tg3_flag(tp, 5717_PLUS)) {
1171 u32 is_serdes; 1171 u32 is_serdes;
1172 1172
1173 tp->phy_addr = PCI_FUNC(tp->pdev->devfn) + 1; 1173 tp->phy_addr = tp->pci_fn + 1;
1174 1174
1175 if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) 1175 if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0)
1176 is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES; 1176 is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
@@ -13951,6 +13951,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13951 val = tr32(MEMARB_MODE); 13951 val = tr32(MEMARB_MODE);
13952 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE); 13952 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
13953 13953
13954 if (tg3_flag(tp, PCIX_MODE)) {
13955 pci_read_config_dword(tp->pdev,
13956 tp->pcix_cap + PCI_X_STATUS, &val);
13957 tp->pci_fn = val & 0x7;
13958 } else {
13959 tp->pci_fn = PCI_FUNC(tp->pdev->devfn) & 3;
13960 }
13961
13954 /* Get eeprom hw config before calling tg3_set_power_state(). 13962 /* Get eeprom hw config before calling tg3_set_power_state().
13955 * In particular, the TG3_FLAG_IS_NIC flag must be 13963 * In particular, the TG3_FLAG_IS_NIC flag must be
13956 * determined before calling tg3_set_power_state() so that 13964 * determined before calling tg3_set_power_state() so that
@@ -14316,9 +14324,9 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
14316 else 14324 else
14317 tg3_nvram_unlock(tp); 14325 tg3_nvram_unlock(tp);
14318 } else if (tg3_flag(tp, 5717_PLUS)) { 14326 } else if (tg3_flag(tp, 5717_PLUS)) {
14319 if (PCI_FUNC(tp->pdev->devfn) & 1) 14327 if (tp->pci_fn & 1)
14320 mac_offset = 0xcc; 14328 mac_offset = 0xcc;
14321 if (PCI_FUNC(tp->pdev->devfn) > 1) 14329 if (tp->pci_fn > 1)
14322 mac_offset += 0x18c; 14330 mac_offset += 0x18c;
14323 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 14331 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
14324 mac_offset = 0x10; 14332 mac_offset = 0x10;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 5f250aef7c92..b4c003db69a1 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -3020,6 +3020,7 @@ struct tg3 {
3020 u8 pci_cacheline_sz; 3020 u8 pci_cacheline_sz;
3021 u8 pci_lat_timer; 3021 u8 pci_lat_timer;
3022 3022
3023 int pci_fn;
3023 int pm_cap; 3024 int pm_cap;
3024 int msi_cap; 3025 int msi_cap;
3025 int pcix_cap; 3026 int pcix_cap;