lpfc: Add TM v9.4 target hooks into LPFC v8.3.12
Subsystems (2)
PATCH 2/2 lpfc: Add TM v9.4 target hooks into LPFC v8.3.12
From: Nicholas Bellinger <[email protected]>
This patch contains a forward port from SF_lpfcdriver_8_2_8_14_tm_9_4 into LPFC to add the necessary support for handling target mode operation.
This includes the necessary changes in initialization, ELS, and SLIport v3 HW and TGTports v3. Note that the LPFC_TARGET_MODE stubs have been left in place for rev1 of the patch for reference, and will be removed once the latest TM v9.5 with support for TM API v3 is merged.
--- drivers/scsi/lpfc/lpfc.h | 18 +++ drivers/scsi/lpfc/lpfc_attr.c | 78 ++++++++++++- drivers/scsi/lpfc/lpfc_crtn.h | 23 ++++ drivers/scsi/lpfc/lpfc_ct.c | 10 ++ drivers/scsi/lpfc/lpfc_debugfs.c | 4 + drivers/scsi/lpfc/lpfc_disc.h | 21 ++++ drivers/scsi/lpfc/lpfc_els.c | 134 +++++++++++++++++++++- drivers/scsi/lpfc/lpfc_hbadisc.c | 74 +++++++++++- drivers/scsi/lpfc/lpfc_hw.h | 136 +++++++++++++++++++++- drivers/scsi/lpfc/lpfc_init.c | 18 +++ drivers/scsi/lpfc/lpfc_logmsg.h | 1 + drivers/scsi/lpfc/lpfc_mbox.c | 9 ++ drivers/scsi/lpfc/lpfc_mem.c | 8 ++ drivers/scsi/lpfc/lpfc_nportdisc.c | 140 ++++++++++++++++++++++- drivers/scsi/lpfc/lpfc_scsi.c | 4 + drivers/scsi/lpfc/lpfc_sli.c | 223 ++++++++++++++++++++++++++++++++++-- drivers/scsi/lpfc/lpfc_sli.h | 40 +++++++ drivers/scsi/lpfc/lpfc_vport.c | 17 +++ 18 files changed, 936 insertions(+), 22 deletions(-)
drivers/scsi/lpfc/lpfc.h +18 -0
@@ -418,6 +418,10 @@ struct lpfc_vport {unsigned long rcv_buffer_time_stamp;uint32_t vport_flag;#define STATIC_VPORT 1 + +#if definedLPFC_TARGET_MODE && defined _H_LPFC_TGT_API_BASE +tm_tgtport_t target_tgtport; +#endif };struct hbq_s {
@@ -816,6 +820,20 @@ struct lpfc_hba {uint8_t menlo_flag;/* menlo generic flags */ #define HBA_MENLO_SUPPORT 0x1/* HBA supports menlo commands */ + +#if definedLPFC_TARGET_MODE && defined _H_LPFC_TGT_API_BASE +uint32_t cfg_initialize_link; +uint32_t cfg_tgt_brings_link_up; +uint32_t cfg_fcp_mode; +#define LPFC_FCP_MODE_INITIATOR 1 +#define LPFC_FCP_MODE_TARGET 2 +uint32_t poll_rsp_cnt; +uint32_t num_targets_bound; +uint32_t tm_terp_capabilities; + +tm_sliport_t target_sliport; +tm_driver_data_t *tgt_data; +#endif }; static inline struct Scsi_Host *
drivers/scsi/lpfc/lpfc_attr.c +77 -1
119 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_crtn.h +23 -0
@@ -101,6 +101,9 @@ void lpfc_cleanup(struct lpfc_vport *);void lpfc_disc_timeout (unsigned long );struct lpfc_nodelist *__lpfc_findnode_rpi (struct lpfc_vport *,uint16_t ); +#ifdef LPFC_TARGET_MODE +struct lpfc_nodelist *lpfc_findnode_rpi (struct lpfc_vport *,uint16_t ); +#endif void lpfc_worker_wake_up (struct lpfc_hba *);int lpfc_workq_post_event (struct lpfc_hba *,void *,void *,uint32_t );
@@ -282,8 +285,15 @@ struct lpfc_dmabuf * lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *,int lpfc_sli_hbq_count (void );int lpfc_sli_hbqbuf_add_hbqs (struct lpfc_hba *,uint32_t ); +#ifdef LPFC_TARGET_MODE +int lpfc_sli_hbqbuf_fill_hbqs (struct lpfc_hba *,uint32_t ,uint32_t ); +#endif void lpfc_sli_hbqbuf_free_all (struct lpfc_hba *);int lpfc_sli_hbq_size (void ); +#ifdef LPFC_TARGET_MODE +int lpfc_get_hba_info (struct lpfc_hba *phba,uint32_t *mxri,uint32_t *axri, +uint32_t *mrpi,uint32_t *arpi,uint32_t *mvpi,uint32_t *avpi); +#endif int lpfc_sli_issue_abort_iotag (struct lpfc_hba *,struct lpfc_sli_ring *,struct lpfc_iocbq *);int lpfc_sli_sum_iocb (struct lpfc_vport *,uint16_t ,uint64_t ,lpfc_ctx_cmd );
@@ -382,6 +392,19 @@ lpfc_send_els_failure_event(struct lpfc_hba *, struct lpfc_iocbq *, struct lpfc_iocbq *);struct lpfc_fast_path_event *lpfc_alloc_fast_evt (struct lpfc_hba *);void lpfc_free_fast_evt (struct lpfc_hba *,struct lpfc_fast_path_event *); + +#ifdef LPFC_TARGET_MODE +void lpfc_tm_get_hba_terp_cap (struct lpfc_hba *phba); + +extern struct lpfc_hbq_init *lpfc_hbq_defs[]; + +void lpfc_tm_hbq_free (struct lpfc_hba *phba,struct hbq_dmabuf *hbqbp); +void lpfc_tm_recv_unsol (struct lpfc_hba *phba, +struct lpfc_sli_ring *pring,struct lpfc_iocbq *iocb); +struct hbq_dmabuf *lpfc_tm_hbq_alloc (struct lpfc_hba *phba); +void lpfc_tm_hbq_free (struct lpfc_hba *phba,struct hbq_dmabuf *hbqbp); +#endif +void lpfc_create_static_vport (struct lpfc_hba *);void lpfc_stop_hba_timers (struct lpfc_hba *);void lpfc_stop_port (struct lpfc_hba *);
drivers/scsi/lpfc/lpfc_ct.c +10 -0
@@ -38,6 +38,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
@@ -1252,7 +1256,13 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, CtReq->CommandResponse.bits.CmdRsp =be16_to_cpu (SLI_CTNS_RFF_ID ); CtReq->un.rff.PortId =cpu_to_be32 (vport->fc_myDID); +#ifdef LPFC_TARGET_MODE + CtReq->un.rff.fbits =0 ; +if (phba->cfg_fcp_mode &LPFC_FCP_MODE_INITIATOR ) + CtReq->un.rff.fbits =FC4_FEATURE_INIT ; +#else CtReq->un.rff.fbits =FC4_FEATURE_INIT ; +#endif CtReq->un.rff.type_code =FC_TYPE_FCP ; cmpl = lpfc_cmpl_ct_cmd_rff_id;break ;
drivers/scsi/lpfc/lpfc_debugfs.c +4 -0
@@ -38,6 +38,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
drivers/scsi/lpfc/lpfc_disc.h +21 -0
@@ -111,6 +111,23 @@ struct lpfc_nodelist {uint32_t cmd_qdepth;unsigned long last_change_time;struct lpfc_scsicmd_bkt *lat_data;/* Latency data */ +#if definedLPFC_TARGET_MODE && defined _H_LPFC_TGT_API +tm_login_info_t tm_login_info; +tm_login_handle_t login_handle; +uint32_t tm_check_login_result; +uint8_t tm_check_login_called; +uint8_t login_handle_valid; +uint16_t tm_login_flags; +#define NLP_TM_DELAYED_LOGIN 0x8000 +#define NLP_TM_FCP_CONF 0x0001 +#define NLP_TM_FCP_RETRY 0x0002 +#define NLP_TM_FCP_RETRY_ID 0x0004 +#define NLP_TM_CISC_MODE 0x0008 +#define NLP_TM_FCP_4_ERP \ + (NLP_TM_FCP_CONF | NLP_TM_FCP_RETRY | NLP_TM_FCP_RETRY_ID) +uint16_t tm_node_capabilities; +#endif + };/* Defines for nlp_flag (uint32) */
@@ -135,6 +152,10 @@ struct lpfc_nodelist {#define NLP_TARGET_REMOVE 0x10000000/* Target remove in process */ #define NLP_SC_REQ 0x20000000/* Target requires authentication */ #define NLP_RPI_VALID 0x80000000/* nlp_rpi is valid */ +#ifdef LPFC_TARGET_MODE +#define NLP_NEED_PRLI 0x40000000/* Need PRLI to determine capability */ +#define NLP_SKIP_REDISC 0x80000000/* Skip rediscovery via ADISC */ +#endif /* ndlp usage management macros */ #define NLP_CHK_NODE_ACT (ndlp) (((ndlp)->nlp_usg_map \
drivers/scsi/lpfc/lpfc_els.c +131 -3
205 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hbadisc.c +69 -5
135 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hw.h +133 -3
197 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_init.c +18 -0
@@ -40,6 +40,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
@@ -615,6 +619,12 @@ lpfc_config_port_post(struct lpfc_hba *phba)mempool_free (pmb, phba->mbox_mem_pool); } +#ifdef LPFC_TARGET_MODE +lpfc_tm_get_hba_terp_cap (phba); + +if (!phba->cfg_initialize_link) +return 0 ; +#endif return 0 ; }
@@ -5021,6 +5031,14 @@ lpfc_post_init_setup(struct lpfc_hba *phba)lpfc_printf_log (phba,KERN_INFO ,LOG_INIT ,"0428 Perform SCSI scan\n" ); + +#ifdef LPFC_TARGET_MODE +if (!phba->cfg_initialize_link) { +/* After initialization, this should always be set */ + phba->cfg_initialize_link =1 ; +return ; + } +#endif /* Send board arrival event to upper layer */ adapter_event.event_type =FC_REG_ADAPTER_EVENT ; adapter_event.subcategory =LPFC_EVENT_ARRIVAL ;
drivers/scsi/lpfc/lpfc_logmsg.h +1 -0
@@ -36,6 +36,7 @@#define LOF_SECURITY 0x00008000/* Security events */ #define LOG_EVENT 0x00010000/* CT,TEMP,DUMP, logging */ #define LOG_FIP 0x00020000/* FIP events */ +#define LOG_TARGET 0x00040000/* Target API events */ #define LOG_ALL_MSG 0xffffffff/* LOG all messages */ #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
drivers/scsi/lpfc/lpfc_mbox.c +9 -0
@@ -33,6 +33,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
@@ -535,6 +539,11 @@ lpfc_init_link(struct lpfc_hba * phba,else mb->un.varInitLnk.link_speed =LINK_SPEED_AUTO ; +#ifdef LPFC_TARGET_MODE +/* This flag must be set for FCP-4 tERP to work */ +if (phba->cfg_fcp_mode &LPFC_FCP_MODE_TARGET ) + mb->un.varInitLnk.link_flags |=FLAGS_DISABLE_TGT_ABTS ; +#endif mb->mbxCommand = (volatile uint8_t )MBX_INIT_LINK ; mb->mbxOwner =OWN_HOST ; mb->un.varInitLnk.fabric_AL_PA = phba->fc_pref_ALPA;
drivers/scsi/lpfc/lpfc_mem.c +8 -0
@@ -33,6 +33,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
@@ -522,6 +526,10 @@ lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp)if (hbq_entry->tag ==-1 ) { (phba->hbqs[LPFC_ELS_HBQ ].hbq_free_buffer) (phba, hbq_entry); +#ifdef LPFC_TARGET_MODE + }else if (hbq_entry->tag &QUE_BUFTAG_BIT ) { + (phba->hbqs[LPFC_ELS_HBQ ].hbq_free_buffer)(phba, hbq_entry); +#endif }else {lpfc_sli_free_hbq (phba, hbq_entry); }
drivers/scsi/lpfc/lpfc_nportdisc.c +139 -1
198 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_scsi.c +4 -0
@@ -36,6 +36,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
drivers/scsi/lpfc/lpfc_sli.c +214 -9
370 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_sli.h +40 -0
@@ -297,3 +297,43 @@ struct lpfc_sli {* multiple flash erases that can be * spawned. */ +#ifdef LPFC_TARGET_MODE + +/* +* Functions to build or extract fields for HBQ buffer tags. +* The libdfc functions use the high order bit (bit 31) aka +* QUE_BUFTAG_BIT. Since we will never use more than 7 HBQs, +* the hbqno occupies only bits 30:28. The the hbqno is in 30:28, +* applications tag is in bits 27:14, the hbq entry index +* is in bits 13:0. +*/ + +#define LPFC_MAX_HBQ_ENTRIES 0x3fff + +static inline uint32_t +lpfc_build_hbq_tag (uint16_t hbqno,uint16_t hbqidx,uint16_t app_tag) +{ +return ((hbqno &0x7 ) <<28 ) | + ((app_tag &LPFC_MAX_HBQ_ENTRIES ) <<14 ) | + (hbqidx &LPFC_MAX_HBQ_ENTRIES ); +} + +static inline uint16_t +lpfc_hbq_app_tag_get (uint32_t tag) +{ +return (tag >>14 ) &LPFC_MAX_HBQ_ENTRIES ; +} + +static inline uint16_t +lpfc_hbq_idx_get (uint32_t tag) +{ +return tag &LPFC_MAX_HBQ_ENTRIES ; +} + +static inline uint16_t +lpfc_hbqno_get (uint32_t tag) +{ +return (tag >>28 ) &0x7 ; +} + +#endif
drivers/scsi/lpfc/lpfc_vport.c +17 -0
@@ -37,6 +37,10 @@#include "lpfc_hw.h" #include "lpfc_sli.h" #include "lpfc_sli4.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_api.h" +#include "lpfc_target_api_base.h" +#endif #include "lpfc_nl.h" #include "lpfc_disc.h" #include "lpfc_scsi.h"
@@ -45,6 +49,9 @@#include "lpfc_crtn.h" #include "lpfc_version.h" #include "lpfc_vport.h" +#ifdef LPFC_TARGET_MODE +#include "lpfc_target_protos.h" +#endif inline void lpfc_vport_set_state (struct lpfc_vport *vport,enum fc_vport_state new_state)
@@ -416,6 +423,11 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable) goto out; } +#ifdef LPFC_TARGET_MODE +if (phba->cfg_fcp_mode &LPFC_FCP_MODE_TARGET ) +lpfc_target_new_tgtport (vport); +#endif +if ((phba->link_state <LPFC_LINK_UP ) || (pport->port_state <LPFC_FABRIC_CFG_LINK ) || (phba->fc_topology ==TOPOLOGY_LOOP )) {
@@ -739,6 +751,11 @@ skip_logo: }else scsi_host_put (shost); +#ifdef LPFC_TARGET_MODE +if (phba->cfg_fcp_mode &LPFC_FCP_MODE_TARGET ) +lpfc_tm_tgtport_unbind (vport); +#endif +lpfc_free_vpi (phba, vport->vpi); vport->work_port_events =0 ;spin_lock_irq (&phba->hbalock);
Signature · 1 line
1.5.6.5