xref: /kernel/linux/linux-5.10/drivers/scsi/snic/snic.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2014 Cisco Systems, Inc.  All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify
58c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
68c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
98c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
108c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
118c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
128c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
148c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
158c2ecf20Sopenharmony_ci * SOFTWARE.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef _SNIC_H_
198c2ecf20Sopenharmony_ci#define _SNIC_H_
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <linux/module.h>
228c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
238c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
248c2ecf20Sopenharmony_ci#include <linux/bitops.h>
258c2ecf20Sopenharmony_ci#include <linux/mempool.h>
268c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h>
278c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
288c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#include "snic_disc.h"
318c2ecf20Sopenharmony_ci#include "snic_io.h"
328c2ecf20Sopenharmony_ci#include "snic_res.h"
338c2ecf20Sopenharmony_ci#include "snic_trc.h"
348c2ecf20Sopenharmony_ci#include "snic_stats.h"
358c2ecf20Sopenharmony_ci#include "vnic_dev.h"
368c2ecf20Sopenharmony_ci#include "vnic_wq.h"
378c2ecf20Sopenharmony_ci#include "vnic_cq.h"
388c2ecf20Sopenharmony_ci#include "vnic_intr.h"
398c2ecf20Sopenharmony_ci#include "vnic_stats.h"
408c2ecf20Sopenharmony_ci#include "vnic_snic.h"
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define SNIC_DRV_NAME		"snic"
438c2ecf20Sopenharmony_ci#define SNIC_DRV_DESCRIPTION	"Cisco SCSI NIC Driver"
448c2ecf20Sopenharmony_ci#define SNIC_DRV_VERSION	"0.0.1.18"
458c2ecf20Sopenharmony_ci#define PFX			SNIC_DRV_NAME ":"
468c2ecf20Sopenharmony_ci#define DFX			SNIC_DRV_NAME "%d: "
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define DESC_CLEAN_LOW_WATERMARK	8
498c2ecf20Sopenharmony_ci#define SNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16 /* UCSM default throttle count */
508c2ecf20Sopenharmony_ci#define SNIC_MAX_IO_REQ			50 /* scsi_cmnd tag map entries */
518c2ecf20Sopenharmony_ci#define SNIC_MIN_IO_REQ			8  /* Min IO throttle count */
528c2ecf20Sopenharmony_ci#define SNIC_IO_LOCKS			64 /* IO locks: power of 2 */
538c2ecf20Sopenharmony_ci#define SNIC_DFLT_QUEUE_DEPTH		32 /* Default Queue Depth */
548c2ecf20Sopenharmony_ci#define SNIC_MAX_QUEUE_DEPTH		64 /* Max Queue Depth */
558c2ecf20Sopenharmony_ci#define SNIC_DFLT_CMD_TIMEOUT		90 /* Extended tmo for FW */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/*
588c2ecf20Sopenharmony_ci * Tag bits used for special requests.
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ci#define SNIC_TAG_ABORT		BIT(30)		/* Tag indicating abort */
618c2ecf20Sopenharmony_ci#define SNIC_TAG_DEV_RST	BIT(29)		/* Tag for device reset */
628c2ecf20Sopenharmony_ci#define SNIC_TAG_IOCTL_DEV_RST	BIT(28)		/* Tag for User Device Reset */
638c2ecf20Sopenharmony_ci#define SNIC_TAG_MASK		(BIT(24) - 1)	/* Mask for lookup */
648c2ecf20Sopenharmony_ci#define SNIC_NO_TAG		-1
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/*
678c2ecf20Sopenharmony_ci * Command flags to identify the type of command and for other future use
688c2ecf20Sopenharmony_ci */
698c2ecf20Sopenharmony_ci#define SNIC_NO_FLAGS			0
708c2ecf20Sopenharmony_ci#define SNIC_IO_INITIALIZED		BIT(0)
718c2ecf20Sopenharmony_ci#define SNIC_IO_ISSUED			BIT(1)
728c2ecf20Sopenharmony_ci#define SNIC_IO_DONE			BIT(2)
738c2ecf20Sopenharmony_ci#define SNIC_IO_REQ_NULL		BIT(3)
748c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_PENDING		BIT(4)
758c2ecf20Sopenharmony_ci#define SNIC_IO_ABORTED			BIT(5)
768c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_ISSUED		BIT(6)
778c2ecf20Sopenharmony_ci#define SNIC_IO_TERM_ISSUED		BIT(7)
788c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_TIMEDOUT		BIT(8)
798c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_TERM_DONE		BIT(9)
808c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_TERM_REQ_NULL	BIT(10)
818c2ecf20Sopenharmony_ci#define SNIC_IO_ABTS_TERM_TIMEDOUT	BIT(11)
828c2ecf20Sopenharmony_ci#define SNIC_IO_INTERNAL_TERM_PENDING	BIT(12)
838c2ecf20Sopenharmony_ci#define SNIC_IO_INTERNAL_TERM_ISSUED	BIT(13)
848c2ecf20Sopenharmony_ci#define SNIC_DEVICE_RESET		BIT(14)
858c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_ISSUED		BIT(15)
868c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_TIMEDOUT		BIT(16)
878c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_ABTS_ISSUED	BIT(17)
888c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_TERM_ISSUED	BIT(18)
898c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_DONE		BIT(19)
908c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_REQ_NULL		BIT(20)
918c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_ABTS_DONE		BIT(21)
928c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_TERM_DONE		BIT(22)
938c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_ABTS_PENDING	BIT(23)
948c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_PENDING		BIT(24)
958c2ecf20Sopenharmony_ci#define SNIC_DEV_RST_NOTSUP		BIT(25)
968c2ecf20Sopenharmony_ci#define SNIC_SCSI_CLEANUP		BIT(26)
978c2ecf20Sopenharmony_ci#define SNIC_HOST_RESET_ISSUED		BIT(27)
988c2ecf20Sopenharmony_ci#define SNIC_HOST_RESET_CMD_TERM	\
998c2ecf20Sopenharmony_ci	(SNIC_DEV_RST_NOTSUP | SNIC_SCSI_CLEANUP | SNIC_HOST_RESET_ISSUED)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define SNIC_ABTS_TIMEOUT		30000		/* msec */
1028c2ecf20Sopenharmony_ci#define SNIC_LUN_RESET_TIMEOUT		30000		/* msec */
1038c2ecf20Sopenharmony_ci#define SNIC_HOST_RESET_TIMEOUT		30000		/* msec */
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/*
1078c2ecf20Sopenharmony_ci * These are protected by the hashed req_lock.
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_ci#define CMD_SP(Cmnd)		\
1108c2ecf20Sopenharmony_ci	(((struct snic_internal_io_state *)scsi_cmd_priv(Cmnd))->rqi)
1118c2ecf20Sopenharmony_ci#define CMD_STATE(Cmnd)		\
1128c2ecf20Sopenharmony_ci	(((struct snic_internal_io_state *)scsi_cmd_priv(Cmnd))->state)
1138c2ecf20Sopenharmony_ci#define CMD_ABTS_STATUS(Cmnd)	\
1148c2ecf20Sopenharmony_ci	(((struct snic_internal_io_state *)scsi_cmd_priv(Cmnd))->abts_status)
1158c2ecf20Sopenharmony_ci#define CMD_LR_STATUS(Cmnd)	\
1168c2ecf20Sopenharmony_ci	(((struct snic_internal_io_state *)scsi_cmd_priv(Cmnd))->lr_status)
1178c2ecf20Sopenharmony_ci#define CMD_FLAGS(Cmnd)	\
1188c2ecf20Sopenharmony_ci	(((struct snic_internal_io_state *)scsi_cmd_priv(Cmnd))->flags)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define SNIC_INVALID_CODE 0x100	/* Hdr Status val unused by firmware */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#define SNIC_MAX_TARGET			256
1238c2ecf20Sopenharmony_ci#define SNIC_FLAGS_NONE			(0)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* snic module params */
1268c2ecf20Sopenharmony_ciextern unsigned int snic_max_qdepth;
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/* snic debugging */
1298c2ecf20Sopenharmony_ciextern unsigned int snic_log_level;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define SNIC_MAIN_LOGGING	0x1
1328c2ecf20Sopenharmony_ci#define SNIC_SCSI_LOGGING	0x2
1338c2ecf20Sopenharmony_ci#define SNIC_ISR_LOGGING	0x8
1348c2ecf20Sopenharmony_ci#define SNIC_DESC_LOGGING	0x10
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define SNIC_CHECK_LOGGING(LEVEL, CMD)		\
1378c2ecf20Sopenharmony_cido {						\
1388c2ecf20Sopenharmony_ci	if (unlikely(snic_log_level & LEVEL))	\
1398c2ecf20Sopenharmony_ci		do {				\
1408c2ecf20Sopenharmony_ci			CMD;			\
1418c2ecf20Sopenharmony_ci		} while (0);			\
1428c2ecf20Sopenharmony_ci} while (0)
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#define SNIC_MAIN_DBG(host, fmt, args...)	\
1458c2ecf20Sopenharmony_ci	SNIC_CHECK_LOGGING(SNIC_MAIN_LOGGING,		\
1468c2ecf20Sopenharmony_ci		shost_printk(KERN_INFO, host, fmt, ## args);)
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define SNIC_SCSI_DBG(host, fmt, args...)	\
1498c2ecf20Sopenharmony_ci	SNIC_CHECK_LOGGING(SNIC_SCSI_LOGGING,		\
1508c2ecf20Sopenharmony_ci		shost_printk(KERN_INFO, host, fmt, ##args);)
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci#define SNIC_DISC_DBG(host, fmt, args...)	\
1538c2ecf20Sopenharmony_ci	SNIC_CHECK_LOGGING(SNIC_SCSI_LOGGING,		\
1548c2ecf20Sopenharmony_ci		shost_printk(KERN_INFO, host, fmt, ##args);)
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define SNIC_ISR_DBG(host, fmt, args...)	\
1578c2ecf20Sopenharmony_ci	SNIC_CHECK_LOGGING(SNIC_ISR_LOGGING,		\
1588c2ecf20Sopenharmony_ci		shost_printk(KERN_INFO, host, fmt, ##args);)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define SNIC_HOST_ERR(host, fmt, args...)		\
1618c2ecf20Sopenharmony_ci	shost_printk(KERN_ERR, host, fmt, ##args)
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci#define SNIC_HOST_INFO(host, fmt, args...)		\
1648c2ecf20Sopenharmony_ci	shost_printk(KERN_INFO, host, fmt, ##args)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#define SNIC_INFO(fmt, args...)				\
1678c2ecf20Sopenharmony_ci	pr_info(PFX fmt, ## args)
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define SNIC_DBG(fmt, args...)				\
1708c2ecf20Sopenharmony_ci	pr_info(PFX fmt, ## args)
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#define SNIC_ERR(fmt, args...)				\
1738c2ecf20Sopenharmony_ci	pr_err(PFX fmt, ## args)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#ifdef DEBUG
1768c2ecf20Sopenharmony_ci#define SNIC_BUG_ON(EXPR) \
1778c2ecf20Sopenharmony_ci	({ \
1788c2ecf20Sopenharmony_ci		if (EXPR) { \
1798c2ecf20Sopenharmony_ci			SNIC_ERR("SNIC BUG(%s)\n", #EXPR); \
1808c2ecf20Sopenharmony_ci			BUG_ON(EXPR); \
1818c2ecf20Sopenharmony_ci		} \
1828c2ecf20Sopenharmony_ci	})
1838c2ecf20Sopenharmony_ci#else
1848c2ecf20Sopenharmony_ci#define SNIC_BUG_ON(EXPR) \
1858c2ecf20Sopenharmony_ci	({ \
1868c2ecf20Sopenharmony_ci		if (EXPR) { \
1878c2ecf20Sopenharmony_ci			SNIC_ERR("SNIC BUG(%s) at %s : %d\n", \
1888c2ecf20Sopenharmony_ci				 #EXPR, __func__, __LINE__); \
1898c2ecf20Sopenharmony_ci			WARN_ON_ONCE(EXPR); \
1908c2ecf20Sopenharmony_ci		} \
1918c2ecf20Sopenharmony_ci	})
1928c2ecf20Sopenharmony_ci#endif
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/* Soft assert */
1958c2ecf20Sopenharmony_ci#define SNIC_ASSERT_NOT_IMPL(EXPR) \
1968c2ecf20Sopenharmony_ci	({ \
1978c2ecf20Sopenharmony_ci		if (EXPR) {\
1988c2ecf20Sopenharmony_ci			SNIC_INFO("Functionality not impl'ed at %s:%d\n", \
1998c2ecf20Sopenharmony_ci				  __func__, __LINE__); \
2008c2ecf20Sopenharmony_ci			WARN_ON_ONCE(EXPR); \
2018c2ecf20Sopenharmony_ci		} \
2028c2ecf20Sopenharmony_ci	 })
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ciextern const char *snic_state_str[];
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_cienum snic_intx_intr_index {
2088c2ecf20Sopenharmony_ci	SNIC_INTX_WQ_RQ_COPYWQ,
2098c2ecf20Sopenharmony_ci	SNIC_INTX_ERR,
2108c2ecf20Sopenharmony_ci	SNIC_INTX_NOTIFY,
2118c2ecf20Sopenharmony_ci	SNIC_INTX_INTR_MAX,
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cienum snic_msix_intr_index {
2158c2ecf20Sopenharmony_ci	SNIC_MSIX_WQ,
2168c2ecf20Sopenharmony_ci	SNIC_MSIX_IO_CMPL,
2178c2ecf20Sopenharmony_ci	SNIC_MSIX_ERR_NOTIFY,
2188c2ecf20Sopenharmony_ci	SNIC_MSIX_INTR_MAX,
2198c2ecf20Sopenharmony_ci};
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define SNIC_INTRHDLR_NAMSZ	(2 * IFNAMSIZ)
2228c2ecf20Sopenharmony_cistruct snic_msix_entry {
2238c2ecf20Sopenharmony_ci	int requested;
2248c2ecf20Sopenharmony_ci	char devname[SNIC_INTRHDLR_NAMSZ];
2258c2ecf20Sopenharmony_ci	irqreturn_t (*isr)(int, void *);
2268c2ecf20Sopenharmony_ci	void *devid;
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cienum snic_state {
2308c2ecf20Sopenharmony_ci	SNIC_INIT = 0,
2318c2ecf20Sopenharmony_ci	SNIC_ERROR,
2328c2ecf20Sopenharmony_ci	SNIC_ONLINE,
2338c2ecf20Sopenharmony_ci	SNIC_OFFLINE,
2348c2ecf20Sopenharmony_ci	SNIC_FWRESET,
2358c2ecf20Sopenharmony_ci};
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci#define SNIC_WQ_MAX		1
2388c2ecf20Sopenharmony_ci#define SNIC_CQ_IO_CMPL_MAX	1
2398c2ecf20Sopenharmony_ci#define SNIC_CQ_MAX		(SNIC_WQ_MAX + SNIC_CQ_IO_CMPL_MAX)
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* firmware version information */
2428c2ecf20Sopenharmony_cistruct snic_fw_info {
2438c2ecf20Sopenharmony_ci	u32	fw_ver;
2448c2ecf20Sopenharmony_ci	u32	hid;			/* u16 hid | u16 vnic id */
2458c2ecf20Sopenharmony_ci	u32	max_concur_ios;		/* max concurrent ios */
2468c2ecf20Sopenharmony_ci	u32	max_sgs_per_cmd;	/* max sgls per IO */
2478c2ecf20Sopenharmony_ci	u32	max_io_sz;		/* max io size supported */
2488c2ecf20Sopenharmony_ci	u32	hba_cap;		/* hba capabilities */
2498c2ecf20Sopenharmony_ci	u32	max_tgts;		/* max tgts supported */
2508c2ecf20Sopenharmony_ci	u16	io_tmo;			/* FW Extended timeout */
2518c2ecf20Sopenharmony_ci	struct completion *wait;	/* protected by snic lock*/
2528c2ecf20Sopenharmony_ci};
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/*
2558c2ecf20Sopenharmony_ci * snic_work item : defined to process asynchronous events
2568c2ecf20Sopenharmony_ci */
2578c2ecf20Sopenharmony_cistruct snic_work {
2588c2ecf20Sopenharmony_ci	struct work_struct work;
2598c2ecf20Sopenharmony_ci	u16	ev_id;
2608c2ecf20Sopenharmony_ci	u64	*ev_data;
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci/*
2648c2ecf20Sopenharmony_ci * snic structure to represent SCSI vNIC
2658c2ecf20Sopenharmony_ci */
2668c2ecf20Sopenharmony_cistruct snic {
2678c2ecf20Sopenharmony_ci	/* snic specific members */
2688c2ecf20Sopenharmony_ci	struct list_head list;
2698c2ecf20Sopenharmony_ci	char name[IFNAMSIZ];
2708c2ecf20Sopenharmony_ci	atomic_t state;
2718c2ecf20Sopenharmony_ci	spinlock_t snic_lock;
2728c2ecf20Sopenharmony_ci	struct completion *remove_wait;
2738c2ecf20Sopenharmony_ci	bool in_remove;
2748c2ecf20Sopenharmony_ci	bool stop_link_events;		/* stop processing link events */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	/* discovery related */
2778c2ecf20Sopenharmony_ci	struct snic_disc disc;
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	/* Scsi Host info */
2808c2ecf20Sopenharmony_ci	struct Scsi_Host *shost;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	/* vnic related structures */
2838c2ecf20Sopenharmony_ci	struct vnic_dev_bar bar0;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	struct vnic_stats *stats;
2868c2ecf20Sopenharmony_ci	unsigned long stats_time;
2878c2ecf20Sopenharmony_ci	unsigned long stats_reset_time;
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	struct vnic_dev *vdev;
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	/* hw resource info */
2928c2ecf20Sopenharmony_ci	unsigned int wq_count;
2938c2ecf20Sopenharmony_ci	unsigned int cq_count;
2948c2ecf20Sopenharmony_ci	unsigned int intr_count;
2958c2ecf20Sopenharmony_ci	unsigned int err_intr_offset;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	int link_status; /* retrieved from svnic_dev_link_status() */
2988c2ecf20Sopenharmony_ci	u32 link_down_cnt;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	/* pci related */
3018c2ecf20Sopenharmony_ci	struct pci_dev *pdev;
3028c2ecf20Sopenharmony_ci	struct snic_msix_entry msix[SNIC_MSIX_INTR_MAX];
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	/* io related info */
3058c2ecf20Sopenharmony_ci	mempool_t *req_pool[SNIC_REQ_MAX_CACHES]; /* (??) */
3068c2ecf20Sopenharmony_ci	____cacheline_aligned spinlock_t io_req_lock[SNIC_IO_LOCKS];
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	/* Maintain snic specific commands, cmds with no tag in spl_cmd_list */
3098c2ecf20Sopenharmony_ci	____cacheline_aligned spinlock_t spl_cmd_lock;
3108c2ecf20Sopenharmony_ci	struct list_head spl_cmd_list;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	unsigned int max_tag_id;
3138c2ecf20Sopenharmony_ci	atomic_t ios_inflight;		/* io in flight counter */
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	struct vnic_snic_config config;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	struct work_struct link_work;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	/* firmware information */
3208c2ecf20Sopenharmony_ci	struct snic_fw_info fwinfo;
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	/* Work for processing Target related work */
3238c2ecf20Sopenharmony_ci	struct work_struct tgt_work;
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	/* Work for processing Discovery */
3268c2ecf20Sopenharmony_ci	struct work_struct disc_work;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	/* stats related */
3298c2ecf20Sopenharmony_ci	unsigned int reset_stats;
3308c2ecf20Sopenharmony_ci	atomic64_t io_cmpl_skip;
3318c2ecf20Sopenharmony_ci	struct snic_stats s_stats;	/* Per SNIC driver stats */
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	/* platform specific */
3348c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_SNIC_DEBUG_FS
3358c2ecf20Sopenharmony_ci	struct dentry *stats_host;	/* Per snic debugfs root */
3368c2ecf20Sopenharmony_ci	struct dentry *stats_file;	/* Per snic debugfs file */
3378c2ecf20Sopenharmony_ci	struct dentry *reset_stats_file;/* Per snic reset stats file */
3388c2ecf20Sopenharmony_ci#endif
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	/* completion queue cache line section */
3418c2ecf20Sopenharmony_ci	____cacheline_aligned struct vnic_cq cq[SNIC_CQ_MAX];
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	/* work queue cache line section */
3448c2ecf20Sopenharmony_ci	____cacheline_aligned struct vnic_wq wq[SNIC_WQ_MAX];
3458c2ecf20Sopenharmony_ci	spinlock_t wq_lock[SNIC_WQ_MAX];
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci	/* interrupt resource cache line section */
3488c2ecf20Sopenharmony_ci	____cacheline_aligned struct vnic_intr intr[SNIC_MSIX_INTR_MAX];
3498c2ecf20Sopenharmony_ci}; /* end of snic structure */
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci/*
3528c2ecf20Sopenharmony_ci * SNIC Driver's Global Data
3538c2ecf20Sopenharmony_ci */
3548c2ecf20Sopenharmony_cistruct snic_global {
3558c2ecf20Sopenharmony_ci	struct list_head snic_list;
3568c2ecf20Sopenharmony_ci	spinlock_t snic_list_lock;
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	struct kmem_cache *req_cache[SNIC_REQ_MAX_CACHES];
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	struct workqueue_struct *event_q;
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_SNIC_DEBUG_FS
3638c2ecf20Sopenharmony_ci	/* debugfs related global data */
3648c2ecf20Sopenharmony_ci	struct dentry *trc_root;
3658c2ecf20Sopenharmony_ci	struct dentry *stats_root;
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci	struct snic_trc trc ____cacheline_aligned;
3688c2ecf20Sopenharmony_ci#endif
3698c2ecf20Sopenharmony_ci};
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ciextern struct snic_global *snic_glob;
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ciint snic_glob_init(void);
3748c2ecf20Sopenharmony_civoid snic_glob_cleanup(void);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ciextern struct workqueue_struct *snic_event_queue;
3778c2ecf20Sopenharmony_ciextern struct device_attribute *snic_attrs[];
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ciint snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
3808c2ecf20Sopenharmony_ciint snic_abort_cmd(struct scsi_cmnd *);
3818c2ecf20Sopenharmony_ciint snic_device_reset(struct scsi_cmnd *);
3828c2ecf20Sopenharmony_ciint snic_host_reset(struct scsi_cmnd *);
3838c2ecf20Sopenharmony_ciint snic_reset(struct Scsi_Host *, struct scsi_cmnd *);
3848c2ecf20Sopenharmony_civoid snic_shutdown_scsi_cleanup(struct snic *);
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ciint snic_request_intr(struct snic *);
3888c2ecf20Sopenharmony_civoid snic_free_intr(struct snic *);
3898c2ecf20Sopenharmony_ciint snic_set_intr_mode(struct snic *);
3908c2ecf20Sopenharmony_civoid snic_clear_intr_mode(struct snic *);
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ciint snic_fwcq_cmpl_handler(struct snic *, int);
3938c2ecf20Sopenharmony_ciint snic_wq_cmpl_handler(struct snic *, int);
3948c2ecf20Sopenharmony_civoid snic_free_wq_buf(struct vnic_wq *, struct vnic_wq_buf *);
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_civoid snic_log_q_error(struct snic *);
3988c2ecf20Sopenharmony_civoid snic_handle_link_event(struct snic *);
3998c2ecf20Sopenharmony_civoid snic_handle_link(struct work_struct *);
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ciint snic_queue_exch_ver_req(struct snic *);
4028c2ecf20Sopenharmony_civoid snic_io_exch_ver_cmpl_handler(struct snic *, struct snic_fw_req *);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ciint snic_queue_wq_desc(struct snic *, void *os_buf, u16 len);
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_civoid snic_handle_untagged_req(struct snic *, struct snic_req_info *);
4078c2ecf20Sopenharmony_civoid snic_release_untagged_req(struct snic *, struct snic_req_info *);
4088c2ecf20Sopenharmony_civoid snic_free_all_untagged_reqs(struct snic *);
4098c2ecf20Sopenharmony_ciint snic_get_conf(struct snic *);
4108c2ecf20Sopenharmony_civoid snic_set_state(struct snic *, enum snic_state);
4118c2ecf20Sopenharmony_ciint snic_get_state(struct snic *);
4128c2ecf20Sopenharmony_ciconst char *snic_state_to_str(unsigned int);
4138c2ecf20Sopenharmony_civoid snic_hex_dump(char *, char *, int);
4148c2ecf20Sopenharmony_civoid snic_print_desc(const char *fn, char *os_buf, int len);
4158c2ecf20Sopenharmony_ciconst char *show_opcode_name(int val);
4168c2ecf20Sopenharmony_ci#endif /* _SNIC_H */
417