bfa_svc.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. #ifndef __BFA_SVC_H__
  18. #define __BFA_SVC_H__
  19. /*
  20. * forward declarations
  21. */
  22. struct bfa_fcxp_s;
  23. #include <defs/bfa_defs_status.h>
  24. #include <defs/bfa_defs_pport.h>
  25. #include <defs/bfa_defs_rport.h>
  26. #include <defs/bfa_defs_qos.h>
  27. #include <defs/bfa_defs_fcport.h>
  28. #include <cs/bfa_sm.h>
  29. #include <bfa.h>
  30. /**
  31. * BFA rport information.
  32. */
  33. struct bfa_rport_info_s {
  34. u16 max_frmsz; /* max rcv pdu size */
  35. u32 pid:24, /* remote port ID */
  36. lp_tag:8; /* tag */
  37. u32 local_pid:24, /* local port ID */
  38. cisc:8; /* CIRO supported */
  39. u8 fc_class; /* supported FC classes. enum fc_cos */
  40. u8 vf_en; /* virtual fabric enable */
  41. u16 vf_id; /* virtual fabric ID */
  42. enum bfa_pport_speed speed; /* Rport's current speed */
  43. };
  44. /**
  45. * BFA rport data structure
  46. */
  47. struct bfa_rport_s {
  48. struct list_head qe; /* queue element */
  49. bfa_sm_t sm; /* state machine */
  50. struct bfa_s *bfa; /* backpointer to BFA */
  51. void *rport_drv; /* fcs/driver rport object */
  52. u16 fw_handle; /* firmware rport handle */
  53. u16 rport_tag; /* BFA rport tag */
  54. struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
  55. struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
  56. struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
  57. struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
  58. struct bfa_rport_qos_attr_s qos_attr;
  59. union a {
  60. bfa_status_t status; /* f/w status */
  61. void *fw_msg; /* QoS scn event */
  62. } event_arg;
  63. };
  64. #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
  65. /**
  66. * Send completion callback.
  67. */
  68. typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
  69. void *cbarg, enum bfa_status req_status,
  70. u32 rsp_len, u32 resid_len,
  71. struct fchs_s *rsp_fchs);
  72. /**
  73. * BFA fcxp allocation (asynchronous)
  74. */
  75. typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
  76. struct bfa_fcxp_wqe_s {
  77. struct list_head qe;
  78. bfa_fcxp_alloc_cbfn_t alloc_cbfn;
  79. void *alloc_cbarg;
  80. };
  81. typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
  82. typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
  83. #define BFA_UF_BUFSZ (2 * 1024 + 256)
  84. /**
  85. * @todo private
  86. */
  87. struct bfa_uf_buf_s {
  88. u8 d[BFA_UF_BUFSZ];
  89. };
  90. struct bfa_uf_s {
  91. struct list_head qe; /* queue element */
  92. struct bfa_s *bfa; /* bfa instance */
  93. u16 uf_tag; /* identifying tag fw msgs */
  94. u16 vf_id;
  95. u16 src_rport_handle;
  96. u16 rsvd;
  97. u8 *data_ptr;
  98. u16 data_len; /* actual receive length */
  99. u16 pb_len; /* posted buffer length */
  100. void *buf_kva; /* buffer virtual address */
  101. u64 buf_pa; /* buffer physical address */
  102. struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
  103. struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
  104. };
  105. typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
  106. /**
  107. * bfa lport login/logout service interface
  108. */
  109. struct bfa_lps_s {
  110. struct list_head qe; /* queue element */
  111. struct bfa_s *bfa; /* parent bfa instance */
  112. bfa_sm_t sm; /* finite state machine */
  113. u8 lp_tag; /* lport tag */
  114. u8 reqq; /* lport request queue */
  115. u8 alpa; /* ALPA for loop topologies */
  116. u32 lp_pid; /* lport port ID */
  117. bfa_boolean_t fdisc; /* send FDISC instead of FLOGI */
  118. bfa_boolean_t auth_en; /* enable authentication */
  119. bfa_boolean_t auth_req; /* authentication required */
  120. bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
  121. bfa_boolean_t fport; /* attached peer is F_PORT */
  122. bfa_boolean_t brcd_switch;/* attached peer is brcd switch */
  123. bfa_status_t status; /* login status */
  124. u16 pdusz; /* max receive PDU size */
  125. u16 pr_bbcred; /* BB_CREDIT from peer */
  126. u8 lsrjt_rsn; /* LSRJT reason */
  127. u8 lsrjt_expl; /* LSRJT explanation */
  128. wwn_t pwwn; /* port wwn of lport */
  129. wwn_t nwwn; /* node wwn of lport */
  130. wwn_t pr_pwwn; /* port wwn of lport peer */
  131. wwn_t pr_nwwn; /* node wwn of lport peer */
  132. mac_t lp_mac; /* fpma/spma MAC for lport */
  133. mac_t fcf_mac; /* FCF MAC of lport */
  134. struct bfa_reqq_wait_s wqe; /* request wait queue element */
  135. void *uarg; /* user callback arg */
  136. struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
  137. struct bfi_lps_login_rsp_s *loginrsp;
  138. bfa_eproto_status_t ext_status;
  139. };
  140. #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
  141. /*
  142. * bfa pport API functions
  143. */
  144. bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
  145. bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
  146. bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
  147. enum bfa_pport_speed speed);
  148. enum bfa_pport_speed bfa_fcport_get_speed(struct bfa_s *bfa);
  149. bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
  150. enum bfa_pport_topology topo);
  151. enum bfa_pport_topology bfa_fcport_get_topology(struct bfa_s *bfa);
  152. bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
  153. bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
  154. u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
  155. bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
  156. bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
  157. u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
  158. u32 bfa_fcport_mypid(struct bfa_s *bfa);
  159. u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
  160. bfa_status_t bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap);
  161. bfa_status_t bfa_fcport_trunk_disable(struct bfa_s *bfa);
  162. bfa_boolean_t bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap);
  163. void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr);
  164. wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
  165. void bfa_fcport_event_register(struct bfa_s *bfa,
  166. void (*event_cbfn) (void *cbarg,
  167. bfa_pport_event_t event), void *event_cbarg);
  168. bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
  169. void bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off);
  170. void bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off);
  171. bfa_status_t bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa,
  172. enum bfa_pport_speed speed);
  173. enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
  174. void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
  175. void bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status);
  176. void bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon,
  177. bfa_boolean_t link_e2e_beacon);
  178. void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event);
  179. void bfa_fcport_qos_get_attr(struct bfa_s *bfa,
  180. struct bfa_qos_attr_s *qos_attr);
  181. void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa,
  182. struct bfa_qos_vc_attr_s *qos_vc_attr);
  183. bfa_status_t bfa_fcport_get_qos_stats(struct bfa_s *bfa,
  184. union bfa_fcport_stats_u *stats,
  185. bfa_cb_pport_t cbfn, void *cbarg);
  186. bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
  187. void *cbarg);
  188. bfa_status_t bfa_fcport_get_fcoe_stats(struct bfa_s *bfa,
  189. union bfa_fcport_stats_u *stats,
  190. bfa_cb_pport_t cbfn, void *cbarg);
  191. bfa_status_t bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
  192. void *cbarg);
  193. bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
  194. bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
  195. bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
  196. union bfa_fcport_stats_u *stats,
  197. bfa_cb_pport_t cbfn, void *cbarg);
  198. bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
  199. void *cbarg);
  200. bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
  201. /*
  202. * bfa rport API functions
  203. */
  204. struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
  205. void bfa_rport_delete(struct bfa_rport_s *rport);
  206. void bfa_rport_online(struct bfa_rport_s *rport,
  207. struct bfa_rport_info_s *rport_info);
  208. void bfa_rport_offline(struct bfa_rport_s *rport);
  209. void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed);
  210. void bfa_rport_get_stats(struct bfa_rport_s *rport,
  211. struct bfa_rport_hal_stats_s *stats);
  212. void bfa_rport_clear_stats(struct bfa_rport_s *rport);
  213. void bfa_cb_rport_online(void *rport);
  214. void bfa_cb_rport_offline(void *rport);
  215. void bfa_cb_rport_qos_scn_flowid(void *rport,
  216. struct bfa_rport_qos_attr_s old_qos_attr,
  217. struct bfa_rport_qos_attr_s new_qos_attr);
  218. void bfa_cb_rport_qos_scn_prio(void *rport,
  219. struct bfa_rport_qos_attr_s old_qos_attr,
  220. struct bfa_rport_qos_attr_s new_qos_attr);
  221. void bfa_rport_get_qos_attr(struct bfa_rport_s *rport,
  222. struct bfa_rport_qos_attr_s *qos_attr);
  223. /*
  224. * bfa fcxp API functions
  225. */
  226. struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
  227. int nreq_sgles, int nrsp_sgles,
  228. bfa_fcxp_get_sgaddr_t get_req_sga,
  229. bfa_fcxp_get_sglen_t get_req_sglen,
  230. bfa_fcxp_get_sgaddr_t get_rsp_sga,
  231. bfa_fcxp_get_sglen_t get_rsp_sglen);
  232. void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
  233. bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *cbarg);
  234. void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
  235. struct bfa_fcxp_wqe_s *wqe);
  236. void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
  237. void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
  238. void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
  239. void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
  240. void bfa_fcxp_send(struct bfa_fcxp_s *fcxp,
  241. struct bfa_rport_s *rport, u16 vf_id, u8 lp_tag,
  242. bfa_boolean_t cts, enum fc_cos cos,
  243. u32 reqlen, struct fchs_s *fchs,
  244. bfa_cb_fcxp_send_t cbfn,
  245. void *cbarg,
  246. u32 rsp_maxlen, u8 rsp_timeout);
  247. bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
  248. u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
  249. u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
  250. static inline void *
  251. bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
  252. {
  253. return uf->data_ptr;
  254. }
  255. static inline u16
  256. bfa_uf_get_frmlen(struct bfa_uf_s *uf)
  257. {
  258. return uf->data_len;
  259. }
  260. /**
  261. * Callback prototype for unsolicited frame receive handler.
  262. *
  263. * @param[in] cbarg callback arg for receive handler
  264. * @param[in] uf unsolicited frame descriptor
  265. *
  266. * @return None
  267. */
  268. typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
  269. /*
  270. * bfa uf API functions
  271. */
  272. void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
  273. void *cbarg);
  274. void bfa_uf_free(struct bfa_uf_s *uf);
  275. /**
  276. * bfa lport service api
  277. */
  278. u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
  279. struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
  280. void bfa_lps_delete(struct bfa_lps_s *lps);
  281. void bfa_lps_discard(struct bfa_lps_s *lps);
  282. void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
  283. wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en);
  284. void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
  285. wwn_t nwwn);
  286. void bfa_lps_flogo(struct bfa_lps_s *lps);
  287. void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
  288. u8 bfa_lps_get_tag(struct bfa_lps_s *lps);
  289. bfa_boolean_t bfa_lps_is_npiv_en(struct bfa_lps_s *lps);
  290. bfa_boolean_t bfa_lps_is_fport(struct bfa_lps_s *lps);
  291. bfa_boolean_t bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps);
  292. bfa_boolean_t bfa_lps_is_authreq(struct bfa_lps_s *lps);
  293. bfa_eproto_status_t bfa_lps_get_extstatus(struct bfa_lps_s *lps);
  294. u32 bfa_lps_get_pid(struct bfa_lps_s *lps);
  295. u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
  296. u16 bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps);
  297. wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps);
  298. wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps);
  299. u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps);
  300. u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps);
  301. mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps);
  302. void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
  303. void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
  304. void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
  305. void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
  306. void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
  307. #endif /* __BFA_SVC_H__ */