ice_controlq.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 timeout settings - max delay 1s */
  26. #define ICE_CTL_Q_SQ_CMD_TIMEOUT 10000 /* Count 10000 times */
  27. #define ICE_CTL_Q_SQ_CMD_USEC 100 /* Check every 100usec */
  28. struct ice_ctl_q_ring {
  29. void *dma_head; /* Virtual address to dma head */
  30. struct ice_dma_mem desc_buf; /* descriptor ring memory */
  31. void *cmd_buf; /* command buffer memory */
  32. union {
  33. struct ice_dma_mem *sq_bi;
  34. struct ice_dma_mem *rq_bi;
  35. } r;
  36. u16 count; /* Number of descriptors */
  37. /* used for interrupt processing */
  38. u16 next_to_use;
  39. u16 next_to_clean;
  40. /* used for queue tracking */
  41. u32 head;
  42. u32 tail;
  43. u32 len;
  44. u32 bah;
  45. u32 bal;
  46. u32 len_mask;
  47. u32 len_ena_mask;
  48. u32 head_mask;
  49. };
  50. /* sq transaction details */
  51. struct ice_sq_cd {
  52. struct ice_aq_desc *wb_desc;
  53. };
  54. #define ICE_CTL_Q_DETAILS(R, i) (&(((struct ice_sq_cd *)((R).cmd_buf))[i]))
  55. /* rq event information */
  56. struct ice_rq_event_info {
  57. struct ice_aq_desc desc;
  58. u16 msg_len;
  59. u16 buf_len;
  60. u8 *msg_buf;
  61. };
  62. /* Control Queue information */
  63. struct ice_ctl_q_info {
  64. enum ice_ctl_q qtype;
  65. struct ice_ctl_q_ring rq; /* receive queue */
  66. struct ice_ctl_q_ring sq; /* send queue */
  67. u32 sq_cmd_timeout; /* send queue cmd write back timeout */
  68. u16 num_rq_entries; /* receive queue depth */
  69. u16 num_sq_entries; /* send queue depth */
  70. u16 rq_buf_size; /* receive queue buffer size */
  71. u16 sq_buf_size; /* send queue buffer size */
  72. struct mutex sq_lock; /* Send queue lock */
  73. struct mutex rq_lock; /* Receive queue lock */
  74. enum ice_aq_err sq_last_status; /* last status on send queue */
  75. enum ice_aq_err rq_last_status; /* last status on receive queue */
  76. };
  77. #endif /* _ICE_CONTROLQ_H_ */