[PATCH 0/8] net: fsl-mc: sync to latest MC APIs

This patch set syncs all the MC APIs to their latest form using packed structures to ilustrate each field and its endianness. No change in the minimum MC version or the command's version is made.
The first patch removes any unused API so that we do not carry around useless code.
Ioana Ciornei (8): net: fsl-mc: remove unused MC APIs net: fsl-mc: sync DPBP MC APIs net: fsl-mc: sync DPMAC MC APIs net: fsl-mc: sync DPRC MC APIs net: fsl-mc: sync DPNI MC APIs net: fsl-mc: sync DPSPARSER MC APIs net: fsl-mc: sync DPIO MC APIs net: fsl-mc: sync remaining MC commands
drivers/net/fsl-mc/dpbp.c | 180 +++- drivers/net/fsl-mc/dpio/dpio.c | 194 ++-- drivers/net/fsl-mc/dpmac.c | 274 +++-- drivers/net/fsl-mc/dpmng.c | 20 +- drivers/net/fsl-mc/dpni.c | 680 +++++++++---- drivers/net/fsl-mc/dprc.c | 405 ++++---- drivers/net/fsl-mc/dpsparser.c | 124 ++- drivers/net/fsl-mc/fsl_dpmng_cmd.h | 17 +- drivers/net/fsl-mc/mc.c | 14 +- drivers/net/fsl-mc/mc_sys.c | 13 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 22 +- include/fsl-mc/fsl_dpbp.h | 207 +--- include/fsl-mc/fsl_dpio.h | 266 ++--- include/fsl-mc/fsl_dpmac.h | 360 ++----- include/fsl-mc/fsl_dpmng.h | 13 +- include/fsl-mc/fsl_dpni.h | 1529 ++++++++++------------------ include/fsl-mc/fsl_dprc.h | 935 ++--------------- include/fsl-mc/fsl_dpsparser.h | 139 +-- include/fsl-mc/fsl_mc_cmd.h | 47 +- 19 files changed, 2050 insertions(+), 3389 deletions(-)

