i40e_adminq.h revision 269198
1/******************************************************************************
2
3  Copyright (c) 2013-2014, Intel Corporation
4  All rights reserved.
5
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8
9   1. Redistributions of source code must retain the above copyright notice,
10      this list of conditions and the following disclaimer.
11
12   2. Redistributions in binary form must reproduce the above copyright
13      notice, this list of conditions and the following disclaimer in the
14      documentation and/or other materials provided with the distribution.
15
16   3. Neither the name of the Intel Corporation nor the names of its
17      contributors may be used to endorse or promote products derived from
18      this software without specific prior written permission.
19
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: head/sys/dev/i40e/i40e_adminq.h 269198 2014-07-28 21:57:09Z jfv $*/
34
35#ifndef _I40E_ADMINQ_H_
36#define _I40E_ADMINQ_H_
37
38#include "i40e_osdep.h"
39#include "i40e_adminq_cmd.h"
40
41#define I40E_ADMINQ_DESC(R, i)   \
42	(&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
43
44#define I40E_ADMINQ_DESC_ALIGNMENT 4096
45
46struct i40e_adminq_ring {
47	struct i40e_virt_mem dma_head;	/* space for dma structures */
48	struct i40e_dma_mem desc_buf;	/* descriptor ring memory */
49	struct i40e_virt_mem cmd_buf;	/* command buffer memory */
50
51	union {
52		struct i40e_dma_mem *asq_bi;
53		struct i40e_dma_mem *arq_bi;
54	} r;
55
56	u16 count;		/* Number of descriptors */
57	u16 rx_buf_len;		/* Admin Receive Queue buffer length */
58
59	/* used for interrupt processing */
60	u16 next_to_use;
61	u16 next_to_clean;
62
63	/* used for queue tracking */
64	u32 head;
65	u32 tail;
66	u32 len;
67	u32 bah;
68	u32 bal;
69};
70
71/* ASQ transaction details */
72struct i40e_asq_cmd_details {
73	void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
74	u64 cookie;
75	u16 flags_ena;
76	u16 flags_dis;
77	bool async;
78	bool postpone;
79};
80
81#define I40E_ADMINQ_DETAILS(R, i)   \
82	(&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
83
84/* ARQ event information */
85struct i40e_arq_event_info {
86	struct i40e_aq_desc desc;
87	u16 msg_size;
88	u8 *msg_buf;
89};
90
91/* Admin Queue information */
92struct i40e_adminq_info {
93	struct i40e_adminq_ring arq;    /* receive queue */
94	struct i40e_adminq_ring asq;    /* send queue */
95	u32 asq_cmd_timeout;            /* send queue cmd write back timeout*/
96	u16 num_arq_entries;            /* receive queue depth */
97	u16 num_asq_entries;            /* send queue depth */
98	u16 arq_buf_size;               /* receive queue buffer size */
99	u16 asq_buf_size;               /* send queue buffer size */
100	u16 fw_maj_ver;                 /* firmware major version */
101	u16 fw_min_ver;                 /* firmware minor version */
102	u16 api_maj_ver;                /* api major version */
103	u16 api_min_ver;                /* api minor version */
104	bool nvm_busy;
105	bool nvm_release_on_done;
106
107	struct i40e_spinlock asq_spinlock; /* Send queue spinlock */
108	struct i40e_spinlock arq_spinlock; /* Receive queue spinlock */
109
110	/* last status values on send and receive queues */
111	enum i40e_admin_queue_err asq_last_status;
112	enum i40e_admin_queue_err arq_last_status;
113};
114
115/* general information */
116#define I40E_AQ_LARGE_BUF		512
117#define I40E_ASQ_CMD_TIMEOUT		100000 /* usecs */
118
119void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
120				       u16 opcode);
121
122#endif /* _I40E_ADMINQ_H_ */
123