DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>,
	Harman Kalra <hkalra@marvell.com>
Cc: <dev@dpdk.org>, <jerinj@marvell.com>,
	Ankur Dwivedi <adwivedi@marvell.com>
Subject: [PATCH 2/6] net/cnxk: add MTU set ops
Date: Mon, 24 Jun 2024 13:18:17 +0530	[thread overview]
Message-ID: <20240624074822.88955-2-hkalra@marvell.com> (raw)
In-Reply-To: <20240624074822.88955-1-hkalra@marvell.com>

From: Ankur Dwivedi <adwivedi@marvell.com>

Implement mtu set ops for representor ports

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 drivers/net/cnxk/cnxk_rep.h     |  1 +
 drivers/net/cnxk/cnxk_rep_ops.c | 34 ++++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

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	other threads:[~2024-06-24  7:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  7:48 [PATCH 1/6] net/cnxk: stale offload flag reset Harman Kalra
2024-06-24  7:48 ` Harman Kalra [this message]
2024-06-24  7:48 ` [PATCH 3/6] net/cnxk: add multi seg support in eswitch Harman Kalra
2024-06-24  7:48 ` [PATCH 4/6] net/cnxk: increment number of flow pattern Harman Kalra
2024-06-24  9:14   ` Jerin Jacob
2024-06-24  7:48 ` [PATCH 5/6] net/cnxk: update processing ready message Harman Kalra
2024-06-24  7:48 ` [PATCH 6/6] common/cnxk: flow aginig delaying app shutdown Harman Kalra
2024-06-24  9:13 ` [PATCH 1/6] net/cnxk: stale offload flag reset Jerin Jacob
2024-06-24 11:57 ` [PATCH v2 1/5] net/cnxk: fix " Harman Kalra
2024-06-24 11:57   ` [PATCH v2 2/5] net/cnxk: add MTU set ops Harman Kalra
2024-06-24 11:57   ` [PATCH v2 3/5] net/cnxk: add multi seg support in eswitch Harman Kalra
2024-06-24 11:57   ` [PATCH v2 4/5] net/cnxk: fix invalid pattern count Harman Kalra
2024-06-24 11:57   ` [PATCH v2 5/5] net/cnxk: fix representor port mapping Harman Kalra
2024-06-24 13:24 ` [PATCH v3 1/5] net/cnxk: fix stale offload flag reset Harman Kalra
2024-06-24 13:24   ` [PATCH v3 2/5] net/cnxk: add MTU set ops Harman Kalra
2024-06-24 13:24   ` [PATCH v3 3/5] net/cnxk: add multi seg support in eswitch Harman Kalra
2024-06-24 13:24   ` [PATCH v3 4/5] net/cnxk: fix invalid pattern count Harman Kalra
2024-06-24 13:24   ` [PATCH v3 5/5] net/cnxk: fix representor port mapping Harman Kalra
2024-06-25  9:46     ` Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240624074822.88955-2-hkalra@marvell.com \
    --to=hkalra@marvell.com \
    --cc=adwivedi@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).