blob: fb95ac544a0256f304c45ebda6ef0b0b83ce5975 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07002/*
3 * Freescale Layerscape MC I/O wrapper
4 *
Yogesh Gaura6f2a6e2018-05-09 10:52:17 +05305 * Copyright 2013-2016 Freescale Semiconductor, Inc.
Ioana Ciornei95f309a2023-05-31 19:04:32 +03006 * Copyright 2017, 2023 NXP
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07007 */
8#ifndef _FSL_DPRC_H
9#define _FSL_DPRC_H
10
11/* DPRC Version */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053012#define DPRC_VER_MAJOR 6
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053013#define DPRC_VER_MINOR 1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070014
15/* Command IDs */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053016#define DPRC_CMDID_CLOSE 0x8001
17#define DPRC_CMDID_OPEN 0x8051
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070018
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053019#define DPRC_CMDID_GET_API_VERSION 0xa051
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070020
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053021#define DPRC_CMDID_CREATE_CONT 0x1511
22#define DPRC_CMDID_DESTROY_CONT 0x1521
23#define DPRC_CMDID_GET_CONT_ID 0x8301
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070024
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053025#define DPRC_CMDID_CONNECT 0x1671
26#define DPRC_CMDID_DISCONNECT 0x1681
27#define DPRC_CMDID_GET_CONNECTION 0x16C1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070028
Ioana Ciornei95f309a2023-05-31 19:04:32 +030029#pragma pack(push, 1)
30struct dprc_cmd_open {
31 __le32 container_id;
32};
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070033
Ioana Ciornei95f309a2023-05-31 19:04:32 +030034struct dprc_cmd_create_container {
35 __le32 options;
36 __le32 icid;
37 __le32 pad1;
38 __le32 portal_id;
39 u8 label[16];
40};
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070041
Ioana Ciornei95f309a2023-05-31 19:04:32 +030042struct dprc_rsp_create_container {
43 __le64 pad0;
44 __le32 child_container_id;
45 __le32 pad1;
46 __le64 child_portal_addr;
47};
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053048
Ioana Ciornei95f309a2023-05-31 19:04:32 +030049struct dprc_cmd_destroy_container {
50 __le32 child_container_id;
51};
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053052
Ioana Ciornei95f309a2023-05-31 19:04:32 +030053struct dprc_cmd_connect {
54 __le32 ep1_id;
55 __le16 ep1_interface_id;
56 __le16 pad0;
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053057
Ioana Ciornei95f309a2023-05-31 19:04:32 +030058 __le32 ep2_id;
59 __le16 ep2_interface_id;
60 __le16 pad1;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070061
Ioana Ciornei95f309a2023-05-31 19:04:32 +030062 u8 ep1_type[16];
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070063
Ioana Ciornei95f309a2023-05-31 19:04:32 +030064 __le32 max_rate;
65 __le32 committed_rate;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070066
Ioana Ciornei95f309a2023-05-31 19:04:32 +030067 u8 ep2_type[16];
68};
69
70struct dprc_cmd_disconnect {
71 __le32 id;
72 __le32 interface_id;
73 u8 type[16];
74};
75
76struct dprc_cmd_get_connection {
77 __le32 ep1_id;
78 __le16 ep1_interface_id;
79 __le16 pad;
80
81 u8 ep1_type[16];
82};
83
84struct dprc_rsp_get_connection {
85 __le64 pad[3];
86 __le32 ep2_id;
87 __le16 ep2_interface_id;
88 __le16 pad1;
89 u8 ep2_type[16];
90 __le32 state;
91};
92
93#pragma pack(pop)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070094
95/* Data Path Resource Container API
96 * Contains DPRC API for managing and querying DPAA resources
97 */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053098
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070099struct fsl_mc_io;
100
101/**
102 * Set this value as the icid value in dprc_cfg structure when creating a
103 * container, in case the ICID is not selected by the user and should be
104 * allocated by the DPRC from the pool of ICIDs.
105 */
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300106#define DPRC_GET_ICID_FROM_POOL (u16)(~(0))
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700107
108/**
109 * Set this value as the portal_id value in dprc_cfg structure when creating a
110 * container, in case the portal ID is not specifically selected by the
111 * user and should be allocated by the DPRC from the pool of portal ids.
112 */
113#define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
114
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300115int dprc_get_container_id(struct fsl_mc_io *mc_io, u32 cmd_flags, int *container_id);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700116
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300117int dprc_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int container_id, u16 *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700118
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300119int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700120
121/**
122 * Container general options
123 *
124 * These options may be selected at container creation by the container creator
125 * and can be retrieved using dprc_get_attributes()
126 */
127
128/* Spawn Policy Option allowed - Indicates that the new container is allowed
129 * to spawn and have its own child containers.
130 */
131#define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
132
133/* General Container allocation policy - Indicates that the new container is
134 * allowed to allocate requested resources from its parent container; if not
135 * set, the container is only allowed to use resources in its own pools; Note
136 * that this is a container's global policy, but the parent container may
137 * override it and set specific quota per resource type.
138 */
139#define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
140
141/* Object initialization allowed - software context associated with this
142 * container is allowed to invoke object initialization operations.
143 */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530144#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700145
146/* Topology change allowed - software context associated with this
147 * container is allowed to invoke topology operations, such as attach/detach
148 * of network objects.
149 */
150#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
151
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700152
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530153/* AIOP - Indicates that container belongs to AIOP. */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700154#define DPRC_CFG_OPT_AIOP 0x00000020
155
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530156/* IRQ Config - Indicates that the container allowed to configure its IRQs.*/
157#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
158
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700159/**
160 * struct dprc_cfg - Container configuration options
161 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
162 * ICID value is allocated by the DPRC
163 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
164 * portal ID is allocated by the DPRC
165 * @options: Combination of 'DPRC_CFG_OPT_<X>' options
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530166 * @label: Object's label
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700167 */
168struct dprc_cfg {
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300169 u16 icid;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700170 int portal_id;
171 uint64_t options;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530172 char label[16];
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700173};
174
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300175int dprc_create_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
176 struct dprc_cfg *cfg, int *child_container_id,
177 uint64_t *child_portal_offset);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530178
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300179int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
180 int child_container_id);
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530181
182/**
183 * struct dprc_connection_cfg - Connection configuration.
184 * Used for virtual connections only
185 * @committed_rate: Committed rate (Mbits/s)
186 * @max_rate: Maximum rate (Mbits/s)
187 */
188struct dprc_connection_cfg {
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300189 u32 committed_rate;
190 u32 max_rate;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700191};
192
193/**
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300194 * struct dprc_endpoint - Endpoint description for link connect/disconnect
195 * operations
196 * @type: Endpoint object type: NULL terminated string
197 * @id: Endpoint object ID
198 * @if_id: Interface ID; should be set for endpoints with multiple
199 * interfaces ("dpsw", "dpdmux"); for others, always set to 0
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700200 */
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300201struct dprc_endpoint {
202 char type[16];
203 int id;
204 u16 if_id;
205};
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700206
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300207int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
208 const struct dprc_endpoint *endpoint1,
209 const struct dprc_endpoint *endpoint2,
210 const struct dprc_connection_cfg *cfg);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700211
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300212int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
213 const struct dprc_endpoint *endpoint);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700214
Ioana Ciornei95f309a2023-05-31 19:04:32 +0300215int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
216 const struct dprc_endpoint *endpoint1,
217 struct dprc_endpoint *endpoint2, int *state);
218
219int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
220 u16 *major_ver, u16 *minor_ver);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530221
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700222#endif /* _FSL_DPRC_H */