1dea3101eS /*******************************************************************
2dea3101eS * This file is part of the Emulex Linux Device Driver for *
3c44ce173SJames.Smart@Emulex.Com * Fibre Channel Host Bus Adapters. *
4ea4044e4SJustin Tee * Copyright (C) 2017-2024 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
36f5779b52SJustin 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
309*b5c18c9dSJustin Tee /* Data structure to keep withheld FLOGI_ACC information */
310*b5c18c9dSJustin Tee struct lpfc_defer_flogi_acc {
311*b5c18c9dSJustin Tee bool flag;
312*b5c18c9dSJustin Tee u16 rx_id;
313*b5c18c9dSJustin Tee u16 ox_id;
314*b5c18c9dSJustin Tee struct lpfc_nodelist *ndlp;
315*b5c18c9dSJustin Tee
316*b5c18c9dSJustin Tee };
31792d7f7b0SJames Smart
31802169e84SGaurav Srivastava #define LPFC_VMID_TIMER 300 /* timer interval in seconds */
31902169e84SGaurav Srivastava
32002169e84SGaurav Srivastava #define LPFC_MAX_VMID_SIZE 256
32102169e84SGaurav Srivastava
32202169e84SGaurav Srivastava union lpfc_vmid_io_tag {
32302169e84SGaurav Srivastava u32 app_id; /* App Id vmid */
32402169e84SGaurav Srivastava u8 cs_ctl_vmid; /* Priority tag vmid */
32502169e84SGaurav Srivastava };
32602169e84SGaurav Srivastava
32702169e84SGaurav Srivastava #define JIFFIES_PER_HR (HZ * 60 * 60)
32802169e84SGaurav Srivastava
32902169e84SGaurav Srivastava struct lpfc_vmid {
33002169e84SGaurav Srivastava u8 flag;
33102169e84SGaurav Srivastava #define LPFC_VMID_SLOT_FREE 0x0
33202169e84SGaurav Srivastava #define LPFC_VMID_SLOT_USED 0x1
33302169e84SGaurav Srivastava #define LPFC_VMID_REQ_REGISTER 0x2
33402169e84SGaurav Srivastava #define LPFC_VMID_REGISTERED 0x4
33502169e84SGaurav Srivastava #define LPFC_VMID_DE_REGISTER 0x8
33602169e84SGaurav Srivastava char host_vmid[LPFC_MAX_VMID_SIZE];
33702169e84SGaurav Srivastava union lpfc_vmid_io_tag un;
33802169e84SGaurav Srivastava struct hlist_node hnode;
33902169e84SGaurav Srivastava u64 io_rd_cnt;
34002169e84SGaurav Srivastava u64 io_wr_cnt;
34102169e84SGaurav Srivastava u8 vmid_len;
34202169e84SGaurav Srivastava u8 delete_inactive; /* Delete if inactive flag 0 = no, 1 = yes */
34302169e84SGaurav Srivastava u32 hash_index;
34402169e84SGaurav Srivastava u64 __percpu *last_io_time;
34502169e84SGaurav Srivastava };
34602169e84SGaurav Srivastava
34702169e84SGaurav Srivastava #define lpfc_vmid_is_type_priority_tag(vport)\
34802169e84SGaurav Srivastava (vport->vmid_priority_tagging ? 1 : 0)
34902169e84SGaurav Srivastava
35002169e84SGaurav Srivastava #define LPFC_VMID_HASH_SIZE 256
35102169e84SGaurav Srivastava #define LPFC_VMID_HASH_MASK 255
35202169e84SGaurav Srivastava #define LPFC_VMID_HASH_SHIFT 6
35302169e84SGaurav Srivastava
35402169e84SGaurav Srivastava struct lpfc_vmid_context {
35502169e84SGaurav Srivastava struct lpfc_vmid *vmp;
35602169e84SGaurav Srivastava struct lpfc_nodelist *nlp;
35702169e84SGaurav Srivastava bool instantiated;
35802169e84SGaurav Srivastava };
35902169e84SGaurav Srivastava
36002169e84SGaurav Srivastava struct lpfc_vmid_priority_range {
36102169e84SGaurav Srivastava u8 low;
36202169e84SGaurav Srivastava u8 high;
36302169e84SGaurav Srivastava u8 qos;
36402169e84SGaurav Srivastava };
36502169e84SGaurav Srivastava
36602169e84SGaurav Srivastava struct lpfc_vmid_priority_info {
36702169e84SGaurav Srivastava u32 num_descriptors;
36802169e84SGaurav Srivastava struct lpfc_vmid_priority_range *vmid_range;
36902169e84SGaurav Srivastava };
37002169e84SGaurav Srivastava
37102169e84SGaurav Srivastava #define QFPA_EVEN_ONLY 0x01
37202169e84SGaurav Srivastava #define QFPA_ODD_ONLY 0x02
37302169e84SGaurav Srivastava #define QFPA_EVEN_ODD 0x03
37402169e84SGaurav Srivastava
3752e0fef85SJames Smart enum discovery_state {
37692d7f7b0SJames Smart LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */
37792d7f7b0SJames Smart LPFC_VPORT_FAILED = 1, /* vport has failed */
3782e0fef85SJames Smart LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */
3792e0fef85SJames Smart LPFC_FLOGI = 7, /* FLOGI sent to Fabric */
38092d7f7b0SJames Smart LPFC_FDISC = 8, /* FDISC sent for vport */
38192d7f7b0SJames Smart LPFC_FABRIC_CFG_LINK = 9, /* Fabric assigned NPORT Id
3822e0fef85SJames Smart * configured */
38392d7f7b0SJames Smart LPFC_NS_REG = 10, /* Register with NameServer */
38492d7f7b0SJames Smart LPFC_NS_QRY = 11, /* Query NameServer for NPort ID list */
38592d7f7b0SJames Smart LPFC_BUILD_DISC_LIST = 12, /* Build ADISC and PLOGI lists for
386dea3101eS * device authentication / discovery */
38792d7f7b0SJames Smart LPFC_DISC_AUTH = 13, /* Processing ADISC list */
3882e0fef85SJames Smart LPFC_VPORT_READY = 32,
3892e0fef85SJames Smart };
390dea3101eS
3912e0fef85SJames Smart enum hba_state {
3922e0fef85SJames Smart LPFC_LINK_UNKNOWN = 0, /* HBA state is unknown */
3932e0fef85SJames Smart LPFC_WARM_START = 1, /* HBA state after selective reset */
3942e0fef85SJames Smart LPFC_INIT_START = 2, /* Initial state after board reset */
3952e0fef85SJames Smart LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */
3962e0fef85SJames Smart LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */
3972e0fef85SJames Smart LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */
39892d7f7b0SJames Smart LPFC_CLEAR_LA = 6, /* authentication cmplt - issue
3992e0fef85SJames Smart * CLEAR_LA */
40092d7f7b0SJames Smart LPFC_HBA_READY = 32,
4012e0fef85SJames Smart LPFC_HBA_ERROR = -1
4022e0fef85SJames Smart };
403dea3101eS
404e780c942SJustin Tee enum lpfc_hba_flag { /* hba generic flags */
405e780c942SJustin Tee HBA_ERATT_HANDLED = 0, /* This flag is set when eratt handled */
406e780c942SJustin Tee DEFER_ERATT = 1, /* Deferred error attn in progress */
407e780c942SJustin Tee HBA_FCOE_MODE = 2, /* HBA function in FCoE Mode */
408e780c942SJustin Tee HBA_SP_QUEUE_EVT = 3, /* Slow-path qevt posted to worker thread*/
409e780c942SJustin Tee HBA_POST_RECEIVE_BUFFER = 4, /* Rcv buffers need to be posted */
410e780c942SJustin Tee HBA_PERSISTENT_TOPO = 5, /* Persistent topology support in hba */
411e780c942SJustin Tee ELS_XRI_ABORT_EVENT = 6, /* ELS_XRI abort event was queued */
412e780c942SJustin Tee ASYNC_EVENT = 7,
413e780c942SJustin Tee LINK_DISABLED = 8, /* Link disabled by user */
414e780c942SJustin Tee FCF_TS_INPROG = 9, /* FCF table scan in progress */
415e780c942SJustin Tee FCF_RR_INPROG = 10, /* FCF roundrobin flogi in progress */
416e780c942SJustin Tee HBA_FIP_SUPPORT = 11, /* FIP support in HBA */
417e780c942SJustin Tee HBA_DEVLOSS_TMO = 13, /* HBA in devloss timeout */
418e780c942SJustin Tee HBA_RRQ_ACTIVE = 14, /* process the rrq active list */
419e780c942SJustin Tee HBA_IOQ_FLUSH = 15, /* I/O queues being flushed */
420e780c942SJustin Tee HBA_RECOVERABLE_UE = 17, /* FW supports recoverable UE */
421e780c942SJustin Tee HBA_FORCED_LINK_SPEED = 18, /*
422e780c942SJustin Tee * Firmware supports Forced Link
423e780c942SJustin Tee * Speed capability
424e780c942SJustin Tee */
425e780c942SJustin Tee HBA_FLOGI_ISSUED = 20, /* FLOGI was issued */
426e780c942SJustin Tee HBA_DEFER_FLOGI = 23, /* Defer FLOGI till read_sparm cmpl */
427e780c942SJustin Tee HBA_SETUP = 24, /* HBA setup completed */
428e780c942SJustin Tee HBA_NEEDS_CFG_PORT = 25, /* SLI3: CONFIG_PORT mbox needed */
429e780c942SJustin Tee HBA_HBEAT_INP = 26, /* mbox HBEAT is in progress */
430e780c942SJustin Tee HBA_HBEAT_TMO = 27, /* HBEAT initiated after timeout */
431e780c942SJustin Tee HBA_FLOGI_OUTSTANDING = 28, /* FLOGI is outstanding */
432e780c942SJustin Tee HBA_RHBA_CMPL = 29, /* RHBA FDMI cmd is successful */
433e780c942SJustin Tee };
434e780c942SJustin Tee
4351dc5ec24SJames Smart struct lpfc_trunk_link_state {
4361dc5ec24SJames Smart enum hba_state state;
4371dc5ec24SJames Smart uint8_t fault;
4381dc5ec24SJames Smart };
4391dc5ec24SJames Smart
4401dc5ec24SJames Smart struct lpfc_trunk_link {
4411dc5ec24SJames Smart struct lpfc_trunk_link_state link0,
4421dc5ec24SJames Smart link1,
4431dc5ec24SJames Smart link2,
4441dc5ec24SJames Smart link3;
445dbb1e2ffSJames Smart u32 phy_lnk_speed;
4461dc5ec24SJames Smart };
4471dc5ec24SJames Smart
44872df8a45SJames Smart /* Format of congestion module parameters */
44972df8a45SJames Smart struct lpfc_cgn_param {
45072df8a45SJames Smart uint32_t cgn_param_magic;
45172df8a45SJames Smart uint8_t cgn_param_version; /* version 1 */
45272df8a45SJames Smart uint8_t cgn_param_mode; /* 0=off 1=managed 2=monitor only */
45372df8a45SJames Smart #define LPFC_CFG_OFF 0
45472df8a45SJames Smart #define LPFC_CFG_MANAGED 1
45572df8a45SJames Smart #define LPFC_CFG_MONITOR 2
45672df8a45SJames Smart uint8_t cgn_rsvd1;
45772df8a45SJames Smart uint8_t cgn_rsvd2;
45872df8a45SJames Smart uint8_t cgn_param_level0;
45972df8a45SJames Smart uint8_t cgn_param_level1;
46072df8a45SJames Smart uint8_t cgn_param_level2;
46172df8a45SJames Smart uint8_t byte11;
46272df8a45SJames Smart uint8_t byte12;
46372df8a45SJames Smart uint8_t byte13;
46472df8a45SJames Smart uint8_t byte14;
46572df8a45SJames Smart uint8_t byte15;
46672df8a45SJames Smart };
46772df8a45SJames Smart
4688c42a65cSJames Smart /* Max number of days of congestion data */
4698c42a65cSJames Smart #define LPFC_MAX_CGN_DAYS 10
4708c42a65cSJames Smart
47193190ac1SJustin Tee struct lpfc_cgn_ts {
47293190ac1SJustin Tee uint8_t month;
47393190ac1SJustin Tee uint8_t day;
47493190ac1SJustin Tee uint8_t year;
47593190ac1SJustin Tee uint8_t hour;
47693190ac1SJustin Tee uint8_t minute;
47793190ac1SJustin Tee uint8_t second;
47893190ac1SJustin Tee };
47993190ac1SJustin Tee
4808c42a65cSJames Smart /* Format of congestion buffer info
4818c42a65cSJames Smart * This structure defines memory thats allocated and registered with
4828c42a65cSJames Smart * the HBA firmware. When adding or removing fields from this structure
4838c42a65cSJames Smart * the alignment must match the HBA firmware.
4848c42a65cSJames Smart */
4858c42a65cSJames Smart
4868c42a65cSJames Smart struct lpfc_cgn_info {
4878c42a65cSJames Smart /* Header */
4888c42a65cSJames Smart __le16 cgn_info_size; /* is sizeof(struct lpfc_cgn_info) */
4898c42a65cSJames Smart uint8_t cgn_info_version; /* represents format of structure */
4908c42a65cSJames Smart #define LPFC_CGN_INFO_V1 1
4918c42a65cSJames Smart #define LPFC_CGN_INFO_V2 2
4928c42a65cSJames Smart #define LPFC_CGN_INFO_V3 3
49393190ac1SJustin Tee #define LPFC_CGN_INFO_V4 4
4948c42a65cSJames Smart uint8_t cgn_info_mode; /* 0=off 1=managed 2=monitor only */
4958c42a65cSJames Smart uint8_t cgn_info_detect;
4968c42a65cSJames Smart uint8_t cgn_info_action;
4978c42a65cSJames Smart uint8_t cgn_info_level0;
4988c42a65cSJames Smart uint8_t cgn_info_level1;
4998c42a65cSJames Smart uint8_t cgn_info_level2;
5008c42a65cSJames Smart
5018c42a65cSJames Smart /* Start Time */
50293190ac1SJustin Tee struct lpfc_cgn_ts base_time;
5038c42a65cSJames Smart
5048c42a65cSJames Smart /* minute / hours / daily indices */
5058c42a65cSJames Smart uint8_t cgn_index_minute;
5068c42a65cSJames Smart uint8_t cgn_index_hour;
5078c42a65cSJames Smart uint8_t cgn_index_day;
5088c42a65cSJames Smart
5098c42a65cSJames Smart __le16 cgn_warn_freq;
5108c42a65cSJames Smart __le16 cgn_alarm_freq;
5118c42a65cSJames Smart __le16 cgn_lunq;
5128c42a65cSJames Smart uint8_t cgn_pad1[8];
5138c42a65cSJames Smart
5148c42a65cSJames Smart /* Driver Information */
5158c42a65cSJames Smart __le16 cgn_drvr_min[60];
5168c42a65cSJames Smart __le32 cgn_drvr_hr[24];
5178c42a65cSJames Smart __le32 cgn_drvr_day[LPFC_MAX_CGN_DAYS];
5188c42a65cSJames Smart
5198c42a65cSJames Smart /* Congestion Warnings */
5208c42a65cSJames Smart __le16 cgn_warn_min[60];
5218c42a65cSJames Smart __le32 cgn_warn_hr[24];
5228c42a65cSJames Smart __le32 cgn_warn_day[LPFC_MAX_CGN_DAYS];
5238c42a65cSJames Smart
5248c42a65cSJames Smart /* Latency Information */
5258c42a65cSJames Smart __le32 cgn_latency_min[60];
5268c42a65cSJames Smart __le32 cgn_latency_hr[24];
5278c42a65cSJames Smart __le32 cgn_latency_day[LPFC_MAX_CGN_DAYS];
5288c42a65cSJames Smart
5298c42a65cSJames Smart /* Bandwidth Information */
5308c42a65cSJames Smart __le16 cgn_bw_min[60];
5318c42a65cSJames Smart __le16 cgn_bw_hr[24];
5328c42a65cSJames Smart __le16 cgn_bw_day[LPFC_MAX_CGN_DAYS];
5338c42a65cSJames Smart
5348c42a65cSJames Smart /* Congestion Alarms */
5358c42a65cSJames Smart __le16 cgn_alarm_min[60];
5368c42a65cSJames Smart __le32 cgn_alarm_hr[24];
5378c42a65cSJames Smart __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS];
5388c42a65cSJames Smart
539532adda9SKees Cook struct_group(cgn_stat,
5408c42a65cSJames Smart uint8_t cgn_stat_npm; /* Notifications per minute */
5418c42a65cSJames Smart
5428c42a65cSJames Smart /* Start Time */
54393190ac1SJustin Tee struct lpfc_cgn_ts stat_start; /* Base time */
54493190ac1SJustin Tee uint8_t cgn_pad2;
5458c42a65cSJames Smart
5468c42a65cSJames Smart __le32 cgn_notification;
5478c42a65cSJames Smart __le32 cgn_peer_notification;
5488c42a65cSJames Smart __le32 link_integ_notification;
5498c42a65cSJames Smart __le32 delivery_notification;
55093190ac1SJustin Tee struct lpfc_cgn_ts stat_fpin; /* Last congestion notification FPIN */
55193190ac1SJustin Tee struct lpfc_cgn_ts stat_peer; /* Last peer congestion FPIN */
55293190ac1SJustin Tee struct lpfc_cgn_ts stat_lnk; /* Last link integrity FPIN */
55393190ac1SJustin Tee struct lpfc_cgn_ts stat_delivery; /* Last delivery notification FPIN */
554532adda9SKees Cook );
5558c42a65cSJames Smart
5568c42a65cSJames Smart __le32 cgn_info_crc;
5578c42a65cSJames Smart #define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
5588c42a65cSJames Smart #define LPFC_CGN_CRC32_SEED 0xFFFFFFFF
5598c42a65cSJames Smart };
5608c42a65cSJames Smart
5618c42a65cSJames Smart #define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \
5628c42a65cSJames Smart sizeof(uint32_t))
5638c42a65cSJames Smart
56402243836SJames Smart struct lpfc_cgn_stat {
56502243836SJames Smart atomic64_t total_bytes;
56602243836SJames Smart atomic64_t rcv_bytes;
56702243836SJames Smart atomic64_t rx_latency;
56802243836SJames Smart #define LPFC_CGN_NOT_SENT 0xFFFFFFFFFFFFFFFFLL
56902243836SJames Smart atomic_t rx_io_cnt;
57002243836SJames Smart };
57102243836SJames Smart
5729064aeb2SJames Smart struct lpfc_cgn_acqe_stat {
5739064aeb2SJames Smart atomic64_t alarm;
5749064aeb2SJames Smart atomic64_t warn;
5759064aeb2SJames Smart };
5769064aeb2SJames Smart
577a645b8c1SJustin Tee enum lpfc_fc_flag {
578a645b8c1SJustin Tee /* Several of these flags are HBA centric and should be moved to
579a645b8c1SJustin Tee * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
580a645b8c1SJustin Tee */
581a645b8c1SJustin Tee FC_PT2PT, /* pt2pt with no fabric */
582a645b8c1SJustin Tee FC_PT2PT_PLOGI, /* pt2pt initiate PLOGI */
583a645b8c1SJustin Tee FC_DISC_TMO, /* Discovery timer running */
584a645b8c1SJustin Tee FC_PUBLIC_LOOP, /* Public loop */
585a645b8c1SJustin Tee FC_LBIT, /* LOGIN bit in loopinit set */
586a645b8c1SJustin Tee FC_RSCN_MODE, /* RSCN cmd rcv'ed */
587a645b8c1SJustin Tee FC_NLP_MORE, /* More node to process in node tbl */
588a645b8c1SJustin Tee FC_OFFLINE_MODE, /* Interface is offline for diag */
589a645b8c1SJustin Tee FC_FABRIC, /* We are fabric attached */
590a645b8c1SJustin Tee FC_VPORT_LOGO_RCVD, /* LOGO received on vport */
591a645b8c1SJustin Tee FC_RSCN_DISCOVERY, /* Auth all devices after RSCN */
592a645b8c1SJustin Tee FC_LOGO_RCVD_DID_CHNG, /* FDISC on phys port detect DID chng */
593a645b8c1SJustin Tee FC_PT2PT_NO_NVME, /* Don't send NVME PRLI */
594a645b8c1SJustin Tee FC_SCSI_SCAN_TMO, /* scsi scan timer running */
595a645b8c1SJustin Tee FC_ABORT_DISCOVERY, /* we want to abort discovery */
596a645b8c1SJustin Tee FC_NDISC_ACTIVE, /* NPort discovery active */
597a645b8c1SJustin Tee FC_BYPASSED_MODE, /* NPort is in bypassed mode */
598a645b8c1SJustin Tee FC_VPORT_NEEDS_REG_VPI, /* Needs to have its vpi registered */
599a645b8c1SJustin Tee FC_RSCN_DEFERRED, /* A deferred RSCN being processed */
600a645b8c1SJustin Tee FC_VPORT_NEEDS_INIT_VPI, /* Need to INIT_VPI before FDISC */
601a645b8c1SJustin Tee FC_VPORT_CVL_RCVD, /* VLink failed due to CVL */
602a645b8c1SJustin Tee FC_VFI_REGISTERED, /* VFI is registered */
603a645b8c1SJustin Tee FC_FDISC_COMPLETED, /* FDISC completed */
604a645b8c1SJustin Tee FC_DISC_DELAYED, /* Delay NPort discovery */
605a645b8c1SJustin Tee };
606a645b8c1SJustin Tee
607e39811beSJustin Tee enum lpfc_load_flag {
608e39811beSJustin Tee FC_LOADING, /* HBA in process of loading drvr */
609e39811beSJustin Tee FC_UNLOADING, /* HBA in process of unloading drvr */
610e39811beSJustin Tee FC_ALLOW_FDMI, /* port is ready for FDMI requests */
611e39811beSJustin Tee FC_ALLOW_VMID, /* Allow VMID I/Os */
612e39811beSJustin Tee FC_DEREGISTER_ALL_APP_ID /* Deregister all VMIDs */
613e39811beSJustin Tee };
614e39811beSJustin Tee
6152e0fef85SJames Smart struct lpfc_vport {
6162e0fef85SJames Smart struct lpfc_hba *phba;
6173772a991SJames Smart struct list_head listentry;
6182e0fef85SJames Smart uint8_t port_type;
6192e0fef85SJames Smart #define LPFC_PHYSICAL_PORT 1
6202e0fef85SJames Smart #define LPFC_NPIV_PORT 2
6212e0fef85SJames Smart #define LPFC_FABRIC_PORT 3
6222e0fef85SJames Smart enum discovery_state port_state;
623dea3101eS
62492d7f7b0SJames Smart uint16_t vpi;
625da0436e9SJames Smart uint16_t vfi;
626c868595dSJames Smart uint8_t vpi_state;
627c868595dSJames Smart #define LPFC_VPI_REGISTERED 0x1
628dea3101eS
629a645b8c1SJustin Tee unsigned long fc_flag; /* FC flags */
630dea3101eS
6317ee5d43eSJames Smart uint32_t ct_flags;
6327ee5d43eSJames Smart #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
6337ee5d43eSJames Smart #define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
6347ee5d43eSJames Smart #define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
6357ee5d43eSJames Smart #define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
6367ee5d43eSJames Smart #define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
637de3ec318SJames Smart #define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */
6387ee5d43eSJames Smart
639685f0bf7SJames Smart struct list_head fc_nodes;
6409bb36777SJustin Tee spinlock_t fc_nodes_list_lock; /* spinlock for fc_nodes list */
641dea3101eS
642dea3101eS /* Keep counters for the number of entries in each list. */
6430dfd9cbcSJustin Tee atomic_t fc_plogi_cnt;
6440dfd9cbcSJustin Tee atomic_t fc_adisc_cnt;
6450dfd9cbcSJustin Tee atomic_t fc_reglogin_cnt;
6460dfd9cbcSJustin Tee atomic_t fc_prli_cnt;
6470dfd9cbcSJustin Tee atomic_t fc_unmap_cnt;
6480dfd9cbcSJustin Tee atomic_t fc_map_cnt;
6490dfd9cbcSJustin Tee atomic_t fc_npr_cnt;
6500dfd9cbcSJustin Tee atomic_t fc_unused_cnt;
6510dfd9cbcSJustin Tee
6522e0fef85SJames Smart struct serv_parm fc_sparam; /* buffer for our service parameters */
6532e0fef85SJames Smart
6542e0fef85SJames Smart uint32_t fc_myDID; /* fibre channel S_ID */
6552e0fef85SJames Smart uint32_t fc_prevDID; /* previous fibre channel S_ID */
65692494144SJames Smart struct lpfc_name fabric_portname;
65792494144SJames Smart struct lpfc_name fabric_nodename;
6582e0fef85SJames Smart
6592e0fef85SJames Smart int32_t stopped; /* HBA has not been restarted since last ERATT */
6602e0fef85SJames Smart uint8_t fc_linkspeed; /* Link speed after last READ_LA */
6612e0fef85SJames Smart
6622e0fef85SJames Smart uint32_t num_disc_nodes; /* in addition to hba_state */
663a0f2d3efSJames Smart uint32_t gidft_inp; /* cnt of outstanding GID_FTs */
6642e0fef85SJames Smart
6652e0fef85SJames Smart uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */
6662e0fef85SJames Smart uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */
6677f5f3d0dSJames Smart uint32_t fc_rscn_flush; /* flag use of fc_rscn_id_list */
6682e0fef85SJames Smart struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN];
6692e0fef85SJames Smart struct lpfc_name fc_nodename; /* fc nodename */
6702e0fef85SJames Smart struct lpfc_name fc_portname; /* fc portname */
6712e0fef85SJames Smart
6722e0fef85SJames Smart struct lpfc_work_evt disc_timeout_evt;
6732e0fef85SJames Smart
6742e0fef85SJames Smart struct timer_list fc_disctmo; /* Discovery rescue timer */
6752e0fef85SJames Smart uint8_t fc_ns_retry; /* retries for fabric nameserver */
6762e0fef85SJames Smart uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */
6772e0fef85SJames Smart
6782e0fef85SJames Smart spinlock_t work_port_lock;
6792e0fef85SJames Smart uint32_t work_port_events; /* Timeout to be handled */
680858c9f6cSJames Smart #define WORKER_DISC_TMO 0x1 /* vport: Discovery timeout */
681858c9f6cSJames Smart #define WORKER_ELS_TMO 0x2 /* vport: ELS timeout */
68292494144SJames Smart #define WORKER_DELAYED_DISC_TMO 0x8 /* vport: delayed discovery */
683858c9f6cSJames Smart
684858c9f6cSJames Smart #define WORKER_MBOX_TMO 0x100 /* hba: MBOX timeout */
685858c9f6cSJames Smart #define WORKER_HB_TMO 0x200 /* hba: Heart beat timeout */
686b1c11812SJoe Perches #define WORKER_FABRIC_BLOCK_TMO 0x400 /* hba: fabric block timeout */
687858c9f6cSJames Smart #define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */
688858c9f6cSJames Smart #define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */
6892a9bf3d0SJames Smart #define WORKER_SERVICE_TXQ 0x2000 /* hba: IOCBs on the txq */
69002169e84SGaurav Srivastava #define WORKER_CHECK_INACTIVE_VMID 0x4000 /* hba: check inactive vmids */
69102169e84SGaurav Srivastava #define WORKER_CHECK_VMID_ISSUE_QFPA 0x8000 /* vport: Check if qfpa needs
69202169e84SGaurav Srivastava * to be issued */
6932e0fef85SJames Smart
6942e0fef85SJames Smart struct timer_list els_tmofunc;
69592494144SJames Smart struct timer_list delayed_disc_tmo;
6962e0fef85SJames Smart
697e39811beSJustin Tee unsigned long load_flag;
6983de2a653SJames Smart /* Vport Config Parameters */
6993de2a653SJames Smart uint32_t cfg_scan_down;
7003de2a653SJames Smart uint32_t cfg_lun_queue_depth;
7013de2a653SJames Smart uint32_t cfg_nodev_tmo;
7023de2a653SJames Smart uint32_t cfg_devloss_tmo;
7033de2a653SJames Smart uint32_t cfg_restrict_login;
7043de2a653SJames Smart uint32_t cfg_peer_port_login;
7053de2a653SJames Smart uint32_t cfg_fcp_class;
7063de2a653SJames Smart uint32_t cfg_use_adisc;
7073de2a653SJames Smart uint32_t cfg_discovery_threads;
708e8b62011SJames Smart uint32_t cfg_log_verbose;
709f6e84790SJames Smart uint32_t cfg_enable_fc4_type;
7103de2a653SJames Smart uint32_t cfg_max_luns;
7117ee5d43eSJames Smart uint32_t cfg_enable_da_id;
712977b5a0aSJames Smart uint32_t cfg_max_scsicmpl_time;
7137dc517dfSJames Smart uint32_t cfg_tgt_queue_depth;
7143cb01c57SJames Smart uint32_t cfg_first_burst_size;
7153de2a653SJames Smart uint32_t dev_loss_tmo_changed;
71602169e84SGaurav Srivastava /* VMID parameters */
71719d7102aSAndy Shevchenko u8 lpfc_vmid_host_uuid[16];
71802169e84SGaurav Srivastava u32 max_vmid; /* maximum VMIDs allowed per port */
71902169e84SGaurav Srivastava u32 cur_vmid_cnt; /* Current VMID count */
72002169e84SGaurav Srivastava #define LPFC_MIN_VMID 4
72102169e84SGaurav Srivastava #define LPFC_MAX_VMID 255
72202169e84SGaurav Srivastava u32 vmid_inactivity_timeout; /* Time after which the VMID */
72302169e84SGaurav Srivastava /* deregisters from switch */
72402169e84SGaurav Srivastava u32 vmid_priority_tagging;
72502169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_DISABLE 0 /* Disable */
72602169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_SUP_TARGETS 1 /* Allow supported targets only */
72702169e84SGaurav Srivastava #define LPFC_VMID_PRIO_TAG_ALL_TARGETS 2 /* Allow all targets */
72802169e84SGaurav Srivastava unsigned long *vmid_priority_range;
72902169e84SGaurav Srivastava #define LPFC_VMID_MAX_PRIORITY_RANGE 256
73002169e84SGaurav Srivastava #define LPFC_VMID_PRIORITY_BITMAP_SIZE 32
73102169e84SGaurav Srivastava u8 vmid_flag;
73202169e84SGaurav Srivastava #define LPFC_VMID_IN_USE 0x1
73302169e84SGaurav Srivastava #define LPFC_VMID_ISSUE_QFPA 0x2
73402169e84SGaurav Srivastava #define LPFC_VMID_QFPA_CMPL 0x4
73502169e84SGaurav Srivastava #define LPFC_VMID_QOS_ENABLED 0x8
73602169e84SGaurav Srivastava #define LPFC_VMID_TIMER_ENBLD 0x10
7375099478eSJames Smart #define LPFC_VMID_TYPE_PRIO 0x20
73802169e84SGaurav Srivastava struct fc_qfpa_res *qfpa_res;
73951ef4c26SJames Smart
74051ef4c26SJames Smart struct fc_vport *fc_vport;
74151ef4c26SJames Smart
74202169e84SGaurav Srivastava struct lpfc_vmid *vmid;
74302169e84SGaurav Srivastava DECLARE_HASHTABLE(hash_table, 8);
74402169e84SGaurav Srivastava rwlock_t vmid_lock;
74502169e84SGaurav Srivastava struct lpfc_vmid_priority_info vmid_priority;
74602169e84SGaurav Srivastava
747923e4b6aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
74851ef4c26SJames Smart struct dentry *debug_disc_trc;
74951ef4c26SJames Smart struct dentry *debug_nodelist;
750bd2cdd5eSJames Smart struct dentry *debug_nvmestat;
7514c47efc1SJames Smart struct dentry *debug_scsistat;
7522fcbc569SJames Smart struct dentry *debug_ioktime;
753840eda96SJames Smart struct dentry *debug_hdwqstat;
75451ef4c26SJames Smart struct dentry *vport_debugfs_root;
75551ef4c26SJames Smart struct lpfc_debugfs_trc *disc_trc;
75651ef4c26SJames Smart atomic_t disc_trc_cnt;
75751ef4c26SJames Smart #endif
758da0436e9SJames Smart struct list_head rcv_buffer_list;
75945ed1190SJames Smart unsigned long rcv_buffer_time_stamp;
760da0436e9SJames Smart uint32_t vport_flag;
7611b6f71f7SJames Smart #define STATIC_VPORT 0x1
7621b6f71f7SJames Smart #define FAWWPN_PARAM_CHG 0x2
7634258e98eSJames Smart
7644258e98eSJames Smart uint16_t fdmi_num_disc;
7654258e98eSJames Smart uint32_t fdmi_hba_mask;
7664258e98eSJames Smart uint32_t fdmi_port_mask;
767895427bdSJames Smart
768895427bdSJames Smart /* There is a single nvme instance per vport. */
769895427bdSJames Smart struct nvme_fc_local_port *localport;
770895427bdSJames Smart uint8_t nvmei_support; /* driver supports NVME Initiator */
771895427bdSJames Smart uint32_t last_fcp_wqidx;
772d496b9a7SJames Smart uint32_t rcv_flogi_cnt; /* How many unsol FLOGIs ACK'd. */
7732e0fef85SJames Smart };
7742e0fef85SJames Smart
775ed957684SJames Smart struct hbq_s {
776ed957684SJames Smart uint16_t entry_count; /* Current number of HBQ slots */
777a8adb832SJames Smart uint16_t buffer_count; /* Current number of buffers posted */
778ed957684SJames Smart uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
779ed957684SJames Smart uint32_t hbqPutIdx; /* HBQ slot to use */
780ed957684SJames Smart uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
78151ef4c26SJames Smart void *hbq_virt; /* Virtual ptr to this hbq */
78251ef4c26SJames Smart struct list_head hbq_buffer_list; /* buffers assigned to this HBQ */
78351ef4c26SJames Smart /* Callback for HBQ buffer allocation */
78451ef4c26SJames Smart struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *);
78551ef4c26SJames Smart /* Callback for HBQ buffer free */
78651ef4c26SJames Smart void (*hbq_free_buffer) (struct lpfc_hba *,
78751ef4c26SJames Smart struct hbq_dmabuf *);
788ed957684SJames Smart };
789ed957684SJames Smart
79051ef4c26SJames Smart /* this matches the position in the lpfc_hbq_defs array */
79192d7f7b0SJames Smart #define LPFC_ELS_HBQ 0
792895427bdSJames Smart #define LPFC_MAX_HBQS 1
793ed957684SJames Smart
7947af67051SJames Smart enum hba_temp_state {
7957af67051SJames Smart HBA_NORMAL_TEMP,
7967af67051SJames Smart HBA_OVER_TEMP
7977af67051SJames Smart };
7987af67051SJames Smart
799db2378e0SJames Smart enum intr_type_t {
800db2378e0SJames Smart NONE = 0,
801db2378e0SJames Smart INTx,
802db2378e0SJames Smart MSI,
803db2378e0SJames Smart MSIX,
804db2378e0SJames Smart };
805db2378e0SJames Smart
8066dd9e31cSJames Smart #define LPFC_CT_CTX_MAX 64
807f1c3b0fcSJames Smart struct unsol_rcv_ct_ctx {
808f1c3b0fcSJames Smart uint32_t ctxt_id;
809f1c3b0fcSJames Smart uint32_t SID;
8106dd9e31cSJames Smart uint32_t valid;
8116dd9e31cSJames Smart #define UNSOL_INVALID 0
8126dd9e31cSJames Smart #define UNSOL_VALID 1
8137851fe2cSJames Smart uint16_t oxid;
8147851fe2cSJames Smart uint16_t rxid;
815f1c3b0fcSJames Smart };
816f1c3b0fcSJames Smart
81776a95d75SJames Smart #define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
81876a95d75SJames Smart #define LPFC_USER_LINK_SPEED_1G 1 /* 1 Gigabaud */
81976a95d75SJames Smart #define LPFC_USER_LINK_SPEED_2G 2 /* 2 Gigabaud */
82076a95d75SJames Smart #define LPFC_USER_LINK_SPEED_4G 4 /* 4 Gigabaud */
82176a95d75SJames Smart #define LPFC_USER_LINK_SPEED_8G 8 /* 8 Gigabaud */
82276a95d75SJames Smart #define LPFC_USER_LINK_SPEED_10G 10 /* 10 Gigabaud */
82376a95d75SJames Smart #define LPFC_USER_LINK_SPEED_16G 16 /* 16 Gigabaud */
824d38dd52cSJames Smart #define LPFC_USER_LINK_SPEED_32G 32 /* 32 Gigabaud */
825fbd8a6baSJames Smart #define LPFC_USER_LINK_SPEED_64G 64 /* 64 Gigabaud */
826fbd8a6baSJames Smart #define LPFC_USER_LINK_SPEED_MAX LPFC_USER_LINK_SPEED_64G
827fbd8a6baSJames Smart
828fbd8a6baSJames Smart #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
82976a95d75SJames Smart
8307ad20aa9SJames Smart enum nemb_type {
8317ad20aa9SJames Smart nemb_mse = 1,
8327ad20aa9SJames Smart nemb_hbd
8337ad20aa9SJames Smart };
8347ad20aa9SJames Smart
8357ad20aa9SJames Smart enum mbox_type {
8367ad20aa9SJames Smart mbox_rd = 1,
8377ad20aa9SJames Smart mbox_wr
8387ad20aa9SJames Smart };
8397ad20aa9SJames Smart
8407ad20aa9SJames Smart enum dma_type {
8417ad20aa9SJames Smart dma_mbox = 1,
8427ad20aa9SJames Smart dma_ebuf
8437ad20aa9SJames Smart };
8447ad20aa9SJames Smart
8457ad20aa9SJames Smart enum sta_type {
8467ad20aa9SJames Smart sta_pre_addr = 1,
8477ad20aa9SJames Smart sta_pos_addr
8487ad20aa9SJames Smart };
8497ad20aa9SJames Smart
8507ad20aa9SJames Smart struct lpfc_mbox_ext_buf_ctx {
8517ad20aa9SJames Smart uint32_t state;
8527ad20aa9SJames Smart #define LPFC_BSG_MBOX_IDLE 0
8537ad20aa9SJames Smart #define LPFC_BSG_MBOX_HOST 1
8547ad20aa9SJames Smart #define LPFC_BSG_MBOX_PORT 2
8557ad20aa9SJames Smart #define LPFC_BSG_MBOX_DONE 3
8567ad20aa9SJames Smart #define LPFC_BSG_MBOX_ABTS 4
8577ad20aa9SJames Smart enum nemb_type nembType;
8587ad20aa9SJames Smart enum mbox_type mboxType;
8597ad20aa9SJames Smart uint32_t numBuf;
8607ad20aa9SJames Smart uint32_t mbxTag;
8617ad20aa9SJames Smart uint32_t seqNum;
8627ad20aa9SJames Smart struct lpfc_dmabuf *mbx_dmabuf;
8637ad20aa9SJames Smart struct list_head ext_dmabuf_list;
8647ad20aa9SJames Smart };
8657ad20aa9SJames Smart
866c490850aSJames Smart struct lpfc_epd_pool {
867c490850aSJames Smart /* Expedite pool */
868c490850aSJames Smart struct list_head list;
869c490850aSJames Smart u32 count;
870c490850aSJames Smart spinlock_t lock; /* lock for expedite pool */
871c490850aSJames Smart };
872c490850aSJames Smart
87395bfc6d8SJames Smart enum ras_state {
87495bfc6d8SJames Smart INACTIVE,
87595bfc6d8SJames Smart REG_INPROGRESS,
87695bfc6d8SJames Smart ACTIVE
87795bfc6d8SJames Smart };
87895bfc6d8SJames Smart
879d2cc9bcdSJames Smart struct lpfc_ras_fwlog {
880d2cc9bcdSJames Smart uint8_t *fwlog_buff;
881d2cc9bcdSJames Smart uint32_t fw_buffcount; /* Buffer size posted to FW */
882d2cc9bcdSJames Smart #define LPFC_RAS_BUFF_ENTERIES 16 /* Each entry can hold max of 64k */
883d2cc9bcdSJames Smart #define LPFC_RAS_MAX_ENTRY_SIZE (64 * 1024)
884d2cc9bcdSJames Smart #define LPFC_RAS_MIN_BUFF_POST_SIZE (256 * 1024)
885d2cc9bcdSJames Smart #define LPFC_RAS_MAX_BUFF_POST_SIZE (1024 * 1024)
886d2cc9bcdSJames Smart uint32_t fw_loglevel; /* Log level set */
887d2cc9bcdSJames Smart struct lpfc_dmabuf lwpd;
888d2cc9bcdSJames Smart struct list_head fwlog_buff_list;
889d2cc9bcdSJames Smart
890d2cc9bcdSJames Smart /* RAS support status on adapter */
891d2cc9bcdSJames Smart bool ras_hwsupport; /* RAS Support available on HW or not */
892d2cc9bcdSJames Smart bool ras_enabled; /* Ras Enabled for the function */
893d2cc9bcdSJames Smart #define LPFC_RAS_DISABLE_LOGGING 0x00
894d2cc9bcdSJames Smart #define LPFC_RAS_ENABLE_LOGGING 0x01
89595bfc6d8SJames Smart enum ras_state state; /* RAS logging running state */
896d2cc9bcdSJames Smart };
897d2cc9bcdSJames Smart
898372c187bSDick Kennedy #define DBG_LOG_STR_SZ 256
899372c187bSDick Kennedy #define DBG_LOG_SZ 256
900372c187bSDick Kennedy
901372c187bSDick Kennedy struct dbg_log_ent {
902372c187bSDick Kennedy char log[DBG_LOG_STR_SZ];
903372c187bSDick Kennedy u64 t_ns;
904372c187bSDick Kennedy };
905372c187bSDick Kennedy
9063048e3e8SDick Kennedy enum lpfc_irq_chann_mode {
9073048e3e8SDick Kennedy /* Assign IRQs to all possible cpus that have hardware queues */
9083048e3e8SDick Kennedy NORMAL_MODE,
9093048e3e8SDick Kennedy
9103048e3e8SDick Kennedy /* Assign IRQs only to cpus on the same numa node as HBA */
9113048e3e8SDick Kennedy NUMA_MODE,
9123048e3e8SDick Kennedy
9133048e3e8SDick Kennedy /* Assign IRQs only on non-hyperthreaded CPUs. This is the
9143048e3e8SDick Kennedy * same as normal_mode, but assign IRQS only on physical CPUs.
9153048e3e8SDick Kennedy */
9163048e3e8SDick Kennedy NHT_MODE,
9173048e3e8SDick Kennedy };
9183048e3e8SDick Kennedy
91935ed9613SJames Smart enum lpfc_hba_bit_flags {
92035ed9613SJames Smart FABRIC_COMANDS_BLOCKED,
92135ed9613SJames Smart HBA_PCI_ERR,
922089ea22eSJustin Tee MBX_TMO_ERR,
92335ed9613SJames Smart };
92435ed9613SJames Smart
9252e0fef85SJames Smart struct lpfc_hba {
9263772a991SJames Smart /* SCSI interface function jump table entries */
927c490850aSJames Smart struct lpfc_io_buf * (*lpfc_get_scsi_buf)
928ace44e48SJames Smart (struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
929ace44e48SJames Smart struct scsi_cmnd *cmnd);
9303772a991SJames Smart int (*lpfc_scsi_prep_dma_buf)
931c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
9323772a991SJames Smart void (*lpfc_scsi_unprep_dma_buf)
933c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
9343772a991SJames Smart void (*lpfc_release_scsi_buf)
935c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
9363772a991SJames Smart void (*lpfc_rampdown_queue_depth)
9373772a991SJames Smart (struct lpfc_hba *);
9383772a991SJames Smart void (*lpfc_scsi_prep_cmnd)
939c490850aSJames Smart (struct lpfc_vport *, struct lpfc_io_buf *,
9403772a991SJames Smart struct lpfc_nodelist *);
941da255e2eSJames Smart int (*lpfc_scsi_prep_cmnd_buf)
942da255e2eSJames Smart (struct lpfc_vport *vport,
943da255e2eSJames Smart struct lpfc_io_buf *lpfc_cmd,
944da255e2eSJames Smart uint8_t tmo);
9453512ac09SJames Smart int (*lpfc_scsi_prep_task_mgmt_cmd)
9463512ac09SJames Smart (struct lpfc_vport *vport,
9473512ac09SJames Smart struct lpfc_io_buf *lpfc_cmd,
9483512ac09SJames Smart u64 lun, u8 task_mgmt_cmd);
949acd6859bSJames Smart
9503772a991SJames Smart /* IOCB interface function jump table entries */
9513772a991SJames Smart int (*__lpfc_sli_issue_iocb)
9523772a991SJames Smart (struct lpfc_hba *, uint32_t,
9533772a991SJames Smart struct lpfc_iocbq *, uint32_t);
95447ff4c51SJames Smart int (*__lpfc_sli_issue_fcp_io)
95547ff4c51SJames Smart (struct lpfc_hba *phba, uint32_t ring_number,
95647ff4c51SJames Smart struct lpfc_iocbq *piocb, uint32_t flag);
9573772a991SJames Smart void (*__lpfc_sli_release_iocbq)(struct lpfc_hba *,
9583772a991SJames Smart struct lpfc_iocbq *);
9593772a991SJames Smart int (*lpfc_hba_down_post)(struct lpfc_hba *phba);
9603772a991SJames Smart
9613772a991SJames Smart /* MBOX interface function jump table entries */
9623772a991SJames Smart int (*lpfc_sli_issue_mbox)
9633772a991SJames Smart (struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
964acd6859bSJames Smart
9653772a991SJames Smart /* Slow-path IOCB process function jump table entries */
9663772a991SJames Smart void (*lpfc_sli_handle_slow_ring_event)
9673772a991SJames Smart (struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
9683772a991SJames Smart uint32_t mask);
969acd6859bSJames Smart
9703772a991SJames Smart /* INIT device interface function jump table entries */
9713772a991SJames Smart int (*lpfc_sli_hbq_to_firmware)
9723772a991SJames Smart (struct lpfc_hba *, uint32_t, struct hbq_dmabuf *);
9733772a991SJames Smart int (*lpfc_sli_brdrestart)
9743772a991SJames Smart (struct lpfc_hba *);
9753772a991SJames Smart int (*lpfc_sli_brdready)
9763772a991SJames Smart (struct lpfc_hba *, uint32_t);
9773772a991SJames Smart void (*lpfc_handle_eratt)
9783772a991SJames Smart (struct lpfc_hba *);
9793772a991SJames Smart void (*lpfc_stop_port)
9803772a991SJames Smart (struct lpfc_hba *);
98184d1b006SJames Smart int (*lpfc_hba_init_link)
9826e7288d9SJames Smart (struct lpfc_hba *, uint32_t);
98384d1b006SJames Smart int (*lpfc_hba_down_link)
9846e7288d9SJames Smart (struct lpfc_hba *, uint32_t);
9857f86059aSJames Smart int (*lpfc_selective_reset)
9867f86059aSJames Smart (struct lpfc_hba *);
9873772a991SJames Smart
988acd6859bSJames Smart int (*lpfc_bg_scsi_prep_dma_buf)
989c490850aSJames Smart (struct lpfc_hba *, struct lpfc_io_buf *);
9906831ce12SJames Smart
9916831ce12SJames Smart /* Prep SLI WQE/IOCB jump table entries */
9926831ce12SJames Smart void (*__lpfc_sli_prep_els_req_rsp)(struct lpfc_iocbq *cmdiocbq,
9936831ce12SJames Smart struct lpfc_vport *vport,
9946831ce12SJames Smart struct lpfc_dmabuf *bmp,
9956831ce12SJames Smart u16 cmd_size, u32 did, u32 elscmd,
9966831ce12SJames Smart u8 tmo, u8 expect_rsp);
99761910d6aSJames Smart void (*__lpfc_sli_prep_gen_req)(struct lpfc_iocbq *cmdiocbq,
99861910d6aSJames Smart struct lpfc_dmabuf *bmp, u16 rpi,
99961910d6aSJames Smart u32 num_entry, u8 tmo);
100061910d6aSJames Smart void (*__lpfc_sli_prep_xmit_seq64)(struct lpfc_iocbq *cmdiocbq,
100161910d6aSJames Smart struct lpfc_dmabuf *bmp, u16 rpi,
100261910d6aSJames Smart u16 ox_id, u32 num_entry, u8 rctl,
100361910d6aSJames Smart u8 last_seq, u8 cr_cx_cmd);
100431a59f75SJames Smart void (*__lpfc_sli_prep_abort_xri)(struct lpfc_iocbq *cmdiocbq,
100531a59f75SJames Smart u16 ulp_context, u16 iotag,
1006b21c9debSJames Smart u8 ulp_class, u16 cqid, bool ia,
1007b21c9debSJames Smart bool wqec);
1008acd6859bSJames Smart
1009c490850aSJames Smart /* expedite pool */
1010c490850aSJames Smart struct lpfc_epd_pool epd_pool;
1011c490850aSJames Smart
10123772a991SJames Smart /* SLI4 specific HBA data structure */
10133772a991SJames Smart struct lpfc_sli4_hba sli4_hba;
10143772a991SJames Smart
1015f485c18dSDick Kennedy struct workqueue_struct *wq;
101632517fc0SJames Smart struct delayed_work eq_delay_work;
1017f485c18dSDick Kennedy
1018317aeb83SDick Kennedy #define LPFC_IDLE_STAT_DELAY 1000
1019317aeb83SDick Kennedy struct delayed_work idle_stat_delay_work;
1020317aeb83SDick Kennedy
10212e0fef85SJames Smart struct lpfc_sli sli;
10223772a991SJames Smart uint8_t pci_dev_grp; /* lpfc PCI dev group: 0x0, 0x1, 0x2,... */
10233772a991SJames Smart uint32_t sli_rev; /* SLI2, SLI3, or SLI4 */
1024ed957684SJames Smart uint32_t sli3_options; /* Mask of enabled SLI3 options */
102534b02dcdSJames Smart #define LPFC_SLI3_HBQ_ENABLED 0x01
102634b02dcdSJames Smart #define LPFC_SLI3_NPIV_ENABLED 0x02
102734b02dcdSJames Smart #define LPFC_SLI3_VPORT_TEARDOWN 0x04
102834b02dcdSJames Smart #define LPFC_SLI3_CRP_ENABLED 0x08
102981301a9bSJames Smart #define LPFC_SLI3_BG_ENABLED 0x20
1030da0436e9SJames Smart #define LPFC_SLI3_DSS_ENABLED 0x40
1031fedd3b7bSJames Smart #define LPFC_SLI4_PERFH_ENABLED 0x80
1032fedd3b7bSJames Smart #define LPFC_SLI4_PHWQ_ENABLED 0x100
1033ed957684SJames Smart uint32_t iocb_cmd_size;
1034ed957684SJames Smart uint32_t iocb_rsp_size;
10352e0fef85SJames Smart
10361dc5ec24SJames Smart struct lpfc_trunk_link trunk_link;
10372e0fef85SJames Smart enum hba_state link_state;
10382e0fef85SJames Smart uint32_t link_flag; /* link state flags */
103992d7f7b0SJames Smart #define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
10402e0fef85SJames Smart /* This flag is set while issuing */
10412e0fef85SJames Smart /* INIT_LINK mailbox command */
104292d7f7b0SJames Smart #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
10431b32f6aaSJames Smart #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */
1044ae9e28f3SJames Smart #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
104553e13ee0SJames Smart #define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
10468aaa7bcfSJames Smart #define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
1047ead76d4cSJames Smart #define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */
10482e0fef85SJames Smart
1049e780c942SJustin Tee unsigned long hba_flag; /* hba generic flags */
1050895427bdSJames Smart
10517dd2e2a9SJames Smart struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
105245ed1190SJames Smart uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
105334b02dcdSJames Smart struct lpfc_dmabuf slim2p;
10542e0fef85SJames Smart
105534b02dcdSJames Smart MAILBOX_t *mbox;
10567a470277SJames Smart uint32_t *mbox_ext;
10577ad20aa9SJames Smart struct lpfc_mbox_ext_buf_ctx mbox_ext_buf_ctx;
10589399627fSJames Smart uint32_t ha_copy;
105934b02dcdSJames Smart struct _PCB *pcb;
106034b02dcdSJames Smart struct _IOCB *IOCBs;
106134b02dcdSJames Smart
106234b02dcdSJames Smart struct lpfc_dmabuf hbqslimp;
10632e0fef85SJames Smart
10642e0fef85SJames Smart uint16_t pci_cfg_value;
10652e0fef85SJames Smart
10662e0fef85SJames Smart uint8_t fc_linkspeed; /* Link speed after last READ_LA */
10672e0fef85SJames Smart
10682e0fef85SJames Smart uint32_t fc_eventTag; /* event tag for link attention */
10694d9ab994SJames Smart uint32_t link_events;
10702e0fef85SJames Smart
10712e0fef85SJames Smart /* These fields used to be binfo */
10722e0fef85SJames Smart uint32_t fc_pref_DID; /* preferred D_ID */
10732e0fef85SJames Smart uint8_t fc_pref_ALPA; /* preferred AL_PA */
107412265f68SJames Smart uint32_t fc_edtovResol; /* E_D_TOV timer resolution */
10752e0fef85SJames Smart uint32_t fc_edtov; /* E_D_TOV timer value */
10762e0fef85SJames Smart uint32_t fc_arbtov; /* ARB_TOV timer value */
10772e0fef85SJames Smart uint32_t fc_ratov; /* R_A_TOV timer value */
10782e0fef85SJames Smart uint32_t fc_rttov; /* R_T_TOV timer value */
10792e0fef85SJames Smart uint32_t fc_altov; /* AL_TOV timer value */
10802e0fef85SJames Smart uint32_t fc_crtov; /* C_R_TOV timer value */
10812e0fef85SJames Smart
10822e0fef85SJames Smart struct serv_parm fc_fabparam; /* fabric service parameters buffer */
10832e0fef85SJames Smart uint8_t alpa_map[128]; /* AL_PA map from READ_LA */
10842e0fef85SJames Smart
10852e0fef85SJames Smart uint32_t lmt;
10862e0fef85SJames Smart
10872e0fef85SJames Smart uint32_t fc_topology; /* link topology, from LINK INIT */
1088e74c03c8SJames Smart uint32_t fc_topology_changed; /* link topology, from LINK INIT */
10892e0fef85SJames Smart
10902e0fef85SJames Smart struct lpfc_stats fc_stat;
10912e0fef85SJames Smart
1092dea3101eS struct lpfc_nodelist fc_fcpnodev; /* nodelist entry for no device */
1093dea3101eS uint32_t nport_event_cnt; /* timestamp for nlplist entry */
1094dea3101eS
10952e0fef85SJames Smart uint8_t wwnn[8];
10962e0fef85SJames Smart uint8_t wwpn[8];
1097dea3101eS uint32_t RandomData[7];
10987bdedb34SJames Smart uint8_t fcp_embed_io;
1099895427bdSJames Smart uint8_t nvmet_support; /* driver supports NVMET */
1100f358dd0cSJames Smart #define LPFC_NVMET_MAX_PORTS 32
11017bdedb34SJames Smart uint8_t mds_diags_support;
110244fd7fe3SJames Smart uint8_t bbcredit_support;
1103c176ffa0SJames Smart uint8_t enab_exp_wqcq_pages;
11040d8af096SJames Smart u8 nsler; /* Firmware supports FC-NVMe-2 SLER */
1105dea3101eS
11063de2a653SJames Smart /* HBA Config Parameters */
1107dea3101eS uint32_t cfg_ack0;
1108c490850aSJames Smart uint32_t cfg_xri_rebalancing;
1109d79c9e9dSJames Smart uint32_t cfg_xpsgl;
111078b2d852SJames Smart uint32_t cfg_enable_npiv;
111119ca7609SJames Smart uint32_t cfg_enable_rrq;
1112dea3101eS uint32_t cfg_topology;
1113dea3101eS uint32_t cfg_link_speed;
11147d791df7SJames Smart #define LPFC_FCF_FOV 1 /* Fast fcf failover */
11157d791df7SJames Smart #define LPFC_FCF_PRIORITY 2 /* Priority fcf failover */
11167d791df7SJames Smart uint32_t cfg_fcf_failover_policy;
111749aa143dSJames Smart uint32_t cfg_fcp_io_sched;
11187ea92eb4SJames Smart uint32_t cfg_ns_query;
1119a6571c6eSJames Smart uint32_t cfg_fcp2_no_tgt_reset;
1120dea3101eS uint32_t cfg_cr_delay;
1121dea3101eS uint32_t cfg_cr_count;
1122cf5bf97eSJamie Wellnitz uint32_t cfg_multi_ring_support;
1123a4bc3379SJames Smart uint32_t cfg_multi_ring_rctl;
1124a4bc3379SJames Smart uint32_t cfg_multi_ring_type;
1125875fbdfeSJames.Smart@Emulex.Com uint32_t cfg_poll;
1126875fbdfeSJames.Smart@Emulex.Com uint32_t cfg_poll_tmo;
11270c411222SJames Smart uint32_t cfg_task_mgmt_tmo;
11284ff43246SJames Smart uint32_t cfg_use_msi;
11290cf07f84SJames Smart uint32_t cfg_auto_imax;
1130da0436e9SJames Smart uint32_t cfg_fcp_imax;
113141b194b8SJames Smart uint32_t cfg_force_rscn;
113232517fc0SJames Smart uint32_t cfg_cq_poll_threshold;
113332517fc0SJames Smart uint32_t cfg_cq_max_proc_limit;
11347bb03bbfSJames Smart uint32_t cfg_fcp_cpu_map;
113577ffd346SJames Smart uint32_t cfg_fcp_mq_threshold;
1136cdb42becSJames Smart uint32_t cfg_hdw_queue;
11376a828b0fSJames Smart uint32_t cfg_irq_chann;
1138f358dd0cSJames Smart uint32_t cfg_suppress_rsp;
1139895427bdSJames Smart uint32_t cfg_nvme_oas;
11404e565cf0SJames Smart uint32_t cfg_nvme_embed_cmd;
11412448e484SJames Smart uint32_t cfg_nvmet_mrq_post;
11422d7dbc4cSJames Smart uint32_t cfg_nvmet_mrq;
1143f358dd0cSJames Smart uint32_t cfg_enable_nvmet;
1144895427bdSJames Smart uint32_t cfg_nvme_enable_fb;
11452d7dbc4cSJames Smart uint32_t cfg_nvmet_fb_size;
114696f7077fSJames Smart uint32_t cfg_total_seg_cnt;
1147dea3101eS uint32_t cfg_sg_seg_cnt;
11484d4c4a4aSJames Smart uint32_t cfg_nvme_seg_cnt;
11495b9e70b2SJames Smart uint32_t cfg_scsi_seg_cnt;
1150dea3101eS uint32_t cfg_sg_dma_buf_size;
11513de2a653SJames Smart uint32_t cfg_hba_queue_depth;
115213815c83SJames Smart uint32_t cfg_enable_hba_reset;
115313815c83SJames Smart uint32_t cfg_enable_hba_heartbeat;
11541ba981fdSJames Smart uint32_t cfg_fof;
11551ba981fdSJames Smart uint32_t cfg_EnableXLane;
11561ba981fdSJames Smart uint8_t cfg_oas_tgt_wwpn[8];
11571ba981fdSJames Smart uint8_t cfg_oas_vpt_wwpn[8];
11581ba981fdSJames Smart uint32_t cfg_oas_lun_state;
11591ba981fdSJames Smart #define OAS_LUN_ENABLE 1
11601ba981fdSJames Smart #define OAS_LUN_DISABLE 0
11611ba981fdSJames Smart uint32_t cfg_oas_lun_status;
11621ba981fdSJames Smart #define OAS_LUN_STATUS_EXISTS 0x01
11631ba981fdSJames Smart uint32_t cfg_oas_flags;
11641ba981fdSJames Smart #define OAS_FIND_ANY_VPORT 0x01
11651ba981fdSJames Smart #define OAS_FIND_ANY_TARGET 0x02
11661ba981fdSJames Smart #define OAS_LUN_VALID 0x04
1167c92c841cSJames Smart uint32_t cfg_oas_priority;
11681ba981fdSJames Smart uint32_t cfg_XLanePriority;
116981301a9bSJames Smart uint32_t cfg_enable_bg;
1170b3b98b74SJames Smart uint32_t cfg_prot_mask;
1171b3b98b74SJames Smart uint32_t cfg_prot_guard;
11727a470277SJames Smart uint32_t cfg_hostmem_hgp;
1173da0436e9SJames Smart uint32_t cfg_log_verbose;
1174f6e84790SJames Smart uint32_t cfg_enable_fc4_type;
1175c80b27cfSJames Smart #define LPFC_ENABLE_FCP 1
1176c80b27cfSJames Smart #define LPFC_ENABLE_NVME 2
1177c80b27cfSJames Smart #define LPFC_ENABLE_BOTH 3
1178c80b27cfSJames Smart #if (IS_ENABLED(CONFIG_NVME_FC))
1179c80b27cfSJames Smart #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1180c80b27cfSJames Smart #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1181c80b27cfSJames Smart #else
1182c80b27cfSJames Smart #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1183c80b27cfSJames Smart #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1184c80b27cfSJames Smart #endif
1185912e3acdSJames Smart uint32_t cfg_sriov_nr_virtfn;
1186c71ab861SJames Smart uint32_t cfg_request_firmware_upgrade;
118784d1b006SJames Smart uint32_t cfg_suppress_link_up;
1188cff261f6SJames Smart uint32_t cfg_rrq_xri_bitmap_sz;
11893e49af93SJames Smart u32 cfg_fcp_wait_abts_rsp;
11908eb8b960SJames Smart uint32_t cfg_delay_discovery;
119112247e81SJames Smart uint32_t cfg_sli_mode;
1192e40a02c1SJames Smart #define LPFC_INITIALIZE_LINK 0 /* do normal init_link mbox */
1193e40a02c1SJames Smart #define LPFC_DELAY_INIT_LINK 1 /* layered driver hold off */
1194e40a02c1SJames Smart #define LPFC_DELAY_INIT_LINK_INDEFINITELY 2 /* wait, manual intervention */
11954258e98eSJames Smart uint32_t cfg_fdmi_on;
11964258e98eSJames Smart #define LPFC_FDMI_NO_SUPPORT 0 /* FDMI not supported */
11974258e98eSJames Smart #define LPFC_FDMI_SUPPORT 1 /* FDMI supported? */
11984258e98eSJames Smart uint32_t cfg_enable_SmartSAN;
11997bdedb34SJames Smart uint32_t cfg_enable_mds_diags;
1200d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_level;
1201d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_buffsize;
1202d2cc9bcdSJames Smart uint32_t cfg_ras_fwlog_func;
120344fd7fe3SJames Smart uint32_t cfg_enable_bbcr; /* Enable BB Credit Recovery */
12041351e69fSJames Smart uint32_t cfg_enable_dpp; /* Enable Direct Packet Push */
1205414abe0aSJames Smart uint32_t cfg_enable_pbde;
12068aaa7bcfSJames Smart uint32_t cfg_enable_mi;
1207f358dd0cSJames Smart struct nvmet_fc_target_port *targetport;
1208dea3101eS lpfc_vpd_t vpd; /* vital product data */
1209dea3101eS
121002169e84SGaurav Srivastava u32 cfg_max_vmid; /* maximum VMIDs allowed per port */
121102169e84SGaurav Srivastava u32 cfg_vmid_app_header;
121202169e84SGaurav Srivastava #define LPFC_VMID_APP_HEADER_DISABLE 0
121302169e84SGaurav Srivastava #define LPFC_VMID_APP_HEADER_ENABLE 1
121402169e84SGaurav Srivastava u32 cfg_vmid_priority_tagging;
121502169e84SGaurav Srivastava u32 cfg_vmid_inactivity_timeout; /* Time after which the VMID */
121602169e84SGaurav Srivastava /* deregisters from switch */
1217dea3101eS struct pci_dev *pcidev;
1218dea3101eS struct list_head work_list;
1219dea3101eS uint32_t work_ha; /* Host Attention Bits for WT */
1220dea3101eS uint32_t work_ha_mask; /* HA Bits owned by WT */
1221dea3101eS uint32_t work_hs; /* HS stored in case of ERRAT */
1222dea3101eS uint32_t work_status[2]; /* Extra status from SLIM */
1223dea3101eS
12245e9d9b82SJames Smart wait_queue_head_t work_waitq;
1225dea3101eS struct task_struct *worker_thread;
1226d7c255b2SJames Smart unsigned long data_flags;
1227d79c9e9dSJames Smart uint32_t border_sge_num;
1228dea3101eS
12293163f725SJames Smart uint32_t hbq_in_use; /* HBQs in use flag */
1230ed957684SJames Smart uint32_t hbq_count; /* Count of configured HBQs */
123192d7f7b0SJames Smart struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
1232ed957684SJames Smart
1233895427bdSJames Smart atomic_t fcp_qidx; /* next FCP WQ (RR Policy) */
1234895427bdSJames Smart atomic_t nvme_qidx; /* next NVME WQ (RR Policy) */
12358fa38513SJames Smart
1236115a4124SJames Smart phys_addr_t pci_bar0_map; /* Physical address for PCI BAR0 */
1237115a4124SJames Smart phys_addr_t pci_bar1_map; /* Physical address for PCI BAR1 */
1238115a4124SJames Smart phys_addr_t pci_bar2_map; /* Physical address for PCI BAR2 */
1239dea3101eS void __iomem *slim_memmap_p; /* Kernel memory mapped address for
1240dea3101eS PCI BAR0 */
1241dea3101eS void __iomem *ctrl_regs_memmap_p;/* Kernel memory mapped address for
1242dea3101eS PCI BAR2 */
1243dea3101eS
1244962bc51bSJames Smart void __iomem *pci_bar0_memmap_p; /* Kernel memory mapped address for
1245962bc51bSJames Smart PCI BAR0 with dual-ULP support */
1246962bc51bSJames Smart void __iomem *pci_bar2_memmap_p; /* Kernel memory mapped address for
1247962bc51bSJames Smart PCI BAR2 with dual-ULP support */
1248962bc51bSJames Smart void __iomem *pci_bar4_memmap_p; /* Kernel memory mapped address for
1249962bc51bSJames Smart PCI BAR4 with dual-ULP support */
1250962bc51bSJames Smart #define PCI_64BIT_BAR0 0
1251962bc51bSJames Smart #define PCI_64BIT_BAR2 2
1252962bc51bSJames Smart #define PCI_64BIT_BAR4 4
1253dea3101eS void __iomem *MBslimaddr; /* virtual address for mbox cmds */
1254dea3101eS void __iomem *HAregaddr; /* virtual address for host attn reg */
1255dea3101eS void __iomem *CAregaddr; /* virtual address for chip attn reg */
1256dea3101eS void __iomem *HSregaddr; /* virtual address for host status
1257dea3101eS reg */
1258dea3101eS void __iomem *HCregaddr; /* virtual address for host ctl reg */
1259dea3101eS
1260ed957684SJames Smart struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */
126134b02dcdSJames Smart struct lpfc_pgp *port_gp;
1262ed957684SJames Smart uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */
126392d7f7b0SJames Smart uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */
1264ed957684SJames Smart
1265dea3101eS int brd_no; /* FC board number */
1266dea3101eS char SerialNumber[32]; /* adapter Serial Number */
1267dea3101eS char OptionROMVersion[32]; /* adapter BIOS / Fcode version */
1268b3b4f3e1SJames Smart char BIOSVersion[16]; /* Boot BIOS version */
1269dea3101eS char ModelDesc[256]; /* Model Description */
1270dea3101eS char ModelName[80]; /* Model Name */
1271dea3101eS char ProgramType[256]; /* Program Type */
1272dea3101eS char Port[20]; /* Port No */
1273dea3101eS uint8_t vpd_flag; /* VPD data flag */
1274dea3101eS
1275dea3101eS #define VPD_MODEL_DESC 0x1 /* valid vpd model description */
1276dea3101eS #define VPD_MODEL_NAME 0x2 /* valid vpd model name */
1277dea3101eS #define VPD_PROGRAM_TYPE 0x4 /* valid vpd program type */
1278dea3101eS #define VPD_PORT 0x8 /* valid vpd port data */
1279dea3101eS #define VPD_MASK 0xf /* mask for any vpd data */
1280dea3101eS
1281352e5fd1SJames Smart
1282875fbdfeSJames.Smart@Emulex.Com struct timer_list fcp_poll_timer;
12839399627fSJames Smart struct timer_list eratt_poll;
128465791f1fSJames Smart uint32_t eratt_poll_interval;
1285875fbdfeSJames.Smart@Emulex.Com
128681301a9bSJames Smart uint64_t bg_guard_err_cnt;
128781301a9bSJames Smart uint64_t bg_apptag_err_cnt;
128881301a9bSJames Smart uint64_t bg_reftag_err_cnt;
1289dea3101eS
1290dea3101eS /* fastpath list. */
1291a40fc5f0SJames Smart spinlock_t scsi_buf_list_get_lock; /* SCSI buf alloc list lock */
1292a40fc5f0SJames Smart spinlock_t scsi_buf_list_put_lock; /* SCSI buf free list lock */
1293a40fc5f0SJames Smart struct list_head lpfc_scsi_buf_list_get;
1294a40fc5f0SJames Smart struct list_head lpfc_scsi_buf_list_put;
1295dea3101eS uint32_t total_scsi_bufs;
1296dea3101eS struct list_head lpfc_iocb_list;
1297dea3101eS uint32_t total_iocbq_bufs;
12985f800d72SJustin Tee spinlock_t rrq_list_lock; /* lock for active_rrq_list */
129919ca7609SJames Smart struct list_head active_rrq_list;
13002e0fef85SJames Smart spinlock_t hbalock;
130102243836SJames Smart struct work_struct unblock_request_work; /* SCSI layer unblock IOs */
1302dea3101eS
1303771db5c0SRomain Perier /* dma_mem_pools */
1304771db5c0SRomain Perier struct dma_pool *lpfc_sg_dma_buf_pool;
1305771db5c0SRomain Perier struct dma_pool *lpfc_mbuf_pool;
1306771db5c0SRomain Perier struct dma_pool *lpfc_hrb_pool; /* header receive buffer pool */
1307771db5c0SRomain Perier struct dma_pool *lpfc_drb_pool; /* data receive buffer pool */
1308771db5c0SRomain Perier struct dma_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */
1309771db5c0SRomain Perier struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
1310d79c9e9dSJames Smart struct dma_pool *lpfc_cmd_rsp_buf_pool;
1311dea3101eS struct lpfc_dma_pool lpfc_mbuf_safety_pool;
1312dea3101eS
1313dea3101eS mempool_t *mbox_mem_pool;
1314dea3101eS mempool_t *nlp_mem_pool;
131519ca7609SJames Smart mempool_t *rrq_pool;
1316cff261f6SJames Smart mempool_t *active_rrq_pool;
1317f888ba3cSJames.Smart@Emulex.Com
1318f888ba3cSJames.Smart@Emulex.Com struct fc_host_statistics link_stats;
13193048e3e8SDick Kennedy enum lpfc_irq_chann_mode irq_chann_mode;
1320db2378e0SJames Smart enum intr_type_t intr_type;
13215b75da2fSJames Smart uint32_t intr_mode;
13225b75da2fSJames Smart #define LPFC_INTR_ERROR 0xFFFFFFFF
13232e0fef85SJames Smart struct list_head port_list;
1324523128e5SJames Smart spinlock_t port_list_lock; /* lock for port_list mutations */
13252e0fef85SJames Smart struct lpfc_vport *pport; /* physical lpfc_vport pointer */
132692d7f7b0SJames Smart uint16_t max_vpi; /* Maximum virtual nports */
13278b47ae69SJames Smart #define LPFC_MAX_VPI 0xFF /* Max number VPI supported 0 - 0xff */
13288b47ae69SJames Smart #define LPFC_MAX_VPORTS 0x100 /* Max vports per port, with pport */
1329da0436e9SJames Smart uint16_t max_vports; /*
1330da0436e9SJames Smart * For IOV HBAs max_vpi can change
1331da0436e9SJames Smart * after a reset. max_vports is max
1332da0436e9SJames Smart * number of vports present. This can
1333da0436e9SJames Smart * be greater than max_vpi.
1334da0436e9SJames Smart */
1335da0436e9SJames Smart uint16_t vpi_base;
1336da0436e9SJames Smart uint16_t vfi_base;
133792d7f7b0SJames Smart unsigned long *vpi_bmask; /* vpi allocation table */
13386d368e53SJames Smart uint16_t *vpi_ids;
13396d368e53SJames Smart uint16_t vpi_count;
13406d368e53SJames Smart struct list_head lpfc_vpi_blk_list;
134192d7f7b0SJames Smart
134292d7f7b0SJames Smart /* Data structure used by fabric iocb scheduler */
134392d7f7b0SJames Smart struct list_head fabric_iocb_list;
134492d7f7b0SJames Smart atomic_t fabric_iocb_count;
134592d7f7b0SJames Smart struct timer_list fabric_block_timer;
134692d7f7b0SJames Smart unsigned long bit_flags;
134792d7f7b0SJames Smart atomic_t num_rsrc_err;
134892d7f7b0SJames Smart unsigned long last_rsrc_error_time;
134992d7f7b0SJames Smart unsigned long last_ramp_down_time;
1350923e4b6aSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1351858c9f6cSJames Smart struct dentry *hba_debugfs_root;
1352858c9f6cSJames Smart atomic_t debugfs_vport_count;
1353c490850aSJames Smart struct dentry *debug_multixri_pools;
135478b2d852SJames Smart struct dentry *debug_hbqinfo;
1355c95d6c6cSJames Smart struct dentry *debug_dumpHostSlim;
1356c95d6c6cSJames Smart struct dentry *debug_dumpHBASlim;
1357f9bb2da1SJames Smart struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
13584ac9b226SJames Smart struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
13594ac9b226SJames Smart struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
1360f9bb2da1SJames Smart struct dentry *debug_writeGuard; /* inject write guard_tag errors */
1361f9bb2da1SJames Smart struct dentry *debug_writeApp; /* inject write app_tag errors */
1362f9bb2da1SJames Smart struct dentry *debug_writeRef; /* inject write ref_tag errors */
1363acd6859bSJames Smart struct dentry *debug_readGuard; /* inject read guard_tag errors */
1364f9bb2da1SJames Smart struct dentry *debug_readApp; /* inject read app_tag errors */
1365f9bb2da1SJames Smart struct dentry *debug_readRef; /* inject read ref_tag errors */
1366f9bb2da1SJames Smart
1367bd2cdd5eSJames Smart struct dentry *debug_nvmeio_trc;
1368bd2cdd5eSJames Smart struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
13695e5b511dSJames Smart struct dentry *debug_hdwqinfo;
13706a828b0fSJames Smart #ifdef LPFC_HDWQ_LOCK_STAT
13716a828b0fSJames Smart struct dentry *debug_lockstat;
13726a828b0fSJames Smart #endif
13739f778708SJames Smart struct dentry *debug_cgn_buffer;
13749f778708SJames Smart struct dentry *debug_rx_monitor;
137595bfc6d8SJames Smart struct dentry *debug_ras_log;
1376bd2cdd5eSJames Smart atomic_t nvmeio_trc_cnt;
1377bd2cdd5eSJames Smart uint32_t nvmeio_trc_size;
1378bd2cdd5eSJames Smart uint32_t nvmeio_trc_output_idx;
1379bd2cdd5eSJames Smart
1380f9bb2da1SJames Smart /* T10 DIF error injection */
1381f9bb2da1SJames Smart uint32_t lpfc_injerr_wgrd_cnt;
1382f9bb2da1SJames Smart uint32_t lpfc_injerr_wapp_cnt;
1383f9bb2da1SJames Smart uint32_t lpfc_injerr_wref_cnt;
1384acd6859bSJames Smart uint32_t lpfc_injerr_rgrd_cnt;
1385f9bb2da1SJames Smart uint32_t lpfc_injerr_rapp_cnt;
1386f9bb2da1SJames Smart uint32_t lpfc_injerr_rref_cnt;
13874ac9b226SJames Smart uint32_t lpfc_injerr_nportid;
13884ac9b226SJames Smart struct lpfc_name lpfc_injerr_wwpn;
1389f9bb2da1SJames Smart sector_t lpfc_injerr_lba;
1390acd6859bSJames Smart #define LPFC_INJERR_LBA_OFF (sector_t)(-1)
1391f9bb2da1SJames Smart
1392a58cbd52SJames Smart struct dentry *debug_slow_ring_trc;
1393a58cbd52SJames Smart struct lpfc_debugfs_trc *slow_ring_trc;
1394a58cbd52SJames Smart atomic_t slow_ring_trc_cnt;
13952a622bfbSJames Smart /* iDiag debugfs sub-directory */
13962a622bfbSJames Smart struct dentry *idiag_root;
13972a622bfbSJames Smart struct dentry *idiag_pci_cfg;
1398b76f2dc9SJames Smart struct dentry *idiag_bar_acc;
13992a622bfbSJames Smart struct dentry *idiag_que_info;
140086a80846SJames Smart struct dentry *idiag_que_acc;
140186a80846SJames Smart struct dentry *idiag_drb_acc;
1402b76f2dc9SJames Smart struct dentry *idiag_ctl_acc;
1403b76f2dc9SJames Smart struct dentry *idiag_mbx_acc;
1404b76f2dc9SJames Smart struct dentry *idiag_ext_acc;
140507bcd98eSJames Smart uint8_t lpfc_idiag_last_eq;
1406858c9f6cSJames Smart #endif
1407bd2cdd5eSJames Smart uint16_t nvmeio_trc_on;
1408858c9f6cSJames Smart
14090ff10d46SJames Smart /* Used for deferred freeing of ELS data buffers */
14100ff10d46SJames Smart struct list_head elsbuf;
14110ff10d46SJames Smart int elsbuf_cnt;
14120ff10d46SJames Smart int elsbuf_prev_cnt;
14130ff10d46SJames Smart
141457127f15SJames Smart uint8_t temp_sensor_support;
1415858c9f6cSJames Smart /* Fields used for heart beat. */
1416858c9f6cSJames Smart unsigned long last_completion_time;
1417bc73905aSJames Smart unsigned long skipped_hb;
1418858c9f6cSJames Smart struct timer_list hb_tmofunc;
141919ca7609SJames Smart struct timer_list rrq_tmr;
142084774a4dSJames Smart enum hba_temp_state over_temp_state;
142176bb24efSJames Smart /*
142276bb24efSJames Smart * Following bit will be set for all buffer tags which are not
142376bb24efSJames Smart * associated with any HBQ.
142476bb24efSJames Smart */
142576bb24efSJames Smart #define QUE_BUFTAG_BIT (1<<31)
142676bb24efSJames Smart uint32_t buffer_tag_count;
1427ea2151b4SJames Smart
1428ea2151b4SJames Smart /* Maximum number of events that can be outstanding at any time*/
1429ea2151b4SJames Smart #define LPFC_MAX_EVT_COUNT 512
1430ea2151b4SJames Smart atomic_t fast_event_count;
143132b9793fSJames Smart uint32_t fcoe_eventtag;
143232b9793fSJames Smart uint32_t fcoe_eventtag_at_fcf_scan;
143380c17849SJames Smart uint32_t fcoe_cvl_eventtag;
143480c17849SJames Smart uint32_t fcoe_cvl_eventtag_attn;
1435da0436e9SJames Smart struct lpfc_fcf fcf;
1436da0436e9SJames Smart uint8_t fc_map[3];
1437da0436e9SJames Smart uint8_t valid_vlan;
1438da0436e9SJames Smart uint16_t vlan_id;
1439da0436e9SJames Smart struct list_head fcf_conn_rec_list;
1440f1c3b0fcSJames Smart
1441*b5c18c9dSJustin Tee struct lpfc_defer_flogi_acc defer_flogi_acc;
14420a9e9687SJames Smart
14434fede78fSJames Smart spinlock_t ct_ev_lock; /* synchronize access to ct_ev_waiters */
1444f1c3b0fcSJames Smart struct list_head ct_ev_waiters;
14456dd9e31cSJames Smart struct unsol_rcv_ct_ctx ct_ctx[LPFC_CT_CTX_MAX];
1446f1c3b0fcSJames Smart uint32_t ctx_idx;
144702169e84SGaurav Srivastava struct timer_list inactive_vmid_poll;
1448e2aed29fSJames Smart
1449d2cc9bcdSJames Smart /* RAS Support */
1450f733a76eSJustin Tee spinlock_t ras_fwlog_lock; /* do not take while holding another lock */
1451d2cc9bcdSJames Smart struct lpfc_ras_fwlog ras_fwlog;
1452d2cc9bcdSJames Smart
14532a9bf3d0SJames Smart uint32_t iocb_cnt;
14542a9bf3d0SJames Smart uint32_t iocb_max;
1455d7c47992SJames Smart atomic_t sdev_cnt;
14561ba981fdSJames Smart spinlock_t devicelock; /* lock for luns list */
14571ba981fdSJames Smart mempool_t *device_data_mem_pool;
14581ba981fdSJames Smart struct list_head luns;
1459310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TEMPERATURE 0x0080
1460310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TEMPERATURE 0x0040
1461310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_VOLTAGE 0x0020
1462310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_VOLTAGE 0x0010
1463310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TXBIAS 0x0008
1464310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TXBIAS 0x0004
1465310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_TXPOWER 0x0002
1466310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_TXPOWER 0x0001
1467310429efSJames Smart #define LPFC_TRANSGRESSION_HIGH_RXPOWER 0x8000
1468310429efSJames Smart #define LPFC_TRANSGRESSION_LOW_RXPOWER 0x4000
1469310429efSJames Smart uint16_t sfp_alarm;
1470310429efSJames Smart uint16_t sfp_warning;
1471bd2cdd5eSJames Smart
1472bd2cdd5eSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1473840eda96SJames Smart uint16_t hdwqstat_on;
1474bd2cdd5eSJames Smart #define LPFC_CHECK_OFF 0
1475bd2cdd5eSJames Smart #define LPFC_CHECK_NVME_IO 1
1476840eda96SJames Smart #define LPFC_CHECK_NVMET_IO 2
1477840eda96SJames Smart #define LPFC_CHECK_SCSI_IO 4
1478bd2cdd5eSJames Smart uint16_t ktime_on;
1479bd2cdd5eSJames Smart uint64_t ktime_data_samples;
1480bd2cdd5eSJames Smart uint64_t ktime_status_samples;
1481bd2cdd5eSJames Smart uint64_t ktime_last_cmd;
1482bd2cdd5eSJames Smart uint64_t ktime_seg1_total;
1483bd2cdd5eSJames Smart uint64_t ktime_seg1_min;
1484bd2cdd5eSJames Smart uint64_t ktime_seg1_max;
1485bd2cdd5eSJames Smart uint64_t ktime_seg2_total;
1486bd2cdd5eSJames Smart uint64_t ktime_seg2_min;
1487bd2cdd5eSJames Smart uint64_t ktime_seg2_max;
1488bd2cdd5eSJames Smart uint64_t ktime_seg3_total;
1489bd2cdd5eSJames Smart uint64_t ktime_seg3_min;
1490bd2cdd5eSJames Smart uint64_t ktime_seg3_max;
1491bd2cdd5eSJames Smart uint64_t ktime_seg4_total;
1492bd2cdd5eSJames Smart uint64_t ktime_seg4_min;
1493bd2cdd5eSJames Smart uint64_t ktime_seg4_max;
1494bd2cdd5eSJames Smart uint64_t ktime_seg5_total;
1495bd2cdd5eSJames Smart uint64_t ktime_seg5_min;
1496bd2cdd5eSJames Smart uint64_t ktime_seg5_max;
1497bd2cdd5eSJames Smart uint64_t ktime_seg6_total;
1498bd2cdd5eSJames Smart uint64_t ktime_seg6_min;
1499bd2cdd5eSJames Smart uint64_t ktime_seg6_max;
1500bd2cdd5eSJames Smart uint64_t ktime_seg7_total;
1501bd2cdd5eSJames Smart uint64_t ktime_seg7_min;
1502bd2cdd5eSJames Smart uint64_t ktime_seg7_max;
1503bd2cdd5eSJames Smart uint64_t ktime_seg8_total;
1504bd2cdd5eSJames Smart uint64_t ktime_seg8_min;
1505bd2cdd5eSJames Smart uint64_t ktime_seg8_max;
1506bd2cdd5eSJames Smart uint64_t ktime_seg9_total;
1507bd2cdd5eSJames Smart uint64_t ktime_seg9_min;
1508bd2cdd5eSJames Smart uint64_t ktime_seg9_max;
1509bd2cdd5eSJames Smart uint64_t ktime_seg10_total;
1510bd2cdd5eSJames Smart uint64_t ktime_seg10_min;
1511bd2cdd5eSJames Smart uint64_t ktime_seg10_max;
1512bd2cdd5eSJames Smart #endif
15139064aeb2SJames Smart /* CMF objects */
151402243836SJames Smart struct lpfc_cgn_stat __percpu *cmf_stat;
151502243836SJames Smart uint32_t cmf_interval_rate; /* timer interval limit in ms */
151602243836SJames Smart uint32_t cmf_timer_cnt;
1517daebf93fSJames Smart #define LPFC_CMF_INTERVAL 90
151802243836SJames Smart uint64_t cmf_link_byte_count;
151902243836SJames Smart uint64_t cmf_max_line_rate;
152002243836SJames Smart uint64_t cmf_max_bytes_per_interval;
152102243836SJames Smart uint64_t cmf_last_sync_bw;
1522daebf93fSJames Smart #define LPFC_CMF_BLK_SIZE 512
152302243836SJames Smart struct hrtimer cmf_timer;
152493190ac1SJustin Tee struct hrtimer cmf_stats_timer; /* 1 minute stats timer */
152502243836SJames Smart atomic_t cmf_bw_wait;
152602243836SJames Smart atomic_t cmf_busy;
152702243836SJames Smart atomic_t cmf_stop_io; /* To block request and stop IO's */
152802243836SJames Smart uint32_t cmf_active_mode;
152902243836SJames Smart uint32_t cmf_info_per_interval;
1530daebf93fSJames Smart #define LPFC_MAX_CMF_INFO 32
153102243836SJames Smart struct timespec64 cmf_latency; /* Interval congestion timestamp */
153202243836SJames Smart uint32_t cmf_last_ts; /* Interval congestion time (ms) */
153302243836SJames Smart uint32_t cmf_active_info;
1534daebf93fSJames Smart
15359064aeb2SJames Smart /* Signal / FPIN handling for Congestion Mgmt */
15369064aeb2SJames Smart u8 cgn_reg_fpin; /* Negotiated value from RDF */
15379064aeb2SJames Smart u8 cgn_init_reg_fpin; /* Initial value from READ_CONFIG */
15389064aeb2SJames Smart #define LPFC_CGN_FPIN_NONE 0x0
15399064aeb2SJames Smart #define LPFC_CGN_FPIN_WARN 0x1
15409064aeb2SJames Smart #define LPFC_CGN_FPIN_ALARM 0x2
15419064aeb2SJames Smart #define LPFC_CGN_FPIN_BOTH (LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM)
15429064aeb2SJames Smart
15439064aeb2SJames Smart u8 cgn_reg_signal; /* Negotiated value from EDC */
15449064aeb2SJames Smart u8 cgn_init_reg_signal; /* Initial value from READ_CONFIG */
15459064aeb2SJames Smart /* cgn_reg_signal and cgn_init_reg_signal use
15469064aeb2SJames Smart * enum fc_edc_cg_signal_cap_types
15479064aeb2SJames Smart */
154871ddeeafSJames Smart u16 cgn_fpin_frequency; /* In units of msecs */
15499064aeb2SJames Smart #define LPFC_FPIN_INIT_FREQ 0xffff
15509064aeb2SJames Smart u32 cgn_sig_freq;
15519064aeb2SJames Smart u32 cgn_acqe_cnt;
15529064aeb2SJames Smart
155317b27ac5SJames Smart /* RX monitor handling for CMF */
1554bd269188SJames Smart struct lpfc_rx_info_monitor *rx_monitor;
155517b27ac5SJames Smart atomic_t rx_max_read_cnt; /* Maximum read bytes */
155602243836SJames Smart uint64_t rx_block_cnt;
155702243836SJames Smart
155872df8a45SJames Smart /* Congestion parameters from flash */
155972df8a45SJames Smart struct lpfc_cgn_param cgn_p;
156072df8a45SJames Smart
15619064aeb2SJames Smart /* Statistics counter for ACQE cgn alarms and warnings */
15629064aeb2SJames Smart struct lpfc_cgn_acqe_stat cgn_acqe_stat;
15639064aeb2SJames Smart
15649064aeb2SJames Smart /* Congestion buffer information */
15658c42a65cSJames Smart struct lpfc_dmabuf *cgn_i; /* Congestion Info buffer */
15669064aeb2SJames Smart atomic_t cgn_fabric_warn_cnt; /* Total warning cgn events for info */
15679064aeb2SJames Smart atomic_t cgn_fabric_alarm_cnt; /* Total alarm cgn events for info */
15689064aeb2SJames Smart atomic_t cgn_sync_warn_cnt; /* Total warning events for SYNC wqe */
15699064aeb2SJames Smart atomic_t cgn_sync_alarm_cnt; /* Total alarm events for SYNC wqe */
15708c42a65cSJames Smart atomic_t cgn_driver_evt_cnt; /* Total driver cgn events for fmw */
15718c42a65cSJames Smart atomic_t cgn_latency_evt_cnt;
15728c42a65cSJames Smart atomic64_t cgn_latency_evt; /* Avg latency per minute */
15738c42a65cSJames Smart unsigned long cgn_evt_timestamp;
15748c42a65cSJames Smart #define LPFC_CGN_TIMER_TO_MIN 60000 /* ms in a minute */
15758c42a65cSJames Smart uint32_t cgn_evt_minute;
157693190ac1SJustin Tee #define LPFC_SEC_MIN 60UL
15778c42a65cSJames Smart #define LPFC_MIN_HOUR 60
15788c42a65cSJames Smart #define LPFC_HOUR_DAY 24
15798c42a65cSJames Smart #define LPFC_MIN_DAY (LPFC_MIN_HOUR * LPFC_HOUR_DAY)
158093a4d6f4SJames Smart
158193a4d6f4SJames Smart struct hlist_node cpuhp; /* used for cpuhp per hba callback */
158293a4d6f4SJames Smart struct timer_list cpuhp_poll_timer;
158393a4d6f4SJames Smart struct list_head poll_list; /* slowpath eq polling list */
158493a4d6f4SJames Smart #define LPFC_POLL_HB 1 /* slowpath heartbeat */
1585e3ba04c9SJames Smart
1586e3ba04c9SJames Smart char os_host_name[MAXHOSTNAMELEN];
1587c90b4480SJames Smart
1588dbb1e2ffSJames Smart /* LD Signaling */
1589dbb1e2ffSJames Smart u32 degrade_activate_threshold;
1590dbb1e2ffSJames Smart u32 degrade_deactivate_threshold;
1591dbb1e2ffSJames Smart u32 fec_degrade_interval;
1592dbb1e2ffSJames Smart
1593372c187bSDick Kennedy atomic_t dbg_log_idx;
1594372c187bSDick Kennedy atomic_t dbg_log_cnt;
1595372c187bSDick Kennedy atomic_t dbg_log_dmping;
1596372c187bSDick Kennedy struct dbg_log_ent dbg_log[DBG_LOG_SZ];
1597dea3101eS };
1598dea3101eS
159917b27ac5SJames Smart #define LPFC_MAX_RXMONITOR_ENTRY 800
160074a7baa2SJames Smart #define LPFC_MAX_RXMONITOR_DUMP 32
1601bd269188SJames Smart struct rx_info_entry {
1602a6269f83SJames Smart uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */
160317b27ac5SJames Smart uint64_t total_bytes; /* Total no of read bytes requested */
160417b27ac5SJames Smart uint64_t rcv_bytes; /* Total no of read bytes completed */
160517b27ac5SJames Smart uint64_t avg_io_size;
160617b27ac5SJames Smart uint64_t avg_io_latency;/* Average io latency in microseconds */
160717b27ac5SJames Smart uint64_t max_read_cnt; /* Maximum read bytes */
160817b27ac5SJames Smart uint64_t max_bytes_per_interval;
160917b27ac5SJames Smart uint32_t cmf_busy;
161017b27ac5SJames Smart uint32_t cmf_info; /* CMF_SYNC_WQE info */
161117b27ac5SJames Smart uint32_t io_cnt;
161217b27ac5SJames Smart uint32_t timer_utilization;
161317b27ac5SJames Smart uint32_t timer_interval;
161417b27ac5SJames Smart };
161517b27ac5SJames Smart
1616bd269188SJames Smart struct lpfc_rx_info_monitor {
1617bd269188SJames Smart struct rx_info_entry *ring; /* info organized in a circular buffer */
1618bd269188SJames Smart u32 head_idx, tail_idx; /* index to head/tail of ring */
1619bd269188SJames Smart spinlock_t lock; /* spinlock for ring */
1620bd269188SJames Smart u32 entries; /* storing number entries/size of ring */
1621bd269188SJames Smart };
1622bd269188SJames Smart
16232e0fef85SJames Smart static inline struct Scsi_Host *
lpfc_shost_from_vport(struct lpfc_vport * vport)16242e0fef85SJames Smart lpfc_shost_from_vport(struct lpfc_vport *vport)
16252e0fef85SJames Smart {
16262e0fef85SJames Smart return container_of((void *) vport, struct Scsi_Host, hostdata[0]);
16275b8bd0c9SJames Smart }
1628dea3101eS
16292e0fef85SJames Smart static inline void
lpfc_set_loopback_flag(struct lpfc_hba * phba)16302e0fef85SJames Smart lpfc_set_loopback_flag(struct lpfc_hba *phba)
16312e0fef85SJames Smart {
16322e0fef85SJames Smart if (phba->cfg_topology == FLAGS_LOCAL_LB)
16332e0fef85SJames Smart phba->link_flag |= LS_LOOPBACK_MODE;
16342e0fef85SJames Smart else
16352e0fef85SJames Smart phba->link_flag &= ~LS_LOOPBACK_MODE;
16362e0fef85SJames Smart }
16372e0fef85SJames Smart
16382e0fef85SJames Smart static inline int
lpfc_is_link_up(struct lpfc_hba * phba)16392e0fef85SJames Smart lpfc_is_link_up(struct lpfc_hba *phba)
16402e0fef85SJames Smart {
16412e0fef85SJames Smart return phba->link_state == LPFC_LINK_UP ||
164292d7f7b0SJames Smart phba->link_state == LPFC_CLEAR_LA ||
164392d7f7b0SJames Smart phba->link_state == LPFC_HBA_READY;
16442e0fef85SJames Smart }
16452e0fef85SJames Smart
16465e9d9b82SJames Smart static inline void
lpfc_worker_wake_up(struct lpfc_hba * phba)16475e9d9b82SJames Smart lpfc_worker_wake_up(struct lpfc_hba *phba)
16485e9d9b82SJames Smart {
16495e9d9b82SJames Smart /* Set the lpfc data pending flag */
16505e9d9b82SJames Smart set_bit(LPFC_DATA_READY, &phba->data_flags);
16515e9d9b82SJames Smart
16525e9d9b82SJames Smart /* Wake up worker thread */
16535e9d9b82SJames Smart wake_up(&phba->work_waitq);
16545e9d9b82SJames Smart return;
16555e9d9b82SJames Smart }
16565e9d9b82SJames Smart
16579940b97bSJames Smart static inline int
lpfc_readl(void __iomem * addr,uint32_t * data)16589940b97bSJames Smart lpfc_readl(void __iomem *addr, uint32_t *data)
16599940b97bSJames Smart {
16609940b97bSJames Smart uint32_t temp;
16619940b97bSJames Smart temp = readl(addr);
16629940b97bSJames Smart if (temp == 0xffffffff)
16639940b97bSJames Smart return -EIO;
16649940b97bSJames Smart *data = temp;
16659940b97bSJames Smart return 0;
16669940b97bSJames Smart }
16679940b97bSJames Smart
16689940b97bSJames Smart static inline int
lpfc_sli_read_hs(struct lpfc_hba * phba)16699399627fSJames Smart lpfc_sli_read_hs(struct lpfc_hba *phba)
16709399627fSJames Smart {
16719399627fSJames Smart /*
16729399627fSJames Smart * There was a link/board error. Read the status register to retrieve
16739399627fSJames Smart * the error event and process it.
16749399627fSJames Smart */
16759399627fSJames Smart phba->sli.slistat.err_attn_event++;
16769399627fSJames Smart
16779940b97bSJames Smart /* Save status info and check for unplug error */
16789940b97bSJames Smart if (lpfc_readl(phba->HSregaddr, &phba->work_hs) ||
16799940b97bSJames Smart lpfc_readl(phba->MBslimaddr + 0xa8, &phba->work_status[0]) ||
16809940b97bSJames Smart lpfc_readl(phba->MBslimaddr + 0xac, &phba->work_status[1])) {
16819940b97bSJames Smart return -EIO;
16829940b97bSJames Smart }
16839399627fSJames Smart
16849399627fSJames Smart /* Clear chip Host Attention error bit */
16859399627fSJames Smart writel(HA_ERATT, phba->HAregaddr);
16869399627fSJames Smart readl(phba->HAregaddr); /* flush */
16879399627fSJames Smart phba->pport->stopped = 1;
16889399627fSJames Smart
16899940b97bSJames Smart return 0;
16909399627fSJames Smart }
1691895427bdSJames Smart
1692895427bdSJames Smart static inline struct lpfc_sli_ring *
lpfc_phba_elsring(struct lpfc_hba * phba)1693895427bdSJames Smart lpfc_phba_elsring(struct lpfc_hba *phba)
1694895427bdSJames Smart {
16955a9eeff5SJames Smart /* Return NULL if sli_rev has become invalid due to bad fw */
16965a9eeff5SJames Smart if (phba->sli_rev != LPFC_SLI_REV4 &&
16975a9eeff5SJames Smart phba->sli_rev != LPFC_SLI_REV3 &&
16985a9eeff5SJames Smart phba->sli_rev != LPFC_SLI_REV2)
16995a9eeff5SJames Smart return NULL;
17005a9eeff5SJames Smart
17010c9c6a75SJames Smart if (phba->sli_rev == LPFC_SLI_REV4) {
17020c9c6a75SJames Smart if (phba->sli4_hba.els_wq)
1703895427bdSJames Smart return phba->sli4_hba.els_wq->pring;
17040c9c6a75SJames Smart else
17050c9c6a75SJames Smart return NULL;
17060c9c6a75SJames Smart }
1707895427bdSJames Smart return &phba->sli.sli3_ring[LPFC_ELS_RING];
1708895427bdSJames Smart }
170932517fc0SJames Smart
171032517fc0SJames Smart /**
17113048e3e8SDick Kennedy * lpfc_next_online_cpu - Finds next online CPU on cpumask
17123048e3e8SDick Kennedy * @mask: Pointer to phba's cpumask member.
1713dcaa2136SJames Smart * @start: starting cpu index
1714dcaa2136SJames Smart *
1715dcaa2136SJames Smart * Note: If no valid cpu found, then nr_cpu_ids is returned.
1716dcaa2136SJames Smart *
1717dcaa2136SJames Smart **/
1718dcaa2136SJames Smart static inline unsigned int
lpfc_next_online_cpu(const struct cpumask * mask,unsigned int start)17193048e3e8SDick Kennedy lpfc_next_online_cpu(const struct cpumask *mask, unsigned int start)
1720dcaa2136SJames Smart {
1721dcaa2136SJames Smart unsigned int cpu_it;
1722dcaa2136SJames Smart
17233048e3e8SDick Kennedy for_each_cpu_wrap(cpu_it, mask, start) {
1724dcaa2136SJames Smart if (cpu_online(cpu_it))
1725dcaa2136SJames Smart break;
1726dcaa2136SJames Smart }
1727dcaa2136SJames Smart
1728dcaa2136SJames Smart return cpu_it;
1729dcaa2136SJames Smart }
1730dcaa2136SJames Smart /**
1731d668b368SJustin Tee * lpfc_next_present_cpu - Finds next present CPU after n
1732d668b368SJustin Tee * @n: the cpu prior to search
1733d668b368SJustin Tee *
1734d668b368SJustin Tee * Note: If no next present cpu, then fallback to first present cpu.
1735d668b368SJustin Tee *
1736d668b368SJustin Tee **/
lpfc_next_present_cpu(int n)1737d668b368SJustin Tee static inline unsigned int lpfc_next_present_cpu(int n)
1738d668b368SJustin Tee {
1739d668b368SJustin Tee unsigned int cpu;
1740d668b368SJustin Tee
1741d668b368SJustin Tee cpu = cpumask_next(n, cpu_present_mask);
1742d668b368SJustin Tee
1743d668b368SJustin Tee if (cpu >= nr_cpu_ids)
1744d668b368SJustin Tee cpu = cpumask_first(cpu_present_mask);
1745d668b368SJustin Tee
1746d668b368SJustin Tee return cpu;
1747d668b368SJustin Tee }
1748d668b368SJustin Tee
1749d668b368SJustin Tee /**
175032517fc0SJames Smart * lpfc_sli4_mod_hba_eq_delay - update EQ delay
175132517fc0SJames Smart * @phba: Pointer to HBA context object.
175232517fc0SJames Smart * @q: The Event Queue to update.
175332517fc0SJames Smart * @delay: The delay value (in us) to be written.
175432517fc0SJames Smart *
175532517fc0SJames Smart **/
175632517fc0SJames Smart static inline void
lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba * phba,struct lpfc_queue * eq,u32 delay)175732517fc0SJames Smart lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba *phba, struct lpfc_queue *eq,
175832517fc0SJames Smart u32 delay)
175932517fc0SJames Smart {
176032517fc0SJames Smart struct lpfc_register reg_data;
176132517fc0SJames Smart
176232517fc0SJames Smart reg_data.word0 = 0;
176332517fc0SJames Smart bf_set(lpfc_sliport_eqdelay_id, ®_data, eq->queue_id);
176432517fc0SJames Smart bf_set(lpfc_sliport_eqdelay_delay, ®_data, delay);
176532517fc0SJames Smart writel(reg_data.word0, phba->sli4_hba.u.if_type2.EQDregaddr);
176632517fc0SJames Smart eq->q_mode = delay;
176732517fc0SJames Smart }
1768df3fe766SJames Smart
1769df3fe766SJames Smart
1770df3fe766SJames Smart /*
1771df3fe766SJames Smart * Macro that declares tables and a routine to perform enum type to
1772df3fe766SJames Smart * ascii string lookup.
1773df3fe766SJames Smart *
1774df3fe766SJames Smart * Defines a <key,value> table for an enum. Uses xxx_INIT defines for
1775df3fe766SJames Smart * the enum to populate the table. Macro defines a routine (named
1776df3fe766SJames Smart * by caller) that will search all elements of the table for the key
1777df3fe766SJames Smart * and return the name string if found or "Unrecognized" if not found.
1778df3fe766SJames Smart */
1779df3fe766SJames Smart #define DECLARE_ENUM2STR_LOOKUP(routine, enum_name, enum_init) \
1780df3fe766SJames Smart static struct { \
1781df3fe766SJames Smart enum enum_name value; \
1782df3fe766SJames Smart char *name; \
1783df3fe766SJames Smart } fc_##enum_name##_e2str_names[] = enum_init; \
1784df3fe766SJames Smart static const char *routine(enum enum_name table_key) \
1785df3fe766SJames Smart { \
1786df3fe766SJames Smart int i; \
1787df3fe766SJames Smart char *name = "Unrecognized"; \
1788df3fe766SJames Smart \
1789df3fe766SJames Smart for (i = 0; i < ARRAY_SIZE(fc_##enum_name##_e2str_names); i++) {\
1790df3fe766SJames Smart if (fc_##enum_name##_e2str_names[i].value == table_key) {\
1791df3fe766SJames Smart name = fc_##enum_name##_e2str_names[i].name; \
1792df3fe766SJames Smart break; \
1793df3fe766SJames Smart } \
1794df3fe766SJames Smart } \
1795df3fe766SJames Smart return name; \
1796df3fe766SJames Smart }
179702169e84SGaurav Srivastava
179802169e84SGaurav Srivastava /**
179902169e84SGaurav Srivastava * lpfc_is_vmid_enabled - returns if VMID is enabled for either switch types
180002169e84SGaurav Srivastava * @phba: Pointer to HBA context object.
180102169e84SGaurav Srivastava *
180202169e84SGaurav Srivastava * Relationship between the enable, target support and if vmid tag is required
180302169e84SGaurav Srivastava * for the particular combination
180402169e84SGaurav Srivastava * ---------------------------------------------------
180502169e84SGaurav Srivastava * Switch Enable Flag Target Support VMID Needed
180602169e84SGaurav Srivastava * ---------------------------------------------------
180702169e84SGaurav Srivastava * App Id 0 NA N
180802169e84SGaurav Srivastava * App Id 1 0 N
180902169e84SGaurav Srivastava * App Id 1 1 Y
181002169e84SGaurav Srivastava * Pr Tag 0 NA N
181102169e84SGaurav Srivastava * Pr Tag 1 0 N
181202169e84SGaurav Srivastava * Pr Tag 1 1 Y
181302169e84SGaurav Srivastava * Pr Tag 2 * Y
181402169e84SGaurav Srivastava ---------------------------------------------------
181502169e84SGaurav Srivastava *
181602169e84SGaurav Srivastava **/
lpfc_is_vmid_enabled(struct lpfc_hba * phba)181702169e84SGaurav Srivastava static inline int lpfc_is_vmid_enabled(struct lpfc_hba *phba)
181802169e84SGaurav Srivastava {
181902169e84SGaurav Srivastava return phba->cfg_vmid_app_header || phba->cfg_vmid_priority_tagging;
182002169e84SGaurav Srivastava }
18211b64aa9eSJames Smart
18221b64aa9eSJames Smart static inline
get_job_ulpstatus(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18231b64aa9eSJames Smart u8 get_job_ulpstatus(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18241b64aa9eSJames Smart {
18251b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18261b64aa9eSJames Smart return bf_get(lpfc_wcqe_c_status, &iocbq->wcqe_cmpl);
18271b64aa9eSJames Smart else
18281b64aa9eSJames Smart return iocbq->iocb.ulpStatus;
18291b64aa9eSJames Smart }
18301b64aa9eSJames Smart
18311b64aa9eSJames Smart static inline
get_job_word4(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18321b64aa9eSJames Smart u32 get_job_word4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18331b64aa9eSJames Smart {
18341b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18351b64aa9eSJames Smart return iocbq->wcqe_cmpl.parameter;
18361b64aa9eSJames Smart else
18371b64aa9eSJames Smart return iocbq->iocb.un.ulpWord[4];
18381b64aa9eSJames Smart }
18391b64aa9eSJames Smart
18401b64aa9eSJames Smart static inline
get_job_cmnd(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18411b64aa9eSJames Smart u8 get_job_cmnd(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18421b64aa9eSJames Smart {
18431b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18441b64aa9eSJames Smart return bf_get(wqe_cmnd, &iocbq->wqe.generic.wqe_com);
18451b64aa9eSJames Smart else
18461b64aa9eSJames Smart return iocbq->iocb.ulpCommand;
18471b64aa9eSJames Smart }
18481b64aa9eSJames Smart
18491b64aa9eSJames Smart static inline
get_job_ulpcontext(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18501b64aa9eSJames Smart u16 get_job_ulpcontext(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18511b64aa9eSJames Smart {
18521b64aa9eSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18531b64aa9eSJames Smart return bf_get(wqe_ctxt_tag, &iocbq->wqe.generic.wqe_com);
18541b64aa9eSJames Smart else
18551b64aa9eSJames Smart return iocbq->iocb.ulpContext;
18561b64aa9eSJames Smart }
18576831ce12SJames Smart
18586831ce12SJames Smart static inline
get_job_rcvoxid(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)1859cad93a08SJames Smart u16 get_job_rcvoxid(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
1860cad93a08SJames Smart {
1861cad93a08SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
1862cad93a08SJames Smart return bf_get(wqe_rcvoxid, &iocbq->wqe.generic.wqe_com);
1863cad93a08SJames Smart else
1864cad93a08SJames Smart return iocbq->iocb.unsli3.rcvsli3.ox_id;
1865cad93a08SJames Smart }
1866cad93a08SJames Smart
1867cad93a08SJames Smart static inline
get_job_data_placed(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)186861910d6aSJames Smart u32 get_job_data_placed(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
186961910d6aSJames Smart {
187061910d6aSJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
187161910d6aSJames Smart return iocbq->wcqe_cmpl.total_data_placed;
187261910d6aSJames Smart else
187361910d6aSJames Smart return iocbq->iocb.un.genreq64.bdl.bdeSize;
187461910d6aSJames Smart }
187561910d6aSJames Smart
187661910d6aSJames Smart static inline
get_job_abtsiotag(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)187731a59f75SJames Smart u32 get_job_abtsiotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
187831a59f75SJames Smart {
187931a59f75SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
188031a59f75SJames Smart return iocbq->wqe.abort_cmd.wqe_com.abort_tag;
188131a59f75SJames Smart else
188231a59f75SJames Smart return iocbq->iocb.un.acxri.abortIoTag;
188331a59f75SJames Smart }
188431a59f75SJames Smart
188531a59f75SJames Smart static inline
get_job_els_rsp64_did(struct lpfc_hba * phba,struct lpfc_iocbq * iocbq)18866831ce12SJames Smart u32 get_job_els_rsp64_did(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
18876831ce12SJames Smart {
18886831ce12SJames Smart if (phba->sli_rev == LPFC_SLI_REV4)
18896831ce12SJames Smart return bf_get(wqe_els_did, &iocbq->wqe.els_req.wqe_dest);
18906831ce12SJames Smart else
18916831ce12SJames Smart return iocbq->iocb.un.elsreq64.remoteID;
18926831ce12SJames Smart }
1893