File Index
Files and directories
Sign in
FILE

fnic.h

File preview with syntax highlighting.

linux-6.19.14/drivers/scsi/fnic/fnic.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
  4 * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
  5 */
  6#ifndef _FNIC_H_
  7#define _FNIC_H_
  8
  9#include <linux/interrupt.h>
 10#include <linux/netdevice.h>
 11#include <linux/workqueue.h>
 12#include <linux/bitops.h>
 13#include <scsi/scsi_cmnd.h>
 14#include <scsi/scsi_transport.h>
 15#include <scsi/scsi_transport_fc.h>
 16#include <scsi/fc_frame.h>
 17#include "fnic_io.h"
 18#include "fnic_res.h"
 19#include "fnic_trace.h"
 20#include "fnic_stats.h"
 21#include "vnic_dev.h"
 22#include "vnic_wq.h"
 23#include "vnic_rq.h"
 24#include "vnic_cq.h"
 25#include "vnic_wq_copy.h"
 26#include "vnic_intr.h"
 27#include "vnic_stats.h"
 28#include "vnic_scsi.h"
 29#include "fnic_fdls.h"
 30
 31#define DRV_NAME		"fnic"
 32#define DRV_DESCRIPTION		"Cisco FCoE HBA Driver"
 33#define DRV_VERSION		"1.8.0.2"
 34#define PFX			DRV_NAME ": "
 35#define DFX                     DRV_NAME "%d: "
 36
 37#define FABRIC_LOGO_MAX_RETRY 3
 38#define DESC_CLEAN_LOW_WATERMARK 8
 39#define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD	16 /* UCSM default throttle count */
 40#define FNIC_MIN_IO_REQ			256 /* Min IO throttle count */
 41#define FNIC_MAX_IO_REQ		1024 /* scsi_cmnd tag map entries */
 42#define FNIC_DFLT_IO_REQ        256 /* Default scsi_cmnd tag map entries */
 43#define FNIC_DFLT_QUEUE_DEPTH	256
 44#define	FNIC_STATS_RATE_LIMIT	4 /* limit rate at which stats are pulled up */
 45#define LUN0_DELAY_TIME			9
 46
 47/*
 48 * Tag bits used for special requests.
 49 */
 50#define FNIC_TAG_ABORT		BIT(30)		/* tag bit indicating abort */
 51#define FNIC_TAG_DEV_RST	BIT(29)		/* indicates device reset */
 52#define FNIC_TAG_MASK		(BIT(24) - 1)	/* mask for lookup */
 53#define FNIC_NO_TAG             -1
 54
 55/*
 56 * Command flags to identify the type of command and for other future
 57 * use.
 58 */
 59#define FNIC_NO_FLAGS                   0
 60#define FNIC_IO_INITIALIZED             BIT(0)
 61#define FNIC_IO_ISSUED                  BIT(1)
 62#define FNIC_IO_DONE                    BIT(2)
 63#define FNIC_IO_REQ_NULL                BIT(3)
 64#define FNIC_IO_ABTS_PENDING            BIT(4)
 65#define FNIC_IO_ABORTED                 BIT(5)
 66#define FNIC_IO_ABTS_ISSUED             BIT(6)
 67#define FNIC_IO_TERM_ISSUED             BIT(7)
 68#define FNIC_IO_INTERNAL_TERM_ISSUED    BIT(8)
 69#define FNIC_IO_ABT_TERM_DONE           BIT(9)
 70#define FNIC_IO_ABT_TERM_REQ_NULL       BIT(10)
 71#define FNIC_IO_ABT_TERM_TIMED_OUT      BIT(11)
 72#define FNIC_DEVICE_RESET               BIT(12)  /* Device reset request */
 73#define FNIC_DEV_RST_ISSUED             BIT(13)
 74#define FNIC_DEV_RST_TIMED_OUT          BIT(14)
 75#define FNIC_DEV_RST_ABTS_ISSUED        BIT(15)
 76#define FNIC_DEV_RST_TERM_ISSUED        BIT(16)
 77#define FNIC_DEV_RST_DONE               BIT(17)
 78#define FNIC_DEV_RST_REQ_NULL           BIT(18)
 79#define FNIC_DEV_RST_ABTS_DONE          BIT(19)
 80#define FNIC_DEV_RST_TERM_DONE          BIT(20)
 81#define FNIC_DEV_RST_ABTS_PENDING       BIT(21)
 82
 83#define FNIC_FW_RESET_TIMEOUT        60000	/* mSec   */
 84#define FNIC_FCOE_MAX_CMD_LEN        16
 85/* Retry supported by rport (returned by PRLI service parameters) */
 86#define FNIC_FC_RP_FLAGS_RETRY            0x1
 87
 88/* Cisco vendor id */
 89#define PCI_VENDOR_ID_CISCO						0x1137
 90#define PCI_DEVICE_ID_CISCO_VIC_FC				0x0045	/* fc vnic */
 91
 92/* sereno pcie switch */
 93#define PCI_DEVICE_ID_CISCO_SERENO             0x004e
 94#define PCI_DEVICE_ID_CISCO_CRUZ               0x007a	/* Cruz */
 95#define PCI_DEVICE_ID_CISCO_BODEGA             0x0131	/* Bodega */
 96#define PCI_DEVICE_ID_CISCO_BEVERLY            0x025f	/* Beverly */
 97
 98/* Sereno */
 99#define PCI_SUBDEVICE_ID_CISCO_VASONA			0x004f	/* vasona mezz */
