1e6550b3eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
25df6d737SAbhijeet Joglekar /*
35df6d737SAbhijeet Joglekar * Copyright 2008 Cisco Systems, Inc. All rights reserved.
45df6d737SAbhijeet Joglekar * Copyright 2007 Nuova Systems, Inc. All rights reserved.
55df6d737SAbhijeet Joglekar */
65df6d737SAbhijeet Joglekar #ifndef _FNIC_H_
75df6d737SAbhijeet Joglekar #define _FNIC_H_
85df6d737SAbhijeet Joglekar
95df6d737SAbhijeet Joglekar #include <linux/interrupt.h>
105df6d737SAbhijeet Joglekar #include <linux/netdevice.h>
115df6d737SAbhijeet Joglekar #include <linux/workqueue.h>
12a737b88dSAndrew Morton #include <linux/bitops.h>
135df6d737SAbhijeet Joglekar #include <scsi/libfc.h>
1478112e55SJoe Eykholt #include <scsi/libfcoe.h>
155df6d737SAbhijeet Joglekar #include "fnic_io.h"
165df6d737SAbhijeet Joglekar #include "fnic_res.h"
174d7007b4SHiral Patel #include "fnic_trace.h"
1867125b02SHiral Patel #include "fnic_stats.h"
195df6d737SAbhijeet Joglekar #include "vnic_dev.h"
205df6d737SAbhijeet Joglekar #include "vnic_wq.h"
215df6d737SAbhijeet Joglekar #include "vnic_rq.h"
225df6d737SAbhijeet Joglekar #include "vnic_cq.h"
235df6d737SAbhijeet Joglekar #include "vnic_wq_copy.h"
245df6d737SAbhijeet Joglekar #include "vnic_intr.h"
255df6d737SAbhijeet Joglekar #include "vnic_stats.h"
265df6d737SAbhijeet Joglekar #include "vnic_scsi.h"
275df6d737SAbhijeet Joglekar
285df6d737SAbhijeet Joglekar #define DRV_NAME "fnic"
295df6d737SAbhijeet Joglekar #define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
3053021c19SKaran Tilak Kumar #define DRV_VERSION "1.7.0.0"
315df6d737SAbhijeet Joglekar #define PFX DRV_NAME ": "
325df6d737SAbhijeet Joglekar #define DFX DRV_NAME "%d: "
335df6d737SAbhijeet Joglekar
345df6d737SAbhijeet Joglekar #define DESC_CLEAN_LOW_WATERMARK 8
35fc85799eSHiral Patel #define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16 /* UCSM default throttle count */
36fc85799eSHiral Patel #define FNIC_MIN_IO_REQ 256 /* Min IO throttle count */
37c8ff03c6SHiral Shah #define FNIC_MAX_IO_REQ 1024 /* scsi_cmnd tag map entries */
38c8ff03c6SHiral Shah #define FNIC_DFLT_IO_REQ 256 /* Default scsi_cmnd tag map entries */
391c552626SSatish Kharat #define FNIC_DFLT_QUEUE_DEPTH 256
405df6d737SAbhijeet Joglekar #define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */
41da87bfabSVasu Dev
425df6d737SAbhijeet Joglekar /*
435df6d737SAbhijeet Joglekar * Tag bits used for special requests.
445df6d737SAbhijeet Joglekar */
455df6d737SAbhijeet Joglekar #define FNIC_TAG_ABORT BIT(30) /* tag bit indicating abort */
465df6d737SAbhijeet Joglekar #define FNIC_TAG_DEV_RST BIT(29) /* indicates device reset */
475df6d737SAbhijeet Joglekar #define FNIC_TAG_MASK (BIT(24) - 1) /* mask for lookup */
485df6d737SAbhijeet Joglekar #define FNIC_NO_TAG -1
495df6d737SAbhijeet Joglekar
505df6d737SAbhijeet Joglekar /*
5103298552SHiral Patel * Command flags to identify the type of command and for other future
5203298552SHiral Patel * use.
5303298552SHiral Patel */
5403298552SHiral Patel #define FNIC_NO_FLAGS 0
5514eb5d90SHiral Patel #define FNIC_IO_INITIALIZED BIT(0)
5614eb5d90SHiral Patel #define FNIC_IO_ISSUED BIT(1)
5714eb5d90SHiral Patel #define FNIC_IO_DONE BIT(2)
5814eb5d90SHiral Patel #define FNIC_IO_REQ_NULL BIT(3)
5914eb5d90SHiral Patel #define FNIC_IO_ABTS_PENDING BIT(4)
6014eb5d90SHiral Patel #define FNIC_IO_ABORTED BIT(5)
6114eb5d90SHiral Patel #define FNIC_IO_ABTS_ISSUED BIT(6)
6214eb5d90SHiral Patel #define FNIC_IO_TERM_ISSUED BIT(7)
6314eb5d90SHiral Patel #define FNIC_IO_INTERNAL_TERM_ISSUED BIT(8)
6414eb5d90SHiral Patel #define FNIC_IO_ABT_TERM_DONE BIT(9)
6514eb5d90SHiral Patel #define FNIC_IO_ABT_TERM_REQ_NULL BIT(10)
6614eb5d90SHiral Patel #define FNIC_IO_ABT_TERM_TIMED_OUT BIT(11)
6714eb5d90SHiral Patel #define FNIC_DEVICE_RESET BIT(12) /* Device reset request */
6814eb5d90SHiral Patel #define FNIC_DEV_RST_ISSUED BIT(13)
6914eb5d90SHiral Patel #define FNIC_DEV_RST_TIMED_OUT BIT(14)
7014eb5d90SHiral Patel #define FNIC_DEV_RST_ABTS_ISSUED BIT(15)
7114eb5d90SHiral Patel #define FNIC_DEV_RST_TERM_ISSUED BIT(16)
7214eb5d90SHiral Patel #define FNIC_DEV_RST_DONE BIT(17)
7314eb5d90SHiral Patel #define FNIC_DEV_RST_REQ_NULL BIT(18)
7414eb5d90SHiral Patel #define FNIC_DEV_RST_ABTS_DONE BIT(19)
7514eb5d90SHiral Patel #define FNIC_DEV_RST_TERM_DONE BIT(20)
7614eb5d90SHiral Patel #define FNIC_DEV_RST_ABTS_PENDING BIT(21)
7703298552SHiral Patel
7803298552SHiral Patel /*
79924cb24dSBart Van Assche * fnic private data per SCSI command.
805df6d737SAbhijeet Joglekar * These fields are locked by the hashed io_req_lock.
815df6d737SAbhijeet Joglekar */
82924cb24dSBart Van Assche struct fnic_cmd_priv {
83924cb24dSBart Van Assche struct fnic_io_req *io_req;
84924cb24dSBart Van Assche enum fnic_ioreq_state state;
85924cb24dSBart Van Assche u32 flags;
86924cb24dSBart Van Assche u16 abts_status;
87924cb24dSBart Van Assche u16 lr_status;
88924cb24dSBart Van Assche };
89924cb24dSBart Van Assche
fnic_priv(struct scsi_cmnd * cmd)90924cb24dSBart Van Assche static inline struct fnic_cmd_priv *fnic_priv(struct scsi_cmnd *cmd)
91924cb24dSBart Van Assche {
92924cb24dSBart Van Assche return scsi_cmd_priv(cmd);
93924cb24dSBart Van Assche }
94924cb24dSBart Van Assche
fnic_flags_and_state(struct scsi_cmnd * cmd)95924cb24dSBart Van Assche static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)
96924cb24dSBart Van Assche {
97924cb24dSBart Van Assche struct fnic_cmd_priv *fcmd = fnic_priv(cmd);
98924cb24dSBart Van Assche
99924cb24dSBart Van Assche return ((u64)fcmd->flags << 32) | fcmd->state;
100924cb24dSBart Van Assche }
1015df6d737SAbhijeet Joglekar
1025df6d737SAbhijeet Joglekar #define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */
1035df6d737SAbhijeet Joglekar
1045df6d737SAbhijeet Joglekar #define FNIC_LUN_RESET_TIMEOUT 10000 /* mSec */
1055df6d737SAbhijeet Joglekar #define FNIC_HOST_RESET_TIMEOUT 10000 /* mSec */
1065df6d737SAbhijeet Joglekar #define FNIC_RMDEVICE_TIMEOUT 1000 /* mSec */
1075df6d737SAbhijeet Joglekar #define FNIC_HOST_RESET_SETTLE_TIME 30 /* Sec */
10803298552SHiral Patel #define FNIC_ABT_TERM_DELAY_TIMEOUT 500 /* mSec */
1095df6d737SAbhijeet Joglekar
1105df6d737SAbhijeet Joglekar #define FNIC_MAX_FCP_TARGET 256
11152f6e196SKaran Tilak Kumar #define FNIC_PCI_OFFSET 2
11203298552SHiral Patel /**
11303298552SHiral Patel * state_flags to identify host state along along with fnic's state
11403298552SHiral Patel **/
11503298552SHiral Patel #define __FNIC_FLAGS_FWRESET BIT(0) /* fwreset in progress */
11603298552SHiral Patel #define __FNIC_FLAGS_BLOCK_IO BIT(1) /* IOs are blocked */
11703298552SHiral Patel
11803298552SHiral Patel #define FNIC_FLAGS_NONE (0)
11903298552SHiral Patel #define FNIC_FLAGS_FWRESET (__FNIC_FLAGS_FWRESET | \
12003298552SHiral Patel __FNIC_FLAGS_BLOCK_IO)
12103298552SHiral Patel
12203298552SHiral Patel #define FNIC_FLAGS_IO_BLOCKED (__FNIC_FLAGS_BLOCK_IO)
12303298552SHiral Patel
12403298552SHiral Patel #define fnic_set_state_flags(fnicp, st_flags) \
12503298552SHiral Patel __fnic_set_state_flags(fnicp, st_flags, 0)
12603298552SHiral Patel
12703298552SHiral Patel #define fnic_clear_state_flags(fnicp, st_flags) \
12803298552SHiral Patel __fnic_set_state_flags(fnicp, st_flags, 1)
12903298552SHiral Patel
1305df6d737SAbhijeet Joglekar extern unsigned int fnic_log_level;
13118244e94SSatish Kharat extern unsigned int io_completions;
1325df6d737SAbhijeet Joglekar
1335df6d737SAbhijeet Joglekar #define FNIC_MAIN_LOGGING 0x01
1345df6d737SAbhijeet Joglekar #define FNIC_FCS_LOGGING 0x02
1355df6d737SAbhijeet Joglekar #define FNIC_SCSI_LOGGING 0x04
1365df6d737SAbhijeet Joglekar #define FNIC_ISR_LOGGING 0x08
1375df6d737SAbhijeet Joglekar
1385df6d737SAbhijeet Joglekar #define FNIC_CHECK_LOGGING(LEVEL, CMD) \
1395df6d737SAbhijeet Joglekar do { \
1405df6d737SAbhijeet Joglekar if (unlikely(fnic_log_level & LEVEL)) \
1415df6d737SAbhijeet Joglekar do { \
1425df6d737SAbhijeet Joglekar CMD; \
1435df6d737SAbhijeet Joglekar } while (0); \
1445df6d737SAbhijeet Joglekar } while (0)
1455df6d737SAbhijeet Joglekar
1463df9dd0dSKaran Tilak Kumar #define FNIC_MAIN_DBG(kern_level, host, fnic_num, fmt, args...) \
1475df6d737SAbhijeet Joglekar FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \
1483df9dd0dSKaran Tilak Kumar shost_printk(kern_level, host, \
1493df9dd0dSKaran Tilak Kumar "fnic<%d>: %s: %d: " fmt, fnic_num,\
1503df9dd0dSKaran Tilak Kumar __func__, __LINE__, ##args);)
1515df6d737SAbhijeet Joglekar
1523df9dd0dSKaran Tilak Kumar #define FNIC_FCS_DBG(kern_level, host, fnic_num, fmt, args...) \
1535df6d737SAbhijeet Joglekar FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
1543df9dd0dSKaran Tilak Kumar shost_printk(kern_level, host, \
1553df9dd0dSKaran Tilak Kumar "fnic<%d>: %s: %d: " fmt, fnic_num,\
1563df9dd0dSKaran Tilak Kumar __func__, __LINE__, ##args);)
1575df6d737SAbhijeet Joglekar
15855cf7152SKaran Tilak Kumar #define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...) \
1595df6d737SAbhijeet Joglekar FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
16055cf7152SKaran Tilak Kumar shost_printk(kern_level, host, \
16155cf7152SKaran Tilak Kumar "fnic<%d>: %s: %d: " fmt, fnic_num,\
16255cf7152SKaran Tilak Kumar __func__, __LINE__, ##args);)
1635df6d737SAbhijeet Joglekar
1648a8449caSKaran Tilak Kumar #define FNIC_ISR_DBG(kern_level, host, fnic_num, fmt, args...) \
1655df6d737SAbhijeet Joglekar FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
1668a8449caSKaran Tilak Kumar shost_printk(kern_level, host, \
1678a8449caSKaran Tilak Kumar "fnic<%d>: %s: %d: " fmt, fnic_num,\
1688a8449caSKaran Tilak Kumar __func__, __LINE__, ##args);)
1695df6d737SAbhijeet Joglekar
1701adee040SNarsimhulu Musini #define FNIC_MAIN_NOTE(kern_level, host, fmt, args...) \
1711adee040SNarsimhulu Musini shost_printk(kern_level, host, fmt, ##args)
1721adee040SNarsimhulu Musini
173554a1482SKaran Tilak Kumar #define FNIC_WQ_COPY_MAX 64
174554a1482SKaran Tilak Kumar #define FNIC_WQ_MAX 1
175554a1482SKaran Tilak Kumar #define FNIC_RQ_MAX 1
176554a1482SKaran Tilak Kumar #define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
177554a1482SKaran Tilak Kumar #define FNIC_DFLT_IO_COMPLETIONS 256
178554a1482SKaran Tilak Kumar
179554a1482SKaran Tilak Kumar #define FNIC_MQ_CQ_INDEX 2
180554a1482SKaran Tilak Kumar
1815df6d737SAbhijeet Joglekar extern const char *fnic_state_str[];
1825df6d737SAbhijeet Joglekar
1835df6d737SAbhijeet Joglekar enum fnic_intx_intr_index {
1845df6d737SAbhijeet Joglekar FNIC_INTX_WQ_RQ_COPYWQ,
185554a1482SKaran Tilak Kumar FNIC_INTX_DUMMY,
1865df6d737SAbhijeet Joglekar FNIC_INTX_NOTIFY,
187554a1482SKaran Tilak Kumar FNIC_INTX_ERR,
1885df6d737SAbhijeet Joglekar FNIC_INTX_INTR_MAX,
1895df6d737SAbhijeet Joglekar };
1905df6d737SAbhijeet Joglekar
1915df6d737SAbhijeet Joglekar enum fnic_msix_intr_index {
1925df6d737SAbhijeet Joglekar FNIC_MSIX_RQ,
1935df6d737SAbhijeet Joglekar FNIC_MSIX_WQ,
1945df6d737SAbhijeet Joglekar FNIC_MSIX_WQ_COPY,
195554a1482SKaran Tilak Kumar FNIC_MSIX_ERR_NOTIFY = FNIC_MSIX_WQ_COPY + FNIC_WQ_COPY_MAX,
1965df6d737SAbhijeet Joglekar FNIC_MSIX_INTR_MAX,
1975df6d737SAbhijeet Joglekar };
1985df6d737SAbhijeet Joglekar
1995df6d737SAbhijeet Joglekar struct fnic_msix_entry {
2005df6d737SAbhijeet Joglekar int requested;
201514e59c1SArnd Bergmann char devname[IFNAMSIZ + 11];
2025df6d737SAbhijeet Joglekar irqreturn_t (*isr)(int, void *);
2035df6d737SAbhijeet Joglekar void *devid;
204554a1482SKaran Tilak Kumar int irq_num;
2055df6d737SAbhijeet Joglekar };
2065df6d737SAbhijeet Joglekar
2075df6d737SAbhijeet Joglekar enum fnic_state {
2085df6d737SAbhijeet Joglekar FNIC_IN_FC_MODE = 0,
2095df6d737SAbhijeet Joglekar FNIC_IN_FC_TRANS_ETH_MODE,
2105df6d737SAbhijeet Joglekar FNIC_IN_ETH_MODE,
2115df6d737SAbhijeet Joglekar FNIC_IN_ETH_TRANS_FC_MODE,
2125df6d737SAbhijeet Joglekar };
2135df6d737SAbhijeet Joglekar
2145df6d737SAbhijeet Joglekar struct mempool;
2155df6d737SAbhijeet Joglekar
216d3c995f1SHiral Patel enum fnic_evt {
217d3c995f1SHiral Patel FNIC_EVT_START_VLAN_DISC = 1,
218d3c995f1SHiral Patel FNIC_EVT_START_FCF_DISC = 2,
219d3c995f1SHiral Patel FNIC_EVT_MAX,
220d3c995f1SHiral Patel };
221d3c995f1SHiral Patel
222d3c995f1SHiral Patel struct fnic_event {
223d3c995f1SHiral Patel struct list_head list;
224d3c995f1SHiral Patel struct fnic *fnic;
225d3c995f1SHiral Patel enum fnic_evt event;
226d3c995f1SHiral Patel };
227d3c995f1SHiral Patel
228554a1482SKaran Tilak Kumar struct fnic_cpy_wq {
229554a1482SKaran Tilak Kumar unsigned long hw_lock_flags;
230554a1482SKaran Tilak Kumar u16 active_ioreq_count;
231554a1482SKaran Tilak Kumar u16 ioreq_table_size;
232554a1482SKaran Tilak Kumar ____cacheline_aligned struct fnic_io_req **io_req_table;
233554a1482SKaran Tilak Kumar };
234554a1482SKaran Tilak Kumar
2355df6d737SAbhijeet Joglekar /* Per-instance private data structure */
2365df6d737SAbhijeet Joglekar struct fnic {
237ca008aeeSKaran Tilak Kumar int fnic_num;
2385df6d737SAbhijeet Joglekar struct fc_lport *lport;
23978112e55SJoe Eykholt struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */
2405df6d737SAbhijeet Joglekar struct vnic_dev_bar bar0;
2415df6d737SAbhijeet Joglekar
2425df6d737SAbhijeet Joglekar struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX];
2435df6d737SAbhijeet Joglekar
2445df6d737SAbhijeet Joglekar struct vnic_stats *stats;
2455df6d737SAbhijeet Joglekar unsigned long stats_time; /* time of stats update */
2461adee040SNarsimhulu Musini unsigned long stats_reset_time; /* time of stats reset */
2475df6d737SAbhijeet Joglekar struct vnic_nic_cfg *nic_cfg;
2485df6d737SAbhijeet Joglekar char name[IFNAMSIZ];
2495df6d737SAbhijeet Joglekar struct timer_list notify_timer; /* used for MSI interrupts */
2505df6d737SAbhijeet Joglekar
251fc85799eSHiral Patel unsigned int fnic_max_tag_id;
2525df6d737SAbhijeet Joglekar unsigned int err_intr_offset;
2535df6d737SAbhijeet Joglekar unsigned int link_intr_offset;
2545df6d737SAbhijeet Joglekar
2555df6d737SAbhijeet Joglekar unsigned int wq_count;
2565df6d737SAbhijeet Joglekar unsigned int cq_count;
2575df6d737SAbhijeet Joglekar
25815924b05SKaran Tilak Kumar struct mutex sgreset_mutex;
259514f0c40SKaran Tilak Kumar spinlock_t sgreset_lock; /* lock for sgreset */
260514f0c40SKaran Tilak Kumar struct scsi_cmnd *sgreset_sc;
26167125b02SHiral Patel struct dentry *fnic_stats_debugfs_host;
26267125b02SHiral Patel struct dentry *fnic_stats_debugfs_file;
26367125b02SHiral Patel struct dentry *fnic_reset_debugfs_file;
26467125b02SHiral Patel unsigned int reset_stats;
26567125b02SHiral Patel atomic64_t io_cmpl_skip;
26667125b02SHiral Patel struct fnic_stats fnic_stats;
26767125b02SHiral Patel
2685df6d737SAbhijeet Joglekar u32 vlan_hw_insert:1; /* let hw insert the tag */
2695df6d737SAbhijeet Joglekar u32 in_remove:1; /* fnic device in removal */
2705df6d737SAbhijeet Joglekar u32 stop_rx_link_events:1; /* stop proc. rx frames, link events */
271f9e2beb9SKaran Tilak Kumar u32 link_events:1; /* set when we get any link event*/
2725df6d737SAbhijeet Joglekar
2735df6d737SAbhijeet Joglekar struct completion *remove_wait; /* device remove thread blocks */
2745df6d737SAbhijeet Joglekar
27503298552SHiral Patel atomic_t in_flight; /* io counter */
2769698b6f4SSatish Kharat bool internal_reset_inprogress;
27703298552SHiral Patel u32 _reserved; /* fill hole */
27803298552SHiral Patel unsigned long state_flags; /* protected by host lock */
2795df6d737SAbhijeet Joglekar enum fnic_state state;
2805df6d737SAbhijeet Joglekar spinlock_t fnic_lock;
2815df6d737SAbhijeet Joglekar
2825df6d737SAbhijeet Joglekar u16 vlan_id; /* VLAN tag including priority */
2835df6d737SAbhijeet Joglekar u8 data_src_addr[ETH_ALEN];
2845df6d737SAbhijeet Joglekar u64 fcp_input_bytes; /* internal statistic */
2855df6d737SAbhijeet Joglekar u64 fcp_output_bytes; /* internal statistic */
2865df6d737SAbhijeet Joglekar u32 link_down_cnt;
2875df6d737SAbhijeet Joglekar int link_status;
2885df6d737SAbhijeet Joglekar
2895df6d737SAbhijeet Joglekar struct list_head list;
2905df6d737SAbhijeet Joglekar struct pci_dev *pdev;
2915df6d737SAbhijeet Joglekar struct vnic_fc_config config;
2925df6d737SAbhijeet Joglekar struct vnic_dev *vdev;
2935df6d737SAbhijeet Joglekar unsigned int raw_wq_count;
2945df6d737SAbhijeet Joglekar unsigned int wq_copy_count;
2955df6d737SAbhijeet Joglekar unsigned int rq_count;
2965df6d737SAbhijeet Joglekar int fw_ack_index[FNIC_WQ_COPY_MAX];
2975df6d737SAbhijeet Joglekar unsigned short fw_ack_recd[FNIC_WQ_COPY_MAX];
2985df6d737SAbhijeet Joglekar unsigned short wq_copy_desc_low[FNIC_WQ_COPY_MAX];
2995df6d737SAbhijeet Joglekar unsigned int intr_count;
3005df6d737SAbhijeet Joglekar u32 __iomem *legacy_pba;
3015df6d737SAbhijeet Joglekar struct fnic_host_tag *tags;
3025df6d737SAbhijeet Joglekar mempool_t *io_req_pool;
3035df6d737SAbhijeet Joglekar mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
3045df6d737SAbhijeet Joglekar
305554a1482SKaran Tilak Kumar unsigned int copy_wq_base;
3065df6d737SAbhijeet Joglekar struct work_struct link_work;
3075df6d737SAbhijeet Joglekar struct work_struct frame_work;
308*379a58caSLee Duncan struct work_struct flush_work;
3095df6d737SAbhijeet Joglekar struct sk_buff_head frame_queue;
31078112e55SJoe Eykholt struct sk_buff_head tx_queue;
3115df6d737SAbhijeet Joglekar
312d3c995f1SHiral Patel /*** FIP related data members -- start ***/
313d3c995f1SHiral Patel void (*set_vlan)(struct fnic *, u16 vlan);
314d3c995f1SHiral Patel struct work_struct fip_frame_work;
315d3c995f1SHiral Patel struct sk_buff_head fip_frame_queue;
316d3c995f1SHiral Patel struct timer_list fip_timer;
317d3c995f1SHiral Patel struct list_head vlans;
318d3c995f1SHiral Patel spinlock_t vlans_lock;
319d3c995f1SHiral Patel
320d3c995f1SHiral Patel struct work_struct event_work;
321d3c995f1SHiral Patel struct list_head evlist;
322d3c995f1SHiral Patel /*** FIP related data members -- end ***/
323d3c995f1SHiral Patel
3245df6d737SAbhijeet Joglekar /* copy work queue cache line section */
32586b86a7dSKaran Tilak Kumar ____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX];
326554a1482SKaran Tilak Kumar ____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX];
327554a1482SKaran Tilak Kumar
3285df6d737SAbhijeet Joglekar /* completion queue cache line section */
3295df6d737SAbhijeet Joglekar ____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
3305df6d737SAbhijeet Joglekar
3315df6d737SAbhijeet Joglekar spinlock_t wq_copy_lock[FNIC_WQ_COPY_MAX];
3325df6d737SAbhijeet Joglekar
3335df6d737SAbhijeet Joglekar /* work queue cache line section */
3345df6d737SAbhijeet Joglekar ____cacheline_aligned struct vnic_wq wq[FNIC_WQ_MAX];
3355df6d737SAbhijeet Joglekar spinlock_t wq_lock[FNIC_WQ_MAX];
3365df6d737SAbhijeet Joglekar
3375df6d737SAbhijeet Joglekar /* receive queue cache line section */
3385df6d737SAbhijeet Joglekar ____cacheline_aligned struct vnic_rq rq[FNIC_RQ_MAX];
3395df6d737SAbhijeet Joglekar
3405df6d737SAbhijeet Joglekar /* interrupt resource cache line section */
3415df6d737SAbhijeet Joglekar ____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX];
3425df6d737SAbhijeet Joglekar };
3435df6d737SAbhijeet Joglekar
fnic_from_ctlr(struct fcoe_ctlr * fip)34478112e55SJoe Eykholt static inline struct fnic *fnic_from_ctlr(struct fcoe_ctlr *fip)
34578112e55SJoe Eykholt {
34678112e55SJoe Eykholt return container_of(fip, struct fnic, ctlr);
34778112e55SJoe Eykholt }
34878112e55SJoe Eykholt
3495df6d737SAbhijeet Joglekar extern struct workqueue_struct *fnic_event_queue;
350d3c995f1SHiral Patel extern struct workqueue_struct *fnic_fip_queue;
351d6ddcd8bSBart Van Assche extern const struct attribute_group *fnic_host_groups[];
3525df6d737SAbhijeet Joglekar
3535df6d737SAbhijeet Joglekar void fnic_clear_intr_mode(struct fnic *fnic);
3545df6d737SAbhijeet Joglekar int fnic_set_intr_mode(struct fnic *fnic);
3558a8449caSKaran Tilak Kumar int fnic_set_intr_mode_msix(struct fnic *fnic);
3565df6d737SAbhijeet Joglekar void fnic_free_intr(struct fnic *fnic);
3575df6d737SAbhijeet Joglekar int fnic_request_intr(struct fnic *fnic);
3585df6d737SAbhijeet Joglekar
3595df6d737SAbhijeet Joglekar int fnic_send(struct fc_lport *, struct fc_frame *);
3605df6d737SAbhijeet Joglekar void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf);
3615df6d737SAbhijeet Joglekar void fnic_handle_frame(struct work_struct *work);
3625df6d737SAbhijeet Joglekar void fnic_handle_link(struct work_struct *work);
363d3c995f1SHiral Patel void fnic_handle_event(struct work_struct *work);
3645df6d737SAbhijeet Joglekar int fnic_rq_cmpl_handler(struct fnic *fnic, int);
3655df6d737SAbhijeet Joglekar int fnic_alloc_rq_frame(struct vnic_rq *rq);
3665df6d737SAbhijeet Joglekar void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
367*379a58caSLee Duncan void fnic_flush_tx(struct work_struct *work);
36878112e55SJoe Eykholt void fnic_eth_send(struct fcoe_ctlr *, struct sk_buff *skb);
36978112e55SJoe Eykholt void fnic_set_port_id(struct fc_lport *, u32, struct fc_frame *);
37078112e55SJoe Eykholt void fnic_update_mac(struct fc_lport *, u8 *new);
37178112e55SJoe Eykholt void fnic_update_mac_locked(struct fnic *, u8 *new);
3725df6d737SAbhijeet Joglekar
373f281233dSJeff Garzik int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
3745df6d737SAbhijeet Joglekar int fnic_abort_cmd(struct scsi_cmnd *);
3755df6d737SAbhijeet Joglekar int fnic_device_reset(struct scsi_cmnd *);
3765df6d737SAbhijeet Joglekar int fnic_host_reset(struct scsi_cmnd *);
3775df6d737SAbhijeet Joglekar int fnic_reset(struct Scsi_Host *);
3785df6d737SAbhijeet Joglekar void fnic_scsi_cleanup(struct fc_lport *);
3795df6d737SAbhijeet Joglekar void fnic_scsi_abort_io(struct fc_lport *);
3805df6d737SAbhijeet Joglekar void fnic_empty_scsi_cleanup(struct fc_lport *);
3815df6d737SAbhijeet Joglekar void fnic_exch_mgr_reset(struct fc_lport *, u32, u32);
3828a8449caSKaran Tilak Kumar int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index);
3835df6d737SAbhijeet Joglekar int fnic_wq_cmpl_handler(struct fnic *fnic, int);
38478112e55SJoe Eykholt int fnic_flogi_reg_handler(struct fnic *fnic, u32);
3855df6d737SAbhijeet Joglekar void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
3865df6d737SAbhijeet Joglekar struct fcpio_host_req *desc);
3875df6d737SAbhijeet Joglekar int fnic_fw_reset_handler(struct fnic *fnic);
3885df6d737SAbhijeet Joglekar void fnic_terminate_rport_io(struct fc_rport *);
3895df6d737SAbhijeet Joglekar const char *fnic_state_to_str(unsigned int state);
39052f6e196SKaran Tilak Kumar void fnic_mq_map_queues_cpus(struct Scsi_Host *host);
3915df6d737SAbhijeet Joglekar void fnic_log_q_error(struct fnic *fnic);
3925df6d737SAbhijeet Joglekar void fnic_handle_link_event(struct fnic *fnic);
3935df6d737SAbhijeet Joglekar
394a0bf1ca2SHiral Patel int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);
395a0bf1ca2SHiral Patel
396d3c995f1SHiral Patel void fnic_handle_fip_frame(struct work_struct *work);
397d3c995f1SHiral Patel void fnic_handle_fip_event(struct fnic *fnic);
398d3c995f1SHiral Patel void fnic_fcoe_reset_vlans(struct fnic *fnic);
399d3c995f1SHiral Patel void fnic_fcoe_evlist_free(struct fnic *fnic);
400d3c995f1SHiral Patel extern void fnic_handle_fip_timer(struct fnic *fnic);
401d3c995f1SHiral Patel
40203298552SHiral Patel static inline int
fnic_chk_state_flags_locked(struct fnic * fnic,unsigned long st_flags)40303298552SHiral Patel fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags)
40403298552SHiral Patel {
40503298552SHiral Patel return ((fnic->state_flags & st_flags) == st_flags);
40603298552SHiral Patel }
40703298552SHiral Patel void __fnic_set_state_flags(struct fnic *, unsigned long, unsigned long);
4081adee040SNarsimhulu Musini void fnic_dump_fchost_stats(struct Scsi_Host *, struct fc_host_statistics *);
4095df6d737SAbhijeet Joglekar #endif /* _FNIC_H_ */
410