Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: libfc: FDMI enhancements

Add all the attributes for FDMI.

Fall back mechanism is added in between FDMI V2 and FDMI V1 attributes. In
case FDMI get fails for V2 attributes we fall back to V1 attributes.

Link: https://lore.kernel.org/r/20210603121623.10084-5-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Javed Hasan and committed by
Martin K. Petersen
974db67a 82897fef

+58 -6
+58 -6
drivers/scsi/libfc/fc_lport.c
··· 1188 1188 struct fc_lport *lport = lp_arg; 1189 1189 struct fc_frame_header *fh; 1190 1190 struct fc_ct_hdr *ct; 1191 - 1191 + struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); 1192 1192 FC_LPORT_DBG(lport, "Received a ms %s\n", fc_els_resp_type(fp)); 1193 1193 1194 1194 if (fp == ERR_PTR(-FC_EX_CLOSED)) ··· 1222 1222 1223 1223 switch (lport->state) { 1224 1224 case LPORT_ST_RHBA: 1225 - if (ntohs(ct->ct_cmd) == FC_FS_ACC) 1225 + if ((ntohs(ct->ct_cmd) == FC_FS_RJT) && fc_host->fdmi_version == FDMI_V2) { 1226 + FC_LPORT_DBG(lport, "Error for FDMI-V2, fall back to FDMI-V1\n"); 1227 + fc_host->fdmi_version = FDMI_V1; 1228 + 1229 + fc_lport_enter_ms(lport, LPORT_ST_RHBA); 1230 + 1231 + } else if (ntohs(ct->ct_cmd) == FC_FS_ACC) 1226 1232 fc_lport_enter_ms(lport, LPORT_ST_RPA); 1227 1233 else /* Error Skip RPA */ 1228 1234 fc_lport_enter_scr(lport); ··· 1442 1436 int size = sizeof(struct fc_ct_hdr); 1443 1437 size_t len; 1444 1438 int numattrs; 1445 - 1439 + struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); 1446 1440 lockdep_assert_held(&lport->lp_mutex); 1447 1441 1448 1442 FC_LPORT_DBG(lport, "Entered %s state from %s state\n", ··· 1455 1449 case LPORT_ST_RHBA: 1456 1450 cmd = FC_FDMI_RHBA; 1457 1451 /* Number of HBA Attributes */ 1458 - numattrs = 10; 1452 + numattrs = 11; 1459 1453 len = sizeof(struct fc_fdmi_rhba); 1460 1454 len -= sizeof(struct fc_fdmi_attr_entry); 1461 - len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); 1455 + 1462 1456 len += FC_FDMI_HBA_ATTR_NODENAME_LEN; 1463 1457 len += FC_FDMI_HBA_ATTR_MANUFACTURER_LEN; 1464 1458 len += FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN; ··· 1469 1463 len += FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN; 1470 1464 len += FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN; 1471 1465 len += FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN; 1466 + len += FC_FDMI_HBA_ATTR_MAXCTPAYLOAD_LEN; 1467 + 1468 + 1469 + if (fc_host->fdmi_version == FDMI_V2) { 1470 + numattrs += 7; 1471 + len += FC_FDMI_HBA_ATTR_NODESYMBLNAME_LEN; 1472 + len += FC_FDMI_HBA_ATTR_VENDORSPECIFICINFO_LEN; 1473 + len += FC_FDMI_HBA_ATTR_NUMBEROFPORTS_LEN; 1474 + len += FC_FDMI_HBA_ATTR_FABRICNAME_LEN; 1475 + len += FC_FDMI_HBA_ATTR_BIOSVERSION_LEN; 1476 + len += FC_FDMI_HBA_ATTR_BIOSSTATE_LEN; 1477 + len += FC_FDMI_HBA_ATTR_VENDORIDENTIFIER_LEN; 1478 + } 1479 + 1480 + len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); 1472 1481 1473 1482 size += len; 1474 1483 break; ··· 1493 1472 numattrs = 6; 1494 1473 len = sizeof(struct fc_fdmi_rpa); 1495 1474 len -= sizeof(struct fc_fdmi_attr_entry); 1496 - len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); 1497 1475 len += FC_FDMI_PORT_ATTR_FC4TYPES_LEN; 1498 1476 len += FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN; 1499 1477 len += FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN; 1500 1478 len += FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN; 1501 1479 len += FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN; 1502 1480 len += FC_FDMI_PORT_ATTR_HOSTNAME_LEN; 1481 + 1482 + if (fc_host->fdmi_version == FDMI_V2) { 1483 + numattrs += 10; 1484 + len += FC_FDMI_PORT_ATTR_NODENAME_LEN; 1485 + len += FC_FDMI_PORT_ATTR_PORTNAME_LEN; 1486 + len += FC_FDMI_PORT_ATTR_SYMBOLICNAME_LEN; 1487 + len += FC_FDMI_PORT_ATTR_PORTTYPE_LEN; 1488 + len += FC_FDMI_PORT_ATTR_SUPPORTEDCLASSSRVC_LEN; 1489 + len += FC_FDMI_PORT_ATTR_FABRICNAME_LEN; 1490 + len += FC_FDMI_PORT_ATTR_CURRENTFC4TYPE_LEN; 1491 + len += FC_FDMI_PORT_ATTR_PORTSTATE_LEN; 1492 + len += FC_FDMI_PORT_ATTR_DISCOVEREDPORTS_LEN; 1493 + len += FC_FDMI_PORT_ATTR_PORTID_LEN; 1494 + } 1495 + 1496 + len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); 1503 1497 1504 1498 size += len; 1505 1499 break; ··· 1585 1549 struct fc_lport *lport = 1586 1550 container_of(work, struct fc_lport, 1587 1551 retry_work.work); 1552 + struct fc_host_attrs *fc_host = shost_to_fc_host(lport->host); 1588 1553 1589 1554 mutex_lock(&lport->lp_mutex); 1590 1555 ··· 1613 1576 fc_lport_enter_fdmi(lport); 1614 1577 break; 1615 1578 case LPORT_ST_RHBA: 1579 + if (fc_host->fdmi_version == FDMI_V2) { 1580 + FC_LPORT_DBG(lport, "timeout for FDMI-V2 RHBA,fall back to FDMI-V1\n"); 1581 + fc_host->fdmi_version = FDMI_V1; 1582 + fc_lport_enter_ms(lport, LPORT_ST_RHBA); 1583 + break; 1584 + } 1585 + fallthrough; 1616 1586 case LPORT_ST_RPA: 1617 1587 case LPORT_ST_DHBA: 1618 1588 case LPORT_ST_DPRT: ··· 1886 1842 */ 1887 1843 int fc_lport_init(struct fc_lport *lport) 1888 1844 { 1845 + struct fc_host_attrs *fc_host; 1846 + 1847 + fc_host = shost_to_fc_host(lport->host); 1848 + 1849 + /* Set FDMI version to FDMI-2 specification*/ 1850 + fc_host->fdmi_version = FDMI_V2; 1851 + 1889 1852 fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; 1890 1853 fc_host_node_name(lport->host) = lport->wwnn; 1891 1854 fc_host_port_name(lport->host) = lport->wwpn; ··· 1901 1850 sizeof(fc_host_supported_fc4s(lport->host))); 1902 1851 fc_host_supported_fc4s(lport->host)[2] = 1; 1903 1852 fc_host_supported_fc4s(lport->host)[7] = 1; 1853 + fc_host_num_discovered_ports(lport->host) = 4; 1904 1854 1905 1855 /* This value is also unchanging */ 1906 1856 memset(fc_host_active_fc4s(lport->host), 0,