There are multiple MC APIs which were added years ago but they are not used at all in the u-boot source code. Remove all these APIs.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpio/dpio.c | 15 - drivers/net/fsl-mc/dpmac.c | 89 ------ drivers/net/fsl-mc/dpni.c | 100 ------- drivers/net/fsl-mc/dprc.c | 173 ----------- include/fsl-mc/fsl_dpbp.h | 14 - include/fsl-mc/fsl_dpio.h | 13 - include/fsl-mc/fsl_dpmac.h | 120 -------- include/fsl-mc/fsl_dpni.h | 434 ---------------------------- include/fsl-mc/fsl_dprc.h | 513 --------------------------------- 9 files changed, 1471 deletions(-)
diff --git a/drivers/net/fsl-mc/dpio/dpio.c b/drivers/net/fsl-mc/dpio/dpio.c index 8884455963de..30ecc9124b27 100644 --- a/drivers/net/fsl-mc/dpio/dpio.c +++ b/drivers/net/fsl-mc/dpio/dpio.c @@ -123,21 +123,6 @@ int dpio_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpio_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET, - cmd_flags, - token); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - int dpio_get_attributes(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, diff --git a/drivers/net/fsl-mc/dpmac.c b/drivers/net/fsl-mc/dpmac.c index 43a2ff43f888..f6def987c10b 100644 --- a/drivers/net/fsl-mc/dpmac.c +++ b/drivers/net/fsl-mc/dpmac.c @@ -95,95 +95,6 @@ int dpmac_destroy(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpmac_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_attr *attr) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_ATTR, - cmd_flags, - token); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPMAC_RSP_GET_ATTRIBUTES(cmd, attr); - - return 0; -} - -int dpmac_mdio_read(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_mdio_cfg *cfg) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_READ, - cmd_flags, - token); - DPMAC_CMD_MDIO_READ(cmd, cfg); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPMAC_RSP_MDIO_READ(cmd, cfg->data); - - return 0; -} - -int dpmac_mdio_write(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_mdio_cfg *cfg) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_WRITE, - cmd_flags, - token); - DPMAC_CMD_MDIO_WRITE(cmd, cfg); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - -int dpmac_get_link_cfg(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_link_cfg *cfg) -{ - struct mc_command cmd = { 0 }; - int err = 0; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_LINK_CFG, - cmd_flags, - token); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - DPMAC_RSP_GET_LINK_CFG(cmd, cfg); - - return 0; -} - int dpmac_set_link_state(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, diff --git a/drivers/net/fsl-mc/dpni.c b/drivers/net/fsl-mc/dpni.c index a31abbff71b9..d0596a8e38d9 100644 --- a/drivers/net/fsl-mc/dpni.c +++ b/drivers/net/fsl-mc/dpni.c @@ -18,16 +18,6 @@ int dpni_prepare_cfg(const struct dpni_cfg *cfg, return 0; }
-int dpni_extract_cfg(struct dpni_cfg *cfg, - const uint8_t *cfg_buf) -{ - uint64_t *params = (uint64_t *)cfg_buf; - - DPNI_EXT_CFG(params, cfg); - - return 0; -} - int dpni_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpni_id, @@ -198,23 +188,6 @@ int dpni_get_attributes(struct fsl_mc_io *mc_io, return 0; }
-int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_error_cfg *cfg) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR, - cmd_flags, - token); - DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -322,48 +295,6 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io, return 0; }
- -int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC, - cmd_flags, - token); - DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - -int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t mac_addr[6]) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC, - cmd_flags, - token); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr); - - return 0; -} - int dpni_add_mac_addr(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, @@ -381,23 +312,6 @@ int dpni_add_mac_addr(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR, - cmd_flags, - token); - DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - int dpni_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 *major_ver, @@ -511,17 +425,3 @@ int dpni_get_statistics(struct fsl_mc_io *mc_io,
return 0; } - -int dpni_reset_statistics(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET_STATISTICS, - cmd_flags, token); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} diff --git a/drivers/net/fsl-mc/dprc.c b/drivers/net/fsl-mc/dprc.c index e0a2865ab8f5..2be56e24a186 100644 --- a/drivers/net/fsl-mc/dprc.c +++ b/drivers/net/fsl-mc/dprc.c @@ -117,179 +117,6 @@ int dprc_destroy_container(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dprc_reset_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int child_container_id) -{ - struct mc_command cmd = { 0 }; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT, - cmd_flags, - token); - DPRC_CMD_RESET_CONTAINER(cmd, child_container_id); - - /* send command to mc*/ - return mc_send_command(mc_io, &cmd); -} - -int dprc_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dprc_attributes *attr) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_ATTR, - cmd_flags, - token); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_ATTRIBUTES(cmd, attr); - - return 0; -} - -int dprc_get_obj_count(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *obj_count) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT, - cmd_flags, - token); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_OBJ_COUNT(cmd, *obj_count); - - return 0; -} - -int dprc_get_obj(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int obj_index, - struct dprc_obj_desc *obj_desc) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ, - cmd_flags, - token); - DPRC_CMD_GET_OBJ(cmd, obj_index); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_OBJ(cmd, obj_desc); - - return 0; -} - -int dprc_get_res_count(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *type, - int *res_count) -{ - struct mc_command cmd = { 0 }; - int err; - - *res_count = 0; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT, - cmd_flags, - token); - DPRC_CMD_GET_RES_COUNT(cmd, type); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_RES_COUNT(cmd, *res_count); - - return 0; -} - -int dprc_get_res_ids(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *type, - struct dprc_res_ids_range_desc *range_desc) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS, - cmd_flags, - token); - DPRC_CMD_GET_RES_IDS(cmd, range_desc, type); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_RES_IDS(cmd, range_desc); - - return 0; -} - -int dprc_get_obj_region(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *obj_type, - int obj_id, - uint8_t region_index, - struct dprc_region_desc *region_desc) -{ - struct mc_command cmd = { 0 }; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG, - cmd_flags, - token); - DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - DPRC_RSP_GET_OBJ_REGION(cmd, region_desc); - - return 0; -} - int dprc_connect(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, diff --git a/include/fsl-mc/fsl_dpbp.h b/include/fsl-mc/fsl_dpbp.h index 2278ac952ea9..477a08ef268f 100644 --- a/include/fsl-mc/fsl_dpbp.h +++ b/include/fsl-mc/fsl_dpbp.h @@ -155,20 +155,6 @@ int dpbp_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token);
-/** - * dpbp_is_enabled() - Check if the DPBP is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); - /** * dpbp_reset() - Reset the DPBP, returns the object to initial state. * @mc_io: Pointer to MC portal's I/O object diff --git a/include/fsl-mc/fsl_dpio.h b/include/fsl-mc/fsl_dpio.h index 7788e1962e64..9d52a8e42f87 100644 --- a/include/fsl-mc/fsl_dpio.h +++ b/include/fsl-mc/fsl_dpio.h @@ -21,7 +21,6 @@ #define DPIO_CMDID_ENABLE 0x0021 #define DPIO_CMDID_DISABLE 0x0031 #define DPIO_CMDID_GET_ATTR 0x0041 -#define DPIO_CMDID_RESET 0x0051
/* cmd, param, offset, width, type, arg_name */ #define DPIO_CMD_OPEN(cmd, dpio_id) \ @@ -177,18 +176,6 @@ int dpio_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token);
-/** - * dpio_reset() - Reset the DPIO, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); - /** * struct dpio_attr - Structure representing DPIO attributes * @id: DPIO object ID diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h index 1fa26ef3805a..eebfe548cc6e 100644 --- a/include/fsl-mc/fsl_dpmac.h +++ b/include/fsl-mc/fsl_dpmac.h @@ -21,12 +21,8 @@ #define DPMAC_CMDID_DESTROY 0x98c1 #define DPMAC_CMDID_GET_API_VERSION 0xa0c1
-#define DPMAC_CMDID_GET_ATTR 0x0041 #define DPMAC_CMDID_RESET 0x0051
-#define DPMAC_CMDID_MDIO_READ 0x0c01 -#define DPMAC_CMDID_MDIO_WRITE 0x0c11 -#define DPMAC_CMDID_GET_LINK_CFG 0x0c21 #define DPMAC_CMDID_SET_LINK_STATE 0x0c31 #define DPMAC_CMDID_GET_COUNTER 0x0c41
@@ -38,42 +34,6 @@ #define DPMAC_CMD_OPEN(cmd, dpmac_id) \ MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id)
-/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->phy_id);\ - MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ - MC_RSP_OP(cmd, 1, 32, 8, enum dpmac_link_type, attr->link_type);\ - MC_RSP_OP(cmd, 1, 40, 8, enum dpmac_eth_if, attr->eth_if);\ - MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->max_rate);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_MDIO_READ(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_RSP_MDIO_READ(cmd, data) \ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, data) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_MDIO_WRITE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \ - MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->data); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_RSP_GET_LINK_CFG(cmd, cfg) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \ -} while (0) - /* cmd, param, offset, width, type, arg_name */ #define DPMAC_CMD_SET_LINK_STATE(cmd, cfg) \ do { \ @@ -251,62 +211,6 @@ struct dpmac_attr { uint32_t max_rate; };
-/** - * dpmac_get_attributes - Retrieve DPMAC attributes. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_attr *attr); - -/** - * struct dpmac_mdio_cfg - DPMAC MDIO read/write parameters - * @phy_addr: MDIO device address - * @reg: Address of the register within the Clause 45 PHY device from which data - * is to be read - * @data: Data read/write from/to MDIO - */ -struct dpmac_mdio_cfg { - uint8_t phy_addr; - uint8_t reg; - uint16_t data; -}; - -/** - * dpmac_mdio_read() - Perform MDIO read transaction - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @cfg: Structure with MDIO transaction parameters - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_mdio_read(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_mdio_cfg *cfg); - -/** - * dpmac_mdio_write() - Perform MDIO write transaction - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @cfg: Structure with MDIO transaction parameters - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_mdio_write(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_mdio_cfg *cfg); - /* DPMAC link configuration/state options */
/* Enable auto-negotiation */ @@ -318,30 +222,6 @@ int dpmac_mdio_write(struct fsl_mc_io *mc_io, /* Enable a-symmetric pause frames */ #define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
-/** - * struct dpmac_link_cfg - Structure representing DPMAC link configuration - * @rate: Link's rate - in Mbps - * @options: Enable/Disable DPMAC link cfg features (bitmap) - */ -struct dpmac_link_cfg { - uint32_t rate; - uint64_t options; -}; - -/** - * dpmac_get_link_cfg() - Get Ethernet link configuration - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @cfg: Returned structure with the link configuration - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_get_link_cfg(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_link_cfg *cfg); - /** * struct dpmac_link_state - DPMAC link configuration request * @rate: Rate in Mbps diff --git a/include/fsl-mc/fsl_dpni.h b/include/fsl-mc/fsl_dpni.h index fc57c375ac14..fa15a141f1fb 100644 --- a/include/fsl-mc/fsl_dpni.h +++ b/include/fsl-mc/fsl_dpni.h @@ -24,21 +24,15 @@
#define DPNI_CMDID_SET_POOLS 0x2002 #define DPNI_CMDID_SET_BUFFER_LAYOUT 0x2651 -#define DPNI_CMDID_GET_BUFFER_LAYOUT 0x2641 -#define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B1
#define DPNI_CMDID_GET_QDID 0x2101 #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x2121 #define DPNI_CMDID_GET_LINK_STATE 0x2151 #define DPNI_CMDID_SET_LINK_CFG 0x21A1
-#define DPNI_CMDID_SET_PRIM_MAC 0x2241 -#define DPNI_CMDID_GET_PRIM_MAC 0x2251 #define DPNI_CMDID_ADD_MAC_ADDR 0x2261 -#define DPNI_CMDID_REMOVE_MAC_ADDR 0x2271
#define DPNI_CMDID_GET_STATISTICS 0x25D1 -#define DPNI_CMDID_RESET_STATISTICS 0x25E1 #define DPNI_CMDID_GET_QUEUE 0x25F1 #define DPNI_CMDID_SET_QUEUE 0x2601 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE 0x2661 @@ -59,18 +53,6 @@ do { \ MC_PREP_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \ } while (0)
-/* cmd, param, offset, width, type, arg_name */ -#define DPNI_EXT_CFG(param, cfg) \ -do { \ - MC_EXT_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \ - MC_EXT_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \ - MC_EXT_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \ - MC_EXT_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \ - MC_EXT_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \ - MC_EXT_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \ - MC_EXT_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \ -} while (0) - /* cmd, param, offset, width, type, arg_name */ #define DPNI_CMD_CREATE(cmd, cfg) \ do { \ @@ -128,14 +110,6 @@ do { \ MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->wriop_version); \ } while (0)
-/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \ - MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \ - MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \ -} while (0) - /* cmd, param, offset, width, type, arg_name */ #define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, queue) \ do { \ @@ -173,28 +147,6 @@ do { \ MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\ } while (0)
-/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - /* cmd, param, offset, width, type, arg_name */ #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \ do { \ @@ -206,17 +158,6 @@ do { \ MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ } while (0)
-/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - #define DPNI_CMD_GET_QUEUE(cmd, type, tc, index) \ do { \ MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \ @@ -267,60 +208,6 @@ do { \ MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->raw.counter[6]); \ } while (0)
-enum net_prot { - NET_PROT_NONE = 0, - NET_PROT_PAYLOAD, - NET_PROT_ETH, - NET_PROT_VLAN, - NET_PROT_IPV4, - NET_PROT_IPV6, - NET_PROT_IP, - NET_PROT_TCP, - NET_PROT_UDP, - NET_PROT_UDP_LITE, - NET_PROT_IPHC, - NET_PROT_SCTP, - NET_PROT_SCTP_CHUNK_DATA, - NET_PROT_PPPOE, - NET_PROT_PPP, - NET_PROT_PPPMUX, - NET_PROT_PPPMUX_SUBFRM, - NET_PROT_L2TPV2, - NET_PROT_L2TPV3_CTRL, - NET_PROT_L2TPV3_SESS, - NET_PROT_LLC, - NET_PROT_LLC_SNAP, - NET_PROT_NLPID, - NET_PROT_SNAP, - NET_PROT_MPLS, - NET_PROT_IPSEC_AH, - NET_PROT_IPSEC_ESP, - NET_PROT_UDP_ENC_ESP, /* RFC 3948 */ - NET_PROT_MACSEC, - NET_PROT_GRE, - NET_PROT_MINENCAP, - NET_PROT_DCCP, - NET_PROT_ICMP, - NET_PROT_IGMP, - NET_PROT_ARP, - NET_PROT_CAPWAP_DATA, - NET_PROT_CAPWAP_CTRL, - NET_PROT_RFC2684, - NET_PROT_ICMPV6, - NET_PROT_FCOE, - NET_PROT_FIP, - NET_PROT_ISCSI, - NET_PROT_GTP, - NET_PROT_USER_DEFINED_L2, - NET_PROT_USER_DEFINED_L3, - NET_PROT_USER_DEFINED_L4, - NET_PROT_USER_DEFINED_L5, - NET_PROT_USER_DEFINED_SHIM1, - NET_PROT_USER_DEFINED_SHIM2, - - NET_PROT_DUMMY_LAST -}; - /** * Data Path Network Interface API * Contains initialization APIs and runtime control APIs for DPNI @@ -455,46 +342,6 @@ struct dpni_cfg { } adv; };
-/** - * struct dpni_extended_cfg - Structure representing extended DPNI configuration - * @tc_cfg: TCs configuration - * @ipr_cfg: IP reassembly configuration - */ -struct dpni_extended_cfg { - /** - * struct tc_cfg - TC configuration - * @max_dist: Maximum distribution size for Rx traffic class; - * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96, - * 112,128,192,224,256,384,448,512,768,896,1024; - * value '0' will be treated as '1'. - * other unsupported values will be round down to the nearest - * supported value. - * @max_fs_entries: Maximum FS entries for Rx traffic class; - * '0' means no support for this TC; - */ - struct { - uint16_t max_dist; - uint16_t max_fs_entries; - } tc_cfg[DPNI_MAX_TC]; - /** - * struct ipr_cfg - Structure representing IP reassembly configuration - * @max_reass_frm_size: Maximum size of the reassembled frame - * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments - * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments - * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly - * process - * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly - * process - */ - struct { - uint16_t max_reass_frm_size; - uint16_t min_frag_size_ipv4; - uint16_t min_frag_size_ipv6; - uint16_t max_open_frames_ipv4; - uint16_t max_open_frames_ipv6; - } ipr_cfg; -}; - /** * dpni_prepare_cfg() - function prepare parameters * @cfg: cfg structure @@ -666,87 +513,6 @@ int dpni_get_attributes(struct fsl_mc_io *mc_io, uint16_t token, struct dpni_attr *attr);
-/** - * dpni_extract_cfg() - extract the parameters - * @cfg: cfg structure - * @cfg_buf: 256 bytes of DMA-able memory - * - * This function has to be called after dpni_get_attributes() - */ -int dpni_extract_cfg(struct dpni_cfg *cfg, - const uint8_t *cfg_buf); - -/** - * DPNI errors - */ - -/** - * Extract out of frame header error - */ -#define DPNI_ERROR_EOFHE 0x00020000 -/** - * Frame length error - */ -#define DPNI_ERROR_FLE 0x00002000 -/** - * Frame physical error - */ -#define DPNI_ERROR_FPE 0x00001000 -/** - * Parsing header error - */ -#define DPNI_ERROR_PHE 0x00000020 -/** - * Parser L3 checksum error - */ -#define DPNI_ERROR_L3CE 0x00000004 -/** - * Parser L3 checksum error - */ -#define DPNI_ERROR_L4CE 0x00000001 - -/** - * enum dpni_error_action - Defines DPNI behavior for errors - * @DPNI_ERROR_ACTION_DISCARD: Discard the frame - * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow - * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue - */ -enum dpni_error_action { - DPNI_ERROR_ACTION_DISCARD = 0, - DPNI_ERROR_ACTION_CONTINUE = 1, - DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2 -}; - -/** - * struct dpni_error_cfg - Structure representing DPNI errors treatment - * @errors: Errors mask; use 'DPNI_ERROR__<X> - * @error_action: The desired action for the errors mask - * @set_frame_annotation: Set to '1' to mark the errors in frame annotation - * status (FAS); relevant only for the non-discard action - */ -struct dpni_error_cfg { - uint32_t errors; - enum dpni_error_action error_action; - int set_frame_annotation; -}; - -/** - * dpni_set_errors_behavior() - Set errors behavior - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Errors configuration - * - * this function may be called numerous times with different - * error masks - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_error_cfg *cfg); - /* DPNI buffer layout modification options */
/* Select to modify the time-stamp setting */ @@ -787,22 +553,6 @@ struct dpni_buffer_layout { uint16_t data_tail_room; };
-/** - * dpni_get_buffer_layout() - Retrieve buffer layout attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @layout: Returns buffer layout attributes - * @type: DPNI queue type - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_buffer_layout(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_buffer_layout *layout, - enum dpni_queue_type type); - /** * dpni_set_buffer_layout() - Set buffer layout configuration. * @mc_io: Pointer to MC portal's I/O object @@ -910,34 +660,6 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io, uint16_t token, struct dpni_link_state *state);
-/** - * dpni_set_primary_mac_addr() - Set the primary MAC address - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to set as primary address - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); - -/** - * dpni_get_primary_mac_addr() - Get the primary MAC address - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: Returned MAC address - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t mac_addr[6]); - /** * dpni_add_mac_addr() - Add MAC address filter * @mc_io: Pointer to MC portal's I/O object @@ -952,20 +674,6 @@ int dpni_add_mac_addr(struct fsl_mc_io *mc_io, uint16_t token, const uint8_t mac_addr[6]);
-/** - * dpni_remove_mac_addr() - Remove MAC address filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to remove - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); - /** * enum dpni_dest - DPNI destination types * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and @@ -985,137 +693,6 @@ enum dpni_dest { DPNI_DEST_DPCON = 2 };
-/** - * struct dpni_dest_cfg - Structure representing DPNI destination parameters - * @dest_type: Destination type - * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type - * @priority: Priority selection within the DPIO or DPCON channel; valid values - * are 0-1 or 0-7, depending on the number of priorities in that - * channel; not relevant for 'DPNI_DEST_NONE' option - */ -struct dpni_dest_cfg { - enum dpni_dest dest_type; - int dest_id; - uint8_t priority; -}; - -/** - * enum dpni_flc_type - DPNI FLC types - * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value - * @DPNI_FLC_STASH: select the FLC to be used for stash control - */ -enum dpni_flc_type { - DPNI_FLC_USER_DEFINED = 0, - DPNI_FLC_STASH = 1, -}; - -/** - * enum dpni_stash_size - DPNI FLC stashing size - * @DPNI_STASH_SIZE_0B: no stash - * @DPNI_STASH_SIZE_64B: stashes 64 bytes - * @DPNI_STASH_SIZE_128B: stashes 128 bytes - * @DPNI_STASH_SIZE_192B: stashes 192 bytes - */ -enum dpni_stash_size { - DPNI_STASH_SIZE_0B = 0, - DPNI_STASH_SIZE_64B = 1, - DPNI_STASH_SIZE_128B = 2, - DPNI_STASH_SIZE_192B = 3, -}; - -/* DPNI FLC stash options */ - -/* stashes the whole annotation area (up to 192 bytes) */ -#define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001 - -/** - * struct dpni_flc_cfg - Structure representing DPNI FLC configuration - * @flc_type: FLC type - * @options: Mask of available options; - * use 'DPNI_FLC_STASH_<X>' values - * @frame_data_size: Size of frame data to be stashed - * @flow_context_size: Size of flow context to be stashed - * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED': - * this value will be provided in the frame descriptor - * (FD[FLC]) - * 2. In case flc_type is 'DPNI_FLC_STASH': - * this value will be I/O virtual address of the - * flow-context; - * Must be cacheline-aligned and DMA-able memory - */ -struct dpni_flc_cfg { - enum dpni_flc_type flc_type; - uint32_t options; - enum dpni_stash_size frame_data_size; - enum dpni_stash_size flow_context_size; - uint64_t flow_context; -}; - -/* DPNI queue modification options */ - -/* Select to modify the user's context associated with the queue */ -#define DPNI_QUEUE_OPT_USER_CTX 0x00000001 -/* Select to modify the queue's destination */ -#define DPNI_QUEUE_OPT_DEST 0x00000002 -/** Select to modify the flow-context parameters; - * not applicable for Tx-conf/Err queues as the FD comes from the user - */ -#define DPNI_QUEUE_OPT_FLC 0x00000004 -/* Select to modify the queue's order preservation */ -#define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008 -/* Select to modify the queue's tail-drop threshold */ -#define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010 - -/** - * struct dpni_queue_cfg - Structure representing queue configuration - * @options: Flags representing the suggested modifications to the queue; - * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags - * @user_ctx: User context value provided in the frame descriptor of each - * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX' - * is contained in 'options' - * @dest_cfg: Queue destination parameters; - * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options' - * @flc_cfg: Flow context configuration; in case the TC's distribution - * is either NONE or HASH the FLC's settings of flow#0 are used. - * in the case of FS (flow-steering) the flow's FLC settings - * are used. - * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options' - * @order_preservation_en: enable/disable order preservation; - * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained - * in 'options' - * @tail_drop_threshold: set the queue's tail drop threshold in bytes; - * '0' value disable the threshold; maximum value is 0xE000000; - * valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained - * in 'options' - */ -struct dpni_queue_cfg { - uint32_t options; - uint64_t user_ctx; - struct dpni_dest_cfg dest_cfg; - struct dpni_flc_cfg flc_cfg; - int order_preservation_en; - uint32_t tail_drop_threshold; -}; - -/** - * struct dpni_queue_attr - Structure representing queue attributes - * @user_ctx: User context value provided in the frame descriptor of each - * dequeued frame - * @dest_cfg: Queue destination configuration - * @flc_cfg: Flow context configuration - * @order_preservation_en: enable/disable order preservation - * @tail_drop_threshold: queue's tail drop threshold in bytes; - * @fqid: Virtual fqid value to be used for dequeue operations - */ -struct dpni_queue_attr { - uint64_t user_ctx; - struct dpni_dest_cfg dest_cfg; - struct dpni_flc_cfg flc_cfg; - int order_preservation_en; - uint32_t tail_drop_threshold; - uint32_t fqid; -}; - /* DPNI Tx flow modification options */
/* Select to modify the settings for dedicate Tx confirmation/error */ @@ -1371,15 +948,4 @@ int dpni_get_statistics(struct fsl_mc_io *mc_io, uint8_t page, union dpni_statistics *stat);
-/** - * dpni_reset_statistics() - Clears DPNI statistics - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_reset_statistics(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); #endif /* _FSL_DPNI_H */ diff --git a/include/fsl-mc/fsl_dprc.h b/include/fsl-mc/fsl_dprc.h index 950ecb075698..0b95a06a911c 100644 --- a/include/fsl-mc/fsl_dprc.h +++ b/include/fsl-mc/fsl_dprc.h @@ -15,20 +15,12 @@ /* Command IDs */ #define DPRC_CMDID_CLOSE 0x8001 #define DPRC_CMDID_OPEN 0x8051 -#define DPRC_CMDID_CREATE 0x9051
-#define DPRC_CMDID_GET_ATTR 0x0041 -#define DPRC_CMDID_RESET_CONT 0x0051 #define DPRC_CMDID_GET_API_VERSION 0xa051
#define DPRC_CMDID_CREATE_CONT 0x1511 #define DPRC_CMDID_DESTROY_CONT 0x1521 #define DPRC_CMDID_GET_CONT_ID 0x8301 -#define DPRC_CMDID_GET_OBJ_COUNT 0x1591 -#define DPRC_CMDID_GET_OBJ 0x15A1 -#define DPRC_CMDID_GET_RES_COUNT 0x15B1 -#define DPRC_CMDID_GET_RES_IDS 0x15C1 -#define DPRC_CMDID_GET_OBJ_REG 0x15E1
#define DPRC_CMDID_CONNECT 0x1671 #define DPRC_CMDID_DISCONNECT 0x1681 @@ -77,268 +69,6 @@ do { \ #define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \ MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
-/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \ - MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\ - MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \ - MC_RSP_OP(cmd, 0, 32, 32, int, obj_count) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_OBJ(cmd, obj_index) \ - MC_CMD_OP(cmd, 0, 0, 32, int, obj_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_OBJ(cmd, obj_desc) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \ - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \ - MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \ - MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \ - MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\ - MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\ - MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\ - MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \ - MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\ - MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\ - MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\ - MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\ - MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\ - MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\ - MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\ - MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\ - MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\ - MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\ - MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\ - MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\ - MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\ - MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\ - MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\ - MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\ - MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\ - MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\ - MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\ - MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\ - MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\ - MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\ - MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\ - MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\ - MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\ - MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\ - MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\ - MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\ - MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\ - MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\ - MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\ - MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, obj_id);\ - MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\ - MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\ - MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\ - MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\ - MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\ - MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\ - MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\ - MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\ - MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\ - MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\ - MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\ - MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\ - MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\ - MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\ - MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\ - MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \ - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \ - MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \ - MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \ - MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\ - MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\ - MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\ - MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \ - MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\ - MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\ - MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\ - MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\ - MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\ - MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\ - MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\ - MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\ - MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\ - MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\ - MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\ - MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\ - MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\ - MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\ - MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\ - MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\ - MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\ - MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\ - MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\ - MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\ - MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\ - MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\ - MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\ - MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\ - MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\ - MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\ - MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\ - MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\ - MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\ - MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\ - MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\ - MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_RES_COUNT(cmd, type) \ -do { \ - MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\ - MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\ - MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\ - MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\ - MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\ - MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\ - MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\ - MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\ - MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\ - MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\ - MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\ - MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\ - MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\ - MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\ - MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\ - MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \ - MC_RSP_OP(cmd, 0, 0, 32, int, res_count) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \ -do { \ - MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ - range_desc->iter_status); \ - MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ - MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ - MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\ - MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\ - MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\ - MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\ - MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\ - MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\ - MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\ - MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\ - MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\ - MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\ - MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\ - MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\ - MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\ - MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\ - MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\ - MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \ -do { \ - MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ - range_desc->iter_status);\ - MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ - MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\ - MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\ - MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\ - MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\ - MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\ - MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\ - MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\ - MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\ - MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\ - MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\ - MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\ - MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\ - MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\ - MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\ - MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\ - MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\ - MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\ -} while (0) - -/* param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \ -do { \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\ - MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \ - MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\ - MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \ - MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\ - MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\ - MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\ - MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\ - MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\ - MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\ - MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\ - MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\ - MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\ - MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\ - MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\ - MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\ - MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\ - MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\ - MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\ - MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\ - MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\ - MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\ - MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\ - MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\ - MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\ - MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\ - MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\ - MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\ - MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\ - MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\ - MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\ - MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\ - MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\ - MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\ - MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\ - MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\ -} while (0) - /* cmd, param, offset, width, type, arg_name */ #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \ do { \ @@ -615,249 +345,6 @@ int dprc_destroy_container(struct fsl_mc_io *mc_io, uint16_t token, int child_container_id);
-/** - * dprc_reset_container - Reset child container. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @child_container_id: ID of the container to reset - * - * In case a software context crashes or becomes non-responsive, the parent - * may wish to reset its resources container before the software context is - * restarted. - * - * This routine informs all objects assigned to the child container that the - * container is being reset, so they may perform any cleanup operations that are - * needed. All objects handles that were owned by the child container shall be - * closed. - * - * Note that such request may be submitted even if the child software context - * has not crashed, but the resulting object cleanup operations will not be - * aware of that. - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_reset_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int child_container_id); - -/** - * struct dprc_attributes - Container attributes - * @container_id: Container's ID - * @icid: Container's ICID - * @portal_id: Container's portal ID - * @options: Container's options as set at container's creation - * @version: DPRC version - */ -struct dprc_attributes { - int container_id; - uint16_t icid; - int portal_id; - uint64_t options; -}; - -/** - * dprc_get_attributes() - Obtains container attributes - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @attributes: Returned container attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dprc_attributes *attributes); - -/** - * dprc_get_obj_count() - Obtains the number of objects in the DPRC - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @obj_count: Number of objects assigned to the DPRC - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_obj_count(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *obj_count); - -/* Objects Attributes Flags */ - -/* Opened state - Indicates that an object is open by at least one owner */ -#define DPRC_OBJ_STATE_OPEN 0x00000001 -/* Plugged state - Indicates that the object is plugged */ -#define DPRC_OBJ_STATE_PLUGGED 0x00000002 - -/** - * Shareability flag - Object flag indicating no memory shareability. - * the object generates memory accesses that are non coherent with other - * masters; - * user is responsible for proper memory handling through IOMMU configuration. - */ -#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001 - -/** - * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj() - * @type: Type of object: NULL terminated string - * @id: ID of logical object resource - * @vendor: Object vendor identifier - * @ver_major: Major version number - * @ver_minor: Minor version number - * @irq_count: Number of interrupts supported by the object - * @region_count: Number of mappable regions supported by the object - * @state: Object state: combination of DPRC_OBJ_STATE_ states - * @label: Object label - * @flags: Object's flags - */ -struct dprc_obj_desc { - char type[16]; - int id; - uint16_t vendor; - uint16_t ver_major; - uint16_t ver_minor; - uint8_t irq_count; - uint8_t region_count; - uint32_t state; - char label[16]; - uint16_t flags; -}; - -/** - * dprc_get_obj() - Get general information on an object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @obj_index: Index of the object to be queried (< obj_count) - * @obj_desc: Returns the requested object descriptor - * - * The object descriptors are retrieved one by one by incrementing - * obj_index up to (not including) the value of obj_count returned - * from dprc_get_obj_count(). dprc_get_obj_count() must - * be called prior to dprc_get_obj(). - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_obj(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int obj_index, - struct dprc_obj_desc *obj_desc); - -/** - * dprc_get_res_count() - Obtains the number of free resources that are - * assigned to this container, by pool type - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @type: pool type - * @res_count: Returned number of free resources of the given - * resource type that are assigned to this DPRC - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_res_count(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *type, - int *res_count); - -/** - * enum dprc_iter_status - Iteration status - * @DPRC_ITER_STATUS_FIRST: Perform first iteration - * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed - * @DPRC_ITER_STATUS_LAST: Indicates last iteration - */ -enum dprc_iter_status { - DPRC_ITER_STATUS_FIRST = 0, - DPRC_ITER_STATUS_MORE = 1, - DPRC_ITER_STATUS_LAST = 2 -}; - -/** - * struct dprc_res_ids_range_desc - Resource ID range descriptor - * @base_id: Base resource ID of this range - * @last_id: Last resource ID of this range - * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at - * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE, - * additional iterations are needed, until the returned marker is - * DPRC_ITER_STATUS_LAST - */ -struct dprc_res_ids_range_desc { - int base_id; - int last_id; - enum dprc_iter_status iter_status; -}; - -/** - * dprc_get_res_ids() - Obtains IDs of free resources in the container - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @type: pool type - * @range_desc: range descriptor - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_res_ids(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *type, - struct dprc_res_ids_range_desc *range_desc); - -/* Region flags */ -/* Cacheable - Indicates that region should be mapped as cacheable */ -#define DPRC_REGION_CACHEABLE 0x00000001 - -/** - * enum dprc_region_type - Region type - * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region - * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region - */ -enum dprc_region_type { - DPRC_REGION_TYPE_MC_PORTAL, - DPRC_REGION_TYPE_QBMAN_PORTAL -}; - -/** - * struct dprc_region_desc - Mappable region descriptor - * @base_offset: Region offset from region's base address. - * For DPMCP and DPRC objects, region base is offset from SoC MC portals - * base address; For DPIO, region base is offset from SoC QMan portals - * base address - * @size: Region size (in bytes) - * @flags: Region attributes - * @type: Portal region type - */ -struct dprc_region_desc { - uint32_t base_offset; - uint32_t size; - uint32_t flags; - enum dprc_region_type type; -}; - -/** - * dprc_get_obj_region() - Get region information for a specified object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @obj_type: Object type as returned in dprc_get_obj() - * @obj_id: Unique object instance as returned in dprc_get_obj() - * @region_index: The specific region to query - * @region_desc: Returns the requested region descriptor - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_obj_region(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - char *obj_type, - int obj_id, - uint8_t region_index, - struct dprc_region_desc *region_desc); /** * struct dprc_endpoint - Endpoint description for link connect/disconnect * operations

