bnx2: Read PCI function number from internal register
authorMichael Chan <mchan@broadcom.com>
Sat, 16 Jun 2012 15:45:43 +0000 (15:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 17 Jun 2012 05:22:59 +0000 (22:22 -0700)
so that it will work on any hypervisor.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/broadcom/bnx2.h

index da88de73e899b6266960363e5b58206e6230c936..c6d39438cbe374eed9eab2aef6d998adfb216862 100644 (file)
@@ -7903,7 +7903,7 @@ bnx2_get_5709_media(struct bnx2 *bp)
        else
                strap = (val & BNX2_MISC_DUAL_MEDIA_CTRL_PHY_CTRL_STRAP) >> 8;
 
-       if (PCI_FUNC(bp->pdev->devfn) == 0) {
+       if (bp->func == 0) {
                switch (strap) {
                case 0x4:
                case 0x5:
@@ -8202,9 +8202,12 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
        reg = bnx2_reg_rd_ind(bp, BNX2_SHM_HDR_SIGNATURE);
 
+       if (bnx2_reg_rd_ind(bp, BNX2_MCP_TOE_ID) & BNX2_MCP_TOE_ID_FUNCTION_ID)
+               bp->func = 1;
+
        if ((reg & BNX2_SHM_HDR_SIGNATURE_SIG_MASK) ==
            BNX2_SHM_HDR_SIGNATURE_SIG) {
-               u32 off = PCI_FUNC(pdev->devfn) << 2;
+               u32 off = bp->func << 2;
 
                bp->shmem_base = bnx2_reg_rd_ind(bp, BNX2_SHM_HDR_ADDR_0 + off);
        } else
index f9cb639a478734278bea2953a308ad6eff36b6fe..af6451dec2954aedce75ef45cd9f26b9edd88b94 100644 (file)
@@ -6971,6 +6971,8 @@ struct bnx2 {
        struct bnx2_irq         irq_tbl[BNX2_MAX_MSIX_VEC];
        int                     irq_nvecs;
 
+       u8                      func;
+
        u8                      num_tx_rings;
        u8                      num_rx_rings;