DM_MDIO/CMD for ls1046afrwy
sync APIs for fsl-mc
ldpaa_eth update
lx2160ardb recv support.
net: dsa fix of fallback lookup
This commit is contained in:
Tom Rini 2023-06-15 11:02:22 -04:00
commit 5ac10c00ed
31 changed files with 2593 additions and 3558 deletions

View file

@ -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>;
};
};
};

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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

View file

@ -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 */

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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);
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_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_attr *attr)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_ATTR,
cmd_flags,
token);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
DPMAC_RSP_GET_ATTRIBUTES(cmd, attr);
return 0;
}
int dpmac_mdio_read(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_mdio_cfg *cfg)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_READ,
cmd_flags,
token);
DPMAC_CMD_MDIO_READ(cmd, cfg);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
DPMAC_RSP_MDIO_READ(cmd, cfg->data);
return 0;
}
int dpmac_mdio_write(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_mdio_cfg *cfg)
{
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_WRITE,
cmd_flags,
token);
DPMAC_CMD_MDIO_WRITE(cmd, cfg);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_cfg *cfg)
{
struct mc_command cmd = { 0 };
int err = 0;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_LINK_CFG,
cmd_flags,
token);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
DPMAC_RSP_GET_LINK_CFG(cmd, cfg);
return 0;
}
int dpmac_set_link_state(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
/**
* 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;

View file

@ -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;
}

View file

@ -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,98 +485,171 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io,
return err;
/* retrieve response parameters */
DPNI_RSP_GET_LINK_STATE(cmd, state);
rsp_params = (struct dpni_rsp_get_link_state *)cmd.params;
state->up = dpni_get_field(rsp_params->flags, LINK_STATE);
state->state_valid = dpni_get_field(rsp_params->flags, STATE_VALID);
state->rate = le32_to_cpu(rsp_params->rate);
state->options = le64_to_cpu(rsp_params->options);
state->supported = le64_to_cpu(rsp_params->supported);
state->advertising = le64_to_cpu(rsp_params->advertising);
return 0;
}
int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const uint8_t mac_addr[6])
{
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
cmd_flags,
token);
DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t mac_addr[6])
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
cmd_flags,
token);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr);
return 0;
}
int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const uint8_t mac_addr[6])
/**
* dpni_add_mac_addr() - Add MAC address filter
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPNI object
* @mac_addr: MAC address to add
* @flags :0 - tc_id and flow_id will be ignored.
* Pkt with this mac_id will be passed to the next
* classification stages
* DPNI_MAC_SET_QUEUE_ACTION
* Pkt with this mac will be forward directly to
* queue defined by the tc_id and flow_id
* @tc_id : Traffic class selection (0-7)
* @flow_id : Selects the specific queue out of the set allocated for the
* same as tc_id. Value must be in range 0 to NUM_QUEUES - 1
* Return: '0' on Success; Error code otherwise.
*/
int dpni_add_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
const u8 mac_addr[6], u8 flags,
u8 tc_id, u8 flow_id)
{
struct dpni_cmd_add_mac_addr *cmd_params;
struct mc_command cmd = { 0 };
int i;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
cmd_flags,
token);
DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params;
cmd_params->flags = flags;
cmd_params->tc_id = tc_id;
cmd_params->fq_id = flow_id;
for (i = 0; i < 6; i++)
cmd_params->mac_addr[i] = mac_addr[5 - i];
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const uint8_t mac_addr[6])
{
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
cmd_flags,
token);
DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpni_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
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);
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0;
}
/**
* 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);
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 */
return mc_send_command(mc_io, &cmd);
}
/**
* 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);
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 */
err = mc_send_command(mc_io, &cmd);
@ -416,112 +657,107 @@ int dpni_get_api_version(struct fsl_mc_io *mc_io,
return err;
/* retrieve response parameters */
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
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_queue(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpni_queue_type type,
uint8_t tc,
uint8_t index,
const struct dpni_queue *queue)
{
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
cmd_flags,
token);
DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue);
/* 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)
{
struct mc_command cmd = { 0 };
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);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
DPNI_RSP_GET_QUEUE(cmd, queue);
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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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 */

