i40e_adminq.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2014 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #ifndef _I40E_ADMINQ_H_
  27. #define _I40E_ADMINQ_H_
  28. #include "i40e_osdep.h"
  29. #include "i40e_status.h"
  30. #include "i40e_adminq_cmd.h"
  31. #define I40E_ADMINQ_DESC(R, i) \
  32. (&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
  33. #define I40E_ADMINQ_DESC_ALIGNMENT 4096
  34. struct i40e_adminq_ring {
  35. struct i40e_virt_mem dma_head; /* space for dma structures */
  36. struct i40e_dma_mem desc_buf; /* descriptor ring memory */
  37. struct i40e_virt_mem cmd_buf; /* command buffer memory */
  38. union {
  39. struct i40e_dma_mem *asq_bi;
  40. struct i40e_dma_mem *arq_bi;
  41. } r;
  42. u16 count; /* Number of descriptors */
  43. u16 rx_buf_len; /* Admin Receive Queue buffer length */
  44. /* used for interrupt processing */
  45. u16 next_to_use;
  46. u16 next_to_clean;
  47. /* used for queue tracking */
  48. u32 head;
  49. u32 tail;
  50. u32 len;
  51. u32 bah;
  52. u32 bal;
  53. };
  54. /* ASQ transaction details */
  55. struct i40e_asq_cmd_details {
  56. void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
  57. u64 cookie;
  58. u16 flags_ena;
  59. u16 flags_dis;
  60. bool async;
  61. bool postpone;
  62. struct i40e_aq_desc *wb_desc;
  63. };
  64. #define I40E_ADMINQ_DETAILS(R, i) \
  65. (&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
  66. /* ARQ event information */
  67. struct i40e_arq_event_info {
  68. struct i40e_aq_desc desc;
  69. u16 msg_len;
  70. u16 buf_len;
  71. u8 *msg_buf;
  72. };
  73. /* Admin Queue information */
  74. struct i40e_adminq_info {
  75. struct i40e_adminq_ring arq; /* receive queue */
  76. struct i40e_adminq_ring asq; /* send queue */
  77. u32 asq_cmd_timeout; /* send queue cmd write back timeout*/
  78. u16 num_arq_entries; /* receive queue depth */
  79. u16 num_asq_entries; /* send queue depth */
  80. u16 arq_buf_size; /* receive queue buffer size */
  81. u16 asq_buf_size; /* send queue buffer size */
  82. u16 fw_maj_ver; /* firmware major version */
  83. u16 fw_min_ver; /* firmware minor version */
  84. u32 fw_build; /* firmware build number */
  85. u16 api_maj_ver; /* api major version */
  86. u16 api_min_ver; /* api minor version */
  87. struct mutex asq_mutex; /* Send queue lock */
  88. struct mutex arq_mutex; /* Receive queue lock */
  89. /* last status values on send and receive queues */
  90. enum i40e_admin_queue_err asq_last_status;
  91. enum i40e_admin_queue_err arq_last_status;
  92. };
  93. /**
  94. * i40e_aq_rc_to_posix - convert errors to user-land codes
  95. * aq_ret: AdminQ handler error code can override aq_rc
  96. * aq_rc: AdminQ firmware error code to convert
  97. **/
  98. static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
  99. {
  100. int aq_to_posix[] = {
  101. 0, /* I40E_AQ_RC_OK */
  102. -EPERM, /* I40E_AQ_RC_EPERM */
  103. -ENOENT, /* I40E_AQ_RC_ENOENT */
  104. -ESRCH, /* I40E_AQ_RC_ESRCH */
  105. -EINTR, /* I40E_AQ_RC_EINTR */
  106. -EIO, /* I40E_AQ_RC_EIO */
  107. -ENXIO, /* I40E_AQ_RC_ENXIO */
  108. -E2BIG, /* I40E_AQ_RC_E2BIG */
  109. -EAGAIN, /* I40E_AQ_RC_EAGAIN */
  110. -ENOMEM, /* I40E_AQ_RC_ENOMEM */
  111. -EACCES, /* I40E_AQ_RC_EACCES */
  112. -EFAULT, /* I40E_AQ_RC_EFAULT */
  113. -EBUSY, /* I40E_AQ_RC_EBUSY */
  114. -EEXIST, /* I40E_AQ_RC_EEXIST */
  115. -EINVAL, /* I40E_AQ_RC_EINVAL */
  116. -ENOTTY, /* I40E_AQ_RC_ENOTTY */
  117. -ENOSPC, /* I40E_AQ_RC_ENOSPC */
  118. -ENOSYS, /* I40E_AQ_RC_ENOSYS */
  119. -ERANGE, /* I40E_AQ_RC_ERANGE */
  120. -EPIPE, /* I40E_AQ_RC_EFLUSHED */
  121. -ESPIPE, /* I40E_AQ_RC_BAD_ADDR */
  122. -EROFS, /* I40E_AQ_RC_EMODE */
  123. -EFBIG, /* I40E_AQ_RC_EFBIG */
  124. };
  125. /* aq_rc is invalid if AQ timed out */
  126. if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
  127. return -EAGAIN;
  128. if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
  129. return -ERANGE;
  130. return aq_to_posix[aq_rc];
  131. }
  132. /* general information */
  133. #define I40E_AQ_LARGE_BUF 512
  134. #define I40E_ASQ_CMD_TIMEOUT 250 /* msecs */
  135. void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
  136. u16 opcode);
  137. #endif /* _I40E_ADMINQ_H_ */