bfa_svc.h 12 KB

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