1
1
// SPDX-License-Identifier: GPL-2.0
2
2
// Copyright 2019 NXP
3
3
4
+ #include <linux/bitfield.h>
4
5
#include <linux/module.h>
5
6
#include <linux/types.h>
6
7
#include <linux/io.h>
7
8
#include <linux/fsl/mc.h>
8
9
#include "dpdmai.h"
9
10
11
+ #define DEST_TYPE_MASK 0xF
12
+
10
13
struct dpdmai_rsp_get_attributes {
11
14
__le32 id ;
12
15
u8 num_of_priorities ;
13
- u8 pad0 [3 ];
16
+ u8 num_of_queues ;
17
+ u8 pad0 [2 ];
14
18
__le16 major ;
15
19
__le16 minor ;
16
20
};
17
21
18
22
struct dpdmai_cmd_queue {
19
23
__le32 dest_id ;
20
- u8 priority ;
21
- u8 queue ;
24
+ u8 dest_priority ;
25
+ union {
26
+ u8 queue ;
27
+ u8 pri ;
28
+ };
22
29
u8 dest_type ;
23
- u8 pad ;
30
+ u8 queue_idx ;
24
31
__le64 user_ctx ;
25
32
union {
26
33
__le32 options ;
27
34
__le32 fqid ;
28
35
};
29
- };
36
+ } __packed ;
30
37
31
38
struct dpdmai_rsp_get_tx_queue {
32
39
__le64 pad ;
@@ -37,6 +44,10 @@ struct dpdmai_cmd_open {
37
44
__le32 dpdmai_id ;
38
45
} __packed ;
39
46
47
+ struct dpdmai_cmd_destroy {
48
+ __le32 dpdmai_id ;
49
+ } __packed ;
50
+
40
51
static inline u64 mc_enc (int lsoffset , int width , u64 val )
41
52
{
42
53
return (val & MAKE_UMASK64 (width )) << lsoffset ;
@@ -113,18 +124,23 @@ EXPORT_SYMBOL_GPL(dpdmai_close);
113
124
* dpdmai_destroy() - Destroy the DPDMAI object and release all its resources.
114
125
* @mc_io: Pointer to MC portal's I/O object
115
126
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
127
+ * @dpdmai_id: The object id; it must be a valid id within the container that created this object;
116
128
* @token: Token of DPDMAI object
117
129
*
118
130
* Return: '0' on Success; error code otherwise.
119
131
*/
120
- int dpdmai_destroy (struct fsl_mc_io * mc_io , u32 cmd_flags , u16 token )
132
+ int dpdmai_destroy (struct fsl_mc_io * mc_io , u32 cmd_flags , u32 dpdmai_id , u16 token )
121
133
{
134
+ struct dpdmai_cmd_destroy * cmd_params ;
122
135
struct fsl_mc_command cmd = { 0 };
123
136
124
137
/* prepare command */
125
138
cmd .header = mc_encode_cmd_header (DPDMAI_CMDID_DESTROY ,
126
139
cmd_flags , token );
127
140
141
+ cmd_params = (struct dpdmai_cmd_destroy * )& cmd .params ;
142
+ cmd_params -> dpdmai_id = cpu_to_le32 (dpdmai_id );
143
+
128
144
/* send command to mc*/
129
145
return mc_send_command (mc_io , & cmd );
130
146
}
@@ -224,6 +240,7 @@ int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
224
240
attr -> version .major = le16_to_cpu (rsp_params -> major );
225
241
attr -> version .minor = le16_to_cpu (rsp_params -> minor );
226
242
attr -> num_of_priorities = rsp_params -> num_of_priorities ;
243
+ attr -> num_of_queues = rsp_params -> num_of_queues ;
227
244
228
245
return 0 ;
229
246
}
@@ -240,7 +257,7 @@ EXPORT_SYMBOL_GPL(dpdmai_get_attributes);
240
257
*
241
258
* Return: '0' on Success; Error code otherwise.
242
259
*/
243
- int dpdmai_set_rx_queue (struct fsl_mc_io * mc_io , u32 cmd_flags , u16 token ,
260
+ int dpdmai_set_rx_queue (struct fsl_mc_io * mc_io , u32 cmd_flags , u16 token , u8 queue_idx ,
244
261
u8 priority , const struct dpdmai_rx_queue_cfg * cfg )
245
262
{
246
263
struct dpdmai_cmd_queue * cmd_params ;
@@ -252,11 +269,12 @@ int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
252
269
253
270
cmd_params = (struct dpdmai_cmd_queue * )cmd .params ;
254
271
cmd_params -> dest_id = cpu_to_le32 (cfg -> dest_cfg .dest_id );
255
- cmd_params -> priority = cfg -> dest_cfg .priority ;
256
- cmd_params -> queue = priority ;
272
+ cmd_params -> dest_priority = cfg -> dest_cfg .priority ;
273
+ cmd_params -> pri = priority ;
257
274
cmd_params -> dest_type = cfg -> dest_cfg .dest_type ;
258
275
cmd_params -> user_ctx = cpu_to_le64 (cfg -> user_ctx );
259
276
cmd_params -> options = cpu_to_le32 (cfg -> options );
277
+ cmd_params -> queue_idx = queue_idx ;
260
278
261
279
/* send command to mc*/
262
280
return mc_send_command (mc_io , & cmd );
@@ -274,7 +292,7 @@ EXPORT_SYMBOL_GPL(dpdmai_set_rx_queue);
274
292
*
275
293
* Return: '0' on Success; Error code otherwise.
276
294
*/
277
- int dpdmai_get_rx_queue (struct fsl_mc_io * mc_io , u32 cmd_flags , u16 token ,
295
+ int dpdmai_get_rx_queue (struct fsl_mc_io * mc_io , u32 cmd_flags , u16 token , u8 queue_idx ,
278
296
u8 priority , struct dpdmai_rx_queue_attr * attr )
279
297
{
280
298
struct dpdmai_cmd_queue * cmd_params ;
@@ -287,6 +305,7 @@ int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
287
305
288
306
cmd_params = (struct dpdmai_cmd_queue * )cmd .params ;
289
307
cmd_params -> queue = priority ;
308
+ cmd_params -> queue_idx = queue_idx ;
290
309
291
310
/* send command to mc*/
292
311
err = mc_send_command (mc_io , & cmd );
@@ -295,8 +314,8 @@ int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
295
314
296
315
/* retrieve response parameters */
297
316
attr -> dest_cfg .dest_id = le32_to_cpu (cmd_params -> dest_id );
298
- attr -> dest_cfg .priority = cmd_params -> priority ;
299
- attr -> dest_cfg .dest_type = cmd_params -> dest_type ;
317
+ attr -> dest_cfg .priority = cmd_params -> dest_priority ;
318
+ attr -> dest_cfg .dest_type = FIELD_GET ( DEST_TYPE_MASK , cmd_params -> dest_type ) ;
300
319
attr -> user_ctx = le64_to_cpu (cmd_params -> user_ctx );
301
320
attr -> fqid = le32_to_cpu (cmd_params -> fqid );
302
321
@@ -316,7 +335,7 @@ EXPORT_SYMBOL_GPL(dpdmai_get_rx_queue);
316
335
* Return: '0' on Success; Error code otherwise.
317
336
*/
318
337
int dpdmai_get_tx_queue (struct fsl_mc_io * mc_io , u32 cmd_flags ,
319
- u16 token , u8 priority , u32 * fqid )
338
+ u16 token , u8 queue_idx , u8 priority , struct dpdmai_tx_queue_attr * attr )
320
339
{
321
340
struct dpdmai_rsp_get_tx_queue * rsp_params ;
322
341
struct dpdmai_cmd_queue * cmd_params ;
@@ -329,6 +348,7 @@ int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,
329
348
330
349
cmd_params = (struct dpdmai_cmd_queue * )cmd .params ;
331
350
cmd_params -> queue = priority ;
351
+ cmd_params -> queue_idx = queue_idx ;
332
352
333
353
/* send command to mc*/
334
354
err = mc_send_command (mc_io , & cmd );
@@ -338,7 +358,7 @@ int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,
338
358
/* retrieve response parameters */
339
359
340
360
rsp_params = (struct dpdmai_rsp_get_tx_queue * )cmd .params ;
341
- * fqid = le32_to_cpu (rsp_params -> fqid );
361
+ attr -> fqid = le32_to_cpu (rsp_params -> fqid );
342
362
343
363
return 0 ;
344
364
}
0 commit comments