bfa_msgq.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Linux network driver for Brocade Converged Network Adapter.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License (GPL) Version 2 as
  6. * published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. /*
  14. * Copyright (c) 2005-2011 Brocade Communications Systems, Inc.
  15. * All rights reserved
  16. * www.brocade.com
  17. */
  18. #ifndef __BFA_MSGQ_H__
  19. #define __BFA_MSGQ_H__
  20. #include "bfa_defs.h"
  21. #include "bfi.h"
  22. #include "bfa_ioc.h"
  23. #include "bfa_cs.h"
  24. #define BFA_MSGQ_FREE_CNT(_q) \
  25. (((_q)->consumer_index - (_q)->producer_index - 1) & ((_q)->depth - 1))
  26. #define BFA_MSGQ_INDX_ADD(_q_indx, _qe_num, _q_depth) \
  27. ((_q_indx) = (((_q_indx) + (_qe_num)) & ((_q_depth) - 1)))
  28. #define BFA_MSGQ_CMDQ_NUM_ENTRY 128
  29. #define BFA_MSGQ_CMDQ_SIZE \
  30. (BFI_MSGQ_CMD_ENTRY_SIZE * BFA_MSGQ_CMDQ_NUM_ENTRY)
  31. #define BFA_MSGQ_RSPQ_NUM_ENTRY 128
  32. #define BFA_MSGQ_RSPQ_SIZE \
  33. (BFI_MSGQ_RSP_ENTRY_SIZE * BFA_MSGQ_RSPQ_NUM_ENTRY)
  34. #define bfa_msgq_cmd_set(_cmd, _cbfn, _cbarg, _msg_size, _msg_hdr) \
  35. do { \
  36. (_cmd)->cbfn = (_cbfn); \
  37. (_cmd)->cbarg = (_cbarg); \
  38. (_cmd)->msg_size = (_msg_size); \
  39. (_cmd)->msg_hdr = (_msg_hdr); \
  40. } while (0)
  41. struct bfa_msgq;
  42. typedef void (*bfa_msgq_cmdcbfn_t)(void *cbarg, enum bfa_status status);
  43. struct bfa_msgq_cmd_entry {
  44. struct list_head qe;
  45. bfa_msgq_cmdcbfn_t cbfn;
  46. void *cbarg;
  47. size_t msg_size;
  48. struct bfi_msgq_mhdr *msg_hdr;
  49. };
  50. enum bfa_msgq_cmdq_flags {
  51. BFA_MSGQ_CMDQ_F_DB_UPDATE = 1,
  52. };
  53. struct bfa_msgq_cmdq {
  54. bfa_fsm_t fsm;
  55. enum bfa_msgq_cmdq_flags flags;
  56. u16 producer_index;
  57. u16 consumer_index;
  58. u16 depth; /* FW Q depth is 16 bits */
  59. struct bfa_dma addr;
  60. struct bfa_mbox_cmd dbell_mb;
  61. u16 token;
  62. int offset;
  63. int bytes_to_copy;
  64. struct bfa_mbox_cmd copy_mb;
  65. struct list_head pending_q; /* pending command queue */
  66. struct bfa_msgq *msgq;
  67. };
  68. enum bfa_msgq_rspq_flags {
  69. BFA_MSGQ_RSPQ_F_DB_UPDATE = 1,
  70. };
  71. typedef void (*bfa_msgq_mcfunc_t)(void *cbarg, struct bfi_msgq_mhdr *mhdr);
  72. struct bfa_msgq_rspq {
  73. bfa_fsm_t fsm;
  74. enum bfa_msgq_rspq_flags flags;
  75. u16 producer_index;
  76. u16 consumer_index;
  77. u16 depth; /* FW Q depth is 16 bits */
  78. struct bfa_dma addr;
  79. struct bfa_mbox_cmd dbell_mb;
  80. int nmclass;
  81. struct {
  82. bfa_msgq_mcfunc_t cbfn;
  83. void *cbarg;
  84. } rsphdlr[BFI_MC_MAX];
  85. struct bfa_msgq *msgq;
  86. };
  87. struct bfa_msgq {
  88. struct bfa_msgq_cmdq cmdq;
  89. struct bfa_msgq_rspq rspq;
  90. struct bfa_wc init_wc;
  91. struct bfa_mbox_cmd init_mb;
  92. struct bfa_ioc_notify ioc_notify;
  93. struct bfa_ioc *ioc;
  94. };
  95. u32 bfa_msgq_meminfo(void);
  96. void bfa_msgq_memclaim(struct bfa_msgq *msgq, u8 *kva, u64 pa);
  97. void bfa_msgq_attach(struct bfa_msgq *msgq, struct bfa_ioc *ioc);
  98. void bfa_msgq_regisr(struct bfa_msgq *msgq, enum bfi_mclass mc,
  99. bfa_msgq_mcfunc_t cbfn, void *cbarg);
  100. void bfa_msgq_cmd_post(struct bfa_msgq *msgq,
  101. struct bfa_msgq_cmd_entry *cmd);
  102. void bfa_msgq_rsp_copy(struct bfa_msgq *msgq, u8 *buf, size_t buf_len);
  103. #endif