i40e_adminq.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 <linux/mutex.h>
  6. #include "i40e_alloc.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. };
  25. /* ASQ transaction details */
  26. struct i40e_asq_cmd_details {
  27. void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
  28. u64 cookie;
  29. u16 flags_ena;
  30. u16 flags_dis;
  31. bool async;
  32. bool postpone;
  33. struct i40e_aq_desc *wb_desc;
  34. };
  35. #define I40E_ADMINQ_DETAILS(R, i) \
  36. (&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
  37. /* ARQ event information */
  38. struct i40e_arq_event_info {
  39. struct i40e_aq_desc desc;
  40. u16 msg_len;
  41. u16 buf_len;
  42. u8 *msg_buf;
  43. };
  44. /* Admin Queue information */
  45. struct i40e_adminq_info {
  46. struct i40e_adminq_ring arq; /* receive queue */
  47. struct i40e_adminq_ring asq; /* send queue */
  48. u32 asq_cmd_timeout; /* send queue cmd write back timeout*/
  49. u16 num_arq_entries; /* receive queue depth */
  50. u16 num_asq_entries; /* send queue depth */
  51. u16 arq_buf_size; /* receive queue buffer size */
  52. u16 asq_buf_size; /* send queue buffer size */
  53. u16 fw_maj_ver; /* firmware major version */
  54. u16 fw_min_ver; /* firmware minor version */
  55. u32 fw_build; /* firmware build number */
  56. u16 api_maj_ver; /* api major version */
  57. u16 api_min_ver; /* api minor version */
  58. struct mutex asq_mutex; /* Send queue lock */
  59. struct mutex arq_mutex; /* Receive queue lock */
  60. /* last status values on send and receive queues */
  61. enum i40e_admin_queue_err asq_last_status;
  62. enum i40e_admin_queue_err arq_last_status;
  63. };
  64. /**
  65. * i40e_aq_rc_to_posix - convert errors to user-land codes
  66. * @aq_ret: AdminQ handler error code can override aq_rc
  67. * @aq_rc: AdminQ firmware error code to convert
  68. **/
  69. static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
  70. {
  71. int aq_to_posix[] = {
  72. 0, /* I40E_AQ_RC_OK */
  73. -EPERM, /* I40E_AQ_RC_EPERM */
  74. -ENOENT, /* I40E_AQ_RC_ENOENT */
  75. -ESRCH, /* I40E_AQ_RC_ESRCH */
  76. -EINTR, /* I40E_AQ_RC_EINTR */
  77. -EIO, /* I40E_AQ_RC_EIO */
  78. -ENXIO, /* I40E_AQ_RC_ENXIO */
  79. -E2BIG, /* I40E_AQ_RC_E2BIG */
  80. -EAGAIN, /* I40E_AQ_RC_EAGAIN */
  81. -ENOMEM, /* I40E_AQ_RC_ENOMEM */
  82. -EACCES, /* I40E_AQ_RC_EACCES */
  83. -EFAULT, /* I40E_AQ_RC_EFAULT */
  84. -EBUSY, /* I40E_AQ_RC_EBUSY */
  85. -EEXIST, /* I40E_AQ_RC_EEXIST */
  86. -EINVAL, /* I40E_AQ_RC_EINVAL */
  87. -ENOTTY, /* I40E_AQ_RC_ENOTTY */
  88. -ENOSPC, /* I40E_AQ_RC_ENOSPC */
  89. -ENOSYS, /* I40E_AQ_RC_ENOSYS */
  90. -ERANGE, /* I40E_AQ_RC_ERANGE */
  91. -EPIPE, /* I40E_AQ_RC_EFLUSHED */
  92. -ESPIPE, /* I40E_AQ_RC_BAD_ADDR */
  93. -EROFS, /* I40E_AQ_RC_EMODE */
  94. -EFBIG, /* I40E_AQ_RC_EFBIG */
  95. };
  96. if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
  97. return -ERANGE;
  98. return aq_to_posix[aq_rc];
  99. }
  100. /* general information */
  101. #define I40E_AQ_LARGE_BUF 512
  102. #define I40E_ASQ_CMD_TIMEOUT 250000 /* usecs */
  103. void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
  104. u16 opcode);
  105. #endif /* _I40E_ADMINQ_H_ */