From: Gagandeep Singh <[email protected]> Make burst size checks and MC command fields SoC-aware, enabling bursts larger than 64K on LX2160A with dpni version 8.7+.
The max_burst_size field in dpni_tx_shaping_cfg is widened to uint32_t and the MC command struct is updated to split the value across two 16-bit fields using the new DPNI_BURST_LO/HI macros. Signed-off-by: Prashant Gupta <[email protected]> Signed-off-by: Gagandeep Singh <[email protected]> --- drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_tm.c | 17 ++++++++++++----- drivers/net/dpaa2/mc/dpni.c | 11 +++++++++-- drivers/net/dpaa2/mc/fsl_dpni.h | 5 +++-- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 6 +++++- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index 149954fb6b..bec1096850 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -462,6 +462,8 @@ struct dpaa2_dev_priv { #define DPNI_GET_MAC_SUPPORTED_IFS_VER_MAJOR 8 #define DPNI_GET_MAC_SUPPORTED_IFS_VER_MINOR 6 +#define DPNI_TX_BURST_LARGE_VER_MAJOR 8 +#define DPNI_TX_BURST_LARGE_VER_MINOR 7 static inline int dpaa2_dev_cmp_dpni_ver(struct dpaa2_dev_priv *priv, uint16_t ver_major, uint16_t ver_minor) diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c index 36e815c356..0275c2a010 100644 --- a/drivers/net/dpaa2/dpaa2_tm.c +++ b/drivers/net/dpaa2/dpaa2_tm.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2020-2024 NXP + * Copyright 2020-2026 NXP */ #include <rte_ethdev.h> @@ -10,14 +10,21 @@ #include "dpaa2_pmd_logs.h" #include <dpaa2_hw_dpio.h> -#define DPAA2_BURST_MAX (64 * 1024) - #define DPAA2_SHAPER_MIN_RATE 0 #define DPAA2_SHAPER_MAX_RATE 107374182400ull #define DPAA2_WEIGHT_MAX 24701 #define DPAA2_PKT_ADJUST_LEN_MIN 0 #define DPAA2_PKT_ADJUST_LEN_MAX 0x7ff +static inline uint32_t dpaa2_get_burst_max(struct dpaa2_dev_priv *priv) +{ + if (dpaa2_dev_cmp_dpni_ver(priv, DPNI_TX_BURST_LARGE_VER_MAJOR, + DPNI_TX_BURST_LARGE_VER_MINOR) >= 0) + return (dpaa2_svr_family == SVR_LX2160A) ? 0x37FFF : 0xF7FF; + + return 0xF7FF; +} + int dpaa2_tm_init(struct rte_eth_dev *dev) { @@ -283,7 +290,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id, RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE, NULL, "committed rate is out of range\n"); - if (params->committed.size > DPAA2_BURST_MAX) + if (params->committed.size > dpaa2_get_burst_max(priv)) return -rte_tm_error_set(error, EINVAL, RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE, NULL, "committed size is out of range\n"); @@ -293,7 +300,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id, RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE, NULL, "Peak rate is out of range\n"); - if (params->peak.size > DPAA2_BURST_MAX) + if (params->peak.size > dpaa2_get_burst_max(priv)) return -rte_tm_error_set(error, EINVAL, RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE, NULL, "Peak size is out of range\n"); diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c index d0a9fefd31..17275b7195 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -1106,6 +1106,7 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io, { struct dpni_cmd_set_tx_shaping *cmd_params; struct mc_command cmd = { 0 }; + uint32_t tx_cr_burst, tx_er_burst; int coupled, lni_shaper; uint8_t channel_id; uint16_t oal; @@ -1115,10 +1116,16 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io, cmd_flags, token); cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params; + tx_cr_burst = tx_cr_shaper->max_burst_size; + tx_er_burst = tx_er_shaper->max_burst_size; cmd_params->tx_cr_max_burst_size = - cpu_to_le16(tx_cr_shaper->max_burst_size); + cpu_to_le16(DPNI_BURST_LO(tx_cr_burst)); cmd_params->tx_er_max_burst_size = - cpu_to_le16(tx_er_shaper->max_burst_size); + cpu_to_le16(DPNI_BURST_LO(tx_er_burst)); + cmd_params->tx_cr_max_burst_size_hi = + cpu_to_le16(DPNI_BURST_HI(tx_cr_burst)); + cmd_params->tx_er_max_burst_size_hi = + cpu_to_le16(DPNI_BURST_HI(tx_er_burst)); cmd_params->tx_cr_rate_limit = cpu_to_le32(tx_cr_shaper->rate_limit); cmd_params->tx_er_rate_limit = diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h index 42d633eaf8..7bcbad6859 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni.h +++ b/drivers/net/dpaa2/mc/fsl_dpni.h @@ -833,11 +833,12 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io, /** * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration * @rate_limit: Rate in Mbits/s - * @max_burst_size: Burst size in bytes (up to 64KB) + * @max_burst_size: Burst size in bytes. Limits depend on the SoC (0x37FFF + * for LX2160A, 0xF7FF for all others) */ struct dpni_tx_shaping_cfg { uint32_t rate_limit; - uint16_t max_burst_size; + uint32_t max_burst_size; }; /** diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h index bb4939031b..cc7bf42a4e 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h @@ -391,10 +391,14 @@ struct dpni_rsp_get_link_state { #define DPNI_LNI_SHAPER_SHIFT 1 #define DPNI_LNI_SHAPER_SIZE 1 +#define DPNI_BURST_LO(burst) ((burst) & GENMASK(15, 0)) +#define DPNI_BURST_HI(burst) ((burst) >> 16) + struct dpni_cmd_set_tx_shaping { uint16_t tx_cr_max_burst_size; uint16_t tx_er_max_burst_size; - uint32_t pad; + uint16_t tx_cr_max_burst_size_hi; + uint16_t tx_er_max_burst_size_hi; uint32_t tx_cr_rate_limit; uint32_t tx_er_rate_limit; /* from LSB: coupled:1, lni_shaper: 1*/ -- 2.43.0

