Commit 026abb87 authored by James Smart's avatar James Smart Committed by James Bottomley

[SCSI] lpfc 8.3.28: Miscellaneous fixes in sysfs and mgmt interfaces

Miscellaneous fixes in sysfs and mgmt interfaces:

- Added SLI4 INTF_TYPE and SLI_FAMILY as sub-field to the fwrev sysfs
  attribute (CR 124103)
- Added a sysfs attribute "protocol" to report SLI4 port link protocol
  type (CR 124102)
- Increment mix-and-match minor number by 1 for added "protocol" sysfs
  attribute. (124102)
- Move the link speed check into the generic sli3/sli4 code
  path. (CR 124185, 124122)
- Deleted check for inExtWLen (CR 122523)
- Add the word "offline" to message 2889 (CR 124385)
- Conditionalize the firmware upgrade/downgrade so that it is only
  attempted for SLI4 type 2 boards (CR 124406)
- Return an error if the mbox sysfs is called. (CR 124210)
- When port_state is less than LPFC_VPORT_READY, report
  FC_PORTSTATE_BYPASSED (CR 120018)
- Added driver support for performing persistent linkdown based on
  configure region 23 (CR 124534)
- Added restore state and error log when sysfs board_mode attribute
  access failed (CR 124158)
- Added support for SLI4_CONFIG non-embedded COMN_GET_CNTL_ADDL_ATTR
  pass-through (CR 124466)
- Rejecting un-supported multi-buffer mailbox commands (CR 124771)
- Byte swap the extended data request and response data for extended
  mailbox data (CR 125081)
