1f2835adfSPeng Ma // SPDX-License-Identifier: GPL-2.0
2f2835adfSPeng Ma // Copyright 2019 NXP
3f2835adfSPeng Ma
453596dfaSPeng Ma #include <linux/module.h>
5f2835adfSPeng Ma #include <linux/types.h>
6f2835adfSPeng Ma #include <linux/io.h>
7f2835adfSPeng Ma #include <linux/fsl/mc.h>
8f2835adfSPeng Ma #include "dpdmai.h"
9f2835adfSPeng Ma
10f2835adfSPeng Ma struct dpdmai_rsp_get_attributes {
11f2835adfSPeng Ma __le32 id;
12f2835adfSPeng Ma u8 num_of_priorities;
13f2835adfSPeng Ma u8 pad0[3];
14f2835adfSPeng Ma __le16 major;
15f2835adfSPeng Ma __le16 minor;
16f2835adfSPeng Ma };
17f2835adfSPeng Ma
18f2835adfSPeng Ma struct dpdmai_cmd_queue {
19f2835adfSPeng Ma __le32 dest_id;
20f2835adfSPeng Ma u8 priority;
21f2835adfSPeng Ma u8 queue;
22f2835adfSPeng Ma u8 dest_type;
23f2835adfSPeng Ma u8 pad;
24f2835adfSPeng Ma __le64 user_ctx;
25f2835adfSPeng Ma union {
26f2835adfSPeng Ma __le32 options;
27f2835adfSPeng Ma __le32 fqid;
28f2835adfSPeng Ma };
29f2835adfSPeng Ma };
30f2835adfSPeng Ma
31f2835adfSPeng Ma struct dpdmai_rsp_get_tx_queue {
32f2835adfSPeng Ma __le64 pad;
33f2835adfSPeng Ma __le32 fqid;
34f2835adfSPeng Ma };
35f2835adfSPeng Ma
36f2835adfSPeng Ma #define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \
37f2835adfSPeng Ma ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
38f2835adfSPeng Ma
39f2835adfSPeng Ma /* cmd, param, offset, width, type, arg_name */
407208474dSNathan Chancellor #define DPDMAI_CMD_CREATE(cmd, cfg) \
41f2835adfSPeng Ma do { \
42f2835adfSPeng Ma MC_CMD_OP(cmd, 0, 8, 8, u8, (cfg)->priorities[0]);\
43f2835adfSPeng Ma MC_CMD_OP(cmd, 0, 16, 8, u8, (cfg)->priorities[1]);\
44f2835adfSPeng Ma } while (0)
45f2835adfSPeng Ma
mc_enc(int lsoffset,int width,u64 val)46f2835adfSPeng Ma static inline u64 mc_enc(int lsoffset, int width, u64 val)
47f2835adfSPeng Ma {
48f2835adfSPeng Ma return (val & MAKE_UMASK64(width)) << lsoffset;
49f2835adfSPeng Ma }
50f2835adfSPeng Ma
51f2835adfSPeng Ma /**
52f2835adfSPeng Ma * dpdmai_open() - Open a control session for the specified object
53f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
54f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
55f2835adfSPeng Ma * @dpdmai_id: DPDMAI unique ID
56f2835adfSPeng Ma * @token: Returned token; use in subsequent API calls
57f2835adfSPeng Ma *
58f2835adfSPeng Ma * This function can be used to open a control session for an
59f2835adfSPeng Ma * already created object; an object may have been declared in
60f2835adfSPeng Ma * the DPL or by calling the dpdmai_create() function.
61f2835adfSPeng Ma * This function returns a unique authentication token,
62f2835adfSPeng Ma * associated with the specific object ID and the specific MC
63f2835adfSPeng Ma * portal; this token must be used in all subsequent commands for
64f2835adfSPeng Ma * this specific object.
65f2835adfSPeng Ma *
66f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
67f2835adfSPeng Ma */
dpdmai_open(struct fsl_mc_io * mc_io,u32 cmd_flags,int dpdmai_id,u16 * token)68f2835adfSPeng Ma int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,
69f2835adfSPeng Ma int dpdmai_id, u16 *token)
70f2835adfSPeng Ma {
71f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
72f2835adfSPeng Ma __le64 *cmd_dpdmai_id;
73f2835adfSPeng Ma int err;
74f2835adfSPeng Ma
75f2835adfSPeng Ma /* prepare command */
76f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_OPEN,
77f2835adfSPeng Ma cmd_flags, 0);
78f2835adfSPeng Ma
79f2835adfSPeng Ma cmd_dpdmai_id = cmd.params;
80f2835adfSPeng Ma *cmd_dpdmai_id = cpu_to_le32(dpdmai_id);
81f2835adfSPeng Ma
82f2835adfSPeng Ma /* send command to mc*/
83f2835adfSPeng Ma err = mc_send_command(mc_io, &cmd);
84f2835adfSPeng Ma if (err)
85f2835adfSPeng Ma return err;
86f2835adfSPeng Ma
87f2835adfSPeng Ma /* retrieve response parameters */
88f2835adfSPeng Ma *token = mc_cmd_hdr_read_token(&cmd);
89f2835adfSPeng Ma
90f2835adfSPeng Ma return 0;
91f2835adfSPeng Ma }
9253596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_open);
93f2835adfSPeng Ma
94f2835adfSPeng Ma /**
95f2835adfSPeng Ma * dpdmai_close() - Close the control session of the object
96f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
97f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
98f2835adfSPeng Ma * @token: Token of DPDMAI object
99f2835adfSPeng Ma *
100f2835adfSPeng Ma * After this function is called, no further operations are
101f2835adfSPeng Ma * allowed on the object without opening a new control session.
102f2835adfSPeng Ma *
103f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
104f2835adfSPeng Ma */
dpdmai_close(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token)105f2835adfSPeng Ma int dpdmai_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
106f2835adfSPeng Ma {
107f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
108f2835adfSPeng Ma
109f2835adfSPeng Ma /* prepare command */
110f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CLOSE,
111f2835adfSPeng Ma cmd_flags, token);
112f2835adfSPeng Ma
113f2835adfSPeng Ma /* send command to mc*/
114f2835adfSPeng Ma return mc_send_command(mc_io, &cmd);
115f2835adfSPeng Ma }
11653596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_close);
117f2835adfSPeng Ma
118f2835adfSPeng Ma /**
119f2835adfSPeng Ma * dpdmai_create() - Create the DPDMAI object
120f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
121f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
122f2835adfSPeng Ma * @cfg: Configuration structure
123f2835adfSPeng Ma * @token: Returned token; use in subsequent API calls
124f2835adfSPeng Ma *
125f2835adfSPeng Ma * Create the DPDMAI object, allocate required resources and
126f2835adfSPeng Ma * perform required initialization.
127f2835adfSPeng Ma *
128f2835adfSPeng Ma * The object can be created either by declaring it in the
129f2835adfSPeng Ma * DPL file, or by calling this function.
130f2835adfSPeng Ma *
131f2835adfSPeng Ma * This function returns a unique authentication token,
132f2835adfSPeng Ma * associated with the specific object ID and the specific MC
133f2835adfSPeng Ma * portal; this token must be used in all subsequent calls to
134f2835adfSPeng Ma * this specific object. For objects that are created using the
135f2835adfSPeng Ma * DPL file, call dpdmai_open() function to get an authentication
136f2835adfSPeng Ma * token first.
137f2835adfSPeng Ma *
138f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
139f2835adfSPeng Ma */
dpdmai_create(struct fsl_mc_io * mc_io,u32 cmd_flags,const struct dpdmai_cfg * cfg,u16 * token)140f2835adfSPeng Ma int dpdmai_create(struct fsl_mc_io *mc_io, u32 cmd_flags,
141f2835adfSPeng Ma const struct dpdmai_cfg *cfg, u16 *token)
142f2835adfSPeng Ma {
143f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
144f2835adfSPeng Ma int err;
145f2835adfSPeng Ma
146f2835adfSPeng Ma /* prepare command */
147f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CREATE,
148f2835adfSPeng Ma cmd_flags, 0);
149f2835adfSPeng Ma DPDMAI_CMD_CREATE(cmd, cfg);
150f2835adfSPeng Ma
151f2835adfSPeng Ma /* send command to mc*/
152f2835adfSPeng Ma err = mc_send_command(mc_io, &cmd);
153f2835adfSPeng Ma if (err)
154f2835adfSPeng Ma return err;
155f2835adfSPeng Ma
156f2835adfSPeng Ma /* retrieve response parameters */
157f2835adfSPeng Ma *token = mc_cmd_hdr_read_token(&cmd);
158f2835adfSPeng Ma
159f2835adfSPeng Ma return 0;
160f2835adfSPeng Ma }
161f2835adfSPeng Ma
162f2835adfSPeng Ma /**
163*3e0ca3c3SPeng Ma * dpdmai_destroy() - Destroy the DPDMAI object and release all its resources.
164*3e0ca3c3SPeng Ma * @mc_io: Pointer to MC portal's I/O object
165*3e0ca3c3SPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
166*3e0ca3c3SPeng Ma * @token: Token of DPDMAI object
167*3e0ca3c3SPeng Ma *
168*3e0ca3c3SPeng Ma * Return: '0' on Success; error code otherwise.
169*3e0ca3c3SPeng Ma */
dpdmai_destroy(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token)170*3e0ca3c3SPeng Ma int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
171*3e0ca3c3SPeng Ma {
172*3e0ca3c3SPeng Ma struct fsl_mc_command cmd = { 0 };
173*3e0ca3c3SPeng Ma
174*3e0ca3c3SPeng Ma /* prepare command */
175*3e0ca3c3SPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DESTROY,
176*3e0ca3c3SPeng Ma cmd_flags, token);
177*3e0ca3c3SPeng Ma
178*3e0ca3c3SPeng Ma /* send command to mc*/
179*3e0ca3c3SPeng Ma return mc_send_command(mc_io, &cmd);
180*3e0ca3c3SPeng Ma }
181*3e0ca3c3SPeng Ma EXPORT_SYMBOL_GPL(dpdmai_destroy);
182*3e0ca3c3SPeng Ma
183*3e0ca3c3SPeng Ma /**
184f2835adfSPeng Ma * dpdmai_enable() - Enable the DPDMAI, allow sending and receiving frames.
185f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
186f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
187f2835adfSPeng Ma * @token: Token of DPDMAI object
188f2835adfSPeng Ma *
189f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
190f2835adfSPeng Ma */
dpdmai_enable(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token)191f2835adfSPeng Ma int dpdmai_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
192f2835adfSPeng Ma {
193f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
194f2835adfSPeng Ma
195f2835adfSPeng Ma /* prepare command */
196f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_ENABLE,
197f2835adfSPeng Ma cmd_flags, token);
198f2835adfSPeng Ma
199f2835adfSPeng Ma /* send command to mc*/
200f2835adfSPeng Ma return mc_send_command(mc_io, &cmd);
201f2835adfSPeng Ma }
20253596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_enable);
203f2835adfSPeng Ma
204f2835adfSPeng Ma /**
205f2835adfSPeng Ma * dpdmai_disable() - Disable the DPDMAI, stop sending and receiving frames.
206f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
207f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
208f2835adfSPeng Ma * @token: Token of DPDMAI object
209f2835adfSPeng Ma *
210f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
211f2835adfSPeng Ma */
dpdmai_disable(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token)212f2835adfSPeng Ma int dpdmai_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
213f2835adfSPeng Ma {
214f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
215f2835adfSPeng Ma
216f2835adfSPeng Ma /* prepare command */
217f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DISABLE,
218f2835adfSPeng Ma cmd_flags, token);
219f2835adfSPeng Ma
220f2835adfSPeng Ma /* send command to mc*/
221f2835adfSPeng Ma return mc_send_command(mc_io, &cmd);
222f2835adfSPeng Ma }
22353596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_disable);
224f2835adfSPeng Ma
225f2835adfSPeng Ma /**
226f2835adfSPeng Ma * dpdmai_reset() - Reset the DPDMAI, returns the object to initial state.
227f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
228f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
229f2835adfSPeng Ma * @token: Token of DPDMAI object
230f2835adfSPeng Ma *
231f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
232f2835adfSPeng Ma */
dpdmai_reset(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token)233f2835adfSPeng Ma int dpdmai_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
234f2835adfSPeng Ma {
235f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
236f2835adfSPeng Ma
237f2835adfSPeng Ma /* prepare command */
238f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_RESET,
239f2835adfSPeng Ma cmd_flags, token);
240f2835adfSPeng Ma
241f2835adfSPeng Ma /* send command to mc*/
242f2835adfSPeng Ma return mc_send_command(mc_io, &cmd);
243f2835adfSPeng Ma }
24453596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_reset);
245f2835adfSPeng Ma
246f2835adfSPeng Ma /**
247f2835adfSPeng Ma * dpdmai_get_attributes() - Retrieve DPDMAI attributes.
248f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
249f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
250f2835adfSPeng Ma * @token: Token of DPDMAI object
251f2835adfSPeng Ma * @attr: Returned object's attributes
252f2835adfSPeng Ma *
253f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
254f2835adfSPeng Ma */
dpdmai_get_attributes(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token,struct dpdmai_attr * attr)255f2835adfSPeng Ma int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
256f2835adfSPeng Ma u16 token, struct dpdmai_attr *attr)
257f2835adfSPeng Ma {
258f2835adfSPeng Ma struct dpdmai_rsp_get_attributes *rsp_params;
259f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
260f2835adfSPeng Ma int err;
261f2835adfSPeng Ma
262f2835adfSPeng Ma /* prepare command */
263f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_ATTR,
264f2835adfSPeng Ma cmd_flags, token);
265f2835adfSPeng Ma
266f2835adfSPeng Ma /* send command to mc*/
267f2835adfSPeng Ma err = mc_send_command(mc_io, &cmd);
268f2835adfSPeng Ma if (err)
269f2835adfSPeng Ma return err;
270f2835adfSPeng Ma
271f2835adfSPeng Ma /* retrieve response parameters */
272f2835adfSPeng Ma rsp_params = (struct dpdmai_rsp_get_attributes *)cmd.params;
273f2835adfSPeng Ma attr->id = le32_to_cpu(rsp_params->id);
274f2835adfSPeng Ma attr->version.major = le16_to_cpu(rsp_params->major);
275f2835adfSPeng Ma attr->version.minor = le16_to_cpu(rsp_params->minor);
276f2835adfSPeng Ma attr->num_of_priorities = rsp_params->num_of_priorities;
277f2835adfSPeng Ma
278f2835adfSPeng Ma return 0;
279f2835adfSPeng Ma }
28053596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_get_attributes);
281f2835adfSPeng Ma
282f2835adfSPeng Ma /**
283f2835adfSPeng Ma * dpdmai_set_rx_queue() - Set Rx queue configuration
284f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
285f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
286f2835adfSPeng Ma * @token: Token of DPDMAI object
287f2835adfSPeng Ma * @priority: Select the queue relative to number of
288f2835adfSPeng Ma * priorities configured at DPDMAI creation
289f2835adfSPeng Ma * @cfg: Rx queue configuration
290f2835adfSPeng Ma *
291f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
292f2835adfSPeng Ma */
dpdmai_set_rx_queue(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token,u8 priority,const struct dpdmai_rx_queue_cfg * cfg)293f2835adfSPeng Ma int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
294f2835adfSPeng Ma u8 priority, const struct dpdmai_rx_queue_cfg *cfg)
295f2835adfSPeng Ma {
296f2835adfSPeng Ma struct dpdmai_cmd_queue *cmd_params;
297f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
298f2835adfSPeng Ma
299f2835adfSPeng Ma /* prepare command */
300f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_RX_QUEUE,
301f2835adfSPeng Ma cmd_flags, token);
302f2835adfSPeng Ma
303f2835adfSPeng Ma cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
304f2835adfSPeng Ma cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
305f2835adfSPeng Ma cmd_params->priority = cfg->dest_cfg.priority;
306f2835adfSPeng Ma cmd_params->queue = priority;
307f2835adfSPeng Ma cmd_params->dest_type = cfg->dest_cfg.dest_type;
308f2835adfSPeng Ma cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
309f2835adfSPeng Ma cmd_params->options = cpu_to_le32(cfg->options);
310f2835adfSPeng Ma
311f2835adfSPeng Ma /* send command to mc*/
312f2835adfSPeng Ma return mc_send_command(mc_io, &cmd);
313f2835adfSPeng Ma }
31453596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_set_rx_queue);
315f2835adfSPeng Ma
316f2835adfSPeng Ma /**
317f2835adfSPeng Ma * dpdmai_get_rx_queue() - Retrieve Rx queue attributes.
318f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
319f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
320f2835adfSPeng Ma * @token: Token of DPDMAI object
321f2835adfSPeng Ma * @priority: Select the queue relative to number of
322f2835adfSPeng Ma * priorities configured at DPDMAI creation
323f2835adfSPeng Ma * @attr: Returned Rx queue attributes
324f2835adfSPeng Ma *
325f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
326f2835adfSPeng Ma */
dpdmai_get_rx_queue(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token,u8 priority,struct dpdmai_rx_queue_attr * attr)327f2835adfSPeng Ma int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
328f2835adfSPeng Ma u8 priority, struct dpdmai_rx_queue_attr *attr)
329f2835adfSPeng Ma {
330f2835adfSPeng Ma struct dpdmai_cmd_queue *cmd_params;
331f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
332f2835adfSPeng Ma int err;
333f2835adfSPeng Ma
334f2835adfSPeng Ma /* prepare command */
335f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_RX_QUEUE,
336f2835adfSPeng Ma cmd_flags, token);
337f2835adfSPeng Ma
338f2835adfSPeng Ma cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
339f2835adfSPeng Ma cmd_params->queue = priority;
340f2835adfSPeng Ma
341f2835adfSPeng Ma /* send command to mc*/
342f2835adfSPeng Ma err = mc_send_command(mc_io, &cmd);
343f2835adfSPeng Ma if (err)
344f2835adfSPeng Ma return err;
345f2835adfSPeng Ma
346f2835adfSPeng Ma /* retrieve response parameters */
347f2835adfSPeng Ma attr->dest_cfg.dest_id = le32_to_cpu(cmd_params->dest_id);
348f2835adfSPeng Ma attr->dest_cfg.priority = cmd_params->priority;
349f2835adfSPeng Ma attr->dest_cfg.dest_type = cmd_params->dest_type;
350f2835adfSPeng Ma attr->user_ctx = le64_to_cpu(cmd_params->user_ctx);
351f2835adfSPeng Ma attr->fqid = le32_to_cpu(cmd_params->fqid);
352f2835adfSPeng Ma
353f2835adfSPeng Ma return 0;
354f2835adfSPeng Ma }
35553596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_get_rx_queue);
356f2835adfSPeng Ma
357f2835adfSPeng Ma /**
358f2835adfSPeng Ma * dpdmai_get_tx_queue() - Retrieve Tx queue attributes.
359f2835adfSPeng Ma * @mc_io: Pointer to MC portal's I/O object
360f2835adfSPeng Ma * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
361f2835adfSPeng Ma * @token: Token of DPDMAI object
362f2835adfSPeng Ma * @priority: Select the queue relative to number of
363f2835adfSPeng Ma * priorities configured at DPDMAI creation
364f2835adfSPeng Ma * @fqid: Returned Tx queue
365f2835adfSPeng Ma *
366f2835adfSPeng Ma * Return: '0' on Success; Error code otherwise.
367f2835adfSPeng Ma */
dpdmai_get_tx_queue(struct fsl_mc_io * mc_io,u32 cmd_flags,u16 token,u8 priority,u32 * fqid)368f2835adfSPeng Ma int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,
369f2835adfSPeng Ma u16 token, u8 priority, u32 *fqid)
370f2835adfSPeng Ma {
371f2835adfSPeng Ma struct dpdmai_rsp_get_tx_queue *rsp_params;
372f2835adfSPeng Ma struct dpdmai_cmd_queue *cmd_params;
373f2835adfSPeng Ma struct fsl_mc_command cmd = { 0 };
374f2835adfSPeng Ma int err;
375f2835adfSPeng Ma
376f2835adfSPeng Ma /* prepare command */
377f2835adfSPeng Ma cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_TX_QUEUE,
378f2835adfSPeng Ma cmd_flags, token);
379f2835adfSPeng Ma
380f2835adfSPeng Ma cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
381f2835adfSPeng Ma cmd_params->queue = priority;
382f2835adfSPeng Ma
383f2835adfSPeng Ma /* send command to mc*/
384f2835adfSPeng Ma err = mc_send_command(mc_io, &cmd);
385f2835adfSPeng Ma if (err)
386f2835adfSPeng Ma return err;
387f2835adfSPeng Ma
388f2835adfSPeng Ma /* retrieve response parameters */
389f2835adfSPeng Ma
390f2835adfSPeng Ma rsp_params = (struct dpdmai_rsp_get_tx_queue *)cmd.params;
391f2835adfSPeng Ma *fqid = le32_to_cpu(rsp_params->fqid);
392f2835adfSPeng Ma
393f2835adfSPeng Ma return 0;
394f2835adfSPeng Ma }
39553596dfaSPeng Ma EXPORT_SYMBOL_GPL(dpdmai_get_tx_queue);
39653596dfaSPeng Ma
39753596dfaSPeng Ma MODULE_LICENSE("GPL v2");
398