bfad_im.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __BFAD_IM_H__
  18. #define __BFAD_IM_H__
  19. #include "bfa_fcs.h"
  20. #define FCPI_NAME " fcpim"
  21. #ifndef KOBJ_NAME_LEN
  22. #define KOBJ_NAME_LEN 20
  23. #endif
  24. bfa_status_t bfad_im_module_init(void);
  25. void bfad_im_module_exit(void);
  26. bfa_status_t bfad_im_probe(struct bfad_s *bfad);
  27. void bfad_im_probe_undo(struct bfad_s *bfad);
  28. bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);
  29. void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);
  30. void bfad_im_port_clean(struct bfad_im_port_s *im_port);
  31. int bfad_im_scsi_host_alloc(struct bfad_s *bfad,
  32. struct bfad_im_port_s *im_port, struct device *dev);
  33. void bfad_im_scsi_host_free(struct bfad_s *bfad,
  34. struct bfad_im_port_s *im_port);
  35. #define MAX_FCP_TARGET 1024
  36. #define MAX_FCP_LUN 16384
  37. #define BFAD_TARGET_RESET_TMO 60
  38. #define BFAD_LUN_RESET_TMO 60
  39. #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
  40. #define BFA_QUEUE_FULL_RAMP_UP_TIME 120
  41. /*
  42. * itnim flags
  43. */
  44. #define IO_DONE_BIT 0
  45. struct bfad_itnim_data_s {
  46. struct bfad_itnim_s *itnim;
  47. };
  48. struct bfad_im_port_s {
  49. struct bfad_s *bfad;
  50. struct bfad_port_s *port;
  51. struct work_struct port_delete_work;
  52. int idr_id;
  53. u16 cur_scsi_id;
  54. u16 flags;
  55. struct list_head binding_list;
  56. struct Scsi_Host *shost;
  57. struct list_head itnim_mapped_list;
  58. struct fc_vport *fc_vport;
  59. };
  60. enum bfad_itnim_state {
  61. ITNIM_STATE_NONE,
  62. ITNIM_STATE_ONLINE,
  63. ITNIM_STATE_OFFLINE_PENDING,
  64. ITNIM_STATE_OFFLINE,
  65. ITNIM_STATE_TIMEOUT,
  66. ITNIM_STATE_FREE,
  67. };
  68. /*
  69. * Per itnim data structure
  70. */
  71. struct bfad_itnim_s {
  72. struct list_head list_entry;
  73. struct bfa_fcs_itnim_s fcs_itnim;
  74. struct work_struct itnim_work;
  75. u32 flags;
  76. enum bfad_itnim_state state;
  77. struct bfad_im_s *im;
  78. struct bfad_im_port_s *im_port;
  79. struct bfad_rport_s *drv_rport;
  80. struct fc_rport *fc_rport;
  81. struct bfa_itnim_s *bfa_itnim;
  82. u16 scsi_tgt_id;
  83. u16 queue_work;
  84. unsigned long last_ramp_up_time;
  85. unsigned long last_queue_full_time;
  86. };
  87. enum bfad_binding_type {
  88. FCP_PWWN_BINDING = 0x1,
  89. FCP_NWWN_BINDING = 0x2,
  90. FCP_FCID_BINDING = 0x3,
  91. };
  92. struct bfad_fcp_binding {
  93. struct list_head list_entry;
  94. enum bfad_binding_type binding_type;
  95. u16 scsi_target_id;
  96. u32 fc_id;
  97. wwn_t nwwn;
  98. wwn_t pwwn;
  99. };
  100. struct bfad_im_s {
  101. struct bfad_s *bfad;
  102. struct workqueue_struct *drv_workq;
  103. char drv_workq_name[KOBJ_NAME_LEN];
  104. };
  105. struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
  106. struct bfad_s *);
  107. bfa_status_t bfad_thread_workq(struct bfad_s *bfad);
  108. void bfad_destroy_workq(struct bfad_im_s *im);
  109. void bfad_fc_host_init(struct bfad_im_port_s *im_port);
  110. void bfad_scsi_host_free(struct bfad_s *bfad,
  111. struct bfad_im_port_s *im_port);
  112. void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,
  113. struct scsi_device *sdev);
  114. void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
  115. struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);
  116. extern struct scsi_host_template bfad_im_scsi_host_template;
  117. extern struct scsi_host_template bfad_im_vport_template;
  118. extern struct fc_function_template bfad_im_fc_function_template;
  119. extern struct fc_function_template bfad_im_vport_fc_function_template;
  120. extern struct scsi_transport_template *bfad_im_scsi_transport_template;
  121. extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
  122. extern struct device_attribute *bfad_im_host_attrs[];
  123. extern struct device_attribute *bfad_im_vport_attrs[];
  124. irqreturn_t bfad_intx(int irq, void *dev_id);
  125. /* Firmware releated */
  126. #define BFAD_FW_FILE_CT_FC "ctfw_fc.bin"
  127. #define BFAD_FW_FILE_CT_CNA "ctfw_cna.bin"
  128. #define BFAD_FW_FILE_CB_FC "cbfw_fc.bin"
  129. u32 *bfad_get_firmware_buf(struct pci_dev *pdev);
  130. u32 *bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
  131. u32 *bfi_image_size, char *fw_name);
  132. static inline u32 *
  133. bfad_load_fwimg(struct pci_dev *pdev)
  134. {
  135. return bfad_get_firmware_buf(pdev);
  136. }
  137. static inline void
  138. bfad_free_fwimg(void)
  139. {
  140. if (bfi_image_ct_fc_size && bfi_image_ct_fc)
  141. vfree(bfi_image_ct_fc);
  142. if (bfi_image_ct_cna_size && bfi_image_ct_cna)
  143. vfree(bfi_image_ct_cna);
  144. if (bfi_image_cb_fc_size && bfi_image_cb_fc)
  145. vfree(bfi_image_cb_fc);
  146. }
  147. #endif