View file

@ -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;

View file

@ -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;

View file

@ -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++;
}
}
static void ldpaa_eth_get_dpni_counter(void)
{
int err = 0;
unsigned int page = 0;
struct dpni_statistics dpni_stats;
printf("DPNI counters ..\n");
for (page = 0; page < 3; page++) {
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, page,
&dpni_stats);
if (err < 0) {
printf("dpni_get_statistics: failed:");
printf("%d for page[%d]\n", err, page);
return;
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);
}
print_dpni_stats(dpni_statistics[page], dpni_stats);
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_dpmac_counter(struct udevice *dev)
static void ldpaa_eth_add_dpni_stats(struct udevice *dev, u64 *data)
{
struct ldpaa_eth_priv *priv = dev_get_priv(dev);
int err = 0;
int i;
for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
priv->dpni_stats[i] += data[i];
}
static void ldpaa_eth_collect_dpmac_stats(struct udevice *dev, u64 *data)
{
struct ldpaa_eth_priv *priv = dev_get_priv(dev);
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[] = {

View file

@ -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;

View file

@ -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

View file

@ -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)
/* cmd, param, offset, width, type, arg_name */
#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
do { \
MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
} while (0)
struct dpbp_cmd_open {
__le32 dpbp_id;
};
/* Data Path Buffer Pool API
* Contains initialization APIs and runtime control APIs for DPBP
*/
struct dpbp_cmd_destroy {
__le32 object_id;
};
struct dpbp_rsp_get_attributes {
__le16 pad;
__le16 bpid;
__le32 id;
};
#pragma pack(pop)
struct fsl_mc_io;
/**
* dpbp_open() - Open a control session for the specified object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @dpbp_id: DPBP unique ID
* @token: Returned token; use in subsequent API calls
*
* This function can be used to open a control session for an
* already created object; an object may have been declared in
* the DPL or by calling the dpbp_create function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent commands for
* this specific object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int dpbp_id,
uint16_t *token);
int dpbp_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpbp_id, u16 *token);
/**
* dpbp_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* After this function is called, no further operations are
* allowed on the object without opening a new control session.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
int dpbp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/**
* struct dpbp_cfg - Structure representing DPBP configuration
* @options: place holder
*/
struct dpbp_cfg {
uint32_t options;
u32 options;
};
/**
* dpbp_create() - Create the DPBP object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @token: Returned token; use in subsequent API calls
*
* Create the DPBP object, allocate required resources and
* perform required initialization.
*
* The object can be created either by declaring it in the
* DPL file, or by calling this function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent calls to
* this specific object. For objects that are created using the
* DPL file, call dpbp_open function to get an authentication
* token first.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_create(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
const struct dpbp_cfg *cfg,
uint32_t *obj_id);
int dpbp_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
const struct dpbp_cfg *cfg, u32 *obj_id);
/**
* dpbp_destroy() - Destroy the DPBP object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; error code otherwise.
*/
int dpbp_destroy(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
uint32_t obj_id);
int dpbp_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
u32 obj_id);
/**
* dpbp_enable() - Enable the DPBP.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/**
* dpbp_disable() - Disable the DPBP.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_disable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* dpbp_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);
int dpbp_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 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_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
u16 *major_ver, u16 *minor_ver);
#endif /* __FSL_DPBP_H */

View file