Signed-off-by: default avatarAlex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: default avatarJames Smart <james.smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 2cb6fc8c
......@@ -247,18 +247,6 @@ struct lpfc_stats {
uint32_t fcpLocalErr;
};
enum sysfs_mbox_state {
SMBOX_IDLE,
SMBOX_WRITING,
SMBOX_READING
};
struct lpfc_sysfs_mbox {
enum sysfs_mbox_state state;
size_t offset;
struct lpfcMboxq * mbox;
};
struct lpfc_hba;
......@@ -783,8 +771,6 @@ struct lpfc_hba {
uint64_t bg_apptag_err_cnt;
uint64_t bg_reftag_err_cnt;
struct lpfc_sysfs_mbox sysfs_mbox;
/* fastpath list. */
spinlock_t scsi_buf_list_lock;
struct list_head lpfc_scsi_buf_list;
......
This diff is collapsed.
......@@ -3140,6 +3140,9 @@ lpfc_bsg_issue_mbox_ext_handle_job(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
unsigned long flags;
uint32_t size;
int rc = 0;
struct lpfc_dmabuf *dmabuf;
struct lpfc_sli_config_mbox *sli_cfg_mbx;
uint8_t *pmbx;
spin_lock_irqsave(&phba->ct_ev_lock, flags);
dd_data = pmboxq->context1;
......@@ -3156,7 +3159,19 @@ lpfc_bsg_issue_mbox_ext_handle_job(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
*/
pmb = (uint8_t *)&pmboxq->u.mb;
pmb_buf = (uint8_t *)dd_data->context_un.mbox.mb;
/* Copy the byte swapped response mailbox back to the user */
memcpy(pmb_buf, pmb, sizeof(MAILBOX_t));
/* if there is any non-embedded extended data copy that too */
dmabuf = phba->mbox_ext_buf_ctx.mbx_dmabuf;
sli_cfg_mbx = (struct lpfc_sli_config_mbox *)dmabuf->virt;
if (!bsg_bf_get(lpfc_mbox_hdr_emb,
&sli_cfg_mbx->un.sli_config_emb0_subsys.sli_config_hdr)) {
pmbx = (uint8_t *)dmabuf->virt;
/* byte swap the extended data following the mailbox command */
lpfc_sli_pcimem_bcopy(&pmbx[sizeof(MAILBOX_t)],
&pmbx[sizeof(MAILBOX_t)],
sli_cfg_mbx->un.sli_config_emb0_subsys.mse[0].buf_len);
}
job = dd_data->context_un.mbox.set_job;
if (job) {
......@@ -3519,6 +3534,18 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
/* state change */
phba->mbox_ext_buf_ctx.state = LPFC_BSG_MBOX_PORT;
/*
* Non-embedded mailbox subcommand data gets byte swapped here because
* the lower level driver code only does the first 64 mailbox words.
*/
if ((!bsg_bf_get(lpfc_mbox_hdr_emb,
&sli_cfg_mbx->un.sli_config_emb0_subsys.sli_config_hdr)) &&
(nemb_tp == nemb_mse))
lpfc_sli_pcimem_bcopy(&pmbx[sizeof(MAILBOX_t)],
&pmbx[sizeof(MAILBOX_t)],
sli_cfg_mbx->un.sli_config_emb0_subsys.
mse[0].buf_len);
rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
if ((rc == MBX_SUCCESS) || (rc == MBX_BUSY)) {
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
......@@ -3575,7 +3602,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
&sli_cfg_mbx->un.sli_config_emb0_subsys.sli_config_hdr);
if (ext_buf_cnt > LPFC_MBX_SLI_CONFIG_MAX_MSE) {
lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
"2953 Handled SLI_CONFIG(mse) wr, "
"2953 Failed SLI_CONFIG(mse) wr, "
"ext_buf_cnt(%d) out of range(%d)\n",
ext_buf_cnt,
LPFC_MBX_SLI_CONFIG_MAX_MSE);
......@@ -3593,7 +3620,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
ext_buf_cnt = sli_cfg_mbx->un.sli_config_emb1_subsys.hbd_count;
if (ext_buf_cnt > LPFC_MBX_SLI_CONFIG_MAX_HBD) {
lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
"2954 Handled SLI_CONFIG(hbd) wr, "
"2954 Failed SLI_CONFIG(hbd) wr, "
"ext_buf_cnt(%d) out of range(%d)\n",
ext_buf_cnt,
LPFC_MBX_SLI_CONFIG_MAX_HBD);
......@@ -3687,6 +3714,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
"2956 Failed to issue SLI_CONFIG ext-buffer "
"maibox command, rc:x%x\n", rc);
rc = -EPIPE;
goto job_error;
}
/* wait for additoinal external buffers */
......@@ -3721,7 +3749,7 @@ lpfc_bsg_handle_sli_cfg_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
uint32_t opcode;
int rc = SLI_CONFIG_NOT_HANDLED;
/* state change */
/* state change on new multi-buffer pass-through mailbox command */
phba->mbox_ext_buf_ctx.state = LPFC_BSG_MBOX_HOST;
sli_cfg_mbx = (struct lpfc_sli_config_mbox *)dmabuf->virt;
......@@ -3752,18 +3780,36 @@ lpfc_bsg_handle_sli_cfg_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
break;
default:
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"2959 Not handled SLI_CONFIG "
"2959 Reject SLI_CONFIG "
"subsys_fcoe, opcode:x%x\n",
opcode);
rc = SLI_CONFIG_NOT_HANDLED;
rc = -EPERM;
break;
}
} else if (subsys == SLI_CONFIG_SUBSYS_COMN) {
switch (opcode) {
case COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES:
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"3106 Handled SLI_CONFIG "
"subsys_fcoe, opcode:x%x\n",
opcode);
rc = lpfc_bsg_sli_cfg_read_cmd_ext(phba, job,
nemb_mse, dmabuf);
break;
default:
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"3107 Reject SLI_CONFIG "
"subsys_fcoe, opcode:x%x\n",
opcode);
rc = -EPERM;
break;
}
} else {
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"2977 Handled SLI_CONFIG "
"2977 Reject SLI_CONFIG "
"subsys:x%d, opcode:x%x\n",
subsys, opcode);
rc = SLI_CONFIG_NOT_HANDLED;
rc = -EPERM;
}
} else {
subsys = bsg_bf_get(lpfc_emb1_subcmnd_subsys,
......@@ -3799,12 +3845,17 @@ lpfc_bsg_handle_sli_cfg_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
}
} else {
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"2978 Handled SLI_CONFIG "
"2978 Not handled SLI_CONFIG "
"subsys:x%d, opcode:x%x\n",
subsys, opcode);
rc = SLI_CONFIG_NOT_HANDLED;
}
}
/* state reset on not handled new multi-buffer mailbox command */
if (rc != SLI_CONFIG_HANDLED)
phba->mbox_ext_buf_ctx.state = LPFC_BSG_MBOX_IDLE;
return rc;
}
......@@ -4262,11 +4313,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
/* extended mailbox commands will need an extended buffer */
if (mbox_req->inExtWLen || mbox_req->outExtWLen) {
/* any data for the device? */
if (mbox_req->inExtWLen) {
from = pmbx;
ext = from + sizeof(MAILBOX_t);
}
from = pmbx;
ext = from + sizeof(MAILBOX_t);
pmboxq->context2 = ext;
pmboxq->in_ext_byte_len =
mbox_req->inExtWLen * sizeof(uint32_t);
......
......@@ -96,7 +96,7 @@ struct get_mgmt_rev {
};
#define MANAGEMENT_MAJOR_REV 1
#define MANAGEMENT_MINOR_REV 0
#define MANAGEMENT_MINOR_REV 1
/* the MgmtRevInfo structure */
struct MgmtRevInfo {
......@@ -248,6 +248,7 @@ struct lpfc_sli_config_emb1_subsys {
#define COMN_OPCODE_WRITE_OBJECT 0xAC
#define COMN_OPCODE_READ_OBJECT_LIST 0xAD
#define COMN_OPCODE_DELETE_OBJECT 0xAE
#define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES 0x79
uint32_t timeout;
uint32_t request_length;
uint32_t word9;
......
......@@ -26,7 +26,7 @@ void lpfc_sli_read_link_ste(struct lpfc_hba *);
void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t, uint16_t);
void lpfc_dump_wakeup_param(struct lpfc_hba *, LPFC_MBOXQ_t *);
int lpfc_dump_static_vport(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
int lpfc_dump_fcoe_param(struct lpfc_hba *, struct lpfcMboxq *);
int lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *, struct lpfcMboxq *);
void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
......
......@@ -2104,6 +2104,8 @@ struct lpfc_mbx_read_config {
#define lpfc_mbx_rd_conf_lnk_type_SHIFT 6
#define lpfc_mbx_rd_conf_lnk_type_MASK 0x00000003
#define lpfc_mbx_rd_conf_lnk_type_WORD word2
#define LPFC_LNK_TYPE_GE 0
#define LPFC_LNK_TYPE_FC 1
#define lpfc_mbx_rd_conf_lnk_ldv_SHIFT 8
#define lpfc_mbx_rd_conf_lnk_ldv_MASK 0x00000001
#define lpfc_mbx_rd_conf_lnk_ldv_WORD word2
......
......@@ -475,27 +475,6 @@ lpfc_config_port_post(struct lpfc_hba *phba)
/* Get the default values for Model Name and Description */
lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_16G)
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G)
&& !(phba->lmt & LMT_1Gb))
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G)
&& !(phba->lmt & LMT_2Gb))
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G)
&& !(phba->lmt & LMT_4Gb))
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G)
&& !(phba->lmt & LMT_8Gb))
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G)
&& !(phba->lmt & LMT_10Gb))
|| ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G)
&& !(phba->lmt & LMT_16Gb))) {
/* Reset link speed to auto */
lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
"1302 Invalid speed for this board: "
"Reset link speed to auto: x%x\n",
phba->cfg_link_speed);
phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO;
}
phba->link_state = LPFC_LINK_DOWN;
/* Only process IOCBs on ELS ring till hba_state is READY */
......@@ -585,28 +564,10 @@ lpfc_config_port_post(struct lpfc_hba *phba)
return -EIO;
}
} else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) {
lpfc_init_link(phba, pmb, phba->cfg_topology,
phba->cfg_link_speed);
pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
lpfc_set_loopback_flag(phba);
rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
if (rc != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0454 Adapter failed to init, mbxCmd x%x "
"INIT_LINK, mbxStatus x%x\n",
mb->mbxCommand, mb->mbxStatus);
/* Clear all interrupt enable conditions */
writel(0, phba->HCregaddr);
readl(phba->HCregaddr); /* flush */
/* Clear all pending interrupts */
writel(0xffffffff, phba->HAregaddr);
readl(phba->HAregaddr); /* flush */
phba->link_state = LPFC_HBA_ERROR;
if (rc != MBX_BUSY)
mempool_free(pmb, phba->mbox_mem_pool);
return -EIO;
}
mempool_free(pmb, phba->mbox_mem_pool);
rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
if (rc)
return rc;
}
/* MBOX buffer will be freed in mbox compl */
pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
......@@ -681,6 +642,26 @@ lpfc_hba_init_link(struct lpfc_hba *phba, uint32_t flag)
mb = &pmb->u.mb;
pmb->vport = vport;
if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) &&
!(phba->lmt & LMT_1Gb)) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) &&
!(phba->lmt & LMT_2Gb)) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) &&
!(phba->lmt & LMT_4Gb)) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) &&
!(phba->lmt & LMT_8Gb)) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) &&
!(phba->lmt & LMT_10Gb)) ||
((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) &&
!(phba->lmt & LMT_16Gb))) {
/* Reset link speed to auto */
lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
"1302 Invalid speed for this board:%d "
"Reset link speed to auto.\n",
phba->cfg_link_speed);
phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO;
}
lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed);
pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
lpfc_set_loopback_flag(phba);
......@@ -1474,7 +1455,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba)
/* TODO: Register for Overtemp async events. */
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"2889 Port Overtemperature event, "
"taking port\n");
"taking port offline\n");
spin_lock_irq(&phba->hbalock);
phba->over_temp_state = HBA_OVER_TEMP;
spin_unlock_irq(&phba->hbalock);
......@@ -9198,12 +9179,15 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
/* Perform post initialization setup */
lpfc_post_init_setup(phba);
/* check for firmware upgrade or downgrade */
snprintf(file_name, 16, "%s.grp", phba->ModelName);
error = request_firmware(&fw, file_name, &phba->pcidev->dev);
if (!error) {
lpfc_write_firmware(phba, fw);
release_firmware(fw);
/* check for firmware upgrade or downgrade (if_type 2 only) */
if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) ==
LPFC_SLI_INTF_IF_TYPE_2) {
snprintf(file_name, 16, "%s.grp", phba->ModelName);
error = request_firmware(&fw, file_name, &phba->pcidev->dev);
if (!error) {
lpfc_write_firmware(phba, fw);
release_firmware(fw);
}
}
/* Check if there are static vports to be created. */
......
......@@ -2175,16 +2175,15 @@ lpfc_unreg_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport)
}
/**
* lpfc_dump_fcoe_param - Dump config region 23 to get FCoe parameters.
* lpfc_sli4_dump_cfg_rg23 - Dump sli4 port config region 23
* @phba: pointer to the hba structure containing.
* @mbox: pointer to lpfc mbox command to initialize.
*
* This function create a SLI4 dump mailbox command to dump FCoE
* parameters stored in region 23.
* This function create a SLI4 dump mailbox command to dump configure
* region 23.
**/
int
lpfc_dump_fcoe_param(struct lpfc_hba *phba,
struct lpfcMboxq *mbox)
lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
{
struct lpfc_dmabuf *mp = NULL;
MAILBOX_t *mb;
......@@ -2198,9 +2197,9 @@ lpfc_dump_fcoe_param(struct lpfc_hba *phba,
if (!mp || !mp->virt) {
kfree(mp);
/* dump_fcoe_param failed to allocate memory */
/* dump config region 23 failed to allocate memory */
lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
"2569 lpfc_dump_fcoe_param: memory"
"2569 lpfc dump config region 23: memory"
" allocation failed\n");
return 1;
}
......
......@@ -4566,7 +4566,7 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba,
phba->fc_map[2] = LPFC_FCOE_FCF_MAP2;
mqe = &mboxq->u.mqe;
if (lpfc_dump_fcoe_param(phba, mboxq))
if (lpfc_sli4_dump_cfg_rg23(phba, mboxq))
return -ENOMEM;
mp = (struct lpfc_dmabuf *) mboxq->context1;
......@@ -6205,7 +6205,11 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
rc = 0;
phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi,
&mboxq->u.mqe.un.reg_fcfi);
/* Check if the port is configured to be disabled */
lpfc_sli_read_link_ste(phba);
}
/*
* The port is ready, set the host's link state to LINK_DOWN
* in preparation for link interrupts.
......@@ -6213,7 +6217,19 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
spin_lock_irq(&phba->hbalock);
phba->link_state = LPFC_LINK_DOWN;
spin_unlock_irq(&phba->hbalock);
if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) {
if (!(phba->hba_flag & HBA_FCOE_MODE) &&
(phba->hba_flag & LINK_DISABLED)) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_SLI,
"3103 Adapter Link is disabled.\n");
lpfc_down_link(phba, mboxq);
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
if (rc != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_SLI,
"3104 Adapter failed to issue "
"DOWN_LINK mbox cmd, rc:x%x\n", rc);
goto out_unset_queue;
}
} else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) {
rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
if (rc)
goto out_unset_queue;
......@@ -15252,45 +15268,42 @@ lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *phba)
}
/**
* lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
* lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
* @phba: pointer to lpfc hba data structure.
* @rgn23_data: pointer to configure region 23 data.
*
* This function read region 23 and parse TLV for port status to
* decide if the user disaled the port. If the TLV indicates the
* port is disabled, the hba_flag is set accordingly.
* This function gets SLI3 port configure region 23 data through memory dump
* mailbox command. When it successfully retrieves data, the size of the data
* will be returned, otherwise, 0 will be returned.
**/
void
lpfc_sli_read_link_ste(struct lpfc_hba *phba)
static uint32_t
lpfc_sli_get_config_region23(struct lpfc_hba *phba, char *rgn23_data)
{
LPFC_MBOXQ_t *pmb = NULL;
MAILBOX_t *mb;
uint8_t *rgn23_data = NULL;
uint32_t offset = 0, data_size, sub_tlv_len, tlv_offset;
uint32_t offset = 0;
int rc;
if (!rgn23_data)
return 0;
pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!pmb) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"2600 lpfc_sli_read_serdes_param failed to"
" allocate mailbox memory\n");
goto out;
"2600 failed to allocate mailbox memory\n");
return 0;
}
mb = &pmb->u.mb;
/* Get adapter Region 23 data */
rgn23_data = kzalloc(DMP_RGN23_SIZE, GFP_KERNEL);
if (!rgn23_data)
goto out;
do {
lpfc_dump_mem(phba, pmb, offset, DMP_REGION_23);
rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
if (rc != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"2601 lpfc_sli_read_link_ste failed to"
" read config region 23 rc 0x%x Status 0x%x\n",
rc, mb->mbxStatus);
"2601 failed to read config "
"region 23, rc 0x%x Status 0x%x\n",
rc, mb->mbxStatus);
mb->un.varDmp.word_cnt = 0;
}
/*
......@@ -15303,13 +15316,96 @@ lpfc_sli_read_link_ste(struct lpfc_hba *phba)
mb->un.varDmp.word_cnt = DMP_RGN23_SIZE - offset;
lpfc_sli_pcimem_bcopy(((uint8_t *)mb) + DMP_RSP_OFFSET,
rgn23_data + offset,
mb->un.varDmp.word_cnt);
rgn23_data + offset,
mb->un.varDmp.word_cnt);
offset += mb->un.varDmp.word_cnt;
} while (mb->un.varDmp.word_cnt && offset < DMP_RGN23_SIZE);
data_size = offset;
offset = 0;
mempool_free(pmb, phba->mbox_mem_pool);
return offset;
}
/**
* lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
* @phba: pointer to lpfc hba data structure.
* @rgn23_data: pointer to configure region 23 data.
*
* This function gets SLI4 port configure region 23 data through memory dump
* mailbox command. When it successfully retrieves data, the size of the data
* will be returned, otherwise, 0 will be returned.
**/
static uint32_t
lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data)
{
LPFC_MBOXQ_t *mboxq = NULL;
struct lpfc_dmabuf *mp = NULL;
struct lpfc_mqe *mqe;
uint32_t data_length = 0;
int rc;
if (!rgn23_data)
return 0;
mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!mboxq) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"3105 failed to allocate mailbox memory\n");
return 0;
}
if (lpfc_sli4_dump_cfg_rg23(phba, mboxq))
goto out;
mqe = &mboxq->u.mqe;
mp = (struct lpfc_dmabuf *) mboxq->context1;
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
if (rc)
goto out;
data_length = mqe->un.mb_words[5];
if (data_length == 0)
goto out;
if (data_length > DMP_RGN23_SIZE) {
data_length = 0;
goto out;
}
lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length);
out:
mempool_free(mboxq, phba->mbox_mem_pool);
if (mp) {
lpfc_mbuf_free(phba, mp->virt, mp->phys);
kfree(mp);
}
return data_length;
}
/**
* lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
* @phba: pointer to lpfc hba data structure.
*
* This function read region 23 and parse TLV for port status to
* decide if the user disaled the port. If the TLV indicates the
* port is disabled, the hba_flag is set accordingly.
**/
void
lpfc_sli_read_link_ste(struct lpfc_hba *phba)
{
uint8_t *rgn23_data = NULL;
uint32_t if_type, data_size, sub_tlv_len, tlv_offset;
uint32_t offset = 0;
/* Get adapter Region 23 data */
rgn23_data = kzalloc(DMP_RGN23_SIZE, GFP_KERNEL);
if (!rgn23_data)
goto out;
if (phba->sli_rev < LPFC_SLI_REV4)
data_size = lpfc_sli_get_config_region23(phba, rgn23_data);
else {
if_type = bf_get(lpfc_sli_intf_if_type,
&phba->sli4_hba.sli_intf);
if (if_type == LPFC_SLI_INTF_IF_TYPE_0)
goto out;
data_size = lpfc_sli4_get_config_region23(phba, rgn23_data);
}
if (!data_size)
goto out;
......@@ -15373,9 +15469,8 @@ lpfc_sli_read_link_ste(struct lpfc_hba *phba)
goto out;
}
}
out:
if (pmb)
mempool_free(pmb, phba->mbox_mem_pool);
kfree(rgn23_data);
return;
}
......
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