xref: /dpdk/drivers/crypto/dpaa2_sec/mc/dpseci.c (revision 131a75b6e4df60586103d71defb85dcf9f77fb17)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016 NXP
5  *
6  */
7 #include <fsl_mc_sys.h>
8 #include <fsl_mc_cmd.h>
9 #include <fsl_dpseci.h>
10 #include <fsl_dpseci_cmd.h>
11 
12 /**
13  * dpseci_open() - Open a control session for the specified object
14  * @mc_io:	Pointer to MC portal's I/O object
15  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
16  * @dpseci_id:	DPSECI unique ID
17  * @token:	Returned token; use in subsequent API calls
18  *
19  * This function can be used to open a control session for an
20  * already created object; an object may have been declared in
21  * the DPL or by calling the dpseci_create() function.
22  * This function returns a unique authentication token,
23  * associated with the specific object ID and the specific MC
24  * portal; this token must be used in all subsequent commands for
25  * this specific object.
26  *
27  * Return:	'0' on Success; Error code otherwise.
28  */
29 int dpseci_open(struct fsl_mc_io *mc_io,
30 		uint32_t cmd_flags,
31 		int dpseci_id,
32 		uint16_t *token)
33 {
34 	struct dpseci_cmd_open *cmd_params;
35 	struct mc_command cmd = { 0 };
36 	int err;
37 
38 	/* prepare command */
39 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
40 					  cmd_flags,
41 					  0);
42 	cmd_params = (struct dpseci_cmd_open *)cmd.params;
43 	cmd_params->dpseci_id = cpu_to_le32(dpseci_id);
44 
45 	/* send command to mc*/
46 	err = mc_send_command(mc_io, &cmd);
47 	if (err)
48 		return err;
49 
50 	/* retrieve response parameters */
51 	*token = mc_cmd_hdr_read_token(&cmd);
52 
53 	return 0;
54 }
55 
56 /**
57  * dpseci_close() - Close the control session of the object
58  * @mc_io:	Pointer to MC portal's I/O object
59  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
60  * @token:	Token of DPSECI object
61  *
62  * After this function is called, no further operations are
63  * allowed on the object without opening a new control session.
64  *
65  * Return:	'0' on Success; Error code otherwise.
66  */
67 int dpseci_close(struct fsl_mc_io *mc_io,
68 		 uint32_t cmd_flags,
69 		 uint16_t token)
70 {
71 	struct mc_command cmd = { 0 };
72 
73 	/* prepare command */
74 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
75 					  cmd_flags,
76 					  token);
77 
78 	/* send command to mc*/
79 	return mc_send_command(mc_io, &cmd);
80 }
81 
82 /**
83  * dpseci_create() - Create the DPSECI object
84  * @mc_io:	Pointer to MC portal's I/O object
85  * @dprc_token:	Parent container token; '0' for default container
86  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
87  * @cfg:	Configuration structure
88  * @obj_id:	Returned object id
89  *
90  * Create the DPSECI object, allocate required resources and
91  * perform required initialization.
92  *
93  * The object can be created either by declaring it in the
94  * DPL file, or by calling this function.
95  *
96  * The function accepts an authentication token of a parent
97  * container that this object should be assigned to. The token
98  * can be '0' so the object will be assigned to the default container.
99  * The newly created object can be opened with the returned
100  * object id and using the container's associated tokens and MC portals.
101  *
102  * Return:	'0' on Success; Error code otherwise.
103  */
104 int dpseci_create(struct fsl_mc_io *mc_io,
105 		  uint16_t dprc_token,
106 		  uint32_t cmd_flags,
107 		  const struct dpseci_cfg *cfg,
108 		  uint32_t *obj_id)
109 {
110 	struct dpseci_cmd_create *cmd_params;
111 	struct mc_command cmd = { 0 };
112 	int err, i;
113 
114 	/* prepare command */
115 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE,
116 					  cmd_flags,
117 					  dprc_token);
118 	cmd_params = (struct dpseci_cmd_create *)cmd.params;
119 	for (i = 0; i < DPSECI_PRIO_NUM; i++)
120 		cmd_params->priorities[i] = cfg->priorities[i];
121 	cmd_params->num_tx_queues = cfg->num_tx_queues;
122 	cmd_params->num_rx_queues = cfg->num_rx_queues;
123 	cmd_params->options = cfg->options;
124 
125 	/* send command to mc*/
126 	err = mc_send_command(mc_io, &cmd);
127 	if (err)
128 		return err;
129 
130 	/* retrieve response parameters */
131 	*obj_id = mc_cmd_read_object_id(&cmd);
132 
133 	return 0;
134 }
135 
136 /**
137  * dpseci_destroy() - Destroy the DPSECI object and release all its resources.
138  * @mc_io:	Pointer to MC portal's I/O object
139  * @dprc_token: Parent container token; '0' for default container
140  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
141  * @object_id:	The object id; it must be a valid id within the container that
142  * created this object;
143  *
144  * The function accepts the authentication token of the parent container that
145  * created the object (not the one that currently owns the object). The object
146  * is searched within parent using the provided 'object_id'.
147  * All tokens to the object must be closed before calling destroy.
148  *
149  * Return:	'0' on Success; error code otherwise.
150  */
151 int dpseci_destroy(struct fsl_mc_io *mc_io,
152 		   uint16_t dprc_token,
153 		   uint32_t cmd_flags,
154 		   uint32_t object_id)
155 {
156 	struct dpseci_cmd_destroy *cmd_params;
157 	struct mc_command cmd = { 0 };
158 
159 	/* prepare command */
160 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DESTROY,
161 					  cmd_flags,
162 					  dprc_token);
163 	cmd_params = (struct dpseci_cmd_destroy *)cmd.params;
164 	cmd_params->dpseci_id = cpu_to_le32(object_id);
165 
166 	/* send command to mc*/
167 	return mc_send_command(mc_io, &cmd);
168 }
169 
170 /**
171  * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames.
172  * @mc_io:	Pointer to MC portal's I/O object
173  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
174  * @token:	Token of DPSECI object
175  *
176  * Return:	'0' on Success; Error code otherwise.
177  */
178 int dpseci_enable(struct fsl_mc_io *mc_io,
179 		  uint32_t cmd_flags,
180 		  uint16_t token)
181 {
182 	struct mc_command cmd = { 0 };
183 
184 	/* prepare command */
185 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
186 					  cmd_flags,
187 					  token);
188 
189 	/* send command to mc*/
190 	return mc_send_command(mc_io, &cmd);
191 }
192 
193 /**
194  * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames.
195  * @mc_io:	Pointer to MC portal's I/O object
196  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
197  * @token:	Token of DPSECI object
198  *
199  * Return:	'0' on Success; Error code otherwise.
200  */
201 int dpseci_disable(struct fsl_mc_io *mc_io,
202 		   uint32_t cmd_flags,
203 		   uint16_t token)
204 {
205 	struct mc_command cmd = { 0 };
206 
207 	/* prepare command */
208 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
209 					  cmd_flags,
210 					  token);
211 
212 	/* send command to mc*/
213 	return mc_send_command(mc_io, &cmd);
214 }
215 
216 /**
217  * dpseci_is_enabled() - Check if the DPSECI is enabled.
218  * @mc_io:	Pointer to MC portal's I/O object
219  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
220  * @token:	Token of DPSECI object
221  * @en:		Returns '1' if object is enabled; '0' otherwise
222  *
223  * Return:	'0' on Success; Error code otherwise.
224  */
225 int dpseci_is_enabled(struct fsl_mc_io *mc_io,
226 		      uint32_t cmd_flags,
227 		      uint16_t token,
228 		      int *en)
229 {
230 	struct dpseci_rsp_is_enabled *rsp_params;
231 	struct mc_command cmd = { 0 };
232 	int err;
233 
234 	/* prepare command */
235 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
236 					  cmd_flags,
237 					  token);
238 
239 	/* send command to mc*/
240 	err = mc_send_command(mc_io, &cmd);
241 	if (err)
242 		return err;
243 
244 	/* retrieve response parameters */
245 	rsp_params = (struct dpseci_rsp_is_enabled *)cmd.params;
246 	*en = dpseci_get_field(rsp_params->en, ENABLE);
247 
248 	return 0;
249 }
250 
251 /**
252  * dpseci_reset() - Reset the DPSECI, returns the object to initial state.
253  * @mc_io:	Pointer to MC portal's I/O object
254  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
255  * @token:	Token of DPSECI object
256  *
257  * Return:	'0' on Success; Error code otherwise.
258  */
259 int dpseci_reset(struct fsl_mc_io *mc_io,
260 		 uint32_t cmd_flags,
261 		 uint16_t token)
262 {
263 	struct mc_command cmd = { 0 };
264 
265 	/* prepare command */
266 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
267 					  cmd_flags,
268 					  token);
269 
270 	/* send command to mc*/
271 	return mc_send_command(mc_io, &cmd);
272 }
273 
274 /**
275  * dpseci_get_attributes() - Retrieve DPSECI attributes.
276  * @mc_io:	Pointer to MC portal's I/O object
277  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
278  * @token:	Token of DPSECI object
279  * @attr:	Returned object's attributes
280  *
281  * Return:	'0' on Success; Error code otherwise.
282  */
283 int dpseci_get_attributes(struct fsl_mc_io *mc_io,
284 			  uint32_t cmd_flags,
285 			  uint16_t token,
286 			  struct dpseci_attr *attr)
287 {
288 	struct dpseci_rsp_get_attr *rsp_params;
289 	struct mc_command cmd = { 0 };
290 	int err;
291 
292 	/* prepare command */
293 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
294 					  cmd_flags,
295 					  token);
296 
297 	/* send command to mc*/
298 	err = mc_send_command(mc_io, &cmd);
299 	if (err)
300 		return err;
301 
302 	/* retrieve response parameters */
303 	rsp_params = (struct dpseci_rsp_get_attr *)cmd.params;
304 	attr->id = le32_to_cpu(rsp_params->id);
305 	attr->options = rsp_params->options;
306 	attr->num_tx_queues = rsp_params->num_tx_queues;
307 	attr->num_rx_queues = rsp_params->num_rx_queues;
308 
309 	return 0;
310 }
311 
312 /**
313  * dpseci_set_rx_queue() - Set Rx queue configuration
314  * @mc_io:	Pointer to MC portal's I/O object
315  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
316  * @token:	Token of DPSECI object
317  * @queue:	Select the queue relative to number of
318  *		priorities configured at DPSECI creation; use
319  *		DPSECI_ALL_QUEUES to configure all Rx queues identically.
320  * @cfg:	Rx queue configuration
321  *
322  * Return:	'0' on Success; Error code otherwise.
323  */
324 int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
325 			uint32_t cmd_flags,
326 			uint16_t token,
327 			uint8_t queue,
328 			const struct dpseci_rx_queue_cfg *cfg)
329 {
330 	struct dpseci_cmd_set_rx_queue *cmd_params;
331 	struct mc_command cmd = { 0 };
332 
333 	/* prepare command */
334 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
335 					  cmd_flags,
336 					  token);
337 	cmd_params = (struct dpseci_cmd_set_rx_queue *)cmd.params;
338 	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
339 	cmd_params->dest_priority = cfg->dest_cfg.priority;
340 	cmd_params->queue = queue;
341 	cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
342 	cmd_params->options = cpu_to_le32(cfg->options);
343 	dpseci_set_field(cmd_params->dest_type,
344 			 DEST_TYPE,
345 			 cfg->dest_cfg.dest_type);
346 	dpseci_set_field(cmd_params->order_preservation_en,
347 			 ORDER_PRESERVATION,
348 			 cfg->order_preservation_en);
349 
350 	/* send command to mc*/
351 	return mc_send_command(mc_io, &cmd);
352 }
353 
354 /**
355  * dpseci_get_rx_queue() - Retrieve Rx queue attributes.
356  * @mc_io:	Pointer to MC portal's I/O object
357  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
358  * @token:	Token of DPSECI object
359  * @queue:	Select the queue relative to number of
360  *				priorities configured at DPSECI creation
361  * @attr:	Returned Rx queue attributes
362  *
363  * Return:	'0' on Success; Error code otherwise.
364  */
365 int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
366 			uint32_t cmd_flags,
367 			uint16_t token,
368 			uint8_t queue,
369 			struct dpseci_rx_queue_attr *attr)
370 {
371 	struct dpseci_rsp_get_rx_queue *rsp_params;
372 	struct dpseci_cmd_get_queue *cmd_params;
373 	struct mc_command cmd = { 0 };
374 	int err;
375 
376 	/* prepare command */
377 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
378 					  cmd_flags,
379 					  token);
380 	cmd_params = (struct dpseci_cmd_get_queue *)cmd.params;
381 	cmd_params->queue = queue;
382 
383 	/* send command to mc*/
384 	err = mc_send_command(mc_io, &cmd);
385 	if (err)
386 		return err;
387 
388 	/* retrieve response parameters */
389 	rsp_params = (struct dpseci_rsp_get_rx_queue *)cmd.params;
390 	attr->user_ctx = le64_to_cpu(rsp_params->user_ctx);
391 	attr->fqid = le32_to_cpu(rsp_params->fqid);
392 	attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
393 	attr->dest_cfg.priority = rsp_params->dest_priority;
394 	attr->dest_cfg.dest_type =
395 		dpseci_get_field(rsp_params->dest_type,
396 				 DEST_TYPE);
397 	attr->order_preservation_en =
398 		dpseci_get_field(rsp_params->order_preservation_en,
399 				 ORDER_PRESERVATION);
400 
401 	return 0;
402 }
403 
404 /**
405  * dpseci_get_tx_queue() - Retrieve Tx queue attributes.
406  * @mc_io:	Pointer to MC portal's I/O object
407  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
408  * @token:	Token of DPSECI object
409  * @queue:	Select the queue relative to number of
410  *		priorities configured at DPSECI creation
411  * @attr:	Returned Tx queue attributes
412  *
413  * Return:	'0' on Success; Error code otherwise.
414  */
415 int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
416 			uint32_t cmd_flags,
417 			uint16_t token,
418 			uint8_t queue,
419 			struct dpseci_tx_queue_attr *attr)
420 {
421 	struct dpseci_rsp_get_tx_queue *rsp_params;
422 	struct dpseci_cmd_get_queue *cmd_params;
423 	struct mc_command cmd = { 0 };
424 	int err;
425 
426 	/* prepare command */
427 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
428 					  cmd_flags,
429 					  token);
430 	cmd_params = (struct dpseci_cmd_get_queue *)cmd.params;
431 	cmd_params->queue = queue;
432 
433 	/* send command to mc*/
434 	err = mc_send_command(mc_io, &cmd);
435 	if (err)
436 		return err;
437 
438 	/* retrieve response parameters */
439 	rsp_params = (struct dpseci_rsp_get_tx_queue *)cmd.params;
440 	attr->fqid = le32_to_cpu(rsp_params->fqid);
441 	attr->priority = rsp_params->priority;
442 
443 	return 0;
444 }
445 
446 /**
447  * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes.
448  * @mc_io:	Pointer to MC portal's I/O object
449  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
450  * @token:	Token of DPSECI object
451  * @attr:	Returned SEC attributes
452  *
453  * Return:	'0' on Success; Error code otherwise.
454  */
455 int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
456 			uint32_t cmd_flags,
457 			uint16_t token,
458 			struct dpseci_sec_attr *attr)
459 {
460 	struct dpseci_rsp_get_sec_attr *rsp_params;
461 	struct mc_command cmd = { 0 };
462 	int err;
463 
464 	/* prepare command */
465 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
466 					  cmd_flags,
467 					  token);
468 
469 	/* send command to mc*/
470 	err = mc_send_command(mc_io, &cmd);
471 	if (err)
472 		return err;
473 
474 	/* retrieve response parameters */
475 	rsp_params = (struct dpseci_rsp_get_sec_attr *)cmd.params;
476 	attr->ip_id = le16_to_cpu(rsp_params->ip_id);
477 	attr->major_rev = rsp_params->major_rev;
478 	attr->minor_rev = rsp_params->minor_rev;
479 	attr->era = rsp_params->era;
480 	attr->deco_num = rsp_params->deco_num;
481 	attr->zuc_auth_acc_num = rsp_params->zuc_auth_acc_num;
482 	attr->zuc_enc_acc_num = rsp_params->zuc_enc_acc_num;
483 	attr->snow_f8_acc_num = rsp_params->snow_f8_acc_num;
484 	attr->snow_f9_acc_num = rsp_params->snow_f9_acc_num;
485 	attr->crc_acc_num = rsp_params->crc_acc_num;
486 	attr->pk_acc_num = rsp_params->pk_acc_num;
487 	attr->kasumi_acc_num = rsp_params->kasumi_acc_num;
488 	attr->rng_acc_num = rsp_params->rng_acc_num;
489 	attr->md_acc_num = rsp_params->md_acc_num;
490 	attr->arc4_acc_num = rsp_params->arc4_acc_num;
491 	attr->des_acc_num = rsp_params->des_acc_num;
492 	attr->aes_acc_num = rsp_params->aes_acc_num;
493 
494 	return 0;
495 }
496 
497 /**
498  * dpseci_get_sec_counters() - Retrieve SEC accelerator counters.
499  * @mc_io:	Pointer to MC portal's I/O object
500  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
501  * @token:	Token of DPSECI object
502  * @counters:	Returned SEC counters
503  *
504  * Return:	'0' on Success; Error code otherwise.
505  */
506 int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
507 			    uint32_t cmd_flags,
508 			    uint16_t token,
509 			    struct dpseci_sec_counters *counters)
510 {
511 	struct dpseci_rsp_get_sec_counters *rsp_params;
512 	struct mc_command cmd = { 0 };
513 	int err;
514 
515 	/* prepare command */
516 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS,
517 					  cmd_flags,
518 					  token);
519 
520 	/* send command to mc*/
521 	err = mc_send_command(mc_io, &cmd);
522 	if (err)
523 		return err;
524 
525 	/* retrieve response parameters */
526 	rsp_params = (struct dpseci_rsp_get_sec_counters *)cmd.params;
527 	counters->dequeued_requests =
528 				le64_to_cpu(rsp_params->dequeued_requests);
529 	counters->ob_enc_requests = le64_to_cpu(rsp_params->ob_enc_requests);
530 	counters->ib_dec_requests = le64_to_cpu(rsp_params->ib_dec_requests);
531 	counters->ob_enc_bytes = le64_to_cpu(rsp_params->ob_enc_bytes);
532 	counters->ob_prot_bytes = le64_to_cpu(rsp_params->ob_prot_bytes);
533 	counters->ib_dec_bytes = le64_to_cpu(rsp_params->ib_dec_bytes);
534 	counters->ib_valid_bytes = le64_to_cpu(rsp_params->ib_valid_bytes);
535 
536 	return 0;
537 }
538 
539 /**
540  * dpseci_get_api_version() - Get Data Path SEC Interface API version
541  * @mc_io:  Pointer to MC portal's I/O object
542  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
543  * @major_ver:	Major version of data path sec API
544  * @minor_ver:	Minor version of data path sec API
545  *
546  * Return:  '0' on Success; Error code otherwise.
547  */
548 int dpseci_get_api_version(struct fsl_mc_io *mc_io,
549 			   uint32_t cmd_flags,
550 			   uint16_t *major_ver,
551 			   uint16_t *minor_ver)
552 {
553 	struct dpseci_rsp_get_api_version *rsp_params;
554 	struct mc_command cmd = { 0 };
555 	int err;
556 
557 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION,
558 					cmd_flags,
559 					0);
560 
561 	err = mc_send_command(mc_io, &cmd);
562 	if (err)
563 		return err;
564 
565 	rsp_params = (struct dpseci_rsp_get_api_version *)cmd.params;
566 	*major_ver = le16_to_cpu(rsp_params->major);
567 	*minor_ver = le16_to_cpu(rsp_params->minor);
568 
569 	return 0;
570 }
571 
572 int dpseci_set_congestion_notification(
573 			struct fsl_mc_io *mc_io,
574 			uint32_t cmd_flags,
575 			uint16_t token,
576 			const struct dpseci_congestion_notification_cfg *cfg)
577 {
578 	struct dpseci_cmd_set_congestion_notification *cmd_params;
579 	struct mc_command cmd = { 0 };
580 
581 	/* prepare command */
582 	cmd.header = mc_encode_cmd_header(
583 			DPSECI_CMDID_SET_CONGESTION_NOTIFICATION,
584 			cmd_flags,
585 			token);
586 
587 	cmd_params =
588 		(struct dpseci_cmd_set_congestion_notification *)cmd.params;
589 	cmd_params->dest_id = cfg->dest_cfg.dest_id;
590 	cmd_params->dest_priority = cfg->dest_cfg.priority;
591 	cmd_params->message_ctx = cfg->message_ctx;
592 	cmd_params->message_iova = cfg->message_iova;
593 	cmd_params->notification_mode = cfg->notification_mode;
594 	cmd_params->threshold_entry = cfg->threshold_entry;
595 	cmd_params->threshold_exit = cfg->threshold_exit;
596 	dpseci_set_field(cmd_params->type_units,
597 			 DEST_TYPE,
598 			 cfg->dest_cfg.dest_type);
599 	dpseci_set_field(cmd_params->type_units,
600 			 CG_UNITS,
601 			 cfg->units);
602 
603 	/* send command to mc*/
604 	return mc_send_command(mc_io, &cmd);
605 }
606 
607 int dpseci_get_congestion_notification(
608 				struct fsl_mc_io *mc_io,
609 				uint32_t cmd_flags,
610 				uint16_t token,
611 				struct dpseci_congestion_notification_cfg *cfg)
612 {
613 	struct dpseci_cmd_set_congestion_notification *rsp_params;
614 	struct mc_command cmd = { 0 };
615 	int err;
616 
617 	/* prepare command */
618 	cmd.header = mc_encode_cmd_header(
619 			DPSECI_CMDID_GET_CONGESTION_NOTIFICATION,
620 			cmd_flags,
621 			token);
622 
623 	/* send command to mc*/
624 	err = mc_send_command(mc_io, &cmd);
625 	if (err)
626 		return err;
627 
628 	rsp_params =
629 		(struct dpseci_cmd_set_congestion_notification *)cmd.params;
630 
631 	cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
632 	cfg->dest_cfg.priority = rsp_params->dest_priority;
633 	cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode);
634 	cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx);
635 	cfg->message_iova = le64_to_cpu(rsp_params->message_iova);
636 	cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry);
637 	cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit);
638 	cfg->units = dpseci_get_field(rsp_params->type_units, CG_UNITS);
639 	cfg->dest_cfg.dest_type = dpseci_get_field(rsp_params->type_units,
640 						DEST_TYPE);
641 
642 	return 0;
643 }
644