New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / bus / fslmc / mc / fsl_dpci_cmd.h
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license. When using or
3  * redistributing this file, you may do so under either license.
4  *
5  *   BSD LICENSE
6  *
7  * Copyright 2013-2016 Freescale Semiconductor Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * * Neither the name of the above-listed copyright holders nor the
17  * names of any contributors may be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  *   GPL LICENSE SUMMARY
21  *
22  * ALTERNATIVELY, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") as published by the Free Software
24  * Foundation, either version 2 of that License or (at your option) any
25  * later version.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 #ifndef _FSL_DPCI_CMD_H
40 #define _FSL_DPCI_CMD_H
41
42 /* DPCI Version */
43 #define DPCI_VER_MAJOR                  3
44 #define DPCI_VER_MINOR                  3
45
46 #define DPCI_CMD_BASE_VERSION           1
47 #define DPCI_CMD_BASE_VERSION_V2        2
48 #define DPCI_CMD_ID_OFFSET              4
49
50 #define DPCI_CMD_V1(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION)
51 #define DPCI_CMD_V2(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION_V2)
52
53 /* Command IDs */
54 #define DPCI_CMDID_CLOSE                DPCI_CMD_V1(0x800)
55 #define DPCI_CMDID_OPEN                 DPCI_CMD_V1(0x807)
56 #define DPCI_CMDID_CREATE               DPCI_CMD_V2(0x907)
57 #define DPCI_CMDID_DESTROY              DPCI_CMD_V1(0x987)
58 #define DPCI_CMDID_GET_API_VERSION      DPCI_CMD_V1(0xa07)
59
60 #define DPCI_CMDID_ENABLE               DPCI_CMD_V1(0x002)
61 #define DPCI_CMDID_DISABLE              DPCI_CMD_V1(0x003)
62 #define DPCI_CMDID_GET_ATTR             DPCI_CMD_V1(0x004)
63 #define DPCI_CMDID_RESET                DPCI_CMD_V1(0x005)
64 #define DPCI_CMDID_IS_ENABLED           DPCI_CMD_V1(0x006)
65
66 #define DPCI_CMDID_SET_RX_QUEUE         DPCI_CMD_V1(0x0e0)
67 #define DPCI_CMDID_GET_LINK_STATE       DPCI_CMD_V1(0x0e1)
68 #define DPCI_CMDID_GET_PEER_ATTR        DPCI_CMD_V1(0x0e2)
69 #define DPCI_CMDID_GET_RX_QUEUE         DPCI_CMD_V1(0x0e3)
70 #define DPCI_CMDID_GET_TX_QUEUE         DPCI_CMD_V1(0x0e4)
71
72 /* Macros for accessing command fields smaller than 1byte */
73 #define DPCI_MASK(field)        \
74         GENMASK(DPCI_##field##_SHIFT + DPCI_##field##_SIZE - 1, \
75                 DPCI_##field##_SHIFT)
76 #define dpci_set_field(var, field, val) \
77         ((var) |= (((val) << DPCI_##field##_SHIFT) & DPCI_MASK(field)))
78 #define dpci_get_field(var, field)      \
79         (((var) & DPCI_MASK(field)) >> DPCI_##field##_SHIFT)
80
81 #pragma pack(push, 1)
82 struct dpci_cmd_open {
83         uint32_t dpci_id;
84 };
85
86 struct dpci_cmd_create {
87         uint8_t num_of_priorities;
88         uint8_t pad[15];
89         uint32_t options;
90 };
91
92 struct dpci_cmd_destroy {
93         uint32_t dpci_id;
94 };
95
96 #define DPCI_ENABLE_SHIFT       0
97 #define DPCI_ENABLE_SIZE        1
98
99 struct dpci_rsp_is_enabled {
100         /* only the LSB bit */
101         uint8_t en;
102 };
103
104 struct dpci_rsp_get_attr {
105         uint32_t id;
106         uint16_t pad;
107         uint8_t num_of_priorities;
108 };
109
110 struct dpci_rsp_get_peer_attr {
111         uint32_t id;
112         uint32_t pad;
113         uint8_t num_of_priorities;
114 };
115
116 #define DPCI_UP_SHIFT   0
117 #define DPCI_UP_SIZE    1
118
119 struct dpci_rsp_get_link_state {
120         /* only the LSB bit */
121         uint8_t up;
122 };
123
124 #define DPCI_DEST_TYPE_SHIFT    0
125 #define DPCI_DEST_TYPE_SIZE     4
126
127 struct dpci_cmd_set_rx_queue {
128         uint32_t dest_id;
129         uint8_t dest_priority;
130         uint8_t priority;
131         /* from LSB: dest_type:4 */
132         uint8_t dest_type;
133         uint8_t pad;
134         uint64_t user_ctx;
135         uint32_t options;
136 };
137
138 struct dpci_cmd_get_queue {
139         uint8_t pad[5];
140         uint8_t priority;
141 };
142
143 struct dpci_rsp_get_rx_queue {
144         uint32_t dest_id;
145         uint8_t dest_priority;
146         uint8_t pad;
147         /* from LSB: dest_type:4 */
148         uint8_t dest_type;
149         uint8_t pad1;
150         uint64_t user_ctx;
151         uint32_t fqid;
152 };
153
154 struct dpci_rsp_get_tx_queue {
155         uint32_t pad;
156         uint32_t fqid;
157 };
158
159 struct dpci_rsp_get_api_version {
160         uint16_t major;
161         uint16_t minor;
162 };
163
164 #pragma pack(pop)
165 #endif /* _FSL_DPCI_CMD_H */