ice_controlq.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_CONTROLQ_H_
  4. #define _ICE_CONTROLQ_H_
  5. #include "ice_adminq_cmd.h"
  6. /* Maximum buffer lengths for all control queue types */
  7. #define ICE_AQ_MAX_BUF_LEN 4096
  8. #define ICE_MBXQ_MAX_BUF_LEN 4096
  9. #define ICE_CTL_Q_DESC(R, i) \
  10. (&(((struct ice_aq_desc *)((R).desc_buf.va))[i]))
  11. #define ICE_CTL_Q_DESC_UNUSED(R) \
  12. (u16)((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  13. (R)->next_to_clean - (R)->next_to_use - 1)
  14. /* Defines that help manage the driver vs FW API checks.
  15. * Take a look at ice_aq_ver_check in ice_controlq.c for actual usage.
  16. *
  17. */
  18. #define EXP_FW_API_VER_BRANCH 0x00
  19. #define EXP_FW_API_VER_MAJOR 0x00
  20. #define EXP_FW_API_VER_MINOR 0x01
  21. /* Different control queue types: These are mainly for SW consumption. */
  22. enum ice_ctl_q {
  23. ICE_CTL_Q_UNKNOWN = 0,
  24. ICE_CTL_Q_ADMIN,
  25. ICE_CTL_Q_MAILBOX,
  26. };
  27. /* Control Queue default settings */
  28. #define ICE_CTL_Q_SQ_CMD_TIMEOUT 250 /* msecs */
  29. struct ice_ctl_q_ring {
  30. void *dma_head; /* Virtual address to dma head */
  31. struct ice_dma_mem desc_buf; /* descriptor ring memory */
  32. void *cmd_buf; /* command buffer memory */
  33. union {
  34. struct ice_dma_mem *sq_bi;
  35. struct ice_dma_mem *rq_bi;
  36. } r;
  37. u16 count; /* Number of descriptors */
  38. /* used for interrupt processing */
  39. u16 next_to_use;
  40. u16 next_to_clean;
  41. /* used for queue tracking */
  42. u32 head;
  43. u32 tail;
  44. u32 len;
  45. u32 bah;
  46. u32 bal;
  47. u32 len_mask;
  48. u32 len_ena_mask;
  49. u32 head_mask;
  50. };
  51. /* sq transaction details */
  52. struct ice_sq_cd {
  53. struct ice_aq_desc *wb_desc;
  54. };
  55. #define ICE_CTL_Q_DETAILS(R, i) (&(((struct ice_sq_cd *)((R).cmd_buf))[i]))
  56. /* rq event information */
  57. struct ice_rq_event_info {
  58. struct ice_aq_desc desc;
  59. u16 msg_len;
  60. u16 buf_len;
  61. u8 *msg_buf;
  62. };
  63. /* Control Queue information */
  64. struct ice_ctl_q_info {
  65. enum ice_ctl_q qtype;
  66. struct ice_ctl_q_ring rq; /* receive queue */
  67. struct ice_ctl_q_ring sq; /* send queue */
  68. u32 sq_cmd_timeout; /* send queue cmd write back timeout */
  69. u16 num_rq_entries; /* receive queue depth */
  70. u16 num_sq_entries; /* send queue depth */
  71. u16 rq_buf_size; /* receive queue buffer size */
  72. u16 sq_buf_size; /* send queue buffer size */
  73. struct mutex sq_lock; /* Send queue lock */
  74. struct mutex rq_lock; /* Receive queue lock */
  75. enum ice_aq_err sq_last_status; /* last status on send queue */
  76. enum ice_aq_err rq_last_status; /* last status on receive queue */
  77. };
  78. #endif /* _ICE_CONTROLQ_H_ */