bfa_fcs.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 (*modinit) (struct bfa_fcs_s *fcs);
  37. void (*modexit) (struct bfa_fcs_s *fcs);
  38. };
  39. #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
  40. static struct bfa_fcs_mod_s fcs_modules[] = {
  41. BFA_FCS_MODULE(bfa_fcs_pport),
  42. BFA_FCS_MODULE(bfa_fcs_uf),
  43. BFA_FCS_MODULE(bfa_fcs_fabric),
  44. BFA_FCS_MODULE(bfa_fcs_vport),
  45. BFA_FCS_MODULE(bfa_fcs_rport),
  46. BFA_FCS_MODULE(bfa_fcs_fcpim),
  47. };
  48. /**
  49. * fcs_api BFA FCS API
  50. */
  51. static void
  52. bfa_fcs_exit_comp(void *fcs_cbarg)
  53. {
  54. struct bfa_fcs_s *fcs = fcs_cbarg;
  55. struct bfad_s *bfad = fcs->bfad;
  56. complete(&bfad->comp);
  57. }
  58. /**
  59. * fcs_api BFA FCS API
  60. */
  61. /**
  62. * FCS instance initialization.
  63. *
  64. * param[in] fcs FCS instance
  65. * param[in] bfa BFA instance
  66. * param[in] bfad BFA driver instance
  67. *
  68. * return None
  69. */
  70. void
  71. bfa_fcs_init(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
  72. bfa_boolean_t min_cfg)
  73. {
  74. int i;
  75. struct bfa_fcs_mod_s *mod;
  76. fcs->bfa = bfa;
  77. fcs->bfad = bfad;
  78. fcs->min_cfg = min_cfg;
  79. bfa_attach_fcs(bfa);
  80. fcbuild_init();
  81. for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
  82. mod = &fcs_modules[i];
  83. mod->modinit(fcs);
  84. }
  85. }
  86. /**
  87. * Start FCS operations.
  88. */
  89. void
  90. bfa_fcs_start(struct bfa_fcs_s *fcs)
  91. {
  92. bfa_fcs_fabric_modstart(fcs);
  93. }
  94. /**
  95. * FCS driver details initialization.
  96. *
  97. * param[in] fcs FCS instance
  98. * param[in] driver_info Driver Details
  99. *
  100. * return None
  101. */
  102. void
  103. bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  104. struct bfa_fcs_driver_info_s *driver_info)
  105. {
  106. fcs->driver_info = *driver_info;
  107. bfa_fcs_fabric_psymb_init(&fcs->fabric);
  108. }
  109. /**
  110. * FCS instance cleanup and exit.
  111. *
  112. * param[in] fcs FCS instance
  113. * return None
  114. */
  115. void
  116. bfa_fcs_exit(struct bfa_fcs_s *fcs)
  117. {
  118. struct bfa_fcs_mod_s *mod;
  119. int nmods, i;
  120. bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
  121. nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
  122. for (i = 0; i < nmods; i++) {
  123. bfa_wc_up(&fcs->wc);
  124. mod = &fcs_modules[i];
  125. mod->modexit(fcs);
  126. }
  127. bfa_wc_wait(&fcs->wc);
  128. }
  129. void
  130. bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod)
  131. {
  132. fcs->trcmod = trcmod;
  133. }
  134. void
  135. bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod)
  136. {
  137. fcs->logm = logmod;
  138. }
  139. void
  140. bfa_fcs_aen_init(struct bfa_fcs_s *fcs, struct bfa_aen_s *aen)
  141. {
  142. fcs->aen = aen;
  143. }
  144. void
  145. bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs)
  146. {
  147. bfa_wc_down(&fcs->wc);
  148. }