Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 2013 - 2018 Intel Corporation. */
0003 
0004 #ifndef _I40E_ADMINQ_H_
0005 #define _I40E_ADMINQ_H_
0006 
0007 #include "i40e_osdep.h"
0008 #include "i40e_status.h"
0009 #include "i40e_adminq_cmd.h"
0010 
0011 #define I40E_ADMINQ_DESC(R, i)   \
0012     (&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
0013 
0014 #define I40E_ADMINQ_DESC_ALIGNMENT 4096
0015 
0016 struct i40e_adminq_ring {
0017     struct i40e_virt_mem dma_head;  /* space for dma structures */
0018     struct i40e_dma_mem desc_buf;   /* descriptor ring memory */
0019     struct i40e_virt_mem cmd_buf;   /* command buffer memory */
0020 
0021     union {
0022         struct i40e_dma_mem *asq_bi;
0023         struct i40e_dma_mem *arq_bi;
0024     } r;
0025 
0026     u16 count;      /* Number of descriptors */
0027     u16 rx_buf_len;     /* Admin Receive Queue buffer length */
0028 
0029     /* used for interrupt processing */
0030     u16 next_to_use;
0031     u16 next_to_clean;
0032 
0033     /* used for queue tracking */
0034     u32 head;
0035     u32 tail;
0036     u32 len;
0037     u32 bah;
0038     u32 bal;
0039 };
0040 
0041 /* ASQ transaction details */
0042 struct i40e_asq_cmd_details {
0043     void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
0044     u64 cookie;
0045     u16 flags_ena;
0046     u16 flags_dis;
0047     bool async;
0048     bool postpone;
0049     struct i40e_aq_desc *wb_desc;
0050 };
0051 
0052 #define I40E_ADMINQ_DETAILS(R, i)   \
0053     (&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
0054 
0055 /* ARQ event information */
0056 struct i40e_arq_event_info {
0057     struct i40e_aq_desc desc;
0058     u16 msg_len;
0059     u16 buf_len;
0060     u8 *msg_buf;
0061 };
0062 
0063 /* Admin Queue information */
0064 struct i40e_adminq_info {
0065     struct i40e_adminq_ring arq;    /* receive queue */
0066     struct i40e_adminq_ring asq;    /* send queue */
0067     u32 asq_cmd_timeout;            /* send queue cmd write back timeout*/
0068     u16 num_arq_entries;            /* receive queue depth */
0069     u16 num_asq_entries;            /* send queue depth */
0070     u16 arq_buf_size;               /* receive queue buffer size */
0071     u16 asq_buf_size;               /* send queue buffer size */
0072     u16 fw_maj_ver;                 /* firmware major version */
0073     u16 fw_min_ver;                 /* firmware minor version */
0074     u32 fw_build;                   /* firmware build number */
0075     u16 api_maj_ver;                /* api major version */
0076     u16 api_min_ver;                /* api minor version */
0077 
0078     struct mutex asq_mutex; /* Send queue lock */
0079     struct mutex arq_mutex; /* Receive queue lock */
0080 
0081     /* last status values on send and receive queues */
0082     enum i40e_admin_queue_err asq_last_status;
0083     enum i40e_admin_queue_err arq_last_status;
0084 };
0085 
0086 /**
0087  * i40e_aq_rc_to_posix - convert errors to user-land codes
0088  * @aq_ret: AdminQ handler error code can override aq_rc
0089  * @aq_rc: AdminQ firmware error code to convert
0090  **/
0091 static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
0092 {
0093     int aq_to_posix[] = {
0094         0,           /* I40E_AQ_RC_OK */
0095         -EPERM,      /* I40E_AQ_RC_EPERM */
0096         -ENOENT,     /* I40E_AQ_RC_ENOENT */
0097         -ESRCH,      /* I40E_AQ_RC_ESRCH */
0098         -EINTR,      /* I40E_AQ_RC_EINTR */
0099         -EIO,        /* I40E_AQ_RC_EIO */
0100         -ENXIO,      /* I40E_AQ_RC_ENXIO */
0101         -E2BIG,      /* I40E_AQ_RC_E2BIG */
0102         -EAGAIN,     /* I40E_AQ_RC_EAGAIN */
0103         -ENOMEM,     /* I40E_AQ_RC_ENOMEM */
0104         -EACCES,     /* I40E_AQ_RC_EACCES */
0105         -EFAULT,     /* I40E_AQ_RC_EFAULT */
0106         -EBUSY,      /* I40E_AQ_RC_EBUSY */
0107         -EEXIST,     /* I40E_AQ_RC_EEXIST */
0108         -EINVAL,     /* I40E_AQ_RC_EINVAL */
0109         -ENOTTY,     /* I40E_AQ_RC_ENOTTY */
0110         -ENOSPC,     /* I40E_AQ_RC_ENOSPC */
0111         -ENOSYS,     /* I40E_AQ_RC_ENOSYS */
0112         -ERANGE,     /* I40E_AQ_RC_ERANGE */
0113         -EPIPE,      /* I40E_AQ_RC_EFLUSHED */
0114         -ESPIPE,     /* I40E_AQ_RC_BAD_ADDR */
0115         -EROFS,      /* I40E_AQ_RC_EMODE */
0116         -EFBIG,      /* I40E_AQ_RC_EFBIG */
0117     };
0118 
0119     /* aq_rc is invalid if AQ timed out */
0120     if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
0121         return -EAGAIN;
0122 
0123     if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
0124         return -ERANGE;
0125 
0126     return aq_to_posix[aq_rc];
0127 }
0128 
0129 /* general information */
0130 #define I40E_AQ_LARGE_BUF   512
0131 #define I40E_ASQ_CMD_TIMEOUT    250000  /* usecs */
0132 
0133 void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
0134                        u16 opcode);
0135 
0136 #endif /* _I40E_ADMINQ_H_ */