ice_controlq.h 2.4 KB

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