bfa_msgq.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Linux network driver for QLogic BR-series 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-2014 Brocade Communications Systems, Inc.
  15. * Copyright (c) 2014-2015 QLogic Corporation
  16. * All rights reserved
  17. * www.qlogic.com
  18. */
  19. #ifndef __BFA_MSGQ_H__
  20. #define __BFA_MSGQ_H__
  21. #include "bfa_defs.h"
  22. #include "bfi.h"
  23. #include "bfa_ioc.h"
  24. #include "bfa_cs.h"
  25. #define BFA_MSGQ_FREE_CNT(_q) \
  26. (((_q)->consumer_index - (_q)->producer_index - 1) & ((_q)->depth - 1))
  27. #define BFA_MSGQ_INDX_ADD(_q_indx, _qe_num, _q_depth) \
  28. ((_q_indx) = (((_q_indx) + (_qe_num)) & ((_q_depth) - 1)))
  29. #define BFA_MSGQ_CMDQ_NUM_ENTRY 128
  30. #define BFA_MSGQ_CMDQ_SIZE \
  31. (BFI_MSGQ_CMD_ENTRY_SIZE * BFA_MSGQ_CMDQ_NUM_ENTRY)
  32. #define BFA_MSGQ_RSPQ_NUM_ENTRY 128
  33. #define BFA_MSGQ_RSPQ_SIZE \
  34. (BFI_MSGQ_RSP_ENTRY_SIZE * BFA_MSGQ_RSPQ_NUM_ENTRY)
  35. #define bfa_msgq_cmd_set(_cmd, _cbfn, _cbarg, _msg_size, _msg_hdr) \
  36. do { \
  37. (_cmd)->cbfn = (_cbfn); \
  38. (_cmd)->cbarg = (_cbarg); \
  39. (_cmd)->msg_size = (_msg_size); \
  40. (_cmd)->msg_hdr = (_msg_hdr); \
  41. } while (0)
  42. struct bfa_msgq;
  43. typedef void (*bfa_msgq_cmdcbfn_t)(void *cbarg, enum bfa_status status);
  44. struct bfa_msgq_cmd_entry {
  45. struct list_head qe;
  46. bfa_msgq_cmdcbfn_t cbfn;
  47. void *cbarg;
  48. size_t msg_size;
  49. struct bfi_msgq_mhdr *msg_hdr;
  50. };
  51. enum bfa_msgq_cmdq_flags {
  52. BFA_MSGQ_CMDQ_F_DB_UPDATE = 1,
  53. };
  54. struct bfa_msgq_cmdq {
  55. bfa_fsm_t fsm;
  56. enum bfa_msgq_cmdq_flags flags;
  57. u16 producer_index;
  58. u16 consumer_index;
  59. u16 depth; /* FW Q depth is 16 bits */
  60. struct bfa_dma addr;
  61. struct bfa_mbox_cmd dbell_mb;
  62. u16 token;
  63. int offset;
  64. int bytes_to_copy;
  65. struct bfa_mbox_cmd copy_mb;
  66. struct list_head pending_q; /* pending command queue */
  67. struct bfa_msgq *msgq;
  68. };
  69. enum bfa_msgq_rspq_flags {
  70. BFA_MSGQ_RSPQ_F_DB_UPDATE = 1,
  71. };
  72. typedef void (*bfa_msgq_mcfunc_t)(void *cbarg, struct bfi_msgq_mhdr *mhdr);
  73. struct bfa_msgq_rspq {
  74. bfa_fsm_t fsm;
  75. enum bfa_msgq_rspq_flags flags;
  76. u16 producer_index;
  77. u16 consumer_index;
  78. u16 depth; /* FW Q depth is 16 bits */
  79. struct bfa_dma addr;
  80. struct bfa_mbox_cmd dbell_mb;
  81. int nmclass;
  82. struct {
  83. bfa_msgq_mcfunc_t cbfn;
  84. void *cbarg;
  85. } rsphdlr[BFI_MC_MAX];
  86. struct bfa_msgq *msgq;
  87. };
  88. struct bfa_msgq {
  89. struct bfa_msgq_cmdq cmdq;
  90. struct bfa_msgq_rspq rspq;
  91. struct bfa_wc init_wc;
  92. struct bfa_mbox_cmd init_mb;
  93. struct bfa_ioc_notify ioc_notify;
  94. struct bfa_ioc *ioc;
  95. };
  96. u32 bfa_msgq_meminfo(void);
  97. void bfa_msgq_memclaim(struct bfa_msgq *msgq, u8 *kva, u64 pa);
  98. void bfa_msgq_attach(struct bfa_msgq *msgq, struct bfa_ioc *ioc);
  99. void bfa_msgq_regisr(struct bfa_msgq *msgq, enum bfi_mclass mc,
  100. bfa_msgq_mcfunc_t cbfn, void *cbarg);
  101. void bfa_msgq_cmd_post(struct bfa_msgq *msgq,
  102. struct bfa_msgq_cmd_entry *cmd);
  103. void bfa_msgq_rsp_copy(struct bfa_msgq *msgq, u8 *buf, size_t buf_len);
  104. #endif