i40e_adminq.h 4.74 KB
Newer Older
1
2
3
/*******************************************************************************
 *
 * Intel Ethernet Controller XL710 Family Linux Driver
Greg Rose's avatar
Greg Rose committed
4
 * Copyright(c) 2013 - 2014 Intel Corporation.
5
6
7
8
9
10
11
12
13
14
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
Greg Rose's avatar
Greg Rose committed
15
16
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 *
 * The full GNU General Public License is included in this distribution in
 * the file called "COPYING".
 *
 * Contact Information:
 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 ******************************************************************************/

#ifndef _I40E_ADMINQ_H_
#define _I40E_ADMINQ_H_

#include "i40e_osdep.h"
31
#include "i40e_status.h"
32
33
34
#include "i40e_adminq_cmd.h"

#define I40E_ADMINQ_DESC(R, i)   \
35
	(&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
36
37
38
39

#define I40E_ADMINQ_DESC_ALIGNMENT 4096

struct i40e_adminq_ring {
40
41
42
	struct i40e_virt_mem dma_head;	/* space for dma structures */
	struct i40e_dma_mem desc_buf;	/* descriptor ring memory */
	struct i40e_virt_mem cmd_buf;	/* command buffer memory */
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

	union {
		struct i40e_dma_mem *asq_bi;
		struct i40e_dma_mem *arq_bi;
	} r;

	u16 count;		/* Number of descriptors */
	u16 rx_buf_len;		/* Admin Receive Queue buffer length */

	/* used for interrupt processing */
	u16 next_to_use;
	u16 next_to_clean;

	/* used for queue tracking */
	u32 head;
	u32 tail;
59
	u32 len;
60
61
	u32 bah;
	u32 bal;
62
63
64
65
66
67
68
69
70
71
72
73
74
};

/* ASQ transaction details */
struct i40e_asq_cmd_details {
	void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
	u64 cookie;
	u16 flags_ena;
	u16 flags_dis;
	bool async;
	bool postpone;
};

#define I40E_ADMINQ_DETAILS(R, i)   \
75
	(&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
76
77
78
79

/* ARQ event information */
struct i40e_arq_event_info {
	struct i40e_aq_desc desc;
Mitch Williams's avatar
Mitch Williams committed
80
81
	u16 msg_len;
	u16 buf_len;
82
83
84
85
86
87
88
	u8 *msg_buf;
};

/* Admin Queue information */
struct i40e_adminq_info {
	struct i40e_adminq_ring arq;    /* receive queue */
	struct i40e_adminq_ring asq;    /* send queue */
89
	u32 asq_cmd_timeout;            /* send queue cmd write back timeout*/
90
91
92
93
94
95
96
97
	u16 num_arq_entries;            /* receive queue depth */
	u16 num_asq_entries;            /* send queue depth */
	u16 arq_buf_size;               /* receive queue buffer size */
	u16 asq_buf_size;               /* send queue buffer size */
	u16 fw_maj_ver;                 /* firmware major version */
	u16 fw_min_ver;                 /* firmware minor version */
	u16 api_maj_ver;                /* api major version */
	u16 api_min_ver;                /* api minor version */
98
	bool nvm_release_on_done;
99
100
101
102
103
104
105
106
107

	struct mutex asq_mutex; /* Send queue lock */
	struct mutex arq_mutex; /* Receive queue lock */

	/* last status values on send and receive queues */
	enum i40e_admin_queue_err asq_last_status;
	enum i40e_admin_queue_err arq_last_status;
};

108
109
110
111
/**
 * i40e_aq_rc_to_posix - convert errors to user-land codes
 * aq_rc: AdminQ error code to convert
 **/
112
static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
	int aq_to_posix[] = {
		0,           /* I40E_AQ_RC_OK */
		-EPERM,      /* I40E_AQ_RC_EPERM */
		-ENOENT,     /* I40E_AQ_RC_ENOENT */
		-ESRCH,      /* I40E_AQ_RC_ESRCH */
		-EINTR,      /* I40E_AQ_RC_EINTR */
		-EIO,        /* I40E_AQ_RC_EIO */
		-ENXIO,      /* I40E_AQ_RC_ENXIO */
		-E2BIG,      /* I40E_AQ_RC_E2BIG */
		-EAGAIN,     /* I40E_AQ_RC_EAGAIN */
		-ENOMEM,     /* I40E_AQ_RC_ENOMEM */
		-EACCES,     /* I40E_AQ_RC_EACCES */
		-EFAULT,     /* I40E_AQ_RC_EFAULT */
		-EBUSY,      /* I40E_AQ_RC_EBUSY */
		-EEXIST,     /* I40E_AQ_RC_EEXIST */
		-EINVAL,     /* I40E_AQ_RC_EINVAL */
		-ENOTTY,     /* I40E_AQ_RC_ENOTTY */
		-ENOSPC,     /* I40E_AQ_RC_ENOSPC */
		-ENOSYS,     /* I40E_AQ_RC_ENOSYS */
		-ERANGE,     /* I40E_AQ_RC_ERANGE */
		-EPIPE,      /* I40E_AQ_RC_EFLUSHED */
		-ESPIPE,     /* I40E_AQ_RC_BAD_ADDR */
		-EROFS,      /* I40E_AQ_RC_EMODE */
		-EFBIG,      /* I40E_AQ_RC_EFBIG */
	};

140
141
142
143
	/* aq_rc is invalid if AQ timed out */
	if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
		return -EAGAIN;

144
145
	if (aq_rc >= ARRAY_SIZE(aq_to_posix))
		return -ERANGE;
146
147
148
	return aq_to_posix[aq_rc];
}

149
150
/* general information */
#define I40E_AQ_LARGE_BUF	512
151
#define I40E_ASQ_CMD_TIMEOUT	250  /* msecs */
152
153
154
155
156

void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
				       u16 opcode);

#endif /* _I40E_ADMINQ_H_ */