vfapi.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. * vfapi.c Fabric module implementation.
  19. */
  20. #include "fcs_fabric.h"
  21. #include "fcs_trcmod.h"
  22. BFA_TRC_FILE(FCS, VFAPI);
  23. /**
  24. * fcs_vf_api virtual fabrics API
  25. */
  26. /**
  27. * Enable VF mode.
  28. *
  29. * @param[in] fcs fcs module instance
  30. * @param[in] vf_id default vf_id of port, FC_VF_ID_NULL
  31. * to use standard default vf_id of 1.
  32. *
  33. * @retval BFA_STATUS_OK vf mode is enabled
  34. * @retval BFA_STATUS_BUSY Port is active. Port must be disabled
  35. * before VF mode can be enabled.
  36. */
  37. bfa_status_t
  38. bfa_fcs_vf_mode_enable(struct bfa_fcs_s *fcs, u16 vf_id)
  39. {
  40. return BFA_STATUS_OK;
  41. }
  42. /**
  43. * Disable VF mode.
  44. *
  45. * @param[in] fcs fcs module instance
  46. *
  47. * @retval BFA_STATUS_OK vf mode is disabled
  48. * @retval BFA_STATUS_BUSY VFs are present and being used. All
  49. * VFs must be deleted before disabling
  50. * VF mode.
  51. */
  52. bfa_status_t
  53. bfa_fcs_vf_mode_disable(struct bfa_fcs_s *fcs)
  54. {
  55. return BFA_STATUS_OK;
  56. }
  57. /**
  58. * Create a new VF instance.
  59. *
  60. * A new VF is created using the given VF configuration. A VF is identified
  61. * by VF id. No duplicate VF creation is allowed with the same VF id. Once
  62. * a VF is created, VF is automatically started after link initialization
  63. * and EVFP exchange is completed.
  64. *
  65. * param[in] vf - FCS vf data structure. Memory is
  66. * allocated by caller (driver)
  67. * param[in] fcs - FCS module
  68. * param[in] vf_cfg - VF configuration
  69. * param[in] vf_drv - Opaque handle back to the driver's
  70. * virtual vf structure
  71. *
  72. * retval BFA_STATUS_OK VF creation is successful
  73. * retval BFA_STATUS_FAILED VF creation failed
  74. * retval BFA_STATUS_EEXIST A VF exists with the given vf_id
  75. */
  76. bfa_status_t
  77. bfa_fcs_vf_create(bfa_fcs_vf_t *vf, struct bfa_fcs_s *fcs, u16 vf_id,
  78. struct bfa_port_cfg_s *port_cfg, struct bfad_vf_s *vf_drv)
  79. {
  80. bfa_trc(fcs, vf_id);
  81. return BFA_STATUS_OK;
  82. }
  83. /**
  84. * Use this function to delete a BFA VF object. VF object should
  85. * be stopped before this function call.
  86. *
  87. * param[in] vf - pointer to bfa_vf_t.
  88. *
  89. * retval BFA_STATUS_OK On vf deletion success
  90. * retval BFA_STATUS_BUSY VF is not in a stopped state
  91. * retval BFA_STATUS_INPROGRESS VF deletion in in progress
  92. */
  93. bfa_status_t
  94. bfa_fcs_vf_delete(bfa_fcs_vf_t *vf)
  95. {
  96. bfa_trc(vf->fcs, vf->vf_id);
  97. return BFA_STATUS_OK;
  98. }
  99. /**
  100. * Start participation in VF. This triggers login to the virtual fabric.
  101. *
  102. * param[in] vf - pointer to bfa_vf_t.
  103. *
  104. * return None
  105. */
  106. void
  107. bfa_fcs_vf_start(bfa_fcs_vf_t *vf)
  108. {
  109. bfa_trc(vf->fcs, vf->vf_id);
  110. }
  111. /**
  112. * Logout with the virtual fabric.
  113. *
  114. * param[in] vf - pointer to bfa_vf_t.
  115. *
  116. * retval BFA_STATUS_OK On success.
  117. * retval BFA_STATUS_INPROGRESS VF is being stopped.
  118. */
  119. bfa_status_t
  120. bfa_fcs_vf_stop(bfa_fcs_vf_t *vf)
  121. {
  122. bfa_trc(vf->fcs, vf->vf_id);
  123. return BFA_STATUS_OK;
  124. }
  125. /**
  126. * Returns attributes of the given VF.
  127. *
  128. * param[in] vf pointer to bfa_vf_t.
  129. * param[out] vf_attr vf attributes returned
  130. *
  131. * return None
  132. */
  133. void
  134. bfa_fcs_vf_get_attr(bfa_fcs_vf_t *vf, struct bfa_vf_attr_s *vf_attr)
  135. {
  136. bfa_trc(vf->fcs, vf->vf_id);
  137. }
  138. /**
  139. * Return statistics associated with the given vf.
  140. *
  141. * param[in] vf pointer to bfa_vf_t.
  142. * param[out] vf_stats vf statistics returned
  143. *
  144. * @return None
  145. */
  146. void
  147. bfa_fcs_vf_get_stats(bfa_fcs_vf_t *vf, struct bfa_vf_stats_s *vf_stats)
  148. {
  149. bfa_os_memcpy(vf_stats, &vf->stats, sizeof(struct bfa_vf_stats_s));
  150. return;
  151. }
  152. void
  153. /**
  154. * clear statistics associated with the given vf.
  155. *
  156. * param[in] vf pointer to bfa_vf_t.
  157. *
  158. * @return None
  159. */
  160. bfa_fcs_vf_clear_stats(bfa_fcs_vf_t *vf)
  161. {
  162. bfa_os_memset(&vf->stats, 0, sizeof(struct bfa_vf_stats_s));
  163. return;
  164. }
  165. /**
  166. * Returns FCS vf structure for a given vf_id.
  167. *
  168. * param[in] vf_id - VF_ID
  169. *
  170. * return
  171. * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
  172. */
  173. bfa_fcs_vf_t *
  174. bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
  175. {
  176. bfa_trc(fcs, vf_id);
  177. if (vf_id == FC_VF_ID_NULL)
  178. return &fcs->fabric;
  179. /**
  180. * @todo vf support
  181. */
  182. return NULL;
  183. }
  184. /**
  185. * Returns driver VF structure for a given FCS vf.
  186. *
  187. * param[in] vf - pointer to bfa_vf_t
  188. *
  189. * return Driver VF structure
  190. */
  191. struct bfad_vf_s *
  192. bfa_fcs_vf_get_drv_vf(bfa_fcs_vf_t *vf)
  193. {
  194. bfa_assert(vf);
  195. bfa_trc(vf->fcs, vf->vf_id);
  196. return vf->vf_drv;
  197. }
  198. /**
  199. * Return the list of VFs configured.
  200. *
  201. * param[in] fcs fcs module instance
  202. * param[out] vf_ids returned list of vf_ids
  203. * param[in,out] nvfs in:size of vf_ids array,
  204. * out:total elements present,
  205. * actual elements returned is limited by the size
  206. *
  207. * return Driver VF structure
  208. */
  209. void
  210. bfa_fcs_vf_list(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs)
  211. {
  212. bfa_trc(fcs, *nvfs);
  213. }
  214. /**
  215. * Return the list of all VFs visible from fabric.
  216. *
  217. * param[in] fcs fcs module instance
  218. * param[out] vf_ids returned list of vf_ids
  219. * param[in,out] nvfs in:size of vf_ids array,
  220. * out:total elements present,
  221. * actual elements returned is limited by the size
  222. *
  223. * return Driver VF structure
  224. */
  225. void
  226. bfa_fcs_vf_list_all(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs)
  227. {
  228. bfa_trc(fcs, *nvfs);
  229. }
  230. /**
  231. * Return the list of local logical ports present in the given VF.
  232. *
  233. * param[in] vf vf for which logical ports are returned
  234. * param[out] lpwwn returned logical port wwn list
  235. * param[in,out] nlports in:size of lpwwn list;
  236. * out:total elements present,
  237. * actual elements returned is limited by the size
  238. *
  239. */
  240. void
  241. bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t lpwwn[], int *nlports)
  242. {
  243. struct list_head *qe;
  244. struct bfa_fcs_vport_s *vport;
  245. int i;
  246. struct bfa_fcs_s *fcs;
  247. if (vf == NULL || lpwwn == NULL || *nlports == 0)
  248. return;
  249. fcs = vf->fcs;
  250. bfa_trc(fcs, vf->vf_id);
  251. bfa_trc(fcs, (u32) *nlports);
  252. i = 0;
  253. lpwwn[i++] = vf->bport.port_cfg.pwwn;
  254. list_for_each(qe, &vf->vport_q) {
  255. if (i >= *nlports)
  256. break;
  257. vport = (struct bfa_fcs_vport_s *) qe;
  258. lpwwn[i++] = vport->lport.port_cfg.pwwn;
  259. }
  260. bfa_trc(fcs, i);
  261. *nlports = i;
  262. return;
  263. }