Skip to content

Commit 6411280

Browse files
Ariel Eliordavem330
authored andcommitted
bnx2x: Segregate SR-IOV code
In this patch the SR-IOV code is segregated from the main bulk of the bnx2x code. The CONFIG_BNX2X_SRIOV define is added to Broadcom's Kconfig, and allows the elision of the building of all the SR-IOV support code in the driver. The define is dependant on the kernel CONFIG_PCI_IOV configuration define. Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5ebae48 commit 6411280

File tree

10 files changed

+953
-844
lines changed

10 files changed

+953
-844
lines changed

drivers/net/ethernet/broadcom/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,13 @@ config BNX2X
121121
To compile this driver as a module, choose M here: the module
122122
will be called bnx2x. This is recommended.
123123

124+
config BNX2X_SRIOV
125+
bool "Broadcom 578xx and 57712 SR-IOV support"
126+
depends on BNX2X && PCI_IOV
127+
default y
128+
---help---
129+
This configuration parameter enables Single Root Input Output
130+
Virtualization support in the 578xx and 57712 products. This
131+
allows for virtual function acceleration in virtual environments.
132+
124133
endif # NET_VENDOR_BROADCOM

drivers/net/ethernet/broadcom/bnx2x/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
obj-$(CONFIG_BNX2X) += bnx2x.o
66

7-
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
7+
bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o bnx2x_dcb.o bnx2x_sp.o
8+
bnx2x-$(CONFIG_BNX2X_SRIOV) += bnx2x_vfpf.o bnx2x_sriov.o

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ struct bnx2x {
12661266
(vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1))
12671267
#define BP_FW_MB_IDX(bp) BP_FW_MB_IDX_VN(bp, BP_VN(bp))
12681268

1269+
#ifdef CONFIG_BNX2X_SRIOV
12691270
/* vf pf channel mailbox contains request and response buffers */
12701271
struct bnx2x_vf_mbx_msg *vf2pf_mbox;
12711272
dma_addr_t vf2pf_mbox_mapping;
@@ -1278,6 +1279,7 @@ struct bnx2x {
12781279
dma_addr_t pf2vf_bulletin_mapping;
12791280

12801281
struct pf_vf_bulletin_content old_bulletin;
1282+
#endif /* CONFIG_BNX2X_SRIOV */
12811283

12821284
struct net_device *dev;
12831285
struct pci_dev *pdev;
@@ -1379,8 +1381,14 @@ struct bnx2x {
13791381
#define IS_VF_FLAG (1 << 22)
13801382

13811383
#define BP_NOMCP(bp) ((bp)->flags & NO_MCP_FLAG)
1384+
1385+
#ifdef CONFIG_BNX2X_SRIOV
13821386
#define IS_VF(bp) ((bp)->flags & IS_VF_FLAG)
13831387
#define IS_PF(bp) (!((bp)->flags & IS_VF_FLAG))
1388+
#else
1389+
#define IS_VF(bp) false
1390+
#define IS_PF(bp) true
1391+
#endif
13841392

13851393
#define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG)
13861394
#define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
@@ -2275,18 +2283,6 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
22752283

22762284
#define GOOD_ME_REG(me_reg) (((me_reg) & ME_REG_VF_VALID) && \
22772285
(!((me_reg) & ME_REG_VF_ERR)))
2278-
int bnx2x_get_vf_id(struct bnx2x *bp, u32 *vf_id);
2279-
int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping);
2280-
int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
2281-
int bnx2x_vfpf_release(struct bnx2x *bp);
2282-
int bnx2x_vfpf_init(struct bnx2x *bp);
2283-
void bnx2x_vfpf_close_vf(struct bnx2x *bp);
2284-
int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx);
2285-
int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx);
2286-
int bnx2x_vfpf_set_mac(struct bnx2x *bp);
2287-
int bnx2x_vfpf_set_mcast(struct net_device *dev);
2288-
int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp);
2289-
22902286
int bnx2x_nic_load_analyze_req(struct bnx2x *bp, u32 load_code);
22912287
/* Congestion management fairness mode */
22922288
#define CMNG_FNS_NONE 0

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "bnx2x_cmn.h"
2828
#include "bnx2x_init.h"
2929
#include "bnx2x_sp.h"
30-
#include "bnx2x_sriov.h"
3130

3231
/**
3332
* bnx2x_move_fp - move content of the fastpath structure.
@@ -109,7 +108,7 @@ void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len)
109108
(bp->common.bc_ver & 0xff),
110109
((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver);
111110
} else {
112-
strlcpy(buf, bp->acquire_resp.pfdev_info.fw_ver, buf_len);
111+
bnx2x_vf_fill_fw_str(bp, buf, buf_len);
113112
}
114113
}
115114

@@ -2048,7 +2047,7 @@ static int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
20482047
* request struct
20492048
*/
20502049
if (IS_SRIOV(bp))
2051-
vf_headroom = bp->vfdb->sriov.nr_virtfn * BNX2X_CLIENTS_PER_VF;
2050+
vf_headroom = bnx2x_vf_headroom(bp);
20522051

