i40e_adminq.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2013 - 2018 Intel Corporation. */
  3. #ifndef _I40E_ADMINQ_H_
  4. #define _I40E_ADMINQ_H_
  5. #include "i40e_osdep.h"
  6. #include "i40e_status.h"
  7. #include "i40e_adminq_cmd.h"
  8. #define I40E_ADMINQ_DESC(R, i) \
  9. (&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
  10. #define I40E_ADMINQ_DESC_ALIGNMENT 4096
  11. struct i40e_adminq_ring {
  12. struct i40e_virt_mem dma_head; /* space for dma structures */
  13. struct i40e_dma_mem desc_buf; /* descriptor ring memory */
  14. struct i40e_virt_mem cmd_buf; /* command buffer memory */
  15. union {
  16. struct i40e_dma_mem *asq_bi;
  17. struct i40e_dma_mem *arq_bi;
  18. } r;
  19. u16 count; /* Number of descriptors */
  20. u16 rx_buf_len; /* Admin Receive Queue buffer length */
  21. /* used for interrupt processing */
  22. u16 next_to_use;
  23. u16 next_to_clean;
  24. /* used for queue tracking */
  25. u32 head;
  26. u32 tail;
  27. u32 len;
  28. u32 bah;
  29. u32 bal;
  30. };
  31. /* ASQ transaction details */
  32. struct i40e_asq_cmd_details {
  33. void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
  34. u64 cookie;
  35. u16 flags_ena;
  36. u16 flags_dis;
  37. bool async;
  38. bool postpone;
  39. struct i40e_aq_desc *wb_desc;
  40. };
  41. #define I40E_ADMINQ_DETAILS(R, i) \
  42. (&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
  43. /* ARQ event information */
  44. struct i40e_arq_event_info {
  45. struct i40e_aq_desc desc;
  46. u16 msg_len;
  47. u16 buf_len;
  48. u8 *msg_buf;
  49. };
  50. /* Admin Queue information */
  51. struct i40e_adminq_info {
  52. struct i40e_adminq_ring arq; /* receive queue */
  53. struct i40e_adminq_ring asq; /* send queue */
  54. u32 asq_cmd_timeout; /* send queue cmd write back timeout*/
  55. u16 num_arq_entries; /* receive queue depth */
  56. u16 num_asq_entries; /* send queue depth */
  57. u16 arq_buf_size; /* receive queue buffer size */
  58. u16 asq_buf_size; /* send queue buffer size */
  59. u16 fw_maj_ver; /* firmware major version */
  60. u16 fw_min_ver; /* firmware minor version */
  61. u32 fw_build; /* firmware build number */
  62. u16 api_maj_ver; /* api major version */
  63. u16 api_min_ver; /* api minor version */
  64. struct mutex asq_mutex; /* Send queue lock */
  65. struct mutex arq_mutex; /* Receive queue lock */
  66. /* last status values on send and receive queues */
  67. enum i40e_admin_queue_err asq_last_status;
  68. enum i40e_admin_queue_err arq_last_status;
  69. };
  70. /**
  71. * i40e_aq_rc_to_posix - convert errors to user-land codes
  72. * aq_ret: AdminQ handler error code can override aq_rc
  73. * aq_rc: AdminQ firmware error code to convert
  74. **/
  75. static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
  76. {
  77. int aq_to_posix[] = {
  78. 0, /* I40E_AQ_RC_OK */
  79. -EPERM, /* I40E_AQ_RC_EPERM */
  80. -ENOENT, /* I40E_AQ_RC_ENOENT */
  81. -ESRCH, /* I40E_AQ_RC_ESRCH */
  82. -EINTR, /* I40E_AQ_RC_EINTR */
  83. -EIO, /* I40E_AQ_RC_EIO */
  84. -ENXIO, /* I40E_AQ_RC_ENXIO */
  85. -E2BIG, /* I40E_AQ_RC_E2BIG */
  86. -EAGAIN, /* I40E_AQ_RC_EAGAIN */
  87. -ENOMEM, /* I40E_AQ_RC_ENOMEM */
  88. -EACCES, /* I40E_AQ_RC_EACCES */
  89. -EFAULT, /* I40E_AQ_RC_EFAULT */
  90. -EBUSY, /* I40E_AQ_RC_EBUSY */
  91. -EEXIST, /* I40E_AQ_RC_EEXIST */
  92. -EINVAL, /* I40E_AQ_RC_EINVAL */
  93. -ENOTTY, /* I40E_AQ_RC_ENOTTY */
  94. -ENOSPC, /* I40E_AQ_RC_ENOSPC */
  95. -ENOSYS, /* I40E_AQ_RC_ENOSYS */
  96. -ERANGE, /* I40E_AQ_RC_ERANGE */
  97. -EPIPE, /* I40E_AQ_RC_EFLUSHED */
  98. -ESPIPE, /* I40E_AQ_RC_BAD_ADDR */
  99. -EROFS, /* I40E_AQ_RC_EMODE */
  100. -EFBIG, /* I40E_AQ_RC_EFBIG */
  101. };
  102. /* aq_rc is invalid if AQ timed out */
  103. if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
  104. return -EAGAIN;
  105. if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
  106. return -ERANGE;
  107. return aq_to_posix[aq_rc];
  108. }
  109. /* general information */
  110. #define I40E_AQ_LARGE_BUF 512
  111. #define I40E_ASQ_CMD_TIMEOUT 250000 /* usecs */
  112. void i40evf_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
  113. u16 opcode);
  114. #endif /* _I40E_ADMINQ_H_ */