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