1dea3101eS /******************************************************************* 2dea3101eS * This file is part of the Emulex Linux Device Driver for * 3c44ce173SJames.Smart@Emulex.Com * Fibre Channel Host Bus Adapters. * 40fa215e5SJustin Tee * Copyright (C) 2017-2024 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 38ef47575fSJames Smart /* Enumeration to describe the thread lock context. */ 39ef47575fSJames Smart enum lpfc_mbox_ctx { 40ef47575fSJames Smart MBOX_THD_UNLOCKED, 41ef47575fSJames Smart MBOX_THD_LOCKED 42ef47575fSJames Smart }; 43ef47575fSJames 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 */ 18518f7fe44SJustin Tee struct lpfc_nodelist *ctx_ndlp; /* caller ndlp pointer */ 186115d137aSJustin Tee struct lpfc_dmabuf *ctx_buf; /* caller buffer information */ 187115d137aSJustin Tee void *ext_buf; /* extended buffer for extended mbox 188115d137aSJustin Tee * cmds. Not a generic pointer. 189115d137aSJustin Tee * Use for storing virtual address. 190115d137aSJustin Tee */ 19185d77f91SJustin Tee 19285d77f91SJustin Tee /* Pointers that are seldom used during mbox execution, but require 19385d77f91SJustin Tee * a saved context. 194349b1e2cSJustin Tee */ 19585d77f91SJustin Tee union { 19685d77f91SJustin Tee unsigned long ox_rx_id; /* Used in els_rsp_rls_acc */ 19785d77f91SJustin Tee struct lpfc_rdp_context *rdp; /* Used in get_rdp_info */ 19885d77f91SJustin Tee struct lpfc_lcb_context *lcb; /* Used in set_beacon */ 19985d77f91SJustin Tee struct completion *mbox_wait; /* Used in issue_mbox_wait */ 20085d77f91SJustin Tee struct bsg_job_data *dd_data; /* Used in bsg_issue_mbox_cmpl 20185d77f91SJustin Tee * and 20285d77f91SJustin Tee * bsg_issue_mbox_ext_handle_job 20385d77f91SJustin Tee */ 20485d77f91SJustin Tee struct lpfc_iocbq *save_iocb; /* Used in defer_plogi_acc and 20585d77f91SJustin Tee * lpfc_mbx_cmpl_resume_rpi 20685d77f91SJustin Tee */ 20785d77f91SJustin Tee } ctx_u; 208dea3101eS 209dea3101eS void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); 2107054a606SJames Smart uint8_t mbox_flag; 2117a470277SJames Smart uint16_t in_ext_byte_len; 2127a470277SJames Smart uint16_t out_ext_byte_len; 2137a470277SJames Smart uint8_t mbox_offset_word; 214da0436e9SJames Smart struct lpfc_mcqe mcqe; 215da0436e9SJames Smart struct lpfc_mbx_nembed_sge_virt *sge_array; 216dea3101eS } LPFC_MBOXQ_t; 217dea3101eS 218dea3101eS #define MBX_POLL 1 /* poll mailbox till command done, then 219dea3101eS return */ 220dea3101eS #define MBX_NOWAIT 2 /* issue command then return immediately */ 221dea3101eS 2226669f9bbSJames Smart #define LPFC_MAX_RING_MASK 5 /* max num of rctl/type masks allowed per 223dea3101eS ring */ 2242a76a283SJames Smart #define LPFC_SLI3_MAX_RING 4 /* Max num of SLI3 rings used by driver. 2252a76a283SJames Smart For SLI4, an additional ring for each 2262a76a283SJames Smart FCP WQ will be allocated. */ 227dea3101eS 228dea3101eS struct lpfc_sli_ring; 229dea3101eS 230dea3101eS struct lpfc_sli_ring_mask { 231dea3101eS uint8_t profile; /* profile associated with ring */ 232dea3101eS uint8_t rctl; /* rctl / type pair configured for ring */ 233dea3101eS uint8_t type; /* rctl / type pair configured for ring */ 234dea3101eS uint8_t rsvd; 235dea3101eS /* rcv'd unsol event */ 236dea3101eS void (*lpfc_sli_rcv_unsol_event) (struct lpfc_hba *, 237dea3101eS struct lpfc_sli_ring *, 238dea3101eS struct lpfc_iocbq *); 239dea3101eS }; 240dea3101eS 241dea3101eS 242dea3101eS /* Structure used to hold SLI statistical counters and info */ 243dea3101eS struct lpfc_sli_ring_stat { 244dea3101eS uint64_t iocb_event; /* IOCB event counters */ 245dea3101eS uint64_t iocb_cmd; /* IOCB cmd issued */ 246dea3101eS uint64_t iocb_rsp; /* IOCB rsp received */ 247dea3101eS uint64_t iocb_cmd_delay; /* IOCB cmd ring delay */ 248dea3101eS uint64_t iocb_cmd_full; /* IOCB cmd ring full */ 249dea3101eS uint64_t iocb_cmd_empty; /* IOCB cmd ring is now empty */ 250dea3101eS uint64_t iocb_rsp_full; /* IOCB rsp ring full */ 251dea3101eS }; 252dea3101eS 2537e56aa25SJames Smart struct lpfc_sli3_ring { 2547e56aa25SJames Smart uint32_t local_getidx; /* last available cmd index (from cmdGetInx) */ 2557e56aa25SJames Smart uint32_t next_cmdidx; /* next_cmd index */ 2567e56aa25SJames Smart uint32_t rspidx; /* current index in response ring */ 2577e56aa25SJames Smart uint32_t cmdidx; /* current index in command ring */ 2587e56aa25SJames Smart uint16_t numCiocb; /* number of command iocb's per ring */ 2597e56aa25SJames Smart uint16_t numRiocb; /* number of rsp iocb's per ring */ 2607e56aa25SJames Smart uint16_t sizeCiocb; /* Size of command iocb's in this ring */ 2617e56aa25SJames Smart uint16_t sizeRiocb; /* Size of response iocb's in this ring */ 2627e56aa25SJames Smart uint32_t *cmdringaddr; /* virtual address for cmd rings */ 2637e56aa25SJames Smart uint32_t *rspringaddr; /* virtual address for rsp rings */ 2647e56aa25SJames Smart }; 2657e56aa25SJames Smart 2667e56aa25SJames Smart struct lpfc_sli4_ring { 2672a76a283SJames Smart struct lpfc_queue *wqp; /* Pointer to associated WQ */ 2687e56aa25SJames Smart }; 2697e56aa25SJames Smart 2707e56aa25SJames Smart 271dea3101eS /* Structure used to hold SLI ring information */ 272dea3101eS struct lpfc_sli_ring { 273dea3101eS uint16_t flag; /* ring flags */ 274dea3101eS #define LPFC_DEFERRED_RING_EVENT 0x001 /* Deferred processing a ring event */ 275dea3101eS #define LPFC_CALL_RING_AVAILABLE 0x002 /* indicates cmd was full */ 276dea3101eS #define LPFC_STOP_IOCB_EVENT 0x020 /* Stop processing IOCB cmds event */ 277dea3101eS uint16_t abtsiotag; /* tracks next iotag to use for ABTS */ 278dea3101eS 279dea3101eS uint8_t rsvd; 280dea3101eS uint8_t ringno; /* ring number */ 2817e56aa25SJames Smart 2827e56aa25SJames Smart spinlock_t ring_lock; /* lock for issuing commands */ 283dea3101eS 284dea3101eS uint32_t fast_iotag; /* max fastlookup based iotag */ 285dea3101eS uint32_t iotag_ctr; /* keeps track of the next iotag to use */ 286dea3101eS uint32_t iotag_max; /* max iotag value to use */ 287dea3101eS struct list_head txq; 288dea3101eS uint16_t txq_cnt; /* current length of queue */ 289dea3101eS uint16_t txq_max; /* max length */ 290dea3101eS struct list_head txcmplq; 291dea3101eS uint16_t txcmplq_cnt; /* current length of queue */ 292dea3101eS uint16_t txcmplq_max; /* max length */ 293dea3101eS uint32_t missbufcnt; /* keep track of buffers to post */ 294dea3101eS struct list_head postbufq; 295dea3101eS uint16_t postbufq_cnt; /* current length of queue */ 296dea3101eS uint16_t postbufq_max; /* max length */ 297dea3101eS struct list_head iocb_continueq; 298dea3101eS uint16_t iocb_continueq_cnt; /* current length of queue */ 299dea3101eS uint16_t iocb_continueq_max; /* max length */ 3009c2face6SJames Smart struct list_head iocb_continue_saveq; 301dea3101eS 302dea3101eS struct lpfc_sli_ring_mask prt[LPFC_MAX_RING_MASK]; 303dea3101eS uint32_t num_mask; /* number of mask entries in prt array */ 30457127f15SJames Smart void (*lpfc_sli_rcv_async_status) (struct lpfc_hba *, 30557127f15SJames Smart struct lpfc_sli_ring *, struct lpfc_iocbq *); 306dea3101eS 307dea3101eS struct lpfc_sli_ring_stat stats; /* SLI statistical info */ 308dea3101eS 309dea3101eS /* cmd ring available */ 310dea3101eS void (*lpfc_sli_cmd_available) (struct lpfc_hba *, 311dea3101eS struct lpfc_sli_ring *); 3127e56aa25SJames Smart union { 3137e56aa25SJames Smart struct lpfc_sli3_ring sli3; 3147e56aa25SJames Smart struct lpfc_sli4_ring sli4; 3157e56aa25SJames Smart } sli; 316dea3101eS }; 317dea3101eS 318ed957684SJames Smart /* Structure used for configuring rings to a specific profile or rctl / type */ 319ed957684SJames Smart struct lpfc_hbq_init { 320ed957684SJames Smart uint32_t rn; /* Receive buffer notification */ 32192d7f7b0SJames Smart uint32_t entry_count; /* max # of entries in HBQ */ 322ed957684SJames Smart uint32_t headerLen; /* 0 if not profile 4 or 5 */ 323ed957684SJames Smart uint32_t logEntry; /* Set to 1 if this HBQ used for LogEntry */ 324ed957684SJames Smart uint32_t profile; /* Selection profile 0=all, 7=logentry */ 325ed957684SJames Smart uint32_t ring_mask; /* Binds HBQ to a ring e.g. Ring0=b0001, 326ed957684SJames Smart * ring2=b0100 */ 327ed957684SJames Smart uint32_t hbq_index; /* index of this hbq in ring .HBQs[] */ 328ed957684SJames Smart 329ed957684SJames Smart uint32_t seqlenoff; 330ed957684SJames Smart uint32_t maxlen; 331ed957684SJames Smart uint32_t seqlenbcnt; 332ed957684SJames Smart uint32_t cmdcodeoff; 333ed957684SJames Smart uint32_t cmdmatch[8]; 334ed957684SJames Smart uint32_t mask_count; /* number of mask entries in prt array */ 335ed957684SJames Smart struct hbq_mask hbqMasks[6]; 33692d7f7b0SJames Smart 33792d7f7b0SJames Smart /* Non-config rings fields to keep track of buffer allocations */ 33892d7f7b0SJames Smart uint32_t buffer_count; /* number of buffers allocated */ 33992d7f7b0SJames Smart uint32_t init_count; /* number to allocate when initialized */ 34092d7f7b0SJames Smart uint32_t add_count; /* number to allocate when starved */ 341ed957684SJames Smart } ; 342ed957684SJames Smart 343dea3101eS /* Structure used to hold SLI statistical counters and info */ 344dea3101eS struct lpfc_sli_stat { 345dea3101eS uint64_t mbox_stat_err; /* Mbox cmds completed status error */ 346dea3101eS uint64_t mbox_cmd; /* Mailbox commands issued */ 347dea3101eS uint64_t sli_intr; /* Count of Host Attention interrupts */ 348aa6fbb75SJames Smart uint64_t sli_prev_intr; /* Previous cnt of Host Attention interrupts */ 349aa6fbb75SJames Smart uint64_t sli_ips; /* Host Attention interrupts per sec */ 350dea3101eS uint32_t err_attn_event; /* Error Attn event counters */ 351dea3101eS uint32_t link_event; /* Link event counters */ 352dea3101eS uint32_t mbox_event; /* Mailbox event counters */ 353dea3101eS uint32_t mbox_busy; /* Mailbox cmd busy */ 354dea3101eS }; 355dea3101eS 35664ba8818SJames Smart /* Structure to store link status values when port stats are reset */ 35764ba8818SJames Smart struct lpfc_lnk_stat { 35864ba8818SJames Smart uint32_t link_failure_count; 35964ba8818SJames Smart uint32_t loss_of_sync_count; 36064ba8818SJames Smart uint32_t loss_of_signal_count; 36164ba8818SJames Smart uint32_t prim_seq_protocol_err_count; 36264ba8818SJames Smart uint32_t invalid_tx_word_count; 36364ba8818SJames Smart uint32_t invalid_crc_count; 36464ba8818SJames Smart uint32_t error_frames; 36564ba8818SJames Smart uint32_t link_events; 36664ba8818SJames Smart }; 36764ba8818SJames Smart 368dea3101eS /* Structure used to hold SLI information */ 369dea3101eS struct lpfc_sli { 370dea3101eS uint32_t num_rings; 371dea3101eS uint32_t sli_flag; 372dea3101eS 373dea3101eS /* Additional sli_flags */ 374dea3101eS #define LPFC_SLI_MBOX_ACTIVE 0x100 /* HBA mailbox is currently active */ 375f4b4c68fSJames Smart #define LPFC_SLI_ACTIVE 0x200 /* SLI in firmware is active */ 376dea3101eS #define LPFC_PROCESS_LA 0x400 /* Able to process link attention */ 3772e0fef85SJames Smart #define LPFC_BLOCK_MGMT_IO 0x800 /* Don't allow mgmt mbx or iocb cmds */ 378da0436e9SJames Smart #define LPFC_SLI_ASYNC_MBX_BLK 0x2000 /* Async mailbox is blocked */ 379f358dd0cSJames Smart #define LPFC_SLI_SUPPRESS_RSP 0x4000 /* Suppress RSP feature is supported */ 3800cf07f84SJames Smart #define LPFC_SLI_USE_EQDR 0x8000 /* EQ Delay Register is supported */ 3814645f7b5SJames Smart #define LPFC_QUEUE_FREE_INIT 0x10000 /* Queue freeing is in progress */ 3824645f7b5SJames Smart #define LPFC_QUEUE_FREE_WAIT 0x20000 /* Hold Queue free as it is being 3834645f7b5SJames Smart * used outside worker thread 3844645f7b5SJames Smart */ 385dea3101eS 386895427bdSJames Smart struct lpfc_sli_ring *sli3_ring; 387dea3101eS 388dea3101eS struct lpfc_sli_stat slistat; /* SLI statistical info */ 389dea3101eS struct list_head mboxq; 390dea3101eS uint16_t mboxq_cnt; /* current length of queue */ 391dea3101eS uint16_t mboxq_max; /* max length */ 392dea3101eS LPFC_MBOXQ_t *mbox_active; /* active mboxq information */ 39392d7f7b0SJames Smart struct list_head mboxq_cmpl; 394dea3101eS 395dea3101eS struct timer_list mbox_tmo; /* Hold clk to timeout active mbox 396dea3101eS cmd */ 397dea3101eS 398604a3e30SJames Bottomley #define LPFC_IOCBQ_LOOKUP_INCREMENT 1024 399604a3e30SJames Bottomley struct lpfc_iocbq ** iocbq_lookup; /* array to lookup IOCB by IOTAG */ 400604a3e30SJames Bottomley size_t iocbq_lookup_len; /* current lengs of the array */ 401604a3e30SJames Bottomley uint16_t last_iotag; /* last allocated IOTAG */ 402c4d6204dSArnd Bergmann time64_t stats_start; /* in seconds */ 40364ba8818SJames Smart struct lpfc_lnk_stat lnk_stat_offsets; 404dea3101eS }; 405dea3101eS 406a183a15fSJames Smart /* Timeout for normal outstanding mbox command (Seconds) */ 407a183a15fSJames Smart #define LPFC_MBOX_TMO 30 408a183a15fSJames Smart /* Timeout for non-flash-based outstanding sli_config mbox command (Seconds) */ 409a183a15fSJames Smart #define LPFC_MBOX_SLI4_CONFIG_TMO 60 410a183a15fSJames Smart /* Timeout for flash-based outstanding sli_config mbox command (Seconds) */ 411a183a15fSJames Smart #define LPFC_MBOX_SLI4_CONFIG_EXTENDED_TMO 300 412a183a15fSJames Smart /* Timeout for other flash-based outstanding mbox command (Seconds) */ 413a183a15fSJames Smart #define LPFC_MBOX_TMO_FLASH_CMD 300 414c490850aSJames Smart 415c490850aSJames Smart struct lpfc_io_buf { 416c490850aSJames Smart /* Common fields */ 417c490850aSJames Smart struct list_head list; 418c490850aSJames Smart void *data; 419d79c9e9dSJames Smart 420c490850aSJames Smart dma_addr_t dma_handle; 421c490850aSJames Smart dma_addr_t dma_phys_sgl; 422d79c9e9dSJames Smart 423d79c9e9dSJames Smart struct sli4_sge *dma_sgl; /* initial segment chunk */ 424d79c9e9dSJames Smart 425d79c9e9dSJames Smart /* linked list of extra sli4_hybrid_sge */ 426d79c9e9dSJames Smart struct list_head dma_sgl_xtra_list; 427d79c9e9dSJames Smart 428d79c9e9dSJames Smart /* list head for fcp_cmd_rsp buf */ 429d79c9e9dSJames Smart struct list_head dma_cmd_rsp_list; 430d79c9e9dSJames Smart 431c490850aSJames Smart struct lpfc_iocbq cur_iocbq; 432c490850aSJames Smart struct lpfc_sli4_hdw_queue *hdwq; 433c490850aSJames Smart uint16_t hdwq_no; 434c490850aSJames Smart uint16_t cpu; 435c490850aSJames Smart 436c490850aSJames Smart struct lpfc_nodelist *ndlp; 437c490850aSJames Smart uint32_t timeout; 438324e1c40SJames Smart uint16_t flags; 439c490850aSJames Smart #define LPFC_SBUF_XBUSY 0x1 /* SLI4 hba reported XB on WCQE cmpl */ 440c490850aSJames Smart #define LPFC_SBUF_BUMP_QDEPTH 0x2 /* bumped queue depth counter */ 441c490850aSJames Smart /* External DIF device IO conversions */ 442c490850aSJames Smart #define LPFC_SBUF_NORMAL_DIF 0x4 /* normal mode to insert/strip */ 443c490850aSJames Smart #define LPFC_SBUF_PASS_DIF 0x8 /* insert/strip mode to passthru */ 444c490850aSJames Smart #define LPFC_SBUF_NOT_POSTED 0x10 /* SGL failed post to FW. */ 445c490850aSJames Smart uint16_t status; /* From IOCB Word 7- ulpStatus */ 446c490850aSJames Smart uint32_t result; /* From IOCB Word 4. */ 447c490850aSJames Smart 448c490850aSJames Smart uint32_t seg_cnt; /* Number of scatter-gather segments returned by 449c490850aSJames Smart * dma_map_sg. The driver needs this for calls 450c490850aSJames Smart * to dma_unmap_sg. 451c490850aSJames Smart */ 452c490850aSJames Smart unsigned long start_time; 453c2017260SJames Smart spinlock_t buf_lock; /* lock used in case of simultaneous abort */ 454c490850aSJames Smart bool expedite; /* this is an expedite io_buf */ 455c490850aSJames Smart 456c490850aSJames Smart union { 457c490850aSJames Smart /* SCSI specific fields */ 458c490850aSJames Smart struct { 459c490850aSJames Smart struct scsi_cmnd *pCmd; 460c490850aSJames Smart struct lpfc_rport_data *rdata; 461c490850aSJames Smart uint32_t prot_seg_cnt; /* seg_cnt's counterpart for 462c490850aSJames Smart * protection data 463c490850aSJames Smart */ 464c490850aSJames Smart 465c490850aSJames Smart /* 466c490850aSJames Smart * data and dma_handle are the kernel virtual and bus 467c490850aSJames Smart * address of the dma-able buffer containing the 468c490850aSJames Smart * fcp_cmd, fcp_rsp and a scatter gather bde list that 469c490850aSJames Smart * supports the sg_tablesize value. 470c490850aSJames Smart */ 471c490850aSJames Smart struct fcp_cmnd *fcp_cmnd; 472c490850aSJames Smart struct fcp_rsp *fcp_rsp; 473c490850aSJames Smart 474c490850aSJames Smart wait_queue_head_t *waitq; 475c490850aSJames Smart 476c490850aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 477c490850aSJames Smart /* Used to restore any changes to protection data for 478c490850aSJames Smart * error injection 479c490850aSJames Smart */ 480c490850aSJames Smart void *prot_data_segment; 481c490850aSJames Smart uint32_t prot_data; 482c490850aSJames Smart uint32_t prot_data_type; 483c490850aSJames Smart #define LPFC_INJERR_REFTAG 1 484c490850aSJames Smart #define LPFC_INJERR_APPTAG 2 485c490850aSJames Smart #define LPFC_INJERR_GUARD 3 486c490850aSJames Smart #endif 487c490850aSJames Smart }; 488c490850aSJames Smart 489c490850aSJames Smart /* NVME specific fields */ 490c490850aSJames Smart struct { 491c490850aSJames Smart struct nvmefc_fcp_req *nvmeCmd; 492c490850aSJames Smart uint16_t qidx; 493def11a58SJames Smart }; 494def11a58SJames Smart }; 495c490850aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 496c490850aSJames Smart uint64_t ts_cmd_start; 497c490850aSJames Smart uint64_t ts_last_cmd; 498c490850aSJames Smart uint64_t ts_cmd_wqput; 499c490850aSJames Smart uint64_t ts_isr_cmpl; 5002fcbc569SJames Smart uint64_t ts_data_io; 501c490850aSJames Smart #endif 50202243836SJames Smart uint64_t rx_cmd_start; 503c490850aSJames Smart }; 504