20532052
/* Request is built from stats_query_header and an array of
20542053
* stats_query_cmd_group each of which contains
@@ -3793,93 +3792,6 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)
37933792
return 0;
37943793
}
37953794

3796-
/* New mac for VF. Consider these cases:
3797-
* 1. VF hasn't been acquired yet - save the mac in local bulletin board and
3798-
* supply at acquire.
3799-
* 2. VF has already been acquired but has not yet initialized - store in local
3800-
* bulletin board. mac will be posted on VF bulletin board after VF init. VF
3801-
* will configure this mac when it is ready.
3802-
* 3. VF has already initialized but has not yet setup a queue - post the new
3803-
* mac on VF's bulletin board right now. VF will configure this mac when it
3804-
* is ready.
3805-
* 4. VF has already set a queue - delete any macs already configured for this
3806-
* queue and manually config the new mac.
3807-
* In any event, once this function has been called refuse any attempts by the
3808-
* VF to configure any mac for itself except for this mac. In case of a race
3809-
* where the VF fails to see the new post on its bulletin board before sending a
3810-
* mac configuration request, the PF will simply fail the request and VF can try
3811-
* again after consulting its bulletin board
3812-
*/
3813-
int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac)
3814-
{
3815-
struct bnx2x *bp = netdev_priv(dev);
3816-
int rc, q_logical_state, vfidx = queue;
3817-
struct bnx2x_virtf *vf = BP_VF(bp, vfidx);
3818-
struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx);
3819-
3820-
/* if SRIOV is disabled there is nothing to do (and somewhere, someone
3821-
* has erred).
3822-
*/
3823-
if (!IS_SRIOV(bp)) {
3824-
BNX2X_ERR("bnx2x_set_vf_mac called though sriov is disabled\n");
3825-
return -EINVAL;
3826-
}
3827-
3828-
if (!is_valid_ether_addr(mac)) {
3829-
BNX2X_ERR("mac address invalid\n");
3830-
return -EINVAL;
3831-
}
3832-
3833-
/* update PF's copy of the VF's bulletin. will no longer accept mac
3834-
* configuration requests from vf unless match this mac
3835-
*/
3836-
bulletin->valid_bitmap |= 1 << MAC_ADDR_VALID;
3837-
memcpy(bulletin->mac, mac, ETH_ALEN);
3838-
3839-
/* Post update on VF's bulletin board */
3840-
rc = bnx2x_post_vf_bulletin(bp, vfidx);
3841-
if (rc) {
3842-
BNX2X_ERR("failed to update VF[%d] bulletin\n", vfidx);
3843-
return rc;
3844-
}
3845-
3846-
/* is vf initialized and queue set up? */
3847-
q_logical_state =
3848-
bnx2x_get_q_logical_state(bp, &bnx2x_vfq(vf, 0, sp_obj));
3849-
if (vf->state == VF_ENABLED &&
3850-
q_logical_state == BNX2X_Q_LOGICAL_STATE_ACTIVE) {
3851-
/* configure the mac in device on this vf's queue */
3852-
unsigned long flags = 0;
3853-
struct bnx2x_vlan_mac_obj *mac_obj = &bnx2x_vfq(vf, 0, mac_obj);
3854-
3855-
/* must lock vfpf channel to protect against vf flows */
3856-
bnx2x_lock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_MAC);
3857-
3858-
/* remove existing eth macs */
3859-
rc = bnx2x_del_all_macs(bp, mac_obj, BNX2X_ETH_MAC, true);
3860-
if (rc) {
3861-
BNX2X_ERR("failed to delete eth macs\n");
3862-
return -EINVAL;
3863-
}
3864-
3865-
/* remove existing uc list macs */
3866-
rc = bnx2x_del_all_macs(bp, mac_obj, BNX2X_UC_LIST_MAC, true);
3867-
if (rc) {
3868-
BNX2X_ERR("failed to delete uc_list macs\n");
3869-
return -EINVAL;
3870-
}
3871-
3872-
/* configure the new mac to device */
3873-
__set_bit(RAMROD_COMP_WAIT, &flags);
3874-
bnx2x_set_mac_one(bp, (u8 *)&bulletin->mac, mac_obj, true,
3875-
BNX2X_ETH_MAC, &flags);
3876-
3877-
bnx2x_unlock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_MAC);
3878-
}
3879-
3880-
return rc;
3881-
}
3882-
38833795
/* called with rtnl_lock */
38843796
int bnx2x_change_mac_addr(struct net_device *dev, void *p)
38853797
{

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626
#include "bnx2x.h"
27+
#include "bnx2x_sriov.h"
2728

2829
/* This is used as a replacement for an MCP if it's not present */
2930
extern int load_count[2][3]; /* per-path: 0-common, 1-port0, 2-port1 */
@@ -1128,22 +1129,7 @@ static inline u8 bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp)
11281129
return fp->cl_id;
11291130
}
11301131

1131-
static inline u32 bnx2x_rx_ustorm_prods_offset(struct bnx2x_fastpath *fp)
1132-
{
1133-
struct bnx2x *bp = fp->bp;
1134-
u32 offset = BAR_USTRORM_INTMEM;
1135-
1136-
if (IS_VF(bp))
1137-
return PXP_VF_ADDR_USDM_QUEUES_START +
1138-
bp->acquire_resp.resc.hw_qid[fp->index] *
1139-
sizeof(struct ustorm_queue_zone_data);
1140-
else if (!CHIP_IS_E1x(bp))
1141-
offset += USTORM_RX_PRODS_E2_OFFSET(fp->cl_qzone_id);
1142-
else
1143-
offset += USTORM_RX_PRODS_E1X_OFFSET(BP_PORT(bp), fp->cl_id);
1144-
1145-
return offset;
1146-
}
1132+
u32 bnx2x_rx_ustorm_prods_offset(struct bnx2x_fastpath *fp);
11471133

11481134
static inline void bnx2x_init_txdata(struct bnx2x *bp,
11491135
struct bnx2x_fp_txdata *txdata, u32 cid,

0 commit comments

Comments
 (0)