blob: a1e0a106c132bd4d2ba64bd60e380256826cf716 [file] [log] [blame]
dea31012005-04-17 16:05:31 -05001/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04003 * Fibre Channel Host Bus Adapters. *
James Smart67073c62021-03-01 09:18:21 -08004 * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
James Smart4ae2ebd2018-06-26 08:24:31 -07005 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
James Smart50611572016-03-31 14:12:34 -07006 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04007 * EMULEX and SLI are trademarks of Emulex. *
James Smartd080abe2017-02-12 13:52:39 -08008 * www.broadcom.com *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04009 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
dea31012005-04-17 16:05:31 -050010 * *
11 * This program is free software; you can redistribute it and/or *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -040012 * modify it under the terms of version 2 of the GNU General *
13 * Public License as published by the Free Software Foundation. *
14 * This program is distributed in the hope that it will be useful. *
15 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19 * TO BE LEGALLY INVALID. See the GNU General Public License for *
20 * more details, a copy of which can be found in the file COPYING *
21 * included with this package. *
dea31012005-04-17 16:05:31 -050022 *******************************************************************/
23
James Smart2e0fef82007-06-17 19:56:36 -050024#include <scsi/scsi_host.h>
Christoph Hellwig2e9bc342021-09-20 14:33:23 +020025#include <linux/hashtable.h>
James Smart895427b2017-02-12 13:52:30 -080026#include <linux/ktime.h>
Dick Kennedyf485c182017-09-29 17:34:34 -070027#include <linux/workqueue.h>
James Smart88a2cfb2011-07-22 18:36:33 -040028
29#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
30#define CONFIG_SCSI_LPFC_DEBUG_FS
31#endif
32
dea31012005-04-17 16:05:31 -050033struct lpfc_sli2_slim;
34
James Smart5402a312012-09-29 11:30:06 -040035#define ELX_MODEL_NAME_SIZE 80
36
James Smart3772a992009-05-22 14:50:54 -040037#define LPFC_PCI_DEV_LP 0x1
38#define LPFC_PCI_DEV_OC 0x2
39
40#define LPFC_SLI_REV2 2
41#define LPFC_SLI_REV3 3
42#define LPFC_SLI_REV4 4
43
James Smart97eab632008-04-07 10:16:05 -040044#define LPFC_MAX_TARGET 4096 /* max number of targets supported */
James Smarte17da182006-07-06 15:49:25 -040045#define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els
46 requests */
47#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
48 the NameServer before giving up. */
James.Smart@Emulex.Com445cf4f2005-11-28 11:42:38 -050049#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
James Smart81301a92008-12-04 22:39:46 -050050#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
James Smarte2aed292010-02-26 14:15:00 -050051#define LPFC_DEFAULT_MENLO_SG_SEG_CNT 128 /* sg element count per scsi
52 cmnd for menlo needs nearly twice as for firmware
53 downloads using bsg */
James Smart96f70772013-04-17 20:16:15 -040054
James Smartd79c9e92019-08-14 16:57:09 -070055#define LPFC_DEFAULT_XPSGL_SIZE 256
56#define LPFC_MAX_SG_TABLESIZE 0xffff
James Smart96f70772013-04-17 20:16:15 -040057#define LPFC_MIN_SG_SLI4_BUF_SZ 0x800 /* based on LPFC_DEFAULT_SG_SEG_CNT */
James Smart5b9e70b2018-09-10 10:30:42 -070058#define LPFC_MAX_BG_SLI4_SEG_CNT_DIF 128 /* sg element count for BlockGuard */
James Smart96f70772013-04-17 20:16:15 -040059#define LPFC_MAX_SG_SEG_CNT_DIF 512 /* sg element count per scsi cmnd */
James Smart81301a92008-12-04 22:39:46 -050060#define LPFC_MAX_SG_SEG_CNT 4096 /* sg element count per scsi cmnd */
James Smart81e6a632017-11-20 16:00:43 -080061#define LPFC_MIN_SG_SEG_CNT 32 /* sg element count per scsi cmnd */
James Smart09294d42013-04-17 20:16:05 -040062#define LPFC_MAX_SGL_SEG_CNT 512 /* SGL element count per scsi cmnd */
63#define LPFC_MAX_BPL_SEG_CNT 4096 /* BPL element count per scsi cmnd */
James Smartd73154b2017-11-20 16:00:33 -080064#define LPFC_MAX_NVME_SEG_CNT 256 /* max SGL element cnt per NVME cmnd */
James Smart09294d42013-04-17 20:16:05 -040065
James Smart05580562011-05-24 11:40:48 -040066#define LPFC_MAX_SGE_SIZE 0x80000000 /* Maximum data allowed in a SGE */
dea31012005-04-17 16:05:31 -050067#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
James.Smart@Emulex.Com445cf4f2005-11-28 11:42:38 -050068#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
James Smart495a7142008-06-14 22:52:59 -040069#define LPFC_VNAME_LEN 100 /* vport symbolic name length */
James Smart977b5a02008-09-07 11:52:04 -040070#define LPFC_TGTQ_RAMPUP_PCENT 5 /* Target queue rampup in percentage */
James Smart7dc517d2010-07-14 15:32:10 -040071#define LPFC_MIN_TGT_QDEPTH 10
James Smart977b5a02008-09-07 11:52:04 -040072#define LPFC_MAX_TGT_QDEPTH 0xFFFF
dea31012005-04-17 16:05:31 -050073
James Smartea2151b2008-09-07 11:52:10 -040074#define LPFC_MAX_BUCKET_COUNT 20 /* Maximum no. of buckets for stat data
75 collection. */
James Smart92d7f7b2007-06-17 19:56:38 -050076/*
77 * Following time intervals are used of adjusting SCSI device
78 * queue depths when there are driver resource error or Firmware
79 * resource error.
80 */
James Smart256ec0d2013-04-17 20:14:58 -040081/* 1 Second */
82#define QUEUE_RAMP_DOWN_INTERVAL (msecs_to_jiffies(1000 * 1))
James Smart92d7f7b2007-06-17 19:56:38 -050083
84/* Number of exchanges reserved for discovery to complete */
85#define LPFC_DISC_IOCB_BUFF_COUNT 20
86
James Smart858c9f62007-06-17 19:56:39 -050087#define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */
James Smart311464e2007-08-02 11:10:37 -040088#define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */
James Smart858c9f62007-06-17 19:56:39 -050089
James Smart93996272008-08-24 21:50:30 -040090/* Error Attention event polling interval */
91#define LPFC_ERATT_POLL_INTERVAL 5 /* EATT poll interval in seconds */
92
dea31012005-04-17 16:05:31 -050093/* Define macros for 64 bit support */
94#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
95#define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32)))
96#define getPaddr(high, low) ((dma_addr_t)( \
97 (( (u64)(high)<<16 ) << 16)|( (u64)(low))))
98/* Provide maximum configuration definitions. */
99#define LPFC_DRVR_TIMEOUT 16 /* driver iocb timeout value in sec */
dea31012005-04-17 16:05:31 -0500100#define FC_MAX_ADPTMSG 64
101
102#define MAX_HBAEVT 32
James Smart96418b52017-03-04 09:30:31 -0800103#define MAX_HBAS_NO_RESET 16
dea31012005-04-17 16:05:31 -0500104
James Smart93996272008-08-24 21:50:30 -0400105/* Number of MSI-X vectors the driver uses */
106#define LPFC_MSIX_VECTORS 2
107
James Smart5e9d9b82008-06-14 22:52:53 -0400108/* lpfc wait event data ready flag */
James Smart2ade92a2017-03-04 09:30:38 -0800109#define LPFC_DATA_READY 0 /* bit 0 */
James Smart5e9d9b82008-06-14 22:52:53 -0400110
James Smart809c7532012-05-09 21:19:25 -0400111/* queue dump line buffer size */
112#define LPFC_LBUF_SZ 128
113
James Smart618a5232012-06-12 13:54:36 -0400114/* mailbox system shutdown options */
115#define LPFC_MBX_NO_WAIT 0
116#define LPFC_MBX_WAIT 1
117
James Smart72df8a452021-08-16 09:28:52 -0700118#define LPFC_CFG_PARAM_MAGIC_NUM 0xFEAA0005
119#define LPFC_PORT_CFG_NAME "/cfg/port.cfg"
120
121#define lpfc_rangecheck(val, min, max) \
122 ((uint)(val) >= (uint)(min) && (val) <= (max))
123
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500124enum lpfc_polling_flags {
125 ENABLE_FCP_RING_POLLING = 0x1,
126 DISABLE_FCP_RING_INT = 0x2
127};
128
James Smart895427b2017-02-12 13:52:30 -0800129struct perf_prof {
130 uint16_t cmd_cpu[40];
131 uint16_t rsp_cpu[40];
132 uint16_t qh_cpu[40];
133 uint16_t wqidx[40];
134};
135
James Smart01649562017-02-12 13:52:32 -0800136/*
137 * Provide for FC4 TYPE x28 - NVME. The
138 * bit mask for FCP and NVME is 0x8 identically
139 * because they are 32 bit positions distance.
140 */
James Smarta0f2d3e2017-02-12 13:52:31 -0800141#define LPFC_FC4_TYPE_BITMASK 0x00000100
142
dea31012005-04-17 16:05:31 -0500143/* Provide DMA memory definitions the driver uses per port instance. */
144struct lpfc_dmabuf {
145 struct list_head list;
146 void *virt; /* virtual address ptr */
147 dma_addr_t phys; /* mapped address */
James Smart76bb24e2007-10-27 13:38:00 -0400148 uint32_t buffer_tag; /* used for tagged queue ring */
dea31012005-04-17 16:05:31 -0500149};
150
James Smart6c621a22017-05-15 15:20:45 -0700151struct lpfc_nvmet_ctxbuf {
152 struct list_head list;
James Smart7cacae22020-03-31 09:50:03 -0700153 struct lpfc_async_xchg_ctx *context;
James Smart6c621a22017-05-15 15:20:45 -0700154 struct lpfc_iocbq *iocbq;
155 struct lpfc_sglq *sglq;
James Smart472e1462019-01-28 11:14:39 -0800156 struct work_struct defer_work;
James Smart6c621a22017-05-15 15:20:45 -0700157};
158
dea31012005-04-17 16:05:31 -0500159struct lpfc_dma_pool {
160 struct lpfc_dmabuf *elements;
161 uint32_t max_count;
162 uint32_t current_count;
163};
164
James Smarted957682007-06-17 19:56:37 -0500165struct hbq_dmabuf {
James Smartda0436e2009-05-22 14:51:39 -0400166 struct lpfc_dmabuf hbuf;
James Smarted957682007-06-17 19:56:37 -0500167 struct lpfc_dmabuf dbuf;
James Smart895427b2017-02-12 13:52:30 -0800168 uint16_t total_size;
169 uint16_t bytes_recv;
James Smarted957682007-06-17 19:56:37 -0500170 uint32_t tag;
James Smart4d9ab992009-10-02 15:16:39 -0400171 struct lpfc_cq_event cq_event;
James Smart45ed1192009-10-02 15:17:02 -0400172 unsigned long time_stamp;
James Smart895427b2017-02-12 13:52:30 -0800173 void *context;
174};
175
176struct rqb_dmabuf {
177 struct lpfc_dmabuf hbuf;
178 struct lpfc_dmabuf dbuf;
179 uint16_t total_size;
180 uint16_t bytes_recv;
James Smarta8cf5df2017-05-15 15:20:46 -0700181 uint16_t idx;
James Smart895427b2017-02-12 13:52:30 -0800182 struct lpfc_queue *hrq; /* ptr to associated Header RQ */
183 struct lpfc_queue *drq; /* ptr to associated Data RQ */
James Smarted957682007-06-17 19:56:37 -0500184};
185
dea31012005-04-17 16:05:31 -0500186/* Priority bit. Set value to exceed low water mark in lpfc_mem. */
187#define MEM_PRI 0x100
188
189
190/****************************************************************************/
191/* Device VPD save area */
192/****************************************************************************/
193typedef struct lpfc_vpd {
194 uint32_t status; /* vpd status value */
195 uint32_t length; /* number of bytes actually returned */
196 struct {
197 uint32_t rsvd1; /* Revision numbers */
198 uint32_t biuRev;
199 uint32_t smRev;
200 uint32_t smFwRev;
201 uint32_t endecRev;
202 uint16_t rBit;
203 uint8_t fcphHigh;
204 uint8_t fcphLow;
205 uint8_t feaLevelHigh;
206 uint8_t feaLevelLow;
207 uint32_t postKernRev;
208 uint32_t opFwRev;
209 uint8_t opFwName[16];
210 uint32_t sli1FwRev;
211 uint8_t sli1FwName[16];
212 uint32_t sli2FwRev;
213 uint8_t sli2FwName[16];
214 } rev;
James Smart92d7f7b2007-06-17 19:56:38 -0500215 struct {
216#ifdef __BIG_ENDIAN_BITFIELD
James Smart0e754612020-03-22 11:13:03 -0700217 uint32_t rsvd3 :20; /* Reserved */
James Smartda0436e2009-05-22 14:51:39 -0400218 uint32_t rsvd2 : 3; /* Reserved */
219 uint32_t cbg : 1; /* Configure BlockGuard */
James Smart92d7f7b2007-06-17 19:56:38 -0500220 uint32_t cmv : 1; /* Configure Max VPIs */
221 uint32_t ccrp : 1; /* Config Command Ring Polling */
222 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
223 uint32_t chbs : 1; /* Cofigure Host Backing store */
224 uint32_t cinb : 1; /* Enable Interrupt Notification Block */
225 uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
226 uint32_t cmx : 1; /* Configure Max XRIs */
227 uint32_t cmr : 1; /* Configure Max RPIs */
228#else /* __LITTLE_ENDIAN */
229 uint32_t cmr : 1; /* Configure Max RPIs */
230 uint32_t cmx : 1; /* Configure Max XRIs */
231 uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
232 uint32_t cinb : 1; /* Enable Interrupt Notification Block */
233 uint32_t chbs : 1; /* Cofigure Host Backing store */
234 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
235 uint32_t ccrp : 1; /* Config Command Ring Polling */
236 uint32_t cmv : 1; /* Configure Max VPIs */
James Smartda0436e2009-05-22 14:51:39 -0400237 uint32_t cbg : 1; /* Configure BlockGuard */
238 uint32_t rsvd2 : 3; /* Reserved */
James Smart0e754612020-03-22 11:13:03 -0700239 uint32_t rsvd3 :20; /* Reserved */
James Smart92d7f7b2007-06-17 19:56:38 -0500240#endif
241 } sli3Feat;
dea31012005-04-17 16:05:31 -0500242} lpfc_vpd_t;
243
dea31012005-04-17 16:05:31 -0500244
245/*
246 * lpfc stat counters
247 */
248struct lpfc_stats {
249 /* Statistics for ELS commands */
250 uint32_t elsLogiCol;
251 uint32_t elsRetryExceeded;
252 uint32_t elsXmitRetry;
253 uint32_t elsDelayRetry;
254 uint32_t elsRcvDrop;
255 uint32_t elsRcvFrame;
256 uint32_t elsRcvRSCN;
257 uint32_t elsRcvRNID;
258 uint32_t elsRcvFARP;
259 uint32_t elsRcvFARPR;
260 uint32_t elsRcvFLOGI;
261 uint32_t elsRcvPLOGI;
262 uint32_t elsRcvADISC;
263 uint32_t elsRcvPDISC;
264 uint32_t elsRcvFAN;
265 uint32_t elsRcvLOGO;
266 uint32_t elsRcvPRLO;
267 uint32_t elsRcvPRLI;
Jamie Wellnitz7bb3b132006-02-28 19:25:15 -0500268 uint32_t elsRcvLIRR;
James Smart12265f62010-10-22 11:05:53 -0400269 uint32_t elsRcvRLS;
Jamie Wellnitz7bb3b132006-02-28 19:25:15 -0500270 uint32_t elsRcvRPL;
James Smart5ffc2662009-11-18 15:39:44 -0500271 uint32_t elsRcvRRQ;
James Smart12265f62010-10-22 11:05:53 -0400272 uint32_t elsRcvRTV;
273 uint32_t elsRcvECHO;
James Smart8b017a32015-05-21 13:55:18 -0400274 uint32_t elsRcvLCB;
James Smart86478872015-05-21 13:55:21 -0400275 uint32_t elsRcvRDP;
James Smart8eced802021-05-14 12:55:58 -0700276 uint32_t elsRcvRDF;
dea31012005-04-17 16:05:31 -0500277 uint32_t elsXmitFLOGI;
James Smart92d7f7b2007-06-17 19:56:38 -0500278 uint32_t elsXmitFDISC;
dea31012005-04-17 16:05:31 -0500279 uint32_t elsXmitPLOGI;
280 uint32_t elsXmitPRLI;
281 uint32_t elsXmitADISC;
282 uint32_t elsXmitLOGO;
283 uint32_t elsXmitSCR;
James Smartf60cb932019-05-14 14:58:05 -0700284 uint32_t elsXmitRSCN;
dea31012005-04-17 16:05:31 -0500285 uint32_t elsXmitRNID;
286 uint32_t elsXmitFARP;
287 uint32_t elsXmitFARPR;
288 uint32_t elsXmitACC;
289 uint32_t elsXmitLSRJT;
290
291 uint32_t frameRcvBcast;
292 uint32_t frameRcvMulti;
293 uint32_t strayXmitCmpl;
294 uint32_t frameXmitDelay;
295 uint32_t xriCmdCmpl;
296 uint32_t xriStatErr;
297 uint32_t LinkUp;
298 uint32_t LinkDown;
299 uint32_t LinkMultiEvent;
300 uint32_t NoRcvBuf;
301 uint32_t fcpCmd;
302 uint32_t fcpCmpl;
303 uint32_t fcpRspErr;
304 uint32_t fcpRemoteStop;
305 uint32_t fcpPortRjt;
306 uint32_t fcpPortBusy;
307 uint32_t fcpError;
308 uint32_t fcpLocalErr;
309};
310
James Smart2e0fef82007-06-17 19:56:36 -0500311struct lpfc_hba;
dea31012005-04-17 16:05:31 -0500312
James Smart92d7f7b2007-06-17 19:56:38 -0500313
Gaurav Srivastava02169e82021-06-08 10:05:47 +0530314#define LPFC_VMID_TIMER 300 /* timer interval in seconds */
315
316#define LPFC_MAX_VMID_SIZE 256
317#define LPFC_COMPRESS_VMID_SIZE 16
318
319union lpfc_vmid_io_tag {
320 u32 app_id; /* App Id vmid */
321 u8 cs_ctl_vmid; /* Priority tag vmid */
322};
323
324#define JIFFIES_PER_HR (HZ * 60 * 60)
325
326struct lpfc_vmid {
327 u8 flag;
328#define LPFC_VMID_SLOT_FREE 0x0
329#define LPFC_VMID_SLOT_USED 0x1
330#define LPFC_VMID_REQ_REGISTER 0x2
331#define LPFC_VMID_REGISTERED 0x4
332#define LPFC_VMID_DE_REGISTER 0x8
333 char host_vmid[LPFC_MAX_VMID_SIZE];
334 union lpfc_vmid_io_tag un;
335 struct hlist_node hnode;
336 u64 io_rd_cnt;
337 u64 io_wr_cnt;
338 u8 vmid_len;
339 u8 delete_inactive; /* Delete if inactive flag 0 = no, 1 = yes */
340 u32 hash_index;
341 u64 __percpu *last_io_time;
342};
343
344#define lpfc_vmid_is_type_priority_tag(vport)\
345 (vport->vmid_priority_tagging ? 1 : 0)
346
347#define LPFC_VMID_HASH_SIZE 256
348#define LPFC_VMID_HASH_MASK 255
349#define LPFC_VMID_HASH_SHIFT 6
350
351struct lpfc_vmid_context {
352 struct lpfc_vmid *vmp;
353 struct lpfc_nodelist *nlp;
354 bool instantiated;
355};
356
357struct lpfc_vmid_priority_range {
358 u8 low;
359 u8 high;
360 u8 qos;
361};
362
363struct lpfc_vmid_priority_info {
364 u32 num_descriptors;
365 struct lpfc_vmid_priority_range *vmid_range;
366};
367
368#define QFPA_EVEN_ONLY 0x01
369#define QFPA_ODD_ONLY 0x02
370#define QFPA_EVEN_ODD 0x03
371
James Smart2e0fef82007-06-17 19:56:36 -0500372enum discovery_state {
James Smart92d7f7b2007-06-17 19:56:38 -0500373 LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */
374 LPFC_VPORT_FAILED = 1, /* vport has failed */
375 LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */
376 LPFC_FLOGI = 7, /* FLOGI sent to Fabric */
377 LPFC_FDISC = 8, /* FDISC sent for vport */
378 LPFC_FABRIC_CFG_LINK = 9, /* Fabric assigned NPORT Id
379 * configured */
380 LPFC_NS_REG = 10, /* Register with NameServer */
381 LPFC_NS_QRY = 11, /* Query NameServer for NPort ID list */
382 LPFC_BUILD_DISC_LIST = 12, /* Build ADISC and PLOGI lists for
383 * device authentication / discovery */
384 LPFC_DISC_AUTH = 13, /* Processing ADISC list */
385 LPFC_VPORT_READY = 32,
James Smart2e0fef82007-06-17 19:56:36 -0500386};
dea31012005-04-17 16:05:31 -0500387
James Smart2e0fef82007-06-17 19:56:36 -0500388enum hba_state {
389 LPFC_LINK_UNKNOWN = 0, /* HBA state is unknown */
390 LPFC_WARM_START = 1, /* HBA state after selective reset */
391 LPFC_INIT_START = 2, /* Initial state after board reset */
392 LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */
393 LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */
394 LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */
James Smart92d7f7b2007-06-17 19:56:38 -0500395 LPFC_CLEAR_LA = 6, /* authentication cmplt - issue
James Smart2e0fef82007-06-17 19:56:36 -0500396 * CLEAR_LA */
James Smart92d7f7b2007-06-17 19:56:38 -0500397 LPFC_HBA_READY = 32,
James Smart2e0fef82007-06-17 19:56:36 -0500398 LPFC_HBA_ERROR = -1
399};
dea31012005-04-17 16:05:31 -0500400
James Smart1dc5ec22018-10-23 13:41:11 -0700401struct lpfc_trunk_link_state {
402 enum hba_state state;
403 uint8_t fault;
404};
405
406struct lpfc_trunk_link {
407 struct lpfc_trunk_link_state link0,
408 link1,
409 link2,
410 link3;
411};
412
James Smart72df8a452021-08-16 09:28:52 -0700413/* Format of congestion module parameters */
414struct lpfc_cgn_param {
415 uint32_t cgn_param_magic;
416 uint8_t cgn_param_version; /* version 1 */
417 uint8_t cgn_param_mode; /* 0=off 1=managed 2=monitor only */
418#define LPFC_CFG_OFF 0
419#define LPFC_CFG_MANAGED 1
420#define LPFC_CFG_MONITOR 2
421 uint8_t cgn_rsvd1;
422 uint8_t cgn_rsvd2;
423 uint8_t cgn_param_level0;
424 uint8_t cgn_param_level1;
425 uint8_t cgn_param_level2;
426 uint8_t byte11;
427 uint8_t byte12;
428 uint8_t byte13;
429 uint8_t byte14;
430 uint8_t byte15;
431};
432
James Smart8c42a652021-08-16 09:28:51 -0700433/* Max number of days of congestion data */
434#define LPFC_MAX_CGN_DAYS 10
435
436/* Format of congestion buffer info
437 * This structure defines memory thats allocated and registered with
438 * the HBA firmware. When adding or removing fields from this structure
439 * the alignment must match the HBA firmware.
440 */
441
442struct lpfc_cgn_info {
443 /* Header */
444 __le16 cgn_info_size; /* is sizeof(struct lpfc_cgn_info) */
445 uint8_t cgn_info_version; /* represents format of structure */
446#define LPFC_CGN_INFO_V1 1
447#define LPFC_CGN_INFO_V2 2
448#define LPFC_CGN_INFO_V3 3
449 uint8_t cgn_info_mode; /* 0=off 1=managed 2=monitor only */
450 uint8_t cgn_info_detect;
451 uint8_t cgn_info_action;
452 uint8_t cgn_info_level0;
453 uint8_t cgn_info_level1;
454 uint8_t cgn_info_level2;
455
456 /* Start Time */
457 uint8_t cgn_info_month;
458 uint8_t cgn_info_day;
459 uint8_t cgn_info_year;
460 uint8_t cgn_info_hour;
461 uint8_t cgn_info_minute;
462 uint8_t cgn_info_second;
463
464 /* minute / hours / daily indices */
465 uint8_t cgn_index_minute;
466 uint8_t cgn_index_hour;
467 uint8_t cgn_index_day;
468
469 __le16 cgn_warn_freq;
470 __le16 cgn_alarm_freq;
471 __le16 cgn_lunq;
472 uint8_t cgn_pad1[8];
473
474 /* Driver Information */
475 __le16 cgn_drvr_min[60];
476 __le32 cgn_drvr_hr[24];
477 __le32 cgn_drvr_day[LPFC_MAX_CGN_DAYS];
478
479 /* Congestion Warnings */
480 __le16 cgn_warn_min[60];
481 __le32 cgn_warn_hr[24];
482 __le32 cgn_warn_day[LPFC_MAX_CGN_DAYS];
483
484 /* Latency Information */
485 __le32 cgn_latency_min[60];
486 __le32 cgn_latency_hr[24];
487 __le32 cgn_latency_day[LPFC_MAX_CGN_DAYS];
488
489 /* Bandwidth Information */
490 __le16 cgn_bw_min[60];
491 __le16 cgn_bw_hr[24];
492 __le16 cgn_bw_day[LPFC_MAX_CGN_DAYS];
493
494 /* Congestion Alarms */
495 __le16 cgn_alarm_min[60];
496 __le32 cgn_alarm_hr[24];
497 __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS];
498
Kees Cook532adda2021-12-08 11:59:57 -0800499 struct_group(cgn_stat,
500 uint8_t cgn_stat_npm; /* Notifications per minute */
James Smart8c42a652021-08-16 09:28:51 -0700501
Kees Cook532adda2021-12-08 11:59:57 -0800502 /* Start Time */
503 uint8_t cgn_stat_month;
504 uint8_t cgn_stat_day;
505 uint8_t cgn_stat_year;
506 uint8_t cgn_stat_hour;
507 uint8_t cgn_stat_minute;
508 uint8_t cgn_pad2[2];
James Smart8c42a652021-08-16 09:28:51 -0700509
Kees Cook532adda2021-12-08 11:59:57 -0800510 __le32 cgn_notification;
511 __le32 cgn_peer_notification;
512 __le32 link_integ_notification;
513 __le32 delivery_notification;
James Smart8c42a652021-08-16 09:28:51 -0700514
Kees Cook532adda2021-12-08 11:59:57 -0800515 uint8_t cgn_stat_cgn_month; /* Last congestion notification FPIN */
516 uint8_t cgn_stat_cgn_day;
517 uint8_t cgn_stat_cgn_year;
518 uint8_t cgn_stat_cgn_hour;
519 uint8_t cgn_stat_cgn_min;
520 uint8_t cgn_stat_cgn_sec;
James Smart8c42a652021-08-16 09:28:51 -0700521
Kees Cook532adda2021-12-08 11:59:57 -0800522 uint8_t cgn_stat_peer_month; /* Last peer congestion FPIN */
523 uint8_t cgn_stat_peer_day;
524 uint8_t cgn_stat_peer_year;
525 uint8_t cgn_stat_peer_hour;
526 uint8_t cgn_stat_peer_min;
527 uint8_t cgn_stat_peer_sec;
James Smart8c42a652021-08-16 09:28:51 -0700528
Kees Cook532adda2021-12-08 11:59:57 -0800529 uint8_t cgn_stat_lnk_month; /* Last link integrity FPIN */
530 uint8_t cgn_stat_lnk_day;
531 uint8_t cgn_stat_lnk_year;
532 uint8_t cgn_stat_lnk_hour;
533 uint8_t cgn_stat_lnk_min;
534 uint8_t cgn_stat_lnk_sec;
James Smart8c42a652021-08-16 09:28:51 -0700535
Kees Cook532adda2021-12-08 11:59:57 -0800536 uint8_t cgn_stat_del_month; /* Last delivery notification FPIN */
537 uint8_t cgn_stat_del_day;
538 uint8_t cgn_stat_del_year;
539 uint8_t cgn_stat_del_hour;
540 uint8_t cgn_stat_del_min;
541 uint8_t cgn_stat_del_sec;
542 );
James Smart8c42a652021-08-16 09:28:51 -0700543
544 __le32 cgn_info_crc;
545#define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
546#define LPFC_CGN_CRC32_SEED 0xFFFFFFFF
547};
548
549#define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \
550 sizeof(uint32_t))
551
James Smart02243832021-08-16 09:28:54 -0700552struct lpfc_cgn_stat {
553 atomic64_t total_bytes;
554 atomic64_t rcv_bytes;
555 atomic64_t rx_latency;
556#define LPFC_CGN_NOT_SENT 0xFFFFFFFFFFFFFFFFLL
557 atomic_t rx_io_cnt;
558};
559
James Smart9064aeb2021-08-16 09:28:50 -0700560struct lpfc_cgn_acqe_stat {
561 atomic64_t alarm;
562 atomic64_t warn;
563};
564
James Smart2e0fef82007-06-17 19:56:36 -0500565struct lpfc_vport {
James Smart2e0fef82007-06-17 19:56:36 -0500566 struct lpfc_hba *phba;
James Smart3772a992009-05-22 14:50:54 -0400567 struct list_head listentry;
James Smart2e0fef82007-06-17 19:56:36 -0500568 uint8_t port_type;
569#define LPFC_PHYSICAL_PORT 1
570#define LPFC_NPIV_PORT 2
571#define LPFC_FABRIC_PORT 3
572 enum discovery_state port_state;
dea31012005-04-17 16:05:31 -0500573
James Smart92d7f7b2007-06-17 19:56:38 -0500574 uint16_t vpi;
James Smartda0436e2009-05-22 14:51:39 -0400575 uint16_t vfi;
James Smartc8685952009-11-18 15:39:16 -0500576 uint8_t vpi_state;
577#define LPFC_VPI_REGISTERED 0x1
dea31012005-04-17 16:05:31 -0500578
dea31012005-04-17 16:05:31 -0500579 uint32_t fc_flag; /* FC flags */
James Smart2e0fef82007-06-17 19:56:36 -0500580/* Several of these flags are HBA centric and should be moved to
581 * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
582 */
James Smart92d7f7b2007-06-17 19:56:38 -0500583#define FC_PT2PT 0x1 /* pt2pt with no fabric */
584#define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */
585#define FC_DISC_TMO 0x4 /* Discovery timer running */
586#define FC_PUBLIC_LOOP 0x8 /* Public loop */
587#define FC_LBIT 0x10 /* LOGIN bit in loopinit set */
588#define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */
589#define FC_NLP_MORE 0x40 /* More node to process in node tbl */
590#define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */
591#define FC_FABRIC 0x100 /* We are fabric attached */
James Smart4b40c592010-03-15 11:25:44 -0400592#define FC_VPORT_LOGO_RCVD 0x200 /* LOGO received on vport */
James Smart92d7f7b2007-06-17 19:56:38 -0500593#define FC_RSCN_DISCOVERY 0x400 /* Auth all devices after RSCN */
James Smart4b40c592010-03-15 11:25:44 -0400594#define FC_LOGO_RCVD_DID_CHNG 0x800 /* FDISC on phys port detect DID chng*/
James Smart92d7f7b2007-06-17 19:56:38 -0500595#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
596#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
597#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
598#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
James Smart92d7f7b2007-06-17 19:56:38 -0500599#define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
600#define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
James Smart1c6834a2009-07-19 10:01:26 -0400601#define FC_VPORT_NEEDS_INIT_VPI 0x200000 /* Need to INIT_VPI before FDISC */
James Smart695a8142010-01-26 23:08:03 -0500602#define FC_VPORT_CVL_RCVD 0x400000 /* VLink failed due to CVL */
603#define FC_VFI_REGISTERED 0x800000 /* VFI is registered */
604#define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */
James Smart92494142011-02-16 12:39:44 -0500605#define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */
dea31012005-04-17 16:05:31 -0500606
James Smart7ee5d432007-10-27 13:37:17 -0400607 uint32_t ct_flags;
608#define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
609#define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
610#define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
611#define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
612#define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
613
James Smart685f0bf2007-04-25 09:53:08 -0400614 struct list_head fc_nodes;
dea31012005-04-17 16:05:31 -0500615
616 /* Keep counters for the number of entries in each list. */
617 uint16_t fc_plogi_cnt;
618 uint16_t fc_adisc_cnt;
619 uint16_t fc_reglogin_cnt;
620 uint16_t fc_prli_cnt;
621 uint16_t fc_unmap_cnt;
622 uint16_t fc_map_cnt;
623 uint16_t fc_npr_cnt;
624 uint16_t fc_unused_cnt;
James Smart2e0fef82007-06-17 19:56:36 -0500625 struct serv_parm fc_sparam; /* buffer for our service parameters */
626
627 uint32_t fc_myDID; /* fibre channel S_ID */
628 uint32_t fc_prevDID; /* previous fibre channel S_ID */
James Smart92494142011-02-16 12:39:44 -0500629 struct lpfc_name fabric_portname;
630 struct lpfc_name fabric_nodename;
James Smart2e0fef82007-06-17 19:56:36 -0500631
632 int32_t stopped; /* HBA has not been restarted since last ERATT */
633 uint8_t fc_linkspeed; /* Link speed after last READ_LA */
634
James Smarta0f2d3e2017-02-12 13:52:31 -0800635 uint32_t num_disc_nodes; /* in addition to hba_state */
636 uint32_t gidft_inp; /* cnt of outstanding GID_FTs */
James Smart2e0fef82007-06-17 19:56:36 -0500637
638 uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */
639 uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */
James Smart7f5f3d02008-02-08 18:50:14 -0500640 uint32_t fc_rscn_flush; /* flag use of fc_rscn_id_list */
James Smart2e0fef82007-06-17 19:56:36 -0500641 struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN];
642 struct lpfc_name fc_nodename; /* fc nodename */
643 struct lpfc_name fc_portname; /* fc portname */
644
645 struct lpfc_work_evt disc_timeout_evt;
646
647 struct timer_list fc_disctmo; /* Discovery rescue timer */
648 uint8_t fc_ns_retry; /* retries for fabric nameserver */
649 uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */
650
651 spinlock_t work_port_lock;
652 uint32_t work_port_events; /* Timeout to be handled */
James Smart858c9f62007-06-17 19:56:39 -0500653#define WORKER_DISC_TMO 0x1 /* vport: Discovery timeout */
654#define WORKER_ELS_TMO 0x2 /* vport: ELS timeout */
James Smart92494142011-02-16 12:39:44 -0500655#define WORKER_DELAYED_DISC_TMO 0x8 /* vport: delayed discovery */
James Smart858c9f62007-06-17 19:56:39 -0500656
657#define WORKER_MBOX_TMO 0x100 /* hba: MBOX timeout */
658#define WORKER_HB_TMO 0x200 /* hba: Heart beat timeout */
Joe Perchesb1c11812008-02-03 17:28:22 +0200659#define WORKER_FABRIC_BLOCK_TMO 0x400 /* hba: fabric block timeout */
James Smart858c9f62007-06-17 19:56:39 -0500660#define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */
661#define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */
James Smart2a9bf3d2010-06-07 15:24:45 -0400662#define WORKER_SERVICE_TXQ 0x2000 /* hba: IOCBs on the txq */
Gaurav Srivastava02169e82021-06-08 10:05:47 +0530663#define WORKER_CHECK_INACTIVE_VMID 0x4000 /* hba: check inactive vmids */
664#define WORKER_CHECK_VMID_ISSUE_QFPA 0x8000 /* vport: Check if qfpa needs
665 * to be issued */
James Smart2e0fef82007-06-17 19:56:36 -0500666
James Smart2e0fef82007-06-17 19:56:36 -0500667 struct timer_list els_tmofunc;
James Smart92494142011-02-16 12:39:44 -0500668 struct timer_list delayed_disc_tmo;
James Smart2e0fef82007-06-17 19:56:36 -0500669
James Smart2e0fef82007-06-17 19:56:36 -0500670 uint8_t load_flag;
671#define FC_LOADING 0x1 /* HBA in process of loading drvr */
672#define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
James Smart4258e982015-12-16 18:11:58 -0500673#define FC_ALLOW_FDMI 0x4 /* port is ready for FDMI requests */
Gaurav Srivastava02169e82021-06-08 10:05:47 +0530674#define FC_ALLOW_VMID 0x8 /* Allow VMID I/Os */
675#define FC_DEREGISTER_ALL_APP_ID 0x10 /* Deregister all VMIDs */
James Smart3de2a652007-08-02 11:09:59 -0400676 /* Vport Config Parameters */
677 uint32_t cfg_scan_down;
678 uint32_t cfg_lun_queue_depth;
679 uint32_t cfg_nodev_tmo;
680 uint32_t cfg_devloss_tmo;
681 uint32_t cfg_restrict_login;
682 uint32_t cfg_peer_port_login;
683 uint32_t cfg_fcp_class;
684 uint32_t cfg_use_adisc;
James Smart3de2a652007-08-02 11:09:59 -0400685 uint32_t cfg_discovery_threads;
James Smarte8b62012007-08-02 11:10:09 -0400686 uint32_t cfg_log_verbose;
James Smartf6e84792019-01-28 11:14:38 -0800687 uint32_t cfg_enable_fc4_type;
James Smart3de2a652007-08-02 11:09:59 -0400688 uint32_t cfg_max_luns;
James Smart7ee5d432007-10-27 13:37:17 -0400689 uint32_t cfg_enable_da_id;
James Smart977b5a02008-09-07 11:52:04 -0400690 uint32_t cfg_max_scsicmpl_time;
James Smart7dc517d2010-07-14 15:32:10 -0400691 uint32_t cfg_tgt_queue_depth;
James Smart3cb01c52013-07-15 18:35:04 -0400692 uint32_t cfg_first_burst_size;
James Smart3de2a652007-08-02 11:09:59 -0400693 uint32_t dev_loss_tmo_changed;
Gaurav Srivastava02169e82021-06-08 10:05:47 +0530694 /* VMID parameters */
695 u8 lpfc_vmid_host_uuid[LPFC_COMPRESS_VMID_SIZE];
696 u32 max_vmid; /* maximum VMIDs allowed per port */
697 u32 cur_vmid_cnt; /* Current VMID count */
698#define LPFC_MIN_VMID 4
699#define LPFC_MAX_VMID 255
700 u32 vmid_inactivity_timeout; /* Time after which the VMID */
701 /* deregisters from switch */
702 u32 vmid_priority_tagging;
703#define LPFC_VMID_PRIO_TAG_DISABLE 0 /* Disable */
704#define LPFC_VMID_PRIO_TAG_SUP_TARGETS 1 /* Allow supported targets only */
705#define LPFC_VMID_PRIO_TAG_ALL_TARGETS 2 /* Allow all targets */
706 unsigned long *vmid_priority_range;
707#define LPFC_VMID_MAX_PRIORITY_RANGE 256
708#define LPFC_VMID_PRIORITY_BITMAP_SIZE 32
709 u8 vmid_flag;
710#define LPFC_VMID_IN_USE 0x1
711#define LPFC_VMID_ISSUE_QFPA 0x2
712#define LPFC_VMID_QFPA_CMPL 0x4
713#define LPFC_VMID_QOS_ENABLED 0x8
714#define LPFC_VMID_TIMER_ENBLD 0x10
715 struct fc_qfpa_res *qfpa_res;
James Smart51ef4c22007-08-02 11:10:31 -0400716
717 struct fc_vport *fc_vport;
718
Gaurav Srivastava02169e82021-06-08 10:05:47 +0530719 struct lpfc_vmid *vmid;
720 DECLARE_HASHTABLE(hash_table, 8);
721 rwlock_t vmid_lock;
722 struct lpfc_vmid_priority_info vmid_priority;
723
James Smart923e4b62008-12-04 22:40:07 -0500724#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
James Smart51ef4c22007-08-02 11:10:31 -0400725 struct dentry *debug_disc_trc;
726 struct dentry *debug_nodelist;
James Smartbd2cdd52017-02-12 13:52:33 -0800727 struct dentry *debug_nvmestat;
James Smart4c47efc2019-01-28 11:14:25 -0800728 struct dentry *debug_scsistat;
James Smart2fcbc562020-03-22 11:13:02 -0700729 struct dentry *debug_ioktime;
James Smart840eda92020-03-22 11:13:00 -0700730 struct dentry *debug_hdwqstat;
James Smart51ef4c22007-08-02 11:10:31 -0400731 struct dentry *vport_debugfs_root;
732 struct lpfc_debugfs_trc *disc_trc;
733 atomic_t disc_trc_cnt;
734#endif
James Smartea2151b2008-09-07 11:52:10 -0400735 uint8_t stat_data_enabled;
736 uint8_t stat_data_blocked;
James Smartda0436e2009-05-22 14:51:39 -0400737 struct list_head rcv_buffer_list;
James Smart45ed1192009-10-02 15:17:02 -0400738 unsigned long rcv_buffer_time_stamp;
James Smartda0436e2009-05-22 14:51:39 -0400739 uint32_t vport_flag;
740#define STATIC_VPORT 1
James Smartaeb3c812017-04-21 16:05:02 -0700741#define FAWWPN_SET 2
742#define FAWWPN_PARAM_CHG 4
James Smart4258e982015-12-16 18:11:58 -0500743
744 uint16_t fdmi_num_disc;
745 uint32_t fdmi_hba_mask;
746 uint32_t fdmi_port_mask;
James Smart895427b2017-02-12 13:52:30 -0800747
748 /* There is a single nvme instance per vport. */
749 struct nvme_fc_local_port *localport;
750 uint8_t nvmei_support; /* driver supports NVME Initiator */
751 uint32_t last_fcp_wqidx;
James Smartd496b9a2018-10-23 13:41:08 -0700752 uint32_t rcv_flogi_cnt; /* How many unsol FLOGIs ACK'd. */
James Smart2e0fef82007-06-17 19:56:36 -0500753};
754
James Smarted957682007-06-17 19:56:37 -0500755struct hbq_s {
756 uint16_t entry_count; /* Current number of HBQ slots */
James Smarta8adb832007-10-27 13:37:53 -0400757 uint16_t buffer_count; /* Current number of buffers posted */
James Smarted957682007-06-17 19:56:37 -0500758 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
759 uint32_t hbqPutIdx; /* HBQ slot to use */
760 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
James Smart51ef4c22007-08-02 11:10:31 -0400761 void *hbq_virt; /* Virtual ptr to this hbq */
762 struct list_head hbq_buffer_list; /* buffers assigned to this HBQ */
763 /* Callback for HBQ buffer allocation */
764 struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *);
765 /* Callback for HBQ buffer free */
766 void (*hbq_free_buffer) (struct lpfc_hba *,
767 struct hbq_dmabuf *);
James Smarted957682007-06-17 19:56:37 -0500768};
769
James Smart51ef4c22007-08-02 11:10:31 -0400770/* this matches the position in the lpfc_hbq_defs array */
James Smart92d7f7b2007-06-17 19:56:38 -0500771#define LPFC_ELS_HBQ 0
James Smart895427b2017-02-12 13:52:30 -0800772#define LPFC_MAX_HBQS 1
James Smarted957682007-06-17 19:56:37 -0500773
James Smart7af67052007-10-27 13:38:11 -0400774enum hba_temp_state {
775 HBA_NORMAL_TEMP,
776 HBA_OVER_TEMP
777};
778
James Smartdb2378e2008-02-08 18:49:51 -0500779enum intr_type_t {
780 NONE = 0,
781 INTx,
782 MSI,
783 MSIX,
784};
785
James Smart6dd9e312013-01-03 15:43:37 -0500786#define LPFC_CT_CTX_MAX 64
James Smartf1c3b0f2009-07-19 10:01:32 -0400787struct unsol_rcv_ct_ctx {
788 uint32_t ctxt_id;
789 uint32_t SID;
James Smart6dd9e312013-01-03 15:43:37 -0500790 uint32_t valid;
791#define UNSOL_INVALID 0
792#define UNSOL_VALID 1
James Smart7851fe22011-07-22 18:36:52 -0400793 uint16_t oxid;
794 uint16_t rxid;
James Smartf1c3b0f2009-07-19 10:01:32 -0400795};
796
James Smart76a95d72010-11-20 23:11:48 -0500797#define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
798#define LPFC_USER_LINK_SPEED_1G 1 /* 1 Gigabaud */
799#define LPFC_USER_LINK_SPEED_2G 2 /* 2 Gigabaud */
800#define LPFC_USER_LINK_SPEED_4G 4 /* 4 Gigabaud */
801#define LPFC_USER_LINK_SPEED_8G 8 /* 8 Gigabaud */
802#define LPFC_USER_LINK_SPEED_10G 10 /* 10 Gigabaud */
803#define LPFC_USER_LINK_SPEED_16G 16 /* 16 Gigabaud */
James Smartd38dd522015-08-31 16:48:17 -0400804#define LPFC_USER_LINK_SPEED_32G 32 /* 32 Gigabaud */
James Smartfbd8a6b2018-02-22 08:18:45 -0800805#define LPFC_USER_LINK_SPEED_64G 64 /* 64 Gigabaud */
806#define LPFC_USER_LINK_SPEED_MAX LPFC_USER_LINK_SPEED_64G
807
808#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
James Smart76a95d72010-11-20 23:11:48 -0500809
James Smart7ad20aa2011-05-24 11:44:28 -0400810enum nemb_type {
811 nemb_mse = 1,
812 nemb_hbd
813};
814
815enum mbox_type {
816 mbox_rd = 1,
817 mbox_wr
818};
819
820enum dma_type {
821 dma_mbox = 1,
822 dma_ebuf
823};
824
825enum sta_type {
826 sta_pre_addr = 1,
827 sta_pos_addr
828};
829
830struct lpfc_mbox_ext_buf_ctx {
831 uint32_t state;
832#define LPFC_BSG_MBOX_IDLE 0
833#define LPFC_BSG_MBOX_HOST 1
834#define LPFC_BSG_MBOX_PORT 2
835#define LPFC_BSG_MBOX_DONE 3
836#define LPFC_BSG_MBOX_ABTS 4
837 enum nemb_type nembType;
838 enum mbox_type mboxType;
839 uint32_t numBuf;
840 uint32_t mbxTag;
841 uint32_t seqNum;
842 struct lpfc_dmabuf *mbx_dmabuf;
843 struct list_head ext_dmabuf_list;
844};
845
James Smartc4908502019-01-28 11:14:28 -0800846struct lpfc_epd_pool {
847 /* Expedite pool */
848 struct list_head list;
849 u32 count;
850 spinlock_t lock; /* lock for expedite pool */
851};
852
James Smart95bfc6d2019-10-18 14:18:27 -0700853enum ras_state {
854 INACTIVE,
855 REG_INPROGRESS,
856 ACTIVE
857};
858
James Smartd2cc9bc2018-09-10 10:30:50 -0700859struct lpfc_ras_fwlog {
860 uint8_t *fwlog_buff;
861 uint32_t fw_buffcount; /* Buffer size posted to FW */
862#define LPFC_RAS_BUFF_ENTERIES 16 /* Each entry can hold max of 64k */
863#define LPFC_RAS_MAX_ENTRY_SIZE (64 * 1024)
864#define LPFC_RAS_MIN_BUFF_POST_SIZE (256 * 1024)
865#define LPFC_RAS_MAX_BUFF_POST_SIZE (1024 * 1024)
866 uint32_t fw_loglevel; /* Log level set */
867 struct lpfc_dmabuf lwpd;
868 struct list_head fwlog_buff_list;
869
870 /* RAS support status on adapter */
871 bool ras_hwsupport; /* RAS Support available on HW or not */
872 bool ras_enabled; /* Ras Enabled for the function */
873#define LPFC_RAS_DISABLE_LOGGING 0x00
874#define LPFC_RAS_ENABLE_LOGGING 0x01
James Smart95bfc6d2019-10-18 14:18:27 -0700875 enum ras_state state; /* RAS logging running state */
James Smartd2cc9bc2018-09-10 10:30:50 -0700876};
877
Dick Kennedy372c1872020-06-30 14:50:00 -0700878#define DBG_LOG_STR_SZ 256
879#define DBG_LOG_SZ 256
880
881struct dbg_log_ent {
882 char log[DBG_LOG_STR_SZ];
883 u64 t_ns;
884};
885
Dick Kennedy3048e3e2020-05-01 14:43:06 -0700886enum lpfc_irq_chann_mode {
887 /* Assign IRQs to all possible cpus that have hardware queues */
888 NORMAL_MODE,
889
890 /* Assign IRQs only to cpus on the same numa node as HBA */
891 NUMA_MODE,
892
893 /* Assign IRQs only on non-hyperthreaded CPUs. This is the
894 * same as normal_mode, but assign IRQS only on physical CPUs.
895 */
896 NHT_MODE,
897};
898
James Smart2e0fef82007-06-17 19:56:36 -0500899struct lpfc_hba {
James Smart3772a992009-05-22 14:50:54 -0400900 /* SCSI interface function jump table entries */
James Smartc4908502019-01-28 11:14:28 -0800901 struct lpfc_io_buf * (*lpfc_get_scsi_buf)
James Smartace44e42019-01-28 11:14:27 -0800902 (struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
903 struct scsi_cmnd *cmnd);
James Smart3772a992009-05-22 14:50:54 -0400904 int (*lpfc_scsi_prep_dma_buf)
James Smartc4908502019-01-28 11:14:28 -0800905 (struct lpfc_hba *, struct lpfc_io_buf *);
James Smart3772a992009-05-22 14:50:54 -0400906 void (*lpfc_scsi_unprep_dma_buf)
James Smartc4908502019-01-28 11:14:28 -0800907 (struct lpfc_hba *, struct lpfc_io_buf *);
James Smart3772a992009-05-22 14:50:54 -0400908 void (*lpfc_release_scsi_buf)
James Smartc4908502019-01-28 11:14:28 -0800909 (struct lpfc_hba *, struct lpfc_io_buf *);
James Smart3772a992009-05-22 14:50:54 -0400910 void (*lpfc_rampdown_queue_depth)
911 (struct lpfc_hba *);
912 void (*lpfc_scsi_prep_cmnd)
James Smartc4908502019-01-28 11:14:28 -0800913 (struct lpfc_vport *, struct lpfc_io_buf *,
James Smart3772a992009-05-22 14:50:54 -0400914 struct lpfc_nodelist *);
James Smartda255e22020-11-15 11:26:42 -0800915 int (*lpfc_scsi_prep_cmnd_buf)
916 (struct lpfc_vport *vport,
917 struct lpfc_io_buf *lpfc_cmd,
918 uint8_t tmo);
James Smartacd68592012-01-18 16:25:09 -0500919
James Smart3772a992009-05-22 14:50:54 -0400920 /* IOCB interface function jump table entries */
921 int (*__lpfc_sli_issue_iocb)
922 (struct lpfc_hba *, uint32_t,
923 struct lpfc_iocbq *, uint32_t);
James Smart47ff4c52020-11-15 11:26:41 -0800924 int (*__lpfc_sli_issue_fcp_io)
925 (struct lpfc_hba *phba, uint32_t ring_number,
926 struct lpfc_iocbq *piocb, uint32_t flag);
James Smart3772a992009-05-22 14:50:54 -0400927 void (*__lpfc_sli_release_iocbq)(struct lpfc_hba *,
928 struct lpfc_iocbq *);
929 int (*lpfc_hba_down_post)(struct lpfc_hba *phba);
James Smart3772a992009-05-22 14:50:54 -0400930 IOCB_t * (*lpfc_get_iocb_from_iocbq)
931 (struct lpfc_iocbq *);
932 void (*lpfc_scsi_cmd_iocb_cmpl)
933 (struct lpfc_hba *, struct lpfc_iocbq *, struct lpfc_iocbq *);
934
935 /* MBOX interface function jump table entries */
936 int (*lpfc_sli_issue_mbox)
937 (struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
James Smartacd68592012-01-18 16:25:09 -0500938
James Smart3772a992009-05-22 14:50:54 -0400939 /* Slow-path IOCB process function jump table entries */
940 void (*lpfc_sli_handle_slow_ring_event)
941 (struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
942 uint32_t mask);
James Smartacd68592012-01-18 16:25:09 -0500943
James Smart3772a992009-05-22 14:50:54 -0400944 /* INIT device interface function jump table entries */
945 int (*lpfc_sli_hbq_to_firmware)
946 (struct lpfc_hba *, uint32_t, struct hbq_dmabuf *);
947 int (*lpfc_sli_brdrestart)
948 (struct lpfc_hba *);
949 int (*lpfc_sli_brdready)
950 (struct lpfc_hba *, uint32_t);
951 void (*lpfc_handle_eratt)
952 (struct lpfc_hba *);
953 void (*lpfc_stop_port)
954 (struct lpfc_hba *);
James Smart84d1b002010-02-12 14:42:33 -0500955 int (*lpfc_hba_init_link)
James Smart6e7288d2010-06-07 15:23:35 -0400956 (struct lpfc_hba *, uint32_t);
James Smart84d1b002010-02-12 14:42:33 -0500957 int (*lpfc_hba_down_link)
James Smart6e7288d2010-06-07 15:23:35 -0400958 (struct lpfc_hba *, uint32_t);
James Smart7f860592011-03-11 16:05:52 -0500959 int (*lpfc_selective_reset)
960 (struct lpfc_hba *);
James Smart3772a992009-05-22 14:50:54 -0400961
James Smartacd68592012-01-18 16:25:09 -0500962 int (*lpfc_bg_scsi_prep_dma_buf)
James Smartc4908502019-01-28 11:14:28 -0800963 (struct lpfc_hba *, struct lpfc_io_buf *);
James Smartacd68592012-01-18 16:25:09 -0500964 /* Add new entries here */
965
James Smartc4908502019-01-28 11:14:28 -0800966 /* expedite pool */
967 struct lpfc_epd_pool epd_pool;
968
James Smart3772a992009-05-22 14:50:54 -0400969 /* SLI4 specific HBA data structure */
970 struct lpfc_sli4_hba sli4_hba;
971
Dick Kennedyf485c182017-09-29 17:34:34 -0700972 struct workqueue_struct *wq;
James Smart32517fc2019-01-28 11:14:33 -0800973 struct delayed_work eq_delay_work;
Dick Kennedyf485c182017-09-29 17:34:34 -0700974
Dick Kennedy317aeb82020-06-30 14:49:59 -0700975#define LPFC_IDLE_STAT_DELAY 1000
976 struct delayed_work idle_stat_delay_work;
977
James Smart2e0fef82007-06-17 19:56:36 -0500978 struct lpfc_sli sli;
James Smart3772a992009-05-22 14:50:54 -0400979 uint8_t pci_dev_grp; /* lpfc PCI dev group: 0x0, 0x1, 0x2,... */
980 uint32_t sli_rev; /* SLI2, SLI3, or SLI4 */
James Smarted957682007-06-17 19:56:37 -0500981 uint32_t sli3_options; /* Mask of enabled SLI3 options */
James Smart34b02dc2008-08-24 21:49:55 -0400982#define LPFC_SLI3_HBQ_ENABLED 0x01
983#define LPFC_SLI3_NPIV_ENABLED 0x02
984#define LPFC_SLI3_VPORT_TEARDOWN 0x04
985#define LPFC_SLI3_CRP_ENABLED 0x08
James Smart81301a92008-12-04 22:39:46 -0500986#define LPFC_SLI3_BG_ENABLED 0x20
James Smartda0436e2009-05-22 14:51:39 -0400987#define LPFC_SLI3_DSS_ENABLED 0x40
James Smartfedd3b72011-02-16 12:39:24 -0500988#define LPFC_SLI4_PERFH_ENABLED 0x80
989#define LPFC_SLI4_PHWQ_ENABLED 0x100
James Smarted957682007-06-17 19:56:37 -0500990 uint32_t iocb_cmd_size;
991 uint32_t iocb_rsp_size;
James Smart2e0fef82007-06-17 19:56:36 -0500992
James Smart1dc5ec22018-10-23 13:41:11 -0700993 struct lpfc_trunk_link trunk_link;
James Smart2e0fef82007-06-17 19:56:36 -0500994 enum hba_state link_state;
995 uint32_t link_flag; /* link state flags */
James Smart311464e2007-08-02 11:10:37 -0400996#define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
James Smart2e0fef82007-06-17 19:56:36 -0500997 /* This flag is set while issuing */
998 /* INIT_LINK mailbox command */
James Smart92d7f7b2007-06-17 19:56:38 -0500999#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
James Smart1b32f6a2008-02-08 18:49:39 -05001000#define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */
James Smartae9e28f2017-05-15 15:20:51 -07001001#define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
James Smart8aaa7bc2020-10-20 13:27:17 -07001002#define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
1003#define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
James Smart2e0fef82007-06-17 19:56:36 -05001004
James Smart93996272008-08-24 21:50:30 -04001005 uint32_t hba_flag; /* hba generic flags */
1006#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
James Smartda0436e2009-05-22 14:51:39 -04001007#define DEFER_ERATT 0x2 /* Deferred error attention in progress */
James Smart76a95d72010-11-20 23:11:48 -05001008#define HBA_FCOE_MODE 0x4 /* HBA function in FCoE Mode */
James Smart45ed1192009-10-02 15:17:02 -04001009#define HBA_SP_QUEUE_EVT 0x8 /* Slow-path qevt posted to worker thread*/
James Smartda0436e2009-05-22 14:51:39 -04001010#define HBA_POST_RECEIVE_BUFFER 0x10 /* Rcv buffers need to be posted */
James Smart83c6cb12019-10-18 14:18:30 -07001011#define HBA_PERSISTENT_TOPO 0x20 /* Persistent topology support in hba */
James Smarte7dab162020-10-20 13:27:12 -07001012#define ELS_XRI_ABORT_EVENT 0x40 /* ELS_XRI abort event was queued */
James Smartda0436e2009-05-22 14:51:39 -04001013#define ASYNC_EVENT 0x80
James Smarta0c87cb2009-07-19 10:01:10 -04001014#define LINK_DISABLED 0x100 /* Link disabled by user */
James Smarta93ff372010-10-22 11:06:08 -04001015#define FCF_TS_INPROG 0x200 /* FCF table scan in progress */
1016#define FCF_RR_INPROG 0x400 /* FCF roundrobin flogi in progress */
1017#define HBA_FIP_SUPPORT 0x800 /* FIP support in HBA */
1018#define HBA_AER_ENABLED 0x1000 /* AER enabled with HBA */
1019#define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */
James Smart19ca7602010-11-20 23:11:55 -05001020#define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */
James Smartc00f62e2019-08-14 16:57:11 -07001021#define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */
James Smart65791f12016-07-06 12:35:56 -07001022#define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */
James Smartc6918162016-10-13 15:06:16 -07001023#define HBA_FORCED_LINK_SPEED 0x40000 /*
1024 * Firmware supports Forced Link Speed
1025 * capability
1026 */
James Smart25ac2c972021-09-10 16:31:54 -07001027#define HBA_PCI_ERR 0x80000 /* The PCI slot is offline */
James Smart0a9e9682018-11-29 16:09:36 -08001028#define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */
James Smart05116ef2021-12-03 16:26:42 -08001029#define HBA_SHORT_CMF 0x200000 /* shorter CMF timer routine */
James Smart02243832021-08-16 09:28:54 -07001030#define HBA_CGN_DAY_WRAP 0x400000 /* HBA Congestion info day wraps */
James Smart835214f2020-01-27 16:23:03 -08001031#define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */
James Smart02243832021-08-16 09:28:54 -07001032#define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */
James Smartd2f25472021-01-04 10:02:27 -08001033#define HBA_NEEDS_CFG_PORT 0x2000000 /* SLI3 - needs a CONFIG_PORT mbox */
James Smarta22d73b2021-01-04 10:02:38 -08001034#define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */
1035#define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
James Smart9dd83f72021-03-01 09:18:11 -08001036#define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
James Smart895427b2017-02-12 13:52:30 -08001037
James Smart7dd2e2a2021-12-03 16:26:40 -08001038 struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
James Smart45ed1192009-10-02 15:17:02 -04001039 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
James Smart34b02dc2008-08-24 21:49:55 -04001040 struct lpfc_dmabuf slim2p;
James Smart2e0fef82007-06-17 19:56:36 -05001041
James Smart34b02dc2008-08-24 21:49:55 -04001042 MAILBOX_t *mbox;
James Smart7a470272010-03-15 11:25:20 -04001043 uint32_t *mbox_ext;
James Smart7ad20aa2011-05-24 11:44:28 -04001044 struct lpfc_mbox_ext_buf_ctx mbox_ext_buf_ctx;
James Smart93996272008-08-24 21:50:30 -04001045 uint32_t ha_copy;
James Smart34b02dc2008-08-24 21:49:55 -04001046 struct _PCB *pcb;
1047 struct _IOCB *IOCBs;
1048
1049 struct lpfc_dmabuf hbqslimp;
James Smart2e0fef82007-06-17 19:56:36 -05001050
James Smart2e0fef82007-06-17 19:56:36 -05001051 uint16_t pci_cfg_value;
1052
James Smart2e0fef82007-06-17 19:56:36 -05001053 uint8_t fc_linkspeed; /* Link speed after last READ_LA */
1054
1055 uint32_t fc_eventTag; /* event tag for link attention */
James Smart4d9ab992009-10-02 15:16:39 -04001056 uint32_t link_events;
James Smart2e0fef82007-06-17 19:56:36 -05001057
James Smart2e0fef82007-06-17 19:56:36 -05001058 /* These fields used to be binfo */
1059 uint32_t fc_pref_DID; /* preferred D_ID */
James Smart92d7f7b2007-06-17 19:56:38 -05001060 uint8_t fc_pref_ALPA; /* preferred AL_PA */
James Smart12265f62010-10-22 11:05:53 -04001061 uint32_t fc_edtovResol; /* E_D_TOV timer resolution */
James Smart2e0fef82007-06-17 19:56:36 -05001062 uint32_t fc_edtov; /* E_D_TOV timer value */
1063 uint32_t fc_arbtov; /* ARB_TOV timer value */
1064 uint32_t fc_ratov; /* R_A_TOV timer value */
1065 uint32_t fc_rttov; /* R_T_TOV timer value */
1066 uint32_t fc_altov; /* AL_TOV timer value */
1067 uint32_t fc_crtov; /* C_R_TOV timer value */
James Smart2e0fef82007-06-17 19:56:36 -05001068
1069 struct serv_parm fc_fabparam; /* fabric service parameters buffer */
1070 uint8_t alpa_map[128]; /* AL_PA map from READ_LA */
1071
1072 uint32_t lmt;
1073
1074 uint32_t fc_topology; /* link topology, from LINK INIT */
James Smarte74c03c2013-04-17 20:15:19 -04001075 uint32_t fc_topology_changed; /* link topology, from LINK INIT */
James Smart2e0fef82007-06-17 19:56:36 -05001076
1077 struct lpfc_stats fc_stat;
1078
dea31012005-04-17 16:05:31 -05001079 struct lpfc_nodelist fc_fcpnodev; /* nodelist entry for no device */
1080 uint32_t nport_event_cnt; /* timestamp for nlplist entry */
1081
James Smart2e0fef82007-06-17 19:56:36 -05001082 uint8_t wwnn[8];
1083 uint8_t wwpn[8];
dea31012005-04-17 16:05:31 -05001084 uint32_t RandomData[7];
James Smart7bdedb32016-07-06 12:36:00 -07001085 uint8_t fcp_embed_io;
James Smart895427b2017-02-12 13:52:30 -08001086 uint8_t nvmet_support; /* driver supports NVMET */
James Smartf358dd02017-02-12 13:52:34 -08001087#define LPFC_NVMET_MAX_PORTS 32
James Smart7bdedb32016-07-06 12:36:00 -07001088 uint8_t mds_diags_support;
James Smart44fd7fe2017-08-23 16:55:47 -07001089 uint8_t bbcredit_support;
James Smartc176ffa2018-01-30 15:58:46 -08001090 uint8_t enab_exp_wqcq_pages;
James Smart0d8af092019-08-14 16:57:10 -07001091 u8 nsler; /* Firmware supports FC-NVMe-2 SLER */
dea31012005-04-17 16:05:31 -05001092
James Smart3de2a652007-08-02 11:09:59 -04001093 /* HBA Config Parameters */
dea31012005-04-17 16:05:31 -05001094 uint32_t cfg_ack0;
James Smartc4908502019-01-28 11:14:28 -08001095 uint32_t cfg_xri_rebalancing;
James Smartd79c9e92019-08-14 16:57:09 -07001096 uint32_t cfg_xpsgl;
James Smart78b2d852007-08-02 11:10:21 -04001097 uint32_t cfg_enable_npiv;
James Smart19ca7602010-11-20 23:11:55 -05001098 uint32_t cfg_enable_rrq;
dea31012005-04-17 16:05:31 -05001099 uint32_t cfg_topology;
dea31012005-04-17 16:05:31 -05001100 uint32_t cfg_link_speed;
James Smart7d791df2011-07-22 18:37:52 -04001101#define LPFC_FCF_FOV 1 /* Fast fcf failover */
1102#define LPFC_FCF_PRIORITY 2 /* Priority fcf failover */
1103 uint32_t cfg_fcf_failover_policy;
James Smart49aa1432012-08-03 12:36:42 -04001104 uint32_t cfg_fcp_io_sched;
James Smart7ea92eb2018-10-23 13:41:10 -07001105 uint32_t cfg_ns_query;
James Smarta6571c62012-10-31 14:44:42 -04001106 uint32_t cfg_fcp2_no_tgt_reset;
dea31012005-04-17 16:05:31 -05001107 uint32_t cfg_cr_delay;
1108 uint32_t cfg_cr_count;
Jamie Wellnitzcf5bf972006-02-28 22:33:08 -05001109 uint32_t cfg_multi_ring_support;
James Smarta4bc3372006-12-02 13:34:16 -05001110 uint32_t cfg_multi_ring_rctl;
1111 uint32_t cfg_multi_ring_type;
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001112 uint32_t cfg_poll;
1113 uint32_t cfg_poll_tmo;
James Smart0c411222013-09-06 12:22:46 -04001114 uint32_t cfg_task_mgmt_tmo;
James Smart4ff43242006-12-02 13:34:56 -05001115 uint32_t cfg_use_msi;
James Smart0cf07f842017-06-01 21:07:10 -07001116 uint32_t cfg_auto_imax;
James Smartda0436e2009-05-22 14:51:39 -04001117 uint32_t cfg_fcp_imax;
James Smart41b194b2019-05-14 14:58:08 -07001118 uint32_t cfg_force_rscn;
James Smart32517fc2019-01-28 11:14:33 -08001119 uint32_t cfg_cq_poll_threshold;
1120 uint32_t cfg_cq_max_proc_limit;
James Smart7bb03bb2013-04-17 20:19:16 -04001121 uint32_t cfg_fcp_cpu_map;
James Smart77ffd342019-08-15 19:36:49 -07001122 uint32_t cfg_fcp_mq_threshold;
James Smartcdb42be2019-01-28 11:14:21 -08001123 uint32_t cfg_hdw_queue;
James Smart6a828b02019-01-28 11:14:31 -08001124 uint32_t cfg_irq_chann;
James Smartf358dd02017-02-12 13:52:34 -08001125 uint32_t cfg_suppress_rsp;
James Smart895427b2017-02-12 13:52:30 -08001126 uint32_t cfg_nvme_oas;
James Smart4e565cf2018-02-22 08:18:50 -08001127 uint32_t cfg_nvme_embed_cmd;
James Smart2448e482018-04-09 14:24:24 -07001128 uint32_t cfg_nvmet_mrq_post;
James Smart2d7dbc42017-02-12 13:52:35 -08001129 uint32_t cfg_nvmet_mrq;
James Smartf358dd02017-02-12 13:52:34 -08001130 uint32_t cfg_enable_nvmet;
James Smart895427b2017-02-12 13:52:30 -08001131 uint32_t cfg_nvme_enable_fb;
James Smart2d7dbc42017-02-12 13:52:35 -08001132 uint32_t cfg_nvmet_fb_size;
James Smart96f70772013-04-17 20:16:15 -04001133 uint32_t cfg_total_seg_cnt;
dea31012005-04-17 16:05:31 -05001134 uint32_t cfg_sg_seg_cnt;
James Smart4d4c4a42017-04-21 16:05:01 -07001135 uint32_t cfg_nvme_seg_cnt;
James Smart5b9e70b2018-09-10 10:30:42 -07001136 uint32_t cfg_scsi_seg_cnt;
dea31012005-04-17 16:05:31 -05001137 uint32_t cfg_sg_dma_buf_size;
James Smart352e5fd2016-12-30 06:57:47 -08001138 uint64_t cfg_soft_wwnn;
1139 uint64_t cfg_soft_wwpn;
James Smart3de2a652007-08-02 11:09:59 -04001140 uint32_t cfg_hba_queue_depth;
James Smart13815c82008-01-11 01:52:48 -05001141 uint32_t cfg_enable_hba_reset;
1142 uint32_t cfg_enable_hba_heartbeat;
James Smart1ba981f2014-02-20 09:56:45 -05001143 uint32_t cfg_fof;
1144 uint32_t cfg_EnableXLane;
1145 uint8_t cfg_oas_tgt_wwpn[8];
1146 uint8_t cfg_oas_vpt_wwpn[8];
1147 uint32_t cfg_oas_lun_state;
1148#define OAS_LUN_ENABLE 1
1149#define OAS_LUN_DISABLE 0
1150 uint32_t cfg_oas_lun_status;
1151#define OAS_LUN_STATUS_EXISTS 0x01
1152 uint32_t cfg_oas_flags;
1153#define OAS_FIND_ANY_VPORT 0x01
1154#define OAS_FIND_ANY_TARGET 0x02
1155#define OAS_LUN_VALID 0x04
James Smartc92c8412016-07-06 12:36:05 -07001156 uint32_t cfg_oas_priority;
James Smart1ba981f2014-02-20 09:56:45 -05001157 uint32_t cfg_XLanePriority;
James Smart81301a92008-12-04 22:39:46 -05001158 uint32_t cfg_enable_bg;
James Smartb3b98b72016-10-13 15:06:06 -07001159 uint32_t cfg_prot_mask;
1160 uint32_t cfg_prot_guard;
James Smart7a470272010-03-15 11:25:20 -04001161 uint32_t cfg_hostmem_hgp;
James Smartda0436e2009-05-22 14:51:39 -04001162 uint32_t cfg_log_verbose;
James Smartf6e84792019-01-28 11:14:38 -08001163 uint32_t cfg_enable_fc4_type;
James Smartc80b27c2022-02-07 10:05:16 -08001164#define LPFC_ENABLE_FCP 1
1165#define LPFC_ENABLE_NVME 2
1166#define LPFC_ENABLE_BOTH 3
1167#if (IS_ENABLED(CONFIG_NVME_FC))
1168#define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1169#define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
1170#else
1171#define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1172#define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_FCP
1173#endif
James Smart0d878412009-10-02 15:16:56 -04001174 uint32_t cfg_aer_support;
James Smart912e3ac2011-05-24 11:42:11 -04001175 uint32_t cfg_sriov_nr_virtfn;
James Smartc71ab862012-10-31 14:44:33 -04001176 uint32_t cfg_request_firmware_upgrade;
James Smart84d1b002010-02-12 14:42:33 -05001177 uint32_t cfg_suppress_link_up;
James Smartcff261f2013-12-17 20:29:47 -05001178 uint32_t cfg_rrq_xri_bitmap_sz;
James Smart3e49af92021-05-14 12:55:57 -07001179 u32 cfg_fcp_wait_abts_rsp;
James Smart8eb8b962016-07-06 12:36:08 -07001180 uint32_t cfg_delay_discovery;
James Smart12247e82016-07-06 12:36:09 -07001181 uint32_t cfg_sli_mode;
James Smarte40a02c2010-02-26 14:13:54 -05001182#define LPFC_INITIALIZE_LINK 0 /* do normal init_link mbox */
1183#define LPFC_DELAY_INIT_LINK 1 /* layered driver hold off */
1184#define LPFC_DELAY_INIT_LINK_INDEFINITELY 2 /* wait, manual intervention */
James Smart4258e982015-12-16 18:11:58 -05001185 uint32_t cfg_fdmi_on;
1186#define LPFC_FDMI_NO_SUPPORT 0 /* FDMI not supported */
1187#define LPFC_FDMI_SUPPORT 1 /* FDMI supported? */
James Smart4258e982015-12-16 18:11:58 -05001188 uint32_t cfg_enable_SmartSAN;
James Smart7bdedb32016-07-06 12:36:00 -07001189 uint32_t cfg_enable_mds_diags;
James Smartd2cc9bc2018-09-10 10:30:50 -07001190 uint32_t cfg_ras_fwlog_level;
1191 uint32_t cfg_ras_fwlog_buffsize;
1192 uint32_t cfg_ras_fwlog_func;
James Smart1351e692018-02-22 08:18:43 -08001193 uint32_t cfg_enable_bbcr; /* Enable BB Credit Recovery */
1194 uint32_t cfg_enable_dpp; /* Enable Direct Packet Push */
James Smart414abe02018-06-26 08:24:26 -07001195 uint32_t cfg_enable_pbde;
James Smart8aaa7bc2020-10-20 13:27:17 -07001196 uint32_t cfg_enable_mi;
James Smartf358dd02017-02-12 13:52:34 -08001197 struct nvmet_fc_target_port *targetport;
dea31012005-04-17 16:05:31 -05001198 lpfc_vpd_t vpd; /* vital product data */
1199
Gaurav Srivastava02169e82021-06-08 10:05:47 +05301200 u32 cfg_max_vmid; /* maximum VMIDs allowed per port */
1201 u32 cfg_vmid_app_header;
1202#define LPFC_VMID_APP_HEADER_DISABLE 0
1203#define LPFC_VMID_APP_HEADER_ENABLE 1
1204 u32 cfg_vmid_priority_tagging;
1205 u32 cfg_vmid_inactivity_timeout; /* Time after which the VMID */
1206 /* deregisters from switch */
dea31012005-04-17 16:05:31 -05001207 struct pci_dev *pcidev;
1208 struct list_head work_list;
1209 uint32_t work_ha; /* Host Attention Bits for WT */
1210 uint32_t work_ha_mask; /* HA Bits owned by WT */
1211 uint32_t work_hs; /* HS stored in case of ERRAT */
1212 uint32_t work_status[2]; /* Extra status from SLIM */
dea31012005-04-17 16:05:31 -05001213
James Smart5e9d9b82008-06-14 22:52:53 -04001214 wait_queue_head_t work_waitq;
dea31012005-04-17 16:05:31 -05001215 struct task_struct *worker_thread;
James Smartd7c255b2008-08-24 21:50:00 -04001216 unsigned long data_flags;
James Smartd79c9e92019-08-14 16:57:09 -07001217 uint32_t border_sge_num;
dea31012005-04-17 16:05:31 -05001218
James Smart3163f722008-02-08 18:50:25 -05001219 uint32_t hbq_in_use; /* HBQs in use flag */
James Smarted957682007-06-17 19:56:37 -05001220 uint32_t hbq_count; /* Count of configured HBQs */
James Smart92d7f7b2007-06-17 19:56:38 -05001221 struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
James Smarted957682007-06-17 19:56:37 -05001222
James Smart895427b2017-02-12 13:52:30 -08001223 atomic_t fcp_qidx; /* next FCP WQ (RR Policy) */
1224 atomic_t nvme_qidx; /* next NVME WQ (RR Policy) */
James Smart8fa38512009-07-19 10:01:03 -04001225
James Smart115a4122016-07-06 12:36:11 -07001226 phys_addr_t pci_bar0_map; /* Physical address for PCI BAR0 */
1227 phys_addr_t pci_bar1_map; /* Physical address for PCI BAR1 */
1228 phys_addr_t pci_bar2_map; /* Physical address for PCI BAR2 */
dea31012005-04-17 16:05:31 -05001229 void __iomem *slim_memmap_p; /* Kernel memory mapped address for
1230 PCI BAR0 */
1231 void __iomem *ctrl_regs_memmap_p;/* Kernel memory mapped address for
1232 PCI BAR2 */
1233
James Smart962bc512013-01-03 15:44:00 -05001234 void __iomem *pci_bar0_memmap_p; /* Kernel memory mapped address for
1235 PCI BAR0 with dual-ULP support */
1236 void __iomem *pci_bar2_memmap_p; /* Kernel memory mapped address for
1237 PCI BAR2 with dual-ULP support */
1238 void __iomem *pci_bar4_memmap_p; /* Kernel memory mapped address for
1239 PCI BAR4 with dual-ULP support */
1240#define PCI_64BIT_BAR0 0
1241#define PCI_64BIT_BAR2 2
1242#define PCI_64BIT_BAR4 4
dea31012005-04-17 16:05:31 -05001243 void __iomem *MBslimaddr; /* virtual address for mbox cmds */
1244 void __iomem *HAregaddr; /* virtual address for host attn reg */
1245 void __iomem *CAregaddr; /* virtual address for chip attn reg */
1246 void __iomem *HSregaddr; /* virtual address for host status
1247 reg */
1248 void __iomem *HCregaddr; /* virtual address for host ctl reg */
1249
James Smarted957682007-06-17 19:56:37 -05001250 struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */
James Smart34b02dc2008-08-24 21:49:55 -04001251 struct lpfc_pgp *port_gp;
James Smarted957682007-06-17 19:56:37 -05001252 uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */
James Smart92d7f7b2007-06-17 19:56:38 -05001253 uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */
James Smarted957682007-06-17 19:56:37 -05001254
dea31012005-04-17 16:05:31 -05001255 int brd_no; /* FC board number */
dea31012005-04-17 16:05:31 -05001256 char SerialNumber[32]; /* adapter Serial Number */
1257 char OptionROMVersion[32]; /* adapter BIOS / Fcode version */
James Smartb3b4f3e2019-03-12 16:30:23 -07001258 char BIOSVersion[16]; /* Boot BIOS version */
dea31012005-04-17 16:05:31 -05001259 char ModelDesc[256]; /* Model Description */
1260 char ModelName[80]; /* Model Name */
1261 char ProgramType[256]; /* Program Type */
1262 char Port[20]; /* Port No */
1263 uint8_t vpd_flag; /* VPD data flag */
1264
1265#define VPD_MODEL_DESC 0x1 /* valid vpd model description */
1266#define VPD_MODEL_NAME 0x2 /* valid vpd model name */
1267#define VPD_PROGRAM_TYPE 0x4 /* valid vpd program type */
1268#define VPD_PORT 0x8 /* valid vpd port data */
1269#define VPD_MASK 0xf /* mask for any vpd data */
1270
James Smart352e5fd2016-12-30 06:57:47 -08001271 uint8_t soft_wwn_enable;
1272
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001273 struct timer_list fcp_poll_timer;
James Smart93996272008-08-24 21:50:30 -04001274 struct timer_list eratt_poll;
James Smart65791f12016-07-06 12:35:56 -07001275 uint32_t eratt_poll_interval;
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001276
James Smart81301a92008-12-04 22:39:46 -05001277 uint64_t bg_guard_err_cnt;
1278 uint64_t bg_apptag_err_cnt;
1279 uint64_t bg_reftag_err_cnt;
dea31012005-04-17 16:05:31 -05001280
dea31012005-04-17 16:05:31 -05001281 /* fastpath list. */
James Smarta40fc5f2013-04-17 20:17:40 -04001282 spinlock_t scsi_buf_list_get_lock; /* SCSI buf alloc list lock */
1283 spinlock_t scsi_buf_list_put_lock; /* SCSI buf free list lock */
1284 struct list_head lpfc_scsi_buf_list_get;
1285 struct list_head lpfc_scsi_buf_list_put;
dea31012005-04-17 16:05:31 -05001286 uint32_t total_scsi_bufs;
1287 struct list_head lpfc_iocb_list;
1288 uint32_t total_iocbq_bufs;
James Smart19ca7602010-11-20 23:11:55 -05001289 struct list_head active_rrq_list;
James Smart2e0fef82007-06-17 19:56:36 -05001290 spinlock_t hbalock;
James Smart02243832021-08-16 09:28:54 -07001291 struct work_struct unblock_request_work; /* SCSI layer unblock IOs */
dea31012005-04-17 16:05:31 -05001292
Romain Perier771db5c2017-07-06 10:13:05 +02001293 /* dma_mem_pools */
1294 struct dma_pool *lpfc_sg_dma_buf_pool;
1295 struct dma_pool *lpfc_mbuf_pool;
1296 struct dma_pool *lpfc_hrb_pool; /* header receive buffer pool */
1297 struct dma_pool *lpfc_drb_pool; /* data receive buffer pool */
1298 struct dma_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */
1299 struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
James Smartd79c9e92019-08-14 16:57:09 -07001300 struct dma_pool *lpfc_cmd_rsp_buf_pool;
dea31012005-04-17 16:05:31 -05001301 struct lpfc_dma_pool lpfc_mbuf_safety_pool;
1302
1303 mempool_t *mbox_mem_pool;
1304 mempool_t *nlp_mem_pool;
James Smart19ca7602010-11-20 23:11:55 -05001305 mempool_t *rrq_pool;
James Smartcff261f2013-12-17 20:29:47 -05001306 mempool_t *active_rrq_pool;
James.Smart@Emulex.Comf888ba32005-08-10 15:03:01 -04001307
1308 struct fc_host_statistics link_stats;
Dick Kennedy3048e3e2020-05-01 14:43:06 -07001309 enum lpfc_irq_chann_mode irq_chann_mode;
James Smartdb2378e2008-02-08 18:49:51 -05001310 enum intr_type_t intr_type;
James Smart5b75da22008-12-04 22:39:35 -05001311 uint32_t intr_mode;
1312#define LPFC_INTR_ERROR 0xFFFFFFFF
James Smart2e0fef82007-06-17 19:56:36 -05001313 struct list_head port_list;
James Smart523128e2018-09-10 10:30:46 -07001314 spinlock_t port_list_lock; /* lock for port_list mutations */
James Smart549e55c2007-08-02 11:09:51 -04001315 struct lpfc_vport *pport; /* physical lpfc_vport pointer */
1316 uint16_t max_vpi; /* Maximum virtual nports */
James Smart8b47ae62018-11-29 16:09:33 -08001317#define LPFC_MAX_VPI 0xFF /* Max number VPI supported 0 - 0xff */
1318#define LPFC_MAX_VPORTS 0x100 /* Max vports per port, with pport */
James Smartda0436e2009-05-22 14:51:39 -04001319 uint16_t max_vports; /*
1320 * For IOV HBAs max_vpi can change
1321 * after a reset. max_vports is max
1322 * number of vports present. This can
1323 * be greater than max_vpi.
1324 */
1325 uint16_t vpi_base;
1326 uint16_t vfi_base;
James Smart549e55c2007-08-02 11:09:51 -04001327 unsigned long *vpi_bmask; /* vpi allocation table */
James Smart6d368e52011-05-24 11:44:12 -04001328 uint16_t *vpi_ids;
1329 uint16_t vpi_count;
1330 struct list_head lpfc_vpi_blk_list;
James Smart92d7f7b2007-06-17 19:56:38 -05001331
1332 /* Data structure used by fabric iocb scheduler */
1333 struct list_head fabric_iocb_list;
1334 atomic_t fabric_iocb_count;
1335 struct timer_list fabric_block_timer;
1336 unsigned long bit_flags;
1337#define FABRIC_COMANDS_BLOCKED 0
1338 atomic_t num_rsrc_err;
1339 atomic_t num_cmd_success;
1340 unsigned long last_rsrc_error_time;
1341 unsigned long last_ramp_down_time;
James Smart923e4b62008-12-04 22:40:07 -05001342#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
James Smart858c9f62007-06-17 19:56:39 -05001343 struct dentry *hba_debugfs_root;
1344 atomic_t debugfs_vport_count;
James Smartc4908502019-01-28 11:14:28 -08001345 struct dentry *debug_multixri_pools;
James Smart78b2d852007-08-02 11:10:21 -04001346 struct dentry *debug_hbqinfo;
James Smartc95d6c62008-01-11 01:53:23 -05001347 struct dentry *debug_dumpHostSlim;
1348 struct dentry *debug_dumpHBASlim;
James Smartf9bb2da2011-10-10 21:34:11 -04001349 struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
James Smart4ac9b222012-03-01 22:38:29 -05001350 struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
1351 struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
James Smartf9bb2da2011-10-10 21:34:11 -04001352 struct dentry *debug_writeGuard; /* inject write guard_tag errors */
1353 struct dentry *debug_writeApp; /* inject write app_tag errors */
1354 struct dentry *debug_writeRef; /* inject write ref_tag errors */
James Smartacd68592012-01-18 16:25:09 -05001355 struct dentry *debug_readGuard; /* inject read guard_tag errors */
James Smartf9bb2da2011-10-10 21:34:11 -04001356 struct dentry *debug_readApp; /* inject read app_tag errors */
1357 struct dentry *debug_readRef; /* inject read ref_tag errors */
1358
James Smartbd2cdd52017-02-12 13:52:33 -08001359 struct dentry *debug_nvmeio_trc;
1360 struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
James Smart5e5b5112019-01-28 11:14:22 -08001361 struct dentry *debug_hdwqinfo;
James Smart6a828b02019-01-28 11:14:31 -08001362#ifdef LPFC_HDWQ_LOCK_STAT
1363 struct dentry *debug_lockstat;
1364#endif
James Smart9f778702021-08-16 09:28:57 -07001365 struct dentry *debug_cgn_buffer;
1366 struct dentry *debug_rx_monitor;
James Smart95bfc6d2019-10-18 14:18:27 -07001367 struct dentry *debug_ras_log;
James Smartbd2cdd52017-02-12 13:52:33 -08001368 atomic_t nvmeio_trc_cnt;
1369 uint32_t nvmeio_trc_size;
1370 uint32_t nvmeio_trc_output_idx;
1371
James Smartf9bb2da2011-10-10 21:34:11 -04001372 /* T10 DIF error injection */
1373 uint32_t lpfc_injerr_wgrd_cnt;
1374 uint32_t lpfc_injerr_wapp_cnt;
1375 uint32_t lpfc_injerr_wref_cnt;
James Smartacd68592012-01-18 16:25:09 -05001376 uint32_t lpfc_injerr_rgrd_cnt;
James Smartf9bb2da2011-10-10 21:34:11 -04001377 uint32_t lpfc_injerr_rapp_cnt;
1378 uint32_t lpfc_injerr_rref_cnt;
James Smart4ac9b222012-03-01 22:38:29 -05001379 uint32_t lpfc_injerr_nportid;
1380 struct lpfc_name lpfc_injerr_wwpn;
James Smartf9bb2da2011-10-10 21:34:11 -04001381 sector_t lpfc_injerr_lba;
James Smartacd68592012-01-18 16:25:09 -05001382#define LPFC_INJERR_LBA_OFF (sector_t)(-1)
James Smartf9bb2da2011-10-10 21:34:11 -04001383
James Smarta58cbd52007-08-02 11:09:43 -04001384 struct dentry *debug_slow_ring_trc;
1385 struct lpfc_debugfs_trc *slow_ring_trc;
1386 atomic_t slow_ring_trc_cnt;
James Smart2a622bf2011-02-16 12:40:06 -05001387 /* iDiag debugfs sub-directory */
1388 struct dentry *idiag_root;
1389 struct dentry *idiag_pci_cfg;
James Smartb76f2dc2011-07-22 18:37:42 -04001390 struct dentry *idiag_bar_acc;
James Smart2a622bf2011-02-16 12:40:06 -05001391 struct dentry *idiag_que_info;
James Smart86a80842011-04-16 11:03:04 -04001392 struct dentry *idiag_que_acc;
1393 struct dentry *idiag_drb_acc;
James Smartb76f2dc2011-07-22 18:37:42 -04001394 struct dentry *idiag_ctl_acc;
1395 struct dentry *idiag_mbx_acc;
1396 struct dentry *idiag_ext_acc;
James Smart07bcd982017-02-12 13:52:28 -08001397 uint8_t lpfc_idiag_last_eq;
James Smart858c9f62007-06-17 19:56:39 -05001398#endif
James Smartbd2cdd52017-02-12 13:52:33 -08001399 uint16_t nvmeio_trc_on;
James Smart858c9f62007-06-17 19:56:39 -05001400
James Smart0ff10d42008-01-11 01:52:36 -05001401 /* Used for deferred freeing of ELS data buffers */
1402 struct list_head elsbuf;
1403 int elsbuf_cnt;
1404 int elsbuf_prev_cnt;
1405
James Smart57127f12007-10-27 13:37:05 -04001406 uint8_t temp_sensor_support;
James Smart858c9f62007-06-17 19:56:39 -05001407 /* Fields used for heart beat. */
1408 unsigned long last_completion_time;
James Smartbc739052010-08-04 16:11:18 -04001409 unsigned long skipped_hb;
James Smart858c9f62007-06-17 19:56:39 -05001410 struct timer_list hb_tmofunc;
James Smart19ca7602010-11-20 23:11:55 -05001411 struct timer_list rrq_tmr;
James Smart84774a42008-08-24 21:50:06 -04001412 enum hba_temp_state over_temp_state;
James Smart76bb24e2007-10-27 13:38:00 -04001413 /*
1414 * Following bit will be set for all buffer tags which are not
1415 * associated with any HBQ.
1416 */
1417#define QUE_BUFTAG_BIT (1<<31)
1418 uint32_t buffer_tag_count;
James Smart84774a42008-08-24 21:50:06 -04001419 int wait_4_mlo_maint_flg;
1420 wait_queue_head_t wait_4_mlo_m_q;
James Smartea2151b2008-09-07 11:52:10 -04001421 /* data structure used for latency data collection */
1422#define LPFC_NO_BUCKET 0
1423#define LPFC_LINEAR_BUCKET 1
1424#define LPFC_POWER2_BUCKET 2
1425 uint8_t bucket_type;
1426 uint32_t bucket_base;
1427 uint32_t bucket_step;
1428
1429/* Maximum number of events that can be outstanding at any time*/
1430#define LPFC_MAX_EVT_COUNT 512
1431 atomic_t fast_event_count;
James Smart32b97932009-07-19 10:01:21 -04001432 uint32_t fcoe_eventtag;
1433 uint32_t fcoe_eventtag_at_fcf_scan;
James Smart80c17842012-03-01 22:35:45 -05001434 uint32_t fcoe_cvl_eventtag;
1435 uint32_t fcoe_cvl_eventtag_attn;
James Smartda0436e2009-05-22 14:51:39 -04001436 struct lpfc_fcf fcf;
1437 uint8_t fc_map[3];
1438 uint8_t valid_vlan;
1439 uint16_t vlan_id;
1440 struct list_head fcf_conn_rec_list;
James Smartf1c3b0f2009-07-19 10:01:32 -04001441
James Smart0a9e9682018-11-29 16:09:36 -08001442 bool defer_flogi_acc_flag;
1443 uint16_t defer_flogi_acc_rx_id;
1444 uint16_t defer_flogi_acc_ox_id;
1445
James Smart4fede782010-01-26 23:08:55 -05001446 spinlock_t ct_ev_lock; /* synchronize access to ct_ev_waiters */
James Smartf1c3b0f2009-07-19 10:01:32 -04001447 struct list_head ct_ev_waiters;
James Smart6dd9e312013-01-03 15:43:37 -05001448 struct unsol_rcv_ct_ctx ct_ctx[LPFC_CT_CTX_MAX];
James Smartf1c3b0f2009-07-19 10:01:32 -04001449 uint32_t ctx_idx;
Gaurav Srivastava02169e82021-06-08 10:05:47 +05301450 struct timer_list inactive_vmid_poll;
James Smarte2aed292010-02-26 14:15:00 -05001451
James Smartd2cc9bc2018-09-10 10:30:50 -07001452 /* RAS Support */
1453 struct lpfc_ras_fwlog ras_fwlog;
1454
James Smarte2aed292010-02-26 14:15:00 -05001455 uint8_t menlo_flag; /* menlo generic flags */
1456#define HBA_MENLO_SUPPORT 0x1 /* HBA supports menlo commands */
James Smart2a9bf3d2010-06-07 15:24:45 -04001457 uint32_t iocb_cnt;
1458 uint32_t iocb_max;
James Smartd7c47992010-06-08 18:31:54 -04001459 atomic_t sdev_cnt;
James Smart1ba981f2014-02-20 09:56:45 -05001460 spinlock_t devicelock; /* lock for luns list */
1461 mempool_t *device_data_mem_pool;
1462 struct list_head luns;
James Smart310429e2016-07-06 12:35:54 -07001463#define LPFC_TRANSGRESSION_HIGH_TEMPERATURE 0x0080
1464#define LPFC_TRANSGRESSION_LOW_TEMPERATURE 0x0040
1465#define LPFC_TRANSGRESSION_HIGH_VOLTAGE 0x0020
1466#define LPFC_TRANSGRESSION_LOW_VOLTAGE 0x0010
1467#define LPFC_TRANSGRESSION_HIGH_TXBIAS 0x0008
1468#define LPFC_TRANSGRESSION_LOW_TXBIAS 0x0004
1469#define LPFC_TRANSGRESSION_HIGH_TXPOWER 0x0002
1470#define LPFC_TRANSGRESSION_LOW_TXPOWER 0x0001
1471#define LPFC_TRANSGRESSION_HIGH_RXPOWER 0x8000
1472#define LPFC_TRANSGRESSION_LOW_RXPOWER 0x4000
1473 uint16_t sfp_alarm;
1474 uint16_t sfp_warning;
James Smartbd2cdd52017-02-12 13:52:33 -08001475
1476#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
James Smart840eda92020-03-22 11:13:00 -07001477 uint16_t hdwqstat_on;
James Smartbd2cdd52017-02-12 13:52:33 -08001478#define LPFC_CHECK_OFF 0
1479#define LPFC_CHECK_NVME_IO 1
James Smart840eda92020-03-22 11:13:00 -07001480#define LPFC_CHECK_NVMET_IO 2
1481#define LPFC_CHECK_SCSI_IO 4
James Smartbd2cdd52017-02-12 13:52:33 -08001482 uint16_t ktime_on;
1483 uint64_t ktime_data_samples;
1484 uint64_t ktime_status_samples;
1485 uint64_t ktime_last_cmd;
1486 uint64_t ktime_seg1_total;
1487 uint64_t ktime_seg1_min;
1488 uint64_t ktime_seg1_max;
1489 uint64_t ktime_seg2_total;
1490 uint64_t ktime_seg2_min;
1491 uint64_t ktime_seg2_max;
1492 uint64_t ktime_seg3_total;
1493 uint64_t ktime_seg3_min;
1494 uint64_t ktime_seg3_max;
1495 uint64_t ktime_seg4_total;
1496 uint64_t ktime_seg4_min;
1497 uint64_t ktime_seg4_max;
1498 uint64_t ktime_seg5_total;
1499 uint64_t ktime_seg5_min;
1500 uint64_t ktime_seg5_max;
1501 uint64_t ktime_seg6_total;
1502 uint64_t ktime_seg6_min;
1503 uint64_t ktime_seg6_max;
1504 uint64_t ktime_seg7_total;
1505 uint64_t ktime_seg7_min;
1506 uint64_t ktime_seg7_max;
1507 uint64_t ktime_seg8_total;
1508 uint64_t ktime_seg8_min;
1509 uint64_t ktime_seg8_max;
1510 uint64_t ktime_seg9_total;
1511 uint64_t ktime_seg9_min;
1512 uint64_t ktime_seg9_max;
1513 uint64_t ktime_seg10_total;
1514 uint64_t ktime_seg10_min;
1515 uint64_t ktime_seg10_max;
1516#endif
James Smart9064aeb2021-08-16 09:28:50 -07001517 /* CMF objects */
James Smart02243832021-08-16 09:28:54 -07001518 struct lpfc_cgn_stat __percpu *cmf_stat;
1519 uint32_t cmf_interval_rate; /* timer interval limit in ms */
1520 uint32_t cmf_timer_cnt;
James Smartdaebf932021-08-16 09:28:53 -07001521#define LPFC_CMF_INTERVAL 90
James Smart02243832021-08-16 09:28:54 -07001522 uint64_t cmf_link_byte_count;
1523 uint64_t cmf_max_line_rate;
1524 uint64_t cmf_max_bytes_per_interval;
1525 uint64_t cmf_last_sync_bw;
James Smartdaebf932021-08-16 09:28:53 -07001526#define LPFC_CMF_BLK_SIZE 512
James Smart02243832021-08-16 09:28:54 -07001527 struct hrtimer cmf_timer;
1528 atomic_t cmf_bw_wait;
1529 atomic_t cmf_busy;
1530 atomic_t cmf_stop_io; /* To block request and stop IO's */
1531 uint32_t cmf_active_mode;
1532 uint32_t cmf_info_per_interval;
James Smartdaebf932021-08-16 09:28:53 -07001533#define LPFC_MAX_CMF_INFO 32
James Smart02243832021-08-16 09:28:54 -07001534 struct timespec64 cmf_latency; /* Interval congestion timestamp */
1535 uint32_t cmf_last_ts; /* Interval congestion time (ms) */
1536 uint32_t cmf_active_info;
James Smartdaebf932021-08-16 09:28:53 -07001537
James Smart9064aeb2021-08-16 09:28:50 -07001538 /* Signal / FPIN handling for Congestion Mgmt */
1539 u8 cgn_reg_fpin; /* Negotiated value from RDF */
1540 u8 cgn_init_reg_fpin; /* Initial value from READ_CONFIG */
1541#define LPFC_CGN_FPIN_NONE 0x0
1542#define LPFC_CGN_FPIN_WARN 0x1
1543#define LPFC_CGN_FPIN_ALARM 0x2
1544#define LPFC_CGN_FPIN_BOTH (LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM)
1545
1546 u8 cgn_reg_signal; /* Negotiated value from EDC */
1547 u8 cgn_init_reg_signal; /* Initial value from READ_CONFIG */
1548 /* cgn_reg_signal and cgn_init_reg_signal use
1549 * enum fc_edc_cg_signal_cap_types
1550 */
1551 u16 cgn_fpin_frequency;
1552#define LPFC_FPIN_INIT_FREQ 0xffff
1553 u32 cgn_sig_freq;
1554 u32 cgn_acqe_cnt;
1555
James Smart17b27ac2021-08-16 09:28:55 -07001556 /* RX monitor handling for CMF */
1557 struct rxtable_entry *rxtable; /* RX_monitor information */
1558 atomic_t rxtable_idx_head;
1559#define LPFC_RXMONITOR_TABLE_IN_USE (LPFC_MAX_RXMONITOR_ENTRY + 73)
1560 atomic_t rxtable_idx_tail;
1561 atomic_t rx_max_read_cnt; /* Maximum read bytes */
James Smart02243832021-08-16 09:28:54 -07001562 uint64_t rx_block_cnt;
1563
James Smart72df8a452021-08-16 09:28:52 -07001564 /* Congestion parameters from flash */
1565 struct lpfc_cgn_param cgn_p;
1566
James Smart9064aeb2021-08-16 09:28:50 -07001567 /* Statistics counter for ACQE cgn alarms and warnings */
1568 struct lpfc_cgn_acqe_stat cgn_acqe_stat;
1569
1570 /* Congestion buffer information */
James Smart8c42a652021-08-16 09:28:51 -07001571 struct lpfc_dmabuf *cgn_i; /* Congestion Info buffer */
James Smart9064aeb2021-08-16 09:28:50 -07001572 atomic_t cgn_fabric_warn_cnt; /* Total warning cgn events for info */
1573 atomic_t cgn_fabric_alarm_cnt; /* Total alarm cgn events for info */
1574 atomic_t cgn_sync_warn_cnt; /* Total warning events for SYNC wqe */
1575 atomic_t cgn_sync_alarm_cnt; /* Total alarm events for SYNC wqe */
James Smart8c42a652021-08-16 09:28:51 -07001576 atomic_t cgn_driver_evt_cnt; /* Total driver cgn events for fmw */
1577 atomic_t cgn_latency_evt_cnt;
1578 struct timespec64 cgn_daily_ts;
1579 atomic64_t cgn_latency_evt; /* Avg latency per minute */
1580 unsigned long cgn_evt_timestamp;
1581#define LPFC_CGN_TIMER_TO_MIN 60000 /* ms in a minute */
1582 uint32_t cgn_evt_minute;
1583#define LPFC_SEC_MIN 60
1584#define LPFC_MIN_HOUR 60
1585#define LPFC_HOUR_DAY 24
1586#define LPFC_MIN_DAY (LPFC_MIN_HOUR * LPFC_HOUR_DAY)
James Smart93a4d6f2019-11-04 16:57:05 -08001587
1588 struct hlist_node cpuhp; /* used for cpuhp per hba callback */
1589 struct timer_list cpuhp_poll_timer;
1590 struct list_head poll_list; /* slowpath eq polling list */
1591#define LPFC_POLL_HB 1 /* slowpath heartbeat */
1592#define LPFC_POLL_FASTPATH 0 /* called from fastpath */
1593#define LPFC_POLL_SLOWPATH 1 /* called from slowpath */
James Smarte3ba04c2019-12-18 15:58:02 -08001594
1595 char os_host_name[MAXHOSTNAMELEN];
James Smartc90b4482020-03-22 11:12:56 -07001596
1597 /* SCSI host template information - for physical port */
1598 struct scsi_host_template port_template;
1599 /* SCSI host template information - for all vports */
1600 struct scsi_host_template vport_template;
Dick Kennedy372c1872020-06-30 14:50:00 -07001601 atomic_t dbg_log_idx;
1602 atomic_t dbg_log_cnt;
1603 atomic_t dbg_log_dmping;
1604 struct dbg_log_ent dbg_log[DBG_LOG_SZ];
dea31012005-04-17 16:05:31 -05001605};
1606
James Smart17b27ac2021-08-16 09:28:55 -07001607#define LPFC_MAX_RXMONITOR_ENTRY 800
James Smart74a7baa2021-08-16 09:28:58 -07001608#define LPFC_MAX_RXMONITOR_DUMP 32
James Smart17b27ac2021-08-16 09:28:55 -07001609struct rxtable_entry {
James Smarta6269f82021-12-03 16:26:41 -08001610 uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */
James Smart17b27ac2021-08-16 09:28:55 -07001611 uint64_t total_bytes; /* Total no of read bytes requested */
1612 uint64_t rcv_bytes; /* Total no of read bytes completed */
1613 uint64_t avg_io_size;
1614 uint64_t avg_io_latency;/* Average io latency in microseconds */
1615 uint64_t max_read_cnt; /* Maximum read bytes */
1616 uint64_t max_bytes_per_interval;
1617 uint32_t cmf_busy;
1618 uint32_t cmf_info; /* CMF_SYNC_WQE info */
1619 uint32_t io_cnt;
1620 uint32_t timer_utilization;
1621 uint32_t timer_interval;
1622};
1623
James Smart2e0fef82007-06-17 19:56:36 -05001624static inline struct Scsi_Host *
1625lpfc_shost_from_vport(struct lpfc_vport *vport)
1626{
1627 return container_of((void *) vport, struct Scsi_Host, hostdata[0]);
James Smart5b8bd0c2007-04-25 09:52:49 -04001628}
dea31012005-04-17 16:05:31 -05001629
James Smart2e0fef82007-06-17 19:56:36 -05001630static inline void
1631lpfc_set_loopback_flag(struct lpfc_hba *phba)
1632{
1633 if (phba->cfg_topology == FLAGS_LOCAL_LB)
1634 phba->link_flag |= LS_LOOPBACK_MODE;
1635 else
1636 phba->link_flag &= ~LS_LOOPBACK_MODE;
1637}
1638
1639static inline int
1640lpfc_is_link_up(struct lpfc_hba *phba)
1641{
1642 return phba->link_state == LPFC_LINK_UP ||
James Smart92d7f7b2007-06-17 19:56:38 -05001643 phba->link_state == LPFC_CLEAR_LA ||
1644 phba->link_state == LPFC_HBA_READY;
James Smart2e0fef82007-06-17 19:56:36 -05001645}
1646
James Smart5e9d9b82008-06-14 22:52:53 -04001647static inline void
1648lpfc_worker_wake_up(struct lpfc_hba *phba)
1649{
1650 /* Set the lpfc data pending flag */
1651 set_bit(LPFC_DATA_READY, &phba->data_flags);
1652
1653 /* Wake up worker thread */
1654 wake_up(&phba->work_waitq);
1655 return;
1656}
1657
James Smart9940b972011-03-11 16:06:12 -05001658static inline int
1659lpfc_readl(void __iomem *addr, uint32_t *data)
1660{
1661 uint32_t temp;
1662 temp = readl(addr);
1663 if (temp == 0xffffffff)
1664 return -EIO;
1665 *data = temp;
1666 return 0;
1667}
1668
1669static inline int
James Smart93996272008-08-24 21:50:30 -04001670lpfc_sli_read_hs(struct lpfc_hba *phba)
1671{
1672 /*
1673 * There was a link/board error. Read the status register to retrieve
1674 * the error event and process it.
1675 */
1676 phba->sli.slistat.err_attn_event++;
1677
James Smart9940b972011-03-11 16:06:12 -05001678 /* Save status info and check for unplug error */
1679 if (lpfc_readl(phba->HSregaddr, &phba->work_hs) ||
1680 lpfc_readl(phba->MBslimaddr + 0xa8, &phba->work_status[0]) ||
1681 lpfc_readl(phba->MBslimaddr + 0xac, &phba->work_status[1])) {
1682 return -EIO;
1683 }
James Smart93996272008-08-24 21:50:30 -04001684
1685 /* Clear chip Host Attention error bit */
1686 writel(HA_ERATT, phba->HAregaddr);
1687 readl(phba->HAregaddr); /* flush */
1688 phba->pport->stopped = 1;
1689
James Smart9940b972011-03-11 16:06:12 -05001690 return 0;
James Smart93996272008-08-24 21:50:30 -04001691}
James Smart895427b2017-02-12 13:52:30 -08001692
1693static inline struct lpfc_sli_ring *
1694lpfc_phba_elsring(struct lpfc_hba *phba)
1695{
James Smart5a9eeff2018-11-29 16:09:32 -08001696 /* Return NULL if sli_rev has become invalid due to bad fw */
1697 if (phba->sli_rev != LPFC_SLI_REV4 &&
1698 phba->sli_rev != LPFC_SLI_REV3 &&
1699 phba->sli_rev != LPFC_SLI_REV2)
1700 return NULL;
1701
James Smart0c9c6a72017-05-15 15:20:39 -07001702 if (phba->sli_rev == LPFC_SLI_REV4) {
1703 if (phba->sli4_hba.els_wq)
1704 return phba->sli4_hba.els_wq->pring;
1705 else
1706 return NULL;
1707 }
James Smart895427b2017-02-12 13:52:30 -08001708 return &phba->sli.sli3_ring[LPFC_ELS_RING];
1709}
James Smart32517fc2019-01-28 11:14:33 -08001710
1711/**
Dick Kennedy3048e3e2020-05-01 14:43:06 -07001712 * lpfc_next_online_cpu - Finds next online CPU on cpumask
1713 * @mask: Pointer to phba's cpumask member.
James Smartdcaa2132019-11-04 16:57:06 -08001714 * @start: starting cpu index
1715 *
1716 * Note: If no valid cpu found, then nr_cpu_ids is returned.
1717 *
1718 **/
1719static inline unsigned int
Dick Kennedy3048e3e2020-05-01 14:43:06 -07001720lpfc_next_online_cpu(const struct cpumask *mask, unsigned int start)
James Smartdcaa2132019-11-04 16:57:06 -08001721{
1722 unsigned int cpu_it;
1723
Dick Kennedy3048e3e2020-05-01 14:43:06 -07001724 for_each_cpu_wrap(cpu_it, mask, start) {
James Smartdcaa2132019-11-04 16:57:06 -08001725 if (cpu_online(cpu_it))
1726 break;
1727 }
1728
1729 return cpu_it;
1730}
1731/**
James Smart32517fc2019-01-28 11:14:33 -08001732 * lpfc_sli4_mod_hba_eq_delay - update EQ delay
1733 * @phba: Pointer to HBA context object.
1734 * @q: The Event Queue to update.
1735 * @delay: The delay value (in us) to be written.
1736 *
1737 **/
1738static inline void
1739lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba *phba, struct lpfc_queue *eq,
1740 u32 delay)
1741{
1742 struct lpfc_register reg_data;
1743
1744 reg_data.word0 = 0;
1745 bf_set(lpfc_sliport_eqdelay_id, &reg_data, eq->queue_id);
1746 bf_set(lpfc_sliport_eqdelay_delay, &reg_data, delay);
1747 writel(reg_data.word0, phba->sli4_hba.u.if_type2.EQDregaddr);
1748 eq->q_mode = delay;
1749}
James Smartdf3fe762020-02-10 09:31:55 -08001750
1751
1752/*
1753 * Macro that declares tables and a routine to perform enum type to
1754 * ascii string lookup.
1755 *
1756 * Defines a <key,value> table for an enum. Uses xxx_INIT defines for
1757 * the enum to populate the table. Macro defines a routine (named
1758 * by caller) that will search all elements of the table for the key
1759 * and return the name string if found or "Unrecognized" if not found.
1760 */
1761#define DECLARE_ENUM2STR_LOOKUP(routine, enum_name, enum_init) \
1762static struct { \
1763 enum enum_name value; \
1764 char *name; \
1765} fc_##enum_name##_e2str_names[] = enum_init; \
1766static const char *routine(enum enum_name table_key) \
1767{ \
1768 int i; \
1769 char *name = "Unrecognized"; \
1770 \
1771 for (i = 0; i < ARRAY_SIZE(fc_##enum_name##_e2str_names); i++) {\
1772 if (fc_##enum_name##_e2str_names[i].value == table_key) {\
1773 name = fc_##enum_name##_e2str_names[i].name; \
1774 break; \
1775 } \
1776 } \
1777 return name; \
1778}
Gaurav Srivastava02169e82021-06-08 10:05:47 +05301779
1780/**
1781 * lpfc_is_vmid_enabled - returns if VMID is enabled for either switch types
1782 * @phba: Pointer to HBA context object.
1783 *
1784 * Relationship between the enable, target support and if vmid tag is required
1785 * for the particular combination
1786 * ---------------------------------------------------
1787 * Switch Enable Flag Target Support VMID Needed
1788 * ---------------------------------------------------
1789 * App Id 0 NA N
1790 * App Id 1 0 N
1791 * App Id 1 1 Y
1792 * Pr Tag 0 NA N
1793 * Pr Tag 1 0 N
1794 * Pr Tag 1 1 Y
1795 * Pr Tag 2 * Y
1796 ---------------------------------------------------
1797 *
1798 **/
1799static inline int lpfc_is_vmid_enabled(struct lpfc_hba *phba)
1800{
1801 return phba->cfg_vmid_app_header || phba->cfg_vmid_priority_tagging;
1802}