From: Michael Chan Date: Sat, 16 Jun 2012 15:45:43 +0000 (+0000) Subject: bnx2: Read PCI function number from internal register X-Git-Tag: v2.6.39-400.9.0~338^2~133 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8a616b49ede236589f65b9940359ec4e534228a4;p=users%2Fjedix%2Flinux-maple.git bnx2: Read PCI function number from internal register so that it will work on any hypervisor. (cherry picked from commit aefd90e41476223c95e3c84c7dd22a65a21b1e40) Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Joe Jin --- diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 3a65c78253fe..597ac49fbd93 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -7902,7 +7902,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: @@ -8201,9 +8201,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 diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index f64470d976ba..d6b86ac3df28 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h @@ -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;