@ -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)
/* 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)
/* 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)
#pragma pack(push, 1)
struct dpio_cmd_open {
__le32 dpio_id;
};
/* 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)
#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);
int dpio_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
const struct dpio_cfg *cfg, u32 *obj_id);
/**
* dpio_destroy() - Destroy the DPIO object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @token: Authentication token.
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @obj_id: Object ID of DPIO
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_destroy(struct fsl_mc_io *mc_io,
uint16_t token,
uint32_t cmd_flags,
uint32_t obj_id);
int dpio_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
u32 object_id);
/**
* dpio_enable() - Enable the DPIO, allow I/O portal operations.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
/**
* dpio_disable() - Disable the DPIO, stop any I/O portal operation.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_disable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* 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 */

View file

@ -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)
/* 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)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_OPEN(cmd, dpmac_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id)
#pragma pack(push, 1)
struct dpmac_cmd_open {
__le32 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)
struct dpmac_cmd_create {
__le32 mac_id;
};
/* 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)
struct dpmac_cmd_destroy {
__le32 dpmac_id;
};
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_RSP_MDIO_READ(cmd, data) \
MC_RSP_OP(cmd, 0, 16, 16, uint16_t, data)
#define DPMAC_STATE_SIZE 1
#define DPMAC_STATE_SHIFT 0
#define DPMAC_STATE_VALID_SIZE 1
#define DPMAC_STATE_VALID_SHIFT 1
/* 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)
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;
};
/* 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)
struct dpmac_cmd_get_counter {
u8 type;
};
/* 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)
struct dpmac_rsp_get_counter {
__le64 pad;
__le64 counter;
};
/* 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)
#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 */
@ -318,56 +178,26 @@ int dpmac_mdio_write(struct fsl_mc_io *mc_io,
/* Enable a-symmetric pause frames */
#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
/**
* struct dpmac_link_cfg - Structure representing DPMAC link configuration
* @rate: Link's rate - in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
*/
struct dpmac_link_cfg {
uint32_t rate;
uint64_t options;
};
/**
* dpmac_get_link_cfg() - Get Ethernet link configuration
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @cfg: Returned structure with the link configuration
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_cfg *cfg);
/**
* struct dpmac_link_state - DPMAC link configuration request
* @rate: Rate in Mbps
* @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 */

View file

@ -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 */

File diff suppressed because it is too large Load diff

View file

@ -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)
#pragma pack(push, 1)
struct dprc_cmd_open {
__le32 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)
struct dprc_cmd_create_container {
__le32 options;
__le32 icid;
__le32 pad1;
__le32 portal_id;
u8 label[16];
};
/* 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)
struct dprc_rsp_create_container {
__le64 pad0;
__le32 child_container_id;
__le32 pad1;
__le64 child_portal_addr;
};
/* 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)
struct dprc_cmd_destroy_container {
__le32 child_container_id;
};
/* 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)
struct dprc_cmd_connect {
__le32 ep1_id;
__le16 ep1_interface_id;
__le16 pad0;
/* 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)
__le32 ep2_id;
__le16 ep2_interface_id;
__le16 pad1;
/* 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)
u8 ep1_type[16];
/* 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)
__le32 max_rate;
__le32 committed_rate;
/* 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)
u8 ep2_type[16];
};
/* 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)
struct dprc_cmd_disconnect {
__le32 id;
__le32 interface_id;
u8 type[16];
};
/* 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)
struct dprc_cmd_get_connection {
__le32 ep1_id;
__le16 ep1_interface_id;
__le16 pad;
/* 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)
u8 ep1_type[16];
};
/* 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)
struct dprc_rsp_get_connection {
__le64 pad[3];
__le32 ep2_id;
__le16 ep2_interface_id;
__le16 pad1;
u8 ep2_type[16];
__le32 state;
};
/* 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(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,314 +166,18 @@ int dprc_close(struct fsl_mc_io *mc_io,
* @label: Object's label
*/
struct dprc_cfg {
uint16_t icid;
u16 icid;
int portal_id;
uint64_t options;
char label[16];
};
/**
* dprc_create_container() - Create child container
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @cfg: Child container configuration
* @child_container_id: Returned child container ID
* @child_portal_offset: Returned child portal offset from MC portal base
*
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_create_container(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dprc_cfg *cfg,
int *child_container_id,
uint64_t *child_portal_offset);
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);
/**
* 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;
int portal_id;
uint64_t options;
};
/**
* dprc_get_attributes() - Obtains container attributes
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @attributes: Returned container attributes
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dprc_attributes *attributes);
/**
* dprc_get_obj_count() - Obtains the number of objects in the DPRC
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_count: Number of objects assigned to the DPRC
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj_count(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int *obj_count);
/* Objects Attributes Flags */
/* Opened state - Indicates that an object is open by at least one owner */
#define DPRC_OBJ_STATE_OPEN 0x00000001
/* Plugged state - Indicates that the object is plugged */
#define DPRC_OBJ_STATE_PLUGGED 0x00000002
/**
* Shareability flag - Object flag indicating no memory shareability.
* the object generates memory accesses that are non coherent with other
* masters;
* user is responsible for proper memory handling through IOMMU configuration.
*/
#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
/**
* struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
* @type: Type of object: NULL terminated string
* @id: ID of logical object resource
* @vendor: Object vendor identifier
* @ver_major: Major version number
* @ver_minor: Minor version number
* @irq_count: Number of interrupts supported by the object
* @region_count: Number of mappable regions supported by the object
* @state: Object state: combination of DPRC_OBJ_STATE_ states
* @label: Object label
* @flags: Object's flags
*/
struct dprc_obj_desc {
char type[16];
int id;
uint16_t vendor;
uint16_t ver_major;
uint16_t ver_minor;
uint8_t irq_count;
uint8_t region_count;
uint32_t state;
char label[16];
uint16_t flags;
};
/**
* dprc_get_obj() - Get general information on an object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_index: Index of the object to be queried (< obj_count)
* @obj_desc: Returns the requested object descriptor
*
* The object descriptors are retrieved one by one by incrementing
* obj_index up to (not including) the value of obj_count returned
* from dprc_get_obj_count(). dprc_get_obj_count() must
* be called prior to dprc_get_obj().
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int obj_index,
struct dprc_obj_desc *obj_desc);
/**
* dprc_get_res_count() - Obtains the number of free resources that are
* assigned to this container, by pool type
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @type: pool type
* @res_count: Returned number of free resources of the given
* resource type that are assigned to this DPRC
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_res_count(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *type,
int *res_count);
/**
* enum dprc_iter_status - Iteration status
* @DPRC_ITER_STATUS_FIRST: Perform first iteration
* @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
* @DPRC_ITER_STATUS_LAST: Indicates last iteration
*/
enum dprc_iter_status {
DPRC_ITER_STATUS_FIRST = 0,
DPRC_ITER_STATUS_MORE = 1,
DPRC_ITER_STATUS_LAST = 2
};
/**
* struct dprc_res_ids_range_desc - Resource ID range descriptor
* @base_id: Base resource ID of this range
* @last_id: Last resource ID of this range
* @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
* first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
* additional iterations are needed, until the returned marker is
* DPRC_ITER_STATUS_LAST
*/
struct dprc_res_ids_range_desc {
int base_id;
int last_id;
enum dprc_iter_status iter_status;
};
/**
* dprc_get_res_ids() - Obtains IDs of free resources in the container
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @type: pool type
* @range_desc: range descriptor
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_res_ids(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *type,
struct dprc_res_ids_range_desc *range_desc);
/* Region flags */
/* Cacheable - Indicates that region should be mapped as cacheable */
#define DPRC_REGION_CACHEABLE 0x00000001
/**
* enum dprc_region_type - Region type
* @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
* @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
*/
enum dprc_region_type {
DPRC_REGION_TYPE_MC_PORTAL,
DPRC_REGION_TYPE_QBMAN_PORTAL
};
/**
* struct dprc_region_desc - Mappable region descriptor
* @base_offset: Region offset from region's base address.
* For DPMCP and DPRC objects, region base is offset from SoC MC portals
* base address; For DPIO, region base is offset from SoC QMan portals
* base address
* @size: Region size (in bytes)
* @flags: Region attributes
* @type: Portal region type
*/
struct dprc_region_desc {
uint32_t base_offset;
uint32_t size;
uint32_t flags;
enum dprc_region_type type;
};
/**
* dprc_get_obj_region() - Get region information for a specified object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_type: Object type as returned in dprc_get_obj()
* @obj_id: Unique object instance as returned in dprc_get_obj()
* @region_index: The specific region to query
* @region_desc: Returns the requested region descriptor
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj_region(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *obj_type,
int obj_id,
uint8_t region_index,
struct dprc_region_desc *region_desc);
/**
* struct dprc_endpoint - Endpoint description for link connect/disconnect
* operations
* @type: Endpoint object type: NULL terminated string
* @id: Endpoint object ID
* @if_id: Interface ID; should be set for endpoints with multiple
* interfaces ("dpsw", "dpdmux"); for others, always set to 0
*/
struct dprc_endpoint {
char type[16];
int id;
uint16_t if_id;
};
int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
int child_container_id);
/**
* struct dprc_connection_cfg - Connection configuration.
@ -879,79 +186,37 @@ struct dprc_endpoint {
* @max_rate: Maximum rate (Mbits/s)
*/
struct dprc_connection_cfg {
uint32_t committed_rate;
uint32_t max_rate;
u32 committed_rate;
u32 max_rate;
};
/**
* dprc_connect() - Connect two endpoints to create a network link between them
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint1: Endpoint 1 configuration parameters
* @endpoint2: Endpoint 2 configuration parameters
* @cfg: Connection configuration. The connection configuration is ignored for
* connections made to DPMAC objects, where rate is retrieved from the
* MAC configuration.
*
* Return: '0' on Success; Error code otherwise.
* struct dprc_endpoint - Endpoint description for link connect/disconnect
* operations
* @type: Endpoint object type: NULL terminated string
* @id: Endpoint object ID
* @if_id: Interface ID; should be set for endpoints with multiple
* interfaces ("dpsw", "dpdmux"); for others, always set to 0
*/
int dprc_connect(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint1,
const struct dprc_endpoint *endpoint2,
const struct dprc_connection_cfg *cfg);
struct dprc_endpoint {
char type[16];
int id;
u16 if_id;
};
/**
* dprc_disconnect() - Disconnect one endpoint to remove its network connection
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint: Endpoint configuration parameters
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_disconnect(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint);
int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
const struct dprc_endpoint *endpoint1,
const struct dprc_endpoint *endpoint2,
const struct dprc_connection_cfg *cfg);
/**
* dprc_get_connection() - Get connected endpoint and link status if connection
* exists.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint1: Endpoint 1 configuration parameters
* @endpoint2: Returned endpoint 2 configuration parameters
* @state: Returned link state:
* 1 - link is up;
* 0 - link is down;
* -1 - no connection (endpoint2 information is irrelevant)
*
* Return: '0' on Success; -ENAVAIL if connection does not exist.
*/
int dprc_get_connection(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint1,
struct dprc_endpoint *endpoint2,
int *state);
int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
const struct dprc_endpoint *endpoint);
/**
* dprc_get_api_version - Retrieve DPRC Major and Minor version info.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: DPRC major version
* @minor_ver: DPRC minor version
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
const struct dprc_endpoint *endpoint1,
struct dprc_endpoint *endpoint2, int *state);
int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
u16 *major_ver, u16 *minor_ver);
#endif /* _FSL_DPRC_H */

View file

@ -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);
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);
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_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);
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_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
u16 *major_ver, u16 *minor_ver);
#endif /* _FSL_DPSPARSER_H */

View file

@ -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 */

View file

@ -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)

View file

@ -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;