bfa_fcs.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. /**
  18. * bfa_fcs.c BFA FCS main
  19. */
  20. #include <fcs/bfa_fcs.h>
  21. #include "fcs_port.h"
  22. #include "fcs_uf.h"
  23. #include "fcs_vport.h"
  24. #include "fcs_rport.h"
  25. #include "fcs_fabric.h"
  26. #include "fcs_fcpim.h"
  27. #include "fcs_fcptm.h"
  28. #include "fcbuild.h"
  29. #include "fcs.h"
  30. #include "bfad_drv.h"
  31. #include <fcb/bfa_fcb.h>
  32. /**
  33. * FCS sub-modules
  34. */
  35. struct bfa_fcs_mod_s {
  36. void (*attach) (struct bfa_fcs_s *fcs);
  37. void (*modinit) (struct bfa_fcs_s *fcs);
  38. void (*modexit) (struct bfa_fcs_s *fcs);
  39. };
  40. #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
  41. static struct bfa_fcs_mod_s fcs_modules[] = {
  42. { bfa_fcs_pport_attach, NULL, NULL },
  43. { bfa_fcs_uf_attach, NULL, NULL },
  44. { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
  45. bfa_fcs_fabric_modexit },
  46. };
  47. /**
  48. * fcs_api BFA FCS API
  49. */
  50. static void
  51. bfa_fcs_exit_comp(void *fcs_cbarg)
  52. {
  53. struct bfa_fcs_s *fcs = fcs_cbarg;
  54. struct bfad_s *bfad = fcs->bfad;
  55. complete(&bfad->comp);
  56. }
  57. /**
  58. * fcs_api BFA FCS API
  59. */
  60. /**
  61. * fcs attach -- called once to initialize data structures at driver attach time
  62. */
  63. void
  64. bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
  65. bfa_boolean_t min_cfg)
  66. {
  67. int i;
  68. struct bfa_fcs_mod_s *mod;
  69. fcs->bfa = bfa;
  70. fcs->bfad = bfad;
  71. fcs->min_cfg = min_cfg;
  72. bfa_attach_fcs(bfa);
  73. fcbuild_init();
  74. for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
  75. mod = &fcs_modules[i];
  76. if (mod->attach)
  77. mod->attach(fcs);
  78. }
  79. }
  80. /**
  81. * fcs initialization, called once after bfa initialization is complete
  82. */
  83. void
  84. bfa_fcs_init(struct bfa_fcs_s *fcs)
  85. {
  86. int i, npbc_vports;
  87. struct bfa_fcs_mod_s *mod;
  88. struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS];
  89. for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
  90. mod = &fcs_modules[i];
  91. if (mod->modinit)
  92. mod->modinit(fcs);
  93. }
  94. /* Initialize pbc vports */
  95. if (!fcs->min_cfg) {
  96. npbc_vports =
  97. bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports);
  98. for (i = 0; i < npbc_vports; i++)
  99. bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]);
  100. }
  101. }
  102. /**
  103. * Start FCS operations.
  104. */
  105. void
  106. bfa_fcs_start(struct bfa_fcs_s *fcs)
  107. {
  108. bfa_fcs_fabric_modstart(fcs);
  109. }
  110. /**
  111. * FCS driver details initialization.
  112. *
  113. * param[in] fcs FCS instance
  114. * param[in] driver_info Driver Details
  115. *
  116. * return None
  117. */
  118. void
  119. bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  120. struct bfa_fcs_driver_info_s *driver_info)
  121. {
  122. fcs->driver_info = *driver_info;
  123. bfa_fcs_fabric_psymb_init(&fcs->fabric);
  124. }
  125. /**
  126. * @brief
  127. * FCS FDMI Driver Parameter Initialization
  128. *
  129. * @param[in] fcs FCS instance
  130. * @param[in] fdmi_enable TRUE/FALSE
  131. *
  132. * @return None
  133. */
  134. void
  135. bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable)
  136. {
  137. fcs->fdmi_enabled = fdmi_enable;
  138. }
  139. /**
  140. * FCS instance cleanup and exit.
  141. *
  142. * param[in] fcs FCS instance
  143. * return None
  144. */
  145. void
  146. bfa_fcs_exit(struct bfa_fcs_s *fcs)
  147. {
  148. struct bfa_fcs_mod_s *mod;
  149. int i;
  150. bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
  151. for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
  152. mod = &fcs_modules[i];
  153. if (mod->modexit) {
  154. bfa_wc_up(&fcs->wc);
  155. mod->modexit(fcs);
  156. }
  157. }
  158. bfa_wc_wait(&fcs->wc);
  159. }
  160. void
  161. bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod)
  162. {
  163. fcs->trcmod = trcmod;
  164. }
  165. void
  166. bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod)
  167. {
  168. fcs->logm = logmod;
  169. }
  170. void
  171. bfa_fcs_aen_init(struct bfa_fcs_s *fcs, struct bfa_aen_s *aen)
  172. {
  173. fcs->aen = aen;
  174. }
  175. void
  176. bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs)
  177. {
  178. bfa_wc_down(&fcs->wc);
  179. }