1dea3101eS /*******************************************************************
2dea3101eS * This file is part of the Emulex Linux Device Driver for *
3c44ce173SJames.Smart@Emulex.Com * Fibre Channel Host Bus Adapters. *
4191b5a38SJustin Tee * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
54ae2ebdeSJames Smart * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
650611577SJames 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 *
9c44ce173SJames.Smart@Emulex.Com * Portions Copyright (C) 2004-2005 Christoph Hellwig *
10dea3101eS * *
11dea3101eS * This program is free software; you can redistribute it and/or *
12c44ce173SJames.Smart@Emulex.Com * modify it under the terms of version 2 of the GNU General *
13c44ce173SJames.Smart@Emulex.Com * Public License as published by the Free Software Foundation. *
14c44ce173SJames.Smart@Emulex.Com * This program is distributed in the hope that it will be useful. *
15c44ce173SJames.Smart@Emulex.Com * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16c44ce173SJames.Smart@Emulex.Com * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17c44ce173SJames.Smart@Emulex.Com * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18c44ce173SJames.Smart@Emulex.Com * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19c44ce173SJames.Smart@Emulex.Com * TO BE LEGALLY INVALID. See the GNU General Public License for *
20c44ce173SJames.Smart@Emulex.Com * more details, a copy of which can be found in the file COPYING *
21c44ce173SJames.Smart@Emulex.Com * included with this package. *
22dea3101eS *******************************************************************/
23dea3101eS
242e0fef85SJames Smart #include <scsi/scsi_host.h>
252e9bc346SChristoph Hellwig #include <linux/hashtable.h>
26895427bdSJames Smart #include <linux/ktime.h>
27f485c18dSDick Kennedy #include <linux/workqueue.h>
2888a2cfbbSJames Smart
2988a2cfbbSJames Smart #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
3088a2cfbbSJames Smart #define CONFIG_SCSI_LPFC_DEBUG_FS
3188a2cfbbSJames Smart #endif
3288a2cfbbSJames Smart
33dea3101eS struct lpfc_sli2_slim;
34dea3101eS
355402a315SJames Smart #define ELX_MODEL_NAME_SIZE 80
365b94b3a8SJustin Tee #define ELX_FW_NAME_SIZE 84
375402a315SJames Smart
383772a991SJames Smart #define LPFC_PCI_DEV_LP 0x1
393772a991SJames Smart #define LPFC_PCI_DEV_OC 0x2
403772a991SJames Smart
413772a991SJames Smart #define LPFC_SLI_REV2 2
423772a991SJames Smart #define LPFC_SLI_REV3 3
433772a991SJames Smart #define LPFC_SLI_REV4 4
443772a991SJames Smart
4597eab634SJames Smart #define LPFC_MAX_TARGET 4096 /* max number of targets supported */
46e17da18eSJames Smart #define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els
47e17da18eSJames Smart requests */
48e17da18eSJames Smart #define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
49e17da18eSJames Smart the NameServer before giving up. */
50445cf4f4SJames.Smart@Emulex.Com #define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
5183108bd3SJames Smart #define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
5296f7077fSJames Smart
53d79c9e9dSJames Smart #define LPFC_DEFAULT_XPSGL_SIZE 256
54d79c9e9dSJames Smart #define LPFC_MAX_SG_TABLESIZE 0xffff
5596f7077fSJames Smart #define LPFC_MIN_SG_SLI4_BUF_SZ 0x800 /* based on LPFC_DEFAULT_SG_SEG_CNT */
565b9e70b2SJames Smart #define LPFC_MAX_BG_SLI4_SEG_CNT_DIF 128 /* sg element count for BlockGuard */
5796f7077fSJames Smart #define LPFC_MAX_SG_SEG_CNT_DIF 512 /* sg element count per scsi cmnd */
5881301a9bSJames Smart #define LPFC_MAX_SG_SEG_CNT 4096 /* sg element count per scsi cmnd */
5981e6a637SJames Smart #define LPFC_MIN_SG_SEG_CNT 32 /* sg element count per scsi cmnd */
6009294d46SJames Smart #define LPFC_MAX_SGL_SEG_CNT 512 /* SGL element count per scsi cmnd */
6109294d46SJames Smart #define LPFC_MAX_BPL_SEG_CNT 4096 /* BPL element count per scsi cmnd */
62d73154baSJames Smart #define LPFC_MAX_NVME_SEG_CNT 256 /* max SGL element cnt per NVME cmnd */
6309294d46SJames Smart
640558056cSJames Smart #define LPFC_MAX_SGE_SIZE 0x80000000 /* Maximum data allowed in a SGE */
65dea3101eS #define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
66445cf4f4SJames.Smart@Emulex.Com #define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
67495a714cSJames Smart #define LPFC_VNAME_LEN 100 /* vport symbolic name length */
68977b5a0aSJames Smart #define LPFC_TGTQ_RAMPUP_PCENT 5 /* Target queue rampup in percentage */
697dc517dfSJames Smart #define LPFC_MIN_TGT_QDEPTH 10
70977b5a0aSJames Smart #define LPFC_MAX_TGT_QDEPTH 0xFFFF
71dea3101eS
7292d7f7b0SJames Smart /*
7392d7f7b0SJames Smart * Following time intervals are used of adjusting SCSI device
7492d7f7b0SJames Smart * queue depths when there are driver resource error or Firmware
7592d7f7b0SJames Smart * resource error.
7692d7f7b0SJames Smart */
77256ec0d0SJames Smart /* 1 Second */
78256ec0d0SJames Smart #define QUEUE_RAMP_DOWN_INTERVAL (msecs_to_jiffies(1000 * 1))
7992d7f7b0SJames Smart
8092d7f7b0SJames Smart /* Number of exchanges reserved for discovery to complete */
8192d7f7b0SJames Smart #define LPFC_DISC_IOCB_BUFF_COUNT 20
8292d7f7b0SJames Smart
83858c9f6cSJames Smart #define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */
84858c9f6cSJames Smart #define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */
85858c9f6cSJames Smart
869399627fSJames Smart /* Error Attention event polling interval */
879399627fSJames Smart #define LPFC_ERATT_POLL_INTERVAL 5 /* EATT poll interval in seconds */
889399627fSJames Smart
89dea3101eS /* Define macros for 64 bit support */
90dea3101eS #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
91dea3101eS #define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32)))
92dea3101eS #define getPaddr(high, low) ((dma_addr_t)( \
93dea3101eS (( (u64)(high)<<16 ) << 16)|( (u64)(low))))
94dea3101eS /* Provide maximum configuration definitions. */
95dea3101eS #define LPFC_DRVR_TIMEOUT 16 /* driver iocb timeout value in sec */
96dea3101eS #define FC_MAX_ADPTMSG 64
97dea3101eS
98dea3101eS #define MAX_HBAEVT 32
9996418b5eSJames Smart #define MAX_HBAS_NO_RESET 16
100dea3101eS
1019399627fSJames Smart /* Number of MSI-X vectors the driver uses */
1029399627fSJames Smart #define LPFC_MSIX_VECTORS 2
1039399627fSJames Smart
1045e9d9b82SJames Smart /* lpfc wait event data ready flag */
1052ade92aeSJames Smart #define LPFC_DATA_READY 0 /* bit 0 */
1065e9d9b82SJames Smart
107809c7536SJames Smart /* queue dump line buffer size */
108809c7536SJames Smart #define LPFC_LBUF_SZ 128
109809c7536SJames Smart
110618a5230SJames Smart /* mailbox system shutdown options */
111618a5230SJames Smart #define LPFC_MBX_NO_WAIT 0
112618a5230SJames Smart #define LPFC_MBX_WAIT 1
113618a5230SJames Smart
11472df8a45SJames Smart #define LPFC_CFG_PARAM_MAGIC_NUM 0xFEAA0005
11572df8a45SJames Smart #define LPFC_PORT_CFG_NAME "/cfg/port.cfg"
11672df8a45SJames Smart
11772df8a45SJames Smart #define lpfc_rangecheck(val, min, max) \
11872df8a45SJames Smart ((uint)(val) >= (uint)(min) && (val) <= (max))
11972df8a45SJames Smart
120875fbdfeSJames.Smart@Emulex.Com enum lpfc_polling_flags {
121875fbdfeSJames.Smart@Emulex.Com ENABLE_FCP_RING_POLLING = 0x1,
122875fbdfeSJames.Smart@Emulex.Com DISABLE_FCP_RING_INT = 0x2
123875fbdfeSJames.Smart@Emulex.Com };
124875fbdfeSJames.Smart@Emulex.Com
125895427bdSJames Smart struct perf_prof {
126895427bdSJames Smart uint16_t cmd_cpu[40];
127895427bdSJames Smart uint16_t rsp_cpu[40];
128895427bdSJames Smart uint16_t qh_cpu[40];
129895427bdSJames Smart uint16_t wqidx[40];
130895427bdSJames Smart };
131895427bdSJames Smart
13201649561SJames Smart /*
13301649561SJames Smart * Provide for FC4 TYPE x28 - NVME. The
13401649561SJames Smart * bit mask for FCP and NVME is 0x8 identically
13501649561SJames Smart * because they are 32 bit positions distance.
13601649561SJames Smart */
137a0f2d3efSJames Smart #define LPFC_FC4_TYPE_BITMASK 0x00000100
138a0f2d3efSJames Smart
139dea3101eS /* Provide DMA memory definitions the driver uses per port instance. */
140dea3101eS struct lpfc_dmabuf {
141dea3101eS struct list_head list;
142dea3101eS void *virt; /* virtual address ptr */
143dea3101eS dma_addr_t phys; /* mapped address */
14476bb24efSJames Smart uint32_t buffer_tag; /* used for tagged queue ring */
145dea3101eS };
146dea3101eS
1476c621a22SJames Smart struct lpfc_nvmet_ctxbuf {
1486c621a22SJames Smart struct list_head list;
1497cacae2aSJames Smart struct lpfc_async_xchg_ctx *context;
1506c621a22SJames Smart struct lpfc_iocbq *iocbq;
1516c621a22SJames Smart struct lpfc_sglq *sglq;
152472e146dSJames Smart struct work_struct defer_work;
1536c621a22SJames Smart };
1546c621a22SJames Smart
155dea3101eS struct lpfc_dma_pool {
156dea3101eS struct lpfc_dmabuf *elements;
157dea3101eS uint32_t max_count;
158dea3101eS uint32_t current_count;
159dea3101eS };
160dea3101eS
161ed957684SJames Smart struct hbq_dmabuf {
162da0436e9SJames Smart struct lpfc_dmabuf hbuf;
163ed957684SJames Smart struct lpfc_dmabuf dbuf;
164895427bdSJames Smart uint16_t total_size;
165895427bdSJames Smart uint16_t bytes_recv;
166ed957684SJames Smart uint32_t tag;
1674d9ab994SJames Smart struct lpfc_cq_event cq_event;
16845ed1190SJames Smart unsigned long time_stamp;
169895427bdSJames Smart void *context;
170895427bdSJames Smart };
171895427bdSJames Smart
172895427bdSJames Smart struct rqb_dmabuf {
173895427bdSJames Smart struct lpfc_dmabuf hbuf;
174895427bdSJames Smart struct lpfc_dmabuf dbuf;
175895427bdSJames Smart uint16_t total_size;
176895427bdSJames Smart uint16_t bytes_recv;
177a8cf5dfeSJames Smart uint16_t idx;
178895427bdSJames Smart struct lpfc_queue *hrq; /* ptr to associated Header RQ */
179895427bdSJames Smart struct lpfc_queue *drq; /* ptr to associated Data RQ */
180ed957684SJames Smart };
181ed957684SJames Smart
182dea3101eS /* Priority bit. Set value to exceed low water mark in lpfc_mem. */
183dea3101eS #define MEM_PRI 0x100
184dea3101eS
185dea3101eS
186dea3101eS /****************************************************************************/
187dea3101eS /* Device VPD save area */
188dea3101eS /****************************************************************************/
189dea3101eS typedef struct lpfc_vpd {
190dea3101eS uint32_t status; /* vpd status value */
191dea3101eS uint32_t length; /* number of bytes actually returned */
192dea3101eS struct {
193dea3101eS uint32_t rsvd1; /* Revision numbers */
194dea3101eS uint32_t biuRev;
195dea3101eS uint32_t smRev;
196dea3101eS uint32_t smFwRev;
197dea3101eS uint32_t endecRev;
198dea3101eS uint16_t rBit;
199dea3101eS uint8_t fcphHigh;
200dea3101eS uint8_t fcphLow;
201dea3101eS uint8_t feaLevelHigh;
202dea3101eS uint8_t feaLevelLow;
203dea3101eS uint32_t postKernRev;
204dea3101eS uint32_t opFwRev;
205dea3101eS uint8_t opFwName[16];
206dea3101eS uint32_t sli1FwRev;
207dea3101eS uint8_t sli1FwName[16];
208dea3101eS uint32_t sli2FwRev;
209dea3101eS uint8_t sli2FwName[16];
210dea3101eS } rev;
21192d7f7b0SJames Smart struct {
21292d7f7b0SJames Smart #ifdef __BIG_ENDIAN_BITFIELD
2130e75461aSJames Smart uint32_t rsvd3 :20; /* Reserved */
214da0436e9SJames Smart uint32_t rsvd2 : 3; /* Reserved */
215da0436e9SJames Smart uint32_t cbg : 1; /* Configure BlockGuard */
21692d7f7b0SJames Smart uint32_t cmv : 1; /* Configure Max VPIs */
21792d7f7b0SJames Smart uint32_t ccrp : 1; /* Config Command Ring Polling */
21892d7f7b0SJames Smart uint32_t csah : 1; /* Configure Synchronous Abort Handling */
21992d7f7b0SJames Smart uint32_t chbs : 1; /* Cofigure Host Backing store */
22092d7f7b0SJames Smart uint32_t cinb : 1; /* Enable Interrupt Notification Block */
22192d7f7b0SJames Smart uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
22292d7f7b0SJames Smart uint32_t cmx : 1; /* Configure Max XRIs */
22392d7f7b0SJames Smart uint32_t cmr : 1; /* Configure Max RPIs */
22492d7f7b0SJames Smart #else /* __LITTLE_ENDIAN */
22592d7f7b0SJames Smart uint32_t cmr : 1; /* Configure Max RPIs */
22692d7f7b0SJames Smart uint32_t cmx : 1; /* Configure Max XRIs */
22792d7f7b0SJames Smart uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
22892d7f7b0SJames Smart uint32_t cinb : 1; /* Enable Interrupt Notification Block */
22992d7f7b0SJames Smart uint32_t chbs : 1; /* Cofigure Host Backing store */
23092d7f7b0SJames Smart uint32_t csah : 1; /* Configure Synchronous Abort Handling */
23192d7f7b0SJames Smart uint32_t ccrp : 1; /* Config Command Ring Polling */
23292d7f7b0SJames Smart uint32_t cmv : 1; /* Configure Max VPIs */
233da0436e9SJames Smart uint32_t cbg : 1; /* Configure BlockGuard */
234da0436e9SJames Smart uint32_t rsvd2 : 3; /* Reserved */
2350e75461aSJames Smart uint32_t rsvd3 :20; /* Reserved */
23692d7f7b0SJames Smart #endif
23792d7f7b0SJames Smart } sli3Feat;
238dea3101eS } lpfc_vpd_t;
239dea3101eS
240dea3101eS
241dea3101eS /*
242dea3101eS * lpfc stat counters
243dea3101eS */
244dea3101eS struct lpfc_stats {
245dea3101eS /* Statistics for ELS commands */
246dea3101eS uint32_t elsLogiCol;
247dea3101eS uint32_t elsRetryExceeded;
248dea3101eS uint32_t elsXmitRetry;
249dea3101eS uint32_t elsDelayRetry;
250dea3101eS uint32_t elsRcvDrop;
251dea3101eS uint32_t elsRcvFrame;
252dea3101eS uint32_t elsRcvRSCN;
253dea3101eS uint32_t elsRcvRNID;
254dea3101eS uint32_t elsRcvFARP;
255dea3101eS uint32_t elsRcvFARPR;
256dea3101eS uint32_t elsRcvFLOGI;
257dea3101eS uint32_t elsRcvPLOGI;
258dea3101eS uint32_t elsRcvADISC;
259dea3101eS uint32_t elsRcvPDISC;
260dea3101eS uint32_t elsRcvFAN;
261dea3101eS uint32_t elsRcvLOGO;
262dea3101eS uint32_t elsRcvPRLO;
263dea3101eS uint32_t elsRcvPRLI;
2647bb3b137SJamie Wellnitz uint32_t elsRcvLIRR;
26512265f68SJames Smart uint32_t elsRcvRLS;
2667bb3b137SJamie Wellnitz uint32_t elsRcvRPL;
2675ffc266eSJames Smart uint32_t elsRcvRRQ;
26812265f68SJames Smart uint32_t elsRcvRTV;
26912265f68SJames Smart uint32_t elsRcvECHO;
2708b017a30SJames Smart uint32_t elsRcvLCB;
27186478875SJames Smart uint32_t elsRcvRDP;
2728eced807SJames Smart uint32_t elsRcvRDF;
273dea3101eS uint32_t elsXmitFLOGI;
27492d7f7b0SJames Smart uint32_t elsXmitFDISC;
275dea3101eS uint32_t elsXmitPLOGI;
276dea3101eS uint32_t elsXmitPRLI;
277dea3101eS uint32_t elsXmitADISC;
278dea3101eS uint32_t elsXmitLOGO;
279dea3101eS uint32_t elsXmitSCR;
280f60cb93bSJames Smart uint32_t elsXmitRSCN;
281dea3101eS uint32_t elsXmitRNID;
282dea3101eS uint32_t elsXmitFARP;
283dea3101eS uint32_t elsXmitFARPR;
284dea3101eS uint32_t elsXmitACC;
285dea3101eS uint32_t elsXmitLSRJT;
286dea3101eS
287dea3101eS uint32_t frameRcvBcast;
288dea3101eS uint32_t frameRcvMulti;
289dea3101eS uint32_t strayXmitCmpl;
290dea3101eS uint32_t frameXmitDelay;
291dea3101eS uint32_t xriCmdCmpl;
292dea3101eS uint32_t xriStatErr;
293dea3101eS uint32_t LinkUp;
294dea3101eS uint32_t LinkDown;
295dea3101eS uint32_t LinkMultiEvent;
296dea3101eS uint32_t NoRcvBuf;
297dea3101eS uint32_t fcpCmd;
298dea3101eS uint32_t fcpCmpl;
299dea3101eS uint32_t fcpRspErr;
300dea3101eS uint32_t fcpRemoteStop;
301dea3101eS uint32_t fcpPortRjt;
302dea3101eS uint32_t fcpPortBusy;
303dea3101eS uint32_t fcpError;
304dea3101eS uint32_t fcpLocalErr;
305dea3101eS };
306dea3101eS
3072e0fef85SJames Smart struct lpfc_hba;
308dea3101eS
30992d7f7b0SJames Smart
31002169e84SGaurav Srivastava #define LPFC_VMID_TIMER 300 /* timer interval in seconds */
31102169e84SGaurav Srivastava
31202169e84SGaurav Srivastava #define LPFC_MAX_VMID_SIZE 256
31302169e84SGaurav Srivastava
31402169e84SGaurav Srivastava union lpfc_vmid_io_tag {
31502169e84SGaurav Srivastava u32 app_id; /* App Id vmid */
31602169e84SGaurav Srivastava u8 cs_ctl_vmid; /* Priority tag vmid */
31702169e84SGaurav Srivastava };
31802169e84SGaurav Srivastava
31902169e84SGaurav Srivastava #define JIFFIES_PER_HR (HZ * 60 * 60)
32002169e84SGaurav Srivastava
32102169e84SGaurav Srivastava struct lpfc_vmid {
32202169e84SGaurav Srivastava u8 flag;
32302169e84SGaurav Srivastava #define LPFC_VMID_SLOT_FREE 0x0
32402169e84SGaurav Srivastava #define LPFC_VMID_SLOT_USED 0x1
32502169e84SGaurav Srivastava #define LPFC_VMID_REQ_REGISTER 0x2
32602169e84SGaurav Srivastava #define LPFC_VMID_REGISTERED 0x4
32702169e84SGaurav Srivastava #define LPFC_VMID_DE_REGISTER 0x8
32802169e84SGaurav Srivastava char host_vmid[LPFC_MAX_VMID_SIZE];
32902169e84SGaurav Srivastava union lpfc_vmid_io_tag un;
33002169e84SGaurav Srivastava struct hlist_node hnode;
33102169e84SGaurav Srivastava u64 io_rd_cnt;
33202169e84SGaurav Srivastava u64 io_wr_cnt;
33302169e84SGaurav Srivastava u8 vmid_len;
33402169e84SGaurav Srivastava u8 delete_inactive; /* Delete if inactive flag 0 = no, 1 = yes */
33502169e84SGaurav Srivastava u32 hash_index;
33602169e84SGaurav Srivastava u64 __percpu *last_io_time;
33702169e84SGaurav Srivastava };
33802169e84SGaurav Srivastava
33902169e84SGaurav Srivastava #define lpfc_vmid_is_type_priority_tag(vport)\
34002169e84SGaurav Srivastava (vport->vmid_priority_tagging ? 1 : 0)
34102169e84SGaurav Srivastava
34202169e84SGaurav Srivastava #define LPFC_VMID_HASH_SIZE 256
34302169e84SGaurav Srivastava #define LPFC_VMID_HASH_MASK 255
34402169e84SGaurav Srivastava #define LPFC_VMID_HASH_SHIFT 6
34502169e84SGaurav Srivastava
34602169e84SGaurav Srivastava struct lpfc_vmid_context {
34702169e84SGaurav Srivastava struct lpfc_vmid *vmp;
34802169e84SGaurav Srivastava struct lpfc_nodelist *nlp;
34902169e84SGaurav Srivastava bool instantiated;
35002169e84SGaurav Srivastava };
35102169e84SGaurav Srivastava
35202169e84SGaurav Srivastava struct lpfc_vmid_priority_range {
35302169e84SGaurav Srivastava u8 low;
35402169e84SGaurav Srivastava u8 high;
35502169e84SGaurav Srivastava u8 qos;
35602169e84SGaurav Srivastava };
35702169e84SGaurav Srivastava
35802169e84SGaurav Srivastava struct lpfc_vmid_priority_info {
35902169e84SGaurav Srivastava u32 num_descriptors;
36002169e84SGaurav Srivastava struct lpfc_vmid_priority_range *vmid_range;
36102169e84SGaurav Srivastava };
36202169e84SGaurav Srivastava
36302169e84SGaurav Srivastava #define QFPA_EVEN_ONLY 0x01
36402169e84SGaurav Srivastava #define QFPA_ODD_ONLY 0x02
36502169e84SGaurav Srivastava #define QFPA_EVEN_ODD 0x03
36602169e84SGaurav Srivastava
3672e0fef85SJames Smart enum discovery_state {
36892d7f7b0SJames Smart LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */
36992d7f7b0SJames Smart LPFC_VPORT_FAILED = 1, /* vport has failed */
3702e0fef85SJames Smart LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */
3712e0fef85SJames Smart LPFC_FLOGI = 7, /* FLOGI sent to Fabric */
37292d7f7b0SJames Smart LPFC_FDISC = 8, /* FDISC sent for vport */
37392d7f7b0SJames Smart LPFC_FABRIC_CFG_LINK = 9, /* Fabric assigned NPORT Id
3742e0fef85SJames Smart * configured */
37592d7f7b0SJames Smart LPFC_NS_REG = 10, /* Register with NameServer */
37692d7f7b0SJames Smart LPFC_NS_QRY = 11, /* Query NameServer for NPort ID list */
37792d7f7b0SJames Smart LPFC_BUILD_DISC_LIST = 12, /* Build ADISC and PLOGI lists for
378dea3101eS * device authentication / discovery */
37992d7f7b0SJames Smart LPFC_DISC_AUTH = 13, /* Processing ADISC list */
3802e0fef85SJames Smart LPFC_VPORT_READY = 32,
3812e0fef85SJames Smart };
382dea3101eS
3832e0fef85SJames Smart enum hba_state {
3842e0fef85SJames Smart LPFC_LINK_UNKNOWN = 0, /* HBA state is unknown */
3852e0fef85SJames Smart LPFC_WARM_START = 1, /* HBA state after selective reset */
3862e0fef85SJames Smart LPFC_INIT_START = 2, /* Initial state after board reset */
3872e0fef85SJames Smart LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */
3882e0fef85SJames Smart LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */
3892e0fef85SJames Smart LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */
39092d7f7b0SJames Smart LPFC_CLEAR_LA = 6, /* authentication cmplt - issue
3912e0fef85SJames Smart * CLEAR_LA */
39292d7f7b0SJames Smart LPFC_HBA_READY = 32,
3932e0fef85SJames Smart LPFC_HBA_ERROR = -1
3942e0fef85SJames Smart };
395dea3101eS
3961dc5ec24SJames Smart struct lpfc_trunk_link_state {
3971dc5ec24SJames Smart enum hba_state state;
3981dc5ec24SJames Smart uint8_t fault;
3991dc5ec24SJames Smart };
4001dc5ec24SJames Smart
4011dc5ec24SJames Smart struct lpfc_trunk_link {
4021dc5ec24SJames Smart struct lpfc_trunk_link_state link0,
4031dc5ec24SJames Smart link1,
4041dc5ec24SJames Smart link2,
4051dc5ec24SJames Smart link3;
406dbb1e2ffSJames Smart u32 phy_lnk_speed;
4071dc5ec24SJames Smart };
4081dc5ec24SJames Smart
40972df8a45SJames Smart /* Format of congestion module parameters */
41072df8a45SJames Smart struct lpfc_cgn_param {
41172df8a45SJames Smart uint32_t cgn_param_magic;
41272df8a45SJames Smart uint8_t cgn_param_version; /* version 1 */
41372df8a45SJames Smart uint8_t cgn_param_mode; /* 0=off 1=managed 2=monitor only */
41472df8a45SJames Smart #define LPFC_CFG_OFF 0
41572df8a45SJames Smart #define LPFC_CFG_MANAGED 1
41672df8a45SJames Smart #define LPFC_CFG_MONITOR 2
41772df8a45SJames Smart uint8_t cgn_rsvd1;
41872df8a45SJames Smart uint8_t cgn_rsvd2;
41972df8a45SJames Smart uint8_t cgn_param_level0;
42072df8a45SJames Smart uint8_t cgn_param_level1;
42172df8a45SJames Smart uint8_t cgn_param_level2;
42272df8a45SJames Smart uint8_t byte11;
42372df8a45SJames Smart uint8_t byte12;
42472df8a45SJames Smart uint8_t byte13;
42572df8a45SJames Smart uint8_t byte14;
42672df8a45SJames Smart uint8_t byte15;
42772df8a45SJames Smart };
42872df8a45SJames Smart
4298c42a65cSJames Smart /* Max number of days of congestion data */
4308c42a65cSJames Smart #define LPFC_MAX_CGN_DAYS 10
4318c42a65cSJames Smart
43293190ac1SJustin Tee struct lpfc_cgn_ts {
43393190ac1SJustin Tee uint8_t month;
43493190ac1SJustin Tee uint8_t day;
43593190ac1SJustin Tee uint8_t year;
43693190ac1SJustin Tee uint8_t hour;
43793190ac1SJustin Tee uint8_t minute;
43893190ac1SJustin Tee uint8_t second;
43993190ac1SJustin Tee };
44093190ac1SJustin Tee
4418c42a65cSJames Smart /* Format of congestion buffer info
4428c42a65cSJames Smart * This structure defines memory thats allocated and registered with
4438c42a65cSJames Smart * the HBA firmware. When adding or removing fields from this structure
4448c42a65cSJames Smart * the alignment must match the HBA firmware.
4458c42a65cSJames Smart */
4468c42a65cSJames Smart
4478c42a65cSJames Smart struct lpfc_cgn_info {
4488c42a65cSJames Smart /* Header */
4498c42a65cSJames Smart __le16 cgn_info_size; /* is sizeof(struct lpfc_cgn_info) */
4508c42a65cSJames Smart uint8_t cgn_info_version; /* represents format of structure */
4518c42a65cSJames Smart #define LPFC_CGN_INFO_V1 1
4528c42a65cSJames Smart #define LPFC_CGN_INFO_V2 2
4538c42a65cSJames Smart #define LPFC_CGN_INFO_V3 3
45493190ac1SJustin Tee #define LPFC_CGN_INFO_V4 4
4558c42a65cSJames Smart uint8_t cgn_info_mode; /* 0=off 1=managed 2=monitor only */
4568c42a65cSJames Smart uint8_t cgn_info_detect;
4578c42a65cSJames Smart uint8_t cgn_info_action;
4588c42a65cSJames Smart uint8_t cgn_info_level0;
4598c42a65cSJames Smart uint8_t cgn_info_level1;
4608c42a65cSJames Smart uint8_t cgn_info_level2;
4618c42a65cSJames Smart
4628c42a65cSJames Smart /* Start Time */
46393190ac1SJustin Tee struct lpfc_cgn_ts base_time;
4648c42a65cSJames Smart
4658c42a65cSJames Smart /* minute / hours / daily indices */
4668c42a65cSJames Smart uint8_t cgn_index_minute;
4678c42a65cSJames Smart uint8_t cgn_index_hour;
4688c42a65cSJames Smart uint8_t cgn_index_day;
4698c42a65cSJames Smart
4708c42a65cSJames Smart __le16 cgn_warn_freq;
4718c42a65cSJames Smart __le16 cgn_alarm_freq;
4728c42a65cSJames Smart __le16 cgn_lunq;
4738c42a65cSJames Smart uint8_t cgn_pad1[8];
4748c42a65cSJames Smart
4758c42a65cSJames Smart /* Driver Information */
4768c42a65cSJames Smart __le16 cgn_drvr_min[60];
4778c42a65cSJames Smart __le32 cgn_drvr_hr[24];
4788c42a65cSJames Smart __le32 cgn_drvr_day[LPFC_MAX_CGN_DAYS];
4798c42a65cSJames Smart
4808c42a65cSJames Smart /* Congestion Warnings */
4818c42a65cSJames Smart __le16 cgn_warn_min[60];
4828c42a65cSJames Smart __le32 cgn_warn_hr[24];
4838c42a65cSJames Smart __le32 cgn_warn_day[LPFC_MAX_CGN_DAYS];
4848c42a65cSJames Smart
4858c42a65cSJames Smart /* Latency Information */
4868c42a65cSJames Smart __le32 cgn_latency_min[60];
4878c42a65cSJames Smart __le32 cgn_latency_hr[24];
4888c42a65cSJames Smart __le32 cgn_latency_day[LPFC_MAX_CGN_DAYS];
4898c42a65cSJames Smart
4908c42a65cSJames Smart /* Bandwidth Information */
4918c42a65cSJames Smart __le16 cgn_bw_min[60];
4928c42a65cSJames Smart __le16 cgn_bw_hr[24];
4938c42a65cSJames Smart __le16 cgn_bw_day[LPFC_MAX_CGN_DAYS];
4948c42a65cSJames Smart
4958c42a65cSJames Smart /* Congestion Alarms */
4968c42a65cSJames Smart __le16 cgn_alarm_min[60];
4978c42a65cSJames Smart __le32 cgn_alarm_hr[24];
4988c42a65cSJames Smart __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS];
4998c42a65cSJames Smart
500532adda9SKees Cook struct_group(cgn_stat,
5018c42a65cSJames Smart uint8_t cgn_stat_npm; /* Notifications per minute */
5028c42a65cSJames Smart
5038c42a65cSJames Smart /* Start Time */
50493190ac1SJustin Tee struct lpfc_cgn_ts stat_start; /* Base time */
50593190ac1SJustin Tee uint8_t cgn_pad2;
5068c42a65cSJames Smart
5078c42a65cSJames Smart __le32 cgn_notification;
5088c42a65cSJames Smart __le32 cgn_peer_notification;
5098c42a65cSJames Smart __le32 link_integ_notification;
5108c42a65cSJames Smart __le32 delivery_notification;
51193190ac1SJustin Tee struct lpfc_cgn_ts stat_fpin; /* Last congestion notification FPIN */
51293190ac1SJustin Tee struct lpfc_cgn_ts stat_peer; /* Last peer congestion FPIN */
51393190ac1SJustin Tee struct lpfc_cgn_ts stat_lnk; /* Last link integrity FPIN */
51493190ac1SJustin Tee struct lpfc_cgn_ts stat_delivery; /* Last delivery notification FPIN */
515532adda9SKees Cook );
5168c42a65cSJames Smart
5178c42a65cSJames Smart __le32 cgn_info_crc;
5188c42a65cSJames Smart #define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
5198c42a65cSJames Smart #define LPFC_CGN_CRC32_SEED 0xFFFFFFFF
5208c42a65cSJames Smart };
5218c42a65cSJames Smart
5228c42a65cSJames Smart #define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \
5238c42a65cSJames Smart sizeof(uint32_t))
5248c42a65cSJames Smart
52502243836SJames Smart struct lpfc_cgn_stat {
52602243836SJames Smart atomic64_t total_bytes;
52702243836SJames Smart atomic64_t rcv_bytes;
52802243836SJames Smart atomic64_t rx_latency;
52902243836SJames Smart #define LPFC_CGN_NOT_SENT 0xFFFFFFFFFFFFFFFFLL
53002243836SJames Smart atomic_t rx_io_cnt;
53102243836SJames Smart };
53202243836SJames Smart
5339064aeb2SJames Smart struct lpfc_cgn_acqe_stat {
5349064aeb2SJames Smart atomic64_t alarm;
5359064aeb2SJames Smart atomic64_t warn;
5369064aeb2SJames Smart };
5379064aeb2SJames Smart
5382e0fef85SJames Smart struct lpfc_vport {
5392e0fef85SJames Smart struct lpfc_hba *phba;
5403772a991SJames Smart struct list_head listentry;
5412e0fef85SJames Smart uint8_t port_type;
5422e0fef85SJames Smart #define LPFC_PHYSICAL_PORT 1
5432e0fef85SJames Smart #define LPFC_NPIV_PORT 2
5442e0fef85SJames Smart #define LPFC_FABRIC_PORT 3
5452e0fef85SJames Smart enum discovery_state port_state;
546dea3101eS
54792d7f7b0SJames Smart uint16_t vpi;
548da0436e9SJames Smart uint16_t vfi;
549c868595dSJames Smart uint8_t vpi_state;
550c868595dSJames Smart #define LPFC_VPI_REGISTERED 0x1
551dea3101eS
552dea3101eS uint32_t fc_flag; /* FC flags */
5532e0fef85SJames Smart /* Several of these flags are HBA centric and should be moved to
5542e0fef85SJames Smart * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
5552e0fef85SJames Smart */
556dea3101eS #define FC_PT2PT 0x1 /* pt2pt with no fabric */
557dea3101eS #define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */
558dea3101eS #define FC_DISC_TMO 0x4 /* Discovery timer running */
559dea3101eS #define FC_PUBLIC_LOOP 0x8 /* Public loop */
560dea3101eS #define FC_LBIT 0x10 /* LOGIN bit in loopinit set */
561dea3101eS #define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */
562dea3101eS #define FC_NLP_MORE 0x40 /* More node to process in node tbl */
563dea3101eS #define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */
564dea3101eS #define FC_FABRIC 0x100 /* We are fabric attached */
5654b40c59eSJames Smart #define FC_VPORT_LOGO_RCVD 0x200 /* LOGO received on vport */
56692d7f7b0SJames Smart #define FC_RSCN_DISCOVERY 0x400 /* Auth all devices after RSCN */
5674b40c59eSJames Smart #define FC_LOGO_RCVD_DID_CHNG 0x800 /* FDISC on phys port detect DID chng*/
5687f4c5a26SJames Smart #define FC_PT2PT_NO_NVME 0x1000 /* Don't send NVME PRLI */
569dea3101eS #define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
570dea3101eS #define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
571dea3101eS #define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
572c9f8735bSJamie Wellnitz #define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
57392d7f7b0SJames Smart #define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
57492d7f7b0SJames Smart #define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
5751c6834a7SJames Smart #define FC_VPORT_NEEDS_INIT_VPI 0x200000 /* Need to INIT_VPI before FDISC */
576695a814eSJames Smart #define FC_VPORT_CVL_RCVD 0x400000 /* VLink failed due to CVL */
577695a814eSJames Smart #define FC_VFI_REGISTERED 0x800000 /* VFI is registered */
578695a814eSJames Smart #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */
57992494144SJames Smart #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */
580dea3101eS
5817ee5d43eSJames Smart uint32_t ct_flags;
5827ee5d43eSJames Smart #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
5837ee5d43eSJames Smart #define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
5847ee5d43eSJames Smart #define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
5857ee5d43eSJames Smart #define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
5867ee5d43eSJames Smart #define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
587de3ec318SJames Smart #define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */
5887ee5d43eSJames Smart
589685f0bf7SJames Smart struct list_head fc_nodes;
590dea3101eS
591dea3101eS /* Keep counters for the number of entries in each list. */
592dea3101eS uint16_t fc_plogi_cnt;
593dea3101eS uint16_t fc_adisc_cnt;
594dea3101eS uint16_t fc_reglogin_cnt;
595dea3101eS uint16_t fc_prli_cnt;
596dea3101eS uint16_t fc_unmap_cnt;
597dea3101eS uint16_t fc_map_cnt;
598dea3101eS uint16_t fc_npr_cnt;
599dea3101eS uint16_t fc_unused_cnt;
6002e0fef85SJames Smart struct serv_parm fc_sparam; /* buffer for our service parameters */
6012e0fef85SJames Smart
6022e0fef85SJames Smart uint32_t fc_myDID; /* fibre channel S_ID */
6032e0fef85SJames Smart uint32_t fc_prevDID; /* previous fibre channel S_ID */
60492494144SJames Smart struct lpfc_name fabric_portname;
60592494144SJames Smart struct lpfc_name fabric_nodename;
6062e0fef85SJames Smart
6072e0fef85SJames Smart int32_t stopped; /* HBA has not been restarted since last ERATT */
6082e0fef85SJames Smart uint8_t fc_linkspeed; /* Link speed after last READ_LA */
6092e0fef85SJames Smart
6102e0fef85SJames Smart uint32_t num_disc_nodes; /* in addition to hba_state */
611a0f2d3efSJames Smart uint32_t gidft_inp; /* cnt of outstanding GID_FTs */
6122e0fef85SJames Smart
6132e0fef85SJames Smart uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */
6142e0fef85SJames Smart uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */
6157f5f3d0dSJames Smart uint32_t fc_rscn_flush; /* flag use of fc_rscn_id_list */
6162e0fef85SJames Smart struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN];
6172e0fef85SJames Smart struct lpfc_name fc_nodename; /* fc nodename */
6182e0fef85SJames Smart struct lpfc_name fc_portname; /* fc portname */
6192e0fef85SJames Smart
6202e0fef85SJames Smart struct lpfc_work_evt disc_timeout_evt;
6212e0fef85SJames Smart
6222e0fef85SJames Smart struct timer_list fc_disctmo; /* Discovery rescue timer */
6232e0fef85SJames Smart uint8_t fc_ns_retry; /* retries for fabric nameserver */
6242e0fef85SJames Smart uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */
6252e0fef85SJames Smart
6262e0fef85SJames Smart spinlock_t work_port_lock;
6272e0fef85SJames Smart uint32_t work_port_events; /* Timeout to be handled */
628858c9f6cSJames Smart #define WORKER_DISC_TMO 0x1 /* vport: Discovery timeout */
629858c9f6cSJames Smart #define WORKER_ELS_TMO 0x2 /* vport: ELS timeout */
63092494144SJames Smart #define WORKER_DELAYED_DISC_TMO 0x8 /* vport: delayed discovery */
631858c9f6cSJames Smart
632858c9f6cSJames Smart #define WORKER_MBOX_TMO 0x100 /* hba: MBOX timeout */
633858c9f6cSJames Smart #define WORKER_HB_TMO 0x200 /* hba: Heart beat timeout */
634b1c11812SJoe Perches #define WORKER_FABRIC_BLOCK_TMO 0x400 /* hba: fabric block timeout */
635858c9f6cSJames Smart #define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */
636858c9f6cSJames Smart #define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */
6372a9bf3d0SJames Smart #define WORKER_SERVICE_TXQ 0x2000 /* hba: IOCBs on the txq */
63802169e84SGaurav Srivastava #define WORKER_CHECK_INACTIVE_VMID 0x4000 /* hba: check inactive vmids */
63902169e84SGaurav Srivastava #define WORKER_CHECK_VMID_ISSUE_QFPA 0x8000 /* vport: Check if qfpa needs
64002169e84SGaurav Srivastava * to be issued */
6412e0fef85SJames Smart
6422e0fef85SJames Smart struct timer_list els_tmofunc;
64392494144SJames Smart struct timer_list delayed_disc_tmo;
6442e0fef85SJames Smart
6452e0fef85SJames Smart uint8_t load_flag;
6462e0fef85SJames Smart #define FC_LOADING 0x1 /* HBA in process of loading drvr */
6472e0fef85SJames Smart #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
6484258e98eSJames Smart #define FC_ALLOW_FDMI 0x4 /* port is ready for FDMI requests */
64902169e84SGaurav Srivastava #define FC_ALLOW_VMID 0x8 /* Allow VMID I/Os */
65002169e84SGaurav Srivastava #define FC_DEREGISTER_ALL_APP_ID 0x10 /* Deregister all VMIDs */
6513de2a653SJames Smart /* Vport Config Parameters */
6523de2a653SJames Smart uint32_t cfg_scan_down;
6533de2a653SJames Smart uint32_t cfg_lun_queue_depth;
6543de2a653SJames Smart uint32_t cfg_nodev_tmo;
6553de2a653SJames Smart uint32_t cfg_devloss_tmo;
6563de2a653SJames Smart uint32_t cfg_restrict_login;
6573de2a653SJames Smart uint32_t cfg_peer_port_login;
6583de2a653SJames Smart uint32_t cfg_fcp_class;
6593de2a653SJames Smart uint32_t cfg_use_adisc;
6603de2a653SJames Smart uint32_t cfg_discovery_threads;
661e8b62011SJames Smart uint32_t cfg_log_verbose;
662f6e84790SJames Smart uint32_t cfg_enable_fc4_type;
6633de2a653SJames Smart uint32_t cfg_max_luns;
6647ee5d43eSJames Smart uint32_t cfg_enable_da_id;
665977b5a0aSJames Smart uint32_t cfg_max_scsicmpl_time;
6667dc517dfSJames Smart uint32_t cfg_tgt_queue_depth;
6673cb01c57SJames Smart uint32_t cfg_first_burst_size;
6683de2a653SJames Smart uint32_t dev_loss_tmo_changed;
66902169e84SGaurav Srivastava /* VMID parameters */
67019d7102aSAndy Shevchenko u8 lpfc_vmid_host_uuid[16];
67102169e84SGaurav Srivastava u32 max_vmid; /* maximum VMIDs allowed per port */
67202169e84SGaurav Srivastava u32 cur_vmid_cnt; /* Current VMID count */
67302169e84SGaurav Srivastava #define LPFC_MIN_VMID 4
67402169e84SGaurav Srivastava #define LPFC_MAX_VMID 255
67502169e84SGaurav Srivastava u32 vmid_inactivity_timeout; /* Time after which the VMID */
67602169e84SGaurav Srivastava /* deregisters from switch */
67702169e84SGaurav Srivastava u32 vmid_priority_tagging;
67802169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_DISABLE 0 /* Disable */
67902169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_SUP_TARGETS 1 /* Allow supported targets only */
68002169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_ALL_TARGETS 2 /* Allow all targets */
68102169e84SGaurav Srivastava unsigned long *vmid_priority_range;
68202169e84SGaurav Srivastava #define LPFC_VMID_MAX_PRIORITY_RANGE 256
68302169e84SGaurav Srivastava #define LPFC_VMID_PRIORITY_BITMAP_SIZE 32
68402169e84SGaurav Srivastava u8 vmid_flag;
68502169e84SGaurav Srivastava #define LPFC_VMID_IN_USE 0x1
68602169e84SGaurav Srivastava #define LPFC_VMID_ISSUE_QFPA 0x2
68702169e84SGaurav Srivastava #define LPFC_VMID_QFPA_CMPL 0x4
68802169e84SGaurav Srivastava #define LPFC_VMID_QOS_ENABLED 0x8
68902169e84SGaurav Srivastava #define LPFC_VMID_TIMER_ENBLD 0x10
6905099478eSJames Smart #define LPFC_VMID_TYPE_PRIO 0x20
69102169e84SGaurav Srivastava struct fc_qfpa_res *qfpa_res;
69251ef4c26SJames Smart
69351ef4c26SJames Smart struct fc_vport *fc_vport;
69451ef4c26SJames Smart
69502169e84SGaurav Srivastava struct lpfc_vmid *vmid;
69602169e84SGaurav Srivastava DECLARE_HASHTABLE(hash_table, 8);
69702169e84SGaurav Srivastava rwlock_t vmid_lock;
69802169e84SGaurav Srivastava struct lpfc_vmid_priority_info vmid_priority;
69902169e84SGaurav Srivastava
700923e4b6aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
70151ef4c26SJames Smart struct dentry *debug_disc_trc;
70251ef4c26SJames Smart struct dentry *debug_nodelist;
703bd2cdd5eSJames Smart struct dentry *debug_nvmestat;
7044c47efc1SJames Smart struct dentry *debug_scsistat;
7052fcbc569SJames Smart struct dentry *debug_ioktime;
706840eda96SJames Smart struct dentry *debug_hdwqstat;
70751ef4c26SJames Smart struct dentry *vport_debugfs_root;
70851ef4c26SJames Smart struct lpfc_debugfs_trc *disc_trc;
70951ef4c26SJames Smart atomic_t disc_trc_cnt;
71051ef4c26SJames Smart #endif
711da0436e9SJames Smart struct list_head rcv_buffer_list;
71245ed1190SJames Smart unsigned long rcv_buffer_time_stamp;
713da0436e9SJames Smart uint32_t vport_flag;
7141b6f71f7SJames Smart #define STATIC_VPORT 0x1
7151b6f71f7SJames Smart #define FAWWPN_PARAM_CHG 0x2
7164258e98eSJames Smart
7174258e98eSJames Smart uint16_t fdmi_num_disc;
7184258e98eSJames Smart uint32_t fdmi_hba_mask;
7194258e98eSJames Smart uint32_t fdmi_port_mask;
720895427bdSJames Smart
721895427bdSJames Smart /* There is a single nvme instance per vport. */
722895427bdSJames Smart struct nvme_fc_local_port *localport;
723895427bdSJames Smart uint8_t nvmei_support; /* driver supports NVME Initiator */
724895427bdSJames Smart uint32_t last_fcp_wqidx;
725d496b9a7SJames Smart uint32_t rcv_flogi_cnt; /* How many unsol FLOGIs ACK'd. */
7262e0fef85SJames Smart };
7272e0fef85SJames Smart
728ed957684SJames Smart struct hbq_s {
729ed957684SJames Smart uint16_t entry_count; /* Current number of HBQ slots */
730a8adb832SJames Smart uint16_t buffer_count; /* Current number of buffers posted */
731ed957684SJames Smart uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
732ed957684SJames Smart uint32_t hbqPutIdx; /* HBQ slot to use */
733ed957684SJames Smart uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
73451ef4c26SJames Smart void *hbq_virt; /* Virtual ptr to this hbq */
73551ef4c26SJames Smart struct list_head hbq_buffer_list; /* buffers assigned to this HBQ */
73651ef4c26SJames Smart /* Callback for HBQ buffer allocation */
73751ef4c26SJames Smart struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *);
73851ef4c26SJames Smart /* Callback for HBQ buffer free */
73951ef4c26SJames Smart void (*hbq_free_buffer) (struct lpfc_hba *,
74051ef4c26SJames Smart struct hbq_dmabuf *);
741ed957684SJames Smart };
742ed957684SJames Smart
74351ef4c26SJames Smart /* this matches the position in the lpfc_hbq_defs array */
74492d7f7b0SJames Smart #define LPFC_ELS_HBQ 0
745895427bdSJames Smart #define LPFC_MAX_HBQS 1
746ed957684SJames Smart
7477af67051SJames Smart enum hba_temp_state {
7487af67051SJames Smart HBA_NORMAL_TEMP,
7497af67051SJames Smart HBA_OVER_TEMP
7507af67051SJames Smart };
7517af67051SJames Smart
752db2378e0SJames Smart enum intr_type_t {
753db2378e0SJames Smart NONE = 0,
754db2378e0SJames Smart INTx,
755db2378e0SJames Smart MSI,
756db2378e0SJames Smart MSIX,
757db2378e0SJames Smart };
758db2378e0SJames Smart
7596dd9e31cSJames Smart #define LPFC_CT_CTX_MAX 64
760f1c3b0fcSJames Smart struct unsol_rcv_ct_ctx {
761f1c3b0fcSJames Smart uint32_t ctxt_id;
762f1c3b0fcSJames Smart uint32_t SID;
7636dd9e31cSJames Smart uint32_t valid;
7646dd9e31cSJames Smart #define UNSOL_INVALID 0
7656dd9e31cSJames Smart #define UNSOL_VALID 1
7667851fe2cSJames Smart uint16_t oxid;
7677851fe2cSJames Smart uint16_t rxid;
768f1c3b0fcSJames Smart };
769f1c3b0fcSJames Smart
77076a95d75SJames Smart #define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
77176a95d75SJames Smart #define LPFC_USER_LINK_SPEED_1G 1 /* 1 Gigabaud */
77276a95d75SJames Smart #define LPFC_USER_LINK_SPEED_2G 2 /* 2 Gigabaud */
77376a95d75SJames Smart #define LPFC_USER_LINK_SPEED_4G 4 /* 4 Gigabaud */
77476a95d75SJames Smart #define LPFC_USER_LINK_SPEED_8G 8 /* 8 Gigabaud */
77576a95d75SJames Smart #define LPFC_USER_LINK_SPEED_10G 10 /* 10 Gigabaud */
77676a95d75SJames Smart #define LPFC_USER_LINK_SPEED_16G 16 /* 16 Gigabaud */
777d38dd52cSJames Smart #define LPFC_USER_LINK_SPEED_32G 32 /* 32 Gigabaud */
778fbd8a6baSJames Smart #define LPFC_USER_LINK_SPEED_64G 64 /* 64 Gigabaud */
779fbd8a6baSJames Smart #define LPFC_USER_LINK_SPEED_MAX LPFC_USER_LINK_SPEED_64G
780fbd8a6baSJames Smart
781fbd8a6baSJames Smart #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
78276a95d75SJames Smart
7837ad20aa9SJames Smart enum nemb_type {
7847ad20aa9SJames Smart nemb_mse = 1,
7857ad20aa9SJames Smart nemb_hbd
7867ad20aa9SJames Smart };
7877ad20aa9SJames Smart
7887ad20aa9SJames Smart enum mbox_type {
7897ad20aa9SJames Smart mbox_rd = 1,
7907ad20aa9SJames Smart mbox_wr
7917ad20aa9SJames Smart };
7927ad20aa9SJames Smart
7937ad20aa9SJames Smart enum dma_type {
7947ad20aa9SJames Smart dma_mbox = 1,
7957ad20aa9SJames Smart dma_ebuf
7967ad20aa9SJames Smart };
7977ad20aa9SJames Smart
7987ad20aa9SJames Smart enum sta_type {
7997ad20aa9SJames Smart sta_pre_addr = 1,
8007ad20aa9SJames Smart sta_pos_addr
8017ad20aa9SJames Smart };
8027ad20aa9SJames Smart
8037ad20aa9SJames Smart struct lpfc_mbox_ext_buf_ctx {
8047ad20aa9SJames Smart uint32_t state;
8057ad20aa9SJames Smart #define LPFC_BSG_MBOX_IDLE 0
8067ad20aa9SJames Smart #define LPFC_BSG_MBOX_HOST 1
8077ad20aa9SJames Smart #define LPFC_BSG_MBOX_PORT 2
8087ad20aa9SJames Smart #define LPFC_BSG_MBOX_DONE 3
8097ad20aa9SJames Smart #define LPFC_BSG_MBOX_ABTS 4
8107ad20aa9SJames Smart enum nemb_type nembType;
8117ad20aa9SJames Smart enum mbox_type mboxType;
8127ad20aa9SJames Smart uint32_t numBuf;
8137ad20aa9SJames Smart uint32_t mbxTag;
8147ad20aa9SJames Smart uint32_t seqNum;
8157ad20aa9SJames Smart struct lpfc_dmabuf *mbx_dmabuf;
8167ad20aa9SJames Smart struct list_head ext_dmabuf_list;
8177ad20aa9SJames Smart };
8187ad20aa9SJames Smart
819c490850aSJames Smart struct lpfc_epd_pool {
820c490850aSJames Smart /* Expedite pool */
821c490850aSJames Smart struct list_head list;
822c490850aSJames Smart u32 count;
823c490850aSJames Smart spinlock_t lock; /* lock for expedite pool */
824c490850aSJames Smart };
825c490850aSJames Smart
82695bfc6d8SJames Smart enum ras_state {
82795bfc6d8SJames Smart INACTIVE,
82895bfc6d8SJames Smart REG_INPROGRESS,
82995bfc6d8SJames Smart ACTIVE
83095bfc6d8SJames Smart };
83195bfc6d8SJames Smart
832d2cc9bcdSJames Smart struct lpfc_ras_fwlog {
833d2cc9bcdSJames Smart uint8_t *fwlog_buff;
834d2cc9bcdSJames Smart uint32_t fw_buffcount; /* Buffer size posted to FW */
835d2cc9bcdSJames Smart #define LPFC_RAS_BUFF_ENTERIES 16 /* Each entry can hold max of 64k */
836d2cc9bcdSJames Smart #define LPFC_RAS_MAX_ENTRY_SIZE (64 * 1024)
837d2cc9bcdSJames Smart #define LPFC_RAS_MIN_BUFF_POST_SIZE (256 * 1024)
838d2cc9bcdSJames Smart #define LPFC_RAS_MAX_BUFF_POST_SIZE (1024 * 1024)
839d2cc9bcdSJames Smart uint32_t fw_loglevel; /* Log level set */
840d2cc9bcdSJames Smart struct lpfc_dmabuf lwpd;
841d2cc9bcdSJames Smart struct list_head fwlog_buff_list;
842d2cc9bcdSJames Smart
843d2cc9bcdSJames Smart /* RAS support status on adapter */
844d2cc9bcdSJames Smart bool ras_hwsupport; /* RAS Support available on HW or not */
845d2cc9bcdSJames Smart bool ras_enabled; /* Ras Enabled for the function */
846d2cc9bcdSJames Smart #define LPFC_RAS_DISABLE_LOGGING 0x00
847d2cc9bcdSJames Smart #define LPFC_RAS_ENABLE_LOGGING 0x01
84895bfc6d8SJames Smart enum ras_state state; /* RAS logging running state */
849d2cc9bcdSJames Smart };
850d2cc9bcdSJames Smart
851372c187bSDick Kennedy #define DBG_LOG_STR_SZ 256
852372c187bSDick Kennedy #define DBG_LOG_SZ 256
853372c187bSDick Kennedy
854372c187bSDick Kennedy struct dbg_log_ent {
855372c187bSDick Kennedy char log[DBG_LOG_STR_SZ];
856372c187bSDick Kennedy u64 t_ns;
857372c187bSDick Kennedy };
858372c187bSDick Kennedy
8593048e3e8SDick Kennedy enum lpfc_irq_chann_mode {
8603048e3e8SDick Kennedy /* Assign IRQs to all possible cpus that have hardware queues */
8613048e3e8SDick Kennedy NORMAL_MODE,
8623048e3e8SDick Kennedy
8633048e3e8SDick Kennedy /* Assign IRQs only to cpus on the same numa node as HBA */
8643048e3e8SDick Kennedy NUMA_MODE,
8653048e3e8SDick Kennedy
8663048e3e8SDick Kennedy /* Assign IRQs only on non-hyperthreaded CPUs. This is the
8673048e3e8SDick Kennedy * same as normal_mode, but assign IRQS only on physical CPUs.
8683048e3e8SDick Kennedy */
8693048e3e8SDick Kennedy NHT_MODE,
8703048e3e8SDick Kennedy };
8713048e3e8SDick Kennedy
87235ed9613SJames Smart enum lpfc_hba_bit_flags {
87335ed9613SJames Smart FABRIC_COMANDS_BLOCKED,
87435ed9613SJames Smart HBA_PCI_ERR,
875089ea22eSJustin Tee MBX_TMO_ERR,
87635ed9613SJames Smart };
87735ed9613SJames Smart
8782e0fef85SJames Smart struct lpfc_hba {
8793772a991SJames Smart /* SCSI interface function jump table entries */
880c490850aSJames Smart struct lpfc_io_buf * (*lpfc_get_scsi_buf)
881ace44e48SJames Smart (struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
882ace44e48SJames Smart struct scsi_cmnd *cmnd);
8833772a991SJames Smart int (*lpfc_scsi_prep_dma_buf)
884c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
8853772a991SJames Smart void (*lpfc_scsi_unprep_dma_buf)
886c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
8873772a991SJames Smart void (*lpfc_release_scsi_buf)
888c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
8893772a991SJames Smart void (*lpfc_rampdown_queue_depth)
8903772a991SJames Smart (struct lpfc_hba *);
8913772a991SJames Smart void (*lpfc_scsi_prep_cmnd)
892c490850aSJames Smart (struct lpfc_vport *, struct lpfc_io_buf *,
8933772a991SJames Smart struct lpfc_nodelist *);
894da255e2eSJames Smart int (*lpfc_scsi_prep_cmnd_buf)
895da255e2eSJames Smart (struct lpfc_vport *vport,
896da255e2eSJames Smart struct lpfc_io_buf *lpfc_cmd,
897da255e2eSJames Smart uint8_t tmo);
8983512ac09SJames Smart int (*lpfc_scsi_prep_task_mgmt_cmd)
8993512ac09SJames Smart (struct lpfc_vport *vport,
9003512ac09SJames Smart struct lpfc_io_buf *lpfc_cmd,
9013512ac09SJames Smart u64 lun, u8 task_mgmt_cmd);
902acd6859bSJames Smart
9033772a991SJames Smart /* IOCB interface function jump table entries */
9043772a991SJames Smart int (*__lpfc_sli_issue_iocb)
9053772a991SJames Smart (struct lpfc_hba *, uint32_t,
9063772a991SJames Smart struct lpfc_iocbq *, uint32_t);
90747ff4c51SJames Smart int (*__lpfc_sli_issue_fcp_io)
90847ff4c51SJames Smart (struct lpfc_hba *phba, uint32_t ring_number,
90947ff4c51SJames Smart struct lpfc_iocbq *piocb, uint32_t flag);
9103772a991SJames Smart void (*__lpfc_sli_release_iocbq)(struct lpfc_hba *,
9113772a991SJames Smart struct lpfc_iocbq *);
9123772a991SJames Smart int (*lpfc_hba_down_post)(struct lpfc_hba *phba);
9133772a991SJames Smart
9143772a991SJames Smart /* MBOX interface function jump table entries */
9153772a991SJames Smart int (*lpfc_sli_issue_mbox)
9163772a991SJames Smart (struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
917acd6859bSJames Smart
9183772a991SJames Smart /* Slow-path IOCB process function jump table entries */
9193772a991SJames Smart void (*lpfc_sli_handle_slow_ring_event)
9203772a991SJames Smart (struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
9213772a991SJames Smart uint32_t mask);
922acd6859bSJames Smart
9233772a991SJames Smart /* INIT device interface function jump table entries */
9243772a991SJames Smart int (*lpfc_sli_hbq_to_firmware)
9253772a991SJames Smart (struct lpfc_hba *, uint32_t, struct hbq_dmabuf *);
9263772a991SJames Smart int (*lpfc_sli_brdrestart)
9273772a991SJames Smart (struct lpfc_hba *);
9283772a991SJames Smart int (*lpfc_sli_brdready)
9293772a991SJames Smart (struct lpfc_hba *, uint32_t);
9303772a991SJames Smart void (*lpfc_handle_eratt)
9313772a991SJames Smart (struct lpfc_hba *);
9323772a991SJames Smart void (*lpfc_stop_port)
9333772a991SJames Smart (struct lpfc_hba *);
93484d1b006SJames Smart int (*lpfc_hba_init_link)
9356e7288d9SJames Smart (struct lpfc_hba *, uint32_t);
93684d1b006SJames Smart int (*lpfc_hba_down_link)
9376e7288d9SJames Smart (struct lpfc_hba *, uint32_t);
9387f86059aSJames Smart int (*lpfc_selective_reset)
9397f86059aSJames Smart (struct lpfc_hba *);
9403772a991SJames Smart
941acd6859bSJames Smart int (*lpfc_bg_scsi_prep_dma_buf)
942c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
9436831ce12SJames Smart
9446831ce12SJames Smart /* Prep SLI WQE/IOCB jump table entries */
9456831ce12SJames Smart void (*__lpfc_sli_prep_els_req_rsp)(struct lpfc_iocbq *cmdiocbq,
9466831ce12SJames Smart struct lpfc_vport *vport,
9476831ce12SJames Smart struct lpfc_dmabuf *bmp,
9486831ce12SJames Smart u16 cmd_size, u32 did, u32 elscmd,
9496831ce12SJames Smart u8 tmo, u8 expect_rsp);
95061910d6aSJames Smart void (*__lpfc_sli_prep_gen_req)(struct lpfc_iocbq *cmdiocbq,
95161910d6aSJames Smart struct lpfc_dmabuf *bmp, u16 rpi,
95261910d6aSJames Smart u32 num_entry, u8 tmo);
95361910d6aSJames Smart void (*__lpfc_sli_prep_xmit_seq64)(struct lpfc_iocbq *cmdiocbq,
95461910d6aSJames Smart struct lpfc_dmabuf *bmp, u16 rpi,
95561910d6aSJames Smart u16 ox_id, u32 num_entry, u8 rctl,
95661910d6aSJames Smart u8 last_seq, u8 cr_cx_cmd);
95731a59f75SJames Smart void (*__lpfc_sli_prep_abort_xri)(struct lpfc_iocbq *cmdiocbq,
95831a59f75SJames Smart u16 ulp_context, u16 iotag,
959b21c9debSJames Smart u8 ulp_class, u16 cqid, bool ia,
960b21c9debSJames Smart bool wqec);
961acd6859bSJames Smart
962c490850aSJames Smart /* expedite pool */
963c490850aSJames Smart struct lpfc_epd_pool epd_pool;
964c490850aSJames Smart
9653772a991SJames Smart /* SLI4 specific HBA data structure */
9663772a991SJames Smart struct lpfc_sli4_hba sli4_hba;
9673772a991SJames Smart
968f485c18dSDick Kennedy struct workqueue_struct *wq;
96932517fc0SJames Smart struct delayed_work eq_delay_work;
970f485c18dSDick Kennedy
971317aeb83SDick Kennedy #define LPFC_IDLE_STAT_DELAY 1000
972317aeb83SDick Kennedy struct delayed_work idle_stat_delay_work;
973317aeb83SDick Kennedy
9742e0fef85SJames Smart struct lpfc_sli sli;
9753772a991SJames Smart uint8_t pci_dev_grp; /* lpfc PCI dev group: 0x0, 0x1, 0x2,... */
9763772a991SJames Smart uint32_t sli_rev; /* SLI2, SLI3, or SLI4 */
977ed957684SJames Smart uint32_t sli3_options; /* Mask of enabled SLI3 options */
97834b02dcdSJames Smart #define LPFC_SLI3_HBQ_ENABLED 0x01
97934b02dcdSJames Smart #define LPFC_SLI3_NPIV_ENABLED 0x02
98034b02dcdSJames Smart #define LPFC_SLI3_VPORT_TEARDOWN 0x04
98134b02dcdSJames Smart #define LPFC_SLI3_CRP_ENABLED 0x08
98281301a9bSJames Smart #define LPFC_SLI3_BG_ENABLED 0x20
983da0436e9SJames Smart #define LPFC_SLI3_DSS_ENABLED 0x40
984fedd3b7bSJames Smart #define LPFC_SLI4_PERFH_ENABLED 0x80
985fedd3b7bSJames Smart #define LPFC_SLI4_PHWQ_ENABLED 0x100
986ed957684SJames Smart uint32_t iocb_cmd_size;
987ed957684SJames Smart uint32_t iocb_rsp_size;
9882e0fef85SJames Smart
9891dc5ec24SJames Smart struct lpfc_trunk_link trunk_link;
9902e0fef85SJames Smart enum hba_state link_state;
9912e0fef85SJames Smart uint32_t link_flag; /* link state flags */
99292d7f7b0SJames Smart #define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
9932e0fef85SJames Smart /* This flag is set while issuing */
9942e0fef85SJames Smart /* INIT_LINK mailbox command */
99592d7f7b0SJames Smart #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
9961b32f6aaSJames Smart #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */
997ae9e28f3SJames Smart #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
99853e13ee0SJames Smart #define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
9998aaa7bcfSJames Smart #define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
1000ead76d4cSJames Smart #define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */
10012e0fef85SJames Smart
10029399627fSJames Smart uint32_t hba_flag; /* hba generic flags */
10039399627fSJames Smart #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
1004da0436e9SJames Smart #define DEFER_ERATT 0x2 /* Deferred error attention in progress */
100576a95d75SJames Smart #define HBA_FCOE_MODE 0x4 /* HBA function in FCoE Mode */
100645ed1190SJames Smart #define HBA_SP_QUEUE_EVT 0x8 /* Slow-path qevt posted to worker thread*/
1007da0436e9SJames Smart #define HBA_POST_RECEIVE_BUFFER 0x10 /* Rcv buffers need to be posted */
100883c6cb1aSJames Smart #define HBA_PERSISTENT_TOPO 0x20 /* Persistent topology support in hba */
1009e7dab164SJames Smart #define ELS_XRI_ABORT_EVENT 0x40 /* ELS_XRI abort event was queued */
1010da0436e9SJames Smart #define ASYNC_EVENT 0x80
1011a0c87cbdSJames Smart #define LINK_DISABLED 0x100 /* Link disabled by user */
1012a93ff37aSJames Smart #define FCF_TS_INPROG 0x200 /* FCF table scan in progress */
1013a93ff37aSJames Smart #define FCF_RR_INPROG 0x400 /* FCF roundrobin flogi in progress */
1014a93ff37aSJames Smart #define HBA_FIP_SUPPORT 0x800 /* FIP support in HBA */
1015a93ff37aSJames Smart #define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */
101619ca7609SJames Smart #define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */
1017c00f62e6SJames Smart #define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */
101865791f1fSJames Smart #define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */
1019c691816eSJames Smart #define HBA_FORCED_LINK_SPEED 0x40000 /*
1020c691816eSJames Smart * Firmware supports Forced Link Speed
1021c691816eSJames Smart * capability
1022c691816eSJames Smart */
10230a9e9687SJames Smart #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */
1024835214f5SJames Smart #define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */
102502243836SJames Smart #define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */
1026d2f2547eSJames Smart #define HBA_NEEDS_CFG_PORT 0x2000000 /* SLI3 - needs a CONFIG_PORT mbox */
1027a22d73b6SJames Smart #define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */
1028a22d73b6SJames Smart #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
10299dd83f75SJames Smart #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
1030de3ec318SJames Smart #define HBA_RHBA_CMPL 0x20000000 /* RHBA FDMI command is successful */
1031895427bdSJames Smart
10327dd2e2a9SJames Smart struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
103345ed1190SJames Smart uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
103434b02dcdSJames Smart struct lpfc_dmabuf slim2p;
10352e0fef85SJames Smart
103634b02dcdSJames Smart MAILBOX_t *mbox;
10377a470277SJames Smart uint32_t *mbox_ext;
10387ad20aa9SJames Smart struct lpfc_mbox_ext_buf_ctx mbox_ext_buf_ctx;
10399399627fSJames Smart uint32_t ha_copy;
104034b02dcdSJames Smart struct _PCB *pcb;
104134b02dcdSJames Smart struct _IOCB *IOCBs;
104234b02dcdSJames Smart
104334b02dcdSJames Smart struct lpfc_dmabuf hbqslimp;
10442e0fef85SJames Smart
10452e0fef85SJames Smart uint16_t pci_cfg_value;
10462e0fef85SJames Smart
10472e0fef85SJames Smart uint8_t fc_linkspeed; /* Link speed after last READ_LA */
10482e0fef85SJames Smart
10492e0fef85SJames Smart uint32_t fc_eventTag; /* event tag for link attention */
10504d9ab994SJames Smart uint32_t link_events;
10512e0fef85SJames Smart
10522e0fef85SJames Smart /* These fields used to be binfo */
10532e0fef85SJames Smart uint32_t fc_pref_DID; /* preferred D_ID */
10542e0fef85SJames Smart uint8_t fc_pref_ALPA; /* preferred AL_PA */
105512265f68SJames Smart uint32_t fc_edtovResol; /* E_D_TOV timer resolution */
10562e0fef85SJames Smart uint32_t fc_edtov; /* E_D_TOV timer value */
10572e0fef85SJames Smart uint32_t fc_arbtov; /* ARB_TOV timer value */
10582e0fef85SJames Smart uint32_t fc_ratov; /* R_A_TOV timer value */
10592e0fef85SJames Smart uint32_t fc_rttov; /* R_T_TOV timer value */
10602e0fef85SJames Smart uint32_t fc_altov; /* AL_TOV timer value */
10612e0fef85SJames Smart uint32_t fc_crtov; /* C_R_TOV timer value */
10622e0fef85SJames Smart
10632e0fef85SJames Smart struct serv_parm fc_fabparam; /* fabric service parameters buffer */
10642e0fef85SJames Smart uint8_t alpa_map[128]; /* AL_PA map from READ_LA */
10652e0fef85SJames Smart
10662e0fef85SJames Smart uint32_t lmt;
10672e0fef85SJames Smart
10682e0fef85SJames Smart uint32_t fc_topology; /* link topology, from LINK INIT */
1069e74c03c8SJames Smart uint32_t fc_topology_changed; /* link topology, from LINK INIT */
10702e0fef85SJames Smart
10712e0fef85SJames Smart struct lpfc_stats fc_stat;
10722e0fef85SJames Smart
1073dea3101eS struct lpfc_nodelist fc_fcpnodev; /* nodelist entry for no device */
1074dea3101eS uint32_t nport_event_cnt; /* timestamp for nlplist entry */
1075dea3101eS
10762e0fef85SJames Smart uint8_t wwnn[8];
10772e0fef85SJames Smart uint8_t wwpn[8];
1078dea3101eS uint32_t RandomData[7];
10797bdedb34SJames Smart uint8_t fcp_embed_io;
1080895427bdSJames Smart uint8_t nvmet_support; /* driver supports NVMET */
1081f358dd0cSJames Smart #define LPFC_NVMET_MAX_PORTS 32
10827bdedb34SJames Smart uint8_t mds_diags_support;
108344fd7fe3SJames Smart uint8_t bbcredit_support;
1084c176ffa0SJames Smart uint8_t enab_exp_wqcq_pages;
10850d8af096SJames Smart u8 nsler; /* Firmware supports FC-NVMe-2 SLER */
1086dea3101eS
10873de2a653SJames Smart /* HBA Config Parameters */
1088dea3101eS uint32_t cfg_ack0;
1089c490850aSJames Smart uint32_t cfg_xri_rebalancing;
1090d79c9e9dSJames Smart uint32_t cfg_xpsgl;
109178b2d852SJames Smart uint32_t cfg_enable_npiv;
109219ca7609SJames Smart uint32_t cfg_enable_rrq;
1093dea3101eS uint32_t cfg_topology;
1094dea3101eS uint32_t cfg_link_speed;
10957d791df7SJames Smart #define LPFC_FCF_FOV 1 /* Fast fcf failover */
10967d791df7SJames Smart #define LPFC_FCF_PRIORITY 2 /* Priority fcf failover */
10977d791df7SJames Smart uint32_t cfg_fcf_failover_policy;
109849aa143dSJames Smart uint32_t cfg_fcp_io_sched;
10997ea92eb4SJames Smart uint32_t cfg_ns_query;
1100a6571c6eSJames Smart uint32_t cfg_fcp2_no_tgt_reset;
1101dea3101eS uint32_t cfg_cr_delay;
1102dea3101eS uint32_t cfg_cr_count;
1103cf5bf97eSJamie Wellnitz uint32_t cfg_multi_ring_support;
1104a4bc3379SJames Smart uint32_t cfg_multi_ring_rctl;
1105a4bc3379SJames Smart uint32_t cfg_multi_ring_type;
1106875fbdfeSJames.Smart@Emulex.Com uint32_t cfg_poll;
1107875fbdfeSJames.Smart@Emulex.Com uint32_t cfg_poll_tmo;
11080c411222SJames Smart uint32_t cfg_task_mgmt_tmo;
11094ff43246SJames Smart uint32_t cfg_use_msi;
11100cf07f84SJames Smart uint32_t cfg_auto_imax;
1111da0436e9SJames Smart uint32_t cfg_fcp_imax;
111241b194b8SJames Smart uint32_t cfg_force_rscn;
111332517fc0SJames Smart uint32_t cfg_cq_poll_threshold;
111432517fc0SJames Smart uint32_t cfg_cq_max_proc_limit;
11157bb03bbfSJames Smart uint32_t cfg_fcp_cpu_map;
111677ffd346SJames Smart uint32_t cfg_fcp_mq_threshold;
1117cdb42becSJames Smart uint32_t cfg_hdw_queue;
11186a828b0fSJames Smart uint32_t cfg_irq_chann;
1119f358dd0cSJames Smart uint32_t cfg_suppress_rsp;
1120895427bdSJames Smart uint32_t cfg_nvme_oas;
11214e565cf0SJames Smart uint32_t cfg_nvme_embed_cmd;
11222448e484SJames Smart uint32_t cfg_nvmet_mrq_post;
11232d7dbc4cSJames Smart uint32_t cfg_nvmet_mrq;
1124f358dd0cSJames Smart uint32_t cfg_enable_nvmet;
1125895427bdSJames Smart uint32_t cfg_nvme_enable_fb;
11262d7dbc4cSJames Smart uint32_t cfg_nvmet_fb_size;
112796f7077fSJames Smart uint32_t cfg_total_seg_cnt;
1128dea3101eS uint32_t cfg_sg_seg_cnt;
11294d4c4a4aSJames Smart uint32_t cfg_nvme_seg_cnt;
11305b9e70b2SJames Smart uint32_t cfg_scsi_seg_cnt;
1131dea3101eS uint32_t cfg_sg_dma_buf_size;
11323de2a653SJames Smart uint32_t cfg_hba_queue_depth;
113313815c83SJames Smart uint32_t cfg_enable_hba_reset;
113413815c83SJames Smart uint32_t cfg_enable_hba_heartbeat;
11351ba981fdSJames Smart uint32_t cfg_fof;
11361ba981fdSJames Smart uint32_t cfg_EnableXLane;
11371ba981fdSJames Smart uint8_t cfg_oas_tgt_wwpn[8];
11381ba981fdSJames Smart uint8_t cfg_oas_vpt_wwpn[8];
11391ba981fdSJames Smart uint32_t cfg_oas_lun_state;
11401ba981fdSJames Smart #define OAS_LUN_ENABLE 1
11411ba981fdSJames Smart #define OAS_LUN_DISABLE 0
11421ba981fdSJames Smart uint32_t cfg_oas_lun_status;
11431ba981fdSJames Smart #define OAS_LUN_STATUS_EXISTS 0x01
11441ba981fdSJames Smart uint32_t cfg_oas_flags;
11451ba981fdSJames Smart #define OAS_FIND_ANY_VPORT 0x01
11461ba981fdSJames Smart #define OAS_FIND_ANY_TARGET 0x02
11471ba981fdSJames Smart #define OAS_LUN_VALID 0x04
1148c92c841cSJames Smart uint32_t cfg_oas_priority;
11491ba981fdSJames Smart uint32_t cfg_XLanePriority;
115081301a9bSJames Smart uint32_t cfg_enable_bg;
1151b3b98b74SJames Smart uint32_t cfg_prot_mask;
1152b3b98b74SJames Smart uint32_t cfg_prot_guard;
11537a470277SJames Smart uint32_t cfg_hostmem_hgp;
1154da0436e9SJames Smart uint32_t cfg_log_verbose;
1155f6e84790SJames Smart uint32_t cfg_enable_fc4_type;
1156c80b27cfSJames Smart #define LPFC_ENABLE_FCP 1
1157c80b27cfSJames Smart #define LPFC_ENABLE_NVME 2
1158c80b27cfSJames Smart #define LPFC_ENABLE_BOTH 3
1159c80b27cfSJames Smart #if (IS_ENABLED(CONFIG_NVME_FC))
1160c80b27cfSJames Smart #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1161c80b27cfSJames Smart #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1162c80b27cfSJames Smart #else
1163c80b27cfSJames Smart #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1164c80b27cfSJames Smart #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1165c80b27cfSJames Smart #endif
1166912e3acdSJames Smart uint32_t cfg_sriov_nr_virtfn;
1167c71ab861SJames Smart uint32_t cfg_request_firmware_upgrade;
116884d1b006SJames Smart uint32_t cfg_suppress_link_up;
1169cff261f6SJames Smart uint32_t cfg_rrq_xri_bitmap_sz;
11703e49af93SJames Smart u32 cfg_fcp_wait_abts_rsp;
11718eb8b960SJames Smart uint32_t cfg_delay_discovery;
117212247e81SJames Smart uint32_t cfg_sli_mode;
1173e40a02c1SJames Smart #define LPFC_INITIALIZE_LINK 0 /* do normal init_link mbox */
1174e40a02c1SJames Smart #define LPFC_DELAY_INIT_LINK 1 /* layered driver hold off */
1175e40a02c1SJames Smart #define LPFC_DELAY_INIT_LINK_INDEFINITELY 2 /* wait, manual intervention */
11764258e98eSJames Smart uint32_t cfg_fdmi_on;
11774258e98eSJames Smart #define LPFC_FDMI_NO_SUPPORT 0 /* FDMI not supported */
11784258e98eSJames Smart #define LPFC_FDMI_SUPPORT 1 /* FDMI supported? */
11794258e98eSJames Smart uint32_t cfg_enable_SmartSAN;
11807bdedb34SJames Smart uint32_t cfg_enable_mds_diags;
1181d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_level;
1182d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_buffsize;
1183d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_func;
118444fd7fe3SJames Smart uint32_t cfg_enable_bbcr; /* Enable BB Credit Recovery */
11851351e69fSJames Smart uint32_t cfg_enable_dpp; /* Enable Direct Packet Push */
1186414abe0aSJames Smart uint32_t cfg_enable_pbde;
11878aaa7bcfSJames Smart uint32_t cfg_enable_mi;
1188f358dd0cSJames Smart struct nvmet_fc_target_port *targetport;
1189dea3101eS lpfc_vpd_t vpd; /* vital product data */
1190dea3101eS
119102169e84SGaurav Srivastava u32 cfg_max_vmid; /* maximum VMIDs allowed per port */
119202169e84SGaurav Srivastava u32 cfg_vmid_app_header;
119302169e84SGaurav Srivastava #define LPFC_VMID_APP_HEADER_DISABLE 0
119402169e84SGaurav Srivastava #define LPFC_VMID_APP_HEADER_ENABLE 1
119502169e84SGaurav Srivastava u32 cfg_vmid_priority_tagging;
119602169e84SGaurav Srivastava u32 cfg_vmid_inactivity_timeout; /* Time after which the VMID */
119702169e84SGaurav Srivastava /* deregisters from switch */
1198dea3101eS struct pci_dev *pcidev;
1199dea3101eS struct list_head work_list;
1200dea3101eS uint32_t work_ha; /* Host Attention Bits for WT */
1201dea3101eS uint32_t work_ha_mask; /* HA Bits owned by WT */
1202dea3101eS uint32_t work_hs; /* HS stored in case of ERRAT */
1203dea3101eS uint32_t work_status[2]; /* Extra status from SLIM */
1204dea3101eS
12055e9d9b82SJames Smart wait_queue_head_t work_waitq;
1206dea3101eS struct task_struct *worker_thread;
1207d7c255b2SJames Smart unsigned long data_flags;
1208d79c9e9dSJames Smart uint32_t border_sge_num;
1209dea3101eS
12103163f725SJames Smart uint32_t hbq_in_use; /* HBQs in use flag */
1211ed957684SJames Smart uint32_t hbq_count; /* Count of configured HBQs */
121292d7f7b0SJames Smart struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
1213ed957684SJames Smart
1214895427bdSJames Smart atomic_t fcp_qidx; /* next FCP WQ (RR Policy) */
1215895427bdSJames Smart atomic_t nvme_qidx; /* next NVME WQ (RR Policy) */
12168fa38513SJames Smart
1217115a4124SJames Smart phys_addr_t pci_bar0_map; /* Physical address for PCI BAR0 */
1218115a4124SJames Smart phys_addr_t pci_bar1_map; /* Physical address for PCI BAR1 */
1219115a4124SJames Smart phys_addr_t pci_bar2_map; /* Physical address for PCI BAR2 */
1220dea3101eS void __iomem *slim_memmap_p; /* Kernel memory mapped address for
1221dea3101eS PCI BAR0 */
1222dea3101eS void __iomem *ctrl_regs_memmap_p;/* Kernel memory mapped address for
1223dea3101eS PCI BAR2 */
1224dea3101eS
1225962bc51bSJames Smart void __iomem *pci_bar0_memmap_p; /* Kernel memory mapped address for
1226962bc51bSJames Smart PCI BAR0 with dual-ULP support */
1227962bc51bSJames Smart void __iomem *pci_bar2_memmap_p; /* Kernel memory mapped address for
1228962bc51bSJames Smart PCI BAR2 with dual-ULP support */
1229962bc51bSJames Smart void __iomem *pci_bar4_memmap_p; /* Kernel memory mapped address for
1230962bc51bSJames Smart PCI BAR4 with dual-ULP support */
1231962bc51bSJames Smart #define PCI_64BIT_BAR0 0
1232962bc51bSJames Smart #define PCI_64BIT_BAR2 2
1233962bc51bSJames Smart #define PCI_64BIT_BAR4 4
1234dea3101eS void __iomem *MBslimaddr; /* virtual address for mbox cmds */
1235dea3101eS void __iomem *HAregaddr; /* virtual address for host attn reg */
1236dea3101eS void __iomem *CAregaddr; /* virtual address for chip attn reg */
1237dea3101eS void __iomem *HSregaddr; /* virtual address for host status
1238dea3101eS reg */
1239dea3101eS void __iomem *HCregaddr; /* virtual address for host ctl reg */
1240dea3101eS
1241ed957684SJames Smart struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */
124234b02dcdSJames Smart struct lpfc_pgp *port_gp;
1243ed957684SJames Smart uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */
124492d7f7b0SJames Smart uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */
1245ed957684SJames Smart
1246dea3101eS int brd_no; /* FC board number */
1247dea3101eS char SerialNumber[32]; /* adapter Serial Number */
1248dea3101eS char OptionROMVersion[32]; /* adapter BIOS / Fcode version */
1249b3b4f3e1SJames Smart char BIOSVersion[16]; /* Boot BIOS version */
1250dea3101eS char ModelDesc[256]; /* Model Description */
1251dea3101eS char ModelName[80]; /* Model Name */
1252dea3101eS char ProgramType[256]; /* Program Type */
1253dea3101eS char Port[20]; /* Port No */
1254dea3101eS uint8_t vpd_flag; /* VPD data flag */
1255dea3101eS
1256dea3101eS #define VPD_MODEL_DESC 0x1 /* valid vpd model description */
1257dea3101eS #define VPD_MODEL_NAME 0x2 /* valid vpd model name */
1258dea3101eS #define VPD_PROGRAM_TYPE 0x4 /* valid vpd program type */
1259dea3101eS #define VPD_PORT 0x8 /* valid vpd port data */
1260dea3101eS #define VPD_MASK 0xf /* mask for any vpd data */
1261dea3101eS
1262352e5fd1SJames Smart
1263875fbdfeSJames.Smart@Emulex.Com struct timer_list fcp_poll_timer;
12649399627fSJames Smart struct timer_list eratt_poll;
126565791f1fSJames Smart uint32_t eratt_poll_interval;
1266875fbdfeSJames.Smart@Emulex.Com
126781301a9bSJames Smart uint64_t bg_guard_err_cnt;
126881301a9bSJames Smart uint64_t bg_apptag_err_cnt;
126981301a9bSJames Smart uint64_t bg_reftag_err_cnt;
1270dea3101eS
1271dea3101eS /* fastpath list. */
1272a40fc5f0SJames Smart spinlock_t scsi_buf_list_get_lock; /* SCSI buf alloc list lock */
1273a40fc5f0SJames Smart spinlock_t scsi_buf_list_put_lock; /* SCSI buf free list lock */
1274a40fc5f0SJames Smart struct list_head lpfc_scsi_buf_list_get;
1275a40fc5f0SJames Smart struct list_head lpfc_scsi_buf_list_put;
1276dea3101eS uint32_t total_scsi_bufs;
1277dea3101eS struct list_head lpfc_iocb_list;
1278dea3101eS uint32_t total_iocbq_bufs;
127919ca7609SJames Smart struct list_head active_rrq_list;
12802e0fef85SJames Smart spinlock_t hbalock;
128102243836SJames Smart struct work_struct unblock_request_work; /* SCSI layer unblock IOs */
1282dea3101eS
1283771db5c0SRomain Perier /* dma_mem_pools */
1284771db5c0SRomain Perier struct dma_pool *lpfc_sg_dma_buf_pool;
1285771db5c0SRomain Perier struct dma_pool *lpfc_mbuf_pool;
1286771db5c0SRomain Perier struct dma_pool *lpfc_hrb_pool; /* header receive buffer pool */
1287771db5c0SRomain Perier struct dma_pool *lpfc_drb_pool; /* data receive buffer pool */
1288771db5c0SRomain Perier struct dma_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */
1289771db5c0SRomain Perier struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
1290d79c9e9dSJames Smart struct dma_pool *lpfc_cmd_rsp_buf_pool;
1291dea3101eS struct lpfc_dma_pool lpfc_mbuf_safety_pool;
1292dea3101eS
1293dea3101eS mempool_t *mbox_mem_pool;
1294dea3101eS mempool_t *nlp_mem_pool;
129519ca7609SJames Smart mempool_t *rrq_pool;
1296cff261f6SJames Smart mempool_t *active_rrq_pool;
1297f888ba3cSJames.Smart@Emulex.Com
1298f888ba3cSJames.Smart@Emulex.Com struct fc_host_statistics link_stats;
12993048e3e8SDick Kennedy enum lpfc_irq_chann_mode irq_chann_mode;
1300db2378e0SJames Smart enum intr_type_t intr_type;
13015b75da2fSJames Smart uint32_t intr_mode;
13025b75da2fSJames Smart #define LPFC_INTR_ERROR 0xFFFFFFFF
13032e0fef85SJames Smart struct list_head port_list;
1304523128e5SJames Smart spinlock_t port_list_lock; /* lock for port_list mutations */
13052e0fef85SJames Smart struct lpfc_vport *pport; /* physical lpfc_vport pointer */
130692d7f7b0SJames Smart uint16_t max_vpi; /* Maximum virtual nports */
13078b47ae69SJames Smart #define LPFC_MAX_VPI 0xFF /* Max number VPI supported 0 - 0xff */
13088b47ae69SJames Smart #define LPFC_MAX_VPORTS 0x100 /* Max vports per port, with pport */
1309da0436e9SJames Smart uint16_t max_vports; /*
1310da0436e9SJames Smart * For IOV HBAs max_vpi can change
1311da0436e9SJames Smart * after a reset. max_vports is max
1312da0436e9SJames Smart * number of vports present. This can
1313da0436e9SJames Smart * be greater than max_vpi.
1314da0436e9SJames Smart */
1315da0436e9SJames Smart uint16_t vpi_base;
1316da0436e9SJames Smart uint16_t vfi_base;
131792d7f7b0SJames Smart unsigned long *vpi_bmask; /* vpi allocation table */
13186d368e53SJames Smart uint16_t *vpi_ids;
13196d368e53SJames Smart uint16_t vpi_count;
13206d368e53SJames Smart struct list_head lpfc_vpi_blk_list;
132192d7f7b0SJames Smart
132292d7f7b0SJames Smart /* Data structure used by fabric iocb scheduler */
132392d7f7b0SJames Smart struct list_head fabric_iocb_list;
132492d7f7b0SJames Smart atomic_t fabric_iocb_count;
132592d7f7b0SJames Smart struct timer_list fabric_block_timer;
132692d7f7b0SJames Smart unsigned long bit_flags;
132792d7f7b0SJames Smart atomic_t num_rsrc_err;
132892d7f7b0SJames Smart unsigned long last_rsrc_error_time;
132992d7f7b0SJames Smart unsigned long last_ramp_down_time;
1330923e4b6aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1331858c9f6cSJames Smart struct dentry *hba_debugfs_root;
1332858c9f6cSJames Smart atomic_t debugfs_vport_count;
1333c490850aSJames Smart struct dentry *debug_multixri_pools;
133478b2d852SJames Smart struct dentry *debug_hbqinfo;
1335c95d6c6cSJames Smart struct dentry *debug_dumpHostSlim;
1336c95d6c6cSJames Smart struct dentry *debug_dumpHBASlim;
1337f9bb2da1SJames Smart struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
13384ac9b226SJames Smart struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
13394ac9b226SJames Smart struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
1340f9bb2da1SJames Smart struct dentry *debug_writeGuard; /* inject write guard_tag errors */
1341f9bb2da1SJames Smart struct dentry *debug_writeApp; /* inject write app_tag errors */
1342f9bb2da1SJames Smart struct dentry *debug_writeRef; /* inject write ref_tag errors */
1343acd6859bSJames Smart struct dentry *debug_readGuard; /* inject read guard_tag errors */
1344f9bb2da1SJames Smart struct dentry *debug_readApp; /* inject read app_tag errors */
1345f9bb2da1SJames Smart struct dentry *debug_readRef; /* inject read ref_tag errors */
1346f9bb2da1SJames Smart
1347bd2cdd5eSJames Smart struct dentry *debug_nvmeio_trc;
1348bd2cdd5eSJames Smart struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
13495e5b511dSJames Smart struct dentry *debug_hdwqinfo;
13506a828b0fSJames Smart #ifdef LPFC_HDWQ_LOCK_STAT
13516a828b0fSJames Smart struct dentry *debug_lockstat;
13526a828b0fSJames Smart #endif
13539f778708SJames Smart struct dentry *debug_cgn_buffer;
13549f778708SJames Smart struct dentry *debug_rx_monitor;
135595bfc6d8SJames Smart struct dentry *debug_ras_log;
1356bd2cdd5eSJames Smart atomic_t nvmeio_trc_cnt;
1357bd2cdd5eSJames Smart uint32_t nvmeio_trc_size;
1358bd2cdd5eSJames Smart uint32_t nvmeio_trc_output_idx;
1359bd2cdd5eSJames Smart
1360f9bb2da1SJames Smart /* T10 DIF error injection */
1361f9bb2da1SJames Smart uint32_t lpfc_injerr_wgrd_cnt;
1362f9bb2da1SJames Smart uint32_t lpfc_injerr_wapp_cnt;
1363f9bb2da1SJames Smart uint32_t lpfc_injerr_wref_cnt;
1364acd6859bSJames Smart uint32_t lpfc_injerr_rgrd_cnt;
1365f9bb2da1SJames Smart uint32_t lpfc_injerr_rapp_cnt;
1366f9bb2da1SJames Smart uint32_t lpfc_injerr_rref_cnt;
13674ac9b226SJames Smart uint32_t lpfc_injerr_nportid;
13684ac9b226SJames Smart struct lpfc_name lpfc_injerr_wwpn;
1369f9bb2da1SJames Smart sector_t lpfc_injerr_lba;
1370acd6859bSJames Smart #define LPFC_INJERR_LBA_OFF (sector_t)(-1)
1371f9bb2da1SJames Smart
1372a58cbd52SJames Smart struct dentry *debug_slow_ring_trc;
1373a58cbd52SJames Smart struct lpfc_debugfs_trc *slow_ring_trc;
1374a58cbd52SJames Smart atomic_t slow_ring_trc_cnt;
13752a622bfbSJames Smart /* iDiag debugfs sub-directory */
13762a622bfbSJames Smart struct dentry *idiag_root;
13772a622bfbSJames Smart struct dentry *idiag_pci_cfg;
1378b76f2dc9SJames Smart struct dentry *idiag_bar_acc;
13792a622bfbSJames Smart struct dentry *idiag_que_info;
138086a80846SJames Smart struct dentry *idiag_que_acc;
138186a80846SJames Smart struct dentry *idiag_drb_acc;
1382b76f2dc9SJames Smart struct dentry *idiag_ctl_acc;
1383b76f2dc9SJames Smart struct dentry *idiag_mbx_acc;
1384b76f2dc9SJames Smart struct dentry *idiag_ext_acc;
138507bcd98eSJames Smart uint8_t lpfc_idiag_last_eq;
1386858c9f6cSJames Smart #endif
1387bd2cdd5eSJames Smart uint16_t nvmeio_trc_on;
1388858c9f6cSJames Smart
13890ff10d46SJames Smart /* Used for deferred freeing of ELS data buffers */
13900ff10d46SJames Smart struct list_head elsbuf;
13910ff10d46SJames Smart int elsbuf_cnt;
13920ff10d46SJames Smart int elsbuf_prev_cnt;
13930ff10d46SJames Smart
139457127f15SJames Smart uint8_t temp_sensor_support;
1395858c9f6cSJames Smart /* Fields used for heart beat. */
1396858c9f6cSJames Smart unsigned long last_completion_time;
1397bc73905aSJames Smart unsigned long skipped_hb;
1398858c9f6cSJames Smart struct timer_list hb_tmofunc;
139919ca7609SJames Smart struct timer_list rrq_tmr;
140084774a4dSJames Smart enum hba_temp_state over_temp_state;
140176bb24efSJames Smart /*
140276bb24efSJames Smart * Following bit will be set for all buffer tags which are not
140376bb24efSJames Smart * associated with any HBQ.
140476bb24efSJames Smart */
140576bb24efSJames Smart #define QUE_BUFTAG_BIT (1<<31)
140676bb24efSJames Smart uint32_t buffer_tag_count;
1407ea2151b4SJames Smart
1408ea2151b4SJames Smart /* Maximum number of events that can be outstanding at any time*/
1409ea2151b4SJames Smart #define LPFC_MAX_EVT_COUNT 512
1410ea2151b4SJames Smart atomic_t fast_event_count;
141132b9793fSJames Smart uint32_t fcoe_eventtag;
141232b9793fSJames Smart uint32_t fcoe_eventtag_at_fcf_scan;
141380c17849SJames Smart uint32_t fcoe_cvl_eventtag;
141480c17849SJames Smart uint32_t fcoe_cvl_eventtag_attn;
1415da0436e9SJames Smart struct lpfc_fcf fcf;
1416da0436e9SJames Smart uint8_t fc_map[3];
1417da0436e9SJames Smart uint8_t valid_vlan;
1418da0436e9SJames Smart uint16_t vlan_id;
1419da0436e9SJames Smart struct list_head fcf_conn_rec_list;
1420f1c3b0fcSJames Smart
14210a9e9687SJames Smart bool defer_flogi_acc_flag;
14220a9e9687SJames Smart uint16_t defer_flogi_acc_rx_id;
14230a9e9687SJames Smart uint16_t defer_flogi_acc_ox_id;
14240a9e9687SJames Smart
14254fede78fSJames Smart spinlock_t ct_ev_lock; /* synchronize access to ct_ev_waiters */
1426f1c3b0fcSJames Smart struct list_head ct_ev_waiters;
14276dd9e31cSJames Smart struct unsol_rcv_ct_ctx ct_ctx[LPFC_CT_CTX_MAX];
1428f1c3b0fcSJames Smart uint32_t ctx_idx;
142902169e84SGaurav Srivastava struct timer_list inactive_vmid_poll;
1430e2aed29fSJames Smart
1431d2cc9bcdSJames Smart /* RAS Support */
1432*e29758e7SJustin Tee spinlock_t ras_fwlog_lock; /* do not take while holding another lock */
1433d2cc9bcdSJames Smart struct lpfc_ras_fwlog ras_fwlog;
1434d2cc9bcdSJames Smart
14352a9bf3d0SJames Smart uint32_t iocb_cnt;
14362a9bf3d0SJames Smart uint32_t iocb_max;
1437d7c47992SJames Smart atomic_t sdev_cnt;
14381ba981fdSJames Smart spinlock_t devicelock; /* lock for luns list */
14391ba981fdSJames Smart mempool_t *device_data_mem_pool;
14401ba981fdSJames Smart struct list_head luns;
1441310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TEMPERATURE 0x0080
1442310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TEMPERATURE 0x0040
1443310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_VOLTAGE 0x0020
1444310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_VOLTAGE 0x0010
1445310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TXBIAS 0x0008
1446310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TXBIAS 0x0004
1447310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TXPOWER 0x0002
1448310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TXPOWER 0x0001
1449310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_RXPOWER 0x8000
1450310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_RXPOWER 0x4000
1451310429efSJames Smart uint16_t sfp_alarm;
1452310429efSJames Smart uint16_t sfp_warning;
1453bd2cdd5eSJames Smart
1454bd2cdd5eSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1455840eda96SJames Smart uint16_t hdwqstat_on;
1456bd2cdd5eSJames Smart #define LPFC_CHECK_OFF 0
1457bd2cdd5eSJames Smart #define LPFC_CHECK_NVME_IO 1
1458840eda96SJames Smart #define LPFC_CHECK_NVMET_IO 2
1459840eda96SJames Smart #define LPFC_CHECK_SCSI_IO 4
1460bd2cdd5eSJames Smart uint16_t ktime_on;
1461bd2cdd5eSJames Smart uint64_t ktime_data_samples;
1462bd2cdd5eSJames Smart uint64_t ktime_status_samples;
1463bd2cdd5eSJames Smart uint64_t ktime_last_cmd;
1464bd2cdd5eSJames Smart uint64_t ktime_seg1_total;
1465bd2cdd5eSJames Smart uint64_t ktime_seg1_min;
1466bd2cdd5eSJames Smart uint64_t ktime_seg1_max;
1467bd2cdd5eSJames Smart uint64_t ktime_seg2_total;
1468bd2cdd5eSJames Smart uint64_t ktime_seg2_min;
1469bd2cdd5eSJames Smart uint64_t ktime_seg2_max;
1470bd2cdd5eSJames Smart uint64_t ktime_seg3_total;
1471bd2cdd5eSJames Smart uint64_t ktime_seg3_min;
1472bd2cdd5eSJames Smart uint64_t ktime_seg3_max;
1473bd2cdd5eSJames Smart uint64_t ktime_seg4_total;
1474bd2cdd5eSJames Smart uint64_t ktime_seg4_min;
1475bd2cdd5eSJames Smart uint64_t ktime_seg4_max;
1476bd2cdd5eSJames Smart uint64_t ktime_seg5_total;
1477bd2cdd5eSJames Smart uint64_t ktime_seg5_min;
1478bd2cdd5eSJames Smart uint64_t ktime_seg5_max;
1479bd2cdd5eSJames Smart uint64_t ktime_seg6_total;
1480bd2cdd5eSJames Smart uint64_t ktime_seg6_min;
1481bd2cdd5eSJames Smart uint64_t ktime_seg6_max;
1482bd2cdd5eSJames Smart uint64_t ktime_seg7_total;
1483bd2cdd5eSJames Smart uint64_t ktime_seg7_min;
1484bd2cdd5eSJames Smart uint64_t ktime_seg7_max;
1485bd2cdd5eSJames Smart uint64_t ktime_seg8_total;
1486bd2cdd5eSJames Smart uint64_t ktime_seg8_min;
1487bd2cdd5eSJames Smart uint64_t ktime_seg8_max;
1488bd2cdd5eSJames Smart uint64_t ktime_seg9_total;
1489bd2cdd5eSJames Smart uint64_t ktime_seg9_min;
1490bd2cdd5eSJames Smart uint64_t ktime_seg9_max;
1491bd2cdd5eSJames Smart uint64_t ktime_seg10_total;
1492bd2cdd5eSJames Smart uint64_t ktime_seg10_min;
1493bd2cdd5eSJames Smart uint64_t ktime_seg10_max;
1494bd2cdd5eSJames Smart #endif
14959064aeb2SJames Smart /* CMF objects */
149602243836SJames Smart struct lpfc_cgn_stat __percpu *cmf_stat;
149702243836SJames Smart uint32_t cmf_interval_rate; /* timer interval limit in ms */
149802243836SJames Smart uint32_t cmf_timer_cnt;
1499daebf93fSJames Smart #define LPFC_CMF_INTERVAL 90
150002243836SJames Smart uint64_t cmf_link_byte_count;
150102243836SJames Smart uint64_t cmf_max_line_rate;
150202243836SJames Smart uint64_t cmf_max_bytes_per_interval;
150302243836SJames Smart uint64_t cmf_last_sync_bw;
1504daebf93fSJames Smart #define LPFC_CMF_BLK_SIZE 512
150502243836SJames Smart struct hrtimer cmf_timer;
150693190ac1SJustin Tee struct hrtimer cmf_stats_timer; /* 1 minute stats timer */
150702243836SJames Smart atomic_t cmf_bw_wait;
150802243836SJames Smart atomic_t cmf_busy;
150902243836SJames Smart atomic_t cmf_stop_io; /* To block request and stop IO's */
151002243836SJames Smart uint32_t cmf_active_mode;
151102243836SJames Smart uint32_t cmf_info_per_interval;
1512daebf93fSJames Smart #define LPFC_MAX_CMF_INFO 32
151302243836SJames Smart struct timespec64 cmf_latency; /* Interval congestion timestamp */
151402243836SJames Smart uint32_t cmf_last_ts; /* Interval congestion time (ms) */
151502243836SJames Smart uint32_t cmf_active_info;
1516daebf93fSJames Smart
15179064aeb2SJames Smart /* Signal / FPIN handling for Congestion Mgmt */
15189064aeb2SJames Smart u8 cgn_reg_fpin; /* Negotiated value from RDF */
15199064aeb2SJames Smart u8 cgn_init_reg_fpin; /* Initial value from READ_CONFIG */
15209064aeb2SJames Smart #define LPFC_CGN_FPIN_NONE 0x0
15219064aeb2SJames Smart #define LPFC_CGN_FPIN_WARN 0x1
15229064aeb2SJames Smart #define LPFC_CGN_FPIN_ALARM 0x2
15239064aeb2SJames Smart #define LPFC_CGN_FPIN_BOTH (LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM)
15249064aeb2SJames Smart
15259064aeb2SJames Smart u8 cgn_reg_signal; /* Negotiated value from EDC */
15269064aeb2SJames Smart u8 cgn_init_reg_signal; /* Initial value from READ_CONFIG */
15279064aeb2SJames Smart /* cgn_reg_signal and cgn_init_reg_signal use
15289064aeb2SJames Smart * enum fc_edc_cg_signal_cap_types
15299064aeb2SJames Smart */
153071ddeeafSJames Smart u16 cgn_fpin_frequency; /* In units of msecs */
15319064aeb2SJames Smart #define LPFC_FPIN_INIT_FREQ 0xffff
15329064aeb2SJames Smart u32 cgn_sig_freq;
15339064aeb2SJames Smart u32 cgn_acqe_cnt;
15349064aeb2SJames Smart
153517b27ac5SJames Smart /* RX monitor handling for CMF */
1536bd269188SJames Smart struct lpfc_rx_info_monitor *rx_monitor;
153717b27ac5SJames Smart atomic_t rx_max_read_cnt; /* Maximum read bytes */
153802243836SJames Smart uint64_t rx_block_cnt;
153902243836SJames Smart
154072df8a45SJames Smart /* Congestion parameters from flash */
154172df8a45SJames Smart struct lpfc_cgn_param cgn_p;
154272df8a45SJames Smart
15439064aeb2SJames Smart /* Statistics counter for ACQE cgn alarms and warnings */
15449064aeb2SJames Smart struct lpfc_cgn_acqe_stat cgn_acqe_stat;
15459064aeb2SJames Smart
15469064aeb2SJames Smart /* Congestion buffer information */
15478c42a65cSJames Smart struct lpfc_dmabuf *cgn_i; /* Congestion Info buffer */
15489064aeb2SJames Smart atomic_t cgn_fabric_warn_cnt; /* Total warning cgn events for info */
15499064aeb2SJames Smart atomic_t cgn_fabric_alarm_cnt; /* Total alarm cgn events for info */
15509064aeb2SJames Smart atomic_t cgn_sync_warn_cnt; /* Total warning events for SYNC wqe */
15519064aeb2SJames Smart atomic_t cgn_sync_alarm_cnt; /* Total alarm events for SYNC wqe */
15528c42a65cSJames Smart atomic_t cgn_driver_evt_cnt; /* Total driver cgn events for fmw */
15538c42a65cSJames Smart atomic_t cgn_latency_evt_cnt;
15548c42a65cSJames Smart atomic64_t cgn_latency_evt; /* Avg latency per minute */
15558c42a65cSJames Smart unsigned long cgn_evt_timestamp;
15568c42a65cSJames Smart #define LPFC_CGN_TIMER_TO_MIN 60000 /* ms in a minute */
15578c42a65cSJames Smart uint32_t cgn_evt_minute;
155893190ac1SJustin Tee #define LPFC_SEC_MIN 60UL
15598c42a65cSJames Smart #define LPFC_MIN_HOUR 60
15608c42a65cSJames Smart #define LPFC_HOUR_DAY 24
15618c42a65cSJames Smart #define LPFC_MIN_DAY (LPFC_MIN_HOUR * LPFC_HOUR_DAY)
156293a4d6f4SJames Smart
156393a4d6f4SJames Smart struct hlist_node cpuhp; /* used for cpuhp per hba callback */
156493a4d6f4SJames Smart struct timer_list cpuhp_poll_timer;
156593a4d6f4SJames Smart struct list_head poll_list; /* slowpath eq polling list */
156693a4d6f4SJames Smart #define LPFC_POLL_HB 1 /* slowpath heartbeat */
1567e3ba04c9SJames Smart
1568e3ba04c9SJames Smart char os_host_name[MAXHOSTNAMELEN];
1569c90b4480SJames Smart
1570dbb1e2ffSJames Smart /* LD Signaling */
1571dbb1e2ffSJames Smart u32 degrade_activate_threshold;
1572dbb1e2ffSJames Smart u32 degrade_deactivate_threshold;
1573dbb1e2ffSJames Smart u32 fec_degrade_interval;
1574dbb1e2ffSJames Smart
1575372c187bSDick Kennedy atomic_t dbg_log_idx;
1576372c187bSDick Kennedy atomic_t dbg_log_cnt;
1577372c187bSDick Kennedy atomic_t dbg_log_dmping;
1578372c187bSDick Kennedy struct dbg_log_ent dbg_log[DBG_LOG_SZ];
1579dea3101eS };
1580dea3101eS
158117b27ac5SJames Smart #define LPFC_MAX_RXMONITOR_ENTRY 800
158274a7baa2SJames Smart #define LPFC_MAX_RXMONITOR_DUMP 32
1583bd269188SJames Smart struct rx_info_entry {
1584a6269f83SJames Smart uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */
158517b27ac5SJames Smart uint64_t total_bytes; /* Total no of read bytes requested */
158617b27ac5SJames Smart uint64_t rcv_bytes; /* Total no of read bytes completed */
158717b27ac5SJames Smart uint64_t avg_io_size;
158817b27ac5SJames Smart uint64_t avg_io_latency;/* Average io latency in microseconds */
158917b27ac5SJames Smart uint64_t max_read_cnt; /* Maximum read bytes */
159017b27ac5SJames Smart uint64_t max_bytes_per_interval;
159117b27ac5SJames Smart uint32_t cmf_busy;
159217b27ac5SJames Smart uint32_t cmf_info; /* CMF_SYNC_WQE info */
159317b27ac5SJames Smart uint32_t io_cnt;
159417b27ac5SJames Smart uint32_t timer_utilization;
159517b27ac5SJames Smart uint32_t timer_interval;
159617b27ac5SJames Smart };
159717b27ac5SJames Smart
1598bd269188SJames Smart struct lpfc_rx_info_monitor {
1599bd269188SJames Smart struct rx_info_entry *ring; /* info organized in a circular buffer */
1600bd269188SJames Smart u32 head_idx, tail_idx; /* index to head/tail of ring */
1601bd269188SJames Smart spinlock_t lock; /* spinlock for ring */
1602bd269188SJames Smart u32 entries; /* storing number entries/size of ring */
1603bd269188SJames Smart };
1604bd269188SJames Smart
16052e0fef85SJames Smart static inline struct Scsi_Host *
lpfc_shost_from_vport(struct lpfc_vport * vport)16062e0fef85SJames Smart lpfc_shost_from_vport(struct lpfc_vport *vport)
16072e0fef85SJames Smart {
16082e0fef85SJames Smart return container_of((void *) vport, struct Scsi_Host, hostdata[0]);
16095b8bd0c9SJames Smart }
1610dea3101eS
16112e0fef85SJames Smart static inline void
lpfc_set_loopback_flag(struct lpfc_hba * phba)16122e0fef85SJames Smart lpfc_set_loopback_flag(struct lpfc_hba *phba)
16132e0fef85SJames Smart {
16142e0fef85SJames Smart if (phba->cfg_topology == FLAGS_LOCAL_LB)
16152e0fef85SJames Smart phba->link_flag |= LS_LOOPBACK_MODE;
16162e0fef85SJames Smart else
16172e0fef85SJames Smart phba->link_flag &= ~LS_LOOPBACK_MODE;
16182e0fef85SJames Smart }
16192e0fef85SJames Smart
16202e0fef85SJames Smart static inline int
lpfc_is_link_up(struct lpfc_hba * phba)16212e0fef85SJames Smart lpfc_is_link_up(struct lpfc_hba *phba)
16222e0fef85SJames Smart {
16232e0fef85SJames Smart return phba->link_state == LPFC_LINK_UP ||
162492d7f7b0SJames Smart phba->link_state == LPFC_CLEAR_LA ||
162592d7f7b0SJames Smart phba->link_state == LPFC_HBA_READY;
16262e0fef85SJames Smart }
16272e0fef85SJames Smart
16285e9d9b82SJames Smart static inline void
lpfc_worker_wake_up(struct lpfc_hba * phba)16295e9d9b82SJames Smart lpfc_worker_wake_up(struct lpfc_hba *phba)
16305e9d9b82SJames Smart {
16315e9d9b82SJames Smart /* Set the lpfc data pending flag */
16325e9d9b82SJames Smart set_bit(LPFC_DATA_READY, &phba->data_flags);
16335e9d9b82SJames Smart
16345e9d9b82SJames Smart /* Wake up worker thread */
16355e9d9b82SJames Smart wake_up(&phba->work_waitq);
16365e9d9b82SJames Smart return;
16375e9d9b82SJames Smart }
16385e9d9b82SJames Smart
16399940b97bSJames Smart static inline int
lpfc_readl(void __iomem * addr,uint32_t * data)16409940b97bSJames Smart lpfc_readl(void __iomem *addr, uint32_t *data)
16419940b97bSJames Smart {
16429940b97bSJames Smart uint32_t temp;
16439940b97bSJames Smart temp = readl(addr);
16449940b97bSJames Smart if (temp == 0xffffffff)
16459940b97bSJames Smart return -EIO;
16469940b97bSJames Smart *data = temp;
16479940b97bSJames Smart return 0;
16489940b97bSJames Smart }
16499940b97bSJames Smart
16509940b97bSJames Smart static inline int
lpfc_sli_read_hs(struct lpfc_hba * phba)16519399627fSJames Smart lpfc_sli_read_hs(struct lpfc_hba *phba)
16529399627fSJames Smart {
16539399627fSJames Smart /*
16549399627fSJames Smart * There was a link/board error. Read the status register to retrieve
16559399627fSJames Smart * the error event and process it.
16569399627fSJames Smart */
16579399627fSJames Smart phba->sli.slistat.err_attn_event++;
16589399627fSJames Smart
16599940b97bSJames Smart /* Save status info and check for unplug error */
16609940b97bSJames Smart if (lpfc_readl(phba->HSregaddr, &phba->work_hs) ||
16619940b97bSJames Smart lpfc_readl(phba->MBslimaddr + 0xa8, &phba->work_status[0]) ||
16629940b97bSJames Smart lpfc_readl(phba->MBslimaddr + 0xac, &phba->work_status[1])) {
16639940b97bSJames Smart return -EIO;
16649940b97bSJames Smart }
16659399627fSJames Smart
16669399627fSJames Smart /* Clear chip Host Attention error bit */
16679399627fSJames Smart writel(HA_ERATT, phba->HAregaddr);
16689399627fSJames Smart readl(phba->HAregaddr); /* flush */
16699399627fSJames Smart phba->pport->stopped = 1;
16709399627fSJames Smart
16719940b97bSJames Smart return 0;
16729399627fSJames Smart }
1673895427bdSJames Smart
1674895427bdSJames Smart static inline struct lpfc_sli_ring *
lpfc_phba_elsring(struct lpfc_hba * phba)1675895427bdSJames Smart lpfc_phba_elsring(struct lpfc_hba *phba)
1676895427bdSJames Smart {
16775a9eeff5SJames Smart /* Return NULL if sli_rev has become invalid due to bad fw */
16785a9eeff5SJames Smart if (phba->sli_rev != LPFC_SLI_REV4 &&
16795a9eeff5SJames Smart phba->sli_rev != LPFC_SLI_REV3 &&
16805a9eeff5SJames Smart phba->sli_rev != LPFC_SLI_REV2)
16815a9eeff5SJames Smart return NULL;
16825a9eeff5SJames Smart
16830c9c6a75SJames Smart if (phba->sli_rev == LPFC_SLI_REV4) {
16840c9c6a75SJames Smart if (phba->sli4_hba.els_wq)
1685895427bdSJames Smart return phba->sli4_hba.els_wq->pring;
16860c9c6a75SJames Smart else
16870c9c6a75SJames Smart return NULL;
16880c9c6a75SJames Smart }
1689895427bdSJames Smart return &phba->sli.sli3_ring[LPFC_ELS_RING];
1690895427bdSJames Smart }
169132517fc0SJames Smart
169232517fc0SJames Smart /**
16933048e3e8SDick Kennedy * lpfc_next_online_cpu - Finds next online CPU on cpumask
16943048e3e8SDick Kennedy * @mask: Pointer to phba's cpumask member.
1695dcaa2136SJames Smart * @start: starting cpu index
1696dcaa2136SJames Smart *
1697dcaa2136SJames Smart * Note: If no valid cpu found, then nr_cpu_ids is returned.
1698dcaa2136SJames Smart *
1699dcaa2136SJames Smart **/
1700dcaa2136SJames Smart static inline unsigned int
lpfc_next_online_cpu(const struct cpumask * mask,unsigned int start)17013048e3e8SDick Kennedy lpfc_next_online_cpu(const struct cpumask *mask, unsigned int start)
1702dcaa2136SJames Smart {
1703dcaa2136SJames Smart unsigned int cpu_it;
1704dcaa2136SJames Smart
17053048e3e8SDick Kennedy for_each_cpu_wrap(cpu_it, mask, start) {
1706dcaa2136SJames Smart if (cpu_online(cpu_it))
1707dcaa2136SJames Smart break;
1708dcaa2136SJames Smart }
1709dcaa2136SJames Smart
1710dcaa2136SJames Smart return cpu_it;
1711dcaa2136SJames Smart }
1712dcaa2136SJames Smart /**
1713d668b368SJustin Tee * lpfc_next_present_cpu - Finds next present CPU after n
1714d668b368SJustin Tee * @n: the cpu prior to search
1715d668b368SJustin Tee *
1716d668b368SJustin Tee * Note: If no next present cpu, then fallback to first present cpu.
1717d668b368SJustin Tee *
1718d668b368SJustin Tee **/
lpfc_next_present_cpu(int n)1719d668b368SJustin Tee static inline unsigned int lpfc_next_present_cpu(int n)
1720d668b368SJustin Tee {
1721d668b368SJustin Tee unsigned int cpu;
1722d668b368SJustin Tee
1723d668b368SJustin Tee cpu = cpumask_next(n, cpu_present_mask);
1724d668b368SJustin Tee
1725d668b368SJustin Tee if (cpu >= nr_cpu_ids)
1726d668b368SJustin Tee cpu = cpumask_first(cpu_present_mask);
1727d668b368SJustin Tee
1728d668b368SJustin Tee return cpu;
1729d668b368SJustin Tee }
1730d668b368SJustin Tee
1731d668b368SJustin Tee /**
173232517fc0SJames Smart * lpfc_sli4_mod_hba_eq_delay - update EQ delay
173332517fc0SJames Smart * @phba: Pointer to HBA context object.
173432517fc0SJames Smart * @q: The Event Queue to update.
173532517fc0SJames Smart * @delay: The delay value (in us) to be written.
173632517fc0SJames Smart *
173732517fc0SJames Smart **/
173832517fc0SJames Smart static inline void
lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba * phba,struct lpfc_queue * eq,u32 delay)173932517fc0SJames Smart lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba *phba, struct lpfc_queue *eq,
174032517fc0SJames Smart u32 delay)
174132517fc0SJames Smart {
174232517fc0SJames Smart struct lpfc_register reg_data;
174332517fc0SJames Smart
174432517fc0SJames Smart reg_data.word0 = 0;
174532517fc0SJames Smart bf_set(lpfc_sliport_eqdelay_id, ®_data, eq->queue_id);
174632517fc0SJames Smart bf_set(lpfc_sliport_eqdelay_delay, ®_data, delay);
174732517fc0SJames Smart writel(reg_data.word0, phba->sli4_hba.u.if_type2.EQDregaddr);
174832517fc0SJames Smart eq->q_mode = delay;
174932517fc0SJames Smart }
1750df3fe766SJames Smart
1751df3fe766SJames Smart
1752df3fe766SJames Smart /*
1753df3fe766SJames Smart * Macro that declares tables and a routine to perform enum type to
1754df3fe766SJames Smart * ascii string lookup.
1755df3fe766SJames Smart *
1756df3fe766SJames Smart * Defines a <key,value> table for an enum. Uses xxx_INIT defines for
1757df3fe766SJames Smart * the enum to populate the table. Macro defines a routine (named
1758df3fe766SJames Smart * by caller) that will search all elements of the table for the key
1759df3fe766SJames Smart * and return the name string if found or "Unrecognized" if not found.
1760df3fe766SJames Smart */
1761df3fe766SJames Smart #define DECLARE_ENUM2STR_LOOKUP(routine, enum_name, enum_init) \
1762df3fe766SJames Smart static struct { \
1763df3fe766SJames Smart enum enum_name value; \
1764df3fe766SJames Smart char *name; \
1765df3fe766SJames Smart } fc_##enum_name##_e2str_names[] = enum_init; \
1766df3fe766SJames Smart static const char *routine(enum enum_name table_key) \
1767df3fe766SJames Smart { \
1768df3fe766SJames Smart int i; \
1769df3fe766SJames Smart char *name = "Unrecognized"; \
1770df3fe766SJames Smart \
1771df3fe766SJames Smart for (i = 0; i < ARRAY_SIZE(fc_##enum_name##_e2str_names); i++) {\
1772df3fe766SJames Smart if (fc_##enum_name##_e2str_names[i].value == table_key) {\
1773df3fe766SJames Smart name = fc_##enum_name##_e2str_names[i].name; \
1774df3fe766SJames Smart break; \
1775df3fe766SJames Smart } \
1776df3fe766SJames Smart } \
1777df3fe766SJames Smart return name; \
1778df3fe766SJames Smart }
177902169e84SGaurav Srivastava
178002169e84SGaurav Srivastava /**
178102169e84SGaurav Srivastava * lpfc_is_vmid_enabled - returns if VMID is enabled for either switch types
178202169e84SGaurav Srivastava * @phba: Pointer to HBA context object.
178302169e84SGaurav Srivastava *
178402169e84SGaurav Srivastava * Relationship between the enable, target support and if vmid tag is required
178502169e84SGaurav Srivastava * for the particular combination
178602169e84SGaurav Srivastava * ---------------------------------------------------
178702169e84SGaurav Srivastava * Switch Enable Flag Target Support VMID Needed
178802169e84SGaurav Srivastava * ---------------------------------------------------
178902169e84SGaurav Srivastava * App Id 0 NA N
179002169e84SGaurav Srivastava * App Id 1 0 N
179102169e84SGaurav Srivastava * App Id 1 1 Y
179202169e84SGaurav Srivastava * Pr Tag 0 NA N
179302169e84SGaurav Srivastava * Pr Tag 1 0 N
179402169e84SGaurav Srivastava * Pr Tag 1 1 Y
179502169e84SGaurav Srivastava * Pr Tag 2 * Y
179602169e84SGaurav Srivastava ---------------------------------------------------
179702169e84SGaurav Srivastava *
179802169e84SGaurav Srivastava **/
lpfc_is_vmid_enabled(struct lpfc_hba * phba)179902169e84SGaurav Srivastava static inline int lpfc_is_vmid_enabled(struct lpfc_hba *phba)
180002169e84SGaurav Srivastava {
180102169e84SGaurav Srivastava return phba->cfg_vmid_app_header || phba->cfg_vmid_priority_tagging;
180202169e84SGaurav Srivastava }
18031b64aa9eSJames Smart
18041b64aa9eSJames Smart static inline
get_job_ulpstatus(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18051b64aa9eSJames Smart u8 get_job_ulpstatus(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18061b64aa9eSJames Smart {
18071b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18081b64aa9eSJames Smart return bf_get(lpfc_wcqe_c_status, &iocbq->wcqe_cmpl);
18091b64aa9eSJames Smart else
18101b64aa9eSJames Smart return iocbq->iocb.ulpStatus;
18111b64aa9eSJames Smart }
18121b64aa9eSJames Smart
18131b64aa9eSJames Smart static inline
get_job_word4(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18141b64aa9eSJames Smart u32 get_job_word4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18151b64aa9eSJames Smart {
18161b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18171b64aa9eSJames Smart return iocbq->wcqe_cmpl.parameter;
18181b64aa9eSJames Smart else
18191b64aa9eSJames Smart return iocbq->iocb.un.ulpWord[4];
18201b64aa9eSJames Smart }
18211b64aa9eSJames Smart
18221b64aa9eSJames Smart static inline
get_job_cmnd(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18231b64aa9eSJames Smart u8 get_job_cmnd(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18241b64aa9eSJames Smart {
18251b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18261b64aa9eSJames Smart return bf_get(wqe_cmnd, &iocbq->wqe.generic.wqe_com);
18271b64aa9eSJames Smart else
18281b64aa9eSJames Smart return iocbq->iocb.ulpCommand;
18291b64aa9eSJames Smart }
18301b64aa9eSJames Smart
18311b64aa9eSJames Smart static inline
get_job_ulpcontext(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18321b64aa9eSJames Smart u16 get_job_ulpcontext(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18331b64aa9eSJames Smart {
18341b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18351b64aa9eSJames Smart return bf_get(wqe_ctxt_tag, &iocbq->wqe.generic.wqe_com);
18361b64aa9eSJames Smart else
18371b64aa9eSJames Smart return iocbq->iocb.ulpContext;
18381b64aa9eSJames Smart }
18396831ce12SJames Smart
18406831ce12SJames Smart static inline
get_job_rcvoxid(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)1841cad93a08SJames Smart u16 get_job_rcvoxid(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
1842cad93a08SJames Smart {
1843cad93a08SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
1844cad93a08SJames Smart return bf_get(wqe_rcvoxid, &iocbq->wqe.generic.wqe_com);
1845cad93a08SJames Smart else
1846cad93a08SJames Smart return iocbq->iocb.unsli3.rcvsli3.ox_id;
1847cad93a08SJames Smart }
1848cad93a08SJames Smart
1849cad93a08SJames Smart static inline
get_job_data_placed(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)185061910d6aSJames Smart u32 get_job_data_placed(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
185161910d6aSJames Smart {
185261910d6aSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
185361910d6aSJames Smart return iocbq->wcqe_cmpl.total_data_placed;
185461910d6aSJames Smart else
185561910d6aSJames Smart return iocbq->iocb.un.genreq64.bdl.bdeSize;
185661910d6aSJames Smart }
185761910d6aSJames Smart
185861910d6aSJames Smart static inline
get_job_abtsiotag(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)185931a59f75SJames Smart u32 get_job_abtsiotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
186031a59f75SJames Smart {
186131a59f75SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
186231a59f75SJames Smart return iocbq->wqe.abort_cmd.wqe_com.abort_tag;
186331a59f75SJames Smart else
186431a59f75SJames Smart return iocbq->iocb.un.acxri.abortIoTag;
186531a59f75SJames Smart }
186631a59f75SJames Smart
186731a59f75SJames Smart static inline
get_job_els_rsp64_did(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18686831ce12SJames Smart u32 get_job_els_rsp64_did(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18696831ce12SJames Smart {
18706831ce12SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18716831ce12SJames Smart return bf_get(wqe_els_did, &iocbq->wqe.els_req.wqe_dest);
18726831ce12SJames Smart else
18736831ce12SJames Smart return iocbq->iocb.un.elsreq64.remoteID;
18746831ce12SJames Smart }
1875