brintos

brintos / linux-shallow public Read only

0
0
Text · 3.8 KiB · 406506f Raw
129 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/* Copyright(c) 2013 - 2018 Intel Corporation. */3 4#ifndef _IAVF_ADMINQ_H_5#define _IAVF_ADMINQ_H_6 7#include "iavf_osdep.h"8#include "iavf_status.h"9#include "iavf_adminq_cmd.h"10 11#define IAVF_ADMINQ_DESC(R, i)   \12	(&(((struct iavf_aq_desc *)((R).desc_buf.va))[i]))13 14#define IAVF_ADMINQ_DESC_ALIGNMENT 409615 16struct iavf_adminq_ring {17	struct iavf_virt_mem dma_head;	/* space for dma structures */18	struct iavf_dma_mem desc_buf;	/* descriptor ring memory */19	struct iavf_virt_mem cmd_buf;	/* command buffer memory */20 21	union {22		struct iavf_dma_mem *asq_bi;23		struct iavf_dma_mem *arq_bi;24	} r;25 26	u16 count;		/* Number of descriptors */27	u16 rx_buf_len;		/* Admin Receive Queue buffer length */28 29	/* used for interrupt processing */30	u16 next_to_use;31	u16 next_to_clean;32};33 34/* ASQ transaction details */35struct iavf_asq_cmd_details {36	void *callback; /* cast from type IAVF_ADMINQ_CALLBACK */37	u64 cookie;38	u16 flags_ena;39	u16 flags_dis;40	bool async;41	bool postpone;42	struct iavf_aq_desc *wb_desc;43};44 45#define IAVF_ADMINQ_DETAILS(R, i)   \46	(&(((struct iavf_asq_cmd_details *)((R).cmd_buf.va))[i]))47 48/* ARQ event information */49struct iavf_arq_event_info {50	struct iavf_aq_desc desc;51	u16 msg_len;52	u16 buf_len;53	u8 *msg_buf;54};55 56/* Admin Queue information */57struct iavf_adminq_info {58	struct iavf_adminq_ring arq;    /* receive queue */59	struct iavf_adminq_ring asq;    /* send queue */60	u32 asq_cmd_timeout;            /* send queue cmd write back timeout*/61	u16 num_arq_entries;            /* receive queue depth */62	u16 num_asq_entries;            /* send queue depth */63	u16 arq_buf_size;               /* receive queue buffer size */64	u16 asq_buf_size;               /* send queue buffer size */65	u16 fw_maj_ver;                 /* firmware major version */66	u16 fw_min_ver;                 /* firmware minor version */67	u32 fw_build;                   /* firmware build number */68	u16 api_maj_ver;                /* api major version */69	u16 api_min_ver;                /* api minor version */70 71	struct mutex asq_mutex; /* Send queue lock */72	struct mutex arq_mutex; /* Receive queue lock */73 74	/* last status values on send and receive queues */75	enum iavf_admin_queue_err asq_last_status;76	enum iavf_admin_queue_err arq_last_status;77};78 79/**80 * iavf_aq_rc_to_posix - convert errors to user-land codes81 * @aq_ret: AdminQ handler error code can override aq_rc82 * @aq_rc: AdminQ firmware error code to convert83 **/84static inline int iavf_aq_rc_to_posix(int aq_ret, int aq_rc)85{86	int aq_to_posix[] = {87		0,           /* IAVF_AQ_RC_OK */88		-EPERM,      /* IAVF_AQ_RC_EPERM */89		-ENOENT,     /* IAVF_AQ_RC_ENOENT */90		-ESRCH,      /* IAVF_AQ_RC_ESRCH */91		-EINTR,      /* IAVF_AQ_RC_EINTR */92		-EIO,        /* IAVF_AQ_RC_EIO */93		-ENXIO,      /* IAVF_AQ_RC_ENXIO */94		-E2BIG,      /* IAVF_AQ_RC_E2BIG */95		-EAGAIN,     /* IAVF_AQ_RC_EAGAIN */96		-ENOMEM,     /* IAVF_AQ_RC_ENOMEM */97		-EACCES,     /* IAVF_AQ_RC_EACCES */98		-EFAULT,     /* IAVF_AQ_RC_EFAULT */99		-EBUSY,      /* IAVF_AQ_RC_EBUSY */100		-EEXIST,     /* IAVF_AQ_RC_EEXIST */101		-EINVAL,     /* IAVF_AQ_RC_EINVAL */102		-ENOTTY,     /* IAVF_AQ_RC_ENOTTY */103		-ENOSPC,     /* IAVF_AQ_RC_ENOSPC */104		-ENOSYS,     /* IAVF_AQ_RC_ENOSYS */105		-ERANGE,     /* IAVF_AQ_RC_ERANGE */106		-EPIPE,      /* IAVF_AQ_RC_EFLUSHED */107		-ESPIPE,     /* IAVF_AQ_RC_BAD_ADDR */108		-EROFS,      /* IAVF_AQ_RC_EMODE */109		-EFBIG,      /* IAVF_AQ_RC_EFBIG */110	};111 112	/* aq_rc is invalid if AQ timed out */113	if (aq_ret == IAVF_ERR_ADMIN_QUEUE_TIMEOUT)114		return -EAGAIN;115 116	if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))117		return -ERANGE;118 119	return aq_to_posix[aq_rc];120}121 122/* general information */123#define IAVF_AQ_LARGE_BUF	512124#define IAVF_ASQ_CMD_TIMEOUT	250000  /* usecs */125 126void iavf_fill_default_direct_cmd_desc(struct iavf_aq_desc *desc, u16 opcode);127 128#endif /* _IAVF_ADMINQ_H_ */129