Sync the Data Path Buffer Pool APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpbp.c | 180 +++++++++++++++++++++++---------- include/fsl-mc/fsl_dpbp.h | 193 +++++++----------------------------- include/fsl-mc/fsl_mc_cmd.h | 24 +++++ 3 files changed, 188 insertions(+), 209 deletions(-)
diff --git a/drivers/net/fsl-mc/dpbp.c b/drivers/net/fsl-mc/dpbp.c index c609efb9abcc..5e17ccf73d38 100644 --- a/drivers/net/fsl-mc/dpbp.c +++ b/drivers/net/fsl-mc/dpbp.c @@ -3,25 +3,40 @@ * Freescale Layerscape MC I/O wrapper * * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2023 NXP */ #include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpbp.h>
-int dpbp_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpbp_id, - uint16_t *token) +/** + * dpbp_open() - Open a control session for the specified object. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpbp_id: DPBP unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpbp_create function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpbp_id, u16 *token) { + struct dpbp_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN, - cmd_flags, - 0); - DPBP_CMD_OPEN(cmd, dpbp_id); + cmd_flags, 0); + cmd_params = (struct dpbp_cmd_open *)cmd.params; + cmd_params->dpbp_id = cpu_to_le32(dpbp_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -29,14 +44,23 @@ int dpbp_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return err; }
-int dpbp_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpbp_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -48,11 +72,26 @@ int dpbp_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpbp_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpbp_cfg *cfg, - uint32_t *obj_id) +/** + * dpbp_create() - Create the DPBP object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id; use in subsequent API calls + * + * Create the DPBP object, allocate required resources and + * perform required initialization. + * + * This function accepts an authentication token of a parent + * container that this object should be assigned to and returns + * an object id. This object_id will be used in all subsequent calls to + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpbp_cfg *cfg, u32 *obj_id) { struct mc_command cmd = { 0 }; int err; @@ -61,8 +100,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE, - cmd_flags, - dprc_token); + cmd_flags, dprc_token);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -70,33 +108,46 @@ int dpbp_create(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - MC_CMD_READ_OBJ_ID(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd);
return 0; }
-int dpbp_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t obj_id) +/** + * dpbp_destroy() - Destroy the DPBP object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @obj_id: ID of DPBP object + * + * Return: '0' on Success; error code otherwise. + */ +int dpbp_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 obj_id) { + struct dpbp_cmd_destroy *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY, - cmd_flags, - dprc_token); + cmd_flags, dprc_token);
- /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); + cmd_params = (struct dpbp_cmd_destroy *)cmd.params; + cmd_params->object_id = cpu_to_le32(obj_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpbp_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpbp_enable() - Enable the DPBP. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -108,48 +159,66 @@ int dpbp_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpbp_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpbp_disable() - Disable the DPBP. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE, - cmd_flags, - token); + cmd_flags, token);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpbp_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpbp_reset() - Reset the DPBP, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET, - cmd_flags, - token); + cmd_flags, token);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpbp_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpbp_get_attributes - Retrieve DPBP attributes. + * + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * @attr: Returned object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, struct dpbp_attr *attr) { + struct dpbp_rsp_get_attributes *rsp_params; struct mc_command cmd = { 0 }; int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR, - cmd_flags, - token); + cmd_flags, token);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -157,15 +226,24 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPBP_RSP_GET_ATTRIBUTES(cmd, attr); + rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params; + attr->bpid = le16_to_cpu(rsp_params->bpid); + attr->id = le32_to_cpu(rsp_params->id);
return 0; }
-int dpbp_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dpbp_get_api_version - Get Data Path Buffer Pool API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Buffer Pool API + * @minor_ver: Minor version of Buffer Pool API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err; diff --git a/include/fsl-mc/fsl_dpbp.h b/include/fsl-mc/fsl_dpbp.h index 477a08ef268f..3f3e6c40707c 100644 --- a/include/fsl-mc/fsl_dpbp.h +++ b/include/fsl-mc/fsl_dpbp.h @@ -1,14 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* * Freescale Layerscape MC I/O wrapper + * Data Path Buffer Pool API + * Contains initialization APIs and runtime control APIs for DPBP * * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP - */ -/*! - * @file fsl_dpbp.h - * @brief Data Path Buffer Pool API + * Copyright 2017-2023 NXP */ + #ifndef __FSL_DPBP_H #define __FSL_DPBP_H
@@ -27,146 +26,50 @@ #define DPBP_CMDID_DISABLE 0x0031 #define DPBP_CMDID_GET_ATTR 0x0041 #define DPBP_CMDID_RESET 0x0051 -#define DPBP_CMDID_IS_ENABLED 0x0061
-/* cmd, param, offset, width, type, arg_name */ -#define DPBP_CMD_OPEN(cmd, dpbp_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id) +#pragma pack(push, 1)
-/* cmd, param, offset, width, type, arg_name */ -#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \ - MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ -} while (0) +struct dpbp_cmd_open { + __le32 dpbp_id; +};
-/* Data Path Buffer Pool API - * Contains initialization APIs and runtime control APIs for DPBP - */ +struct dpbp_cmd_destroy { + __le32 object_id; +}; + +struct dpbp_rsp_get_attributes { + __le16 pad; + __le16 bpid; + __le32 id; +}; + +#pragma pack(pop)
struct fsl_mc_io;
-/** - * dpbp_open() - Open a control session for the specified object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpbp_id: DPBP unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpbp_create function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpbp_id, - uint16_t *token); +int dpbp_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpbp_id, u16 *token);
-/** - * dpbp_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * struct dpbp_cfg - Structure representing DPBP configuration * @options: place holder */ struct dpbp_cfg { - uint32_t options; + u32 options; };
-/** - * dpbp_create() - Create the DPBP object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @token: Returned token; use in subsequent API calls - * - * Create the DPBP object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent calls to - * this specific object. For objects that are created using the - * DPL file, call dpbp_open function to get an authentication - * token first. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpbp_cfg *cfg, - uint32_t *obj_id); +int dpbp_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpbp_cfg *cfg, u32 *obj_id);
-/** - * dpbp_destroy() - Destroy the DPBP object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; error code otherwise. - */ -int dpbp_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t obj_id); +int dpbp_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 obj_id);
-/** - * dpbp_enable() - Enable the DPBP. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
-/** - * dpbp_disable() - Disable the DPBP. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); - -/** - * dpbp_reset() - Reset the DPBP, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
+int dpbp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * struct dpbp_attr - Structure representing DPBP attributes @@ -176,40 +79,14 @@ int dpbp_reset(struct fsl_mc_io *mc_io, * acquire/release operations on buffers */ struct dpbp_attr { - uint32_t id; - uint16_t bpid; + u32 id; + u16 bpid; };
-/** - * dpbp_get_attributes - Retrieve DPBP attributes. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpbp_attr *attr); - -/** - * dpbp_get_api_version - Retrieve DPBP Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPBP major version - * @minor_ver: DPBP minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver); +int dpbp_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dpbp_attr *attr);
-/** @} */ +int dpbp_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver);
#endif /* __FSL_DPBP_H */ diff --git a/include/fsl-mc/fsl_mc_cmd.h b/include/fsl-mc/fsl_mc_cmd.h index 591cda968515..6fe5fa4eddaf 100644 --- a/include/fsl-mc/fsl_mc_cmd.h +++ b/include/fsl-mc/fsl_mc_cmd.h @@ -19,6 +19,15 @@ static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width) return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width)); }
+struct mc_cmd_header { + u8 src_id; + u8 flags_hw; + u8 status; + u8 flags_sw; + __le16 token; + __le16 cmd_id; +}; + struct mc_command { uint64_t header; uint64_t params[MC_CMD_NUM_OF_PARAMS]; @@ -179,4 +188,19 @@ static inline void mc_cmd_read_api_version(struct mc_command *cmd, *minor_ver = le16_to_cpu(rsp_params->minor_ver); }
+static inline uint16_t mc_cmd_hdr_read_token(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + u16 token = le16_to_cpu(hdr->token); + + return token; +} + +static inline uint32_t mc_cmd_read_object_id(struct mc_command *cmd) +{ + struct mc_rsp_create *rsp_params; + + rsp_params = (struct mc_rsp_create *)cmd->params; + return le32_to_cpu(rsp_params->object_id); +} #endif /* __FSL_MC_CMD_H */

Sync the Data Path MAC APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpmac.c | 185 ++++++++++++++++++++-------- include/fsl-mc/fsl_dpmac.h | 240 +++++++++++++------------------------ 2 files changed, 215 insertions(+), 210 deletions(-)
diff --git a/drivers/net/fsl-mc/dpmac.c b/drivers/net/fsl-mc/dpmac.c index f6def987c10b..5d4f6c67fd0b 100644 --- a/drivers/net/fsl-mc/dpmac.c +++ b/drivers/net/fsl-mc/dpmac.c @@ -11,19 +11,33 @@ #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpmac.h>
-int dpmac_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpmac_id, - uint16_t *token) +/** + * dpmac_open() - Open a control session for the specified object. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpmac_id: DPMAC unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpmac_create function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmac_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpmac_id, u16 *token) { + struct dpmac_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err;
/* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_OPEN, - cmd_flags, - 0); - DPMAC_CMD_OPEN(cmd, dpmac_id); + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_OPEN, cmd_flags, 0); + cmd_params = (struct dpmac_cmd_open *)cmd.params; + cmd_params->dpmac_id = cpu_to_le32(dpmac_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -31,39 +45,63 @@ int dpmac_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return err; }
-int dpmac_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpmac_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPMAC object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmac_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
/* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLOSE, cmd_flags, - token); + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLOSE, cmd_flags, token);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpmac_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpmac_cfg *cfg, - uint32_t *obj_id) +/** + * dpmac_create() - Create the DPMAC object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPMAC object, allocate required resources and + * perform required initialization. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmac_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpmac_cfg *cfg, u32 *obj_id) { + struct dpmac_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err;
/* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CREATE, - cmd_flags, - dprc_token); - DPMAC_CMD_CREATE(cmd, cfg); + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CREATE, cmd_flags, dprc_token); + cmd_params = (struct dpmac_cmd_create *)cmd.params; + cmd_params->mac_id = cpu_to_le32(cfg->mac_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -71,53 +109,87 @@ int dpmac_create(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - MC_CMD_READ_OBJ_ID(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd);
return 0; }
-int dpmac_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t obj_id) +/** + * dpmac_destroy() - Destroy the DPMAC object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; error code otherwise. + */ +int dpmac_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id) { + struct dpmac_cmd_destroy *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPMAC_CMDID_DESTROY, cmd_flags, dprc_token); - - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); + cmd_params = (struct dpmac_cmd_destroy *)cmd.params; + cmd_params->dpmac_id = cpu_to_le32(object_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpmac_set_link_state(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpmac_set_link_state() - Set the Ethernet link status + * @mc_io: Pointer to opaque I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPMAC object + * @link_state: Link state configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmac_set_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, struct dpmac_link_state *link_state) { + struct dpmac_cmd_set_link_state *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ - cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_LINK_STATE, - cmd_flags, - token); - DPMAC_CMD_SET_LINK_STATE(cmd, link_state); + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_LINK_STATE, cmd_flags, token); + cmd_params = (struct dpmac_cmd_set_link_state *)cmd.params; + cmd_params->options = cpu_to_le64(link_state->options); + cmd_params->rate = cpu_to_le32(link_state->rate); + cmd_params->up = dpmac_get_field(link_state->up, STATE); + dpmac_set_field(cmd_params->up, STATE_VALID, link_state->state_valid); + cmd_params->supported = cpu_to_le64(link_state->supported); + cmd_params->advertising = cpu_to_le64(link_state->advertising);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpmac_get_counter(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpmac_counter type, - uint64_t *counter) +/** + * dpmac_get_counter() - Read a specific DPMAC counter + * @mc_io: Pointer to opaque I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPMAC object + * @type: The requested counter + * @counter: Returned counter value + * + * Return: The requested counter; '0' otherwise. + */ +int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpmac_counter type, uint64_t *counter) { + struct dpmac_cmd_get_counter *dpmac_cmd; + struct dpmac_rsp_get_counter *dpmac_rsp; struct mc_command cmd = { 0 }; int err = 0;
@@ -125,36 +197,43 @@ int dpmac_get_counter(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_COUNTER, cmd_flags, token); - DPMAC_CMD_GET_COUNTER(cmd, type); + dpmac_cmd = (struct dpmac_cmd_get_counter *)cmd.params; + dpmac_cmd->type = type;
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err;
- DPMAC_RSP_GET_COUNTER(cmd, *counter); + dpmac_rsp = (struct dpmac_rsp_get_counter *)cmd.params; + *counter = le64_to_cpu(dpmac_rsp->counter);
return 0; }
-int dpmac_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dpmac_get_api_version() - Get Data Path MAC version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path mac API + * @minor_ver: Minor version of data path mac API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err;
- /* prepare command */ cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_API_VERSION, - cmd_flags, 0); + cmd_flags, + 0);
- /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err;
- /* retrieve response parameters */ mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0; diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h index eebfe548cc6e..a8e9e4684a51 100644 --- a/include/fsl-mc/fsl_dpmac.h +++ b/include/fsl-mc/fsl_dpmac.h @@ -26,29 +26,54 @@ #define DPMAC_CMDID_SET_LINK_STATE 0x0c31 #define DPMAC_CMDID_GET_COUNTER 0x0c41
-/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_CREATE(cmd, cfg) \ - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->mac_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_OPEN(cmd, dpmac_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_SET_LINK_STATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \ - MC_CMD_OP(cmd, 2, 0, 1, int, cfg->up); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_CMD_GET_COUNTER(cmd, type) \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpmac_counter, type) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMAC_RSP_GET_COUNTER(cmd, counter) \ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter) +/* Macros for accessing command fields smaller than 1byte */ +#define DPMAC_MASK(field) \ + GENMASK(DPMAC_##field##_SHIFT + DPMAC_##field##_SIZE - 1, \ + DPMAC_##field##_SHIFT) +#define dpmac_set_field(var, field, val) \ + ((var) |= (((val) << DPMAC_##field##_SHIFT) & DPMAC_MASK(field))) +#define dpmac_get_field(var, field) \ + (((var) & DPMAC_MASK(field)) >> DPMAC_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpmac_cmd_open { + __le32 dpmac_id; +}; + +struct dpmac_cmd_create { + __le32 mac_id; +}; + +struct dpmac_cmd_destroy { + __le32 dpmac_id; +}; + +#define DPMAC_STATE_SIZE 1 +#define DPMAC_STATE_SHIFT 0 +#define DPMAC_STATE_VALID_SIZE 1 +#define DPMAC_STATE_VALID_SHIFT 1 + +struct dpmac_cmd_set_link_state { + __le64 options; + __le32 rate; + __le32 pad; + /* only least significant bit is valid */ + u8 up; + u8 pad0[7]; + __le64 supported; + __le64 advertising; +}; + +struct dpmac_cmd_get_counter { + u8 type; +}; + +struct dpmac_rsp_get_counter { + __le64 pad; + __le64 counter; +}; + +#pragma pack(pop)
/* Data Path MAC API * Contains initialization APIs and runtime control APIs for DPMAC @@ -56,42 +81,27 @@ do { \
struct fsl_mc_io;
-/** - * dpmac_open() - Open a control session for the specified object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpmac_id: DPMAC unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpmac_create function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpmac_id, - uint16_t *token); +int dpmac_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpmac_id, u16 *token); + +int dpmac_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** - * dpmac_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. + * struct dpmac_cfg - Structure representing DPMAC configuration + * @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP, + * the MAC IDs are continuous. + * For example: 2 WRIOPs, 16 MACs in each: + * MAC IDs for the 1st WRIOP: 1-16, + * MAC IDs for the 2nd WRIOP: 17-32. */ -int dpmac_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +struct dpmac_cfg { + int mac_id; +}; + +int dpmac_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpmac_cfg *cfg, u32 *obj_id); + +int dpmac_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id);
/** * enum dpmac_link_type - DPMAC link type @@ -131,60 +141,6 @@ enum dpmac_eth_if { DPMAC_ETH_IF_XFI };
-/** - * struct dpmac_cfg - Structure representing DPMAC configuration - * @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP, - * the MAC IDs are continuous. - * For example: 2 WRIOPs, 16 MACs in each: - * MAC IDs for the 1st WRIOP: 1-16, - * MAC IDs for the 2nd WRIOP: 17-32. - */ -struct dpmac_cfg { - int mac_id; -}; - -/** - * dpmac_create() - Create the DPMAC object. - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: Returned obj_id; use in subsequent API calls - * - * Create the DPMAC object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent calls to - * this specific object. For objects that are created using the - * DPL file, call dpmac_open function to get an authentication - * token first. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_create(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - const struct dpmac_cfg *cfg, - uint32_t *obj_id); - -/** - * dpmac_destroy() - Destroy the DPMAC object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @obj_id: DPMAC object id - * - * Return: '0' on Success; error code otherwise. - */ -int dpmac_destroy(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - uint32_t obj_id); - /* DPMAC IRQ Index and Events */
/* IRQ index */ @@ -208,7 +164,7 @@ struct dpmac_attr { int phy_id; enum dpmac_link_type link_type; enum dpmac_eth_if eth_if; - uint32_t max_rate; + u32 max_rate; };
/* DPMAC link configuration/state options */ @@ -227,27 +183,21 @@ struct dpmac_attr { * @rate: Rate in Mbps * @options: Enable/Disable DPMAC link cfg features (bitmap) * @up: Link state + * @state_valid: Ignore/Update the state of the link + * @supported: Speeds capability of the phy (bitmap) + * @advertising: Speeds that are advertised for autoneg (bitmap) */ struct dpmac_link_state { - uint32_t rate; - uint64_t options; - int up; + u32 rate; + u64 options; + int up; + int state_valid; + u64 supported; + u64 advertising; };
-/** - * dpmac_set_link_state() - Set the Ethernet link status - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @link_state: Link state configuration - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_set_link_state(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpmac_link_state *link_state); - +int dpmac_set_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dpmac_link_state *link_state); /** * enum dpni_counter - DPNI counter types * @DPMAC_CNT_ING_FRAME_64: counts 64-octet frame, good or bad. @@ -326,34 +276,10 @@ enum dpmac_counter { DPMAC_CNT_EGR_GOOD_FRAME, };
-/** - * dpmac_get_counter() - Read a specific DPMAC counter - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMAC object - * @type: The requested counter - * @counter: Returned counter value - * - * Return: The requested counter; '0' otherwise. - */ -int dpmac_get_counter(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpmac_counter type, - uint64_t *counter); -/** - * dpmac_get_api_version - Retrieve DPMAC Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPMAC major version - * @minor_ver: DPMAC minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmac_get_api_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver); +int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpmac_counter type, u64 *counter); + +int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver);
#endif /* __FSL_DPMAC_H */

Sync the Data Resource Container APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dprc.c | 232 ++++++++++++++++----- include/fsl-mc/fsl_dprc.h | 424 +++++++++----------------------------- 2 files changed, 280 insertions(+), 376 deletions(-)
diff --git a/drivers/net/fsl-mc/dprc.c b/drivers/net/fsl-mc/dprc.c index 2be56e24a186..d1a74ab47a98 100644 --- a/drivers/net/fsl-mc/dprc.c +++ b/drivers/net/fsl-mc/dprc.c @@ -3,16 +3,22 @@ * Freescale Layerscape MC I/O wrapper * * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */
#include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dprc.h>
-int dprc_get_container_id(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int *container_id) +/** + * dprc_get_container_id - Get container ID associated with a given portal. + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @container_id: Requested container id + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_get_container_id(struct fsl_mc_io *mc_io, u32 cmd_flags, int *container_id) { struct mc_command cmd = { 0 }; int err; @@ -28,23 +34,33 @@ int dprc_get_container_id(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPRC_RSP_GET_CONTAINER_ID(cmd, *container_id); + *container_id = (int)mc_cmd_read_object_id(&cmd);
return 0; }
-int dprc_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int container_id, - uint16_t *token) +/** + * dprc_open() - Open DPRC object for use + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @container_id: Container ID to open + * @token: Returned token of DPRC object + * + * Return: '0' on Success; Error code otherwise. + * + * @warning Required before any operation on the object. + */ +int dprc_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int container_id, u16 *token) { + struct dprc_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, cmd_flags, 0); - DPRC_CMD_OPEN(cmd, container_id); + cmd_params = (struct dprc_cmd_open *)cmd.params; + cmd_params->container_id = cpu_to_le32(container_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -52,14 +68,23 @@ int dprc_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return 0; }
-int dprc_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dprc_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -71,22 +96,35 @@ int dprc_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dprc_create_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dprc_cfg *cfg, - int *child_container_id, - uint64_t *child_portal_paddr) +/** + * dprc_create_container() - Create child container + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @cfg: Child container configuration + * @child_container_id: Returned child container ID + * @child_portal_offset:Returned child portal offset from MC portal base + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_create_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dprc_cfg *cfg, int *child_container_id, + uint64_t *child_portal_offset) { + struct dprc_cmd_create_container *cmd_params; + struct dprc_rsp_create_container *rsp_params; struct mc_command cmd = { 0 }; - int err; + int err, i;
/* prepare command */ - DPRC_CMD_CREATE_CONTAINER(cmd, cfg); - cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT, - cmd_flags, - token); + cmd_flags, token); + cmd_params = (struct dprc_cmd_create_container *)cmd.params; + cmd_params->options = cpu_to_le32(cfg->options); + cmd_params->icid = cpu_to_le32(cfg->icid); + cmd_params->portal_id = cpu_to_le32(cfg->portal_id); + for (i = 0; i < 16; i++) + cmd_params->label[i] = cfg->label[i];
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -94,80 +132,156 @@ int dprc_create_container(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPRC_RSP_CREATE_CONTAINER(cmd, *child_container_id, - *child_portal_paddr); + rsp_params = (struct dprc_rsp_create_container *)cmd.params; + *child_container_id = le32_to_cpu(rsp_params->child_container_id); + *child_portal_offset = le64_to_cpu(rsp_params->child_portal_addr);
return 0; }
-int dprc_destroy_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dprc_destroy_container() - Destroy child container. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @child_container_id: ID of the container to destroy + * + * This function terminates the child container, so following this call the + * child container ID becomes invalid. + * + * Notes: + * - All resources and objects of the destroyed container are returned to the + * parent container or destroyed if were created be the destroyed container. + * - This function destroy all the child containers of the specified + * container prior to destroying the container itself. + * + * warning: Only the parent container is allowed to destroy a child policy + * Container 0 can't be destroyed + * + * Return: '0' on Success; Error code otherwise. + * + */ +int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, int child_container_id) { + struct dprc_cmd_destroy_container *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT, - cmd_flags, - token); - DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id); + cmd_flags, token); + cmd_params = (struct dprc_cmd_destroy_container *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dprc_connect(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dprc_connect() - Connect two endpoints to create a network link between them + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @endpoint1: Endpoint 1 configuration parameters + * @endpoint2: Endpoint 2 configuration parameters + * @cfg: Connection configuration. The connection configuration + * is ignored for connections made to DPMAC objects, where + * rate is retrieved from the MAC configuration. + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dprc_endpoint *endpoint1, const struct dprc_endpoint *endpoint2, const struct dprc_connection_cfg *cfg) { + struct dprc_cmd_connect *cmd_params; struct mc_command cmd = { 0 }; + int i;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT, cmd_flags, token); - DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg); + cmd_params = (struct dprc_cmd_connect *)cmd.params; + cmd_params->ep1_id = cpu_to_le32(endpoint1->id); + cmd_params->ep1_interface_id = cpu_to_le16(endpoint1->if_id); + cmd_params->ep2_id = cpu_to_le32(endpoint2->id); + cmd_params->ep2_interface_id = cpu_to_le16(endpoint2->if_id); + cmd_params->max_rate = cpu_to_le32(cfg->max_rate); + cmd_params->committed_rate = cpu_to_le32(cfg->committed_rate); + for (i = 0; i < 16; i++) { + cmd_params->ep1_type[i] = endpoint1->type[i]; + cmd_params->ep2_type[i] = endpoint2->type[i]; + }
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dprc_disconnect(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dprc_disconnect() - Disconnect one endpoint to remove its network connection + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @endpoint: Endpoint configuration parameters + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dprc_endpoint *endpoint) { + struct dprc_cmd_disconnect *cmd_params; struct mc_command cmd = { 0 }; + int i;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT, cmd_flags, token); - DPRC_CMD_DISCONNECT(cmd, endpoint); + cmd_params = (struct dprc_cmd_disconnect *)cmd.params; + cmd_params->id = cpu_to_le32(endpoint->id); + cmd_params->interface_id = cpu_to_le32(endpoint->if_id); + for (i = 0; i < 16; i++) + cmd_params->type[i] = endpoint->type[i];
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dprc_get_connection(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dprc_get_connection() - Get connected endpoint and link status if connection + * exists. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @endpoint1: Endpoint 1 configuration parameters + * @endpoint2: Returned endpoint 2 configuration parameters + * @state: Returned link state: + * 1 - link is up; + * 0 - link is down; + * -1 - no connection (endpoint2 information is irrelevant) + * + * Return: '0' on Success; -ENAVAIL if connection does not exist. + */ +int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dprc_endpoint *endpoint1, - struct dprc_endpoint *endpoint2, - int *state) + struct dprc_endpoint *endpoint2, int *state) { + struct dprc_cmd_get_connection *cmd_params; + struct dprc_rsp_get_connection *rsp_params; struct mc_command cmd = { 0 }; - int err; + int err, i;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION, cmd_flags, token); - DPRC_CMD_GET_CONNECTION(cmd, endpoint1); + cmd_params = (struct dprc_cmd_get_connection *)cmd.params; + cmd_params->ep1_id = cpu_to_le32(endpoint1->id); + cmd_params->ep1_interface_id = cpu_to_le16(endpoint1->if_id); + for (i = 0; i < 16; i++) + cmd_params->ep1_type[i] = endpoint1->type[i];
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -175,15 +289,27 @@ int dprc_get_connection(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPRC_RSP_GET_CONNECTION(cmd, endpoint2, *state); + rsp_params = (struct dprc_rsp_get_connection *)cmd.params; + endpoint2->id = le32_to_cpu(rsp_params->ep2_id); + endpoint2->if_id = le16_to_cpu(rsp_params->ep2_interface_id); + *state = le32_to_cpu(rsp_params->state); + for (i = 0; i < 16; i++) + endpoint2->type[i] = rsp_params->ep2_type[i];
return 0; }
-int dprc_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dprc_get_api_version - Get Data Path Resource Container API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Data Path Resource Container API + * @minor_ver: Minor version of Data Path Resource Container API + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err; diff --git a/include/fsl-mc/fsl_dprc.h b/include/fsl-mc/fsl_dprc.h index 0b95a06a911c..fb95ac544a02 100644 --- a/include/fsl-mc/fsl_dprc.h +++ b/include/fsl-mc/fsl_dprc.h @@ -3,7 +3,7 @@ * Freescale Layerscape MC I/O wrapper * * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */ #ifndef _FSL_DPRC_H #define _FSL_DPRC_H @@ -26,161 +26,71 @@ #define DPRC_CMDID_DISCONNECT 0x1681 #define DPRC_CMDID_GET_CONNECTION 0x16C1
-/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \ - MC_RSP_OP(cmd, 0, 0, 32, int, container_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_OPEN(cmd, container_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, container_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->icid); \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->options); \ - MC_CMD_OP(cmd, 1, 32, 32, int, cfg->portal_id); \ - MC_CMD_OP(cmd, 2, 0, 8, char, cfg->label[0]);\ - MC_CMD_OP(cmd, 2, 8, 8, char, cfg->label[1]);\ - MC_CMD_OP(cmd, 2, 16, 8, char, cfg->label[2]);\ - MC_CMD_OP(cmd, 2, 24, 8, char, cfg->label[3]);\ - MC_CMD_OP(cmd, 2, 32, 8, char, cfg->label[4]);\ - MC_CMD_OP(cmd, 2, 40, 8, char, cfg->label[5]);\ - MC_CMD_OP(cmd, 2, 48, 8, char, cfg->label[6]);\ - MC_CMD_OP(cmd, 2, 56, 8, char, cfg->label[7]);\ - MC_CMD_OP(cmd, 3, 0, 8, char, cfg->label[8]);\ - MC_CMD_OP(cmd, 3, 8, 8, char, cfg->label[9]);\ - MC_CMD_OP(cmd, 3, 16, 8, char, cfg->label[10]);\ - MC_CMD_OP(cmd, 3, 24, 8, char, cfg->label[11]);\ - MC_CMD_OP(cmd, 3, 32, 8, char, cfg->label[12]);\ - MC_CMD_OP(cmd, 3, 40, 8, char, cfg->label[13]);\ - MC_CMD_OP(cmd, 3, 48, 8, char, cfg->label[14]);\ - MC_CMD_OP(cmd, 3, 56, 8, char, cfg->label[15]);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\ -do { \ - MC_RSP_OP(cmd, 1, 0, 32, int, child_container_id); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, child_portal_offset);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ - MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \ - MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \ - MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->if_id); \ - MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \ - MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \ - MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \ - MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \ - MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \ - MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \ - MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \ - MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \ - MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \ - MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \ - MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \ - MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \ - MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \ - MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \ - MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \ - MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \ - MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \ - MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \ - MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \ - MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \ - MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \ - MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \ - MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \ - MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \ - MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \ - MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \ - MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \ - MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \ - MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \ - MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \ - MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \ - MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \ - MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \ - MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_DISCONNECT(cmd, endpoint) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \ - MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \ - MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \ - MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \ - MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \ - MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \ - MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \ - MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \ - MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \ - MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \ - MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \ - MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \ - MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \ - MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \ - MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \ - MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \ - MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ - MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \ - MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \ - MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \ - MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \ - MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \ - MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \ - MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \ - MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \ - MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \ - MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \ - MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \ - MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \ - MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \ - MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \ - MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \ - MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \ - MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \ -do { \ - MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \ - MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \ - MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \ - MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \ - MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \ - MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \ - MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \ - MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \ - MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \ - MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \ - MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \ - MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \ - MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \ - MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \ - MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \ - MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \ - MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \ - MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \ - MC_RSP_OP(cmd, 6, 0, 32, int, state); \ -} while (0) +#pragma pack(push, 1) +struct dprc_cmd_open { + __le32 container_id; +}; + +struct dprc_cmd_create_container { + __le32 options; + __le32 icid; + __le32 pad1; + __le32 portal_id; + u8 label[16]; +}; + +struct dprc_rsp_create_container { + __le64 pad0; + __le32 child_container_id; + __le32 pad1; + __le64 child_portal_addr; +}; + +struct dprc_cmd_destroy_container { + __le32 child_container_id; +}; + +struct dprc_cmd_connect { + __le32 ep1_id; + __le16 ep1_interface_id; + __le16 pad0; + + __le32 ep2_id; + __le16 ep2_interface_id; + __le16 pad1; + + u8 ep1_type[16]; + + __le32 max_rate; + __le32 committed_rate; + + u8 ep2_type[16]; +}; + +struct dprc_cmd_disconnect { + __le32 id; + __le32 interface_id; + u8 type[16]; +}; + +struct dprc_cmd_get_connection { + __le32 ep1_id; + __le16 ep1_interface_id; + __le16 pad; + + u8 ep1_type[16]; +}; + +struct dprc_rsp_get_connection { + __le64 pad[3]; + __le32 ep2_id; + __le16 ep2_interface_id; + __le16 pad1; + u8 ep2_type[16]; + __le32 state; +}; + +#pragma pack(pop)
/* Data Path Resource Container API * Contains DPRC API for managing and querying DPAA resources @@ -193,7 +103,7 @@ struct fsl_mc_io; * container, in case the ICID is not selected by the user and should be * allocated by the DPRC from the pool of ICIDs. */ -#define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0)) +#define DPRC_GET_ICID_FROM_POOL (u16)(~(0))
/** * Set this value as the portal_id value in dprc_cfg structure when creating a @@ -202,48 +112,11 @@ struct fsl_mc_io; */ #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
-/** - * dprc_get_container_id() - Get container ID associated with a given portal. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @container_id: Requested container ID - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_container_id(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int *container_id); +int dprc_get_container_id(struct fsl_mc_io *mc_io, u32 cmd_flags, int *container_id);
-/** - * dprc_open() - Open DPRC object for use - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @container_id: Container ID to open - * @token: Returned token of DPRC object - * - * Return: '0' on Success; Error code otherwise. - * - * @warning Required before any operation on the object. - */ -int dprc_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int container_id, - uint16_t *token); +int dprc_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int container_id, u16 *token);
-/** - * dprc_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * Container general options @@ -293,71 +166,18 @@ int dprc_close(struct fsl_mc_io *mc_io, * @label: Object's label */ struct dprc_cfg { - uint16_t icid; + u16 icid; int portal_id; uint64_t options; char label[16]; };
-/** - * dprc_create_container() - Create child container - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @cfg: Child container configuration - * @child_container_id: Returned child container ID - * @child_portal_offset: Returned child portal offset from MC portal base - * - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_create_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dprc_cfg *cfg, - int *child_container_id, - uint64_t *child_portal_offset); - -/** - * dprc_destroy_container() - Destroy child container. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @child_container_id: ID of the container to destroy - * - * This function terminates the child container, so following this call the - * child container ID becomes invalid. - * - * Notes: - * - All resources and objects of the destroyed container are returned to the - * parent container or destroyed if were created be the destroyed container. - * - This function destroy all the child containers of the specified - * container prior to destroying the container itself. - * - * warning: Only the parent container is allowed to destroy a child policy - * Container 0 can't be destroyed - * - * Return: '0' on Success; Error code otherwise. - * - */ -int dprc_destroy_container(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int child_container_id); +int dprc_create_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dprc_cfg *cfg, int *child_container_id, + uint64_t *child_portal_offset);
-/** - * struct dprc_endpoint - Endpoint description for link connect/disconnect - * operations - * @type: Endpoint object type: NULL terminated string - * @id: Endpoint object ID - * @if_id: Interface ID; should be set for endpoints with multiple - * interfaces ("dpsw", "dpdmux"); for others, always set to 0 - */ -struct dprc_endpoint { - char type[16]; - int id; - uint16_t if_id; -}; +int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + int child_container_id);
/** * struct dprc_connection_cfg - Connection configuration. @@ -366,79 +186,37 @@ struct dprc_endpoint { * @max_rate: Maximum rate (Mbits/s) */ struct dprc_connection_cfg { - uint32_t committed_rate; - uint32_t max_rate; + u32 committed_rate; + u32 max_rate; };
/** - * dprc_connect() - Connect two endpoints to create a network link between them - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @endpoint1: Endpoint 1 configuration parameters - * @endpoint2: Endpoint 2 configuration parameters - * @cfg: Connection configuration. The connection configuration is ignored for - * connections made to DPMAC objects, where rate is retrieved from the - * MAC configuration. - * - * Return: '0' on Success; Error code otherwise. + * struct dprc_endpoint - Endpoint description for link connect/disconnect + * operations + * @type: Endpoint object type: NULL terminated string + * @id: Endpoint object ID + * @if_id: Interface ID; should be set for endpoints with multiple + * interfaces ("dpsw", "dpdmux"); for others, always set to 0 */ -int dprc_connect(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dprc_endpoint *endpoint1, - const struct dprc_endpoint *endpoint2, - const struct dprc_connection_cfg *cfg); +struct dprc_endpoint { + char type[16]; + int id; + u16 if_id; +};
-/** - * dprc_disconnect() - Disconnect one endpoint to remove its network connection - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPRC object - * @endpoint: Endpoint configuration parameters - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_disconnect(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dprc_endpoint *endpoint); +int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const struct dprc_endpoint *endpoint1, + const struct dprc_endpoint *endpoint2, + const struct dprc_connection_cfg *cfg);
-/** -* dprc_get_connection() - Get connected endpoint and link status if connection -* exists. -* @mc_io: Pointer to MC portal's I/O object -* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' -* @token: Token of DPRC object -* @endpoint1: Endpoint 1 configuration parameters -* @endpoint2: Returned endpoint 2 configuration parameters -* @state: Returned link state: -* 1 - link is up; -* 0 - link is down; -* -1 - no connection (endpoint2 information is irrelevant) -* -* Return: '0' on Success; -ENAVAIL if connection does not exist. -*/ -int dprc_get_connection(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dprc_endpoint *endpoint1, - struct dprc_endpoint *endpoint2, - int *state); +int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const struct dprc_endpoint *endpoint);
-/** - * dprc_get_api_version - Retrieve DPRC Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPRC major version - * @minor_ver: DPRC minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dprc_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver); +int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const struct dprc_endpoint *endpoint1, + struct dprc_endpoint *endpoint2, int *state); + +int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver);
#endif /* _FSL_DPRC_H */

