aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-06-15 11:02:22 -0400
committerTom Rini <trini@konsulko.com>2023-06-15 11:02:22 -0400
commit5ac10c00ed727842c00d8659611151334f84c0ea (patch)
treebd6c31a0a00be76a17a120f7a2ec72bec76daa00
parentcb4fe56eca1109780e97c68329e6b71ef33bf0e6 (diff)
parentb824212dc29b5b0354e84c7dadec21d75bacb349 (diff)
downloadu-boot-WIP/15Jun2023-next.zip
u-boot-WIP/15Jun2023-next.tar.gz
u-boot-WIP/15Jun2023-next.tar.bz2
Merge tag 'fsl-qoriq-2023-6-15' of https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq into nextWIP/15Jun2023-next
DM_MDIO/CMD for ls1046afrwy sync APIs for fsl-mc ldpaa_eth update lx2160ardb recv support. net: dsa fix of fallback lookup
-rw-r--r--arch/arm/dts/fsl-ls1046a-frwy.dts48
-rw-r--r--board/freescale/ls1046afrwy/ls1046afrwy.c3
-rw-r--r--board/freescale/lx2160a/eth_lx2160ardb.c107
-rw-r--r--board/freescale/lx2160a/lx2160a.c22
-rw-r--r--board/freescale/lx2160a/lx2160a.h15
-rw-r--r--cmd/net.c54
-rw-r--r--configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig2
-rw-r--r--configs/ls1046afrwy_tfa_defconfig2
-rw-r--r--drivers/net/fsl-mc/dpbp.c180
-rw-r--r--drivers/net/fsl-mc/dpio/dpio.c194
-rw-r--r--drivers/net/fsl-mc/dpmac.c274
-rw-r--r--drivers/net/fsl-mc/dpmng.c20
-rw-r--r--drivers/net/fsl-mc/dpni.c680
-rw-r--r--drivers/net/fsl-mc/dprc.c405
-rw-r--r--drivers/net/fsl-mc/dpsparser.c124
-rw-r--r--drivers/net/fsl-mc/fsl_dpmng_cmd.h17
-rw-r--r--drivers/net/fsl-mc/mc.c14
-rw-r--r--drivers/net/fsl-mc/mc_sys.c13
-rw-r--r--drivers/net/ldpaa_eth/ldpaa_eth.c268
-rw-r--r--drivers/net/ldpaa_eth/ldpaa_eth.h64
-rw-r--r--include/configs/lx2160ardb.h5
-rw-r--r--include/fsl-mc/fsl_dpbp.h207
-rw-r--r--include/fsl-mc/fsl_dpio.h266
-rw-r--r--include/fsl-mc/fsl_dpmac.h365
-rw-r--r--include/fsl-mc/fsl_dpmng.h13
-rw-r--r--include/fsl-mc/fsl_dpni.h1660
-rw-r--r--include/fsl-mc/fsl_dprc.h935
-rw-r--r--include/fsl-mc/fsl_dpsparser.h139
-rw-r--r--include/fsl-mc/fsl_mc_cmd.h47
-rw-r--r--include/net.h6
-rw-r--r--net/dsa-uclass.c2
31 files changed, 2593 insertions, 3558 deletions
diff --git a/arch/arm/dts/fsl-ls1046a-frwy.dts b/arch/arm/dts/fsl-ls1046a-frwy.dts
index cda0541..1e656d4 100644
--- a/arch/arm/dts/fsl-ls1046a-frwy.dts
+++ b/arch/arm/dts/fsl-ls1046a-frwy.dts
@@ -2,7 +2,7 @@
/*
* Device Tree Include file for NXP Layerscape-1046A family SoC.
*
- * Copyright 2019 NXP
+ * Copyright 2019-2023 NXP
*
*/
@@ -34,3 +34,49 @@
&i2c0 {
status = "okay";
};
+
+#include "fsl-ls1046-post.dtsi"
+
+&fman0 {
+ ethernet@e0000 {
+ phy-handle = <&qsgmii_phy4>;
+ phy-connection-type = "qsgmii";
+ status = "okay";
+ };
+
+ ethernet@e8000 {
+ phy-handle = <&qsgmii_phy2>;
+ phy-connection-type = "qsgmii";
+ status = "okay";
+ };
+
+ ethernet@ea000 {
+ phy-handle = <&qsgmii_phy1>;
+ phy-connection-type = "qsgmii";
+ status = "okay";
+ };
+
+ ethernet@f2000 {
+ phy-handle = <&qsgmii_phy3>;
+ phy-connection-type = "qsgmii";
+ status = "okay";
+ };
+
+ mdio@fd000 {
+ qsgmii_phy1: ethernet-phy@1c {
+ reg = <0x1c>;
+ };
+
+ qsgmii_phy2: ethernet-phy@1d {
+ reg = <0x1d>;
+ };
+
+ qsgmii_phy3: ethernet-phy@1e {
+ reg = <0x1e>;
+ };
+
+ qsgmii_phy4: ethernet-phy@1f {
+ reg = <0x1f>;
+ };
+ };
+};
diff --git a/board/freescale/ls1046afrwy/ls1046afrwy.c b/board/freescale/ls1046afrwy/ls1046afrwy.c
index f6e5c12..899c22a 100644
--- a/board/freescale/ls1046afrwy/ls1046afrwy.c
+++ b/board/freescale/ls1046afrwy/ls1046afrwy.c
@@ -134,6 +134,9 @@ val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
out_le32(SMMU_NSCR0, val);
#endif
+ if (!IS_ENABLED(CONFIG_SYS_EARLY_PCI_INIT))
+ pci_init();
+
select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
return 0;
}
diff --git a/board/freescale/lx2160a/eth_lx2160ardb.c b/board/freescale/lx2160a/eth_lx2160ardb.c
index 533f606..c5dfefe 100644
--- a/board/freescale/lx2160a/eth_lx2160ardb.c
+++ b/board/freescale/lx2160a/eth_lx2160ardb.c
@@ -8,6 +8,7 @@
#include <netdev.h>
#include <exports.h>
#include <fsl-mc/fsl_mc.h>
+#include "lx2160a.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -36,3 +37,109 @@ void reset_phy(void)
#endif
}
#endif /* CONFIG_RESET_PHY_R */
+
+static int fdt_get_dpmac_node(void *fdt, int dpmac_id)
+{
+ char dpmac_str[11] = "dpmacs@00";
+ int offset, dpmacs_offset;
+
+ /* get the dpmac offset */
+ dpmacs_offset = fdt_path_offset(fdt, "/soc/fsl-mc/dpmacs");
+ if (dpmacs_offset < 0)
+ dpmacs_offset = fdt_path_offset(fdt, "/fsl-mc/dpmacs");
+
+ if (dpmacs_offset < 0) {
+ printf("dpmacs node not found in device tree\n");
+ return dpmacs_offset;
+ }
+
+ sprintf(dpmac_str, "dpmac@%x", dpmac_id);
+ offset = fdt_subnode_offset(fdt, dpmacs_offset, dpmac_str);
+ if (offset < 0) {
+ sprintf(dpmac_str, "ethernet@%x", dpmac_id);
+ offset = fdt_subnode_offset(fdt, dpmacs_offset, dpmac_str);
+ if (offset < 0) {
+ printf("dpmac@%x/ethernet@%x node not found in device tree\n",
+ dpmac_id, dpmac_id);
+ return offset;
+ }
+ }
+
+ return offset;
+}
+
+static int fdt_update_phy_addr(void *fdt, int dpmac_id, int phy_addr)
+{
+ char dpmac_str[] = "dpmacs@00";
+ const u32 *phyhandle;
+ int offset;
+ int err;
+
+ /* get the dpmac offset */
+ offset = fdt_get_dpmac_node(fdt, dpmac_id);
+ if (offset < 0)
+ return offset;
+
+ /* get dpmac phy-handle */
+ sprintf(dpmac_str, "dpmac@%x", dpmac_id);
+ phyhandle = (u32 *)fdt_getprop(fdt, offset, "phy-handle", NULL);
+ if (!phyhandle) {
+ printf("%s node not found in device tree\n", dpmac_str);
+ return offset;
+ }
+
+ offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*phyhandle));
+ if (offset < 0) {
+ printf("Could not get the ph node offset for dpmac %d\n",
+ dpmac_id);
+ return offset;
+ }
+
+ phy_addr = cpu_to_fdt32(phy_addr);
+ err = fdt_setprop(fdt, offset, "reg", &phy_addr, sizeof(phy_addr));
+ if (err < 0) {
+ printf("Could not set phy node's reg for dpmac %d: %s.\n",
+ dpmac_id, fdt_strerror(err));
+ return err;
+ }
+
+ return 0;
+}
+
+static int fdt_delete_phy_handle(void *fdt, int dpmac_id)
+{
+ const u32 *phyhandle;
+ int offset;
+
+ /* get the dpmac offset */
+ offset = fdt_get_dpmac_node(fdt, dpmac_id);
+ if (offset < 0)
+ return offset;
+
+ /* verify if the node has a phy-handle */
+ phyhandle = (u32 *)fdt_getprop(fdt, offset, "phy-handle", NULL);
+ if (!phyhandle)
+ return 0;
+
+ return fdt_delprop(fdt, offset, "phy-handle");
+}
+
+int fdt_fixup_board_phy_revc(void *fdt)
+{
+ int ret;
+
+ if (get_board_rev() < 'C')
+ return 0;
+
+ /* DPMACs 3,4 have their Aquantia PHYs at new addresses */
+ ret = fdt_update_phy_addr(fdt, 3, AQR113C_PHY_ADDR1);
+ if (ret)
+ return ret;
+
+ ret = fdt_update_phy_addr(fdt, 4, AQR113C_PHY_ADDR2);
+ if (ret)
+ return ret;
+
+ /* There is no PHY for the DPMAC2, so remove the phy-handle */
+ return fdt_delete_phy_handle(fdt, 2);
+}
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index 2a75205..d631a11 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -133,6 +133,11 @@ int board_fix_fdt(void *fdt)
fdt_setprop(fdt, off, "reg-names", reg_names, names_len);
}
+ /* Fixup u-boot's DTS in case this is a revC board and
+ * we're using DM_ETH.
+ */
+ if (IS_ENABLED(CONFIG_TARGET_LX2160ARDB) && IS_ENABLED(CONFIG_DM_ETH))
+ fdt_fixup_board_phy_revc(fdt);
return 0;
}
#endif
@@ -487,6 +492,15 @@ int config_board_mux(void)
}
#endif
+#if IS_ENABLED(CONFIG_TARGET_LX2160ARDB)
+u8 get_board_rev(void)
+{
+ u8 board_rev = (QIXIS_READ(arch) & 0xf) - 1 + 'A';
+
+ return board_rev;
+}
+#endif
+
unsigned long get_board_sys_clk(void)
{
#if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS)
@@ -627,6 +641,8 @@ void fdt_fixup_board_enet(void *fdt)
if (get_mc_boot_status() == 0 &&
(is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0)) {
fdt_status_okay(fdt, offset);
+ if (IS_ENABLED(CONFIG_TARGET_LX2160ARDB))
+ fdt_fixup_board_phy_revc(fdt);
} else {
fdt_status_fail(fdt, offset);
}
@@ -760,9 +776,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
u64 mc_memory_size = 0;
u16 total_memory_banks;
int err;
-#if IS_ENABLED(CONFIG_TARGET_LX2160ARDB)
- u8 board_rev;
-#endif
err = fdt_increase_size(blob, 512);
if (err) {
@@ -825,8 +838,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
fdt_fixup_icid(blob);
#if IS_ENABLED(CONFIG_TARGET_LX2160ARDB)
- board_rev = (QIXIS_READ(arch) & 0xf) - 1 + 'A';
- if (board_rev == 'C')
+ if (get_board_rev() == 'C')
fdt_fixup_i2c_thermal_node(blob);
#endif
diff --git a/board/freescale/lx2160a/lx2160a.h b/board/freescale/lx2160a/lx2160a.h
index 52b0207..61a8bb9 100644
--- a/board/freescale/lx2160a/lx2160a.h
+++ b/board/freescale/lx2160a/lx2160a.h
@@ -58,4 +58,19 @@
#endif
#endif
+#if IS_ENABLED(CONFIG_TARGET_LX2160ARDB)
+u8 get_board_rev(void);
+int fdt_fixup_board_phy_revc(void *fdt);
+#else
+static inline u8 get_board_rev(void)
+{
+ return 0;
+}
+
+static inline int fdt_fixup_board_phy_revc(void *fdt)
+{
+ return 0;
+}
+#endif
+
#endif /* __LX2160_H */
diff --git a/cmd/net.c b/cmd/net.c
index 68d4062..dfe811f 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -13,6 +13,7 @@
#include <bootstage.h>
#include <command.h>
#include <dm.h>
+#include <dm/devres.h>
#include <env.h>
#include <image.h>
#include <log.h>
@@ -691,8 +692,58 @@ static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const ar
return CMD_RET_SUCCESS;
}
+static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ int nstats, err, i, off;
+ struct udevice *dev;
+ u64 *values;
+ u8 *strings;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ err = uclass_get_device_by_name(UCLASS_ETH, argv[1], &dev);
+ if (err) {
+ printf("Could not find device %s\n", argv[1]);
+ return CMD_RET_FAILURE;
+ }
+
+ if (!eth_get_ops(dev)->get_sset_count ||
+ !eth_get_ops(dev)->get_strings ||
+ !eth_get_ops(dev)->get_stats) {
+ printf("Driver does not implement stats dump!\n");
+ return CMD_RET_FAILURE;
+ }
+
+ nstats = eth_get_ops(dev)->get_sset_count(dev);
+ strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL);
+ if (!strings)
+ return CMD_RET_FAILURE;
+
+ values = kcalloc(nstats, sizeof(u64), GFP_KERNEL);
+ if (!values)
+ goto err_free_strings;
+
+ eth_get_ops(dev)->get_strings(dev, strings);
+ eth_get_ops(dev)->get_stats(dev, values);
+
+ off = 0;
+ for (i = 0; i < nstats; i++) {
+ printf(" %s: %llu\n", &strings[off], values[i]);
+ off += ETH_GSTRING_LEN;
+ };
+
+ return CMD_RET_SUCCESS;
+
+err_free_strings:
+ kfree(strings);
+
+ return CMD_RET_FAILURE;
+}
+
static struct cmd_tbl cmd_net[] = {
U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""),
+ U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""),
};
static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -714,9 +765,10 @@ static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
U_BOOT_CMD(
- net, 2, 1, do_net,
+ net, 3, 1, do_net,
"NET sub-system",
"list - list available devices\n"
+ "stats <device> - dump statistics for specified device\n"
);
#if defined(CONFIG_CMD_NCSI)
diff --git a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
index 8d6a137..da1b18a 100644
--- a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
@@ -30,6 +30,7 @@ CONFIG_MISC_INIT_R=y
CONFIG_SYS_MAXARGS=64
CONFIG_SYS_PBSIZE=532
CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
+CONFIG_CMD_DM=y
CONFIG_CMD_GPT=y
CONFIG_CMD_I2C=y
CONFIG_CMD_MMC=y
@@ -61,6 +62,7 @@ CONFIG_SPI_FLASH_STMICRO=y
# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
CONFIG_PHYLIB=y
CONFIG_PHY_VITESSE=y
+CONFIG_DM_MDIO=y
CONFIG_PHY_GIGE=y
CONFIG_E1000=y
CONFIG_FMAN_ENET=y
diff --git a/configs/ls1046afrwy_tfa_defconfig b/configs/ls1046afrwy_tfa_defconfig
index e5d2b55..71142af 100644
--- a/configs/ls1046afrwy_tfa_defconfig
+++ b/configs/ls1046afrwy_tfa_defconfig
@@ -34,6 +34,7 @@ CONFIG_MISC_INIT_R=y
CONFIG_SYS_MAXARGS=64
CONFIG_SYS_PBSIZE=532
CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
+CONFIG_CMD_DM=y
CONFIG_CMD_GPT=y
CONFIG_CMD_I2C=y
CONFIG_CMD_MMC=y
@@ -67,6 +68,7 @@ CONFIG_SPI_FLASH_STMICRO=y
# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
CONFIG_PHYLIB=y
CONFIG_PHY_VITESSE=y
+CONFIG_DM_MDIO=y
CONFIG_PHY_GIGE=y
CONFIG_E1000=y
CONFIG_FMAN_ENET=y
diff --git a/drivers/net/fsl-mc/dpbp.c b/drivers/net/fsl-mc/dpbp.c
index c609efb..5e17ccf 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/drivers/net/fsl-mc/dpio/dpio.c b/drivers/net/fsl-mc/dpio/dpio.c
index 8884455..d17210b 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,26 +197,19 @@ 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,
+/**
+ * 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;
@@ -157,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/drivers/net/fsl-mc/dpmac.c b/drivers/net/fsl-mc/dpmac.c
index 43a2ff4..5d4f6c6 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,142 +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);
-
- /* send command to mc*/
- 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);
+ 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_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,
+/**
+ * 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;
@@ -214,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/drivers/net/fsl-mc/dpmng.c b/drivers/net/fsl-mc/dpmng.c
index 8314243..147ca6d 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/dpni.c b/drivers/net/fsl-mc/dpni.c
index 5290be2..5b815a4 100644
--- a/drivers/net/fsl-mc/dpni.c
+++ b/drivers/net/fsl-mc/dpni.c
@@ -1,46 +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_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,
- 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);
@@ -48,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 };
@@ -68,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;
@@ -81,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);
@@ -89,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 };
@@ -145,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 };
@@ -160,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 };
@@ -175,76 +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_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,
- 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);
@@ -252,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 */
@@ -276,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 */
@@ -317,211 +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);
-
- 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);
+ 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;
- /* send command to mc*/
- 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);
+ 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,
- struct 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;
}
-
-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 e0a2865..d1a74ab 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,253 +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_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,
+/**
+ * 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);
@@ -348,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/drivers/net/fsl-mc/dpsparser.c b/drivers/net/fsl-mc/dpsparser.c
index cfd1ba6..09dfb8f 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/drivers/net/fsl-mc/fsl_dpmng_cmd.h b/drivers/net/fsl-mc/fsl_dpmng_cmd.h
index e18c88d..e6efcea 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.c b/drivers/net/fsl-mc/mc.c
index 78a40f2..984616f 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/fsl-mc/mc_sys.c b/drivers/net/fsl-mc/mc_sys.c
index b5ae2ea..4d32516 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/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 2cb6e9b..87fbada 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -38,146 +38,90 @@ static void init_phy(struct udevice *dev)
}
#endif
-#ifdef DEBUG
-
-#define DPNI_STATS_PER_PAGE 6
-
-static const char *dpni_statistics[][DPNI_STATS_PER_PAGE] = {
- {
- "DPNI_CNT_ING_ALL_FRAMES",
- "DPNI_CNT_ING_ALL_BYTES",
- "DPNI_CNT_ING_MCAST_FRAMES",
- "DPNI_CNT_ING_MCAST_BYTES",
- "DPNI_CNT_ING_BCAST_FRAMES",
- "DPNI_CNT_ING_BCAST_BYTES",
- }, {
- "DPNI_CNT_EGR_ALL_FRAMES",
- "DPNI_CNT_EGR_ALL_BYTES",
- "DPNI_CNT_EGR_MCAST_FRAMES",
- "DPNI_CNT_EGR_MCAST_BYTES",
- "DPNI_CNT_EGR_BCAST_FRAMES",
- "DPNI_CNT_EGR_BCAST_BYTES",
- }, {
- "DPNI_CNT_ING_FILTERED_FRAMES",
- "DPNI_CNT_ING_DISCARDED_FRAMES",
- "DPNI_CNT_ING_NOBUFFER_DISCARDS",
- "DPNI_CNT_EGR_DISCARDED_FRAMES",
- "DPNI_CNT_EGR_CNF_FRAMES",
- ""
- },
-};
-
-static void print_dpni_stats(const char *strings[],
- struct dpni_statistics dpni_stats)
+static void ldpaa_eth_collect_dpni_stats(struct udevice *dev, u64 *data)
{
- uint64_t *stat;
- int i;
+ union dpni_statistics dpni_stats;
+ int dpni_stats_page_size[DPNI_STATISTICS_CNT] = {
+ sizeof(dpni_stats.page_0),
+ sizeof(dpni_stats.page_1),
+ sizeof(dpni_stats.page_2),
+ sizeof(dpni_stats.page_3),
+ sizeof(dpni_stats.page_4),
+ sizeof(dpni_stats.page_5),
+ sizeof(dpni_stats.page_6),
+ };
+ int j, k, num_cnt, err, i = 0;
- stat = (uint64_t *)&dpni_stats;
- for (i = 0; i < DPNI_STATS_PER_PAGE; i++) {
- if (strcmp(strings[i], "\0") == 0)
- break;
- printf("%s= %llu\n", strings[i], *stat);
- stat++;
+ for (j = 0; j <= 6; j++) {
+ /* We're not interested in pages 4 & 5 for now */
+ if (j == 4 || j == 5)
+ continue;
+ err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS,
+ dflt_dpni->dpni_handle,
+ j, 0, &dpni_stats);
+ if (err) {
+ memset(&dpni_stats, 0, sizeof(dpni_stats));
+ printf("dpni_get_stats(%d) failed\n", j);
+ }
+
+ num_cnt = dpni_stats_page_size[j] / sizeof(u64);
+ for (k = 0; k < num_cnt; k++)
+ *(data + i++) = dpni_stats.raw.counter[k];
}
}
-static void ldpaa_eth_get_dpni_counter(void)
+static void ldpaa_eth_add_dpni_stats(struct udevice *dev, u64 *data)
{
- int err = 0;
- unsigned int page = 0;
- struct dpni_statistics dpni_stats;
+ struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+ int i;
- printf("DPNI counters ..\n");
- for (page = 0; page < 3; page++) {
- err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS,
- dflt_dpni->dpni_handle, page,
- &dpni_stats);
- if (err < 0) {
- printf("dpni_get_statistics: failed:");
- printf("%d for page[%d]\n", err, page);
- return;
- }
- print_dpni_stats(dpni_statistics[page], dpni_stats);
- }
+ for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+ priv->dpni_stats[i] += data[i];
}
-static void ldpaa_eth_get_dpmac_counter(struct udevice *dev)
+static void ldpaa_eth_collect_dpmac_stats(struct udevice *dev, u64 *data)
{
struct ldpaa_eth_priv *priv = dev_get_priv(dev);
- int err = 0;
+ int err, i;
u64 value;
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_BYTE,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
- return;
- }
- printf("\nDPMAC counters ..\n");
- printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) {
+ err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
+ priv->dpmac_handle, i,
+ &value);
+ if (err)
+ printf("dpmac_get_counter(%d) failed\n", i);
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_FRAME_DISCARD,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_FRAME_DISCARD failed\n");
- return;
+ *(data + i) = value;
}
- printf("DPMAC_CNT_ING_FRAME_DISCARD=%lld\n", value);
+}
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_ALIGN_ERR,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_ALIGN_ERR failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_ALIGN_ERR =%lld\n", value);
+static void ldpaa_eth_add_dpmac_stats(struct udevice *dev, u64 *data)
+{
+ struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+ int i;
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_BYTE,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+ priv->dpmac_stats[i] += data[i];
+}
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_ING_ERR_FRAME,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_ING_ERR_FRAME failed\n");
- return;
- }
- printf("DPMAC_CNT_ING_ERR_FRAME=%lld\n", value);
+#ifdef DEBUG
+static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
+{
+ int i;
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_EGR_BYTE ,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_EGR_BYTE failed\n");
- return;
- }
- printf("DPMAC_CNT_EGR_BYTE =%lld\n", value);
+ printf("DPNI counters:\n");
+ for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+ printf(" %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], data[i]);
+}
- err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
- priv->dpmac_handle,
- DPMAC_CNT_EGR_ERR_FRAME ,
- &value);
- if (err < 0) {
- printf("dpmac_get_counter: DPMAC_CNT_EGR_ERR_FRAME failed\n");
- return;
- }
- printf("DPMAC_CNT_EGR_ERR_FRAME =%lld\n", value);
+static void ldpaa_eth_dump_dpmac_stats(struct udevice *dev, u64 *data)
+{
+ int i;
+
+ printf("DPMAC counters:\n");
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+ printf(" %s: %llu\n", ldpaa_eth_dpmac_stat_strings[i], data[i]);
}
#endif
@@ -434,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;
@@ -478,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;
@@ -517,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;
@@ -526,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;
@@ -556,14 +501,30 @@ static void ldpaa_eth_stop(struct udevice *dev)
struct ldpaa_eth_priv *priv = dev_get_priv(dev);
struct phy_device *phydev = NULL;
int err = 0;
+ u64 *data;
if (!eth_is_active(dev))
return;
+ data = kzalloc(sizeof(u64) * LDPAA_ETH_DPNI_NUM_STATS, GFP_KERNEL);
+ if (data) {
+ ldpaa_eth_collect_dpni_stats(dev, data);
+ ldpaa_eth_add_dpni_stats(dev, data);
#ifdef DEBUG
- ldpaa_eth_get_dpni_counter();
- ldpaa_eth_get_dpmac_counter(dev);
+ ldpaa_eth_dump_dpni_stats(dev, data);
#endif
+ }
+ kfree(data);
+
+ data = kzalloc(sizeof(u64) * LDPAA_ETH_DPMAC_NUM_STATS, GFP_KERNEL);
+ if (data) {
+ ldpaa_eth_collect_dpmac_stats(dev, data);
+ ldpaa_eth_add_dpmac_stats(dev, data);
+#ifdef DEBUG
+ ldpaa_eth_dump_dpmac_stats(dev, data);
+#endif
+ }
+ kfree(data);
err = dprc_disconnect(dflt_mc_io, MC_CMD_NO_FLAGS,
dflt_dprc_handle, &dpmac_endpoint);
@@ -885,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;
@@ -897,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;
@@ -907,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;
@@ -963,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");
@@ -972,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;
@@ -1038,11 +998,47 @@ static int ldpaa_eth_of_to_plat(struct udevice *dev)
return 0;
}
+static int ldpaa_eth_get_sset_count(struct udevice *dev)
+{
+ return LDPAA_ETH_DPNI_NUM_STATS + LDPAA_ETH_DPMAC_NUM_STATS;
+}
+
+static void ldpaa_eth_get_strings(struct udevice *dev, u8 *data)
+{
+ u8 *p = data;
+ int i;
+
+ for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++) {
+ strlcpy(p, ldpaa_eth_dpni_stat_strings[i], ETH_GSTRING_LEN);
+ p += ETH_GSTRING_LEN;
+ }
+
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) {
+ strlcpy(p, ldpaa_eth_dpmac_stat_strings[i], ETH_GSTRING_LEN);
+ p += ETH_GSTRING_LEN;
+ }
+}
+
+static void ldpaa_eth_get_stats(struct udevice *dev, u64 *data)
+{
+ struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+ int i, j = 0;
+
+ for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+ *(data + j++) = priv->dpni_stats[i];
+
+ for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+ *(data + j++) = priv->dpmac_stats[i];
+}
+
static const struct eth_ops ldpaa_eth_ops = {
- .start = ldpaa_eth_open,
- .send = ldpaa_eth_tx,
- .recv = ldpaa_eth_pull_dequeue_rx,
- .stop = ldpaa_eth_stop,
+ .start = ldpaa_eth_open,
+ .send = ldpaa_eth_tx,
+ .recv = ldpaa_eth_pull_dequeue_rx,
+ .stop = ldpaa_eth_stop,
+ .get_sset_count = ldpaa_eth_get_sset_count,
+ .get_strings = ldpaa_eth_get_strings,
+ .get_stats = ldpaa_eth_get_stats,
};
static const struct udevice_id ldpaa_eth_of_ids[] = {
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.h b/drivers/net/ldpaa_eth/ldpaa_eth.h
index 16d0106..af082e3 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.h
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.h
@@ -115,6 +115,66 @@ struct ldpaa_fas {
LDPAA_ETH_FAS_MNLE | \
LDPAA_ETH_FAS_TIDE)
+static const char ldpaa_eth_dpni_stat_strings[][ETH_GSTRING_LEN] = {
+ "[dpni ] rx frames",
+ "[dpni ] rx bytes",
+ "[dpni ] rx mcast frames",
+ "[dpni ] rx mcast bytes",
+ "[dpni ] rx bcast frames",
+ "[dpni ] rx bcast bytes",
+ "[dpni ] tx frames",
+ "[dpni ] tx bytes",
+ "[dpni ] tx mcast frames",
+ "[dpni ] tx mcast bytes",
+ "[dpni ] tx bcast frames",
+ "[dpni ] tx bcast bytes",
+ "[dpni ] rx filtered frames",
+ "[dpni ] rx discarded frames",
+ "[dpni ] rx nobuffer discards",
+ "[dpni ] tx discarded frames",
+ "[dpni ] tx confirmed frames",
+ "[dpni ] tx dequeued bytes",
+ "[dpni ] tx dequeued frames",
+ "[dpni ] tx rejected bytes",
+ "[dpni ] tx rejected frames",
+ "[dpni ] tx pending frames",
+};
+
+#define LDPAA_ETH_DPNI_NUM_STATS ARRAY_SIZE(ldpaa_eth_dpni_stat_strings)
+
+static const char ldpaa_eth_dpmac_stat_strings[][ETH_GSTRING_LEN] = {
+ [DPMAC_CNT_ING_ALL_FRAME] = "[mac] rx all frames",
+ [DPMAC_CNT_ING_GOOD_FRAME] = "[mac] rx frames ok",
+ [DPMAC_CNT_ING_ERR_FRAME] = "[mac] rx frame errors",
+ [DPMAC_CNT_ING_FRAME_DISCARD] = "[mac] rx frame discards",
+ [DPMAC_CNT_ING_UCAST_FRAME] = "[mac] rx u-cast",
+ [DPMAC_CNT_ING_BCAST_FRAME] = "[mac] rx b-cast",
+ [DPMAC_CNT_ING_MCAST_FRAME] = "[mac] rx m-cast",
+ [DPMAC_CNT_ING_FRAME_64] = "[mac] rx 64 bytes",
+ [DPMAC_CNT_ING_FRAME_127] = "[mac] rx 65-127 bytes",
+ [DPMAC_CNT_ING_FRAME_255] = "[mac] rx 128-255 bytes",
+ [DPMAC_CNT_ING_FRAME_511] = "[mac] rx 256-511 bytes",
+ [DPMAC_CNT_ING_FRAME_1023] = "[mac] rx 512-1023 bytes",
+ [DPMAC_CNT_ING_FRAME_1518] = "[mac] rx 1024-1518 bytes",
+ [DPMAC_CNT_ING_FRAME_1519_MAX] = "[mac] rx 1519-max bytes",
+ [DPMAC_CNT_ING_FRAG] = "[mac] rx frags",
+ [DPMAC_CNT_ING_JABBER] = "[mac] rx jabber",
+ [DPMAC_CNT_ING_ALIGN_ERR] = "[mac] rx align errors",
+ [DPMAC_CNT_ING_OVERSIZED] = "[mac] rx oversized",
+ [DPMAC_CNT_ING_VALID_PAUSE_FRAME] = "[mac] rx pause",
+ [DPMAC_CNT_ING_BYTE] = "[mac] rx bytes",
+ [DPMAC_CNT_EGR_GOOD_FRAME] = "[mac] tx frames ok",
+ [DPMAC_CNT_EGR_UCAST_FRAME] = "[mac] tx u-cast",
+ [DPMAC_CNT_EGR_MCAST_FRAME] = "[mac] tx m-cast",
+ [DPMAC_CNT_EGR_BCAST_FRAME] = "[mac] tx b-cast",
+ [DPMAC_CNT_EGR_ERR_FRAME] = "[mac] tx frame errors",
+ [DPMAC_CNT_EGR_UNDERSIZED] = "[mac] tx undersized",
+ [DPMAC_CNT_EGR_VALID_PAUSE_FRAME] = "[mac] tx b-pause",
+ [DPMAC_CNT_EGR_BYTE] = "[mac] tx bytes",
+};
+
+#define LDPAA_ETH_DPMAC_NUM_STATS ARRAY_SIZE(ldpaa_eth_dpmac_stat_strings)
+
struct ldpaa_eth_priv {
struct phy_device *phy;
int phy_mode;
@@ -129,6 +189,10 @@ struct ldpaa_eth_priv {
uint16_t tx_flow_id;
enum ldpaa_eth_type type; /* 1G or 10G ethernet */
+
+ /* SW kept statistics */
+ u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS];
+ u64 dpmac_stats[LDPAA_ETH_DPMAC_NUM_STATS];
};
struct dprc_endpoint dpmac_endpoint;
diff --git a/include/configs/lx2160ardb.h b/include/configs/lx2160ardb.h
index 8cc4e0d..6404b35 100644
--- a/include/configs/lx2160ardb.h
+++ b/include/configs/lx2160ardb.h
@@ -11,6 +11,11 @@
/* RTC */
#define CFG_SYS_RTC_BUS_NUM 4
+#if defined(CONFIG_FSL_MC_ENET)
+#define AQR113C_PHY_ADDR1 0x0
+#define AQR113C_PHY_ADDR2 0x08
+#endif
+
/* EMC2305 */
#define I2C_MUX_CH_EMC2305 0x09
#define I2C_EMC2305_ADDR 0x4D
diff --git a/include/fsl-mc/fsl_dpbp.h b/include/fsl-mc/fsl_dpbp.h
index 2278ac9..3f3e6c4 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,160 +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)
+
+struct dpbp_cmd_open {
+ __le32 dpbp_id;
+};
-/* 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_destroy {
+ __le32 object_id;
+};
-/* Data Path Buffer Pool API
- * Contains initialization APIs and runtime control APIs for DPBP
- */
+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_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
- * @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
@@ -190,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_dpio.h b/include/fsl-mc/fsl_dpio.h
index 7788e19..375590f 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
@@ -21,31 +21,53 @@
#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) \
- 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
@@ -53,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
*/
@@ -101,143 +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);
-
-/**
- * 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_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
+ const struct dpio_cfg *cfg, u32 *obj_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_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
+ u32 object_id);
-/**
- * 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_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 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);
+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 */
diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h
index 1cea123..a8e9e46 100644
--- a/include/fsl-mc/fsl_dpmac.h
+++ b/include/fsl-mc/fsl_dpmac.h
@@ -21,74 +21,59 @@
#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
-/* 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_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 { \
- 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, 1, 0, 64, 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
@@ -96,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
@@ -171,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 */
@@ -248,65 +164,9 @@ 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_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 */
@@ -319,55 +179,25 @@ int dpmac_mdio_write(struct fsl_mc_io *mc_io,
#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
* @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.
@@ -412,6 +242,8 @@ int dpmac_set_link_state(struct fsl_mc_io *mc_io,
* @DPMAC_CNT_EGR_ERR_FRAME: counts frame transmitted with an error
* @DPMAC_CNT_ING_GOOD_FRAME: counts frame received without error, including
* pause frames.
+ * @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, including
+ * pause frames.
*/
enum dpmac_counter {
DPMAC_CNT_ING_FRAME_64,
@@ -440,37 +272,14 @@ enum dpmac_counter {
DPMAC_CNT_EGR_BCAST_FRAME,
DPMAC_CNT_EGR_UCAST_FRAME,
DPMAC_CNT_EGR_ERR_FRAME,
- DPMAC_CNT_ING_GOOD_FRAME
+ DPMAC_CNT_ING_GOOD_FRAME,
+ 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 */
diff --git a/include/fsl-mc/fsl_dpmng.h b/include/fsl-mc/fsl_dpmng.h
index 2148601..5dfc9ec 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_dpni.h b/include/fsl-mc/fsl_dpni.h
index e5e7338..9bc4754 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
@@ -24,303 +24,243 @@
#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
-/* 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_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 { \
- 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_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 { \
- 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_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 { \
- 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_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); \
- 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)->counter0); \
- MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->counter1); \
- MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->counter2); \
- MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->counter3); \
- MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->counter4); \
- MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->counter5); \
- MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->counter6); \
-} 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
+/* 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
* Contains initialization APIs and runtime control APIs for DPNI
@@ -336,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 */
@@ -442,57 +349,84 @@ enum dpni_queue_type {
DPNI_QUEUE_RX_ERR,
};
-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;
-};
-
/**
- * struct dpni_extended_cfg - Structure representing extended DPNI configuration
- * @tc_cfg: TCs configuration
- * @ipr_cfg: IP reassembly configuration
+ * 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_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;
+struct dpni_cfg {
+ 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;
};
/**
@@ -503,249 +437,108 @@ struct dpni_extended_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);
+int dpni_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 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_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 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,
- uint32_t cmd_flags,
- uint16_t 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;
-};
-
-/**
- * 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);
-
-/**
- * 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
+ 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;
};
-/**
- * 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);
+int dpni_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ struct dpni_attr *attr);
/* DPNI buffer layout modification options */
@@ -763,93 +556,45 @@ int dpni_set_errors_behavior(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_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
- * @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
@@ -864,107 +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_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]);
+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);
-/**
- * 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]);
-
-/**
- * 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]);
+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
@@ -985,137 +667,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 */
@@ -1126,21 +677,6 @@ struct dpni_queue_attr {
#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
* @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
@@ -1149,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,
@@ -1157,168 +693,194 @@ 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.
- */
-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_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.
+ * 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_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_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);
-struct dpni_statistics {
- /**
- * Page_0 statistics structure
- * @ingress_all_frames: Ingress frame count
- * @ingress_all_bytes: Ingress byte count
- * @ingress_multicast_frames: Ingress multicast frame count
- * @ingress_multicast_bytes: Ingress multicast byte count
- * @ingress_broadcast_frames: Ingress broadcast frame count
- * @ingress_broadcast_bytes: Ingress broadcast byte count
- *
- * Page_1 statistics structure
- * @egress_all_frames: Egress frame count
- * @egress_all_bytes: Egress byte count
- * @egress_multicast_frames: Egress multicast frame count
- * @egress_multicast_bytes: Egress multicast byte count
- * @egress_broadcast_frames: Egress broadcast frame count
- * @egress_broadcast_bytes: Egress broadcast byte count
- *
- * Page_2 statistics structure
- * @ingress_filtered_frames: Ingress filtered frame count
- * @ingress_discarded_frames: Ingress discarded frame count
- * @ingress_nobuffer_discards: Ingress discarded frame count due to
- * lack of buffers.
- * @egress_discarded_frames: Egress discarded frame count
- * @egress_confirmed_frames: Egress confirmed frame count
- */
-
- uint64_t counter0;
- uint64_t counter1;
- uint64_t counter2;
- uint64_t counter3;
- uint64_t counter4;
- uint64_t counter5;
- uint64_t counter6;
+struct dpni_queue_id {
+ u32 fqid;
+ u16 qdbin;
};
-/**
- * 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,
- struct dpni_statistics *stat);
+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);
+
+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
+
+/**
+ * union dpni_statistics - Union describing the DPNI statistics
+ * @page_0: Page_0 statistics structure
+ * @page_0.ingress_all_frames: Ingress frame count
+ * @page_0.ingress_all_bytes: Ingress byte count
+ * @page_0.ingress_multicast_frames: Ingress multicast frame count
+ * @page_0.ingress_multicast_bytes: Ingress multicast byte count
+ * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
+ * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
+ * @page_1: Page_1 statistics structure
+ * @page_1.egress_all_frames: Egress frame count
+ * @page_1.egress_all_bytes: Egress byte count
+ * @page_1.egress_multicast_frames: Egress multicast frame count
+ * @page_1.egress_multicast_bytes: Egress multicast byte count
+ * @page_1.egress_broadcast_frames: Egress broadcast frame count
+ * @page_1.egress_broadcast_bytes: Egress broadcast byte count
+ * @page_2: Page_2 statistics structure
+ * @page_2.ingress_filtered_frames: Ingress filtered frame count
+ * @page_2.ingress_discarded_frames: Ingress discarded frame count
+ * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
+ * lack of buffers
+ * @page_2.egress_discarded_frames: Egress discarded frame count
+ * @page_2.egress_confirmed_frames: Egress confirmed frame count
+ * @page_3: Page_3 statistics structure
+ * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
+ * dequeued from egress FQs
+ * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
+ * dequeued from egress FQs
+ * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
+ * egress frames whose enqueue was rejected
+ * @page_3.egress_reject_frames: Cumulative count of the number of egress
+ * frames whose enqueue was rejected
+ * @page_4: Page_4 statistics structure: congestion points
+ * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
+ * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
+ * @page_5: Page_5 statistics structure: policer
+ * @page_5.policer_cnt_red: NUmber of red colored frames
+ * @page_5.policer_cnt_yellow: number of yellow colored frames
+ * @page_5.policer_cnt_green: number of green colored frames
+ * @page_5.policer_cnt_re_red: number of recolored red frames
+ * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
+ * @page_6: Page_6 statistics structure
+ * @page_6.tx_pending_frames: total number of frames pending in egress FQs
+ * @raw: raw statistics structure, used to index counters
+ */
+union dpni_statistics {
+ struct {
+ u64 ingress_all_frames;
+ u64 ingress_all_bytes;
+ u64 ingress_multicast_frames;
+ u64 ingress_multicast_bytes;
+ u64 ingress_broadcast_frames;
+ u64 ingress_broadcast_bytes;
+ } page_0;
+ struct {
+ u64 egress_all_frames;
+ u64 egress_all_bytes;
+ u64 egress_multicast_frames;
+ u64 egress_multicast_bytes;
+ u64 egress_broadcast_frames;
+ u64 egress_broadcast_bytes;
+ } page_1;
+ struct {
+ u64 ingress_filtered_frames;
+ u64 ingress_discarded_frames;
+ u64 ingress_nobuffer_discards;
+ u64 egress_discarded_frames;
+ u64 egress_confirmed_frames;
+ } page_2;
+ struct {
+ u64 egress_dequeue_bytes;
+ u64 egress_dequeue_frames;
+ u64 egress_reject_bytes;
+ u64 egress_reject_frames;
+ } page_3;
+ struct {
+ u64 cgr_reject_frames;
+ u64 cgr_reject_bytes;
+ } page_4;
+ struct {
+ u64 policer_cnt_red;
+ u64 policer_cnt_yellow;
+ u64 policer_cnt_green;
+ u64 policer_cnt_re_red;
+ u64 policer_cnt_re_yellow;
+ } page_5;
+ struct {
+ u64 tx_pending_frames;
+ } page_6;
+ struct {
+ u64 counter[DPNI_STATISTICS_CNT];
+ } raw;
+};
-/**
- * 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);
+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 */
diff --git a/include/fsl-mc/fsl_dprc.h b/include/fsl-mc/fsl_dprc.h
index 950ecb0..fb95ac5 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
@@ -15,442 +15,82 @@
/* 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
#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_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 { \
- 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
@@ -463,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
@@ -472,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
@@ -563,395 +166,57 @@ int dprc_close(struct fsl_mc_io *mc_io,
* @label: Object's label
*/
struct dprc_cfg {
- uint16_t 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);
-
-/**
- * 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;
+ u16 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
+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);
-/**
- * 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
-};
+int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ int child_container_id);
/**
- * 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_connection_cfg - Connection configuration.
+ * Used for virtual connections only
+ * @committed_rate: Committed rate (Mbits/s)
+ * @max_rate: Maximum rate (Mbits/s)
*/
-struct dprc_region_desc {
- uint32_t base_offset;
- uint32_t size;
- uint32_t flags;
- enum dprc_region_type type;
+struct dprc_connection_cfg {
+ u32 committed_rate;
+ u32 max_rate;
};
/**
- * 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
- * @type: Endpoint object type: NULL terminated string
- * @id: Endpoint object ID
- * @if_id: Interface ID; should be set for endpoints with multiple
+ * @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;
-};
-
-/**
- * struct dprc_connection_cfg - Connection configuration.
- * Used for virtual connections only
- * @committed_rate: Committed rate (Mbits/s)
- * @max_rate: Maximum rate (Mbits/s)
- */
-struct dprc_connection_cfg {
- uint32_t committed_rate;
- uint32_t max_rate;
+ char type[16];
+ int id;
+ u16 if_id;
};
-/**
- * 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,
- uint32_t cmd_flags,
- uint16_t token,
- const struct dprc_endpoint *endpoint1,
- const struct dprc_endpoint *endpoint2,
- const struct dprc_connection_cfg *cfg);
+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_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_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ const struct dprc_endpoint *endpoint);
-/**
-* 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_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ const struct dprc_endpoint *endpoint1,
+ struct dprc_endpoint *endpoint2, int *state);
-/**
- * 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_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
+ u16 *major_ver, u16 *minor_ver);
#endif /* _FSL_DPRC_H */
diff --git a/include/fsl-mc/fsl_dpsparser.h b/include/fsl-mc/fsl_dpsparser.h
index 48fb495..9619bb1 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 */
diff --git a/include/fsl-mc/fsl_mc_cmd.h b/include/fsl-mc/fsl_mc_cmd.h
index 591cda9..c239595 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];
@@ -74,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)
@@ -179,4 +165,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 */
diff --git a/include/net.h b/include/net.h
index 785cb10..e254df7 100644
--- a/include/net.h
+++ b/include/net.h
@@ -167,6 +167,9 @@ enum eth_recv_flags {
* to the network stack. This function should fill in the
* eth_pdata::enetaddr field - optional
* set_promisc: Enable or Disable promiscuous mode
+ * get_sset_count: Number of statistics counters
+ * get_string: Names of the statistic counters
+ * get_stats: The values of the statistic counters
*/
struct eth_ops {
int (*start)(struct udevice *dev);
@@ -178,6 +181,9 @@ struct eth_ops {
int (*write_hwaddr)(struct udevice *dev);
int (*read_rom_hwaddr)(struct udevice *dev);
int (*set_promisc)(struct udevice *dev, bool enable);
+ int (*get_sset_count)(struct udevice *dev);
+ void (*get_strings)(struct udevice *dev, u8 *data);
+ void (*get_stats)(struct udevice *dev, u64 *data);
};
#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)
diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index dd78e57..f64c68e 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -381,7 +381,7 @@ static int dsa_post_bind(struct udevice *dev)
node = ofnode_find_subnode(node, "ports");
if (!ofnode_valid(node))
- node = ofnode_find_subnode(node, "ethernet-ports");
+ node = ofnode_find_subnode(dev_ofnode(dev), "ethernet-ports");
if (!ofnode_valid(node)) {
dev_err(dev, "ports node is missing under DSA device!\n");
return -EINVAL;