This source file includes following definitions.
- fnic_from_ctlr
- fnic_chk_state_flags_locked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _FNIC_H_
19 #define _FNIC_H_
20
21 #include <linux/interrupt.h>
22 #include <linux/netdevice.h>
23 #include <linux/workqueue.h>
24 #include <linux/bitops.h>
25 #include <scsi/libfc.h>
26 #include <scsi/libfcoe.h>
27 #include "fnic_io.h"
28 #include "fnic_res.h"
29 #include "fnic_trace.h"
30 #include "fnic_stats.h"
31 #include "vnic_dev.h"
32 #include "vnic_wq.h"
33 #include "vnic_rq.h"
34 #include "vnic_cq.h"
35 #include "vnic_wq_copy.h"
36 #include "vnic_intr.h"
37 #include "vnic_stats.h"
38 #include "vnic_scsi.h"
39
40 #define DRV_NAME "fnic"
41 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42 #define DRV_VERSION "1.6.0.47"
43 #define PFX DRV_NAME ": "
44 #define DFX DRV_NAME "%d: "
45
46 #define DESC_CLEAN_LOW_WATERMARK 8
47 #define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16
48 #define FNIC_MIN_IO_REQ 256
49 #define FNIC_MAX_IO_REQ 1024
50 #define FNIC_DFLT_IO_REQ 256
51 #define FNIC_IO_LOCKS 64
52 #define FNIC_DFLT_QUEUE_DEPTH 256
53 #define FNIC_STATS_RATE_LIMIT 4
54
55
56
57
58 #define FNIC_TAG_ABORT BIT(30)
59 #define FNIC_TAG_DEV_RST BIT(29)
60 #define FNIC_TAG_MASK (BIT(24) - 1)
61 #define FNIC_NO_TAG -1
62
63
64
65
66
67 #define FNIC_NO_FLAGS 0
68 #define FNIC_IO_INITIALIZED BIT(0)
69 #define FNIC_IO_ISSUED BIT(1)
70 #define FNIC_IO_DONE BIT(2)
71 #define FNIC_IO_REQ_NULL BIT(3)
72 #define FNIC_IO_ABTS_PENDING BIT(4)
73 #define FNIC_IO_ABORTED BIT(5)
74 #define FNIC_IO_ABTS_ISSUED BIT(6)
75 #define FNIC_IO_TERM_ISSUED BIT(7)
76 #define FNIC_IO_INTERNAL_TERM_ISSUED BIT(8)
77 #define FNIC_IO_ABT_TERM_DONE BIT(9)
78 #define FNIC_IO_ABT_TERM_REQ_NULL BIT(10)
79 #define FNIC_IO_ABT_TERM_TIMED_OUT BIT(11)
80 #define FNIC_DEVICE_RESET BIT(12)
81 #define FNIC_DEV_RST_ISSUED BIT(13)
82 #define FNIC_DEV_RST_TIMED_OUT BIT(14)
83 #define FNIC_DEV_RST_ABTS_ISSUED BIT(15)
84 #define FNIC_DEV_RST_TERM_ISSUED BIT(16)
85 #define FNIC_DEV_RST_DONE BIT(17)
86 #define FNIC_DEV_RST_REQ_NULL BIT(18)
87 #define FNIC_DEV_RST_ABTS_DONE BIT(19)
88 #define FNIC_DEV_RST_TERM_DONE BIT(20)
89 #define FNIC_DEV_RST_ABTS_PENDING BIT(21)
90
91
92
93
94
95 #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
96 #define CMD_STATE(Cmnd) ((Cmnd)->SCp.phase)
97 #define CMD_ABTS_STATUS(Cmnd) ((Cmnd)->SCp.Message)
98 #define CMD_LR_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
99 #define CMD_TAG(Cmnd) ((Cmnd)->SCp.sent_command)
100 #define CMD_FLAGS(Cmnd) ((Cmnd)->SCp.Status)
101
102 #define FCPIO_INVALID_CODE 0x100
103
104 #define FNIC_LUN_RESET_TIMEOUT 10000
105 #define FNIC_HOST_RESET_TIMEOUT 10000
106 #define FNIC_RMDEVICE_TIMEOUT 1000
107 #define FNIC_HOST_RESET_SETTLE_TIME 30
108 #define FNIC_ABT_TERM_DELAY_TIMEOUT 500
109
110 #define FNIC_MAX_FCP_TARGET 256
111
112
113
114
115 #define __FNIC_FLAGS_FWRESET BIT(0)
116 #define __FNIC_FLAGS_BLOCK_IO BIT(1)
117
118 #define FNIC_FLAGS_NONE (0)
119 #define FNIC_FLAGS_FWRESET (__FNIC_FLAGS_FWRESET | \
120 __FNIC_FLAGS_BLOCK_IO)
121
122 #define FNIC_FLAGS_IO_BLOCKED (__FNIC_FLAGS_BLOCK_IO)
123
124 #define fnic_set_state_flags(fnicp, st_flags) \
125 __fnic_set_state_flags(fnicp, st_flags, 0)
126
127 #define fnic_clear_state_flags(fnicp, st_flags) \
128 __fnic_set_state_flags(fnicp, st_flags, 1)
129
130 extern unsigned int fnic_log_level;
131 extern unsigned int io_completions;
132
133 #define FNIC_MAIN_LOGGING 0x01
134 #define FNIC_FCS_LOGGING 0x02
135 #define FNIC_SCSI_LOGGING 0x04
136 #define FNIC_ISR_LOGGING 0x08
137
138 #define FNIC_CHECK_LOGGING(LEVEL, CMD) \
139 do { \
140 if (unlikely(fnic_log_level & LEVEL)) \
141 do { \
142 CMD; \
143 } while (0); \
144 } while (0)
145
146 #define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \
147 FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \
148 shost_printk(kern_level, host, fmt, ##args);)
149
150 #define FNIC_FCS_DBG(kern_level, host, fmt, args...) \
151 FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
152 shost_printk(kern_level, host, fmt, ##args);)
153
154 #define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \
155 FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
156 shost_printk(kern_level, host, fmt, ##args);)
157
158 #define FNIC_ISR_DBG(kern_level, host, fmt, args...) \
159 FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
160 shost_printk(kern_level, host, fmt, ##args);)
161
162 #define FNIC_MAIN_NOTE(kern_level, host, fmt, args...) \
163 shost_printk(kern_level, host, fmt, ##args)
164
165 extern const char *fnic_state_str[];
166
167 enum fnic_intx_intr_index {
168 FNIC_INTX_WQ_RQ_COPYWQ,
169 FNIC_INTX_ERR,
170 FNIC_INTX_NOTIFY,
171 FNIC_INTX_INTR_MAX,
172 };
173
174 enum fnic_msix_intr_index {
175 FNIC_MSIX_RQ,
176 FNIC_MSIX_WQ,
177 FNIC_MSIX_WQ_COPY,
178 FNIC_MSIX_ERR_NOTIFY,
179 FNIC_MSIX_INTR_MAX,
180 };
181
182 struct fnic_msix_entry {
183 int requested;
184 char devname[IFNAMSIZ + 11];
185 irqreturn_t (*isr)(int, void *);
186 void *devid;
187 };
188
189 enum fnic_state {
190 FNIC_IN_FC_MODE = 0,
191 FNIC_IN_FC_TRANS_ETH_MODE,
192 FNIC_IN_ETH_MODE,
193 FNIC_IN_ETH_TRANS_FC_MODE,
194 };
195
196 #define FNIC_WQ_COPY_MAX 1
197 #define FNIC_WQ_MAX 1
198 #define FNIC_RQ_MAX 1
199 #define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
200 #define FNIC_DFLT_IO_COMPLETIONS 256
201
202 struct mempool;
203
204 enum fnic_evt {
205 FNIC_EVT_START_VLAN_DISC = 1,
206 FNIC_EVT_START_FCF_DISC = 2,
207 FNIC_EVT_MAX,
208 };
209
210 struct fnic_event {
211 struct list_head list;
212 struct fnic *fnic;
213 enum fnic_evt event;
214 };
215
216
217 struct fnic {
218 struct fc_lport *lport;
219 struct fcoe_ctlr ctlr;
220 struct vnic_dev_bar bar0;
221
222 struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX];
223
224 struct vnic_stats *stats;
225 unsigned long stats_time;
226 unsigned long stats_reset_time;
227 struct vnic_nic_cfg *nic_cfg;
228 char name[IFNAMSIZ];
229 struct timer_list notify_timer;
230
231 unsigned int fnic_max_tag_id;
232 unsigned int err_intr_offset;
233 unsigned int link_intr_offset;
234
235 unsigned int wq_count;
236 unsigned int cq_count;
237
238 struct dentry *fnic_stats_debugfs_host;
239 struct dentry *fnic_stats_debugfs_file;
240 struct dentry *fnic_reset_debugfs_file;
241 unsigned int reset_stats;
242 atomic64_t io_cmpl_skip;
243 struct fnic_stats fnic_stats;
244
245 u32 vlan_hw_insert:1;
246 u32 in_remove:1;
247 u32 stop_rx_link_events:1;
248
249 struct completion *remove_wait;
250
251 atomic_t in_flight;
252 bool internal_reset_inprogress;
253 u32 _reserved;
254 unsigned long state_flags;
255 enum fnic_state state;
256 spinlock_t fnic_lock;
257
258 u16 vlan_id;
259 u8 data_src_addr[ETH_ALEN];
260 u64 fcp_input_bytes;
261 u64 fcp_output_bytes;
262 u32 link_down_cnt;
263 int link_status;
264
265 struct list_head list;
266 struct pci_dev *pdev;
267 struct vnic_fc_config config;
268 struct vnic_dev *vdev;
269 unsigned int raw_wq_count;
270 unsigned int wq_copy_count;
271 unsigned int rq_count;
272 int fw_ack_index[FNIC_WQ_COPY_MAX];
273 unsigned short fw_ack_recd[FNIC_WQ_COPY_MAX];
274 unsigned short wq_copy_desc_low[FNIC_WQ_COPY_MAX];
275 unsigned int intr_count;
276 u32 __iomem *legacy_pba;
277 struct fnic_host_tag *tags;
278 mempool_t *io_req_pool;
279 mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
280 spinlock_t io_req_lock[FNIC_IO_LOCKS];
281
282 struct work_struct link_work;
283 struct work_struct frame_work;
284 struct sk_buff_head frame_queue;
285 struct sk_buff_head tx_queue;
286
287
288 void (*set_vlan)(struct fnic *, u16 vlan);
289 struct work_struct fip_frame_work;
290 struct sk_buff_head fip_frame_queue;
291 struct timer_list fip_timer;
292 struct list_head vlans;
293 spinlock_t vlans_lock;
294
295 struct work_struct event_work;
296 struct list_head evlist;
297
298
299
300 ____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX];
301
302 ____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
303
304 spinlock_t wq_copy_lock[FNIC_WQ_COPY_MAX];
305
306
307 ____cacheline_aligned struct vnic_wq wq[FNIC_WQ_MAX];
308 spinlock_t wq_lock[FNIC_WQ_MAX];
309
310
311 ____cacheline_aligned struct vnic_rq rq[FNIC_RQ_MAX];
312
313
314 ____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX];
315 };
316
317 static inline struct fnic *fnic_from_ctlr(struct fcoe_ctlr *fip)
318 {
319 return container_of(fip, struct fnic, ctlr);
320 }
321
322 extern struct workqueue_struct *fnic_event_queue;
323 extern struct workqueue_struct *fnic_fip_queue;
324 extern struct device_attribute *fnic_attrs[];
325
326 void fnic_clear_intr_mode(struct fnic *fnic);
327 int fnic_set_intr_mode(struct fnic *fnic);
328 void fnic_free_intr(struct fnic *fnic);
329 int fnic_request_intr(struct fnic *fnic);
330
331 int fnic_send(struct fc_lport *, struct fc_frame *);
332 void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf);
333 void fnic_handle_frame(struct work_struct *work);
334 void fnic_handle_link(struct work_struct *work);
335 void fnic_handle_event(struct work_struct *work);
336 int fnic_rq_cmpl_handler(struct fnic *fnic, int);
337 int fnic_alloc_rq_frame(struct vnic_rq *rq);
338 void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
339 void fnic_flush_tx(struct fnic *);
340 void fnic_eth_send(struct fcoe_ctlr *, struct sk_buff *skb);
341 void fnic_set_port_id(struct fc_lport *, u32, struct fc_frame *);
342 void fnic_update_mac(struct fc_lport *, u8 *new);
343 void fnic_update_mac_locked(struct fnic *, u8 *new);
344
345 int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
346 int fnic_abort_cmd(struct scsi_cmnd *);
347 int fnic_device_reset(struct scsi_cmnd *);
348 int fnic_host_reset(struct scsi_cmnd *);
349 int fnic_reset(struct Scsi_Host *);
350 void fnic_scsi_cleanup(struct fc_lport *);
351 void fnic_scsi_abort_io(struct fc_lport *);
352 void fnic_empty_scsi_cleanup(struct fc_lport *);
353 void fnic_exch_mgr_reset(struct fc_lport *, u32, u32);
354 int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int);
355 int fnic_wq_cmpl_handler(struct fnic *fnic, int);
356 int fnic_flogi_reg_handler(struct fnic *fnic, u32);
357 void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
358 struct fcpio_host_req *desc);
359 int fnic_fw_reset_handler(struct fnic *fnic);
360 void fnic_terminate_rport_io(struct fc_rport *);
361 const char *fnic_state_to_str(unsigned int state);
362
363 void fnic_log_q_error(struct fnic *fnic);
364 void fnic_handle_link_event(struct fnic *fnic);
365
366 int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);
367
368 void fnic_handle_fip_frame(struct work_struct *work);
369 void fnic_handle_fip_event(struct fnic *fnic);
370 void fnic_fcoe_reset_vlans(struct fnic *fnic);
371 void fnic_fcoe_evlist_free(struct fnic *fnic);
372 extern void fnic_handle_fip_timer(struct fnic *fnic);
373
374 static inline int
375 fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags)
376 {
377 return ((fnic->state_flags & st_flags) == st_flags);
378 }
379 void __fnic_set_state_flags(struct fnic *, unsigned long, unsigned long);
380 void fnic_dump_fchost_stats(struct Scsi_Host *, struct fc_host_statistics *);
381 #endif