Sync the Data Path Network Interface APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpni.c | 582 +++++++++++---- drivers/net/fsl-mc/mc.c | 14 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 22 +- include/fsl-mc/fsl_dpni.h | 1101 ++++++++++++++--------------- 4 files changed, 990 insertions(+), 729 deletions(-)
diff --git a/drivers/net/fsl-mc/dpni.c b/drivers/net/fsl-mc/dpni.c index d0596a8e38d9..5b815a45a99d 100644 --- a/drivers/net/fsl-mc/dpni.c +++ b/drivers/net/fsl-mc/dpni.c @@ -1,36 +1,43 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */
#include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpni.h>
-int dpni_prepare_cfg(const struct dpni_cfg *cfg, - uint8_t *cfg_buf) -{ - uint64_t *params = (uint64_t *)cfg_buf; - - DPNI_PREP_CFG(params, cfg); - - return 0; -} - -int dpni_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpni_id, - uint16_t *token) +/** + * dpni_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpni_id: DPNI unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpni_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpni_id, u16 *token) { + struct dpni_cmd_open *cmd_params; struct mc_command cmd = { 0 }; + int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN, cmd_flags, 0); - DPNI_CMD_OPEN(cmd, dpni_id); + cmd_params = (struct dpni_cmd_open *)cmd.params; + cmd_params->dpni_id = cpu_to_le32(dpni_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -38,14 +45,23 @@ int dpni_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return 0; }
-int dpni_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpni_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -58,12 +74,32 @@ int dpni_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpni_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpni_cfg *cfg, - uint32_t *obj_id) +/** + * dpni_create() - Create the DPNI object + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPNI object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpni_cfg *cfg, u32 *obj_id) { + struct dpni_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err;
@@ -71,7 +107,19 @@ int dpni_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE, cmd_flags, dprc_token); - DPNI_CMD_CREATE(cmd, cfg); + cmd_params = (struct dpni_cmd_create *)cmd.params; + cmd_params->options = cpu_to_le32(cfg->options); + cmd_params->num_queues = cfg->num_queues; + cmd_params->num_tcs = cfg->num_tcs; + cmd_params->mac_filter_entries = cfg->mac_filter_entries; + cmd_params->num_rx_tcs = cfg->num_rx_tcs; + cmd_params->vlan_filter_entries = cfg->vlan_filter_entries; + cmd_params->qos_entries = cfg->qos_entries; + cmd_params->fs_entries = cpu_to_le16(cfg->fs_entries); + cmd_params->num_cgs = cfg->num_cgs; + cmd_params->num_opr = cfg->num_opr; + cmd_params->dist_key_size = cfg->dist_key_size; + cmd_params->num_channels = cfg->num_channels;
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -79,50 +127,94 @@ int dpni_create(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - MC_CMD_READ_OBJ_ID(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd);
return 0; }
-int dpni_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t obj_id) +/** + * dpni_destroy() - Destroy the DPNI object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; error code otherwise. + */ +int dpni_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id) { + struct dpni_cmd_destroy *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY, cmd_flags, dprc_token); - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); + cmd_params = (struct dpni_cmd_destroy *)cmd.params; + cmd_params->dpni_id = cpu_to_le32(object_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_set_pools(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpni_set_pools() - Set buffer pools configuration + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cfg: Buffer pools configuration + * + * mandatory for DPNI operation + * warning:Allowed only when DPNI is disabled + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dpni_pools_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_pools *cmd_params; + int i;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS, cmd_flags, token); - DPNI_CMD_SET_POOLS(cmd, cfg); + cmd_params = (struct dpni_cmd_set_pools *)cmd.params; + cmd_params->num_dpbp = cfg->num_dpbp; + cmd_params->pool_options = cfg->pool_options; + for (i = 0; i < DPNI_MAX_DPBP; i++) { + cmd_params->pool[i].dpbp_id = + cpu_to_le16(cfg->pools[i].dpbp_id); + cmd_params->pool[i].priority_mask = + cfg->pools[i].priority_mask; + cmd_params->buffer_size[i] = + cpu_to_le16(cfg->pools[i].buffer_size); + cmd_params->backup_pool_mask |= + DPNI_BACKUP_POOL(cfg->pools[i].backup_pool, i); + }
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpni_enable() - Enable the DPNI, allow sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -135,9 +227,15 @@ int dpni_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpni_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpni_disable() - Disable the DPNI, stop sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -150,9 +248,15 @@ int dpni_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpni_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpni_reset() - Reset the DPNI, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -165,59 +269,121 @@ int dpni_reset(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpni_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpni_get_attributes() - Retrieve DPNI attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @attr: Object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, struct dpni_attr *attr) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_attr *rsp_params; + int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR, cmd_flags, token); + /* send command to mc*/ err = mc_send_command(mc_io, &cmd); if (err) return err;
/* retrieve response parameters */ - DPNI_RSP_GET_ATTR(cmd, attr); + rsp_params = (struct dpni_rsp_get_attr *)cmd.params; + attr->options = le32_to_cpu(rsp_params->options); + attr->num_queues = rsp_params->num_queues; + attr->num_rx_tcs = rsp_params->num_rx_tcs; + attr->num_tx_tcs = rsp_params->num_tx_tcs; + attr->mac_filter_entries = rsp_params->mac_filter_entries; + attr->vlan_filter_entries = rsp_params->vlan_filter_entries; + attr->num_channels = rsp_params->num_channels; + attr->qos_entries = rsp_params->qos_entries; + attr->fs_entries = le16_to_cpu(rsp_params->fs_entries); + attr->num_opr = le16_to_cpu(rsp_params->num_opr); + attr->qos_key_size = rsp_params->qos_key_size; + attr->fs_key_size = rsp_params->fs_key_size; + attr->wriop_version = le16_to_cpu(rsp_params->wriop_version); + attr->num_cgs = rsp_params->num_cgs;
return 0; }
-int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_buffer_layout *layout, - enum dpni_queue_type type) +/** + * dpni_set_buffer_layout() - Set buffer layout configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue this configuration applies to + * @layout: Buffer layout configuration + * + * Return: '0' on Success; Error code otherwise. + * + * @warning Allowed only when DPNI is disabled + */ +int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, + const struct dpni_buffer_layout *layout) { + struct dpni_cmd_set_buffer_layout *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT, cmd_flags, token); - DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, type); + cmd_params = (struct dpni_cmd_set_buffer_layout *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->options = cpu_to_le16((u16)layout->options); + dpni_set_field(cmd_params->flags, PASS_TS, layout->pass_timestamp); + dpni_set_field(cmd_params->flags, PASS_PR, layout->pass_parser_result); + dpni_set_field(cmd_params->flags, PASS_FS, layout->pass_frame_status); + dpni_set_field(cmd_params->flags, PASS_SWO, layout->pass_sw_opaque); + cmd_params->private_data_size = cpu_to_le16(layout->private_data_size); + cmd_params->data_align = cpu_to_le16(layout->data_align); + cmd_params->head_room = cpu_to_le16(layout->data_head_room); + cmd_params->tail_room = cpu_to_le16(layout->data_tail_room);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_get_qdid(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t *qdid) +/** + * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used + * for enqueue operations + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue to receive QDID for + * @qdid: Returned virtual QDID value that should be used as an argument + * in all enqueue operations + * + * Return: '0' on Success; Error code otherwise. + * + * If dpni object is created using multiple Tc channels this function will return + * qdid value for the first channel + */ +int dpni_get_qdid(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 *qdid) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_qdid *cmd_params; + struct dpni_rsp_get_qdid *rsp_params; int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID, cmd_flags, token); + cmd_params = (struct dpni_cmd_get_qdid *)cmd.params; + cmd_params->qtype = qtype;
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -225,17 +391,26 @@ int dpni_get_qdid(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPNI_RSP_GET_QDID(cmd, *qdid); + rsp_params = (struct dpni_rsp_get_qdid *)cmd.params; + *qdid = le16_to_cpu(rsp_params->qdid);
return 0; }
-int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t *data_offset) +/** + * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer) + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @data_offset: Tx data offset (from start of buffer) + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 *data_offset) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_tx_data_offset *rsp_params; int err;
/* prepare command */ @@ -249,34 +424,54 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPNI_RSP_GET_TX_DATA_OFFSET(cmd, *data_offset); + rsp_params = (struct dpni_rsp_get_tx_data_offset *)cmd.params; + *data_offset = le16_to_cpu(rsp_params->data_offset);
return 0; }
-int dpni_set_link_cfg(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpni_set_link_cfg() - set the link configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @cfg: Link configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_link_cfg(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dpni_link_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_link_cfg *cmd_params;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG, cmd_flags, token); - DPNI_CMD_SET_LINK_CFG(cmd, cfg); + cmd_params = (struct dpni_cmd_set_link_cfg *)cmd.params; + cmd_params->rate = cpu_to_le32(cfg->rate); + cmd_params->options = cpu_to_le64(cfg->options); + cmd_params->advertising = cpu_to_le64(cfg->advertising);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_get_link_state(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpni_get_link_state() - Return the link state (either up or down) + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @state: Returned link state; + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, struct dpni_link_state *state) { struct mc_command cmd = { 0 }; + struct dpni_rsp_get_link_state *rsp_params; int err;
/* prepare command */ @@ -290,138 +485,279 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPNI_RSP_GET_LINK_STATE(cmd, state); + rsp_params = (struct dpni_rsp_get_link_state *)cmd.params; + state->up = dpni_get_field(rsp_params->flags, LINK_STATE); + state->state_valid = dpni_get_field(rsp_params->flags, STATE_VALID); + state->rate = le32_to_cpu(rsp_params->rate); + state->options = le64_to_cpu(rsp_params->options); + state->supported = le64_to_cpu(rsp_params->supported); + state->advertising = le64_to_cpu(rsp_params->advertising);
return 0; }
-int dpni_add_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]) +/** + * dpni_add_mac_addr() - Add MAC address filter + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @mac_addr: MAC address to add + * @flags :0 - tc_id and flow_id will be ignored. + * Pkt with this mac_id will be passed to the next + * classification stages + * DPNI_MAC_SET_QUEUE_ACTION + * Pkt with this mac will be forward directly to + * queue defined by the tc_id and flow_id + * @tc_id : Traffic class selection (0-7) + * @flow_id : Selects the specific queue out of the set allocated for the + * same as tc_id. Value must be in range 0 to NUM_QUEUES - 1 + * Return: '0' on Success; Error code otherwise. + */ +int dpni_add_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const u8 mac_addr[6], u8 flags, + u8 tc_id, u8 flow_id) { + struct dpni_cmd_add_mac_addr *cmd_params; struct mc_command cmd = { 0 }; + int i;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR, cmd_flags, token); - DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr); + cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params; + cmd_params->flags = flags; + cmd_params->tc_id = tc_id; + cmd_params->fq_id = flow_id; + + for (i = 0; i < 6; i++) + cmd_params->mac_addr[i] = mac_addr[5 - i];
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dpni_get_api_version() - Get Data Path Network Interface API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path network interface API + * @minor_ver: Minor version of data path network interface API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err;
- /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION, - cmd_flags, 0); + cmd_flags, + 0);
- /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err;
- /* retrieve response parameters */ mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0; }
-int dpni_set_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type type, - uint8_t tc, - uint8_t index, - const struct dpni_queue *queue) +/** + * dpni_set_queue() - Set queue parameters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - all queue types are supported, although + * the command is ignored for Tx + * @tc: Traffic class, in range 0 to NUM_TCS - 1 + * @index: Selects the specific queue out of the set allocated for the + * same TC. Value must be in range 0 to NUM_QUEUES - 1 + * @options: A combination of DPNI_QUEUE_OPT_ values that control what + * configuration options are set on the queue + * @queue: Queue structure + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 param, u8 index, + u8 options, const struct dpni_queue *queue) { struct mc_command cmd = { 0 }; + struct dpni_cmd_set_queue *cmd_params; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE, cmd_flags, token); - DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue); + cmd_params = (struct dpni_cmd_set_queue *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = (u8)(param & 0xff); + cmd_params->channel_id = (u8)((param >> 8) & 0xff); + cmd_params->index = index; + cmd_params->options = options; + cmd_params->dest_id = cpu_to_le32(queue->destination.id); + cmd_params->dest_prio = queue->destination.priority; + dpni_set_field(cmd_params->flags, DEST_TYPE, queue->destination.type); + dpni_set_field(cmd_params->flags, STASH_CTRL, queue->flc.stash_control); + dpni_set_field(cmd_params->flags, HOLD_ACTIVE, + queue->destination.hold_active); + cmd_params->flc = cpu_to_le64(queue->flc.value); + cmd_params->user_context = cpu_to_le64(queue->user_context); + cmd_params->cgid = queue->cgid;
- /* send command to mc*/ + /* send command to mc */ return mc_send_command(mc_io, &cmd); }
-int dpni_get_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type type, - uint8_t tc, - uint8_t index, - struct dpni_queue *queue) +/** + * dpni_get_queue() - Get queue parameters + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @qtype: Type of queue - all queue types are supported + * @param: Traffic class and channel ID. + * MSB - channel id; used only for DPNI_QUEUE_TX and + * DPNI_QUEUE_TX_CONFIRM, ignored for the rest + * LSB - traffic class + * Use macro DPNI_BUILD_PARAM() to build correct value. + * If dpni uses a single channel (uses only channel zero) + * the parameter can receive traffic class directly. + * @index: Selects the specific queue out of the set allocated for the + * same TC. Value must be in range 0 to NUM_QUEUES - 1 + * @queue: Queue configuration structure + * @qid: Queue identification + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 param, u8 index, + struct dpni_queue *queue, struct dpni_queue_id *qid) { struct mc_command cmd = { 0 }; + struct dpni_cmd_get_queue *cmd_params; + struct dpni_rsp_get_queue *rsp_params; int err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE, cmd_flags, token); - DPNI_CMD_GET_QUEUE(cmd, type, tc, index); + cmd_params = (struct dpni_cmd_get_queue *)cmd.params; + cmd_params->qtype = qtype; + cmd_params->tc = (u8)(param & 0xff); + cmd_params->index = index; + cmd_params->channel_id = (u8)((param >> 8) & 0xff);
- /* send command to mc*/ + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err;
/* retrieve response parameters */ - DPNI_RSP_GET_QUEUE(cmd, queue); + rsp_params = (struct dpni_rsp_get_queue *)cmd.params; + queue->destination.id = le32_to_cpu(rsp_params->dest_id); + queue->destination.priority = rsp_params->dest_prio; + queue->destination.type = dpni_get_field(rsp_params->flags, DEST_TYPE); + queue->flc.stash_control = dpni_get_field(rsp_params->flags, STASH_CTRL); + queue->destination.hold_active = dpni_get_field(rsp_params->flags, HOLD_ACTIVE); + queue->flc.value = le64_to_cpu(rsp_params->flc); + queue->user_context = le64_to_cpu(rsp_params->user_context); + qid->fqid = le32_to_cpu(rsp_params->fqid); + qid->qdbin = le16_to_cpu(rsp_params->qdbin); + if (dpni_get_field(rsp_params->flags, CGID_VALID)) + queue->cgid = rsp_params->cgid; + else + queue->cgid = -1; + return 0; }
-int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_confirmation_mode mode) +/** + * dpni_set_tx_confirmation_mode() - Tx confirmation mode + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @ceetm_ch_idx: ceetm channel index + * @mode: Tx confirmation mode + * + * This function is useful only when 'DPNI_OPT_TX_CONF_DISABLED' is not + * selected at DPNI creation. + * Calling this function with 'mode' set to DPNI_CONF_DISABLE disables all + * transmit confirmation (including the private confirmation queues), regardless + * of previous settings; Note that in this case, Tx error frames are still + * enqueued to the general transmit errors queue. + * Calling this function with 'mode' set to DPNI_CONF_SINGLE switches all + * Tx confirmations to a shared Tx conf queue. 'index' field in dpni_get_queue + * command will be ignored. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u8 ceetm_ch_idx, enum dpni_confirmation_mode mode) { struct dpni_tx_confirmation_mode *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE, - cmd_flags, - token); - + cmd_flags, token); cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params; + cmd_params->ceetm_ch_idx = ceetm_ch_idx; cmd_params->confirmation_mode = mode;
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpni_get_statistics(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t page, - union dpni_statistics *stat) +/** + * dpni_get_statistics() - Get DPNI statistics + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @page: Selects the statistics page to retrieve, see + * DPNI_GET_STATISTICS output. Pages are numbered 0 to 6. + * @param: Custom parameter for some pages used to select + * a certain statistic source, for example the TC. + * - page_0: not used + * - page_1: not used + * - page_2: not used + * - page_3: high_byte - channel_id, low_byte - traffic class + * - page_4: high_byte - queue_index have meaning only if dpni is + * created using option DPNI_OPT_CUSTOM_CG, low_byte - traffic class + * - page_5: not used + * - page_6: not used + * @stat: Structure containing the statistics + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_statistics(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u8 page, u16 param, union dpni_statistics *stat) { + struct dpni_cmd_get_statistics *cmd_params; + struct dpni_rsp_get_statistics *rsp_params; struct mc_command cmd = { 0 }; - int err; + int i, err;
/* prepare command */ cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS, - cmd_flags, token); - DPNI_CMD_GET_STATISTICS(cmd, page); + cmd_flags, + token); + cmd_params = (struct dpni_cmd_get_statistics *)cmd.params; + cmd_params->page_number = page; + cmd_params->param = param;
- /* send command to mc*/ + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err;
/* retrieve response parameters */ - DPNI_RSP_GET_STATISTICS(cmd, stat); + rsp_params = (struct dpni_rsp_get_statistics *)cmd.params; + for (i = 0; i < DPNI_STATISTICS_CNT; i++) + stat->raw.counter[i] = le64_to_cpu(rsp_params->counter[i]);
return 0; } diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 78a40f285aa2..984616fb65c0 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -1353,10 +1353,9 @@ err:
static int dpni_init(void) { - int err; - uint8_t cfg_buf[256] = {0}; - struct dpni_cfg dpni_cfg; + struct dpni_cfg dpni_cfg = {0}; uint16_t major_ver, minor_ver; + int err;
dflt_dpni = calloc(sizeof(struct fsl_dpni_obj), 1); if (!dflt_dpni) { @@ -1365,14 +1364,6 @@ static int dpni_init(void) goto err_calloc; }
- memset(&dpni_cfg, 0, sizeof(dpni_cfg)); - err = dpni_prepare_cfg(&dpni_cfg, &cfg_buf[0]); - if (err < 0) { - err = -ENODEV; - printf("dpni_prepare_cfg() failed: %d\n", err); - goto err_prepare_cfg; - } - err = dpni_create(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS, @@ -1429,7 +1420,6 @@ err_get_version: MC_CMD_NO_FLAGS, dflt_dpni->dpni_id); err_create: -err_prepare_cfg: free(dflt_dpni); err_calloc: return err; diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index 8c0b5a3b6fd2..87fbada06ba2 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -58,7 +58,7 @@ static void ldpaa_eth_collect_dpni_stats(struct udevice *dev, u64 *data) continue; err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - j, &dpni_stats); + j, 0, &dpni_stats); if (err) { memset(&dpni_stats, 0, sizeof(dpni_stats)); printf("dpni_get_stats(%d) failed\n", j); @@ -378,7 +378,8 @@ static int ldpaa_eth_open(struct udevice *dev) struct dpni_link_state link_state; #endif int err = 0; - struct dpni_queue d_queue; + struct dpni_queue d_queue_cfg = { 0 }; + struct dpni_queue_id d_queue;
if (eth_is_active(dev)) return 0; @@ -422,7 +423,7 @@ static int ldpaa_eth_open(struct udevice *dev) goto err_dpni_bind;
err = dpni_add_mac_addr(dflt_mc_io, MC_CMD_NO_FLAGS, - dflt_dpni->dpni_handle, plat->enetaddr); + dflt_dpni->dpni_handle, plat->enetaddr, 0, 0, 0); if (err) { printf("dpni_add_mac_addr() failed\n"); return err; @@ -461,7 +462,7 @@ static int ldpaa_eth_open(struct udevice *dev) memset(&d_queue, 0, sizeof(struct dpni_queue)); err = dpni_get_queue(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, DPNI_QUEUE_RX, - 0, 0, &d_queue); + 0, 0, &d_queue_cfg, &d_queue); if (err) { printf("dpni_get_queue failed\n"); goto err_get_queue; @@ -470,7 +471,7 @@ static int ldpaa_eth_open(struct udevice *dev) priv->rx_dflt_fqid = d_queue.fqid;
err = dpni_get_qdid(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - &priv->tx_qdid); + DPNI_QUEUE_TX, &priv->tx_qdid); if (err) { printf("dpni_get_qdid() failed\n"); goto err_qdid; @@ -845,7 +846,7 @@ static int ldpaa_dpni_setup(struct ldpaa_eth_priv *priv) /* ...rx, ... */ err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - &dflt_dpni->buf_layout, DPNI_QUEUE_RX); + DPNI_QUEUE_RX, &dflt_dpni->buf_layout); if (err) { printf("dpni_set_buffer_layout() failed"); goto err_buf_layout; @@ -857,7 +858,7 @@ static int ldpaa_dpni_setup(struct ldpaa_eth_priv *priv) DPNI_BUF_LAYOUT_OPT_PARSER_RESULT); err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - &dflt_dpni->buf_layout, DPNI_QUEUE_TX); + DPNI_QUEUE_TX, &dflt_dpni->buf_layout); if (err) { printf("dpni_set_buffer_layout() failed"); goto err_buf_layout; @@ -867,8 +868,7 @@ static int ldpaa_dpni_setup(struct ldpaa_eth_priv *priv) dflt_dpni->buf_layout.options &= ~DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE; err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - &dflt_dpni->buf_layout, - DPNI_QUEUE_TX_CONFIRM); + DPNI_QUEUE_TX_CONFIRM, &dflt_dpni->buf_layout); if (err) { printf("dpni_set_buffer_layout() failed"); goto err_buf_layout; @@ -923,7 +923,7 @@ static int ldpaa_dpni_bind(struct ldpaa_eth_priv *priv)
err = dpni_set_queue(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - DPNI_QUEUE_TX, 0, 0, &tx_queue); + DPNI_QUEUE_TX, 0, 0, 0, &tx_queue);
if (err) { printf("dpni_set_queue() failed\n"); @@ -932,7 +932,7 @@ static int ldpaa_dpni_bind(struct ldpaa_eth_priv *priv)
err = dpni_set_tx_confirmation_mode(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, - DPNI_CONF_DISABLE); + 0, DPNI_CONF_DISABLE); if (err) { printf("dpni_set_tx_confirmation_mode() failed\n"); return err; diff --git a/include/fsl-mc/fsl_dpni.h b/include/fsl-mc/fsl_dpni.h index fa15a141f1fb..9bc475475dfd 100644 --- a/include/fsl-mc/fsl_dpni.h +++ b/include/fsl-mc/fsl_dpni.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */ #ifndef _FSL_DPNI_H #define _FSL_DPNI_H @@ -37,176 +37,229 @@ #define DPNI_CMDID_SET_QUEUE 0x2601 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE 0x2661
-/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_OPEN(cmd, dpni_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_PREP_CFG(param, cfg) \ -do { \ - MC_PREP_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \ - MC_PREP_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \ - MC_PREP_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \ - MC_PREP_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \ - MC_PREP_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \ - MC_PREP_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \ - MC_PREP_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->adv.options); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->adv.num_queues); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->adv.num_tcs); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->adv.mac_entries); \ - MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->adv.vlan_entries); \ - MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->adv.qos_entries); \ - MC_CMD_OP(cmd, 1, 32, 16, uint8_t, cfg->adv.fs_entries); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_POOLS(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \ - MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \ - MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \ - MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \ - MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \ - MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \ - MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \ - MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \ - MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \ - MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \ - MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\ - MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \ - MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\ - MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \ - MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\ - MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \ - MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\ - MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \ - MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\ - MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \ - MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\ - MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \ - MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\ - MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \ - MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->options);\ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_num_queues); \ - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_num_tcs); \ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->max_mac_entries); \ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->max_vlan_entries); \ - MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->max_qos_entries); \ - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fs_entries); \ - MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_qos_key_size); \ - MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_fs_key_size); \ - MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->wriop_version); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, queue) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, queue); \ - MC_CMD_OP(cmd, 1, 0, 16, uint16_t, layout->private_data_size); \ - MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_align); \ - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, layout->options); \ - MC_CMD_OP(cmd, 0, 48, 1, int, layout->pass_timestamp); \ - MC_CMD_OP(cmd, 0, 49, 1, int, layout->pass_parser_result); \ - MC_CMD_OP(cmd, 0, 50, 1, int, layout->pass_frame_status); \ - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_head_room); \ - MC_CMD_OP(cmd, 1, 48, 16, uint16_t, layout->data_tail_room); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_QDID(cmd, qdid) \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\ - MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_LINK_STATE(cmd, state) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ -} while (0) - -#define DPNI_CMD_GET_QUEUE(cmd, type, tc, index) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \ -} while (0) - -#define DPNI_RSP_GET_QUEUE(cmd, queue) \ -do { \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \ - MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \ - MC_RSP_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \ - MC_RSP_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \ - MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (queue)->fqid); \ - MC_RSP_OP(cmd, 4, 32, 16, uint16_t, (queue)->qdbin); \ -} while (0) - -#define DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \ - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \ - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \ - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, (queue)->options); \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \ - MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \ - MC_CMD_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \ - MC_CMD_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \ - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \ - MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \ - MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_CMD_GET_STATISTICS(cmd, page) \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, page) - -/* cmd, param, offset, width, type, arg_name */ -#define DPNI_RSP_GET_STATISTICS(cmd, stat) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->raw.counter[0]); \ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->raw.counter[1]); \ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->raw.counter[2]); \ - MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->raw.counter[3]); \ - MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->raw.counter[4]); \ - MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->raw.counter[5]); \ - MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->raw.counter[6]); \ -} while (0) +/* Macros for accessing command fields smaller than 1byte */ +#define DPNI_MASK(field) \ + GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \ + DPNI_##field##_SHIFT) +#define dpni_set_field(var, field, val) \ + ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field))) +#define dpni_get_field(var, field) \ + (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpni_cmd_open { + __le32 dpni_id; +}; + +struct dpni_cmd_create { + __le32 options; + u8 num_queues; + u8 num_tcs; + u8 mac_filter_entries; + u8 num_channels; + u8 vlan_filter_entries; + u8 pad2; + u8 qos_entries; + u8 pad3; + __le16 fs_entries; + u8 num_rx_tcs; + u8 pad4; + u8 num_cgs; + __le16 num_opr; + u8 dist_key_size; +}; + +struct dpni_cmd_destroy { + __le32 dpni_id; +}; + +#define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order)) + +struct dpni_cmd_pool { + __le16 dpbp_id; + u8 priority_mask; + u8 pad; +}; + +struct dpni_cmd_set_pools { + u8 num_dpbp; + u8 backup_pool_mask; + u8 pad; + u8 pool_options; + struct dpni_cmd_pool pool[8]; + __le16 buffer_size[8]; +}; + +struct dpni_rsp_get_attr { + /* response word 0 */ + __le32 options; + u8 num_queues; + u8 num_rx_tcs; + u8 mac_filter_entries; + u8 num_tx_tcs; + /* response word 1 */ + u8 vlan_filter_entries; + u8 num_channels; + u8 qos_entries; + u8 pad2; + __le16 fs_entries; + __le16 num_opr; + /* response word 2 */ + u8 qos_key_size; + u8 fs_key_size; + __le16 wriop_version; + u8 num_cgs; +}; + +/* There are 3 separate commands for configuring Rx, Tx and Tx confirmation + * buffer layouts, but they all share the same parameters. + * If one of the functions changes, below structure needs to be split. + */ + +#define DPNI_PASS_TS_SHIFT 0 +#define DPNI_PASS_TS_SIZE 1 +#define DPNI_PASS_PR_SHIFT 1 +#define DPNI_PASS_PR_SIZE 1 +#define DPNI_PASS_FS_SHIFT 2 +#define DPNI_PASS_FS_SIZE 1 +#define DPNI_PASS_SWO_SHIFT 3 +#define DPNI_PASS_SWO_SIZE 1 + +struct dpni_cmd_set_buffer_layout { + /* cmd word 0 */ + u8 qtype; + u8 pad0[3]; + __le16 options; + /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */ + u8 flags; + u8 pad1; + /* cmd word 1 */ + __le16 private_data_size; + __le16 data_align; + __le16 head_room; + __le16 tail_room; +}; + +struct dpni_cmd_get_qdid { + u8 qtype; +}; + +struct dpni_rsp_get_qdid { + __le16 qdid; +}; + +struct dpni_rsp_get_tx_data_offset { + __le16 data_offset; +}; + +struct dpni_cmd_set_link_cfg { + __le64 pad0; + __le32 rate; + __le32 pad1; + __le64 options; + __le64 advertising; +}; + +#define DPNI_LINK_STATE_SHIFT 0 +#define DPNI_LINK_STATE_SIZE 1 +#define DPNI_STATE_VALID_SHIFT 1 +#define DPNI_STATE_VALID_SIZE 1 + +struct dpni_rsp_get_link_state { + __le32 pad0; + /* from LSB: up:1 */ + u8 flags; + u8 pad1[3]; + __le32 rate; + __le32 pad2; + __le64 options; + __le64 supported; + __le64 advertising; +}; + +struct dpni_cmd_add_mac_addr { + u8 flags; + u8 pad; + u8 mac_addr[6]; + u8 tc_id; + u8 fq_id; +}; + +struct dpni_cmd_get_queue { + u8 qtype; + u8 tc; + u8 index; + u8 channel_id; +}; + +#define DPNI_DEST_TYPE_SHIFT 0 +#define DPNI_DEST_TYPE_SIZE 4 +#define DPNI_CGID_VALID_SHIFT 5 +#define DPNI_CGID_VALID_SIZE 1 +#define DPNI_STASH_CTRL_SHIFT 6 +#define DPNI_STASH_CTRL_SIZE 1 +#define DPNI_HOLD_ACTIVE_SHIFT 7 +#define DPNI_HOLD_ACTIVE_SIZE 1 + +struct dpni_rsp_get_queue { + /* response word 0 */ + __le64 pad0; + /* response word 1 */ + __le32 dest_id; + __le16 pad1; + u8 dest_prio; + /* From LSB: dest_type:4, pad:1, cgid_valid:1, flc_stash_ctrl:1, hold_active:1 */ + u8 flags; + /* response word 2 */ + __le64 flc; + /* response word 3 */ + __le64 user_context; + /* response word 4 */ + __le32 fqid; + __le16 qdbin; + __le16 pad2; + /* response word 5*/ + u8 cgid; +}; + +struct dpni_cmd_set_queue { + /* cmd word 0 */ + u8 qtype; + u8 tc; + u8 index; + u8 options; + __le32 pad0; + /* cmd word 1 */ + __le32 dest_id; + __le16 pad1; + u8 dest_prio; + u8 flags; + /* cmd word 2 */ + __le64 flc; + /* cmd word 3 */ + __le64 user_context; + /* cmd word 4 */ + u8 cgid; + u8 channel_id; +}; + +struct dpni_tx_confirmation_mode { + u8 ceetm_ch_idx; + u8 pad1; + __le16 pad2; + u8 confirmation_mode; +}; + +struct dpni_cmd_get_statistics { + u8 page_number; + __le16 param; +}; + +struct dpni_rsp_get_statistics { + __le64 counter[7]; +}; + +#pragma pack(pop)
/** * Data Path Network Interface API @@ -223,50 +276,17 @@ struct fsl_mc_io; #define DPNI_MAX_DPBP 8
/* All traffic classes considered; see dpni_set_rx_flow() */ -#define DPNI_ALL_TCS (uint8_t)(-1) +#define DPNI_ALL_TCS (u8)(-1) /* All flows within traffic class considered; see dpni_set_rx_flow() */ -#define DPNI_ALL_TC_FLOWS (uint16_t)(-1) +#define DPNI_ALL_TC_FLOWS (u16)(-1) /* Generate new flow ID; see dpni_set_tx_flow() */ -#define DPNI_NEW_FLOW_ID (uint16_t)(-1) +#define DPNI_NEW_FLOW_ID (u16)(-1) /* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */ -#define DPNI_COMMON_TX_CONF (uint16_t)(-1) +#define DPNI_COMMON_TX_CONF (u16)(-1)
-/** - * dpni_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpni_id: DPNI unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpni_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpni_id, - uint16_t *token); +int dpni_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpni_id, u16 *token);
-/** - * dpni_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/* DPNI configuration options */
@@ -329,17 +349,84 @@ enum dpni_queue_type { DPNI_QUEUE_RX_ERR, };
+/** + * struct dpni_cfg - Structure representing DPNI configuration + * @options: Any combination of the following options: + * DPNI_OPT_TX_FRM_RELEASE + * DPNI_OPT_NO_MAC_FILTER + * DPNI_OPT_HAS_POLICING + * DPNI_OPT_SHARED_CONGESTION + * DPNI_OPT_HAS_KEY_MASKING + * DPNI_OPT_NO_FS + * DPNI_OPT_SINGLE_SENDER + * DPNI_OPT_STASHING_DIS + * @fs_entries: Number of entries in the flow steering table. + * This table is used to select the ingress queue for + * ingress traffic, targeting a GPP core or another. + * In addition it can be used to discard traffic that + * matches the set rule. It is either an exact match table + * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING + * bit in OPTIONS field. This field is ignored if + * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise, + * value 0 defaults to 64. Maximum supported value is 1024. + * Note that the total number of entries is limited on the + * SoC to as low as 512 entries if TCAM is used. + * @vlan_filter_entries: Number of entries in the VLAN address filtering + * table. This is an exact match table used to filter + * ingress traffic based on VLAN IDs. Value 0 disables VLAN + * filtering. Maximum supported value is 16. + * @mac_filter_entries: Number of entries in the MAC address filtering + * table. This is an exact match table and allows both + * unicast and multicast entries. The primary MAC address + * of the network interface is not part of this table, + * this contains only entries in addition to it. This + * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in + * OPTIONS field. Otherwise, value 0 defaults to 80. + * Maximum supported value is 80. + * @num_queues: Number of Tx and Rx queues used for traffic + * distribution. This is orthogonal to QoS and is only + * used to distribute traffic to multiple GPP cores. + * This configuration affects the number of Tx queues + * (logical FQs, all associated with a single CEETM queue), + * Rx queues and Tx confirmation queues, if applicable. + * Value 0 defaults to one queue. Maximum supported value + * is 8. + * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI. + * TCs can have different priority levels for the purpose + * of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different + * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM + * queues for traffic classes (including class queues on + * Tx). Value 0 defaults to one TC. Maximum supported value + * is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx. + * When num_tcs>8 Tx will use this value but Rx will have + * only 8 traffic classes. + * @num_rx_tcs: if set to other value than zero represents number + * of TCs used for Rx. Maximum value is 8. If set to zero the + * number of Rx TCs will be initialized with the value provided + * in num_tcs parameter. + * @qos_entries: Number of entries in the QoS classification table. This + * table is used to select the TC for ingress traffic. It + * is either an exact match or a TCAM table, depending on + * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This + * field is ignored if the DPNI has a single TC. Otherwise, + * a value of 0 defaults to 64. Maximum supported value + * is 64. + * @num_channels: Number of egress channels used by this dpni object. If + * set to zero the dpni object will use a single CEETM channel. + */ struct dpni_cfg { - uint8_t mac_addr[6]; - struct { - uint32_t options; - uint16_t fs_entries; - uint8_t num_queues; - uint8_t num_tcs; - uint8_t mac_entries; - uint8_t vlan_entries; - uint8_t qos_entries; - } adv; + u32 options; + u16 fs_entries; + u8 vlan_filter_entries; + u8 mac_filter_entries; + u8 num_queues; + u8 num_tcs; + u8 num_rx_tcs; + u8 qos_entries; + u8 num_cgs; + u16 num_opr; + u8 dist_key_size; + u8 num_channels; };
/** @@ -350,168 +437,108 @@ struct dpni_cfg { * This function has to be called before dpni_create() */ int dpni_prepare_cfg(const struct dpni_cfg *cfg, - uint8_t *cfg_buf); -/** - * dpni_create() - Create the DPNI object - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: Returned obj_id; use in subsequent API calls - * - * Create the DPNI object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent calls to - * this specific object. For objects that are created using the - * DPL file, call dpni_open() function to get an authentication - * token first. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_create(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - const struct dpni_cfg *cfg, - uint32_t *obj_id); + u8 *cfg_buf);
-/** - * dpni_destroy() - Destroy the DPNI object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @obj_id: Returned obj_id; use in subsequent API calls - * - * Return: '0' on Success; error code otherwise. - */ -int dpni_destroy(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - uint32_t obj_id); +int dpni_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpni_cfg *cfg, u32 *obj_id); + +int dpni_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id);
/** * struct dpni_pools_cfg - Structure representing buffer pools configuration - * @num_dpbp: Number of DPBPs - * @pools: Array of buffer pools parameters; The number of valid entries - * must match 'num_dpbp' value + * @num_dpbp: Number of DPBPs + * @pool_options: Buffer assignment options + * This field is a combination of DPNI_POOL_ASSOC_flags + * @pools: Array of buffer pools parameters; The number of valid entries + * must match 'num_dpbp' value + * @pools.dpbp_id: DPBP object ID + * @pools.priority: Priority mask that indicates TC's used with this buffer. + * I set to 0x00 MC will assume value 0xff. + * @pools.buffer_size: Buffer size + * @pools.backup_pool: Backup pool */ + +#define DPNI_POOL_ASSOC_QPRI 0 +#define DPNI_POOL_ASSOC_QDBIN 1 + struct dpni_pools_cfg { - uint8_t num_dpbp; - /** - * struct pools - Buffer pools parameters - * @dpbp_id: DPBP object ID - * @buffer_size: Buffer size - * @backup_pool: Backup pool - */ + u8 num_dpbp; + u8 pool_options; struct { int dpbp_id; - uint16_t buffer_size; + u8 priority_mask; + u16 buffer_size; int backup_pool; } pools[DPNI_MAX_DPBP]; };
-/** - * dpni_set_pools() - Set buffer pools configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Buffer pools configuration - * - * mandatory for DPNI operation - * warning:Allowed only when DPNI is disabled - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_pools(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_pools_cfg *cfg); - -/** - * dpni_enable() - Enable the DPNI, allow sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const struct dpni_pools_cfg *cfg);
-/** - * dpni_disable() - Disable the DPNI, stop sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
+int dpni_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
-/** - * dpni_reset() - Reset the DPNI, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpni_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * struct dpni_attr - Structure representing DPNI attributes - * @options: Mask of available options; reflects the value as was given in - * object's creation - * @max_num_queues: Number of queues available (for both Tx and Rx) - * @max_num_tcs: Maximum number of traffic classes (for both Tx and Rx) - * @max_mac_entries: Maximum number of traffic classes (for both Tx and Rx) - * @max_unicast_filters: Maximum number of unicast filters - * @max_multicast_filters: Maximum number of multicast filters - * @max_vlan_entries: Maximum number of VLAN filters - * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table - * @max_fs_entries: declares the maximum entries in flow steering table - * @max_qos_key_size: Maximum key size for the QoS look-up - * @max_fs_key_size: Maximum key size for the flow steering - * @wriop_version: Indicates revision of WRIOP hardware block + * @options: Any combination of the following options: + * DPNI_OPT_TX_FRM_RELEASE + * DPNI_OPT_NO_MAC_FILTER + * DPNI_OPT_HAS_POLICING + * DPNI_OPT_SHARED_CONGESTION + * DPNI_OPT_HAS_KEY_MASKING + * DPNI_OPT_NO_FS + * DPNI_OPT_STASHING_DIS + * @num_queues: Number of Tx and Rx queues used for traffic distribution. + * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI. + * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI. + * @mac_filter_entries: Number of entries in the MAC address filtering + * table. + * @vlan_filter_entries: Number of entries in the VLAN address filtering + * table. + * @qos_entries: Number of entries in the QoS classification table. + * @fs_entries: Number of entries in the flow steering table. + * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger + * than this when adding QoS entries will result + * in an error. + * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a + * key larger than this when composing the hash + FS key + * will result in an error. + * @wriop_version: Version of WRIOP HW block. + * The 3 version values are stored on 6, 5, 5 bits + * respectively. + * Values returned: + * - 0x400 - WRIOP version 1.0.0, used on LS2080 and + * variants, + * - 0x421 - WRIOP version 1.1.1, used on LS2088 and + * variants, + * - 0x422 - WRIOP version 1.1.2, used on LS1088 and + * variants. + * - 0xC00 - WRIOP version 3.0.0, used on LX2160 and + * variants. */ struct dpni_attr { - uint32_t id; - uint32_t options; - uint8_t max_num_queues; - uint8_t max_num_tcs; - uint8_t max_mac_entries; - uint8_t max_vlan_entries; - uint8_t max_qos_entries; - uint16_t max_fs_entries; - uint8_t max_qos_key_size; - uint8_t max_fs_key_size; - uint16_t wriop_version; + u32 options; + u8 num_queues; + u8 num_rx_tcs; + u8 num_tx_tcs; + u8 mac_filter_entries; + u8 vlan_filter_entries; + u8 qos_entries; + u16 fs_entries; + u16 num_opr; + u8 qos_key_size; + u8 fs_key_size; + u16 wriop_version; + u8 num_cgs; + u8 num_channels; };
-/** - * dpni_get_attributes() - Retrieve DPNI attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @attr: Object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_attr *attr); +int dpni_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dpni_attr *attr);
/* DPNI buffer layout modification options */
@@ -529,77 +556,45 @@ int dpni_get_attributes(struct fsl_mc_io *mc_io, #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020 /*!< Select to modify the data-tail-room setting */ #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040 +/* Select to modify the sw-opaque value setting */ +#define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE 0x00000080 +/* Select to disable Scatter Gather and use single buffer */ +#define DPNI_BUF_LAYOUT_OPT_NO_SG 0x00000100
/** * struct dpni_buffer_layout - Structure representing DPNI buffer layout - * @options: Flags representing the suggested modifications to the buffer - * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags - * @pass_timestamp: Pass timestamp value - * @pass_parser_result: Pass parser results - * @pass_frame_status: Pass frame status - * @private_data_size: Size kept for private data (in bytes) - * @data_align: Data alignment - * @data_head_room: Data head room - * @data_tail_room: Data tail room + * @options: Flags representing the suggested modifications to the + * buffer layout; + * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags + * @pass_timestamp: Pass timestamp value + * @pass_parser_result: Pass parser results + * @pass_frame_status: Pass frame status + * @private_data_size: Size kept for private data (in bytes) + * @data_align: Data alignment + * @data_head_room: Data head room + * @data_tail_room: Data tail room */ struct dpni_buffer_layout { - uint16_t options; + u32 options; int pass_timestamp; int pass_parser_result; int pass_frame_status; - uint16_t private_data_size; - uint16_t data_align; - uint16_t data_head_room; - uint16_t data_tail_room; + int pass_sw_opaque; + u16 private_data_size; + u16 data_align; + u16 data_head_room; + u16 data_tail_room; };
-/** - * dpni_set_buffer_layout() - Set buffer layout configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @layout: Buffer layout configuration - * @type: DPNI queue type - * - * Return: '0' on Success; Error code otherwise. - * - * @warning Allowed only when DPNI is disabled - */ -int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_buffer_layout *layout, - enum dpni_queue_type type); +int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, + const struct dpni_buffer_layout *layout);
-/** - * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used - * for enqueue operations - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @qdid: Returned virtual QDID value that should be used as an argument - * in all enqueue operations - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_qdid(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t *qdid); +int dpni_get_qdid(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 *qdid);
-/** - * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer) - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @data_offset: Tx data offset (from start of buffer) - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint16_t *data_offset); +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 *data_offset);
/* Enable auto-negotiation */ #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL @@ -614,65 +609,44 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, * struct - Structure representing DPNI link configuration * @rate: Rate * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values + * @advertising: Speeds that are advertised for autoneg (bitmap) */ struct dpni_link_cfg { - uint32_t rate; - uint64_t options; + u32 rate; + u64 options; + u64 advertising; };
-/** - * dpni_set_link_cfg() - set the link configuration. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @cfg: Link configuration - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_link_cfg(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const struct dpni_link_cfg *cfg); +int dpni_set_link_cfg(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const struct dpni_link_cfg *cfg);
/** * struct dpni_link_state - Structure representing DPNI link state - * @rate: Rate - * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values - * @up: Link state; '0' for down, '1' for up + * @rate: Rate + * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values + * @up: Link state; '0' for down, '1' for up + * @state_valid: Ignore/Update the state of the link + * @supported: Speeds capability of the phy (bitmap) + * @advertising: Speeds that are advertised for autoneg (bitmap) */ struct dpni_link_state { - uint32_t rate; - uint64_t options; + u32 rate; + u64 options; int up; + int state_valid; + u64 supported; + u64 advertising; };
-/** - * dpni_get_link_state() - Return the link state (either up or down) - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @state: Returned link state; - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_link_state(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpni_link_state *state); +int dpni_get_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dpni_link_state *state);
-/** - * dpni_add_mac_addr() - Add MAC address filter - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mac_addr: MAC address to add - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_add_mac_addr(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - const uint8_t mac_addr[6]); +int dpni_add_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + const u8 mac_addr[6], u8 flags, + u8 tc_id, u8 flow_id); + +int dpni_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver);
/** * enum dpni_dest - DPNI destination types @@ -702,21 +676,6 @@ enum dpni_dest { /*!< Select to modify the L4 checksum generation setting */ #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
-/** - * dpni_get_api_version - Retrieve DPNI Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPNI major version - * @minor_ver: DPNI minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver); - /** * enum dpni_confirmation_mode - Defines DPNI options supported for Tx * confirmation @@ -726,7 +685,7 @@ int dpni_get_api_version(struct fsl_mc_io *mc_io, * confirmation queue * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated * with proper FD set-up to have buffers release to a Buffer Pool, otherwise - * buffers will be leaked. + * buffers will be leaked */ enum dpni_confirmation_mode { DPNI_CONF_AFFINE, @@ -734,106 +693,97 @@ enum dpni_confirmation_mode { DPNI_CONF_DISABLE, };
-struct dpni_tx_confirmation_mode { - uint32_t pad; - uint8_t confirmation_mode; -}; +/** + * stashes the whole annotation area (up to 192 bytes) + */ +#define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
/** * struct dpni_queue - Queue structure - * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ - * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant - * for Tx queues. - * @flc: FLC value for traffic dequeued from this queue. - * @user_context: User data, presented to the user along with any frames - * from this queue. Not relevant for Tx queues. + * @destination - Destination structure + * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0. + * Identifies either a DPIO or a DPCON object. + * Not relevant for Tx queues. + * @destination.type: May be one of the following: + * 0 - No destination, queue can be manually + * queried, but will not push traffic or + * notifications to a DPIO; + * 1 - The destination is a DPIO. When traffic + * becomes available in the queue a FQDAN + * (FQ data available notification) will be + * generated to selected DPIO; + * 2 - The destination is a DPCON. The queue is + * associated with a DPCON object for the + * purpose of scheduling between multiple + * queues. The DPCON may be independently + * configured to generate notifications. + * Not relevant for Tx queues. + * @destination.hold_active: Hold active, maintains a queue scheduled for longer + * in a DPIO during dequeue to reduce spread of traffic. + * Only relevant if queues are + * not affined to a single DPIO. + * @user_context: User data, presented to the user along with any frames + * from this queue. Not relevant for Tx queues. + * @flc: FD FLow Context structure + * @flc.value: Default FLC value for traffic dequeued from + * this queue. Please check description of FD + * structure for more information. + * Note that FLC values set using dpni_add_fs_entry, + * if any, take precedence over values per queue. + * @flc.stash_control: Boolean, indicates whether the 6 lowest + * - significant bits are used for stash control. + * significant bits are used for stash control. If set, the 6 + * least significant bits in value are interpreted as follows: + * - bits 0-1: indicates the number of 64 byte units of context + * that are stashed. FLC value is interpreted as a memory address + * in this case, excluding the 6 LS bits. + * - bits 2-3: indicates the number of 64 byte units of frame + * annotation to be stashed. Annotation is placed at FD[ADDR]. + * - bits 4-5: indicates the number of 64 byte units of frame + * data to be stashed. Frame data is placed at FD[ADDR] + + * FD[OFFSET]. + * For more details check the Frame Descriptor section in the + * hardware documentation. + *@cgid :indicate the cgid to set relative to dpni */ struct dpni_queue { - /** - * struct destination - Destination structure - * @id: ID of the destination, only relevant if DEST_TYPE is > 0. - * Identifies either a DPIO or a DPCON object. Not relevant for Tx - * queues. - * @type: May be one of the following: - * 0 - No destination, queue can be manually queried, but won't - * push traffic or notifications to a DPIO; - * 1 - The destination is DPIO. When traffic becomes available in - * the queue a FQDAN (FQ data available notification) will be - * generated to selected DPIO; - * 2 - The destination is a DPCON. The queue is associated with a - * DPCON object for purpose of scheduling between multiple - * queues. The DPCON may be independently configured to - * generate notifications. Not relevant for Tx queues. - * @hold_active: Hold active - */ struct { - uint32_t id; + u16 id; enum dpni_dest type; char hold_active; - char stash_ctrl; + u8 priority; } destination; - uint8_t options; - uint32_t fqid; - uint16_t qdbin; - uint64_t flc; - uint64_t user_context; + u64 user_context; + struct { + u64 value; + char stash_control; + } flc; + int cgid; };
/** - * dpni_set_queue() - Set queue parameters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @type: Type of queue - * @tc: Traffic class, in range 0 to NUM_TCS - 1 - * @index: Selects the specific queue out of the set allocated for the same - * TC. Value must be in range 0 to NUM_QUEUES - 1 - * @queue: Queue structure - * - * Return: '0' on Success; Error code otherwise. + * struct dpni_queue_id - Queue identification, used for enqueue commands + * or queue control + * @fqid: FQID used for enqueueing to and/or configuration of this + * specific FQ + * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. + * Only relevant for Tx queues. */ -int dpni_set_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type type, - uint8_t tc, - uint8_t index, - const struct dpni_queue *queue); +struct dpni_queue_id { + u32 fqid; + u16 qdbin; +};
-/** - * dpni_get_queue() - Get queue parameters - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @type: Type of queue - * @tc: Traffic class, in range 0 to NUM_TCS - 1 - * @index: Selects the specific queue out of the set allocated for the same - * TC. Value must be in range 0 to NUM_QUEUES - 1 - * @queue: Queue structure - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_queue_type type, - uint8_t tc, - uint8_t index, - struct dpni_queue *queue); +int dpni_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 param, u8 index, + u8 options, const struct dpni_queue *queue);
-/** - * dpni_set_tx_confirmation_mode() - Set TX conf mode - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @mode: DPNI confirmation mode type - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - enum dpni_confirmation_mode mode); +int dpni_get_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + enum dpni_queue_type qtype, u16 param, u8 index, + struct dpni_queue *queue, struct dpni_queue_id *qid); + +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u8 ceetm_ch_idx, enum dpni_confirmation_mode mode);
#define DPNI_STATISTICS_CNT 7
@@ -931,21 +881,6 @@ union dpni_statistics { } raw; };
-/** - * dpni_get_statistics() - Get DPNI statistics - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPNI object - * @page: Selects the statistics page to retrieve, see DPNI_GET_STATISTICS - * output. Pages are numbered 0 to 2. - * @stat: Structure containing the statistics - * - * Return: '0' on Success; Error code otherwise. - */ -int dpni_get_statistics(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t page, - union dpni_statistics *stat); - +int dpni_get_statistics(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u8 page, u16 param, union dpni_statistics *stat); #endif /* _FSL_DPNI_H */

