Commit b4ba41c8 authored by James Smart's avatar James Smart Committed by Greg Kroah-Hartman

scsi: lpfc: Fix coverity errors in fmdi attribute handling

[ Upstream commit 4cb9e1dd ]

Coverity reported a memory corruption error for the fdmi attributes
routines:

  CID 15768 [Memory Corruption] Out-of-bounds access on FDMI

Sloppy coding of the fmdi structures. In both the lpfc_fdmi_attr_def and
lpfc_fdmi_reg_port_list structures, a field was placed at the start of
payload that may have variable content. The field was given an arbitrary
type (uint32_t). The code then uses the field name to derive an address,
which it used in things such as memset and memcpy. The memset sizes or
memcpy lengths were larger than the arbitrary type, thus coverity reported
an error.

Fix by replacing the arbitrary fields with the real field structures
describing the payload.

Link: https://lore.kernel.org/r/20200128002312.16346-8-jsmart2021@gmail.comSigned-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1ae009aa
...@@ -1737,8 +1737,8 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) ...@@ -1737,8 +1737,8 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, sizeof(struct lpfc_name)); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName, memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -1754,8 +1754,8 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport, ...@@ -1754,8 +1754,8 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
/* This string MUST be consistent with other FC platforms /* This string MUST be consistent with other FC platforms
* supported by Broadcom. * supported by Broadcom.
...@@ -1779,8 +1779,8 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) ...@@ -1779,8 +1779,8 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, phba->SerialNumber, strncpy(ae->un.AttrString, phba->SerialNumber,
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -1801,8 +1801,8 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport, ...@@ -1801,8 +1801,8 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, phba->ModelName, strncpy(ae->un.AttrString, phba->ModelName,
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -1822,8 +1822,8 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport, ...@@ -1822,8 +1822,8 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, phba->ModelDesc, strncpy(ae->un.AttrString, phba->ModelDesc,
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -1845,8 +1845,8 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport, ...@@ -1845,8 +1845,8 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t i, j, incr, size; uint32_t i, j, incr, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
/* Convert JEDEC ID to ascii for hardware version */ /* Convert JEDEC ID to ascii for hardware version */
incr = vp->rev.biuRev; incr = vp->rev.biuRev;
...@@ -1875,8 +1875,8 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport, ...@@ -1875,8 +1875,8 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, lpfc_release_version, strncpy(ae->un.AttrString, lpfc_release_version,
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -1897,8 +1897,8 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport, ...@@ -1897,8 +1897,8 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
if (phba->sli_rev == LPFC_SLI_REV4) if (phba->sli_rev == LPFC_SLI_REV4)
lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
...@@ -1922,8 +1922,8 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport, ...@@ -1922,8 +1922,8 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
len = strnlen(ae->un.AttrString, len = strnlen(ae->un.AttrString,
...@@ -1942,8 +1942,8 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport, ...@@ -1942,8 +1942,8 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s", snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s",
init_utsname()->sysname, init_utsname()->sysname,
...@@ -1965,7 +1965,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport, ...@@ -1965,7 +1965,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = cpu_to_be32(LPFC_MAX_CT_SIZE); ae->un.AttrInt = cpu_to_be32(LPFC_MAX_CT_SIZE);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
...@@ -1981,8 +1981,8 @@ lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport, ...@@ -1981,8 +1981,8 @@ lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
len = lpfc_vport_symbolic_node_name(vport, len = lpfc_vport_symbolic_node_name(vport,
ae->un.AttrString, 256); ae->un.AttrString, 256);
...@@ -2000,7 +2000,7 @@ lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport, ...@@ -2000,7 +2000,7 @@ lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
/* Nothing is defined for this currently */ /* Nothing is defined for this currently */
ae->un.AttrInt = cpu_to_be32(0); ae->un.AttrInt = cpu_to_be32(0);
...@@ -2017,7 +2017,7 @@ lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport, ...@@ -2017,7 +2017,7 @@ lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
/* Each driver instance corresponds to a single port */ /* Each driver instance corresponds to a single port */
ae->un.AttrInt = cpu_to_be32(1); ae->un.AttrInt = cpu_to_be32(1);
...@@ -2034,8 +2034,8 @@ lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport, ...@@ -2034,8 +2034,8 @@ lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, sizeof(struct lpfc_name)); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrWWN, &vport->fabric_nodename, memcpy(&ae->un.AttrWWN, &vport->fabric_nodename,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -2053,8 +2053,8 @@ lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport, ...@@ -2053,8 +2053,8 @@ lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
len = strnlen(ae->un.AttrString, len = strnlen(ae->un.AttrString,
...@@ -2073,7 +2073,7 @@ lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport, ...@@ -2073,7 +2073,7 @@ lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
/* Driver doesn't have access to this information */ /* Driver doesn't have access to this information */
ae->un.AttrInt = cpu_to_be32(0); ae->un.AttrInt = cpu_to_be32(0);
...@@ -2090,8 +2090,8 @@ lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport, ...@@ -2090,8 +2090,8 @@ lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, "EMULEX", strncpy(ae->un.AttrString, "EMULEX",
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -2112,8 +2112,8 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport, ...@@ -2112,8 +2112,8 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 32); memset(ae, 0, sizeof(*ae));
ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */ ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */ ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
...@@ -2134,7 +2134,7 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport, ...@@ -2134,7 +2134,7 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = 0; ae->un.AttrInt = 0;
if (!(phba->hba_flag & HBA_FCOE_MODE)) { if (!(phba->hba_flag & HBA_FCOE_MODE)) {
...@@ -2186,7 +2186,7 @@ lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport, ...@@ -2186,7 +2186,7 @@ lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
if (!(phba->hba_flag & HBA_FCOE_MODE)) { if (!(phba->hba_flag & HBA_FCOE_MODE)) {
switch (phba->fc_linkspeed) { switch (phba->fc_linkspeed) {
...@@ -2253,7 +2253,7 @@ lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport, ...@@ -2253,7 +2253,7 @@ lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
hsp = (struct serv_parm *)&vport->fc_sparam; hsp = (struct serv_parm *)&vport->fc_sparam;
ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb) << 8) | ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb) << 8) |
...@@ -2273,8 +2273,8 @@ lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport, ...@@ -2273,8 +2273,8 @@ lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), snprintf(ae->un.AttrString, sizeof(ae->un.AttrString),
"/sys/class/scsi_host/host%d", shost->host_no); "/sys/class/scsi_host/host%d", shost->host_no);
...@@ -2294,8 +2294,8 @@ lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport, ...@@ -2294,8 +2294,8 @@ lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s", snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s",
init_utsname()->nodename); init_utsname()->nodename);
...@@ -2315,8 +2315,8 @@ lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport, ...@@ -2315,8 +2315,8 @@ lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, sizeof(struct lpfc_name)); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName, memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -2333,8 +2333,8 @@ lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport, ...@@ -2333,8 +2333,8 @@ lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, sizeof(struct lpfc_name)); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrWWN, &vport->fc_sparam.portName, memcpy(&ae->un.AttrWWN, &vport->fc_sparam.portName,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -2351,8 +2351,8 @@ lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport, ...@@ -2351,8 +2351,8 @@ lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
len = lpfc_vport_symbolic_port_name(vport, ae->un.AttrString, 256); len = lpfc_vport_symbolic_port_name(vport, ae->un.AttrString, 256);
len += (len & 3) ? (4 - (len & 3)) : 4; len += (len & 3) ? (4 - (len & 3)) : 4;
...@@ -2370,7 +2370,7 @@ lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport, ...@@ -2370,7 +2370,7 @@ lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) if (phba->fc_topology == LPFC_TOPOLOGY_LOOP)
ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT); ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT);
else else
...@@ -2388,7 +2388,7 @@ lpfc_fdmi_port_attr_class(struct lpfc_vport *vport, ...@@ -2388,7 +2388,7 @@ lpfc_fdmi_port_attr_class(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3); ae->un.AttrInt = cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
ad->AttrLen = cpu_to_be16(size); ad->AttrLen = cpu_to_be16(size);
...@@ -2403,8 +2403,8 @@ lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport, ...@@ -2403,8 +2403,8 @@ lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, sizeof(struct lpfc_name)); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrWWN, &vport->fabric_portname, memcpy(&ae->un.AttrWWN, &vport->fabric_portname,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -2421,8 +2421,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, ...@@ -2421,8 +2421,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 32); memset(ae, 0, sizeof(*ae));
ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */ ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */ ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
...@@ -2442,7 +2442,7 @@ lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport, ...@@ -2442,7 +2442,7 @@ lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
/* Link Up - operational */ /* Link Up - operational */
ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE); ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
...@@ -2458,7 +2458,7 @@ lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport, ...@@ -2458,7 +2458,7 @@ lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
vport->fdmi_num_disc = lpfc_find_map_node(vport); vport->fdmi_num_disc = lpfc_find_map_node(vport);
ae->un.AttrInt = cpu_to_be32(vport->fdmi_num_disc); ae->un.AttrInt = cpu_to_be32(vport->fdmi_num_disc);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
...@@ -2474,7 +2474,7 @@ lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport, ...@@ -2474,7 +2474,7 @@ lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = cpu_to_be32(vport->fc_myDID); ae->un.AttrInt = cpu_to_be32(vport->fc_myDID);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
ad->AttrLen = cpu_to_be16(size); ad->AttrLen = cpu_to_be16(size);
...@@ -2489,8 +2489,8 @@ lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport, ...@@ -2489,8 +2489,8 @@ lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, "Smart SAN Initiator", strncpy(ae->un.AttrString, "Smart SAN Initiator",
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -2510,8 +2510,8 @@ lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport, ...@@ -2510,8 +2510,8 @@ lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
memcpy(&ae->un.AttrString, &vport->fc_sparam.nodeName, memcpy(&ae->un.AttrString, &vport->fc_sparam.nodeName,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
...@@ -2531,8 +2531,8 @@ lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport, ...@@ -2531,8 +2531,8 @@ lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, "Smart SAN Version 2.0", strncpy(ae->un.AttrString, "Smart SAN Version 2.0",
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -2553,8 +2553,8 @@ lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport, ...@@ -2553,8 +2553,8 @@ lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t len, size; uint32_t len, size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
memset(ae, 0, 256); memset(ae, 0, sizeof(*ae));
strncpy(ae->un.AttrString, phba->ModelName, strncpy(ae->un.AttrString, phba->ModelName,
sizeof(ae->un.AttrString)); sizeof(ae->un.AttrString));
...@@ -2573,7 +2573,7 @@ lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport, ...@@ -2573,7 +2573,7 @@ lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
/* SRIOV (type 3) is not supported */ /* SRIOV (type 3) is not supported */
if (vport->vpi) if (vport->vpi)
...@@ -2593,7 +2593,7 @@ lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport, ...@@ -2593,7 +2593,7 @@ lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = cpu_to_be32(0); ae->un.AttrInt = cpu_to_be32(0);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
ad->AttrLen = cpu_to_be16(size); ad->AttrLen = cpu_to_be16(size);
...@@ -2608,7 +2608,7 @@ lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport, ...@@ -2608,7 +2608,7 @@ lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport,
struct lpfc_fdmi_attr_entry *ae; struct lpfc_fdmi_attr_entry *ae;
uint32_t size; uint32_t size;
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; ae = &ad->AttrValue;
ae->un.AttrInt = cpu_to_be32(1); ae->un.AttrInt = cpu_to_be32(1);
size = FOURBYTES + sizeof(uint32_t); size = FOURBYTES + sizeof(uint32_t);
ad->AttrLen = cpu_to_be16(size); ad->AttrLen = cpu_to_be16(size);
...@@ -2756,7 +2756,8 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, ...@@ -2756,7 +2756,8 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
/* Registered Port List */ /* Registered Port List */
/* One entry (port) per adapter */ /* One entry (port) per adapter */
rh->rpl.EntryCnt = cpu_to_be32(1); rh->rpl.EntryCnt = cpu_to_be32(1);
memcpy(&rh->rpl.pe, &phba->pport->fc_sparam.portName, memcpy(&rh->rpl.pe.PortName,
&phba->pport->fc_sparam.portName,
sizeof(struct lpfc_name)); sizeof(struct lpfc_name));
/* point to the HBA attribute block */ /* point to the HBA attribute block */
......
...@@ -1333,25 +1333,8 @@ struct fc_rdp_res_frame { ...@@ -1333,25 +1333,8 @@ struct fc_rdp_res_frame {
/* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */ /* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */
#define SLI_CT_FDMI_Subtypes 0x10 /* Management Service Subtype */ #define SLI_CT_FDMI_Subtypes 0x10 /* Management Service Subtype */
/*
* Registered Port List Format
*/
struct lpfc_fdmi_reg_port_list {
uint32_t EntryCnt;
uint32_t pe; /* Variable-length array */
};
/* Definitions for HBA / Port attribute entries */ /* Definitions for HBA / Port attribute entries */
struct lpfc_fdmi_attr_def { /* Defined in TLV format */
/* Structure is in Big Endian format */
uint32_t AttrType:16;
uint32_t AttrLen:16;
uint32_t AttrValue; /* Marks start of Value (ATTRIBUTE_ENTRY) */
};
/* Attribute Entry */ /* Attribute Entry */
struct lpfc_fdmi_attr_entry { struct lpfc_fdmi_attr_entry {
union { union {
...@@ -1362,7 +1345,13 @@ struct lpfc_fdmi_attr_entry { ...@@ -1362,7 +1345,13 @@ struct lpfc_fdmi_attr_entry {
} un; } un;
}; };
#define LPFC_FDMI_MAX_AE_SIZE sizeof(struct lpfc_fdmi_attr_entry) struct lpfc_fdmi_attr_def { /* Defined in TLV format */
/* Structure is in Big Endian format */
uint32_t AttrType:16;
uint32_t AttrLen:16;
/* Marks start of Value (ATTRIBUTE_ENTRY) */
struct lpfc_fdmi_attr_entry AttrValue;
} __packed;
/* /*
* HBA Attribute Block * HBA Attribute Block
...@@ -1386,13 +1375,20 @@ struct lpfc_fdmi_hba_ident { ...@@ -1386,13 +1375,20 @@ struct lpfc_fdmi_hba_ident {
struct lpfc_name PortName; struct lpfc_name PortName;
}; };
/*
* Registered Port List Format
*/
struct lpfc_fdmi_reg_port_list {
uint32_t EntryCnt;
struct lpfc_fdmi_port_entry pe;
} __packed;
/* /*
* Register HBA(RHBA) * Register HBA(RHBA)
*/ */
struct lpfc_fdmi_reg_hba { struct lpfc_fdmi_reg_hba {
struct lpfc_fdmi_hba_ident hi; struct lpfc_fdmi_hba_ident hi;
struct lpfc_fdmi_reg_port_list rpl; /* variable-length array */ struct lpfc_fdmi_reg_port_list rpl;
/* struct lpfc_fdmi_attr_block ab; */
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment