New upstream version 18.02
[deb_dpdk.git] / drivers / bus / fslmc / mc / fsl_dpci_cmd.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  *
5  */
6 #ifndef _FSL_DPCI_CMD_H
7 #define _FSL_DPCI_CMD_H
8
9 /* DPCI Version */
10 #define DPCI_VER_MAJOR                  3
11 #define DPCI_VER_MINOR                  3
12
13 #define DPCI_CMD_BASE_VERSION           1
14 #define DPCI_CMD_BASE_VERSION_V2        2
15 #define DPCI_CMD_ID_OFFSET              4
16
17 #define DPCI_CMD_V1(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION)
18 #define DPCI_CMD_V2(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION_V2)
19
20 /* Command IDs */
21 #define DPCI_CMDID_CLOSE                DPCI_CMD_V1(0x800)
22 #define DPCI_CMDID_OPEN                 DPCI_CMD_V1(0x807)
23 #define DPCI_CMDID_CREATE               DPCI_CMD_V2(0x907)
24 #define DPCI_CMDID_DESTROY              DPCI_CMD_V1(0x987)
25 #define DPCI_CMDID_GET_API_VERSION      DPCI_CMD_V1(0xa07)
26
27 #define DPCI_CMDID_ENABLE               DPCI_CMD_V1(0x002)
28 #define DPCI_CMDID_DISABLE              DPCI_CMD_V1(0x003)
29 #define DPCI_CMDID_GET_ATTR             DPCI_CMD_V1(0x004)
30 #define DPCI_CMDID_RESET                DPCI_CMD_V1(0x005)
31 #define DPCI_CMDID_IS_ENABLED           DPCI_CMD_V1(0x006)
32
33 #define DPCI_CMDID_SET_RX_QUEUE         DPCI_CMD_V1(0x0e0)
34 #define DPCI_CMDID_GET_LINK_STATE       DPCI_CMD_V1(0x0e1)
35 #define DPCI_CMDID_GET_PEER_ATTR        DPCI_CMD_V1(0x0e2)
36 #define DPCI_CMDID_GET_RX_QUEUE         DPCI_CMD_V1(0x0e3)
37 #define DPCI_CMDID_GET_TX_QUEUE         DPCI_CMD_V1(0x0e4)
38
39 /* Macros for accessing command fields smaller than 1byte */
40 #define DPCI_MASK(field)        \
41         GENMASK(DPCI_##field##_SHIFT + DPCI_##field##_SIZE - 1, \
42                 DPCI_##field##_SHIFT)
43 #define dpci_set_field(var, field, val) \
44         ((var) |= (((val) << DPCI_##field##_SHIFT) & DPCI_MASK(field)))
45 #define dpci_get_field(var, field)      \
46         (((var) & DPCI_MASK(field)) >> DPCI_##field##_SHIFT)
47
48 #pragma pack(push, 1)
49 struct dpci_cmd_open {
50         uint32_t dpci_id;
51 };
52
53 struct dpci_cmd_create {
54         uint8_t num_of_priorities;
55         uint8_t pad[15];
56         uint32_t options;
57 };
58
59 struct dpci_cmd_destroy {
60         uint32_t dpci_id;
61 };
62
63 #define DPCI_ENABLE_SHIFT       0
64 #define DPCI_ENABLE_SIZE        1
65
66 struct dpci_rsp_is_enabled {
67         /* only the LSB bit */
68         uint8_t en;
69 };
70
71 struct dpci_rsp_get_attr {
72         uint32_t id;
73         uint16_t pad;
74         uint8_t num_of_priorities;
75 };
76
77 struct dpci_rsp_get_peer_attr {
78         uint32_t id;
79         uint32_t pad;
80         uint8_t num_of_priorities;
81 };
82
83 #define DPCI_UP_SHIFT   0
84 #define DPCI_UP_SIZE    1
85
86 struct dpci_rsp_get_link_state {
87         /* only the LSB bit */
88         uint8_t up;
89 };
90
91 #define DPCI_DEST_TYPE_SHIFT    0
92 #define DPCI_DEST_TYPE_SIZE     4
93
94 struct dpci_cmd_set_rx_queue {
95         uint32_t dest_id;
96         uint8_t dest_priority;
97         uint8_t priority;
98         /* from LSB: dest_type:4 */
99         uint8_t dest_type;
100         uint8_t pad;
101         uint64_t user_ctx;
102         uint32_t options;
103 };
104
105 struct dpci_cmd_get_queue {
106         uint8_t pad[5];
107         uint8_t priority;
108 };
109
110 struct dpci_rsp_get_rx_queue {
111         uint32_t dest_id;
112         uint8_t dest_priority;
113         uint8_t pad;
114         /* from LSB: dest_type:4 */
115         uint8_t dest_type;
116         uint8_t pad1;
117         uint64_t user_ctx;
118         uint32_t fqid;
119 };
120
121 struct dpci_rsp_get_tx_queue {
122         uint32_t pad;
123         uint32_t fqid;
124 };
125
126 struct dpci_rsp_get_api_version {
127         uint16_t major;
128         uint16_t minor;
129 };
130
131 #pragma pack(pop)
132 #endif /* _FSL_DPCI_CMD_H */