aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
authorJames Smart <james.smart@emulex.com>2015-04-07 15:07:19 -0400
committerJames Bottomley <JBottomley@Odin.com>2015-04-10 10:48:57 -0400
commit76b2c34aeb947a649e52e0f03f5b930ef936e506 (patch)
tree20839e989304d204a320e92ed31dda8c269e584b /drivers/scsi/lpfc
parentf0bf5f91908f7c8819d4111c7bd793178021aa3f (diff)
lpfc: Fix FDMI Fabric support in driver for Brocade
Signed-off-by: Dick Kennedy <dick.kennedy@emulex.com> Signed-off-by: James Smart <james.smart@emulex.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc.h3
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c16
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c715
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c6
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h206
6 files changed, 650 insertions, 298 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 434e9037908e..922e59dfa1f4 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -413,6 +413,9 @@ struct lpfc_vport {
413 uint32_t cfg_fcp_class; 413 uint32_t cfg_fcp_class;
414 uint32_t cfg_use_adisc; 414 uint32_t cfg_use_adisc;
415 uint32_t cfg_fdmi_on; 415 uint32_t cfg_fdmi_on;
416#define LPFC_FDMI_SUPPORT 1 /* bit 0 - FDMI supported? */
417#define LPFC_FDMI_REG_DELAY 2 /* bit 1 - 60 sec registration delay */
418#define LPFC_FDMI_ALL_ATTRIB 4 /* bit 2 - register ALL attributes? */
416 uint32_t cfg_discovery_threads; 419 uint32_t cfg_discovery_threads;
417 uint32_t cfg_log_verbose; 420 uint32_t cfg_log_verbose;
418 uint32_t cfg_max_luns; 421 uint32_t cfg_max_luns;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 374aa03d91e8..faf0e8c575a5 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4573,12 +4573,18 @@ LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
4573 4573
4574/* 4574/*
4575# lpfc_fdmi_on: controls FDMI support. 4575# lpfc_fdmi_on: controls FDMI support.
4576# 0 = no FDMI support 4576# Set NOT Set
4577# 1 = support FDMI without attribute of hostname 4577# bit 0 = FDMI support no FDMI support
4578# 2 = support FDMI with attribute of hostname 4578# LPFC_FDMI_SUPPORT just turns basic support on/off
4579# Value range [0,2]. Default value is 0. 4579# bit 1 = Register delay no register delay (60 seconds)
4580# LPFC_FDMI_REG_DELAY 60 sec registration delay after FDMI login
4581# bit 2 = All attributes Use a attribute subset
4582# LPFC_FDMI_ALL_ATTRIB applies to both port and HBA attributes
4583# Port attrutes subset: 1 thru 6 OR all: 1 thru 0xd 0x101 0x102 0x103
4584# HBA attributes subset: 1 thru 0xb OR all: 1 thru 0xc
4585# Value range [0,7]. Default value is 0.
4580*/ 4586*/
4581LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); 4587LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 7, "Enable FDMI support");
4582 4588
4583/* 4589/*
4584# Specifies the maximum number of ELS cmds we can have outstanding (for 4590# Specifies the maximum number of ELS cmds we can have outstanding (for
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 5fb431a51588..593c02754736 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -555,7 +555,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
555 } 555 }
556 } 556 }
557 } 557 }
558 if (CTentry & (be32_to_cpu(SLI_CT_LAST_ENTRY))) 558 if (CTentry & (cpu_to_be32(SLI_CT_LAST_ENTRY)))
559 goto nsout1; 559 goto nsout1;
560 Cnt -= sizeof (uint32_t); 560 Cnt -= sizeof (uint32_t);
561 } 561 }
@@ -641,7 +641,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
641 /* Good status, continue checking */ 641 /* Good status, continue checking */
642 CTrsp = (struct lpfc_sli_ct_request *) outp->virt; 642 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
643 if (CTrsp->CommandResponse.bits.CmdRsp == 643 if (CTrsp->CommandResponse.bits.CmdRsp ==
644 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { 644 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
645 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 645 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
646 "0208 NameServer Rsp Data: x%x\n", 646 "0208 NameServer Rsp Data: x%x\n",
647 vport->fc_flag); 647 vport->fc_flag);
@@ -1096,6 +1096,26 @@ lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
1096 return n; 1096 return n;
1097} 1097}
1098 1098
1099static uint32_t
1100lpfc_find_map_node(struct lpfc_vport *vport)
1101{
1102 struct lpfc_nodelist *ndlp, *next_ndlp;
1103 struct Scsi_Host *shost;
1104 uint32_t cnt = 0;
1105
1106 shost = lpfc_shost_from_vport(vport);
1107 spin_lock_irq(shost->host_lock);
1108 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
1109 if (ndlp->nlp_type & NLP_FABRIC)
1110 continue;
1111 if ((ndlp->nlp_state == NLP_STE_MAPPED_NODE) ||
1112 (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE))
1113 cnt++;
1114 }
1115 spin_unlock_irq(shost->host_lock);
1116 return cnt;
1117}
1118
1099/* 1119/*
1100 * lpfc_ns_cmd 1120 * lpfc_ns_cmd
1101 * Description: 1121 * Description:
@@ -1194,7 +1214,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1194 switch (cmdcode) { 1214 switch (cmdcode) {
1195 case SLI_CTNS_GID_FT: 1215 case SLI_CTNS_GID_FT:
1196 CtReq->CommandResponse.bits.CmdRsp = 1216 CtReq->CommandResponse.bits.CmdRsp =
1197 be16_to_cpu(SLI_CTNS_GID_FT); 1217 cpu_to_be16(SLI_CTNS_GID_FT);
1198 CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; 1218 CtReq->un.gid.Fc4Type = SLI_CTPT_FCP;
1199 if (vport->port_state < LPFC_NS_QRY) 1219 if (vport->port_state < LPFC_NS_QRY)
1200 vport->port_state = LPFC_NS_QRY; 1220 vport->port_state = LPFC_NS_QRY;
@@ -1205,7 +1225,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1205 1225
1206 case SLI_CTNS_GFF_ID: 1226 case SLI_CTNS_GFF_ID:
1207 CtReq->CommandResponse.bits.CmdRsp = 1227 CtReq->CommandResponse.bits.CmdRsp =
1208 be16_to_cpu(SLI_CTNS_GFF_ID); 1228 cpu_to_be16(SLI_CTNS_GFF_ID);
1209 CtReq->un.gff.PortId = cpu_to_be32(context); 1229 CtReq->un.gff.PortId = cpu_to_be32(context);
1210 cmpl = lpfc_cmpl_ct_cmd_gff_id; 1230 cmpl = lpfc_cmpl_ct_cmd_gff_id;
1211 break; 1231 break;
@@ -1213,7 +1233,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1213 case SLI_CTNS_RFT_ID: 1233 case SLI_CTNS_RFT_ID:
1214 vport->ct_flags &= ~FC_CT_RFT_ID; 1234 vport->ct_flags &= ~FC_CT_RFT_ID;
1215 CtReq->CommandResponse.bits.CmdRsp = 1235 CtReq->CommandResponse.bits.CmdRsp =
1216 be16_to_cpu(SLI_CTNS_RFT_ID); 1236 cpu_to_be16(SLI_CTNS_RFT_ID);
1217 CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); 1237 CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
1218 CtReq->un.rft.fcpReg = 1; 1238 CtReq->un.rft.fcpReg = 1;
1219 cmpl = lpfc_cmpl_ct_cmd_rft_id; 1239 cmpl = lpfc_cmpl_ct_cmd_rft_id;
@@ -1222,7 +1242,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1222 case SLI_CTNS_RNN_ID: 1242 case SLI_CTNS_RNN_ID:
1223 vport->ct_flags &= ~FC_CT_RNN_ID; 1243 vport->ct_flags &= ~FC_CT_RNN_ID;
1224 CtReq->CommandResponse.bits.CmdRsp = 1244 CtReq->CommandResponse.bits.CmdRsp =
1225 be16_to_cpu(SLI_CTNS_RNN_ID); 1245 cpu_to_be16(SLI_CTNS_RNN_ID);
1226 CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); 1246 CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID);
1227 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, 1247 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,
1228 sizeof (struct lpfc_name)); 1248 sizeof (struct lpfc_name));
@@ -1232,7 +1252,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1232 case SLI_CTNS_RSPN_ID: 1252 case SLI_CTNS_RSPN_ID:
1233 vport->ct_flags &= ~FC_CT_RSPN_ID; 1253 vport->ct_flags &= ~FC_CT_RSPN_ID;
1234 CtReq->CommandResponse.bits.CmdRsp = 1254 CtReq->CommandResponse.bits.CmdRsp =
1235 be16_to_cpu(SLI_CTNS_RSPN_ID); 1255 cpu_to_be16(SLI_CTNS_RSPN_ID);
1236 CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); 1256 CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID);
1237 size = sizeof(CtReq->un.rspn.symbname); 1257 size = sizeof(CtReq->un.rspn.symbname);
1238 CtReq->un.rspn.len = 1258 CtReq->un.rspn.len =
@@ -1243,7 +1263,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1243 case SLI_CTNS_RSNN_NN: 1263 case SLI_CTNS_RSNN_NN:
1244 vport->ct_flags &= ~FC_CT_RSNN_NN; 1264 vport->ct_flags &= ~FC_CT_RSNN_NN;
1245 CtReq->CommandResponse.bits.CmdRsp = 1265 CtReq->CommandResponse.bits.CmdRsp =
1246 be16_to_cpu(SLI_CTNS_RSNN_NN); 1266 cpu_to_be16(SLI_CTNS_RSNN_NN);
1247 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, 1267 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,
1248 sizeof (struct lpfc_name)); 1268 sizeof (struct lpfc_name));
1249 size = sizeof(CtReq->un.rsnn.symbname); 1269 size = sizeof(CtReq->un.rsnn.symbname);
@@ -1255,14 +1275,14 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1255 case SLI_CTNS_DA_ID: 1275 case SLI_CTNS_DA_ID:
1256 /* Implement DA_ID Nameserver request */ 1276 /* Implement DA_ID Nameserver request */
1257 CtReq->CommandResponse.bits.CmdRsp = 1277 CtReq->CommandResponse.bits.CmdRsp =
1258 be16_to_cpu(SLI_CTNS_DA_ID); 1278 cpu_to_be16(SLI_CTNS_DA_ID);
1259 CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); 1279 CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID);
1260 cmpl = lpfc_cmpl_ct_cmd_da_id; 1280 cmpl = lpfc_cmpl_ct_cmd_da_id;
1261 break; 1281 break;
1262 case SLI_CTNS_RFF_ID: 1282 case SLI_CTNS_RFF_ID:
1263 vport->ct_flags &= ~FC_CT_RFF_ID; 1283 vport->ct_flags &= ~FC_CT_RFF_ID;
1264 CtReq->CommandResponse.bits.CmdRsp = 1284 CtReq->CommandResponse.bits.CmdRsp =
1265 be16_to_cpu(SLI_CTNS_RFF_ID); 1285 cpu_to_be16(SLI_CTNS_RFF_ID);
1266 CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID); 1286 CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);
1267 CtReq->un.rff.fbits = FC4_FEATURE_INIT; 1287 CtReq->un.rff.fbits = FC4_FEATURE_INIT;
1268 CtReq->un.rff.type_code = FC_TYPE_FCP; 1288 CtReq->un.rff.type_code = FC_TYPE_FCP;
@@ -1316,7 +1336,6 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1316 uint32_t latt; 1336 uint32_t latt;
1317 1337
1318 latt = lpfc_els_chk_latt(vport); 1338 latt = lpfc_els_chk_latt(vport);
1319
1320 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 1339 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1321 "FDMI cmpl: status:x%x/x%x latt:%d", 1340 "FDMI cmpl: status:x%x/x%x latt:%d",
1322 irsp->ulpStatus, irsp->un.ulpWord[4], latt); 1341 irsp->ulpStatus, irsp->un.ulpWord[4], latt);
@@ -1327,29 +1346,49 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1327 "ulpStatus: x%x, rid x%x\n", 1346 "ulpStatus: x%x, rid x%x\n",
1328 be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, 1347 be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus,
1329 irsp->un.ulpWord[4]); 1348 irsp->un.ulpWord[4]);
1330 lpfc_ct_free_iocb(phba, cmdiocb); 1349 goto fail_out;
1331 return;
1332 } 1350 }
1333 1351
1334 ndlp = lpfc_findnode_did(vport, FDMI_DID); 1352 ndlp = lpfc_findnode_did(vport, FDMI_DID);
1335 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) 1353 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
1336 goto fail_out; 1354 goto fail_out;
1337 1355
1338 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { 1356 if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {
1339 /* FDMI rsp failed */ 1357 /* FDMI rsp failed */
1340 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1358 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1341 "0220 FDMI rsp failed Data: x%x\n", 1359 "0220 FDMI rsp failed Data: x%x\n",
1342 be16_to_cpu(fdmi_cmd)); 1360 be16_to_cpu(fdmi_cmd));
1343 } 1361 }
1344 1362
1363fail_out:
1364 lpfc_ct_free_iocb(phba, cmdiocb);
1365}
1366
1367static void
1368lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1369 struct lpfc_iocbq *rspiocb)
1370{
1371 struct lpfc_vport *vport = cmdiocb->vport;
1372 struct lpfc_dmabuf *inp = cmdiocb->context1;
1373 struct lpfc_sli_ct_request *CTcmd = inp->virt;
1374 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
1375 struct lpfc_nodelist *ndlp;
1376
1377 lpfc_cmpl_ct_cmd_fdmi(phba, cmdiocb, rspiocb);
1378
1379 ndlp = lpfc_findnode_did(vport, FDMI_DID);
1380 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
1381 return;
1382
1383 /*
1384 * Need to cycle thru FDMI registration for discovery
1385 * DHBA -> DPRT -> RHBA -> RPA
1386 */
1345 switch (be16_to_cpu(fdmi_cmd)) { 1387 switch (be16_to_cpu(fdmi_cmd)) {
1346 case SLI_MGMT_RHBA: 1388 case SLI_MGMT_RHBA:
1347 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA); 1389 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA);
1348 break; 1390 break;
1349 1391
1350 case SLI_MGMT_RPA:
1351 break;
1352
1353 case SLI_MGMT_DHBA: 1392 case SLI_MGMT_DHBA:
1354 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT); 1393 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT);
1355 break; 1394 break;
@@ -1358,12 +1397,9 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1358 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); 1397 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA);
1359 break; 1398 break;
1360 } 1399 }
1361
1362fail_out:
1363 lpfc_ct_free_iocb(phba, cmdiocb);
1364 return;
1365} 1400}
1366 1401
1402
1367int 1403int
1368lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) 1404lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1369{ 1405{
@@ -1372,18 +1408,28 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1372 struct lpfc_sli_ct_request *CtReq; 1408 struct lpfc_sli_ct_request *CtReq;
1373 struct ulp_bde64 *bpl; 1409 struct ulp_bde64 *bpl;
1374 uint32_t size; 1410 uint32_t size;
1375 REG_HBA *rh; 1411 uint32_t rsp_size;
1376 PORT_ENTRY *pe; 1412 struct lpfc_fdmi_reg_hba *rh;
1377 REG_PORT_ATTRIBUTE *pab; 1413 struct lpfc_fdmi_port_entry *pe;
1378 ATTRIBUTE_BLOCK *ab; 1414 struct lpfc_fdmi_reg_portattr *pab = NULL;
1379 ATTRIBUTE_ENTRY *ae; 1415 struct lpfc_fdmi_attr_block *ab = NULL;
1416 struct lpfc_fdmi_attr_entry *ae;
1417 struct lpfc_fdmi_attr_def *ad;
1380 void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, 1418 void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
1381 struct lpfc_iocbq *); 1419 struct lpfc_iocbq *);
1382 1420
1421 if (ndlp == NULL) {
1422 ndlp = lpfc_findnode_did(vport, FDMI_DID);
1423 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
1424 return 0;
1425 cmpl = lpfc_cmpl_ct_cmd_fdmi; /* cmd interface */
1426 } else {
1427 cmpl = lpfc_cmpl_ct_disc_fdmi; /* called from discovery */
1428 }
1383 1429
1384 /* fill in BDEs for command */ 1430 /* fill in BDEs for command */
1385 /* Allocate buffer for command payload */ 1431 /* Allocate buffer for command payload */
1386 mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); 1432 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
1387 if (!mp) 1433 if (!mp)
1388 goto fdmi_cmd_exit; 1434 goto fdmi_cmd_exit;
1389 1435
@@ -1392,7 +1438,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1392 goto fdmi_cmd_free_mp; 1438 goto fdmi_cmd_free_mp;
1393 1439
1394 /* Allocate buffer for Buffer ptr list */ 1440 /* Allocate buffer for Buffer ptr list */
1395 bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); 1441 bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
1396 if (!bmp) 1442 if (!bmp)
1397 goto fdmi_cmd_free_mpvirt; 1443 goto fdmi_cmd_free_mpvirt;
1398 1444
@@ -1407,205 +1453,330 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1407 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1453 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1408 "0218 FDMI Request Data: x%x x%x x%x\n", 1454 "0218 FDMI Request Data: x%x x%x x%x\n",
1409 vport->fc_flag, vport->port_state, cmdcode); 1455 vport->fc_flag, vport->port_state, cmdcode);
1410 CtReq = (struct lpfc_sli_ct_request *) mp->virt; 1456 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
1411 1457
1458 /* First populate the CT_IU preamble */
1412 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); 1459 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request));
1413 CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; 1460 CtReq->RevisionId.bits.Revision = SLI_CT_REVISION;
1414 CtReq->RevisionId.bits.InId = 0; 1461 CtReq->RevisionId.bits.InId = 0;
1415 1462
1416 CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; 1463 CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE;
1417 CtReq->FsSubType = SLI_CT_FDMI_Subtypes; 1464 CtReq->FsSubType = SLI_CT_FDMI_Subtypes;
1465
1466 CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode);
1467 rsp_size = LPFC_BPL_SIZE;
1418 size = 0; 1468 size = 0;
1419 1469
1470 /* Next fill in the specific FDMI cmd information */
1420 switch (cmdcode) { 1471 switch (cmdcode) {
1472 case SLI_MGMT_RHAT:
1421 case SLI_MGMT_RHBA: 1473 case SLI_MGMT_RHBA:
1422 { 1474 {
1423 lpfc_vpd_t *vp = &phba->vpd; 1475 lpfc_vpd_t *vp = &phba->vpd;
1424 uint32_t i, j, incr; 1476 uint32_t i, j, incr;
1425 int len; 1477 int len = 0;
1426 1478
1427 CtReq->CommandResponse.bits.CmdRsp = 1479 rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID;
1428 be16_to_cpu(SLI_MGMT_RHBA); 1480 /* HBA Identifier */
1429 CtReq->CommandResponse.bits.Size = 0;
1430 rh = (REG_HBA *) & CtReq->un.PortID;
1431 memcpy(&rh->hi.PortName, &vport->fc_sparam.portName, 1481 memcpy(&rh->hi.PortName, &vport->fc_sparam.portName,
1432 sizeof (struct lpfc_name)); 1482 sizeof(struct lpfc_name));
1433 /* One entry (port) per adapter */ 1483
1434 rh->rpl.EntryCnt = be32_to_cpu(1); 1484 if (cmdcode == SLI_MGMT_RHBA) {
1435 memcpy(&rh->rpl.pe, &vport->fc_sparam.portName, 1485 /* Registered Port List */
1436 sizeof (struct lpfc_name)); 1486 /* One entry (port) per adapter */
1437 1487 rh->rpl.EntryCnt = cpu_to_be32(1);
1438 /* point to the HBA attribute block */ 1488 memcpy(&rh->rpl.pe, &vport->fc_sparam.portName,
1439 size = 2 * sizeof (struct lpfc_name) + FOURBYTES; 1489 sizeof(struct lpfc_name));
1440 ab = (ATTRIBUTE_BLOCK *) ((uint8_t *) rh + size); 1490
1491 /* point to the HBA attribute block */
1492 size = 2 * sizeof(struct lpfc_name) +
1493 FOURBYTES;
1494 } else {
1495 size = sizeof(struct lpfc_name);
1496 }
1497 ab = (struct lpfc_fdmi_attr_block *)
1498 ((uint8_t *)rh + size);
1441 ab->EntryCnt = 0; 1499 ab->EntryCnt = 0;
1500 size += FOURBYTES;
1442 1501
1443 /* Point to the beginning of the first HBA attribute 1502 /*
1444 entry */ 1503 * Point to beginning of first HBA attribute entry
1504 */
1445 /* #1 HBA attribute entry */ 1505 /* #1 HBA attribute entry */
1446 size += FOURBYTES; 1506 ad = (struct lpfc_fdmi_attr_def *)
1447 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1507 ((uint8_t *)rh + size);
1448 ae->ad.bits.AttrType = be16_to_cpu(NODE_NAME); 1508 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1449 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES 1509 memset(ae, 0, sizeof(struct lpfc_name));
1450 + sizeof (struct lpfc_name)); 1510 ad->AttrType = cpu_to_be16(RHBA_NODENAME);
1511 ad->AttrLen = cpu_to_be16(FOURBYTES
1512 + sizeof(struct lpfc_name));
1451 memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, 1513 memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName,
1452 sizeof (struct lpfc_name)); 1514 sizeof(struct lpfc_name));
1453 ab->EntryCnt++; 1515 ab->EntryCnt++;
1454 size += FOURBYTES + sizeof (struct lpfc_name); 1516 size += FOURBYTES + sizeof(struct lpfc_name);
1517 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1518 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1519 goto hba_out;
1455 1520
1456 /* #2 HBA attribute entry */ 1521 /* #2 HBA attribute entry */
1457 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1522 ad = (struct lpfc_fdmi_attr_def *)
1458 ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); 1523 ((uint8_t *)rh + size);
1459 strncpy(ae->un.Manufacturer, "Emulex Corporation", 64); 1524 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1460 len = strlen(ae->un.Manufacturer); 1525 memset(ae, 0, sizeof(ae->un.Manufacturer));
1526 ad->AttrType = cpu_to_be16(RHBA_MANUFACTURER);
1527 strncpy(ae->un.Manufacturer, "Emulex Corporation",
1528 sizeof(ae->un.Manufacturer));
1529 len = strnlen(ae->un.Manufacturer,
1530 sizeof(ae->un.Manufacturer));
1461 len += (len & 3) ? (4 - (len & 3)) : 4; 1531 len += (len & 3) ? (4 - (len & 3)) : 4;
1462 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1532 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1463 ab->EntryCnt++; 1533 ab->EntryCnt++;
1464 size += FOURBYTES + len; 1534 size += FOURBYTES + len;
1535 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1536 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1537 goto hba_out;
1465 1538
1466 /* #3 HBA attribute entry */ 1539 /* #3 HBA attribute entry */
1467 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1540 ad = (struct lpfc_fdmi_attr_def *)
1468 ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); 1541 ((uint8_t *)rh + size);
1469 strncpy(ae->un.SerialNumber, phba->SerialNumber, 64); 1542 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1470 len = strlen(ae->un.SerialNumber); 1543 memset(ae, 0, sizeof(ae->un.SerialNumber));
1544 ad->AttrType = cpu_to_be16(RHBA_SERIAL_NUMBER);
1545 strncpy(ae->un.SerialNumber, phba->SerialNumber,
1546 sizeof(ae->un.SerialNumber));
1547 len = strnlen(ae->un.SerialNumber,
1548 sizeof(ae->un.SerialNumber));
1471 len += (len & 3) ? (4 - (len & 3)) : 4; 1549 len += (len & 3) ? (4 - (len & 3)) : 4;
1472 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1550 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1473 ab->EntryCnt++; 1551 ab->EntryCnt++;
1474 size += FOURBYTES + len; 1552 size += FOURBYTES + len;
1553 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1554 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1555 goto hba_out;
1475 1556
1476 /* #4 HBA attribute entry */ 1557 /* #4 HBA attribute entry */
1477 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1558 ad = (struct lpfc_fdmi_attr_def *)
1478 ae->ad.bits.AttrType = be16_to_cpu(MODEL); 1559 ((uint8_t *)rh + size);
1479 strncpy(ae->un.Model, phba->ModelName, 256); 1560 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1480 len = strlen(ae->un.Model); 1561 memset(ae, 0, sizeof(ae->un.Model));
1562 ad->AttrType = cpu_to_be16(RHBA_MODEL);
1563 strncpy(ae->un.Model, phba->ModelName,
1564 sizeof(ae->un.Model));
1565 len = strnlen(ae->un.Model, sizeof(ae->un.Model));
1481 len += (len & 3) ? (4 - (len & 3)) : 4; 1566 len += (len & 3) ? (4 - (len & 3)) : 4;
1482 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1567 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1483 ab->EntryCnt++; 1568 ab->EntryCnt++;
1484 size += FOURBYTES + len; 1569 size += FOURBYTES + len;
1570 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1571 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1572 goto hba_out;
1485 1573
1486 /* #5 HBA attribute entry */ 1574 /* #5 HBA attribute entry */
1487 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1575 ad = (struct lpfc_fdmi_attr_def *)
1488 ae->ad.bits.AttrType = be16_to_cpu(MODEL_DESCRIPTION); 1576 ((uint8_t *)rh + size);
1489 strncpy(ae->un.ModelDescription, phba->ModelDesc, 256); 1577 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1490 len = strlen(ae->un.ModelDescription); 1578 memset(ae, 0, sizeof(ae->un.ModelDescription));
1579 ad->AttrType = cpu_to_be16(RHBA_MODEL_DESCRIPTION);
1580 strncpy(ae->un.ModelDescription, phba->ModelDesc,
1581 sizeof(ae->un.ModelDescription));
1582 len = strnlen(ae->un.ModelDescription,
1583 sizeof(ae->un.ModelDescription));
1491 len += (len & 3) ? (4 - (len & 3)) : 4; 1584 len += (len & 3) ? (4 - (len & 3)) : 4;
1492 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1585 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1493 ab->EntryCnt++; 1586 ab->EntryCnt++;
1494 size += FOURBYTES + len; 1587 size += FOURBYTES + len;
1588 if ((size + 8) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1589 goto hba_out;
1495 1590
1496 /* #6 HBA attribute entry */ 1591 /* #6 HBA attribute entry */
1497 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1592 ad = (struct lpfc_fdmi_attr_def *)
1498 ae->ad.bits.AttrType = be16_to_cpu(HARDWARE_VERSION); 1593 ((uint8_t *)rh + size);
1499 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 8); 1594 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1595 memset(ae, 0, 8);
1596 ad->AttrType = cpu_to_be16(RHBA_HARDWARE_VERSION);
1597 ad->AttrLen = cpu_to_be16(FOURBYTES + 8);
1500 /* Convert JEDEC ID to ascii for hardware version */ 1598 /* Convert JEDEC ID to ascii for hardware version */
1501 incr = vp->rev.biuRev; 1599 incr = vp->rev.biuRev;
1502 for (i = 0; i < 8; i++) { 1600 for (i = 0; i < 8; i++) {
1503 j = (incr & 0xf); 1601 j = (incr & 0xf);
1504 if (j <= 9) 1602 if (j <= 9)
1505 ae->un.HardwareVersion[7 - i] = 1603 ae->un.HardwareVersion[7 - i] =
1506 (char)((uint8_t) 0x30 + 1604 (char)((uint8_t)0x30 +
1507 (uint8_t) j); 1605 (uint8_t)j);
1508 else 1606 else
1509 ae->un.HardwareVersion[7 - i] = 1607 ae->un.HardwareVersion[7 - i] =
1510 (char)((uint8_t) 0x61 + 1608 (char)((uint8_t)0x61 +
1511 (uint8_t) (j - 10)); 1609 (uint8_t)(j - 10));
1512 incr = (incr >> 4); 1610 incr = (incr >> 4);
1513 } 1611 }
1514 ab->EntryCnt++; 1612 ab->EntryCnt++;
1515 size += FOURBYTES + 8; 1613 size += FOURBYTES + 8;
1614 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1615 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1616 goto hba_out;
1516 1617
1517 /* #7 HBA attribute entry */ 1618 /* #7 HBA attribute entry */
1518 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1619 ad = (struct lpfc_fdmi_attr_def *)
1519 ae->ad.bits.AttrType = be16_to_cpu(DRIVER_VERSION); 1620 ((uint8_t *)rh + size);
1520 strncpy(ae->un.DriverVersion, 1621 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1521 lpfc_release_version, 256); 1622 memset(ae, 0, sizeof(ae->un.DriverVersion));
1522 len = strlen(ae->un.DriverVersion); 1623 ad->AttrType = cpu_to_be16(RHBA_DRIVER_VERSION);
1624 strncpy(ae->un.DriverVersion, lpfc_release_version,
1625 sizeof(ae->un.DriverVersion));
1626 len = strnlen(ae->un.DriverVersion,
1627 sizeof(ae->un.DriverVersion));
1523 len += (len & 3) ? (4 - (len & 3)) : 4; 1628 len += (len & 3) ? (4 - (len & 3)) : 4;
1524 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1629 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1525 ab->EntryCnt++; 1630 ab->EntryCnt++;
1526 size += FOURBYTES + len; 1631 size += FOURBYTES + len;
1632 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1633 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1634 goto hba_out;
1527 1635
1528 /* #8 HBA attribute entry */ 1636 /* #8 HBA attribute entry */
1529 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1637 ad = (struct lpfc_fdmi_attr_def *)
1530 ae->ad.bits.AttrType = be16_to_cpu(OPTION_ROM_VERSION); 1638 ((uint8_t *)rh + size);
1531 strncpy(ae->un.OptionROMVersion, 1639 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1532 phba->OptionROMVersion, 256); 1640 memset(ae, 0, sizeof(ae->un.OptionROMVersion));
1533 len = strlen(ae->un.OptionROMVersion); 1641 ad->AttrType = cpu_to_be16(RHBA_OPTION_ROM_VERSION);
1642 strncpy(ae->un.OptionROMVersion, phba->OptionROMVersion,
1643 sizeof(ae->un.OptionROMVersion));
1644 len = strnlen(ae->un.OptionROMVersion,
1645 sizeof(ae->un.OptionROMVersion));
1534 len += (len & 3) ? (4 - (len & 3)) : 4; 1646 len += (len & 3) ? (4 - (len & 3)) : 4;
1535 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1647 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1536 ab->EntryCnt++; 1648 ab->EntryCnt++;
1537 size += FOURBYTES + len; 1649 size += FOURBYTES + len;
1650 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1651 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1652 goto hba_out;
1538 1653
1539 /* #9 HBA attribute entry */ 1654 /* #9 HBA attribute entry */
1540 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1655 ad = (struct lpfc_fdmi_attr_def *)
1541 ae->ad.bits.AttrType = be16_to_cpu(FIRMWARE_VERSION); 1656 ((uint8_t *)rh + size);
1657 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1658 memset(ae, 0, sizeof(ae->un.FirmwareVersion));
1659 ad->AttrType = cpu_to_be16(RHBA_FIRMWARE_VERSION);
1542 lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, 1660 lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion,
1543 1); 1661 1);
1544 len = strlen(ae->un.FirmwareVersion); 1662 len = strnlen(ae->un.FirmwareVersion,
1663 sizeof(ae->un.FirmwareVersion));
1545 len += (len & 3) ? (4 - (len & 3)) : 4; 1664 len += (len & 3) ? (4 - (len & 3)) : 4;
1546 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1665 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1547 ab->EntryCnt++; 1666 ab->EntryCnt++;
1548 size += FOURBYTES + len; 1667 size += FOURBYTES + len;
1668 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1669 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1670 goto hba_out;
1549 1671
1550 /* #10 HBA attribute entry */ 1672 /* #10 HBA attribute entry */
1551 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1673 ad = (struct lpfc_fdmi_attr_def *)
1552 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); 1674 ((uint8_t *)rh + size);
1553 sprintf(ae->un.OsNameVersion, "%s %s %s", 1675 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1554 init_utsname()->sysname, 1676 memset(ae, 0, sizeof(ae->un.OsNameVersion));
1555 init_utsname()->release, 1677 ad->AttrType = cpu_to_be16(RHBA_OS_NAME_VERSION);
1556 init_utsname()->version); 1678 snprintf(ae->un.OsNameVersion,
1557 len = strlen(ae->un.OsNameVersion); 1679 sizeof(ae->un.OsNameVersion),
1680 "%s %s %s",
1681 init_utsname()->sysname,
1682 init_utsname()->release,
1683 init_utsname()->version);
1684 len = strnlen(ae->un.OsNameVersion,
1685 sizeof(ae->un.OsNameVersion));
1558 len += (len & 3) ? (4 - (len & 3)) : 4; 1686 len += (len & 3) ? (4 - (len & 3)) : 4;
1559 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1687 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1560 ab->EntryCnt++; 1688 ab->EntryCnt++;
1561 size += FOURBYTES + len; 1689 size += FOURBYTES + len;
1690 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1691 goto hba_out;
1562 1692
1563 /* #11 HBA attribute entry */ 1693 /* #11 HBA attribute entry */
1564 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 1694 ad = (struct lpfc_fdmi_attr_def *)
1565 ae->ad.bits.AttrType = be16_to_cpu(MAX_CT_PAYLOAD_LEN); 1695 ((uint8_t *)rh + size);
1566 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); 1696 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1567 ae->un.MaxCTPayloadLen = (65 * 4096); 1697 ad->AttrType =
1698 cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN);
1699 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1700 ae->un.MaxCTPayloadLen = cpu_to_be32(LPFC_MAX_CT_SIZE);
1568 ab->EntryCnt++; 1701 ab->EntryCnt++;
1569 size += FOURBYTES + 4; 1702 size += FOURBYTES + 4;
1703 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1704 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1705 goto hba_out;
1570 1706
1571 ab->EntryCnt = be32_to_cpu(ab->EntryCnt); 1707 /*
1708 * Currently switches don't seem to support the
1709 * following extended HBA attributes.
1710 */
1711 if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB))
1712 goto hba_out;
1713
1714 /* #12 HBA attribute entry */
1715 ad = (struct lpfc_fdmi_attr_def *)
1716 ((uint8_t *)rh + size);
1717 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1718 memset(ae, 0, sizeof(ae->un.NodeSymName));
1719 ad->AttrType = cpu_to_be16(RHBA_SYM_NODENAME);
1720 len = lpfc_vport_symbolic_node_name(vport,
1721 ae->un.NodeSymName, sizeof(ae->un.NodeSymName));
1722 len += (len & 3) ? (4 - (len & 3)) : 4;
1723 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1724 ab->EntryCnt++;
1725 size += FOURBYTES + len;
1726hba_out:
1727 ab->EntryCnt = cpu_to_be32(ab->EntryCnt);
1572 /* Total size */ 1728 /* Total size */
1573 size = GID_REQUEST_SZ - 4 + size; 1729 size = GID_REQUEST_SZ - 4 + size;
1574 } 1730 }
1575 break; 1731 break;
1576 1732
1733 case SLI_MGMT_RPRT:
1577 case SLI_MGMT_RPA: 1734 case SLI_MGMT_RPA:
1578 { 1735 {
1579 lpfc_vpd_t *vp; 1736 lpfc_vpd_t *vp;
1580 struct serv_parm *hsp; 1737 struct serv_parm *hsp;
1581 int len; 1738 int len = 0;
1582 1739
1583 vp = &phba->vpd; 1740 vp = &phba->vpd;
1584 1741
1585 CtReq->CommandResponse.bits.CmdRsp = 1742 if (cmdcode == SLI_MGMT_RPRT) {
1586 be16_to_cpu(SLI_MGMT_RPA); 1743 rh = (struct lpfc_fdmi_reg_hba *)
1587 CtReq->CommandResponse.bits.Size = 0; 1744 &CtReq->un.PortID;
1588 pab = (REG_PORT_ATTRIBUTE *) & CtReq->un.PortID; 1745 /* HBA Identifier */
1589 size = sizeof (struct lpfc_name) + FOURBYTES; 1746 memcpy(&rh->hi.PortName,
1590 memcpy((uint8_t *) & pab->PortName, 1747 &vport->fc_sparam.portName,
1591 (uint8_t *) & vport->fc_sparam.portName, 1748 sizeof(struct lpfc_name));
1592 sizeof (struct lpfc_name)); 1749 pab = (struct lpfc_fdmi_reg_portattr *)
1750 &rh->rpl.EntryCnt;
1751 } else
1752 pab = (struct lpfc_fdmi_reg_portattr *)
1753 &CtReq->un.PortID;
1754 size = sizeof(struct lpfc_name) + FOURBYTES;
1755 memcpy((uint8_t *)&pab->PortName,
1756 (uint8_t *)&vport->fc_sparam.portName,
1757 sizeof(struct lpfc_name));
1593 pab->ab.EntryCnt = 0; 1758 pab->ab.EntryCnt = 0;
1594 1759
1595 /* #1 Port attribute entry */ 1760 /* #1 Port attribute entry */
1596 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); 1761 ad = (struct lpfc_fdmi_attr_def *)
1597 ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_FC4_TYPES); 1762 ((uint8_t *)pab + size);
1598 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 32); 1763 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1599 ae->un.SupportFC4Types[2] = 1; 1764 memset(ae, 0, sizeof(ae->un.FC4Types));
1600 ae->un.SupportFC4Types[7] = 1; 1765 ad->AttrType =
1766 cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES);
1767 ad->AttrLen = cpu_to_be16(FOURBYTES + 32);
1768 ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */
1769 ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */
1770 ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */
1601 pab->ab.EntryCnt++; 1771 pab->ab.EntryCnt++;
1602 size += FOURBYTES + 32; 1772 size += FOURBYTES + 32;
1603 1773
1604 /* #2 Port attribute entry */ 1774 /* #2 Port attribute entry */
1605 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); 1775 ad = (struct lpfc_fdmi_attr_def *)
1606 ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_SPEED); 1776 ((uint8_t *)pab + size);
1607 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); 1777 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1608 1778 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_SPEED);
1779 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1609 ae->un.SupportSpeed = 0; 1780 ae->un.SupportSpeed = 0;
1610 if (phba->lmt & LMT_16Gb) 1781 if (phba->lmt & LMT_16Gb)
1611 ae->un.SupportSpeed |= HBA_PORTSPEED_16GBIT; 1782 ae->un.SupportSpeed |= HBA_PORTSPEED_16GBIT;
@@ -1619,15 +1790,19 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1619 ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; 1790 ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT;
1620 if (phba->lmt & LMT_1Gb) 1791 if (phba->lmt & LMT_1Gb)
1621 ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; 1792 ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT;
1793 ae->un.SupportSpeed =
1794 cpu_to_be32(ae->un.SupportSpeed);
1622 1795
1623 pab->ab.EntryCnt++; 1796 pab->ab.EntryCnt++;
1624 size += FOURBYTES + 4; 1797 size += FOURBYTES + 4;
1625 1798
1626 /* #3 Port attribute entry */ 1799 /* #3 Port attribute entry */
1627 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); 1800 ad = (struct lpfc_fdmi_attr_def *)
1628 ae->ad.bits.AttrType = be16_to_cpu(PORT_SPEED); 1801 ((uint8_t *)pab + size);
1629 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); 1802 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1630 switch(phba->fc_linkspeed) { 1803 ad->AttrType = cpu_to_be16(RPRT_PORT_SPEED);
1804 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1805 switch (phba->fc_linkspeed) {
1631 case LPFC_LINK_SPEED_1GHZ: 1806 case LPFC_LINK_SPEED_1GHZ:
1632 ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; 1807 ae->un.PortSpeed = HBA_PORTSPEED_1GBIT;
1633 break; 1808 break;
@@ -1650,93 +1825,273 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1650 ae->un.PortSpeed = HBA_PORTSPEED_UNKNOWN; 1825 ae->un.PortSpeed = HBA_PORTSPEED_UNKNOWN;
1651 break; 1826 break;
1652 } 1827 }
1828 ae->un.PortSpeed = cpu_to_be32(ae->un.PortSpeed);
1653 pab->ab.EntryCnt++; 1829 pab->ab.EntryCnt++;
1654 size += FOURBYTES + 4; 1830 size += FOURBYTES + 4;
1655 1831
1656 /* #4 Port attribute entry */ 1832 /* #4 Port attribute entry */
1657 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); 1833 ad = (struct lpfc_fdmi_attr_def *)
1658 ae->ad.bits.AttrType = be16_to_cpu(MAX_FRAME_SIZE); 1834 ((uint8_t *)pab + size);
1659 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); 1835 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1660 hsp = (struct serv_parm *) & vport->fc_sparam; 1836 ad->AttrType = cpu_to_be16(RPRT_MAX_FRAME_SIZE);
1837 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1838 hsp = (struct serv_parm *)&vport->fc_sparam;
1661 ae->un.MaxFrameSize = 1839 ae->un.MaxFrameSize =
1662 (((uint32_t) hsp->cmn. 1840 (((uint32_t)hsp->cmn.
1663 bbRcvSizeMsb) << 8) | (uint32_t) hsp->cmn. 1841 bbRcvSizeMsb) << 8) | (uint32_t)hsp->cmn.
1664 bbRcvSizeLsb; 1842 bbRcvSizeLsb;
1843 ae->un.MaxFrameSize =
1844 cpu_to_be32(ae->un.MaxFrameSize);
1665 pab->ab.EntryCnt++; 1845 pab->ab.EntryCnt++;
1666 size += FOURBYTES + 4; 1846 size += FOURBYTES + 4;
1847 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1848 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1849 goto port_out;
1667 1850
1668 /* #5 Port attribute entry */ 1851 /* #5 Port attribute entry */
1669 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); 1852 ad = (struct lpfc_fdmi_attr_def *)
1670 ae->ad.bits.AttrType = be16_to_cpu(OS_DEVICE_NAME); 1853 ((uint8_t *)pab + size);
1671 strcpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME); 1854 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1672 len = strlen((char *)ae->un.OsDeviceName); 1855 memset(ae, 0, sizeof(ae->un.OsDeviceName));
1856 ad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME);
1857 strncpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME,
1858 sizeof(ae->un.OsDeviceName));
1859 len = strnlen((char *)ae->un.OsDeviceName,
1860 sizeof(ae->un.OsDeviceName));
1673 len += (len & 3) ? (4 - (len & 3)) : 4; 1861 len += (len & 3) ? (4 - (len & 3)) : 4;
1674 ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); 1862 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1675 pab->ab.EntryCnt++; 1863 pab->ab.EntryCnt++;
1676 size += FOURBYTES + len; 1864 size += FOURBYTES + len;
1865 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1866 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1867 goto port_out;
1868
1869 /* #6 Port attribute entry */
1870 ad = (struct lpfc_fdmi_attr_def *)
1871 ((uint8_t *)pab + size);
1872 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1873 memset(ae, 0, sizeof(ae->un.HostName));
1874 snprintf(ae->un.HostName, sizeof(ae->un.HostName), "%s",
1875 init_utsname()->nodename);
1876 ad->AttrType = cpu_to_be16(RPRT_HOST_NAME);
1877 len = strnlen(ae->un.HostName,
1878 sizeof(ae->un.HostName));
1879 len += (len & 3) ? (4 - (len & 3)) : 4;
1880 ad->AttrLen =
1881 cpu_to_be16(FOURBYTES + len);
1882 pab->ab.EntryCnt++;
1883 size += FOURBYTES + len;
1884 if ((size + sizeof(struct lpfc_name)) >
1885 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1886 goto port_out;
1677 1887
1678 if (vport->cfg_fdmi_on == 2) { 1888 /*
1679 /* #6 Port attribute entry */ 1889 * Currently switches don't seem to support the
1680 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + 1890 * following extended Port attributes.
1681 size); 1891 */
1682 ae->ad.bits.AttrType = be16_to_cpu(HOST_NAME); 1892 if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB))
1683 sprintf(ae->un.HostName, "%s", 1893 goto port_out;
1684 init_utsname()->nodename); 1894
1685 len = strlen(ae->un.HostName); 1895 /* #7 Port attribute entry */
1686 len += (len & 3) ? (4 - (len & 3)) : 4; 1896 ad = (struct lpfc_fdmi_attr_def *)
1687 ae->ad.bits.AttrLen = 1897 ((uint8_t *)pab + size);
1688 be16_to_cpu(FOURBYTES + len); 1898 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1689 pab->ab.EntryCnt++; 1899 memset(ae, 0, sizeof(struct lpfc_name));
1690 size += FOURBYTES + len; 1900 ad->AttrType = cpu_to_be16(RPRT_NODENAME);
1691 } 1901 ad->AttrLen = cpu_to_be16(FOURBYTES
1692 1902 + sizeof(struct lpfc_name));
1693 pab->ab.EntryCnt = be32_to_cpu(pab->ab.EntryCnt); 1903 memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName,
1904 sizeof(struct lpfc_name));
1905 pab->ab.EntryCnt++;
1906 size += FOURBYTES + sizeof(struct lpfc_name);
1907 if ((size + sizeof(struct lpfc_name)) >
1908 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1909 goto port_out;
1910
1911 /* #8 Port attribute entry */
1912 ad = (struct lpfc_fdmi_attr_def *)
1913 ((uint8_t *)pab + size);
1914 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1915 memset(ae, 0, sizeof(struct lpfc_name));
1916 ad->AttrType = cpu_to_be16(RPRT_PORTNAME);
1917 ad->AttrLen = cpu_to_be16(FOURBYTES
1918 + sizeof(struct lpfc_name));
1919 memcpy(&ae->un.PortName, &vport->fc_sparam.portName,
1920 sizeof(struct lpfc_name));
1921 pab->ab.EntryCnt++;
1922 size += FOURBYTES + sizeof(struct lpfc_name);
1923 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1924 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1925 goto port_out;
1926
1927 /* #9 Port attribute entry */
1928 ad = (struct lpfc_fdmi_attr_def *)
1929 ((uint8_t *)pab + size);
1930 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1931 memset(ae, 0, sizeof(ae->un.NodeSymName));
1932 ad->AttrType = cpu_to_be16(RPRT_SYM_PORTNAME);
1933 len = lpfc_vport_symbolic_port_name(vport,
1934 ae->un.NodeSymName, sizeof(ae->un.NodeSymName));
1935 len += (len & 3) ? (4 - (len & 3)) : 4;
1936 ad->AttrLen = cpu_to_be16(FOURBYTES + len);
1937 pab->ab.EntryCnt++;
1938 size += FOURBYTES + len;
1939 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1940 goto port_out;
1941
1942 /* #10 Port attribute entry */
1943 ad = (struct lpfc_fdmi_attr_def *)
1944 ((uint8_t *)pab + size);
1945 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1946 ad->AttrType = cpu_to_be16(RPRT_PORT_TYPE);
1947 ae->un.PortState = 0;
1948 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1949 pab->ab.EntryCnt++;
1950 size += FOURBYTES + 4;
1951 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1952 goto port_out;
1953
1954 /* #11 Port attribute entry */
1955 ad = (struct lpfc_fdmi_attr_def *)
1956 ((uint8_t *)pab + size);
1957 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1958 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_CLASS);
1959 ae->un.SupportClass =
1960 cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3);
1961 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
1962 pab->ab.EntryCnt++;
1963 size += FOURBYTES + 4;
1964 if ((size + sizeof(struct lpfc_name)) >
1965 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1966 goto port_out;
1967
1968 /* #12 Port attribute entry */
1969 ad = (struct lpfc_fdmi_attr_def *)
1970 ((uint8_t *)pab + size);
1971 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1972 memset(ae, 0, sizeof(struct lpfc_name));
1973 ad->AttrType = cpu_to_be16(RPRT_FABRICNAME);
1974 ad->AttrLen = cpu_to_be16(FOURBYTES
1975 + sizeof(struct lpfc_name));
1976 memcpy(&ae->un.FabricName, &vport->fabric_nodename,
1977 sizeof(struct lpfc_name));
1978 pab->ab.EntryCnt++;
1979 size += FOURBYTES + sizeof(struct lpfc_name);
1980 if ((size + LPFC_FDMI_MAX_AE_SIZE) >
1981 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1982 goto port_out;
1983
1984 /* #13 Port attribute entry */
1985 ad = (struct lpfc_fdmi_attr_def *)
1986 ((uint8_t *)pab + size);
1987 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
1988 memset(ae, 0, sizeof(ae->un.FC4Types));
1989 ad->AttrType =
1990 cpu_to_be16(RPRT_ACTIVE_FC4_TYPES);
1991 ad->AttrLen = cpu_to_be16(FOURBYTES + 32);
1992 ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */
1993 ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */
1994 ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */
1995 pab->ab.EntryCnt++;
1996 size += FOURBYTES + 32;
1997 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
1998 goto port_out;
1999
2000 /* #257 Port attribute entry */
2001 ad = (struct lpfc_fdmi_attr_def *)
2002 ((uint8_t *)pab + size);
2003 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
2004 ad->AttrType = cpu_to_be16(RPRT_PORT_STATE);
2005 ae->un.PortState = 0;
2006 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
2007 pab->ab.EntryCnt++;
2008 size += FOURBYTES + 4;
2009 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
2010 goto port_out;
2011
2012 /* #258 Port attribute entry */
2013 ad = (struct lpfc_fdmi_attr_def *)
2014 ((uint8_t *)pab + size);
2015 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
2016 ad->AttrType = cpu_to_be16(RPRT_DISC_PORT);
2017 ae->un.PortState = lpfc_find_map_node(vport);
2018 ae->un.PortState = cpu_to_be32(ae->un.PortState);
2019 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
2020 pab->ab.EntryCnt++;
2021 size += FOURBYTES + 4;
2022 if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
2023 goto port_out;
2024
2025 /* #259 Port attribute entry */
2026 ad = (struct lpfc_fdmi_attr_def *)
2027 ((uint8_t *)pab + size);
2028 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
2029 ad->AttrType = cpu_to_be16(RPRT_PORT_ID);
2030 ae->un.PortId = cpu_to_be32(vport->fc_myDID);
2031 ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
2032 pab->ab.EntryCnt++;
2033 size += FOURBYTES + 4;
2034port_out:
2035 pab->ab.EntryCnt = cpu_to_be32(pab->ab.EntryCnt);
1694 /* Total size */ 2036 /* Total size */
1695 size = GID_REQUEST_SZ - 4 + size; 2037 size = GID_REQUEST_SZ - 4 + size;
1696 } 2038 }
1697 break; 2039 break;
1698 2040
2041 case SLI_MGMT_GHAT:
2042 case SLI_MGMT_GRPL:
2043 rsp_size = FC_MAX_NS_RSP;
1699 case SLI_MGMT_DHBA: 2044 case SLI_MGMT_DHBA:
1700 CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DHBA); 2045 case SLI_MGMT_DHAT:
1701 CtReq->CommandResponse.bits.Size = 0; 2046 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
1702 pe = (PORT_ENTRY *) & CtReq->un.PortID; 2047 memcpy((uint8_t *)&pe->PortName,
1703 memcpy((uint8_t *) & pe->PortName, 2048 (uint8_t *)&vport->fc_sparam.portName,
1704 (uint8_t *) & vport->fc_sparam.portName, 2049 sizeof(struct lpfc_name));
1705 sizeof (struct lpfc_name)); 2050 size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
1706 size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name);
1707 break; 2051 break;
1708 2052
2053 case SLI_MGMT_GPAT:
2054 case SLI_MGMT_GPAS:
2055 rsp_size = FC_MAX_NS_RSP;
1709 case SLI_MGMT_DPRT: 2056 case SLI_MGMT_DPRT:
1710 CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DPRT); 2057 case SLI_MGMT_DPA:
1711 CtReq->CommandResponse.bits.Size = 0; 2058 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
1712 pe = (PORT_ENTRY *) & CtReq->un.PortID; 2059 memcpy((uint8_t *)&pe->PortName,
1713 memcpy((uint8_t *) & pe->PortName, 2060 (uint8_t *)&vport->fc_sparam.portName,
1714 (uint8_t *) & vport->fc_sparam.portName, 2061 sizeof(struct lpfc_name));
1715 sizeof (struct lpfc_name)); 2062 size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
1716 size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); 2063 break;
2064 case SLI_MGMT_GRHL:
2065 size = GID_REQUEST_SZ - 4;
1717 break; 2066 break;
2067 default:
2068 lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY,
2069 "0298 FDMI cmdcode x%x not supported\n",
2070 cmdcode);
2071 goto fdmi_cmd_free_bmpvirt;
1718 } 2072 }
2073 CtReq->CommandResponse.bits.Size = cpu_to_be16(rsp_size);
1719 2074
1720 bpl = (struct ulp_bde64 *) bmp->virt; 2075 bpl = (struct ulp_bde64 *)bmp->virt;
1721 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); 2076 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys));
1722 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); 2077 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys));
1723 bpl->tus.f.bdeFlags = 0; 2078 bpl->tus.f.bdeFlags = 0;
1724 bpl->tus.f.bdeSize = size; 2079 bpl->tus.f.bdeSize = size;
1725 bpl->tus.w = le32_to_cpu(bpl->tus.w);
1726
1727 cmpl = lpfc_cmpl_ct_cmd_fdmi;
1728 2080
1729 /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count 2081 /*
2082 * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
1730 * to hold ndlp reference for the corresponding callback function. 2083 * to hold ndlp reference for the corresponding callback function.
1731 */ 2084 */
1732 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) 2085 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, 0))
1733 return 0; 2086 return 0;
1734 2087
1735 /* Decrement ndlp reference count to release ndlp reference held 2088 /*
2089 * Decrement ndlp reference count to release ndlp reference held
1736 * for the failed command's callback function. 2090 * for the failed command's callback function.
1737 */ 2091 */
1738 lpfc_nlp_put(ndlp); 2092 lpfc_nlp_put(ndlp);
1739 2093
2094fdmi_cmd_free_bmpvirt:
1740 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 2095 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
1741fdmi_cmd_free_bmp: 2096fdmi_cmd_free_bmp:
1742 kfree(bmp); 2097 kfree(bmp);
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 63505637a121..9f3c74e07a63 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -7172,7 +7172,7 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
7172 return; 7172 return;
7173 } 7173 }
7174 7174
7175 if (vport->cfg_fdmi_on) { 7175 if (vport->cfg_fdmi_on & LPFC_FDMI_SUPPORT) {
7176 /* If this is the first time, allocate an ndlp and initialize 7176 /* If this is the first time, allocate an ndlp and initialize
7177 * it. Otherwise, make sure the node is enabled and then do the 7177 * it. Otherwise, make sure the node is enabled and then do the
7178 * login. 7178 * login.
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index b1ad1a068782..9d06d4592c3a 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -5489,11 +5489,11 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
5489 * fdmi-on=2 (supporting RPA/hostnmae) 5489 * fdmi-on=2 (supporting RPA/hostnmae)
5490 */ 5490 */
5491 5491
5492 if (vport->cfg_fdmi_on == 1) 5492 if (vport->cfg_fdmi_on & LPFC_FDMI_REG_DELAY)
5493 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA);
5494 else
5495 mod_timer(&vport->fc_fdmitmo, 5493 mod_timer(&vport->fc_fdmitmo,
5496 jiffies + msecs_to_jiffies(1000 * 60)); 5494 jiffies + msecs_to_jiffies(1000 * 60));
5495 else
5496 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA);
5497 5497
5498 /* decrement the node reference count held for this callback 5498 /* decrement the node reference count held for this callback
5499 * function. 5499 * function.
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 236259252379..a74bbf0029ac 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -107,6 +107,7 @@ struct lpfc_sli_ct_request {
107 uint8_t ReasonCode; 107 uint8_t ReasonCode;
108 uint8_t Explanation; 108 uint8_t Explanation;
109 uint8_t VendorUnique; 109 uint8_t VendorUnique;
110#define LPFC_CT_PREAMBLE 20 /* Size of CTReq + 4 up to here */
110 111
111 union { 112 union {
112 uint32_t PortID; 113 uint32_t PortID;
@@ -170,6 +171,8 @@ struct lpfc_sli_ct_request {
170 } un; 171 } un;
171}; 172};
172 173
174#define LPFC_MAX_CT_SIZE (60 * 4096)
175
173#define SLI_CT_REVISION 1 176#define SLI_CT_REVISION 1
174#define GID_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \ 177#define GID_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
175 sizeof(struct gid)) 178 sizeof(struct gid))
@@ -1007,78 +1010,45 @@ typedef struct _ELS_PKT { /* Structure is in Big Endian format */
1007 } un; 1010 } un;
1008} ELS_PKT; 1011} ELS_PKT;
1009 1012
1010/* 1013/******** FDMI ********/
1011 * FDMI
1012 * HBA MAnagement Operations Command Codes
1013 */
1014#define SLI_MGMT_GRHL 0x100 /* Get registered HBA list */
1015#define SLI_MGMT_GHAT 0x101 /* Get HBA attributes */
1016#define SLI_MGMT_GRPL 0x102 /* Get registered Port list */
1017#define SLI_MGMT_GPAT 0x110 /* Get Port attributes */
1018#define SLI_MGMT_RHBA 0x200 /* Register HBA */
1019#define SLI_MGMT_RHAT 0x201 /* Register HBA attributes */
1020#define SLI_MGMT_RPRT 0x210 /* Register Port */
1021#define SLI_MGMT_RPA 0x211 /* Register Port attributes */
1022#define SLI_MGMT_DHBA 0x300 /* De-register HBA */
1023#define SLI_MGMT_DPRT 0x310 /* De-register Port */
1024 1014
1025/* 1015/* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */
1026 * Management Service Subtypes 1016#define SLI_CT_FDMI_Subtypes 0x10 /* Management Service Subtype */
1027 */
1028#define SLI_CT_FDMI_Subtypes 0x10
1029 1017
1030/* 1018/*
1031 * HBA Management Service Reject Code 1019 * Registered Port List Format
1032 */ 1020 */
1033#define REJECT_CODE 0x9 /* Unable to perform command request */ 1021struct lpfc_fdmi_reg_port_list {
1022 uint32_t EntryCnt;
1023 uint32_t pe; /* Variable-length array */
1024};
1034 1025
1035/*
1036 * HBA Management Service Reject Reason Code
1037 * Please refer to the Reason Codes above
1038 */
1039 1026
1040/* 1027/* Definitions for HBA / Port attribute entries */
1041 * HBA Attribute Types
1042 */
1043#define NODE_NAME 0x1
1044#define MANUFACTURER 0x2
1045#define SERIAL_NUMBER 0x3
1046#define MODEL 0x4
1047#define MODEL_DESCRIPTION 0x5
1048#define HARDWARE_VERSION 0x6
1049#define DRIVER_VERSION 0x7
1050#define OPTION_ROM_VERSION 0x8
1051#define FIRMWARE_VERSION 0x9
1052#define OS_NAME_VERSION 0xa
1053#define MAX_CT_PAYLOAD_LEN 0xb
1054 1028
1055/* 1029struct lpfc_fdmi_attr_def { /* Defined in TLV format */
1056 * Port Attrubute Types
1057 */
1058#define SUPPORTED_FC4_TYPES 0x1
1059#define SUPPORTED_SPEED 0x2
1060#define PORT_SPEED 0x3
1061#define MAX_FRAME_SIZE 0x4
1062#define OS_DEVICE_NAME 0x5
1063#define HOST_NAME 0x6
1064
1065union AttributesDef {
1066 /* Structure is in Big Endian format */ 1030 /* Structure is in Big Endian format */
1067 struct { 1031 uint32_t AttrType:16;
1068 uint32_t AttrType:16; 1032 uint32_t AttrLen:16;
1069 uint32_t AttrLen:16; 1033 uint32_t AttrValue; /* Marks start of Value (ATTRIBUTE_ENTRY) */
1070 } bits;
1071 uint32_t word;
1072}; 1034};
1073 1035
1074 1036
1075/* 1037/* Attribute Entry */
1076 * HBA Attribute Entry (8 - 260 bytes) 1038struct lpfc_fdmi_attr_entry {
1077 */
1078typedef struct {
1079 union AttributesDef ad;
1080 union { 1039 union {
1081 uint32_t VendorSpecific; 1040 uint32_t VendorSpecific;
1041 uint32_t SupportClass;
1042 uint32_t SupportSpeed;
1043 uint32_t PortSpeed;
1044 uint32_t MaxFrameSize;
1045 uint32_t MaxCTPayloadLen;
1046 uint32_t PortState;
1047 uint32_t PortId;
1048 struct lpfc_name NodeName;
1049 struct lpfc_name PortName;
1050 struct lpfc_name FabricName;
1051 uint8_t FC4Types[32];
1082 uint8_t Manufacturer[64]; 1052 uint8_t Manufacturer[64];
1083 uint8_t SerialNumber[64]; 1053 uint8_t SerialNumber[64];
1084 uint8_t Model[256]; 1054 uint8_t Model[256];
@@ -1087,97 +1057,115 @@ typedef struct {
1087 uint8_t DriverVersion[256]; 1057 uint8_t DriverVersion[256];
1088 uint8_t OptionROMVersion[256]; 1058 uint8_t OptionROMVersion[256];
1089 uint8_t FirmwareVersion[256]; 1059 uint8_t FirmwareVersion[256];
1090 struct lpfc_name NodeName; 1060 uint8_t OsHostName[256];
1091 uint8_t SupportFC4Types[32]; 1061 uint8_t NodeSymName[256];
1092 uint32_t SupportSpeed;
1093 uint32_t PortSpeed;
1094 uint32_t MaxFrameSize;
1095 uint8_t OsDeviceName[256]; 1062 uint8_t OsDeviceName[256];
1096 uint8_t OsNameVersion[256]; 1063 uint8_t OsNameVersion[256];
1097 uint32_t MaxCTPayloadLen;
1098 uint8_t HostName[256]; 1064 uint8_t HostName[256];
1099 } un; 1065 } un;
1100} ATTRIBUTE_ENTRY; 1066};
1067
1068#define LPFC_FDMI_MAX_AE_SIZE sizeof(struct lpfc_fdmi_attr_entry)
1101 1069
1102/* 1070/*
1103 * HBA Attribute Block 1071 * HBA Attribute Block
1104 */ 1072 */
1105typedef struct { 1073struct lpfc_fdmi_attr_block {
1106 uint32_t EntryCnt; /* Number of HBA attribute entries */ 1074 uint32_t EntryCnt; /* Number of HBA attribute entries */
1107 ATTRIBUTE_ENTRY Entry; /* Variable-length array */ 1075 struct lpfc_fdmi_attr_entry Entry; /* Variable-length array */
1108} ATTRIBUTE_BLOCK; 1076};
1109 1077
1110/* 1078/*
1111 * Port Entry 1079 * Port Entry
1112 */ 1080 */
1113typedef struct { 1081struct lpfc_fdmi_port_entry {
1114 struct lpfc_name PortName; 1082 struct lpfc_name PortName;
1115} PORT_ENTRY; 1083};
1116 1084
1117/* 1085/*
1118 * HBA Identifier 1086 * HBA Identifier
1119 */ 1087 */
1120typedef struct { 1088struct lpfc_fdmi_hba_ident {
1121 struct lpfc_name PortName; 1089 struct lpfc_name PortName;
1122} HBA_IDENTIFIER; 1090};
1123
1124/*
1125 * Registered Port List Format
1126 */
1127typedef struct {
1128 uint32_t EntryCnt;
1129 PORT_ENTRY pe; /* Variable-length array */
1130} REG_PORT_LIST;
1131 1091
1132/* 1092/*
1133 * Register HBA(RHBA) 1093 * Register HBA(RHBA)
1134 */ 1094 */
1135typedef struct { 1095struct lpfc_fdmi_reg_hba {
1136 HBA_IDENTIFIER hi; 1096 struct lpfc_fdmi_hba_ident hi;
1137 REG_PORT_LIST rpl; /* variable-length array */ 1097 struct lpfc_fdmi_reg_port_list rpl; /* variable-length array */
1138/* ATTRIBUTE_BLOCK ab; */ 1098/* struct lpfc_fdmi_attr_block ab; */
1139} REG_HBA; 1099};
1140 1100
1141/* 1101/*
1142 * Register HBA Attributes (RHAT) 1102 * Register HBA Attributes (RHAT)
1143 */ 1103 */
1144typedef struct { 1104struct lpfc_fdmi_reg_hbaattr {
1145 struct lpfc_name HBA_PortName; 1105 struct lpfc_name HBA_PortName;
1146 ATTRIBUTE_BLOCK ab; 1106 struct lpfc_fdmi_attr_block ab;
1147} REG_HBA_ATTRIBUTE; 1107};
1148 1108
1149/* 1109/*
1150 * Register Port Attributes (RPA) 1110 * Register Port Attributes (RPA)
1151 */ 1111 */
1152typedef struct { 1112struct lpfc_fdmi_reg_portattr {
1153 struct lpfc_name PortName; 1113 struct lpfc_name PortName;
1154 ATTRIBUTE_BLOCK ab; 1114 struct lpfc_fdmi_attr_block ab;
1155} REG_PORT_ATTRIBUTE; 1115};
1156 1116
1157/* 1117/*
1158 * Get Registered HBA List (GRHL) Accept Payload Format 1118 * HBA MAnagement Operations Command Codes
1159 */ 1119 */
1160typedef struct { 1120#define SLI_MGMT_GRHL 0x100 /* Get registered HBA list */
1161 uint32_t HBA__Entry_Cnt; /* Number of Registered HBA Identifiers */ 1121#define SLI_MGMT_GHAT 0x101 /* Get HBA attributes */
1162 struct lpfc_name HBA_PortName; /* Variable-length array */ 1122#define SLI_MGMT_GRPL 0x102 /* Get registered Port list */
1163} GRHL_ACC_PAYLOAD; 1123#define SLI_MGMT_GPAT 0x110 /* Get Port attributes */
1124#define SLI_MGMT_GPAS 0x120 /* Get Port Statistics */
1125#define SLI_MGMT_RHBA 0x200 /* Register HBA */
1126#define SLI_MGMT_RHAT 0x201 /* Register HBA attributes */
1127#define SLI_MGMT_RPRT 0x210 /* Register Port */
1128#define SLI_MGMT_RPA 0x211 /* Register Port attributes */
1129#define SLI_MGMT_DHBA 0x300 /* De-register HBA */
1130#define SLI_MGMT_DHAT 0x301 /* De-register HBA attributes */
1131#define SLI_MGMT_DPRT 0x310 /* De-register Port */
1132#define SLI_MGMT_DPA 0x311 /* De-register Port attributes */
1164 1133
1165/* 1134/*
1166 * Get Registered Port List (GRPL) Accept Payload Format 1135 * HBA Attribute Types
1167 */ 1136 */
1168typedef struct { 1137#define RHBA_NODENAME 0x1 /* 8 byte WWNN */
1169 uint32_t RPL_Entry_Cnt; /* Number of Registered Port Entries */ 1138#define RHBA_MANUFACTURER 0x2 /* 4 to 64 byte ASCII string */
1170 PORT_ENTRY Reg_Port_Entry[1]; /* Variable-length array */ 1139#define RHBA_SERIAL_NUMBER 0x3 /* 4 to 64 byte ASCII string */
1171} GRPL_ACC_PAYLOAD; 1140#define RHBA_MODEL 0x4 /* 4 to 256 byte ASCII string */
1141#define RHBA_MODEL_DESCRIPTION 0x5 /* 4 to 256 byte ASCII string */
1142#define RHBA_HARDWARE_VERSION 0x6 /* 4 to 256 byte ASCII string */
1143#define RHBA_DRIVER_VERSION 0x7 /* 4 to 256 byte ASCII string */
1144#define RHBA_OPTION_ROM_VERSION 0x8 /* 4 to 256 byte ASCII string */
1145#define RHBA_FIRMWARE_VERSION 0x9 /* 4 to 256 byte ASCII string */
1146#define RHBA_OS_NAME_VERSION 0xa /* 4 to 256 byte ASCII string */
1147#define RHBA_MAX_CT_PAYLOAD_LEN 0xb /* 32-bit unsigned int */
1148#define RHBA_SYM_NODENAME 0xc /* 4 to 256 byte ASCII string */
1172 1149
1173/* 1150/*
1174 * Get Port Attributes (GPAT) Accept Payload Format 1151 * Port Attrubute Types
1175 */ 1152 */
1176 1153#define RPRT_SUPPORTED_FC4_TYPES 0x1 /* 32 byte binary array */
1177typedef struct { 1154#define RPRT_SUPPORTED_SPEED 0x2 /* 32-bit unsigned int */
1178 ATTRIBUTE_BLOCK pab; 1155#define RPRT_PORT_SPEED 0x3 /* 32-bit unsigned int */
1179} GPAT_ACC_PAYLOAD; 1156#define RPRT_MAX_FRAME_SIZE 0x4 /* 32-bit unsigned int */
1180 1157#define RPRT_OS_DEVICE_NAME 0x5 /* 4 to 256 byte ASCII string */
1158#define RPRT_HOST_NAME 0x6 /* 4 to 256 byte ASCII string */
1159#define RPRT_NODENAME 0x7 /* 8 byte WWNN */
1160#define RPRT_PORTNAME 0x8 /* 8 byte WWNN */
1161#define RPRT_SYM_PORTNAME 0x9 /* 4 to 256 byte ASCII string */
1162#define RPRT_PORT_TYPE 0xa /* 32-bit unsigned int */
1163#define RPRT_SUPPORTED_CLASS 0xb /* 32-bit unsigned int */
1164#define RPRT_FABRICNAME 0xc /* 8 byte Fabric WWNN */
1165#define RPRT_ACTIVE_FC4_TYPES 0xd /* 32 byte binary array */
1166#define RPRT_PORT_STATE 0x101 /* 32-bit unsigned int */
1167#define RPRT_DISC_PORT 0x102 /* 32-bit unsigned int */
1168#define RPRT_PORT_ID 0x103 /* 32-bit unsigned int */
1181 1169
1182/* 1170/*
1183 * Begin HBA configuration parameters. 1171 * Begin HBA configuration parameters.