100#define PCI_SUBDEVICE_ID_CISCO_COTATI			0x0084	/* cotati mlom */
101#define PCI_SUBDEVICE_ID_CISCO_LEXINGTON		0x0085	/* lexington pcie */
102#define PCI_SUBDEVICE_ID_CISCO_ICEHOUSE			0x00cd	/* Icehouse */
103#define PCI_SUBDEVICE_ID_CISCO_KIRKWOODLAKE		0x00ce	/* KirkwoodLake pcie */
104#define PCI_SUBDEVICE_ID_CISCO_SUSANVILLE		0x012e	/* Susanville MLOM */
105#define PCI_SUBDEVICE_ID_CISCO_TORRANCE			0x0139	/* Torrance MLOM */
106
107/* Cruz */
108#define PCI_SUBDEVICE_ID_CISCO_CALISTOGA		0x012c	/* Calistoga MLOM */
109#define PCI_SUBDEVICE_ID_CISCO_MOUNTAINVIEW		0x0137	/* Cruz Mezz */
110/* Cruz MountTian SIOC */
111#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN		0x014b
112#define PCI_SUBDEVICE_ID_CISCO_CLEARLAKE		0x014d	/* ClearLake pcie */
113/* Cruz MountTian2 SIOC */
114#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN2		0x0157
115#define PCI_SUBDEVICE_ID_CISCO_CLAREMONT		0x015d	/* Claremont MLOM */
116
117/* Bodega */
118/* VIC 1457 PCIe mLOM */
119#define PCI_SUBDEVICE_ID_CISCO_BRADBURY         0x0218
120#define PCI_SUBDEVICE_ID_CISCO_BRENTWOOD        0x0217	/* VIC 1455 PCIe */
121/* VIC 1487 PCIe mLOM */
122#define PCI_SUBDEVICE_ID_CISCO_BURLINGAME       0x021a
123#define PCI_SUBDEVICE_ID_CISCO_BAYSIDE          0x0219	/* VIC 1485 PCIe */
124/* VIC 1440 Mezz mLOM */
125#define PCI_SUBDEVICE_ID_CISCO_BAKERSFIELD      0x0215
126#define PCI_SUBDEVICE_ID_CISCO_BOONVILLE        0x0216	/* VIC 1480 Mezz */
127#define PCI_SUBDEVICE_ID_CISCO_BENICIA          0x024a	/* VIC 1495 */
128#define PCI_SUBDEVICE_ID_CISCO_BEAUMONT         0x024b	/* VIC 1497 */
129#define PCI_SUBDEVICE_ID_CISCO_BRISBANE         0x02af	/* VIC 1467 */
130#define PCI_SUBDEVICE_ID_CISCO_BENTON           0x02b0	/* VIC 1477 */
131#define PCI_SUBDEVICE_ID_CISCO_TWIN_RIVER       0x02cf	/* VIC 14425 */
132#define PCI_SUBDEVICE_ID_CISCO_TWIN_PEAK        0x02d0	/* VIC 14825 */
133
134/* Beverly */
135#define PCI_SUBDEVICE_ID_CISCO_BERN             0x02de	/* VIC 15420 */
136#define PCI_SUBDEVICE_ID_CISCO_STOCKHOLM        0x02dd	/* VIC 15428 */
137#define PCI_SUBDEVICE_ID_CISCO_KRAKOW           0x02dc	/* VIC 15411 */
138#define PCI_SUBDEVICE_ID_CISCO_LUCERNE          0x02db	/* VIC 15231 */
139#define PCI_SUBDEVICE_ID_CISCO_TURKU            0x02e8	/* VIC 15238 */
140#define PCI_SUBDEVICE_ID_CISCO_TURKU_PLUS       0x02f3	/* VIC 15237 */
141#define PCI_SUBDEVICE_ID_CISCO_ZURICH           0x02df	/* VIC 15230 */
142#define PCI_SUBDEVICE_ID_CISCO_RIGA             0x02e0	/* VIC 15427 */
143#define PCI_SUBDEVICE_ID_CISCO_GENEVA           0x02e1	/* VIC 15422 */
144#define PCI_SUBDEVICE_ID_CISCO_HELSINKI         0x02e4	/* VIC 15235 */
145#define PCI_SUBDEVICE_ID_CISCO_GOTHENBURG       0x02f2	/* VIC 15425 */
146
147struct fnic_pcie_device {
148	u32 device;
149	u8 *desc;
150	u32 subsystem_device;
151	u8 *subsys_desc;
152};
153
154/*
155 * fnic private data per SCSI command.
156 * These fields are locked by the hashed io_req_lock.
157 */
158struct fnic_cmd_priv {
159	struct fnic_io_req *io_req;
160	enum fnic_ioreq_state state;
161	u32 flags;
162	u16 abts_status;
163	u16 lr_status;
164};
165
166static inline struct fnic_cmd_priv *fnic_priv(struct scsi_cmnd *cmd)
167{
168	return scsi_cmd_priv(cmd);
169}
170
171static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)
172{
173	struct fnic_cmd_priv *fcmd = fnic_priv(cmd);
174
175	return ((u64)fcmd->flags << 32) | fcmd->state;
176}
177
178#define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */
179
180#define FNIC_LUN_RESET_TIMEOUT	     10000	/* mSec */
181#define FNIC_HOST_RESET_TIMEOUT	     10000	/* mSec */
182#define FNIC_RMDEVICE_TIMEOUT        1000       /* mSec */
183#define FNIC_HOST_RESET_SETTLE_TIME  30         /* Sec */
184#define FNIC_ABT_TERM_DELAY_TIMEOUT  500        /* mSec */
185
186#define FNIC_MAX_FCP_TARGET     256
187#define FNIC_PCI_OFFSET		2
188/**
189 * state_flags to identify host state along along with fnic's state
190 **/
191#define __FNIC_FLAGS_FWRESET		BIT(0) /* fwreset in progress */
192#define __FNIC_FLAGS_BLOCK_IO		BIT(1) /* IOs are blocked */
193
194#define FNIC_FLAGS_NONE			(0)
195#define FNIC_FLAGS_FWRESET		(__FNIC_FLAGS_FWRESET | \
196					__FNIC_FLAGS_BLOCK_IO)
197
198#define FNIC_FLAGS_IO_BLOCKED		(__FNIC_FLAGS_BLOCK_IO)
199
200#define fnic_set_state_flags(fnicp, st_flags)	\
201	__fnic_set_state_flags(fnicp, st_flags, 0)
202
203#define fnic_clear_state_flags(fnicp, st_flags)  \
204	__fnic_set_state_flags(fnicp, st_flags, 1)
205
206enum reset_states {
207	NOT_IN_PROGRESS = 0,
208	IN_PROGRESS,
209	RESET_ERROR
210};
211
212enum rscn_type {
213	NOT_PC_RSCN = 0,
214	PC_RSCN
215};
216
217enum pc_rscn_handling_status {
218	PC_RSCN_HANDLING_NOT_IN_PROGRESS = 0,
219	PC_RSCN_HANDLING_IN_PROGRESS
220};
221
222enum pc_rscn_handling_feature {
223	PC_RSCN_HANDLING_FEATURE_OFF = 0,
224	PC_RSCN_HANDLING_FEATURE_ON
225};
226
227extern unsigned int fnic_fdmi_support;
228extern unsigned int fnic_log_level;
229extern unsigned int io_completions;
230extern struct workqueue_struct *fnic_event_queue;
231
232extern unsigned int pc_rscn_handling_feature_flag;
233extern spinlock_t reset_fnic_list_lock;
234extern struct list_head reset_fnic_list;
235extern struct workqueue_struct *reset_fnic_work_queue;
236extern struct work_struct reset_fnic_work;
237
238
239#define FNIC_MAIN_LOGGING 0x01
240#define FNIC_FCS_LOGGING 0x02
241#define FNIC_SCSI_LOGGING 0x04
242#define FNIC_ISR_LOGGING 0x08
243
244#define FNIC_CHECK_LOGGING(LEVEL, CMD)				\
245do {								\
246	if (unlikely(fnic_log_level & LEVEL))			\
247		do {						\
248			CMD;					\
249		} while (0);					\
250} while (0)
251
252#define FNIC_MAIN_DBG(kern_level, host, fnic_num, fmt, args...)		\
253	FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING,			\
254			 shost_printk(kern_level, host,			\
255				"fnic<%d>: %s: %d: " fmt, fnic_num,\
256				__func__, __LINE__, ##args);)
257
258#define FNIC_FCS_DBG(kern_level, host, fnic_num, fmt, args...)		\
259	FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING,			\
260			 shost_printk(kern_level, host,			\
261				"fnic<%d>: %s: %d: " fmt, fnic_num,\
262				__func__, __LINE__, ##args);)
263
264#define FNIC_FIP_DBG(kern_level, host, fnic_num, fmt, args...)		\
265	FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING,			\
266			 shost_printk(kern_level, host,			\
267				"fnic<%d>: %s: %d: " fmt, fnic_num,\
268				__func__, __LINE__, ##args);)
269
270#define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...)		\
271	FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING,			\
272			 shost_printk(kern_level, host,			\
273				"fnic<%d>: %s: %d: " fmt, fnic_num,\
274				__func__, __LINE__, ##args);)
275
276#define FNIC_ISR_DBG(kern_level, host, fnic_num, fmt, args...)		\
277	FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING,			\
278			 shost_printk(kern_level, host,			\
279				"fnic<%d>: %s: %d: " fmt, fnic_num,\
280				__func__, __LINE__, ##args);)
281
282#define FNIC_MAIN_NOTE(kern_level, host, fmt, args...)          \
283	shost_printk(kern_level, host, fmt, ##args)
284
285#define FNIC_WQ_COPY_MAX 64
286#define FNIC_WQ_MAX 1
287#define FNIC_RQ_MAX 1
288#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
289#define FNIC_DFLT_IO_COMPLETIONS 256
290
291#define FNIC_MQ_CQ_INDEX        2
292
293extern const char *fnic_state_str[];
294
295enum fnic_intx_intr_index {
296	FNIC_INTX_WQ_RQ_COPYWQ,
297	FNIC_INTX_DUMMY,
298	FNIC_INTX_NOTIFY,
299	FNIC_INTX_ERR,
300	FNIC_INTX_INTR_MAX,
301};
302
303enum fnic_msix_intr_index {
304	FNIC_MSIX_RQ,
305	FNIC_MSIX_WQ,
306	FNIC_MSIX_WQ_COPY,
307	FNIC_MSIX_ERR_NOTIFY = FNIC_MSIX_WQ_COPY + FNIC_WQ_COPY_MAX,
308	FNIC_MSIX_INTR_MAX,
309};
310
311struct fnic_msix_entry {
312	int requested;
313	char devname[IFNAMSIZ + 11];
314	irqreturn_t (*isr)(int, void *);
315	void *devid;
316	int irq_num;
317};
318
319enum fnic_state {
320	FNIC_IN_FC_MODE = 0,
321	FNIC_IN_FC_TRANS_ETH_MODE,
322	FNIC_IN_ETH_MODE,
323	FNIC_IN_ETH_TRANS_FC_MODE,
324};
325
326enum fnic_role_e {
327	FNIC_ROLE_FCP_INITIATOR = 0,
328};
329
330enum fnic_evt {
331	FNIC_EVT_START_VLAN_DISC = 1,
332	FNIC_EVT_START_FCF_DISC = 2,
333	FNIC_EVT_MAX,
334};
335
336struct fnic_frame_list {
337	/*
338	 * Link to frame lists
339	 */
340	struct list_head links;
341	void *fp;
342	int frame_len;
343	int rx_ethhdr_stripped;
344};
345
346struct fnic_event {
347	struct list_head list;
348	struct fnic *fnic;
349	enum fnic_evt event;
350};
351
352struct fnic_cpy_wq {
353	unsigned long hw_lock_flags;
354	u16 active_ioreq_count;
355	u16 ioreq_table_size;
356	____cacheline_aligned struct fnic_io_req **io_req_table;
357};
358
359/* Per-instance private data structure */
360struct fnic {
361	int fnic_num;
362	enum fnic_role_e role;
363	struct fnic_iport_s iport;
364	struct Scsi_Host *host;
365	struct vnic_dev_bar bar0;
366
367	struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX];
368
369	struct vnic_stats *stats;
370	unsigned long stats_time;	/* time of stats update */
371	unsigned long stats_reset_time; /* time of stats reset */
372	struct vnic_nic_cfg *nic_cfg;
373	char name[IFNAMSIZ];
374	struct timer_list notify_timer; /* used for MSI interrupts */
375
376	unsigned int fnic_max_tag_id;
377	unsigned int err_intr_offset;
378	unsigned int link_intr_offset;
379
380	unsigned int wq_count;
381	unsigned int cq_count;
382
383	struct completion reset_completion_wait;
384	struct mutex sgreset_mutex;
385	spinlock_t sgreset_lock; /* lock for sgreset */
386	struct scsi_cmnd *sgreset_sc;
387	struct dentry *fnic_stats_debugfs_host;
388	struct dentry *fnic_stats_debugfs_file;
389	struct dentry *fnic_reset_debugfs_file;
390	unsigned int reset_stats;
391	atomic64_t io_cmpl_skip;
392	struct fnic_stats fnic_stats;
393
394	u32 vlan_hw_insert:1;	        /* let hw insert the tag */
395	u32 in_remove:1;                /* fnic device in removal */
396	u32 stop_rx_link_events:1;      /* stop proc. rx frames, link events */
397
398	struct completion *fw_reset_done;
399	u32 reset_in_progress;
400	atomic_t in_flight;		/* io counter */
401	bool internal_reset_inprogress;
402	u32 _reserved;			/* fill hole */
403	unsigned long state_flags;	/* protected by host lock */
404	enum fnic_state state;
405	spinlock_t fnic_lock;
406	unsigned long lock_flags;
407
408	u16 vlan_id;	                /* VLAN tag including priority */
409	u8 data_src_addr[ETH_ALEN];
410	u64 fcp_input_bytes;		/* internal statistic */
411	u64 fcp_output_bytes;		/* internal statistic */
412	u32 link_down_cnt;
413	u32 soft_reset_count;
414	int link_status;
415
416	struct list_head list;
417	struct list_head links;
418	struct pci_dev *pdev;
419	struct vnic_fc_config config;
420	struct vnic_dev *vdev;
421	unsigned int raw_wq_count;
422	unsigned int wq_copy_count;
423	unsigned int rq_count;
424	int fw_ack_index[FNIC_WQ_COPY_MAX];
425	unsigned short fw_ack_recd[FNIC_WQ_COPY_MAX];
426	unsigned short wq_copy_desc_low[FNIC_WQ_COPY_MAX];
427	unsigned int intr_count;
428	u32 __iomem *legacy_pba;
429	struct fnic_host_tag *tags;
430	mempool_t *io_req_pool;
431	mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
432
433	unsigned int copy_wq_base;
434	struct work_struct link_work;
435	struct work_struct frame_work;
436	struct work_struct flush_work;
437	struct list_head frame_queue;
438	struct list_head tx_queue;
439	mempool_t *frame_pool;
440	mempool_t *frame_elem_pool;
441	struct work_struct tport_work;
442	struct list_head tport_event_list;
443
444	char subsys_desc[14];
445	int subsys_desc_len;
446	int pc_rscn_handling_status;
447
448	/*** FIP related data members  -- start ***/
449	void (*set_vlan)(struct fnic *, u16 vlan);
450	struct work_struct      fip_frame_work;
451	struct work_struct		fip_timer_work;
452	struct list_head		fip_frame_queue;
453	struct timer_list       fip_timer;
454	spinlock_t              vlans_lock;
455	struct timer_list retry_fip_timer;
456	struct timer_list fcs_ka_timer;
457	struct timer_list enode_ka_timer;
458	struct timer_list vn_ka_timer;
459	struct list_head vlan_list;
460	/*** FIP related data members  -- end ***/
461
462	/* copy work queue cache line section */
463	____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX];
464	____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX];
465
466	/* completion queue cache line section */
467	____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
468
469	spinlock_t wq_copy_lock[FNIC_WQ_COPY_MAX];
470
471	/* work queue cache line section */
472	____cacheline_aligned struct vnic_wq wq[FNIC_WQ_MAX];
473	spinlock_t wq_lock[FNIC_WQ_MAX];
474
475	/* receive queue cache line section */
476	____cacheline_aligned struct vnic_rq rq[FNIC_RQ_MAX];
477
478	/* interrupt resource cache line section */
479	____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX];
480};
481
482extern struct workqueue_struct *fnic_event_queue;
483extern struct workqueue_struct *fnic_fip_queue;
484extern const struct attribute_group *fnic_host_groups[];
485
486void fnic_clear_intr_mode(struct fnic *fnic);
487int fnic_set_intr_mode(struct fnic *fnic);
488int fnic_set_intr_mode_msix(struct fnic *fnic);
489void fnic_free_intr(struct fnic *fnic);
490int fnic_request_intr(struct fnic *fnic);
491
492void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf);
493void fnic_handle_frame(struct work_struct *work);
494void fnic_tport_event_handler(struct work_struct *work);
495void fnic_handle_link(struct work_struct *work);
496void fnic_handle_event(struct work_struct *work);
497void fdls_reclaim_oxid_handler(struct work_struct *work);
498void fdls_schedule_oxid_free(struct fnic_iport_s *iport, uint16_t *active_oxid);
499void fdls_schedule_oxid_free_retry_work(struct work_struct *work);
500int fnic_rq_cmpl_handler(struct fnic *fnic, int);
501int fnic_alloc_rq_frame(struct vnic_rq *rq);
502void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
503void fnic_flush_tx(struct work_struct *work);
504void fnic_update_mac_locked(struct fnic *, u8 *new);
505
506int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
507int fnic_abort_cmd(struct scsi_cmnd *);
508int fnic_device_reset(struct scsi_cmnd *);
509int fnic_eh_host_reset_handler(struct scsi_cmnd *sc);
510int fnic_host_reset(struct Scsi_Host *shost);
511void fnic_reset(struct Scsi_Host *shost);
512int fnic_issue_fc_host_lip(struct Scsi_Host *shost);
513void fnic_get_host_port_state(struct Scsi_Host *shost);
514void fnic_scsi_fcpio_reset(struct fnic *fnic);
515int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index);
516int fnic_wq_cmpl_handler(struct fnic *fnic, int);
517int fnic_flogi_reg_handler(struct fnic *fnic, u32);
518void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
519				  struct fcpio_host_req *desc);
520int fnic_fw_reset_handler(struct fnic *fnic);
521void fnic_terminate_rport_io(struct fc_rport *);
522const char *fnic_state_to_str(unsigned int state);
523void fnic_mq_map_queues_cpus(struct Scsi_Host *host);
524void fnic_log_q_error(struct fnic *fnic);
525void fnic_handle_link_event(struct fnic *fnic);
526int fnic_stats_debugfs_init(struct fnic *fnic);
527void fnic_stats_debugfs_remove(struct fnic *fnic);
528int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);
529
530void fnic_handle_fip_frame(struct work_struct *work);
531void fnic_reset_work_handler(struct work_struct *work);
532void fnic_handle_fip_event(struct fnic *fnic);
533void fnic_fcoe_reset_vlans(struct fnic *fnic);
534extern void fnic_handle_fip_timer(struct timer_list *t);
535
536static inline int
537fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags)
538{
539	return ((fnic->state_flags & st_flags) == st_flags);
540}
541void __fnic_set_state_flags(struct fnic *, unsigned long, unsigned long);
542void fnic_dump_fchost_stats(struct Scsi_Host *, struct fc_host_statistics *);
543void fnic_free_txq(struct list_head *head);
544int fnic_get_desc_by_devid(struct pci_dev *pdev, char **desc,
545						   char **subsys_desc);
546void fnic_fdls_link_status_change(struct fnic *fnic, int linkup);
547void fnic_delete_fcp_tports(struct fnic *fnic);
548void fnic_flush_tport_event_list(struct fnic *fnic);
549int fnic_count_ioreqs_wq(struct fnic *fnic, u32 hwq, u32 portid);
550unsigned int fnic_count_ioreqs(struct fnic *fnic, u32 portid);
551unsigned int fnic_count_all_ioreqs(struct fnic *fnic);
552unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq,
553						  struct scsi_device *device);
554unsigned int fnic_count_lun_ioreqs(struct fnic *fnic,
555					   struct scsi_device *device);
556void fnic_scsi_unload(struct fnic *fnic);
557void fnic_scsi_unload_cleanup(struct fnic *fnic);
558int fnic_get_debug_info(struct stats_debug_info *info,
559			struct fnic *fnic);
560
561struct fnic_scsi_iter_data {
562	struct fnic *fnic;
563	void *data1;
564	void *data2;
565	bool (*fn)(struct fnic *fnic, struct scsi_cmnd *sc,
566			void *data1, void *data2);
567};
568
569static inline bool
570fnic_io_iter_handler(struct scsi_cmnd *sc, void *iter_data)
571{
572	struct fnic_scsi_iter_data *iter = iter_data;
573
574	return iter->fn(iter->fnic, sc, iter->data1, iter->data2);
575}
576
577static inline void
578fnic_scsi_io_iter(struct fnic *fnic,
579		bool (*fn)(struct fnic *fnic, struct scsi_cmnd *sc,
580				void *data1, void *data2),
581		void *data1, void *data2)
582{
583	struct fnic_scsi_iter_data iter_data = {
584		.fn = fn,
585		.fnic = fnic,
586		.data1 = data1,
587		.data2 = data2,
588	};
589	scsi_host_busy_iter(fnic->host, fnic_io_iter_handler, &iter_data);
590}
591
592#ifdef FNIC_DEBUG
593static inline void
594fnic_debug_dump(struct fnic *fnic, uint8_t *u8arr, int len)
595{
596	int i;
597
598	for (i = 0; i < len; i = i+8) {
599		FNIC_FCS_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
600		    "%d: %02x %02x %02x %02x %02x %02x %02x %02x", i / 8,
601		    u8arr[i + 0], u8arr[i + 1], u8arr[i + 2], u8arr[i + 3],
602		    u8arr[i + 4], u8arr[i + 5], u8arr[i + 6], u8arr[i + 7]);
603	}
604}
605
606static inline void
607fnic_debug_dump_fc_frame(struct fnic *fnic, struct fc_frame_header *fchdr,
608				int len, char *pfx)
609{
610	uint32_t s_id, d_id;
611
612	s_id = ntoh24(fchdr->fh_s_id);
613	d_id = ntoh24(fchdr->fh_d_id);
614	FNIC_FCS_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
615		"%s packet contents: sid/did/type/oxid = 0x%x/0x%x/0x%x/0x%x (len = %d)\n",
616		pfx, s_id, d_id, fchdr->fh_type,
617		FNIC_STD_GET_OX_ID(fchdr), len);
618
619	fnic_debug_dump(fnic, (uint8_t *)fchdr, len);
620
621}
622#else /* FNIC_DEBUG */
623static inline void
624fnic_debug_dump(struct fnic *fnic, uint8_t *u8arr, int len) {}
625static inline void
626fnic_debug_dump_fc_frame(struct fnic *fnic, struct fc_frame_header *fchdr,
627				uint32_t len, char *pfx) {}
628#endif /* FNIC_DEBUG */
629#endif /* _FNIC_H_ */
~/ Read-only file preview.