Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright 2013-2016 Freescale Semiconductor Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright 2017-2018 NXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/fsl/mc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "dpseci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "dpseci_cmd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * dpseci_open() - Open a control session for the specified object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * @dpseci_id:	DPSECI unique ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * @token:	Returned token; use in subsequent API calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * This function can be used to open a control session for an already created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * object; an object may have been declared statically in the DPL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * or created dynamically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * This function returns a unique authentication token, associated with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * specific object ID and the specific MC portal; this token must be used in all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * subsequent commands for this specific object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		u16 *token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct dpseci_cmd_open *cmd_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 					  0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	cmd_params = (struct dpseci_cmd_open *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	cmd_params->dpseci_id = cpu_to_le32(dpseci_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	*token = mc_cmd_hdr_read_token(&cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * dpseci_close() - Close the control session of the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * After this function is called, no further operations are allowed on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * object without opening a new control session.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * dpseci_reset() - Reset the DPSECI, returns the object to initial state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * dpseci_is_enabled() - Check if the DPSECI is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * @en:		Returns '1' if object is enabled; '0' otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		      int *en)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	struct dpseci_rsp_is_enabled *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	rsp_params = (struct dpseci_rsp_is_enabled *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	*en = dpseci_get_field(rsp_params->is_enabled, ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * dpseci_get_attributes() - Retrieve DPSECI attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * @attr:	Returned object's attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			  struct dpseci_attr *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	struct dpseci_rsp_get_attributes *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	rsp_params = (struct dpseci_rsp_get_attributes *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	attr->id = le32_to_cpu(rsp_params->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	attr->num_tx_queues = rsp_params->num_tx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	attr->num_rx_queues = rsp_params->num_rx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	attr->options = le32_to_cpu(rsp_params->options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * dpseci_set_rx_queue() - Set Rx queue configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * @queue:	Select the queue relative to number of priorities configured at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  *		DPSECI creation; use DPSECI_ALL_QUEUES to configure all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  *		Rx queues identically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * @cfg:	Rx queue configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			u8 queue, const struct dpseci_rx_queue_cfg *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct dpseci_cmd_queue *cmd_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	cmd_params = (struct dpseci_cmd_queue *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	cmd_params->priority = cfg->dest_cfg.priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	cmd_params->queue = queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	dpseci_set_field(cmd_params->dest_type, DEST_TYPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			 cfg->dest_cfg.dest_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	cmd_params->options = cpu_to_le32(cfg->options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	dpseci_set_field(cmd_params->order_preservation_en, ORDER_PRESERVATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			 cfg->order_preservation_en);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * dpseci_get_rx_queue() - Retrieve Rx queue attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  * @queue:	Select the queue relative to number of priorities configured at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  *		DPSECI creation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  * @attr:	Returned Rx queue attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			u8 queue, struct dpseci_rx_queue_attr *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	struct dpseci_cmd_queue *cmd_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	cmd_params = (struct dpseci_cmd_queue *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	cmd_params->queue = queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	attr->dest_cfg.dest_id = le32_to_cpu(cmd_params->dest_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	attr->dest_cfg.priority = cmd_params->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	attr->dest_cfg.dest_type = dpseci_get_field(cmd_params->dest_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 						    DEST_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	attr->user_ctx = le64_to_cpu(cmd_params->user_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	attr->fqid = le32_to_cpu(cmd_params->fqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	attr->order_preservation_en =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		dpseci_get_field(cmd_params->order_preservation_en,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 				 ORDER_PRESERVATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  * dpseci_get_tx_queue() - Retrieve Tx queue attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * @queue:	Select the queue relative to number of priorities configured at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *		DPSECI creation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * @attr:	Returned Tx queue attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 			u8 queue, struct dpseci_tx_queue_attr *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	struct dpseci_cmd_queue *cmd_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	struct dpseci_rsp_get_tx_queue *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	cmd_params = (struct dpseci_cmd_queue *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	cmd_params->queue = queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	rsp_params = (struct dpseci_rsp_get_tx_queue *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	attr->fqid = le32_to_cpu(rsp_params->fqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	attr->priority = rsp_params->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)  * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)  * @attr:	Returned SEC attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			struct dpseci_sec_attr *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	struct dpseci_rsp_get_sec_attr *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 					  cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 					  token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	rsp_params = (struct dpseci_rsp_get_sec_attr *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	attr->ip_id = le16_to_cpu(rsp_params->ip_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	attr->major_rev = rsp_params->major_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	attr->minor_rev = rsp_params->minor_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	attr->era = rsp_params->era;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	attr->deco_num = rsp_params->deco_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	attr->zuc_auth_acc_num = rsp_params->zuc_auth_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	attr->zuc_enc_acc_num = rsp_params->zuc_enc_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	attr->snow_f8_acc_num = rsp_params->snow_f8_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	attr->snow_f9_acc_num = rsp_params->snow_f9_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	attr->crc_acc_num = rsp_params->crc_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	attr->pk_acc_num = rsp_params->pk_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	attr->kasumi_acc_num = rsp_params->kasumi_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	attr->rng_acc_num = rsp_params->rng_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	attr->md_acc_num = rsp_params->md_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	attr->arc4_acc_num = rsp_params->arc4_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	attr->des_acc_num = rsp_params->des_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	attr->aes_acc_num = rsp_params->aes_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	attr->ccha_acc_num = rsp_params->ccha_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	attr->ptha_acc_num = rsp_params->ptha_acc_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * dpseci_get_api_version() - Get Data Path SEC Interface API version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  * @major_ver:	Major version of data path sec API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  * @minor_ver:	Minor version of data path sec API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 			   u16 *major_ver, u16 *minor_ver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	struct dpseci_rsp_get_api_version *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 					  cmd_flags, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	rsp_params = (struct dpseci_rsp_get_api_version *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	*major_ver = le16_to_cpu(rsp_params->major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	*minor_ver = le16_to_cpu(rsp_params->minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  * dpseci_set_congestion_notification() - Set congestion group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  *	notification configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  * @cfg:	congestion notification configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	u16 token, const struct dpseci_congestion_notification_cfg *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	struct dpseci_cmd_congestion_notification *cmd_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	cmd.header = mc_encode_cmd_header(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			DPSECI_CMDID_SET_CONGESTION_NOTIFICATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	cmd_params = (struct dpseci_cmd_congestion_notification *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	cmd_params->notification_mode = cpu_to_le16(cfg->notification_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	cmd_params->priority = cfg->dest_cfg.priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	dpseci_set_field(cmd_params->options, CGN_DEST_TYPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			 cfg->dest_cfg.dest_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	dpseci_set_field(cmd_params->options, CGN_UNITS, cfg->units);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	cmd_params->message_iova = cpu_to_le64(cfg->message_iova);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	cmd_params->threshold_entry = cpu_to_le32(cfg->threshold_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	cmd_params->threshold_exit = cpu_to_le32(cfg->threshold_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	return mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * dpseci_get_congestion_notification() - Get congestion group notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  *	configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  * @mc_io:	Pointer to MC portal's I/O object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  * @token:	Token of DPSECI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)  * @cfg:	congestion notification configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)  * Return:	'0' on success, error code otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	u16 token, struct dpseci_congestion_notification_cfg *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	struct fsl_mc_command cmd = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	struct dpseci_cmd_congestion_notification *rsp_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	cmd.header = mc_encode_cmd_header(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			DPSECI_CMDID_GET_CONGESTION_NOTIFICATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 			token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	err = mc_send_command(mc_io, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	rsp_params = (struct dpseci_cmd_congestion_notification *)cmd.params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	cfg->dest_cfg.priority = rsp_params->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	cfg->dest_cfg.dest_type = dpseci_get_field(rsp_params->options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 						   CGN_DEST_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	cfg->units = dpseci_get_field(rsp_params->options, CGN_UNITS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	cfg->message_iova = le64_to_cpu(rsp_params->message_iova);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }