Skip to content

Commit 2971ff6

Browse files
joecar-davem330
authored andcommitted
bnx2fc: Read npiv table from nvram and create vports.
Signed-off-by: Joe Carnuccio <[email protected]> Signed-off-by: Chad Dupuis <[email protected]> Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 97ac4ef commit 2971ff6

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,9 +2051,49 @@ static int bnx2fc_disable(struct net_device *netdev)
20512051
return rc;
20522052
}
20532053

2054+
static uint bnx2fc_npiv_create_vports(struct fc_lport *lport,
2055+
struct cnic_fc_npiv_tbl *npiv_tbl)
2056+
{
2057+
struct fc_vport_identifiers vpid;
2058+
uint i, created = 0;
2059+
2060+
if (npiv_tbl->count > MAX_NPIV_ENTRIES) {
2061+
BNX2FC_HBA_DBG(lport, "Exceeded count max of npiv table\n");
2062+
goto done;
2063+
}
2064+
2065+
/* Sanity check the first entry to make sure it's not 0 */
2066+
if (wwn_to_u64(npiv_tbl->wwnn[0]) == 0 &&
2067+
wwn_to_u64(npiv_tbl->wwpn[0]) == 0) {
2068+
BNX2FC_HBA_DBG(lport, "First NPIV table entries invalid.\n");
2069+
goto done;
2070+
}
2071+
2072+
vpid.roles = FC_PORT_ROLE_FCP_INITIATOR;
2073+
vpid.vport_type = FC_PORTTYPE_NPIV;
2074+
vpid.disable = false;
2075+
2076+
for (i = 0; i < npiv_tbl->count; i++) {
2077+
vpid.node_name = wwn_to_u64(npiv_tbl->wwnn[i]);
2078+
vpid.port_name = wwn_to_u64(npiv_tbl->wwpn[i]);
2079+
scnprintf(vpid.symbolic_name, sizeof(vpid.symbolic_name),
2080+
"NPIV[%u]:%016llx-%016llx",
2081+
created, vpid.port_name, vpid.node_name);
2082+
if (fc_vport_create(lport->host, 0, &vpid))
2083+
created++;
2084+
else
2085+
BNX2FC_HBA_DBG(lport, "Failed to create vport\n");
2086+
}
2087+
done:
2088+
return created;
2089+
}
2090+
20542091
static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
20552092
{
20562093
struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
2094+
struct bnx2fc_hba *hba;
2095+
struct cnic_fc_npiv_tbl npiv_tbl;
2096+
struct fc_lport *lport;
20572097

20582098
if (interface->enabled == false) {
20592099
if (!ctlr->lp) {
@@ -2064,6 +2104,32 @@ static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
20642104
interface->enabled = true;
20652105
}
20662106
}
2107+
2108+
/* Create static NPIV ports if any are contained in NVRAM */
2109+
hba = interface->hba;
2110+
lport = ctlr->lp;
2111+
2112+
if (!hba)
2113+
goto done;
2114+
2115+
if (!hba->cnic)
2116+
goto done;
2117+
2118+
if (!lport)
2119+
goto done;
2120+
2121+
if (!lport->host)
2122+
goto done;
2123+
2124+
if (!hba->cnic->get_fc_npiv_tbl)
2125+
goto done;
2126+
2127+
memset(&npiv_tbl, 0, sizeof(npiv_tbl));
2128+
if (hba->cnic->get_fc_npiv_tbl(hba->cnic, &npiv_tbl))
2129+
goto done;
2130+
2131+
bnx2fc_npiv_create_vports(lport, &npiv_tbl);
2132+
done:
20672133
return 0;
20682134
}
20692135

0 commit comments

Comments
 (0)