Skip to content

Commit 97ac4ef

Browse files
Yuval Mintzdavem330
authored andcommitted
bnx2x: Add BD support for storage
Commit 230d00e ("bnx2x: new Multi-function mode - BD") adds support for the new mode in bnx2x. This expands this support by implementing APIs required by our storage drivers to support that mode. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9b8d504 commit 97ac4ef

File tree

4 files changed

+118
-2
lines changed

4 files changed

+118
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,4 +1386,16 @@ void bnx2x_schedule_sp_rtnl(struct bnx2x*, enum sp_rtnl_flag,
13861386
* @state: OS_DRIVER_STATE_* value reflecting current driver state
13871387
*/
13881388
void bnx2x_set_os_driver_state(struct bnx2x *bp, u32 state);
1389+
1390+
/**
1391+
* bnx2x_nvram_read - reads data from nvram [might sleep]
1392+
*
1393+
* @bp: driver handle
1394+
* @offset: byte offset in nvram
1395+
* @ret_buf: pointer to buffer where data is to be stored
1396+
* @buf_size: Length of 'ret_buf' in bytes
1397+
*/
1398+
int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
1399+
int buf_size);
1400+
13891401
#endif /* BNX2X_CMN_H */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,8 @@ static int bnx2x_nvram_read_dword(struct bnx2x *bp, u32 offset, __be32 *ret_val,
13481348
return rc;
13491349
}
13501350

1351-
static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
1352-
int buf_size)
1351+
int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
1352+
int buf_size)
13531353
{
13541354
int rc;
13551355
u32 cmd_flags;

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,25 @@ enum curr_cfg_method_e {
20752075
CURR_CFG_MET_VENDOR_SPEC = 2,/* e.g. Option ROM, NPAR, O/S Cfg Utils */
20762076
};
20772077

2078+
#define FC_NPIV_WWPN_SIZE 8
2079+
#define FC_NPIV_WWNN_SIZE 8
2080+
struct bdn_npiv_settings {
2081+
u8 npiv_wwpn[FC_NPIV_WWPN_SIZE];
2082+
u8 npiv_wwnn[FC_NPIV_WWNN_SIZE];
2083+
};
2084+
2085+
struct bdn_fc_npiv_cfg {
2086+
/* hdr used internally by the MFW */
2087+
u32 hdr;
2088+
u32 num_of_npiv;
2089+
};
2090+
2091+
#define MAX_NUMBER_NPIV 64
2092+
struct bdn_fc_npiv_tbl {
2093+
struct bdn_fc_npiv_cfg fc_npiv_cfg;
2094+
struct bdn_npiv_settings settings[MAX_NUMBER_NPIV];
2095+
};
2096+
20782097
struct mdump_driver_info {
20792098
u32 epoc;
20802099
u32 drv_ver;

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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14653,6 +14653,90 @@ static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl)
1465314653
rc = -EINVAL;
1465414654
}
1465514655

14656+
/* For storage-only interfaces, change driver state */
14657+
if (IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp)) {
14658+
switch (ctl->drv_state) {
14659+
case DRV_NOP:
14660+
break;
14661+
case DRV_ACTIVE:
14662+
bnx2x_set_os_driver_state(bp,
14663+
OS_DRIVER_STATE_ACTIVE);
14664+
break;
14665+
case DRV_INACTIVE:
14666+
bnx2x_set_os_driver_state(bp,
14667+
OS_DRIVER_STATE_DISABLED);
14668+
break;
14669+
case DRV_UNLOADED:
14670+
bnx2x_set_os_driver_state(bp,
14671+
OS_DRIVER_STATE_NOT_LOADED);
14672+
break;
14673+
default:
14674+
BNX2X_ERR("Unknown cnic driver state: %d\n", ctl->drv_state);
14675+
}
14676+
}
14677+
14678+
return rc;
14679+
}
14680+
14681+
static int bnx2x_get_fc_npiv(struct net_device *dev,
14682+
struct cnic_fc_npiv_tbl *cnic_tbl)
14683+
{
14684+
struct bnx2x *bp = netdev_priv(dev);
14685+
struct bdn_fc_npiv_tbl *tbl = NULL;
14686+
u32 offset, entries;
14687+
int rc = -EINVAL;
14688+
int i;
14689+
14690+
if (!SHMEM2_HAS(bp, fc_npiv_nvram_tbl_addr[0]))
14691+
goto out;
14692+
14693+
DP(BNX2X_MSG_MCP, "About to read the FC-NPIV table\n");
14694+
14695+
tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
14696+
if (!tbl) {
14697+
BNX2X_ERR("Failed to allocate fc_npiv table\n");
14698+
goto out;
14699+
}
14700+
14701+
offset = SHMEM2_RD(bp, fc_npiv_nvram_tbl_addr[BP_PORT(bp)]);
14702+
DP(BNX2X_MSG_MCP, "Offset of FC-NPIV in NVRAM: %08x\n", offset);
14703+
14704+
/* Read the table contents from nvram */
14705+
if (bnx2x_nvram_read(bp, offset, (u8 *)tbl, sizeof(*tbl))) {
14706+
BNX2X_ERR("Failed to read FC-NPIV table\n");
14707+
goto out;
14708+
}
14709+
14710+
/* Since bnx2x_nvram_read() returns data in be32, we need to convert
14711+
* the number of entries back to cpu endianness.
14712+
*/
14713+
entries = tbl->fc_npiv_cfg.num_of_npiv;
14714+
entries = (__force u32)be32_to_cpu((__force __be32)entries);
14715+
tbl->fc_npiv_cfg.num_of_npiv = entries;
14716+
14717+
if (!tbl->fc_npiv_cfg.num_of_npiv) {
14718+
DP(BNX2X_MSG_MCP,
14719+
"No FC-NPIV table [valid, simply not present]\n");
14720+
goto out;
14721+
} else if (tbl->fc_npiv_cfg.num_of_npiv > MAX_NUMBER_NPIV) {
14722+
BNX2X_ERR("FC-NPIV table with bad length 0x%08x\n",
14723+
tbl->fc_npiv_cfg.num_of_npiv);
14724+
goto out;
14725+
} else {
14726+
DP(BNX2X_MSG_MCP, "Read 0x%08x entries from NVRAM\n",
14727+
tbl->fc_npiv_cfg.num_of_npiv);
14728+
}
14729+
14730+
/* Copy the data into cnic-provided struct */
14731+
cnic_tbl->count = tbl->fc_npiv_cfg.num_of_npiv;
14732+
for (i = 0; i < cnic_tbl->count; i++) {
14733+
memcpy(cnic_tbl->wwpn[i], tbl->settings[i].npiv_wwpn, 8);
14734+
memcpy(cnic_tbl->wwnn[i], tbl->settings[i].npiv_wwnn, 8);
14735+
}
14736+
14737+
rc = 0;
14738+
out:
14739+
kfree(tbl);
1465614740
return rc;
1465714741
}
1465814742

@@ -14798,6 +14882,7 @@ static struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev)
1479814882
cp->starting_cid = bnx2x_cid_ilt_lines(bp) * ILT_PAGE_CIDS;
1479914883
cp->drv_submit_kwqes_16 = bnx2x_cnic_sp_queue;
1480014884
cp->drv_ctl = bnx2x_drv_ctl;
14885+
cp->drv_get_fc_npiv_tbl = bnx2x_get_fc_npiv;
1480114886
cp->drv_register_cnic = bnx2x_register_cnic;
1480214887
cp->drv_unregister_cnic = bnx2x_unregister_cnic;
1480314888
cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp);

0 commit comments

Comments
 (0)