Skip to content

Commit

Permalink
bnx2x: Allocate VF database in PF when VFs are present
Browse files Browse the repository at this point in the history
When A PF determines that it may have to manage SRIOV VFs it
allocates a database for this purpose. The database is intended to
keep track of the VF state, the resources allocated for each VF
(queues, interrupt vectors, etc), the state of the VF's queues.
When the VF loads the database is updated accordingly.
When A VF closes the database is consulted to determine which
resources need to be released (close queues against device, reclaim
interrupt vectors, etc).

Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ariel Elior authored and David S. Miller committed Jan 2, 2013
1 parent dc1ba59 commit 290ca2b
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bnx2x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

obj-$(CONFIG_BNX2X) += bnx2x.o

bnx2x-objs := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o bnx2x_dcb.o bnx2x_sp.o bnx2x_vfpf.o
bnx2x-objs := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o bnx2x_dcb.o bnx2x_sp.o bnx2x_vfpf.o bnx2x_sriov.o
8 changes: 8 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

#ifndef BNX2X_H
#define BNX2X_H

#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/dma-mapping.h>
#include <linux/types.h>
#include <linux/pci_regs.h>

/* compilation time flags */

Expand Down Expand Up @@ -966,6 +969,7 @@ extern struct workqueue_struct *bnx2x_wq;
#define BNX2X_MAX_NUM_OF_VFS 64
#define BNX2X_VF_CID_WND 0
#define BNX2X_CIDS_PER_VF (1 << BNX2X_VF_CID_WND)
#define BNX2X_FIRST_VF_CID 256
#define BNX2X_VF_CIDS (BNX2X_MAX_NUM_OF_VFS * BNX2X_CIDS_PER_VF)
#define BNX2X_VF_ID_INVALID 0xFF

Expand Down Expand Up @@ -1117,6 +1121,7 @@ struct hw_context {
/* forward */
struct bnx2x_ilt;

struct bnx2x_vfdb;

enum bnx2x_recovery_state {
BNX2X_RECOVERY_DONE,
Expand Down Expand Up @@ -1606,6 +1611,9 @@ struct bnx2x {
char fw_ver[32];
const struct firmware *firmware;

struct bnx2x_vfdb *vfdb;
#define IS_SRIOV(bp) ((bp)->vfdb)

/* DCB support on/off */
u16 dcb_state;
#define BNX2X_DCB_STATE_OFF 0
Expand Down
28 changes: 28 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7270,12 +7270,21 @@ static int bnx2x_init_hw_func(struct bnx2x *bp)
ilt = BP_ILT(bp);
cdu_ilt_start = ilt->clients[ILT_CLIENT_CDU].start;

if (IS_SRIOV(bp))
cdu_ilt_start += BNX2X_FIRST_VF_CID/ILT_PAGE_CIDS;
cdu_ilt_start = bnx2x_iov_init_ilt(bp, cdu_ilt_start);

/* since BNX2X_FIRST_VF_CID > 0 the PF L2 cids precedes
* those of the VFs, so start line should be reset
*/
cdu_ilt_start = ilt->clients[ILT_CLIENT_CDU].start;
for (i = 0; i < L2_ILT_LINES(bp); i++) {
ilt->lines[cdu_ilt_start + i].page = bp->context[i].vcxt;
ilt->lines[cdu_ilt_start + i].page_mapping =
bp->context[i].cxt_mapping;
ilt->lines[cdu_ilt_start + i].size = bp->context[i].size;
}

bnx2x_ilt_init_op(bp, INITOP_SET);

if (!CONFIGURE_NIC_MODE(bp)) {
Expand Down Expand Up @@ -7881,6 +7890,8 @@ int bnx2x_set_int_mode(struct bnx2x *bp)
/* must be called prior to any HW initializations */
static inline u16 bnx2x_cid_ilt_lines(struct bnx2x *bp)
{
if (IS_SRIOV(bp))
return (BNX2X_FIRST_VF_CID + BNX2X_VF_CIDS)/ILT_PAGE_CIDS;
return L2_ILT_LINES(bp);
}

Expand Down Expand Up @@ -12106,8 +12117,12 @@ static int bnx2x_set_qm_cid_count(struct bnx2x *bp)
{
int cid_count = BNX2X_L2_MAX_CID(bp);

if (IS_SRIOV(bp))
cid_count += BNX2X_VF_CIDS;

if (CNIC_SUPPORT(bp))
cid_count += CNIC_CID_MAX;

return roundup(cid_count, QM_CID_ROUND);
}

Expand Down Expand Up @@ -12312,6 +12327,16 @@ static int bnx2x_init_one(struct pci_dev *pdev,
goto init_one_exit;
}

/* Enable SRIOV if capability found in configuration space.
* Once the generic SR-IOV framework makes it in from the
* pci tree this will be revised, to allow dynamic control
* over the number of VFs. Right now, change the num of vfs
* param below to enable SR-IOV.
*/
rc = bnx2x_iov_init_one(bp, int_mode, 0/*num vfs*/);
if (rc)
goto init_one_exit;

/* calc qm_cid_count */
bp->qm_cid_count = bnx2x_set_qm_cid_count(bp);
BNX2X_DEV_INFO("qm_cid_count %d\n", bp->qm_cid_count);
Expand Down Expand Up @@ -12435,6 +12460,9 @@ static void bnx2x_remove_one(struct pci_dev *pdev)

/* Make sure RESET task is not scheduled before continuing */
cancel_delayed_work_sync(&bp->sp_rtnl_task);

bnx2x_iov_remove_one(bp);

/* send message via vfpf channel to release the resources of this vf */
if (IS_VF(bp))
bnx2x_vfpf_release(bp);
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -6305,6 +6305,15 @@
#define PCI_PM_DATA_B 0x414
#define PCI_ID_VAL1 0x434
#define PCI_ID_VAL2 0x438
#define GRC_CONFIG_REG_PF_INIT_VF 0x624
#define GRC_CR_PF_INIT_VF_PF_FIRST_VF_NUM_MASK 0xf
/* First VF_NUM for PF is encoded in this register.
* The number of VFs assigned to a PF is assumed to be a multiple of 8.
* Software should program these bits based on Total Number of VFs \
* programmed for each PF.
* Since registers from 0x000-0x7ff are split across functions, each PF will
* have the same location for the same 4 bits
*/

#define PXPCS_TL_CONTROL_5 0x814
#define PXPCS_TL_CONTROL_5_UNKNOWNTYPE_ERR_ATTN (1 << 29) /*WC*/
Expand Down
Loading

0 comments on commit 290ca2b

Please sign in to comment.