From: Ankur Dwivedi <adwiv...@marvell.com>

Adding support for changing MTU of a representor port. This is required
to allow processing jumbo packets.
Using this operation, MTU of representor port is only changed, no MTU
change shall be propagated to the respective represented port.

Signed-off-by: Ankur Dwivedi <adwiv...@marvell.com>
---
V2:
 * Better commit message
 * Added to release notes

V3:
 * Minor correction in release notes

 doc/guides/rel_notes/release_24_07.rst |  2 ++
 drivers/net/cnxk/cnxk_rep.h            |  1 +
 drivers/net/cnxk/cnxk_rep_ops.c        | 34 +++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_24_07.rst 
b/doc/guides/rel_notes/release_24_07.rst
index 7c88de381b..adf772f488 100644
--- a/doc/guides/rel_notes/release_24_07.rst
+++ b/doc/guides/rel_notes/release_24_07.rst
@@ -92,6 +92,8 @@ New Features
   * Added support disabling custom meta aura
     and separately use custom SA action support.
 
+  * Added MTU update for port representor.
+
 * **Updated NVIDIA mlx5 driver.**
 
   * Added match with Tx queue.
diff --git a/drivers/net/cnxk/cnxk_rep.h b/drivers/net/cnxk/cnxk_rep.h
index 9bdea47bd4..ad89649702 100644
--- a/drivers/net/cnxk/cnxk_rep.h
+++ b/drivers/net/cnxk/cnxk_rep.h
@@ -146,5 +146,6 @@ int cnxk_rep_xstats_get_by_id(struct rte_eth_dev *eth_dev, 
const uint64_t *ids,
                              unsigned int n);
 int cnxk_rep_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, const 
uint64_t *ids,
                                    struct rte_eth_xstat_name *xstats_names, 
unsigned int n);
+int cnxk_rep_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
 
 #endif /* __CNXK_REP_H__ */
diff --git a/drivers/net/cnxk/cnxk_rep_ops.c b/drivers/net/cnxk/cnxk_rep_ops.c
index 8bcb689468..888842fa90 100644
--- a/drivers/net/cnxk/cnxk_rep_ops.c
+++ b/drivers/net/cnxk/cnxk_rep_ops.c
@@ -821,6 +821,37 @@ cnxk_rep_xstats_get_names_by_id(__rte_unused struct 
rte_eth_dev *eth_dev, const
        return n;
 }
 
+int
+cnxk_rep_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
+{
+       struct cnxk_rep_dev *rep_dev = cnxk_rep_pmd_priv(eth_dev);
+       uint32_t frame_size = mtu + CNXK_NIX_L2_OVERHEAD;
+       int rc = -EINVAL;
+
+       /* Check if MTU is within the allowed range */
+       if ((frame_size - RTE_ETHER_CRC_LEN) < NIX_MIN_HW_FRS) {
+               plt_err("MTU is lesser than minimum");
+               goto exit;
+       }
+
+       if ((frame_size - RTE_ETHER_CRC_LEN) >
+           ((uint32_t)roc_nix_max_pkt_len(&rep_dev->parent_dev->nix))) {
+               plt_err("MTU is greater than maximum");
+               goto exit;
+       }
+
+       frame_size -= RTE_ETHER_CRC_LEN;
+
+       /* Set frame size on Rx */
+       rc = roc_nix_mac_max_rx_len_set(&rep_dev->parent_dev->nix, frame_size);
+       if (rc) {
+               plt_err("Failed to max Rx frame length, rc=%d", rc);
+               goto exit;
+       }
+exit:
+       return rc;
+}
+
 /* CNXK platform representor dev ops */
 struct eth_dev_ops cnxk_rep_dev_ops = {
        .dev_infos_get = cnxk_rep_dev_info_get,
@@ -844,5 +875,6 @@ struct eth_dev_ops cnxk_rep_dev_ops = {
        .xstats_reset = cnxk_rep_xstats_reset,
        .xstats_get_names = cnxk_rep_xstats_get_names,
        .xstats_get_by_id = cnxk_rep_xstats_get_by_id,
-       .xstats_get_names_by_id = cnxk_rep_xstats_get_names_by_id
+       .xstats_get_names_by_id = cnxk_rep_xstats_get_names_by_id,
+       .mtu_set = cnxk_rep_mtu_set
 };
-- 
2.18.0

Reply via email to