bfa_fcxp_priv.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_FCXP_PRIV_H__
  18. #define __BFA_FCXP_PRIV_H__
  19. #include <cs/bfa_sm.h>
  20. #include <protocol/fc.h>
  21. #include <bfa_svc.h>
  22. #include <bfi/bfi_fcxp.h>
  23. #define BFA_FCXP_MIN (1)
  24. #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
  25. #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
  26. struct bfa_fcxp_mod_s {
  27. struct bfa_s *bfa; /* backpointer to BFA */
  28. struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
  29. u16 num_fcxps; /* max num FCXP requests */
  30. struct list_head fcxp_free_q; /* free FCXPs */
  31. struct list_head fcxp_active_q; /* active FCXPs */
  32. void *req_pld_list_kva; /* list of FCXP req pld */
  33. u64 req_pld_list_pa; /* list of FCXP req pld */
  34. void *rsp_pld_list_kva; /* list of FCXP resp pld */
  35. u64 rsp_pld_list_pa; /* list of FCXP resp pld */
  36. struct list_head wait_q; /* wait queue for free fcxp */
  37. u32 req_pld_sz;
  38. u32 rsp_pld_sz;
  39. };
  40. #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
  41. #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
  42. typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
  43. void *cb_arg, bfa_status_t req_status,
  44. u32 rsp_len, u32 resid_len,
  45. struct fchs_s *rsp_fchs);
  46. /**
  47. * Information needed for a FCXP request
  48. */
  49. struct bfa_fcxp_req_info_s {
  50. struct bfa_rport_s *bfa_rport; /* Pointer to the bfa rport that was
  51. *returned from bfa_rport_create().
  52. *This could be left NULL for WKA or for
  53. *FCXP interactions before the rport
  54. *nexus is established
  55. */
  56. struct fchs_s fchs; /* request FC header structure */
  57. u8 cts; /* continous sequence */
  58. u8 class; /* FC class for the request/response */
  59. u16 max_frmsz; /* max send frame size */
  60. u16 vf_id; /* vsan tag if applicable */
  61. u8 lp_tag; /* lport tag */
  62. u32 req_tot_len; /* request payload total length */
  63. };
  64. struct bfa_fcxp_rsp_info_s {
  65. struct fchs_s rsp_fchs; /* Response frame's FC header will
  66. * be *sent back in this field */
  67. u8 rsp_timeout; /* timeout in seconds, 0-no response
  68. */
  69. u8 rsvd2[3];
  70. u32 rsp_maxlen; /* max response length expected */
  71. };
  72. struct bfa_fcxp_s {
  73. struct list_head qe; /* fcxp queue element */
  74. bfa_sm_t sm; /* state machine */
  75. void *caller; /* driver or fcs */
  76. struct bfa_fcxp_mod_s *fcxp_mod;
  77. /* back pointer to fcxp mod */
  78. u16 fcxp_tag; /* internal tag */
  79. struct bfa_fcxp_req_info_s req_info;
  80. /* request info */
  81. struct bfa_fcxp_rsp_info_s rsp_info;
  82. /* response info */
  83. u8 use_ireqbuf; /* use internal req buf */
  84. u8 use_irspbuf; /* use internal rsp buf */
  85. u32 nreq_sgles; /* num request SGLEs */
  86. u32 nrsp_sgles; /* num response SGLEs */
  87. struct list_head req_sgpg_q; /* SG pages for request buf */
  88. struct list_head req_sgpg_wqe; /* wait queue for req SG page */
  89. struct list_head rsp_sgpg_q; /* SG pages for response buf */
  90. struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
  91. bfa_fcxp_get_sgaddr_t req_sga_cbfn;
  92. /* SG elem addr user function */
  93. bfa_fcxp_get_sglen_t req_sglen_cbfn;
  94. /* SG elem len user function */
  95. bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
  96. /* SG elem addr user function */
  97. bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
  98. /* SG elem len user function */
  99. bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
  100. void *send_cbarg; /* callback arg */
  101. struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
  102. /* req SG elems */
  103. struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
  104. /* rsp SG elems */
  105. u8 rsp_status; /* comp: rsp status */
  106. u32 rsp_len; /* comp: actual response len */
  107. u32 residue_len; /* comp: residual rsp length */
  108. struct fchs_s rsp_fchs; /* comp: response fchs */
  109. struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
  110. struct bfa_reqq_wait_s reqq_wqe;
  111. bfa_boolean_t reqq_waiting;
  112. };
  113. #define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
  114. #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
  115. #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
  116. #define BFA_FCXP_REQ_PLD_PA(_fcxp) \
  117. ((_fcxp)->fcxp_mod->req_pld_list_pa + \
  118. ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag))
  119. #define BFA_FCXP_RSP_PLD_PA(_fcxp) \
  120. ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \
  121. ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag))
  122. void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  123. #endif /* __BFA_FCXP_PRIV_H__ */