bfa_fcpim.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #include <bfa.h>
  18. #include <log/bfa_log_hal.h>
  19. BFA_TRC_FILE(HAL, FCPIM);
  20. BFA_MODULE(fcpim);
  21. /**
  22. * hal_fcpim_mod BFA FCP Initiator Mode module
  23. */
  24. /**
  25. * Compute and return memory needed by FCP(im) module.
  26. */
  27. static void
  28. bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
  29. u32 *dm_len)
  30. {
  31. bfa_itnim_meminfo(cfg, km_len, dm_len);
  32. /**
  33. * IO memory
  34. */
  35. if (cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN)
  36. cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
  37. else if (cfg->fwcfg.num_ioim_reqs > BFA_IOIM_MAX)
  38. cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
  39. *km_len += cfg->fwcfg.num_ioim_reqs *
  40. (sizeof(struct bfa_ioim_s) + sizeof(struct bfa_ioim_sp_s));
  41. *dm_len += cfg->fwcfg.num_ioim_reqs * BFI_IOIM_SNSLEN;
  42. /**
  43. * task management command memory
  44. */
  45. if (cfg->fwcfg.num_tskim_reqs < BFA_TSKIM_MIN)
  46. cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN;
  47. *km_len += cfg->fwcfg.num_tskim_reqs * sizeof(struct bfa_tskim_s);
  48. }
  49. static void
  50. bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
  51. struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
  52. {
  53. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  54. bfa_trc(bfa, cfg->drvcfg.path_tov);
  55. bfa_trc(bfa, cfg->fwcfg.num_rports);
  56. bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs);
  57. bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs);
  58. fcpim->bfa = bfa;
  59. fcpim->num_itnims = cfg->fwcfg.num_rports;
  60. fcpim->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
  61. fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs;
  62. fcpim->path_tov = cfg->drvcfg.path_tov;
  63. fcpim->delay_comp = cfg->drvcfg.delay_comp;
  64. bfa_itnim_attach(fcpim, meminfo);
  65. bfa_tskim_attach(fcpim, meminfo);
  66. bfa_ioim_attach(fcpim, meminfo);
  67. }
  68. static void
  69. bfa_fcpim_detach(struct bfa_s *bfa)
  70. {
  71. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  72. bfa_ioim_detach(fcpim);
  73. bfa_tskim_detach(fcpim);
  74. }
  75. static void
  76. bfa_fcpim_start(struct bfa_s *bfa)
  77. {
  78. }
  79. static void
  80. bfa_fcpim_stop(struct bfa_s *bfa)
  81. {
  82. }
  83. static void
  84. bfa_fcpim_iocdisable(struct bfa_s *bfa)
  85. {
  86. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  87. struct bfa_itnim_s *itnim;
  88. struct list_head *qe, *qen;
  89. list_for_each_safe(qe, qen, &fcpim->itnim_q) {
  90. itnim = (struct bfa_itnim_s *) qe;
  91. bfa_itnim_iocdisable(itnim);
  92. }
  93. }
  94. void
  95. bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
  96. {
  97. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  98. fcpim->path_tov = path_tov * 1000;
  99. if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
  100. fcpim->path_tov = BFA_FCPIM_PATHTOV_MAX;
  101. }
  102. u16
  103. bfa_fcpim_path_tov_get(struct bfa_s *bfa)
  104. {
  105. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  106. return fcpim->path_tov / 1000;
  107. }
  108. bfa_status_t
  109. bfa_fcpim_get_modstats(struct bfa_s *bfa, struct bfa_fcpim_stats_s *modstats)
  110. {
  111. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  112. *modstats = fcpim->stats;
  113. return BFA_STATUS_OK;
  114. }
  115. bfa_status_t
  116. bfa_fcpim_clr_modstats(struct bfa_s *bfa)
  117. {
  118. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  119. memset(&fcpim->stats, 0, sizeof(struct bfa_fcpim_stats_s));
  120. return BFA_STATUS_OK;
  121. }
  122. void
  123. bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth)
  124. {
  125. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  126. bfa_assert(q_depth <= BFA_IOCFC_QDEPTH_MAX);
  127. fcpim->q_depth = q_depth;
  128. }
  129. u16
  130. bfa_fcpim_qdepth_get(struct bfa_s *bfa)
  131. {
  132. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  133. return fcpim->q_depth;
  134. }
  135. void
  136. bfa_fcpim_update_ioredirect(struct bfa_s *bfa)
  137. {
  138. bfa_boolean_t ioredirect;
  139. /*
  140. * IO redirection is turned off when QoS is enabled and vice versa
  141. */
  142. ioredirect = bfa_fcport_is_qos_enabled(bfa) ? BFA_FALSE : BFA_TRUE;
  143. /*
  144. * Notify the bfad module of a possible state change in
  145. * IO redirection capability, due to a QoS state change. bfad will
  146. * check on the support for io redirection and update the
  147. * fcpim's ioredirect state accordingly.
  148. */
  149. bfa_cb_ioredirect_state_change((void *)(bfa->bfad), ioredirect);
  150. }
  151. void
  152. bfa_fcpim_set_ioredirect(struct bfa_s *bfa, bfa_boolean_t state)
  153. {
  154. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  155. fcpim->ioredirect = state;
  156. }