1dea3101eS /******************************************************************* 2dea3101eS * This file is part of the Emulex Linux Device Driver for * 3c44ce173SJames.Smart@Emulex.Com * Fibre Channel Host Bus Adapters. * 4f45775bfSJames Smart * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * 54ae2ebdeSJames Smart * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 651f4ca3cSJames Smart * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7c44ce173SJames.Smart@Emulex.Com * EMULEX and SLI are trademarks of Emulex. * 8d080abe0SJames Smart * www.broadcom.com * 9dea3101eS * * 10dea3101eS * This program is free software; you can redistribute it and/or * 11c44ce173SJames.Smart@Emulex.Com * modify it under the terms of version 2 of the GNU General * 12c44ce173SJames.Smart@Emulex.Com * Public License as published by the Free Software Foundation. * 13c44ce173SJames.Smart@Emulex.Com * This program is distributed in the hope that it will be useful. * 14c44ce173SJames.Smart@Emulex.Com * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * 15c44ce173SJames.Smart@Emulex.Com * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * 16c44ce173SJames.Smart@Emulex.Com * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * 17c44ce173SJames.Smart@Emulex.Com * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * 18c44ce173SJames.Smart@Emulex.Com * TO BE LEGALLY INVALID. See the GNU General Public License for * 19c44ce173SJames.Smart@Emulex.Com * more details, a copy of which can be found in the file COPYING * 20c44ce173SJames.Smart@Emulex.Com * included with this package. * 21dea3101eS *******************************************************************/ 22dea3101eS 23c490850aSJames Smart #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS) 24c490850aSJames Smart #define CONFIG_SCSI_LPFC_DEBUG_FS 25c490850aSJames Smart #endif 26c490850aSJames Smart 27dea3101eS /* forward declaration for LPFC_IOCB_t's use */ 28dea3101eS struct lpfc_hba; 292e0fef85SJames Smart struct lpfc_vport; 30dea3101eS 31dea3101eS /* Define the context types that SLI handles for abort and sums. */ 32dea3101eS typedef enum _lpfc_ctx_cmd { 33dea3101eS LPFC_CTX_LUN, 34dea3101eS LPFC_CTX_TGT, 35dea3101eS LPFC_CTX_HOST 36dea3101eS } lpfc_ctx_cmd; 37dea3101eS 38*ef47575fSJames Smart /* Enumeration to describe the thread lock context. */ 39*ef47575fSJames Smart enum lpfc_mbox_ctx { 40*ef47575fSJames Smart MBOX_THD_UNLOCKED, 41*ef47575fSJames Smart MBOX_THD_LOCKED 42*ef47575fSJames Smart }; 43*ef47575fSJames Smart 44a680a929SJames Smart union lpfc_vmid_tag { 4502169e84SGaurav Srivastava uint32_t app_id; 4602169e84SGaurav Srivastava uint8_t cs_ctl_vmid; 4702169e84SGaurav Srivastava struct lpfc_vmid_context *vmid_context; /* UVEM context information */ 4802169e84SGaurav Srivastava }; 4902169e84SGaurav Srivastava 504d9ab994SJames Smart struct lpfc_cq_event { 514d9ab994SJames Smart struct list_head list; 525e5b511dSJames Smart uint16_t hdwq; 534d9ab994SJames Smart union { 544d9ab994SJames Smart struct lpfc_mcqe mcqe_cmpl; 554d9ab994SJames Smart struct lpfc_acqe_link acqe_link; 5670f3c073SJames Smart struct lpfc_acqe_fip acqe_fip; 574d9ab994SJames Smart struct lpfc_acqe_dcbx acqe_dcbx; 58b19a061aSJames Smart struct lpfc_acqe_grp5 acqe_grp5; 5970f3c073SJames Smart struct lpfc_acqe_fc_la acqe_fc; 6070f3c073SJames Smart struct lpfc_acqe_sli acqe_sli; 614d9ab994SJames Smart struct lpfc_rcqe rcqe_cmpl; 624d9ab994SJames Smart struct sli4_wcqe_xri_aborted wcqe_axri; 634d9ab994SJames Smart struct lpfc_wcqe_complete wcqe_cmpl; 644d9ab994SJames Smart } cqe; 65da0436e9SJames Smart }; 66da0436e9SJames Smart 67dea3101eS /* This structure is used to handle IOCB requests / responses */ 68dea3101eS struct lpfc_iocbq { 69dea3101eS /* lpfc_iocbqs are used in double linked lists */ 70dea3101eS struct list_head list; 719c2face6SJames Smart struct list_head clist; 722a9bf3d0SJames Smart struct list_head dlist; 73604a3e30SJames Bottomley uint16_t iotag; /* pre-assigned IO tag */ 746d368e53SJames Smart uint16_t sli4_lxritag; /* logical pre-assigned XRI. */ 75da0436e9SJames Smart uint16_t sli4_xritag; /* pre-assigned XRI, (OXID) tag. */ 76895427bdSJames Smart uint16_t hba_wqidx; /* index to HBA work queue */ 7745ed1190SJames Smart struct lpfc_cq_event cq_event; 78895427bdSJames Smart uint64_t isr_timestamp; 79604a3e30SJames Bottomley 80205e8240SJames Smart union lpfc_wqe128 wqe; /* SLI-4 */ 81205e8240SJames Smart IOCB_t iocb; /* SLI-3 */ 82a680a929SJames Smart struct lpfc_wcqe_complete wcqe_cmpl; /* WQE cmpl */ 83895427bdSJames Smart 8461910d6aSJames Smart u32 unsol_rcv_len; /* Receive len in usol path */ 8531a59f75SJames Smart 86d51cf5bdSJames Smart /* Pack the u8's together and make them module-4. */ 87d51cf5bdSJames Smart u8 num_bdes; /* Number of BDEs */ 88d51cf5bdSJames Smart u8 abort_bls; /* ABTS by initiator or responder */ 8931a59f75SJames Smart u8 abort_rctl; /* ACC or RJT flag */ 90d51cf5bdSJames Smart u8 priority; /* OAS priority */ 91d51cf5bdSJames Smart u8 retry; /* retry counter for IOCB cmd - if needed */ 92d51cf5bdSJames Smart u8 rsvd1; /* Pad for u32 */ 93d51cf5bdSJames Smart u8 rsvd2; /* Pad for u32 */ 94d51cf5bdSJames Smart u8 rsvd3; /* Pad for u32 */ 9531a59f75SJames Smart 96a680a929SJames Smart u32 cmd_flag; 9768876920SJames.Smart@Emulex.Com #define LPFC_IO_LIBDFC 1 /* libdfc iocb */ 985a0916b4SJames Smart #define LPFC_IO_WAKE 2 /* Synchronous I/O completed */ 995a0916b4SJames Smart #define LPFC_IO_WAKE_TMO LPFC_IO_WAKE /* Synchronous I/O timed out */ 1000bd4ca25SJames.Smart@Emulex.Com #define LPFC_IO_FCP 4 /* FCP command -- iocbq in scsi_buf */ 10107951076SJames Smart #define LPFC_DRIVER_ABORTED 8 /* driver aborted this request */ 10292d7f7b0SJames Smart #define LPFC_IO_FABRIC 0x10 /* Iocb send using fabric scheduler */ 1030ff10d46SJames Smart #define LPFC_DELAY_MEM_FREE 0x20 /* Defer free'ing of FC data */ 104341af102SJames Smart #define LPFC_EXCHANGE_BUSY 0x40 /* SLI4 hba reported XB in response */ 105341af102SJames Smart #define LPFC_USE_FCPWQIDX 0x80 /* Submit to specified FCPWQ index */ 1060f65ff68SJames Smart #define DSS_SECURITY_OP 0x100 /* security IO */ 1074f2e66c6SJames Smart #define LPFC_IO_ON_TXCMPLQ 0x200 /* The IO is still on the TXCMPLQ */ 1088012cc38SJames Smart #define LPFC_IO_DIF_PASS 0x400 /* T10 DIF IO pass-thru prot */ 1098012cc38SJames Smart #define LPFC_IO_DIF_STRIP 0x800 /* T10 DIF IO strip prot */ 1108012cc38SJames Smart #define LPFC_IO_DIF_INSERT 0x1000 /* T10 DIF IO insert prot */ 1111b8d11abSJames Smart #define LPFC_IO_CMD_OUTSTANDING 0x2000 /* timeout handler abort window */ 112dea3101eS 113341af102SJames Smart #define LPFC_FIP_ELS_ID_MASK 0xc000 /* ELS_ID range 0-3, non-shifted mask */ 114341af102SJames Smart #define LPFC_FIP_ELS_ID_SHIFT 14 115341af102SJames Smart 1161ba981fdSJames Smart #define LPFC_IO_OAS 0x10000 /* OAS FCP IO */ 1179bd2bff5SJames Smart #define LPFC_IO_FOF 0x20000 /* FOF FCP IO */ 1186c7cf486SJames Smart #define LPFC_IO_LOOPBACK 0x40000 /* Loopback IO */ 119895427bdSJames Smart #define LPFC_PRLI_NVME_REQ 0x80000 /* This is an NVME PRLI. */ 120895427bdSJames Smart #define LPFC_PRLI_FCP_REQ 0x100000 /* This is an NVME PRLI. */ 121895427bdSJames Smart #define LPFC_IO_NVME 0x200000 /* NVME FCP command */ 122895427bdSJames Smart #define LPFC_IO_NVME_LS 0x400000 /* NVME LS command */ 123f358dd0cSJames Smart #define LPFC_IO_NVMET 0x800000 /* NVMET command */ 12402169e84SGaurav Srivastava #define LPFC_IO_VMID 0x1000000 /* VMID tagged IO */ 125daebf93fSJames Smart #define LPFC_IO_CMF 0x4000000 /* CMF command */ 1261ba981fdSJames Smart 127dea3101eS uint32_t drvrTimeout; /* driver timeout in seconds */ 1282e0fef85SJames Smart struct lpfc_vport *vport;/* virtual port pointer */ 129d51cf5bdSJames Smart struct lpfc_dmabuf *cmd_dmabuf; 130d51cf5bdSJames Smart struct lpfc_dmabuf *rsp_dmabuf; 131d51cf5bdSJames Smart struct lpfc_dmabuf *bpl_dmabuf; 13204c1d9c5SJames Smart uint32_t event_tag; /* LA Event tag */ 133dea3101eS union { 13468876920SJames.Smart@Emulex.Com wait_queue_head_t *wait_queue; 135dea3101eS struct lpfcMboxq *mbox; 13619ca7609SJames Smart struct lpfc_node_rrq *rrq; 137d51cf5bdSJames Smart struct nvmefc_ls_req *nvme_lsreq; 138d51cf5bdSJames Smart struct lpfc_async_xchg_ctx *axchg; 139d51cf5bdSJames Smart struct bsg_job_data *dd_data; 140dea3101eS } context_un; 141dea3101eS 142d51cf5bdSJames Smart struct lpfc_io_buf *io_buf; 143d51cf5bdSJames Smart struct lpfc_iocbq *rsp_iocb; 144d51cf5bdSJames Smart struct lpfc_nodelist *ndlp; 145a680a929SJames Smart union lpfc_vmid_tag vmid_tag; 146a680a929SJames Smart void (*fabric_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd, 147a680a929SJames Smart struct lpfc_iocbq *rsp); 148a680a929SJames Smart void (*wait_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd, 149a680a929SJames Smart struct lpfc_iocbq *rsp); 150a680a929SJames Smart void (*cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd, 151a680a929SJames Smart struct lpfc_iocbq *rsp); 152dea3101eS }; 153dea3101eS 154dea3101eS #define SLI_IOCB_RET_IOCB 1 /* Return IOCB if cmd ring full */ 155dea3101eS 156dea3101eS #define IOCB_SUCCESS 0 157dea3101eS #define IOCB_BUSY 1 158dea3101eS #define IOCB_ERROR 2 159dea3101eS #define IOCB_TIMEDOUT 3 160db7531d2SJames Smart #define IOCB_ABORTED 4 161db7531d2SJames Smart #define IOCB_ABORTING 5 162db7531d2SJames Smart #define IOCB_NORESOURCE 6 163dea3101eS 164895427bdSJames Smart #define SLI_WQE_RET_WQE 1 /* Return WQE if cmd ring full */ 165895427bdSJames Smart 166895427bdSJames Smart #define WQE_SUCCESS 0 167895427bdSJames Smart #define WQE_BUSY 1 168895427bdSJames Smart #define WQE_ERROR 2 169895427bdSJames Smart #define WQE_TIMEDOUT 3 170895427bdSJames Smart #define WQE_ABORTED 4 171db7531d2SJames Smart #define WQE_ABORTING 5 172db7531d2SJames Smart #define WQE_NORESOURCE 6 173895427bdSJames Smart 1747054a606SJames Smart #define LPFC_MBX_WAKE 1 175858c9f6cSJames Smart #define LPFC_MBX_IMED_UNREG 2 1767054a606SJames Smart 177dea3101eS typedef struct lpfcMboxq { 178dea3101eS /* MBOXQs are used in single linked lists */ 179dea3101eS struct list_head list; /* ptr to next mailbox command */ 180da0436e9SJames Smart union { 181dea3101eS MAILBOX_t mb; /* Mailbox cmd */ 182da0436e9SJames Smart struct lpfc_mqe mqe; 183da0436e9SJames Smart } u; 184da0436e9SJames Smart struct lpfc_vport *vport; /* virtual port pointer */ 1853e1f0718SJames Smart void *ctx_ndlp; /* caller ndlp information */ 1863e1f0718SJames Smart void *ctx_buf; /* caller buffer information */ 187e29d74f8SJames Smart void *context3; 188dea3101eS 189dea3101eS void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); 1907054a606SJames Smart uint8_t mbox_flag; 1917a470277SJames Smart uint16_t in_ext_byte_len; 1927a470277SJames Smart uint16_t out_ext_byte_len; 1937a470277SJames Smart uint8_t mbox_offset_word; 194da0436e9SJames Smart struct lpfc_mcqe mcqe; 195da0436e9SJames Smart struct lpfc_mbx_nembed_sge_virt *sge_array; 196dea3101eS } LPFC_MBOXQ_t; 197dea3101eS 198dea3101eS #define MBX_POLL 1 /* poll mailbox till command done, then 199dea3101eS return */ 200dea3101eS #define MBX_NOWAIT 2 /* issue command then return immediately */ 201dea3101eS 2026669f9bbSJames Smart #define LPFC_MAX_RING_MASK 5 /* max num of rctl/type masks allowed per 203dea3101eS ring */ 2042a76a283SJames Smart #define LPFC_SLI3_MAX_RING 4 /* Max num of SLI3 rings used by driver. 2052a76a283SJames Smart For SLI4, an additional ring for each 2062a76a283SJames Smart FCP WQ will be allocated. */ 207dea3101eS 208dea3101eS struct lpfc_sli_ring; 209dea3101eS 210dea3101eS struct lpfc_sli_ring_mask { 211dea3101eS uint8_t profile; /* profile associated with ring */ 212dea3101eS uint8_t rctl; /* rctl / type pair configured for ring */ 213dea3101eS uint8_t type; /* rctl / type pair configured for ring */ 214dea3101eS uint8_t rsvd; 215dea3101eS /* rcv'd unsol event */ 216dea3101eS void (*lpfc_sli_rcv_unsol_event) (struct lpfc_hba *, 217dea3101eS struct lpfc_sli_ring *, 218dea3101eS struct lpfc_iocbq *); 219dea3101eS }; 220dea3101eS 221dea3101eS 222dea3101eS /* Structure used to hold SLI statistical counters and info */ 223dea3101eS struct lpfc_sli_ring_stat { 224dea3101eS uint64_t iocb_event; /* IOCB event counters */ 225dea3101eS uint64_t iocb_cmd; /* IOCB cmd issued */ 226dea3101eS uint64_t iocb_rsp; /* IOCB rsp received */ 227dea3101eS uint64_t iocb_cmd_delay; /* IOCB cmd ring delay */ 228dea3101eS uint64_t iocb_cmd_full; /* IOCB cmd ring full */ 229dea3101eS uint64_t iocb_cmd_empty; /* IOCB cmd ring is now empty */ 230dea3101eS uint64_t iocb_rsp_full; /* IOCB rsp ring full */ 231dea3101eS }; 232dea3101eS 2337e56aa25SJames Smart struct lpfc_sli3_ring { 2347e56aa25SJames Smart uint32_t local_getidx; /* last available cmd index (from cmdGetInx) */ 2357e56aa25SJames Smart uint32_t next_cmdidx; /* next_cmd index */ 2367e56aa25SJames Smart uint32_t rspidx; /* current index in response ring */ 2377e56aa25SJames Smart uint32_t cmdidx; /* current index in command ring */ 2387e56aa25SJames Smart uint16_t numCiocb; /* number of command iocb's per ring */ 2397e56aa25SJames Smart uint16_t numRiocb; /* number of rsp iocb's per ring */ 2407e56aa25SJames Smart uint16_t sizeCiocb; /* Size of command iocb's in this ring */ 2417e56aa25SJames Smart uint16_t sizeRiocb; /* Size of response iocb's in this ring */ 2427e56aa25SJames Smart uint32_t *cmdringaddr; /* virtual address for cmd rings */ 2437e56aa25SJames Smart uint32_t *rspringaddr; /* virtual address for rsp rings */ 2447e56aa25SJames Smart }; 2457e56aa25SJames Smart 2467e56aa25SJames Smart struct lpfc_sli4_ring { 2472a76a283SJames Smart struct lpfc_queue *wqp; /* Pointer to associated WQ */ 2487e56aa25SJames Smart }; 2497e56aa25SJames Smart 2507e56aa25SJames Smart 251dea3101eS /* Structure used to hold SLI ring information */ 252dea3101eS struct lpfc_sli_ring { 253dea3101eS uint16_t flag; /* ring flags */ 254dea3101eS #define LPFC_DEFERRED_RING_EVENT 0x001 /* Deferred processing a ring event */ 255dea3101eS #define LPFC_CALL_RING_AVAILABLE 0x002 /* indicates cmd was full */ 256dea3101eS #define LPFC_STOP_IOCB_EVENT 0x020 /* Stop processing IOCB cmds event */ 257dea3101eS uint16_t abtsiotag; /* tracks next iotag to use for ABTS */ 258dea3101eS 259dea3101eS uint8_t rsvd; 260dea3101eS uint8_t ringno; /* ring number */ 2617e56aa25SJames Smart 2627e56aa25SJames Smart spinlock_t ring_lock; /* lock for issuing commands */ 263dea3101eS 264dea3101eS uint32_t fast_iotag; /* max fastlookup based iotag */ 265dea3101eS uint32_t iotag_ctr; /* keeps track of the next iotag to use */ 266dea3101eS uint32_t iotag_max; /* max iotag value to use */ 267dea3101eS struct list_head txq; 268dea3101eS uint16_t txq_cnt; /* current length of queue */ 269dea3101eS uint16_t txq_max; /* max length */ 270dea3101eS struct list_head txcmplq; 271dea3101eS uint16_t txcmplq_cnt; /* current length of queue */ 272dea3101eS uint16_t txcmplq_max; /* max length */ 273dea3101eS uint32_t missbufcnt; /* keep track of buffers to post */ 274dea3101eS struct list_head postbufq; 275dea3101eS uint16_t postbufq_cnt; /* current length of queue */ 276dea3101eS uint16_t postbufq_max; /* max length */ 277dea3101eS struct list_head iocb_continueq; 278dea3101eS uint16_t iocb_continueq_cnt; /* current length of queue */ 279dea3101eS uint16_t iocb_continueq_max; /* max length */ 2809c2face6SJames Smart struct list_head iocb_continue_saveq; 281dea3101eS 282dea3101eS struct lpfc_sli_ring_mask prt[LPFC_MAX_RING_MASK]; 283dea3101eS uint32_t num_mask; /* number of mask entries in prt array */ 28457127f15SJames Smart void (*lpfc_sli_rcv_async_status) (struct lpfc_hba *, 28557127f15SJames Smart struct lpfc_sli_ring *, struct lpfc_iocbq *); 286dea3101eS 287dea3101eS struct lpfc_sli_ring_stat stats; /* SLI statistical info */ 288dea3101eS 289dea3101eS /* cmd ring available */ 290dea3101eS void (*lpfc_sli_cmd_available) (struct lpfc_hba *, 291dea3101eS struct lpfc_sli_ring *); 2927e56aa25SJames Smart union { 2937e56aa25SJames Smart struct lpfc_sli3_ring sli3; 2947e56aa25SJames Smart struct lpfc_sli4_ring sli4; 2957e56aa25SJames Smart } sli; 296dea3101eS }; 297dea3101eS 298ed957684SJames Smart /* Structure used for configuring rings to a specific profile or rctl / type */ 299ed957684SJames Smart struct lpfc_hbq_init { 300ed957684SJames Smart uint32_t rn; /* Receive buffer notification */ 30192d7f7b0SJames Smart uint32_t entry_count; /* max # of entries in HBQ */ 302ed957684SJames Smart uint32_t headerLen; /* 0 if not profile 4 or 5 */ 303ed957684SJames Smart uint32_t logEntry; /* Set to 1 if this HBQ used for LogEntry */ 304ed957684SJames Smart uint32_t profile; /* Selection profile 0=all, 7=logentry */ 305ed957684SJames Smart uint32_t ring_mask; /* Binds HBQ to a ring e.g. Ring0=b0001, 306ed957684SJames Smart * ring2=b0100 */ 307ed957684SJames Smart uint32_t hbq_index; /* index of this hbq in ring .HBQs[] */ 308ed957684SJames Smart 309ed957684SJames Smart uint32_t seqlenoff; 310ed957684SJames Smart uint32_t maxlen; 311ed957684SJames Smart uint32_t seqlenbcnt; 312ed957684SJames Smart uint32_t cmdcodeoff; 313ed957684SJames Smart uint32_t cmdmatch[8]; 314ed957684SJames Smart uint32_t mask_count; /* number of mask entries in prt array */ 315ed957684SJames Smart struct hbq_mask hbqMasks[6]; 31692d7f7b0SJames Smart 31792d7f7b0SJames Smart /* Non-config rings fields to keep track of buffer allocations */ 31892d7f7b0SJames Smart uint32_t buffer_count; /* number of buffers allocated */ 31992d7f7b0SJames Smart uint32_t init_count; /* number to allocate when initialized */ 32092d7f7b0SJames Smart uint32_t add_count; /* number to allocate when starved */ 321ed957684SJames Smart } ; 322ed957684SJames Smart 323dea3101eS /* Structure used to hold SLI statistical counters and info */ 324dea3101eS struct lpfc_sli_stat { 325dea3101eS uint64_t mbox_stat_err; /* Mbox cmds completed status error */ 326dea3101eS uint64_t mbox_cmd; /* Mailbox commands issued */ 327dea3101eS uint64_t sli_intr; /* Count of Host Attention interrupts */ 328aa6fbb75SJames Smart uint64_t sli_prev_intr; /* Previous cnt of Host Attention interrupts */ 329aa6fbb75SJames Smart uint64_t sli_ips; /* Host Attention interrupts per sec */ 330dea3101eS uint32_t err_attn_event; /* Error Attn event counters */ 331dea3101eS uint32_t link_event; /* Link event counters */ 332dea3101eS uint32_t mbox_event; /* Mailbox event counters */ 333dea3101eS uint32_t mbox_busy; /* Mailbox cmd busy */ 334dea3101eS }; 335dea3101eS 33664ba8818SJames Smart /* Structure to store link status values when port stats are reset */ 33764ba8818SJames Smart struct lpfc_lnk_stat { 33864ba8818SJames Smart uint32_t link_failure_count; 33964ba8818SJames Smart uint32_t loss_of_sync_count; 34064ba8818SJames Smart uint32_t loss_of_signal_count; 34164ba8818SJames Smart uint32_t prim_seq_protocol_err_count; 34264ba8818SJames Smart uint32_t invalid_tx_word_count; 34364ba8818SJames Smart uint32_t invalid_crc_count; 34464ba8818SJames Smart uint32_t error_frames; 34564ba8818SJames Smart uint32_t link_events; 34664ba8818SJames Smart }; 34764ba8818SJames Smart 348dea3101eS /* Structure used to hold SLI information */ 349dea3101eS struct lpfc_sli { 350dea3101eS uint32_t num_rings; 351dea3101eS uint32_t sli_flag; 352dea3101eS 353dea3101eS /* Additional sli_flags */ 354dea3101eS #define LPFC_SLI_MBOX_ACTIVE 0x100 /* HBA mailbox is currently active */ 355f4b4c68fSJames Smart #define LPFC_SLI_ACTIVE 0x200 /* SLI in firmware is active */ 356dea3101eS #define LPFC_PROCESS_LA 0x400 /* Able to process link attention */ 3572e0fef85SJames Smart #define LPFC_BLOCK_MGMT_IO 0x800 /* Don't allow mgmt mbx or iocb cmds */ 358da0436e9SJames Smart #define LPFC_SLI_ASYNC_MBX_BLK 0x2000 /* Async mailbox is blocked */ 359f358dd0cSJames Smart #define LPFC_SLI_SUPPRESS_RSP 0x4000 /* Suppress RSP feature is supported */ 3600cf07f84SJames Smart #define LPFC_SLI_USE_EQDR 0x8000 /* EQ Delay Register is supported */ 3614645f7b5SJames Smart #define LPFC_QUEUE_FREE_INIT 0x10000 /* Queue freeing is in progress */ 3624645f7b5SJames Smart #define LPFC_QUEUE_FREE_WAIT 0x20000 /* Hold Queue free as it is being 3634645f7b5SJames Smart * used outside worker thread 3644645f7b5SJames Smart */ 365dea3101eS 366895427bdSJames Smart struct lpfc_sli_ring *sli3_ring; 367dea3101eS 368dea3101eS struct lpfc_sli_stat slistat; /* SLI statistical info */ 369dea3101eS struct list_head mboxq; 370dea3101eS uint16_t mboxq_cnt; /* current length of queue */ 371dea3101eS uint16_t mboxq_max; /* max length */ 372dea3101eS LPFC_MBOXQ_t *mbox_active; /* active mboxq information */ 37392d7f7b0SJames Smart struct list_head mboxq_cmpl; 374dea3101eS 375dea3101eS struct timer_list mbox_tmo; /* Hold clk to timeout active mbox 376dea3101eS cmd */ 377dea3101eS 378604a3e30SJames Bottomley #define LPFC_IOCBQ_LOOKUP_INCREMENT 1024 379604a3e30SJames Bottomley struct lpfc_iocbq ** iocbq_lookup; /* array to lookup IOCB by IOTAG */ 380604a3e30SJames Bottomley size_t iocbq_lookup_len; /* current lengs of the array */ 381604a3e30SJames Bottomley uint16_t last_iotag; /* last allocated IOTAG */ 382c4d6204dSArnd Bergmann time64_t stats_start; /* in seconds */ 38364ba8818SJames Smart struct lpfc_lnk_stat lnk_stat_offsets; 384dea3101eS }; 385dea3101eS 386a183a15fSJames Smart /* Timeout for normal outstanding mbox command (Seconds) */ 387a183a15fSJames Smart #define LPFC_MBOX_TMO 30 388a183a15fSJames Smart /* Timeout for non-flash-based outstanding sli_config mbox command (Seconds) */ 389a183a15fSJames Smart #define LPFC_MBOX_SLI4_CONFIG_TMO 60 390a183a15fSJames Smart /* Timeout for flash-based outstanding sli_config mbox command (Seconds) */ 391a183a15fSJames Smart #define LPFC_MBOX_SLI4_CONFIG_EXTENDED_TMO 300 392a183a15fSJames Smart /* Timeout for other flash-based outstanding mbox command (Seconds) */ 393a183a15fSJames Smart #define LPFC_MBOX_TMO_FLASH_CMD 300 394c490850aSJames Smart 395c490850aSJames Smart struct lpfc_io_buf { 396c490850aSJames Smart /* Common fields */ 397c490850aSJames Smart struct list_head list; 398c490850aSJames Smart void *data; 399d79c9e9dSJames Smart 400c490850aSJames Smart dma_addr_t dma_handle; 401c490850aSJames Smart dma_addr_t dma_phys_sgl; 402d79c9e9dSJames Smart 403d79c9e9dSJames Smart struct sli4_sge *dma_sgl; /* initial segment chunk */ 404d79c9e9dSJames Smart 405d79c9e9dSJames Smart /* linked list of extra sli4_hybrid_sge */ 406d79c9e9dSJames Smart struct list_head dma_sgl_xtra_list; 407d79c9e9dSJames Smart 408d79c9e9dSJames Smart /* list head for fcp_cmd_rsp buf */ 409d79c9e9dSJames Smart struct list_head dma_cmd_rsp_list; 410d79c9e9dSJames Smart 411c490850aSJames Smart struct lpfc_iocbq cur_iocbq; 412c490850aSJames Smart struct lpfc_sli4_hdw_queue *hdwq; 413c490850aSJames Smart uint16_t hdwq_no; 414c490850aSJames Smart uint16_t cpu; 415c490850aSJames Smart 416c490850aSJames Smart struct lpfc_nodelist *ndlp; 417c490850aSJames Smart uint32_t timeout; 418324e1c40SJames Smart uint16_t flags; 419c490850aSJames Smart #define LPFC_SBUF_XBUSY 0x1 /* SLI4 hba reported XB on WCQE cmpl */ 420c490850aSJames Smart #define LPFC_SBUF_BUMP_QDEPTH 0x2 /* bumped queue depth counter */ 421c490850aSJames Smart /* External DIF device IO conversions */ 422c490850aSJames Smart #define LPFC_SBUF_NORMAL_DIF 0x4 /* normal mode to insert/strip */ 423c490850aSJames Smart #define LPFC_SBUF_PASS_DIF 0x8 /* insert/strip mode to passthru */ 424c490850aSJames Smart #define LPFC_SBUF_NOT_POSTED 0x10 /* SGL failed post to FW. */ 425c490850aSJames Smart uint16_t status; /* From IOCB Word 7- ulpStatus */ 426c490850aSJames Smart uint32_t result; /* From IOCB Word 4. */ 427c490850aSJames Smart 428c490850aSJames Smart uint32_t seg_cnt; /* Number of scatter-gather segments returned by 429c490850aSJames Smart * dma_map_sg. The driver needs this for calls 430c490850aSJames Smart * to dma_unmap_sg. 431c490850aSJames Smart */ 432c490850aSJames Smart unsigned long start_time; 433c2017260SJames Smart spinlock_t buf_lock; /* lock used in case of simultaneous abort */ 434c490850aSJames Smart bool expedite; /* this is an expedite io_buf */ 435c490850aSJames Smart 436c490850aSJames Smart union { 437c490850aSJames Smart /* SCSI specific fields */ 438c490850aSJames Smart struct { 439c490850aSJames Smart struct scsi_cmnd *pCmd; 440c490850aSJames Smart struct lpfc_rport_data *rdata; 441c490850aSJames Smart uint32_t prot_seg_cnt; /* seg_cnt's counterpart for 442c490850aSJames Smart * protection data 443c490850aSJames Smart */ 444c490850aSJames Smart 445c490850aSJames Smart /* 446c490850aSJames Smart * data and dma_handle are the kernel virtual and bus 447c490850aSJames Smart * address of the dma-able buffer containing the 448c490850aSJames Smart * fcp_cmd, fcp_rsp and a scatter gather bde list that 449c490850aSJames Smart * supports the sg_tablesize value. 450c490850aSJames Smart */ 451c490850aSJames Smart struct fcp_cmnd *fcp_cmnd; 452c490850aSJames Smart struct fcp_rsp *fcp_rsp; 453c490850aSJames Smart 454c490850aSJames Smart wait_queue_head_t *waitq; 455c490850aSJames Smart 456c490850aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 457c490850aSJames Smart /* Used to restore any changes to protection data for 458c490850aSJames Smart * error injection 459c490850aSJames Smart */ 460c490850aSJames Smart void *prot_data_segment; 461c490850aSJames Smart uint32_t prot_data; 462c490850aSJames Smart uint32_t prot_data_type; 463c490850aSJames Smart #define LPFC_INJERR_REFTAG 1 464c490850aSJames Smart #define LPFC_INJERR_APPTAG 2 465c490850aSJames Smart #define LPFC_INJERR_GUARD 3 466c490850aSJames Smart #endif 467c490850aSJames Smart }; 468c490850aSJames Smart 469c490850aSJames Smart /* NVME specific fields */ 470c490850aSJames Smart struct { 471c490850aSJames Smart struct nvmefc_fcp_req *nvmeCmd; 472c490850aSJames Smart uint16_t qidx; 473def11a58SJames Smart }; 474def11a58SJames Smart }; 475c490850aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 476c490850aSJames Smart uint64_t ts_cmd_start; 477c490850aSJames Smart uint64_t ts_last_cmd; 478c490850aSJames Smart uint64_t ts_cmd_wqput; 479c490850aSJames Smart uint64_t ts_isr_cmpl; 4802fcbc569SJames Smart uint64_t ts_data_io; 481c490850aSJames Smart #endif 48202243836SJames Smart uint64_t rx_cmd_start; 483c490850aSJames Smart }; 484