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_tm.c        | 16 +++++++++++-----
 drivers/net/dpaa2/mc/dpni.c         | 11 +++++++++--
 drivers/net/dpaa2/mc/fsl_dpni.h     |  8 ++++++--
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h |  3 ++-
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c
index 36e815c356..0e1b2c5b54 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,20 @@
 #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 (priv->dpni_ver_major == 8 && priv->dpni_ver_minor >= 7)
+               return (dpaa2_svr_family == SVR_LX2160A) ? 229375 : (64 * 1024);
+
+       return (64 * 1024);
+}
+
 int
 dpaa2_tm_init(struct rte_eth_dev *dev)
 {
@@ -283,7 +289,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 +299,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..8913b408e7 100644
--- a/drivers/net/dpaa2/mc/fsl_dpni.h
+++ b/drivers/net/dpaa2/mc/fsl_dpni.h
@@ -830,14 +830,18 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io,
                        uint16_t token,
                        struct dpni_link_state *state);
 
+#define DPNI_BURST_LO(burst)   ((burst) & GENMASK(15, 0))
+#define DPNI_BURST_HI(burst)   ((burst) >> 16)
+
 /**
  * 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..6b396ca7cc 100644
--- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
+++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
@@ -394,7 +394,8 @@ struct dpni_rsp_get_link_state {
 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

Reply via email to