bfad_im.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2005-2009 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 "fcs/bfa_fcs_fcpim.h"
  20. #include "bfad_im_compat.h"
  21. #define FCPI_NAME " fcpim"
  22. bfa_status_t bfad_im_module_init(void);
  23. void bfad_im_module_exit(void);
  24. bfa_status_t bfad_im_probe(struct bfad_s *bfad);
  25. void bfad_im_probe_undo(struct bfad_s *bfad);
  26. void bfad_im_probe_post(struct bfad_im_s *im);
  27. bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);
  28. void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);
  29. void bfad_im_port_online(struct bfad_s *bfad, struct bfad_port_s *port);
  30. void bfad_im_port_offline(struct bfad_s *bfad, struct bfad_port_s *port);
  31. void bfad_im_port_clean(struct bfad_im_port_s *im_port);
  32. int bfad_im_scsi_host_alloc(struct bfad_s *bfad,
  33. struct bfad_im_port_s *im_port, struct device *dev);
  34. void bfad_im_scsi_host_free(struct bfad_s *bfad,
  35. struct bfad_im_port_s *im_port);
  36. #define MAX_FCP_TARGET 1024
  37. #define MAX_FCP_LUN 16384
  38. #define BFAD_TARGET_RESET_TMO 60
  39. #define BFAD_LUN_RESET_TMO 60
  40. #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
  41. #define BFA_QUEUE_FULL_RAMP_UP_TIME 120
  42. #define BFAD_KOBJ_NAME_LEN 20
  43. /*
  44. * itnim flags
  45. */
  46. #define ITNIM_MAPPED 0x00000001
  47. #define SCSI_TASK_MGMT 0x00000001
  48. #define IO_DONE_BIT 0
  49. struct bfad_itnim_data_s {
  50. struct bfad_itnim_s *itnim;
  51. };
  52. struct bfad_im_port_s {
  53. struct bfad_s *bfad;
  54. struct bfad_port_s *port;
  55. struct work_struct port_delete_work;
  56. int idr_id;
  57. u16 cur_scsi_id;
  58. u16 flags;
  59. struct list_head binding_list;
  60. struct Scsi_Host *shost;
  61. struct list_head itnim_mapped_list;
  62. struct fc_vport *fc_vport;
  63. };
  64. enum bfad_itnim_state {
  65. ITNIM_STATE_NONE,
  66. ITNIM_STATE_ONLINE,
  67. ITNIM_STATE_OFFLINE_PENDING,
  68. ITNIM_STATE_OFFLINE,
  69. ITNIM_STATE_TIMEOUT,
  70. ITNIM_STATE_FREE,
  71. };
  72. /*
  73. * Per itnim data structure
  74. */
  75. struct bfad_itnim_s {
  76. struct list_head list_entry;
  77. struct bfa_fcs_itnim_s fcs_itnim;
  78. struct work_struct itnim_work;
  79. u32 flags;
  80. enum bfad_itnim_state state;
  81. struct bfad_im_s *im;
  82. struct bfad_im_port_s *im_port;
  83. struct bfad_rport_s *drv_rport;
  84. struct fc_rport *fc_rport;
  85. struct bfa_itnim_s *bfa_itnim;
  86. u16 scsi_tgt_id;
  87. u16 queue_work;
  88. unsigned long last_ramp_up_time;
  89. unsigned long last_queue_full_time;
  90. };
  91. enum bfad_binding_type {
  92. FCP_PWWN_BINDING = 0x1,
  93. FCP_NWWN_BINDING = 0x2,
  94. FCP_FCID_BINDING = 0x3,
  95. };
  96. struct bfad_fcp_binding {
  97. struct list_head list_entry;
  98. enum bfad_binding_type binding_type;
  99. u16 scsi_target_id;
  100. u32 fc_id;
  101. wwn_t nwwn;
  102. wwn_t pwwn;
  103. };
  104. struct bfad_im_s {
  105. struct bfad_s *bfad;
  106. struct workqueue_struct *drv_workq;
  107. char drv_workq_name[BFAD_KOBJ_NAME_LEN];
  108. };
  109. struct Scsi_Host *bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port,
  110. struct bfad_s *);
  111. bfa_status_t bfad_os_thread_workq(struct bfad_s *bfad);
  112. void bfad_os_destroy_workq(struct bfad_im_s *im);
  113. void bfad_os_itnim_process(struct bfad_itnim_s *itnim_drv);
  114. void bfad_os_fc_host_init(struct bfad_im_port_s *im_port);
  115. void bfad_os_scsi_host_free(struct bfad_s *bfad,
  116. struct bfad_im_port_s *im_port);
  117. void bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim,
  118. struct scsi_device *sdev);
  119. void bfad_os_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
  120. struct bfad_itnim_s *bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id);
  121. int bfad_os_scsi_add_host(struct Scsi_Host *shost,
  122. struct bfad_im_port_s *im_port, struct bfad_s *bfad);
  123. void bfad_im_itnim_unmap(struct bfad_im_port_s *im_port,
  124. struct bfad_itnim_s *itnim);
  125. extern struct scsi_host_template bfad_im_scsi_host_template;
  126. extern struct scsi_host_template bfad_im_vport_template;
  127. extern struct fc_function_template bfad_im_fc_function_template;
  128. extern struct fc_function_template bfad_im_vport_fc_function_template;
  129. extern struct scsi_transport_template *bfad_im_scsi_transport_template;
  130. extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
  131. #endif