Commit ecfd03c6 authored by James Smart's avatar James Smart Committed by James Bottomley

[SCSI] lpfc 8.3.9: Discovery changes to the lpfc driver.

- Add init_vpi mailbox command before re-registering VPI.
- Add Fast FCF failover support.
Signed-off-by: default avatarJames Smart <james.smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 1dfb5a47
...@@ -78,6 +78,7 @@ void lpfc_set_disctmo(struct lpfc_vport *); ...@@ -78,6 +78,7 @@ void lpfc_set_disctmo(struct lpfc_vport *);
int lpfc_can_disctmo(struct lpfc_vport *); int lpfc_can_disctmo(struct lpfc_vport *);
int lpfc_unreg_rpi(struct lpfc_vport *, struct lpfc_nodelist *); int lpfc_unreg_rpi(struct lpfc_vport *, struct lpfc_nodelist *);
void lpfc_unreg_all_rpis(struct lpfc_vport *); void lpfc_unreg_all_rpis(struct lpfc_vport *);
void lpfc_unreg_hba_rpis(struct lpfc_hba *);
void lpfc_unreg_default_rpis(struct lpfc_vport *); void lpfc_unreg_default_rpis(struct lpfc_vport *);
void lpfc_issue_reg_vpi(struct lpfc_hba *, struct lpfc_vport *); void lpfc_issue_reg_vpi(struct lpfc_hba *, struct lpfc_vport *);
...@@ -202,6 +203,7 @@ void lpfc_reg_fcfi(struct lpfc_hba *, struct lpfcMboxq *); ...@@ -202,6 +203,7 @@ void lpfc_reg_fcfi(struct lpfc_hba *, struct lpfcMboxq *);
void lpfc_unreg_fcfi(struct lpfcMboxq *, uint16_t); void lpfc_unreg_fcfi(struct lpfcMboxq *, uint16_t);
void lpfc_resume_rpi(struct lpfcMboxq *, struct lpfc_nodelist *); void lpfc_resume_rpi(struct lpfcMboxq *, struct lpfc_nodelist *);
int lpfc_check_pending_fcoe_event(struct lpfc_hba *, uint8_t); int lpfc_check_pending_fcoe_event(struct lpfc_hba *, uint8_t);
void lpfc_issue_init_vpi(struct lpfc_vport *);
void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *, void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *,
uint32_t , LPFC_MBOXQ_t *); uint32_t , LPFC_MBOXQ_t *);
...@@ -211,7 +213,11 @@ struct hbq_dmabuf *lpfc_sli4_rb_alloc(struct lpfc_hba *); ...@@ -211,7 +213,11 @@ struct hbq_dmabuf *lpfc_sli4_rb_alloc(struct lpfc_hba *);
void lpfc_sli4_rb_free(struct lpfc_hba *, struct hbq_dmabuf *); void lpfc_sli4_rb_free(struct lpfc_hba *, struct hbq_dmabuf *);
void lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *, struct fcf_record *, void lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *, struct fcf_record *,
uint16_t); uint16_t);
void lpfc_unregister_fcf(struct lpfc_hba *);
void lpfc_unregister_fcf_rescan(struct lpfc_hba *);
void lpfc_unregister_unused_fcf(struct lpfc_hba *); void lpfc_unregister_unused_fcf(struct lpfc_hba *);
int lpfc_sli4_redisc_fcf_table(struct lpfc_hba *);
void lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *);
int lpfc_mem_alloc(struct lpfc_hba *, int align); int lpfc_mem_alloc(struct lpfc_hba *, int align);
void lpfc_mem_free(struct lpfc_hba *); void lpfc_mem_free(struct lpfc_hba *);
...@@ -370,6 +376,8 @@ void lpfc_free_fast_evt(struct lpfc_hba *, struct lpfc_fast_path_event *); ...@@ -370,6 +376,8 @@ void lpfc_free_fast_evt(struct lpfc_hba *, struct lpfc_fast_path_event *);
void lpfc_create_static_vport(struct lpfc_hba *); void lpfc_create_static_vport(struct lpfc_hba *);
void lpfc_stop_hba_timers(struct lpfc_hba *); void lpfc_stop_hba_timers(struct lpfc_hba *);
void lpfc_stop_port(struct lpfc_hba *); void lpfc_stop_port(struct lpfc_hba *);
void __lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *);
void lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *);
void lpfc_parse_fcoe_conf(struct lpfc_hba *, uint8_t *, uint32_t); void lpfc_parse_fcoe_conf(struct lpfc_hba *, uint8_t *, uint32_t);
int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int); int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int);
void lpfc_start_fdiscs(struct lpfc_hba *phba); void lpfc_start_fdiscs(struct lpfc_hba *phba);
......
...@@ -589,6 +589,15 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, ...@@ -589,6 +589,15 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
spin_unlock_irq(shost->host_lock); spin_unlock_irq(shost->host_lock);
} }
/*
* If VPI is unreged, driver need to do INIT_VPI
* before re-registering
*/
if (phba->sli_rev == LPFC_SLI_REV4) {
spin_lock_irq(shost->host_lock);
vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
spin_unlock_irq(shost->host_lock);
}
} }
if (phba->sli_rev < LPFC_SLI_REV4) { if (phba->sli_rev < LPFC_SLI_REV4) {
...@@ -606,7 +615,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, ...@@ -606,7 +615,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
lpfc_start_fdiscs(phba); lpfc_start_fdiscs(phba);
lpfc_do_scr_ns_plogi(phba, vport); lpfc_do_scr_ns_plogi(phba, vport);
} else if (vport->fc_flag & FC_VFI_REGISTERED) } else if (vport->fc_flag & FC_VFI_REGISTERED)
lpfc_register_new_vport(phba, vport, ndlp); lpfc_issue_init_vpi(vport);
else else
lpfc_issue_reg_vfi(vport); lpfc_issue_reg_vfi(vport);
} }
...@@ -6210,10 +6219,13 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ...@@ -6210,10 +6219,13 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
lpfc_mbx_unreg_vpi(vport); lpfc_mbx_unreg_vpi(vport);
spin_lock_irq(shost->host_lock); spin_lock_irq(shost->host_lock);
vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
spin_unlock_irq(shost->host_lock); spin_unlock_irq(shost->host_lock);
} }
if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
lpfc_issue_init_vpi(vport);
else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
lpfc_register_new_vport(phba, vport, ndlp); lpfc_register_new_vport(phba, vport, ndlp);
else else
lpfc_do_scr_ns_plogi(phba, vport); lpfc_do_scr_ns_plogi(phba, vport);
......
This diff is collapsed.
...@@ -797,6 +797,7 @@ struct mbox_header { ...@@ -797,6 +797,7 @@ struct mbox_header {
#define LPFC_MBOX_OPCODE_FCOE_ADD_FCF 0x09 #define LPFC_MBOX_OPCODE_FCOE_ADD_FCF 0x09
#define LPFC_MBOX_OPCODE_FCOE_DELETE_FCF 0x0A #define LPFC_MBOX_OPCODE_FCOE_DELETE_FCF 0x0A
#define LPFC_MBOX_OPCODE_FCOE_POST_HDR_TEMPLATE 0x0B #define LPFC_MBOX_OPCODE_FCOE_POST_HDR_TEMPLATE 0x0B
#define LPFC_MBOX_OPCODE_FCOE_REDISCOVER_FCF 0x10
/* Mailbox command structures */ /* Mailbox command structures */
struct eq_context { struct eq_context {
...@@ -1297,6 +1298,19 @@ struct lpfc_mbx_del_fcf_tbl_entry { ...@@ -1297,6 +1298,19 @@ struct lpfc_mbx_del_fcf_tbl_entry {
#define lpfc_mbx_del_fcf_tbl_index_WORD word10 #define lpfc_mbx_del_fcf_tbl_index_WORD word10
}; };
struct lpfc_mbx_redisc_fcf_tbl {
struct mbox_header header;
uint32_t word10;
#define lpfc_mbx_redisc_fcf_count_SHIFT 0
#define lpfc_mbx_redisc_fcf_count_MASK 0x0000FFFF
#define lpfc_mbx_redisc_fcf_count_WORD word10
uint32_t resvd;
uint32_t word12;
#define lpfc_mbx_redisc_fcf_index_SHIFT 0
#define lpfc_mbx_redisc_fcf_index_MASK 0x0000FFFF
#define lpfc_mbx_redisc_fcf_index_WORD word12
};
struct lpfc_mbx_query_fw_cfg { struct lpfc_mbx_query_fw_cfg {
struct mbox_header header; struct mbox_header header;
uint32_t config_number; uint32_t config_number;
...@@ -1859,6 +1873,7 @@ struct lpfc_mqe { ...@@ -1859,6 +1873,7 @@ struct lpfc_mqe {
struct lpfc_mbx_read_fcf_tbl read_fcf_tbl; struct lpfc_mbx_read_fcf_tbl read_fcf_tbl;
struct lpfc_mbx_add_fcf_tbl_entry add_fcf_entry; struct lpfc_mbx_add_fcf_tbl_entry add_fcf_entry;
struct lpfc_mbx_del_fcf_tbl_entry del_fcf_entry; struct lpfc_mbx_del_fcf_tbl_entry del_fcf_entry;
struct lpfc_mbx_redisc_fcf_tbl redisc_fcf_tbl;
struct lpfc_mbx_reg_fcfi reg_fcfi; struct lpfc_mbx_reg_fcfi reg_fcfi;
struct lpfc_mbx_unreg_fcfi unreg_fcfi; struct lpfc_mbx_unreg_fcfi unreg_fcfi;
struct lpfc_mbx_mq_create mq_create; struct lpfc_mbx_mq_create mq_create;
...@@ -1975,6 +1990,7 @@ struct lpfc_acqe_fcoe { ...@@ -1975,6 +1990,7 @@ struct lpfc_acqe_fcoe {
#define LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL 0x2 #define LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL 0x2
#define LPFC_FCOE_EVENT_TYPE_FCF_DEAD 0x3 #define LPFC_FCOE_EVENT_TYPE_FCF_DEAD 0x3
#define LPFC_FCOE_EVENT_TYPE_CVL 0x4 #define LPFC_FCOE_EVENT_TYPE_CVL 0x4
#define LPFC_FCOE_EVENT_TYPE_FCF_PARAM_MOD 0x5
uint32_t event_tag; uint32_t event_tag;
uint32_t trailer; uint32_t trailer;
}; };
......
...@@ -2072,6 +2072,44 @@ lpfc_stop_vport_timers(struct lpfc_vport *vport) ...@@ -2072,6 +2072,44 @@ lpfc_stop_vport_timers(struct lpfc_vport *vport)
return; return;
} }
/**
* __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
* @phba: pointer to lpfc hba data structure.
*
* This routine stops the SLI4 FCF rediscover wait timer if it's on. The
* caller of this routine should already hold the host lock.
**/
void
__lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *phba)
{
/* Clear pending FCF rediscovery wait timer */
phba->fcf.fcf_flag &= ~FCF_REDISC_PEND;
/* Now, try to stop the timer */
del_timer(&phba->fcf.redisc_wait);
}
/**
* lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
* @phba: pointer to lpfc hba data structure.
*
* This routine stops the SLI4 FCF rediscover wait timer if it's on. It
* checks whether the FCF rediscovery wait timer is pending with the host
* lock held before proceeding with disabling the timer and clearing the
* wait timer pendig flag.
**/
void
lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *phba)
{
spin_lock_irq(&phba->hbalock);
if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) {
/* FCF rediscovery timer already fired or stopped */
spin_unlock_irq(&phba->hbalock);
return;
}
__lpfc_sli4_stop_fcf_redisc_wait_timer(phba);
spin_unlock_irq(&phba->hbalock);
}
/** /**
* lpfc_stop_hba_timers - Stop all the timers associated with an HBA * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
* @phba: pointer to lpfc hba data structure. * @phba: pointer to lpfc hba data structure.
...@@ -2096,6 +2134,7 @@ lpfc_stop_hba_timers(struct lpfc_hba *phba) ...@@ -2096,6 +2134,7 @@ lpfc_stop_hba_timers(struct lpfc_hba *phba)
break; break;
case LPFC_PCI_DEV_OC: case LPFC_PCI_DEV_OC:
/* Stop any OneConnect device sepcific driver timers */ /* Stop any OneConnect device sepcific driver timers */
lpfc_sli4_stop_fcf_redisc_wait_timer(phba);
break; break;
default: default:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT, lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
...@@ -2706,7 +2745,7 @@ lpfc_sli_remove_dflt_fcf(struct lpfc_hba *phba) ...@@ -2706,7 +2745,7 @@ lpfc_sli_remove_dflt_fcf(struct lpfc_hba *phba)
del_fcf_record = &mboxq->u.mqe.un.del_fcf_entry; del_fcf_record = &mboxq->u.mqe.un.del_fcf_entry;
bf_set(lpfc_mbx_del_fcf_tbl_count, del_fcf_record, 1); bf_set(lpfc_mbx_del_fcf_tbl_count, del_fcf_record, 1);
bf_set(lpfc_mbx_del_fcf_tbl_index, del_fcf_record, bf_set(lpfc_mbx_del_fcf_tbl_index, del_fcf_record,
phba->fcf.fcf_indx); phba->fcf.current_rec.fcf_indx);
if (!phba->sli4_hba.intr_enable) if (!phba->sli4_hba.intr_enable)
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
...@@ -2729,6 +2768,57 @@ lpfc_sli_remove_dflt_fcf(struct lpfc_hba *phba) ...@@ -2729,6 +2768,57 @@ lpfc_sli_remove_dflt_fcf(struct lpfc_hba *phba)
mempool_free(mboxq, phba->mbox_mem_pool); mempool_free(mboxq, phba->mbox_mem_pool);
} }
/**
* lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
* @phba: Pointer to hba for which this call is being executed.
*
* This routine starts the timer waiting for the FCF rediscovery to complete.
**/
void
lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *phba)
{
unsigned long fcf_redisc_wait_tmo =
(jiffies + msecs_to_jiffies(LPFC_FCF_REDISCOVER_WAIT_TMO));
/* Start fcf rediscovery wait period timer */
mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo);
spin_lock_irq(&phba->hbalock);
/* Allow action to new fcf asynchronous event */
phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE);
/* Mark the FCF rediscovery pending state */
phba->fcf.fcf_flag |= FCF_REDISC_PEND;
spin_unlock_irq(&phba->hbalock);
}
/**
* lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
* @ptr: Map to lpfc_hba data structure pointer.
*
* This routine is invoked when waiting for FCF table rediscover has been
* timed out. If new FCF record(s) has (have) been discovered during the
* wait period, a new FCF event shall be added to the FCOE async event
* list, and then worker thread shall be waked up for processing from the
* worker thread context.
**/
void
lpfc_sli4_fcf_redisc_wait_tmo(unsigned long ptr)
{
struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
/* Don't send FCF rediscovery event if timer cancelled */
spin_lock_irq(&phba->hbalock);
if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) {
spin_unlock_irq(&phba->hbalock);
return;
}
/* Clear FCF rediscovery timer pending flag */
phba->fcf.fcf_flag &= ~FCF_REDISC_PEND;
/* FCF rediscovery event to worker thread */
phba->fcf.fcf_flag |= FCF_REDISC_EVT;
spin_unlock_irq(&phba->hbalock);
/* wake up worker thread */
lpfc_worker_wake_up(phba);
}
/** /**
* lpfc_sli4_fw_cfg_check - Read the firmware config and verify FCoE support * lpfc_sli4_fw_cfg_check - Read the firmware config and verify FCoE support
* @phba: pointer to lpfc hba data structure. * @phba: pointer to lpfc hba data structure.
...@@ -3020,17 +3110,26 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, ...@@ -3020,17 +3110,26 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
phba->fcoe_eventtag = acqe_fcoe->event_tag; phba->fcoe_eventtag = acqe_fcoe->event_tag;
switch (event_type) { switch (event_type) {
case LPFC_FCOE_EVENT_TYPE_NEW_FCF: case LPFC_FCOE_EVENT_TYPE_NEW_FCF:
case LPFC_FCOE_EVENT_TYPE_FCF_PARAM_MOD:
lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
"2546 New FCF found index 0x%x tag 0x%x\n", "2546 New FCF found index 0x%x tag 0x%x\n",
acqe_fcoe->index, acqe_fcoe->index,
acqe_fcoe->event_tag); acqe_fcoe->event_tag);
/*
* If the current FCF is in discovered state, or
* FCF discovery is in progress do nothing.
*/
spin_lock_irq(&phba->hbalock); spin_lock_irq(&phba->hbalock);
if ((phba->fcf.fcf_flag & FCF_DISCOVERED) || if ((phba->fcf.fcf_flag & FCF_SCAN_DONE) ||
(phba->hba_flag & FCF_DISC_INPROGRESS)) { (phba->hba_flag & FCF_DISC_INPROGRESS)) {
/*
* If the current FCF is in discovered state or
* FCF discovery is in progress, do nothing.
*/
spin_unlock_irq(&phba->hbalock);
break;
}
if (phba->fcf.fcf_flag & FCF_REDISC_EVT) {
/*
* If fast FCF failover rescan event is pending,
* do nothing.
*/
spin_unlock_irq(&phba->hbalock); spin_unlock_irq(&phba->hbalock);
break; break;
} }
...@@ -3057,7 +3156,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, ...@@ -3057,7 +3156,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
" tag 0x%x\n", acqe_fcoe->index, " tag 0x%x\n", acqe_fcoe->index,
acqe_fcoe->event_tag); acqe_fcoe->event_tag);
/* If the event is not for currently used fcf do nothing */ /* If the event is not for currently used fcf do nothing */
if (phba->fcf.fcf_indx != acqe_fcoe->index) if (phba->fcf.current_rec.fcf_indx != acqe_fcoe->index)
break; break;
/* /*
* Currently, driver support only one FCF - so treat this as * Currently, driver support only one FCF - so treat this as
...@@ -3121,6 +3220,18 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, ...@@ -3121,6 +3220,18 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
ndlp->nlp_last_elscmd = ELS_CMD_FDISC; ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
vport->port_state = LPFC_FDISC; vport->port_state = LPFC_FDISC;
} else { } else {
/*
* Otherwise, we request port to rediscover
* the entire FCF table for a fast recovery
* from possible case that the current FCF
* is no longer valid.
*/
rc = lpfc_sli4_redisc_fcf_table(phba);
if (rc)
/*
* Last resort will be re-try on the
* the current registered FCF entry.
*/
lpfc_retry_pport_discovery(phba); lpfc_retry_pport_discovery(phba);
} }
break; break;
...@@ -3197,6 +3308,34 @@ void lpfc_sli4_async_event_proc(struct lpfc_hba *phba) ...@@ -3197,6 +3308,34 @@ void lpfc_sli4_async_event_proc(struct lpfc_hba *phba)
} }
} }
/**
* lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
* @phba: pointer to lpfc hba data structure.
*
* This routine is invoked by the worker thread to process FCF table
* rediscovery pending completion event.
**/
void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *phba)
{
int rc;
spin_lock_irq(&phba->hbalock);
/* Clear FCF rediscovery timeout event */
phba->fcf.fcf_flag &= ~FCF_REDISC_EVT;
/* Clear driver fast failover FCF record flag */
phba->fcf.failover_rec.flag = 0;
/* Set state for FCF fast failover */
phba->fcf.fcf_flag |= FCF_REDISC_FOV;
spin_unlock_irq(&phba->hbalock);
/* Scan FCF table from the first entry to re-discover SAN */
rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST);
if (rc)
lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
"2747 Post FCF rediscovery read FCF record "
"failed 0x%x\n", rc);
}
/** /**
* lpfc_api_table_setup - Set up per hba pci-device group func api jump table * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
* @phba: pointer to lpfc hba data structure. * @phba: pointer to lpfc hba data structure.
...@@ -3512,6 +3651,11 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) ...@@ -3512,6 +3651,11 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
init_timer(&phba->eratt_poll); init_timer(&phba->eratt_poll);
phba->eratt_poll.function = lpfc_poll_eratt; phba->eratt_poll.function = lpfc_poll_eratt;
phba->eratt_poll.data = (unsigned long) phba; phba->eratt_poll.data = (unsigned long) phba;
/* FCF rediscover timer */
init_timer(&phba->fcf.redisc_wait);
phba->fcf.redisc_wait.function = lpfc_sli4_fcf_redisc_wait_tmo;
phba->fcf.redisc_wait.data = (unsigned long)phba;
/* /*
* We need to do a READ_CONFIG mailbox command here before * We need to do a READ_CONFIG mailbox command here before
* calling lpfc_get_cfgparam. For VFs this will report the * calling lpfc_get_cfgparam. For VFs this will report the
...@@ -6039,7 +6183,7 @@ lpfc_sli4_fcfi_unreg(struct lpfc_hba *phba, uint16_t fcfi) ...@@ -6039,7 +6183,7 @@ lpfc_sli4_fcfi_unreg(struct lpfc_hba *phba, uint16_t fcfi)
spin_lock_irqsave(&phba->hbalock, flags); spin_lock_irqsave(&phba->hbalock, flags);
/* Mark the FCFI is no longer registered */ /* Mark the FCFI is no longer registered */
phba->fcf.fcf_flag &= phba->fcf.fcf_flag &=
~(FCF_AVAILABLE | FCF_REGISTERED | FCF_DISCOVERED); ~(FCF_AVAILABLE | FCF_REGISTERED | FCF_SCAN_DONE);
spin_unlock_irqrestore(&phba->hbalock, flags); spin_unlock_irqrestore(&phba->hbalock, flags);
} }
} }
......
...@@ -1746,6 +1746,65 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) ...@@ -1746,6 +1746,65 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request); return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request);
} }
/**
* lpfc_sli4_mbx_read_fcf_record - Allocate and construct read fcf mbox cmd
* @phba: pointer to lpfc hba data structure.
* @fcf_index: index to fcf table.
*
* This routine routine allocates and constructs non-embedded mailbox command
* for reading a FCF table entry refered by @fcf_index.
*
* Return: pointer to the mailbox command constructed if successful, otherwise
* NULL.
**/
int
lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *phba,
struct lpfcMboxq *mboxq,
uint16_t fcf_index)
{
void *virt_addr;
dma_addr_t phys_addr;
uint8_t *bytep;
struct lpfc_mbx_sge sge;
uint32_t alloc_len, req_len;
struct lpfc_mbx_read_fcf_tbl *read_fcf;
if (!mboxq)
return -ENOMEM;
req_len = sizeof(struct fcf_record) +
sizeof(union lpfc_sli4_cfg_shdr) + 2 * sizeof(uint32_t);
/* Set up READ_FCF SLI4_CONFIG mailbox-ioctl command */
alloc_len = lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_FCOE,
LPFC_MBOX_OPCODE_FCOE_READ_FCF_TABLE, req_len,
LPFC_SLI4_MBX_NEMBED);
if (alloc_len < req_len) {
lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
"0291 Allocated DMA memory size (x%x) is "
"less than the requested DMA memory "
"size (x%x)\n", alloc_len, req_len);
return -ENOMEM;
}
/* Get the first SGE entry from the non-embedded DMA memory. This
* routine only uses a single SGE.
*/
lpfc_sli4_mbx_sge_get(mboxq, 0, &sge);
phys_addr = getPaddr(sge.pa_hi, sge.pa_lo);
virt_addr = mboxq->sge_array->addr[0];
read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr;
/* Set up command fields */
bf_set(lpfc_mbx_read_fcf_tbl_indx, &read_fcf->u.request, fcf_index);
/* Perform necessary endian conversion */
bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr);
lpfc_sli_pcimem_bcopy(bytep, bytep, sizeof(uint32_t));
return 0;
}
/** /**
* lpfc_request_features: Configure SLI4 REQUEST_FEATURES mailbox * lpfc_request_features: Configure SLI4 REQUEST_FEATURES mailbox
* @mboxq: pointer to lpfc mbox command. * @mboxq: pointer to lpfc mbox command.
...@@ -1946,13 +2005,14 @@ lpfc_reg_fcfi(struct lpfc_hba *phba, struct lpfcMboxq *mbox) ...@@ -1946,13 +2005,14 @@ lpfc_reg_fcfi(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
bf_set(lpfc_reg_fcfi_rq_id1, reg_fcfi, REG_FCF_INVALID_QID); bf_set(lpfc_reg_fcfi_rq_id1, reg_fcfi, REG_FCF_INVALID_QID);
bf_set(lpfc_reg_fcfi_rq_id2, reg_fcfi, REG_FCF_INVALID_QID); bf_set(lpfc_reg_fcfi_rq_id2, reg_fcfi, REG_FCF_INVALID_QID);
bf_set(lpfc_reg_fcfi_rq_id3, reg_fcfi, REG_FCF_INVALID_QID); bf_set(lpfc_reg_fcfi_rq_id3, reg_fcfi, REG_FCF_INVALID_QID);
bf_set(lpfc_reg_fcfi_info_index, reg_fcfi, phba->fcf.fcf_indx); bf_set(lpfc_reg_fcfi_info_index, reg_fcfi,
phba->fcf.current_rec.fcf_indx);
/* reg_fcf addr mode is bit wise inverted value of fcf addr_mode */ /* reg_fcf addr mode is bit wise inverted value of fcf addr_mode */
bf_set(lpfc_reg_fcfi_mam, reg_fcfi, bf_set(lpfc_reg_fcfi_mam, reg_fcfi, (~phba->fcf.addr_mode) & 0x3);
(~phba->fcf.addr_mode) & 0x3); if (phba->fcf.current_rec.vlan_id != 0xFFFF) {
if (phba->fcf.fcf_flag & FCF_VALID_VLAN) {
bf_set(lpfc_reg_fcfi_vv, reg_fcfi, 1); bf_set(lpfc_reg_fcfi_vv, reg_fcfi, 1);
bf_set(lpfc_reg_fcfi_vlan_tag, reg_fcfi, phba->fcf.vlan_id); bf_set(lpfc_reg_fcfi_vlan_tag, reg_fcfi,
phba->fcf.current_rec.vlan_id);
} }
} }
......
...@@ -11956,12 +11956,6 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) ...@@ -11956,12 +11956,6 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index)
{ {
int rc = 0, error; int rc = 0, error;
LPFC_MBOXQ_t *mboxq; LPFC_MBOXQ_t *mboxq;
void *virt_addr;
dma_addr_t phys_addr;
uint8_t *bytep;
struct lpfc_mbx_sge sge;
uint32_t alloc_len, req_len;
struct lpfc_mbx_read_fcf_tbl *read_fcf;
phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag;
mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
...@@ -11972,43 +11966,19 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) ...@@ -11972,43 +11966,19 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index)
error = -ENOMEM; error = -ENOMEM;
goto fail_fcfscan; goto fail_fcfscan;
} }
/* Construct the read FCF record mailbox command */
req_len = sizeof(struct fcf_record) + rc = lpfc_sli4_mbx_read_fcf_record(phba, mboxq, fcf_index);
sizeof(union lpfc_sli4_cfg_shdr) + 2 * sizeof(uint32_t); if (rc) {
error = -EINVAL;
/* Set up READ_FCF SLI4_CONFIG mailbox-ioctl command */
alloc_len = lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_FCOE,
LPFC_MBOX_OPCODE_FCOE_READ_FCF_TABLE, req_len,
LPFC_SLI4_MBX_NEMBED);
if (alloc_len < req_len) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0291 Allocated DMA memory size (x%x) is "
"less than the requested DMA memory "
"size (x%x)\n", alloc_len, req_len);
error = -ENOMEM;
goto fail_fcfscan; goto fail_fcfscan;
} }
/* Issue the mailbox command asynchronously */
/* Get the first SGE entry from the non-embedded DMA memory. This
* routine only uses a single SGE.
*/
lpfc_sli4_mbx_sge_get(mboxq, 0, &sge);
phys_addr = getPaddr(sge.pa_hi, sge.pa_lo);
virt_addr = mboxq->sge_array->addr[0];
read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr;
/* Set up command fields */
bf_set(lpfc_mbx_read_fcf_tbl_indx, &read_fcf->u.request, fcf_index);
/* Perform necessary endian conversion */
bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr);
lpfc_sli_pcimem_bcopy(bytep, bytep, sizeof(uint32_t));
mboxq->vport = phba->pport; mboxq->vport = phba->pport;
mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record; mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record;
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
if (rc == MBX_NOT_FINISHED) { if (rc == MBX_NOT_FINISHED)
error = -EIO; error = -EIO;
} else { else {
spin_lock_irq(&phba->hbalock); spin_lock_irq(&phba->hbalock);
phba->hba_flag |= FCF_DISC_INPROGRESS; phba->hba_flag |= FCF_DISC_INPROGRESS;
spin_unlock_irq(&phba->hbalock); spin_unlock_irq(&phba->hbalock);
...@@ -12026,6 +11996,90 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) ...@@ -12026,6 +11996,90 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index)
return error; return error;
} }
/**
* lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
* @phba: pointer to lpfc hba data structure.
*
* This routine is the completion routine for the rediscover FCF table mailbox
* command. If the mailbox command returned failure, it will try to stop the
* FCF rediscover wait timer.
**/
void
lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
{
struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf;
uint32_t shdr_status, shdr_add_status;
redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl;
shdr_status = bf_get(lpfc_mbox_hdr_status,
&redisc_fcf->header.cfg_shdr.response);
shdr_add_status = bf_get(lpfc_mbox_hdr_add_status,
&redisc_fcf->header.cfg_shdr.response);
if (shdr_status || shdr_add_status) {
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
"2746 Requesting for FCF rediscovery failed "
"status x%x add_status x%x\n",
shdr_status, shdr_add_status);
/*
* Request failed, last resort to re-try current
* registered FCF entry
*/
lpfc_retry_pport_discovery(phba);
} else
/*
* Start FCF rediscovery wait timer for pending FCF
* before rescan FCF record table.
*/
lpfc_fcf_redisc_wait_start_timer(phba);
mempool_free(mbox, phba->mbox_mem_pool);
}
/**
* lpfc_sli4_redisc_all_fcf - Request to rediscover entire FCF table by port.
* @phba: pointer to lpfc hba data structure.
*
* This routine is invoked to request for rediscovery of the entire FCF table
* by the port.
**/
int
lpfc_sli4_redisc_fcf_table(struct lpfc_hba *phba)
{
LPFC_MBOXQ_t *mbox;
struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf;
int rc, length;
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!mbox) {
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
"2745 Failed to allocate mbox for "
"requesting FCF rediscover.\n");
return -ENOMEM;
}
length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) -
sizeof(struct lpfc_sli4_cfg_mhdr));
lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE,
LPFC_MBOX_OPCODE_FCOE_REDISCOVER_FCF,
length, LPFC_SLI4_MBX_EMBED);
redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl;
/* Set count to 0 for invalidating the entire FCF database */
bf_set(lpfc_mbx_redisc_fcf_count, redisc_fcf, 0);
/* Issue the mailbox command asynchronously */
mbox->vport = phba->pport;
mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table;
rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
if (rc == MBX_NOT_FINISHED) {
mempool_free(mbox, phba->mbox_mem_pool);
return -EIO;
}
return 0;
}
/** /**
* lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled. * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
* @phba: pointer to lpfc hba data structure. * @phba: pointer to lpfc hba data structure.
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#define LPFC_RELEASE_NOTIFICATION_INTERVAL 32 #define LPFC_RELEASE_NOTIFICATION_INTERVAL 32
#define LPFC_GET_QE_REL_INT 32 #define LPFC_GET_QE_REL_INT 32
#define LPFC_RPI_LOW_WATER_MARK 10 #define LPFC_RPI_LOW_WATER_MARK 10
/* Amount of time in seconds for waiting FCF rediscovery to complete */
#define LPFC_FCF_REDISCOVER_WAIT_TMO 2000 /* msec */
/* Number of SGL entries can be posted in a 4KB nonembedded mbox command */ /* Number of SGL entries can be posted in a 4KB nonembedded mbox command */
#define LPFC_NEMBED_MBOX_SGL_CNT 254 #define LPFC_NEMBED_MBOX_SGL_CNT 254
...@@ -129,22 +133,33 @@ struct lpfc_sli4_link { ...@@ -129,22 +133,33 @@ struct lpfc_sli4_link {
uint16_t logical_speed; uint16_t logical_speed;
}; };
struct lpfc_fcf { struct lpfc_fcf_rec {
uint8_t fabric_name[8]; uint8_t fabric_name[8];
uint8_t switch_name[8]; uint8_t switch_name[8];
uint8_t mac_addr[6]; uint8_t mac_addr[6];
uint16_t fcf_indx; uint16_t fcf_indx;
uint32_t priority;
uint16_t vlan_id;
uint32_t addr_mode;
uint32_t flag;
#define BOOT_ENABLE 0x01
#define RECORD_VALID 0x02
};
struct lpfc_fcf {
uint16_t fcfi; uint16_t fcfi;
uint32_t fcf_flag; uint32_t fcf_flag;
#define FCF_AVAILABLE 0x01 /* FCF available for discovery */ #define FCF_AVAILABLE 0x01 /* FCF available for discovery */
#define FCF_REGISTERED 0x02 /* FCF registered with FW */ #define FCF_REGISTERED 0x02 /* FCF registered with FW */
#define FCF_DISCOVERED 0x04 /* FCF discovery started */ #define FCF_SCAN_DONE 0x04 /* FCF table scan done */
#define FCF_BOOT_ENABLE 0x08 /* Boot bios use this FCF */ #define FCF_IN_USE 0x08 /* Atleast one discovery completed */
#define FCF_IN_USE 0x10 /* Atleast one discovery completed */ #define FCF_REDISC_PEND 0x10 /* FCF rediscovery pending */
#define FCF_VALID_VLAN 0x20 /* Use the vlan id specified */ #define FCF_REDISC_EVT 0x20 /* FCF rediscovery event to worker thread */
uint32_t priority; #define FCF_REDISC_FOV 0x40 /* Post FCF rediscovery fast failover */
uint32_t addr_mode; uint32_t addr_mode;
uint16_t vlan_id; struct lpfc_fcf_rec current_rec;
struct lpfc_fcf_rec failover_rec;
struct timer_list redisc_wait;
}; };
#define LPFC_REGION23_SIGNATURE "RG23" #define LPFC_REGION23_SIGNATURE "RG23"
...@@ -407,6 +422,8 @@ void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *); ...@@ -407,6 +422,8 @@ void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *);
void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t); void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t);
void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t, void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t,
struct lpfc_mbx_sge *); struct lpfc_mbx_sge *);
int lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *, struct lpfcMboxq *,
uint16_t);
void lpfc_sli4_hba_reset(struct lpfc_hba *); void lpfc_sli4_hba_reset(struct lpfc_hba *);
struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t, struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t,
...@@ -449,6 +466,7 @@ int lpfc_sli4_alloc_rpi(struct lpfc_hba *); ...@@ -449,6 +466,7 @@ int lpfc_sli4_alloc_rpi(struct lpfc_hba *);
void lpfc_sli4_free_rpi(struct lpfc_hba *, int); void lpfc_sli4_free_rpi(struct lpfc_hba *, int);
void lpfc_sli4_remove_rpis(struct lpfc_hba *); void lpfc_sli4_remove_rpis(struct lpfc_hba *);
void lpfc_sli4_async_event_proc(struct lpfc_hba *); void lpfc_sli4_async_event_proc(struct lpfc_hba *);
void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *);
int lpfc_sli4_resume_rpi(struct lpfc_nodelist *); int lpfc_sli4_resume_rpi(struct lpfc_nodelist *);
void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *); void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *);
void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *); void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *);
......
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