bfa_fcpim.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_initdone(struct bfa_s *bfa)
  70. {
  71. }
  72. static void
  73. bfa_fcpim_detach(struct bfa_s *bfa)
  74. {
  75. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  76. bfa_ioim_detach(fcpim);
  77. bfa_tskim_detach(fcpim);
  78. }
  79. static void
  80. bfa_fcpim_start(struct bfa_s *bfa)
  81. {
  82. }
  83. static void
  84. bfa_fcpim_stop(struct bfa_s *bfa)
  85. {
  86. }
  87. static void
  88. bfa_fcpim_iocdisable(struct bfa_s *bfa)
  89. {
  90. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  91. struct bfa_itnim_s *itnim;
  92. struct list_head *qe, *qen;
  93. list_for_each_safe(qe, qen, &fcpim->itnim_q) {
  94. itnim = (struct bfa_itnim_s *) qe;
  95. bfa_itnim_iocdisable(itnim);
  96. }
  97. }
  98. void
  99. bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
  100. {
  101. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  102. fcpim->path_tov = path_tov * 1000;
  103. if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
  104. fcpim->path_tov = BFA_FCPIM_PATHTOV_MAX;
  105. }
  106. u16
  107. bfa_fcpim_path_tov_get(struct bfa_s *bfa)
  108. {
  109. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  110. return fcpim->path_tov / 1000;
  111. }
  112. bfa_status_t
  113. bfa_fcpim_get_modstats(struct bfa_s *bfa, struct bfa_fcpim_stats_s *modstats)
  114. {
  115. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  116. *modstats = fcpim->stats;
  117. return BFA_STATUS_OK;
  118. }
  119. bfa_status_t
  120. bfa_fcpim_clr_modstats(struct bfa_s *bfa)
  121. {
  122. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  123. memset(&fcpim->stats, 0, sizeof(struct bfa_fcpim_stats_s));
  124. return BFA_STATUS_OK;
  125. }
  126. void
  127. bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth)
  128. {
  129. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  130. bfa_assert(q_depth <= BFA_IOCFC_QDEPTH_MAX);
  131. fcpim->q_depth = q_depth;
  132. }
  133. u16
  134. bfa_fcpim_qdepth_get(struct bfa_s *bfa)
  135. {
  136. struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
  137. return fcpim->q_depth;
  138. }