fnic.h 20 KB

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