Sync the Data Path Soft Parser APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpsparser.c | 124 ++++++++++++++++++++++------- include/fsl-mc/fsl_dpsparser.h | 139 ++++++++------------------------- 2 files changed, 126 insertions(+), 137 deletions(-)
diff --git a/drivers/net/fsl-mc/dpsparser.c b/drivers/net/fsl-mc/dpsparser.c index cfd1ba66a058..09dfb8f1fc02 100644 --- a/drivers/net/fsl-mc/dpsparser.c +++ b/drivers/net/fsl-mc/dpsparser.c @@ -2,15 +2,29 @@ /* * Data Path Soft Parser * - * Copyright 2018 NXP + * Copyright 2018, 2023 NXP */ #include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpsparser.h>
-int dpsparser_open(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *token) +/** + * dpsparser_open() - Open a control session for the specified object. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpsparser_create function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpsparser_open(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 *token) { struct mc_command cmd = { 0 }; int err; @@ -26,14 +40,23 @@ int dpsparser_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return err; }
-int dpsparser_close(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 token) +/** + * dpsparser_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSPARSER object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpsparser_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -45,9 +68,27 @@ int dpsparser_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpsparser_create(struct fsl_mc_io *mc_io, - u16 token, - u32 cmd_flags, +/** + * dpsparser_create() - Create the DPSPARSER object. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Returned token; use in subsequent API calls + * + * Create the DPSPARSER object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent calls to + * this specific object. For objects that are created using the + * DPL file, call dpsparser_open function to get an authentication + * token first. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpsparser_create(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags, u32 *obj_id) { struct mc_command cmd = { 0 }; @@ -64,36 +105,51 @@ int dpsparser_create(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - MC_CMD_READ_OBJ_ID(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd);
return 0; }
-int dpsparser_destroy(struct fsl_mc_io *mc_io, - u16 token, - u32 cmd_flags, +/** + * dpsparser_destroy() - Destroy the DPSPARSER object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSPARSER object + * + * Return: '0' on Success; error code otherwise. + */ +int dpsparser_destroy(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags, u32 obj_id) { + struct dpsparser_cmd_destroy *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_DESTROY, cmd_flags, token); - - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); + cmd_params = (struct dpsparser_cmd_destroy *)cmd.params; + cmd_params->dpsparser_id = cpu_to_le32(obj_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpsparser_apply_spb(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 token, - u64 blob_addr, - u16 *error) +/** + * dpsparser_apply_spb() - Applies the Soft Parser Blob loaded at specified address. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSPARSER object + * @blob_addr: Blob loading address + * @error: Error reported by MC related to SP Blob parsing and apply + * + * Return: '0' on Success; error code otherwise. + */ +int dpsparser_apply_spb(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u64 blob_addr, u16 *error) { + struct dpsparser_rsp_blob_report_error *rsp_params; + struct dpsparser_cmd_blob_set_address *cmd_params; struct mc_command cmd = { 0 }; int err;
@@ -101,7 +157,8 @@ int dpsparser_apply_spb(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_APPLY_SPB, cmd_flags, token); - DPSPARSER_CMD_BLOB_SET_ADDR(cmd, blob_addr); + cmd_params = (struct dpsparser_cmd_blob_set_address *)cmd.params; + cmd_params->blob_addr = cpu_to_le64(blob_addr);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -109,15 +166,24 @@ int dpsparser_apply_spb(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters: MC error code */ - DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, *error); + rsp_params = (struct dpsparser_rsp_blob_report_error *)cmd.params; + *error = le16_to_cpu(rsp_params->error);
return 0; }
-int dpsparser_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dpsparser_get_api_version - Retrieve DPSPARSER Major and Minor version info. + * + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: DPSPARSER major version + * @minor_ver: DPSPARSER minor version + * + * Return: '0' on Success; Error code otherwise. + */ +int dpsparser_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err; diff --git a/include/fsl-mc/fsl_dpsparser.h b/include/fsl-mc/fsl_dpsparser.h index 48fb495059eb..9619bb1413f8 100644 --- a/include/fsl-mc/fsl_dpsparser.h +++ b/include/fsl-mc/fsl_dpsparser.h @@ -2,7 +2,7 @@ /* * Data Path Soft Parser API * - * Copyright 2018 NXP + * Copyright 2018, 2023 NXP */ #ifndef _FSL_DPSPARSER_H #define _FSL_DPSPARSER_H @@ -20,13 +20,26 @@
#define DPSPARSER_CMDID_APPLY_SPB 0x1181
-/* cmd, param, offset, width, type, arg_name */ -#define DPSPARSER_CMD_BLOB_SET_ADDR(cmd, addr) \ - MC_CMD_OP(cmd, 0, 0, 64, u64, addr) +#pragma pack(push, 1)
-/* cmd, param, offset, width, type, arg_name */ -#define DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, err) \ - MC_RSP_OP(cmd, 0, 0, 16, u16, err) +struct dpsparser_cmd_destroy { + __le32 dpsparser_id; +}; + +struct dpsparser_cmd_blob_set_address { + __le64 blob_addr; +}; + +struct dpsparser_rsp_blob_report_error { + __le16 error; +}; + +struct dpsparser_rsp_get_api_version { + __le16 major; + __le16 minor; +}; + +#pragma pack(pop)
/* Data Path Soft Parser API * Contains initialization APIs and runtime control APIs for DPSPARSER @@ -99,110 +112,20 @@ struct fsl_mc_io; NULL, \ }
-/** - * dpsparser_open() - Open a control session for the specified object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpsparser_create function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpsparser_open(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *token); - -/** - * dpsparser_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPSPARSER object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpsparser_close(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 token); - -/** - * dpsparser_create() - Create the DPSPARSER object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Returned token; use in subsequent API calls - * - * Create the DPSPARSER object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent calls to - * this specific object. For objects that are created using the - * DPL file, call dpsparser_open function to get an authentication - * token first. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpsparser_create(struct fsl_mc_io *mc_io, - u16 token, - u32 cmd_flags, +int dpsparser_open(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 *token); + +int dpsparser_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); + +int dpsparser_create(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags, u32 *obj_id);
-/** - * dpsparser_destroy() - Destroy the DPSPARSER object and release all its - * resources. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPSPARSER object - * - * Return: '0' on Success; error code otherwise. - */ -int dpsparser_destroy(struct fsl_mc_io *mc_io, - u16 token, - u32 cmd_flags, +int dpsparser_destroy(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags, u32 obj_id);
-/** - * dpsparser_apply_spb() - Applies the Soft Parser Blob loaded at specified - * address. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPSPARSER object - * @blob_addr: Blob loading address - * @error: Error reported by MC related to SP Blob parsing and apply - * - * Return: '0' on Success; error code otherwise. - */ -int dpsparser_apply_spb(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 token, - u64 blob_addr, - u16 *error); - -/** - * dpsparser_get_api_version - Retrieve DPSPARSER Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPSPARSER major version - * @minor_ver: DPSPARSER minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dpsparser_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver); +int dpsparser_apply_spb(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u64 blob_addr, u16 *error); + +int dpsparser_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver);
#endif /* _FSL_DPSPARSER_H */

Sync the Data Path IO APIs to their latest form, this means the layout of each command is created based on structures which clearly describe the endianness of each field rather than some macros.
The command version is kept in place, meaning that the minimum MC version accepted is not changed in any way.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpio/dpio.c | 179 +++++++++++++++++------ include/fsl-mc/fsl_dpio.h | 251 +++++++++++---------------------- 2 files changed, 220 insertions(+), 210 deletions(-)
diff --git a/drivers/net/fsl-mc/dpio/dpio.c b/drivers/net/fsl-mc/dpio/dpio.c index 30ecc9124b27..d17210bf451a 100644 --- a/drivers/net/fsl-mc/dpio/dpio.c +++ b/drivers/net/fsl-mc/dpio/dpio.c @@ -1,18 +1,34 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */
#include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpio.h>
-int dpio_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint32_t dpio_id, - uint16_t *token) +/** + * dpio_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpio_id: DPIO unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpio_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and any MC portals + * assigned to the parent container; this token must be used in + * all subsequent commands for this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpio_id, + u16 *token) { + struct dpio_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err;
@@ -20,7 +36,8 @@ int dpio_open(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN, cmd_flags, 0); - DPIO_CMD_OPEN(cmd, dpio_id); + cmd_params = (struct dpio_cmd_open *)cmd.params; + cmd_params->dpio_id = cpu_to_le32(dpio_id);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -28,14 +45,20 @@ int dpio_open(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd);
return 0; }
-int dpio_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpio_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -48,12 +71,32 @@ int dpio_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpio_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpio_cfg *cfg, - uint32_t *obj_id) +/** + * dpio_create() - Create the DPIO object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPIO object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpio_cfg *cfg, u32 *obj_id) { + struct dpio_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err;
@@ -61,7 +104,11 @@ int dpio_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE, cmd_flags, dprc_token); - DPIO_CMD_CREATE(cmd, cfg); + cmd_params = (struct dpio_cmd_create *)cmd.params; + cmd_params->num_priorities = cfg->num_priorities; + dpio_set_field(cmd_params->channel_mode, + CHANNEL_MODE, + cfg->channel_mode);
/* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -69,33 +116,54 @@ int dpio_create(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - MC_CMD_READ_OBJ_ID(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd);
return 0; }
-int dpio_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t obj_id) +/** + * dpio_destroy() - Destroy the DPIO object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id) { + struct dpio_cmd_destroy *cmd_params; struct mc_command cmd = { 0 };
/* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY, - cmd_flags, - dprc_token); + cmd_flags, + dprc_token);
/* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); + cmd_params = (struct dpio_cmd_destroy *)cmd.params; + cmd_params->dpio_id = cpu_to_le32(object_id);
/* send command to mc*/ return mc_send_command(mc_io, &cmd); }
-int dpio_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpio_enable() - Enable the DPIO, allow I/O portal operations. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -108,9 +176,15 @@ int dpio_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpio_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token) +/** + * dpio_disable() - Disable the DPIO, stop any I/O portal operation. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { struct mc_command cmd = { 0 };
@@ -123,11 +197,19 @@ int dpio_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); }
-int dpio_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpio_get_attributes() - Retrieve DPIO attributes + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @attr: Returned object's attributes + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, struct dpio_attr *attr) { + struct dpio_rsp_get_attr *rsp_params; struct mc_command cmd = { 0 }; int err;
@@ -142,29 +224,42 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPIO_RSP_GET_ATTR(cmd, attr); + rsp_params = (struct dpio_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(rsp_params->id); + attr->qbman_portal_id = le16_to_cpu(rsp_params->qbman_portal_id); + attr->num_priorities = rsp_params->num_priorities; + attr->qbman_portal_ce_offset = le64_to_cpu(rsp_params->qbman_portal_ce_offset); + attr->qbman_portal_ci_offset = le64_to_cpu(rsp_params->qbman_portal_ci_offset); + attr->qbman_version = le32_to_cpu(rsp_params->qbman_version); + attr->clk = le32_to_cpu(rsp_params->clk); + attr->channel_mode = dpio_get_field(rsp_params->channel_mode, ATTR_CHANNEL_MODE);
return 0; }
-int dpio_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver) +/** + * dpio_get_api_version() - Get Data Path I/O API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path i/o API + * @minor_ver: Minor version of data path i/o API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver) { struct mc_command cmd = { 0 }; int err;
- /* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION, - cmd_flags, 0); + cmd_flags, + 0);
- /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err;
- /* retrieve response parameters */ mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0; diff --git a/include/fsl-mc/fsl_dpio.h b/include/fsl-mc/fsl_dpio.h index 9d52a8e42f87..375590fd9751 100644 --- a/include/fsl-mc/fsl_dpio.h +++ b/include/fsl-mc/fsl_dpio.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */
#ifndef _FSL_DPIO_H @@ -22,29 +22,52 @@ #define DPIO_CMDID_DISABLE 0x0031 #define DPIO_CMDID_GET_ATTR 0x0041
-/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_OPEN(cmd, dpio_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \ - cfg->channel_mode);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_GET_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\ - MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\ - MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\ - MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\ -} while (0) +/* Macros for accessing command fields smaller than 1byte */ +#define DPIO_MASK(field) \ + GENMASK(DPIO_##field##_SHIFT + DPIO_##field##_SIZE - 1, \ + DPIO_##field##_SHIFT) +#define dpio_set_field(var, field, val) \ + ((var) |= (((val) << DPIO_##field##_SHIFT) & DPIO_MASK(field))) +#define dpio_get_field(var, field) \ + (((var) & DPIO_MASK(field)) >> DPIO_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpio_cmd_open { + __le32 dpio_id; +}; + +#define DPIO_CHANNEL_MODE_SHIFT 0 +#define DPIO_CHANNEL_MODE_SIZE 2 + +struct dpio_cmd_create { + __le16 pad1; + /* from LSB: channel_mode:2 */ + u8 channel_mode; + u8 pad2; + u8 num_priorities; +}; + +struct dpio_cmd_destroy { + __le32 dpio_id; +}; + +#define DPIO_ATTR_CHANNEL_MODE_SHIFT 0 +#define DPIO_ATTR_CHANNEL_MODE_SIZE 4 + +struct dpio_rsp_get_attr { + __le32 id; + __le16 qbman_portal_id; + u8 num_priorities; + /* from LSB: channel_mode:4 */ + u8 channel_mode; + __le64 qbman_portal_ce_offset; + __le64 qbman_portal_ci_offset; + __le32 qbman_version; + __le32 pad; + __le32 clk; +}; + +#pragma pack(pop)
/* Data Path I/O Portal API * Contains initialization APIs and runtime control APIs for DPIO @@ -52,44 +75,15 @@ do { \
struct fsl_mc_io;
-/** - * dpio_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpio_id: DPIO unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpio_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint32_t dpio_id, - uint16_t *token); +int dpio_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpio_id, + u16 *token);
-/** - * dpio_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * enum dpio_channel_mode - DPIO notification channel mode - * @DPIO_NO_CHANNEL: No support for notification channel - * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a + * @DPIO_NO_CHANNEL: No support for notification channel + * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a * dedicated channel in the DPIO; user should point the queue's * destination in the relevant interface to this DPIO */ @@ -100,131 +94,52 @@ enum dpio_channel_mode {
/** * struct dpio_cfg - Structure representing DPIO configuration - * @channel_mode: Notification channel mode - * @num_priorities: Number of priorities for the notification channel (1-8); + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification channel (1-8); * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' */ struct dpio_cfg { - enum dpio_channel_mode channel_mode; - uint8_t num_priorities; + enum dpio_channel_mode channel_mode; + u8 num_priorities; };
-/** - * dpio_create() - Create the DPIO object. - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: Returned obj_id; use in subsequent API calls - * - * Create the DPIO object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent calls to - * this specific object. For objects that are created using the - * DPL file, call dpio_open() function to get an authentication - * token first. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_create(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - const struct dpio_cfg *cfg, - uint32_t *obj_id); +int dpio_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + const struct dpio_cfg *cfg, u32 *obj_id);
-/** - * dpio_destroy() - Destroy the DPIO object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @token: Authentication token. - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @obj_id: Object ID of DPIO - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_destroy(struct fsl_mc_io *mc_io, - uint16_t token, - uint32_t cmd_flags, - uint32_t obj_id); +int dpio_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, + u32 object_id);
-/** - * dpio_enable() - Enable the DPIO, allow I/O portal operations. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
-/** - * dpio_disable() - Disable the DPIO, stop any I/O portal operation. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/** * struct dpio_attr - Structure representing DPIO attributes - * @id: DPIO object ID - * @version: DPIO version - * @qbman_portal_ce_offset: offset of the software portal cache-enabled area - * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area - * @qbman_portal_id: Software portal ID - * @channel_mode: Notification channel mode - * @num_priorities: Number of priorities for the notification channel (1-8); - * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' - * @qbman_version: QBMAN version + * @id: DPIO object ID + * @qbman_portal_ce_offset: Offset of the software portal cache-enabled area + * @qbman_portal_ci_offset: Offset of the software portal + * cache-inhibited area + * @qbman_portal_id: Software portal ID + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification + * channel (1-8); relevant only if + * 'channel_mode = DPIO_LOCAL_CHANNEL' + * @qbman_version: QBMAN version */ struct dpio_attr { - uint32_t id; - uint64_t qbman_portal_ce_offset; - uint64_t qbman_portal_ci_offset; - uint16_t qbman_portal_id; + int id; + u64 qbman_portal_ce_offset; + u64 qbman_portal_ci_offset; + u16 qbman_portal_id; enum dpio_channel_mode channel_mode; - uint8_t num_priorities; - uint32_t qbman_version; + u8 num_priorities; + u32 qbman_version; + u32 clk; };
-/** - * dpio_get_attributes() - Retrieve DPIO attributes - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpio_attr *attr); - -/** - * dpio_get_api_version - Retrieve DPIO Major and Minor version info. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: DPIO major version - * @minor_ver: DPIO minor version - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_get_api_version(struct fsl_mc_io *mc_io, - u32 cmd_flags, - u16 *major_ver, - u16 *minor_ver); +int dpio_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + struct dpio_attr *attr);
+int dpio_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 *major_ver, u16 *minor_ver); #endif /* _FSL_DPIO_H */

This patch targets the last remaining commands left to sync to their latest form - mainly the mc_get_version() API.
Besides this, remove any macro which is now of no help.
Signed-off-by: Ioana Ciornei ioana.ciornei@nxp.com --- drivers/net/fsl-mc/dpmng.c | 20 ++++++++++++++++---- drivers/net/fsl-mc/fsl_dpmng_cmd.h | 17 +++++++++-------- drivers/net/fsl-mc/mc_sys.c | 13 +++++++++---- include/fsl-mc/fsl_dpmng.h | 13 +------------ include/fsl-mc/fsl_mc_cmd.h | 23 ----------------------- 5 files changed, 35 insertions(+), 51 deletions(-)
diff --git a/drivers/net/fsl-mc/dpmng.c b/drivers/net/fsl-mc/dpmng.c index 8314243f3561..147ca6da9e1f 100644 --- a/drivers/net/fsl-mc/dpmng.c +++ b/drivers/net/fsl-mc/dpmng.c @@ -1,15 +1,24 @@ // SPDX-License-Identifier: GPL-2.0+ /* Copyright 2013-2015 Freescale Semiconductor Inc. + * Copyright 2023 NXP */ #include <fsl-mc/fsl_mc_sys.h> #include <fsl-mc/fsl_mc_cmd.h> #include <fsl-mc/fsl_dpmng.h> #include "fsl_dpmng_cmd.h"
-int mc_get_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - struct mc_version *mc_ver_info) +/** + * mc_get_version() - Retrieves the Management Complex firmware + * version information + * @mc_io: Pointer to opaque I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @mc_ver_info: Returned version information structure + * + * Return: '0' on Success; Error code otherwise. + */ +int mc_get_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_version *mc_ver_info) { + struct dpmng_rsp_get_version *rsp_params; struct mc_command cmd = { 0 }; int err;
@@ -24,7 +33,10 @@ int mc_get_version(struct fsl_mc_io *mc_io, return err;
/* retrieve response parameters */ - DPMNG_RSP_GET_VERSION(cmd, mc_ver_info); + rsp_params = (struct dpmng_rsp_get_version *)cmd.params; + mc_ver_info->revision = le32_to_cpu(rsp_params->revision); + mc_ver_info->major = le32_to_cpu(rsp_params->version_major); + mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor);
return 0; } diff --git a/drivers/net/fsl-mc/fsl_dpmng_cmd.h b/drivers/net/fsl-mc/fsl_dpmng_cmd.h index e18c88da0972..e6efceab7acc 100644 --- a/drivers/net/fsl-mc/fsl_dpmng_cmd.h +++ b/drivers/net/fsl-mc/fsl_dpmng_cmd.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* Copyright 2013-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017, 2023 NXP */ #ifndef __FSL_DPMNG_CMD_H #define __FSL_DPMNG_CMD_H @@ -8,12 +8,13 @@ /* Command IDs */ #define DPMNG_CMDID_GET_VERSION 0x8311
-/* cmd, param, offset, width, type, arg_name */ -#define DPMNG_RSP_GET_VERSION(cmd, mc_ver_info) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mc_ver_info->revision); \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, mc_ver_info->major); \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, mc_ver_info->minor); \ -} while (0) +#pragma pack(push, 1) +struct dpmng_rsp_get_version { + __le32 revision; + __le32 version_major; + __le32 version_minor; +}; + +#pragma pack(pop)
#endif /* __FSL_DPMNG_CMD_H */ diff --git a/drivers/net/fsl-mc/mc_sys.c b/drivers/net/fsl-mc/mc_sys.c index b5ae2ea3eb56..4d32516b0055 100644 --- a/drivers/net/fsl-mc/mc_sys.c +++ b/drivers/net/fsl-mc/mc_sys.c @@ -13,8 +13,13 @@ #include <asm/io.h> #include <linux/delay.h>
-#define MC_CMD_HDR_READ_CMDID(_hdr) \ - ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S)) +static u16 mc_cmd_hdr_read_cmdid(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + u16 cmd_id = le16_to_cpu(hdr->cmd_id); + + return cmd_id; +}
/** * mc_send_command - Send MC command and wait for response @@ -52,8 +57,8 @@ int mc_send_command(struct fsl_mc_io *mc_io, if (status != MC_CMD_STATUS_OK) { printf("Error: MC command failed (portal: %p, obj handle: %#x, command: %#x, status: %#x)\n", mc_io->mmio_regs, - (unsigned int)MC_CMD_HDR_READ_TOKEN(cmd->header), - (unsigned int)MC_CMD_HDR_READ_CMDID(cmd->header), + (unsigned int)mc_cmd_hdr_read_token(cmd), + (unsigned int)mc_cmd_hdr_read_cmdid(cmd), (unsigned int)status);
return -EIO; diff --git a/include/fsl-mc/fsl_dpmng.h b/include/fsl-mc/fsl_dpmng.h index 2148601e8a12..5dfc9ecc4281 100644 --- a/include/fsl-mc/fsl_dpmng.h +++ b/include/fsl-mc/fsl_dpmng.h @@ -30,17 +30,6 @@ struct mc_version { uint32_t revision; };
-/** - * mc_get_version() - Retrieves the Management Complex firmware - * version information - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @mc_ver_info: Returned version information structure - * - * Return: '0' on Success; Error code otherwise. - */ -int mc_get_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - struct mc_version *mc_ver_info); +int mc_get_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_version *mc_ver_info);
#endif /* __FSL_DPMNG_H */ diff --git a/include/fsl-mc/fsl_mc_cmd.h b/include/fsl-mc/fsl_mc_cmd.h index 6fe5fa4eddaf..c239595ed577 100644 --- a/include/fsl-mc/fsl_mc_cmd.h +++ b/include/fsl-mc/fsl_mc_cmd.h @@ -83,29 +83,6 @@ enum mc_cmd_status { ((enum mc_cmd_status)mc_dec((_hdr), \ MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S))
-#define MC_CMD_HDR_READ_TOKEN(_hdr) \ - ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S)) - -#define MC_PREP_OP(_ext, _param, _offset, _width, _type, _arg) \ - ((_ext)[_param] |= cpu_to_le64(mc_enc((_offset), (_width), _arg))) - -#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \ - (_arg = (_type)mc_dec(cpu_to_le64(_ext[_param]), (_offset), (_width))) - -#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \ - ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg)) - -#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \ - (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width))) - -/* cmd, param, offset, width, type, arg_name */ -#define MC_CMD_READ_OBJ_ID(cmd, obj_id) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, obj_id) - -/* cmd, param, offset, width, type, arg_name */ -#define CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id) \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, object_id) - static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id, uint32_t cmd_flags, uint16_t token)
participants (1)
-
Ioana Ciornei