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