DPDK patches and discussions
 help / color / mirror / Atom feed
From: "WanRenyong" <wanry@yunsilicon.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
	 <andrew.rybchenko@oktetlabs.ru>, <qianr@yunsilicon.com>,
	 <nana@yunsilicon.com>, <zhangxx@yunsilicon.com>,
	 <zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>,
	<jacky@yunsilicon.com>,  <weihg@yunsilicon.com>
Subject: [PATCH v4 15/15] net/xsc: add ethdev link and MTU ops
Date: Fri, 03 Jan 2025 23:04:37 +0800	[thread overview]
Message-ID: <20250103150436.1529663-16-wanry@yunsilicon.com> (raw)
In-Reply-To: <20250103150404.1529663-1-wanry@yunsilicon.com>

Implement xsc ethdev link and MTU ops.

Signed-off-by: WanRenyong <wanry@yunsilicon.com>
---
 doc/guides/nics/features/xsc.ini |  1 +
 drivers/net/xsc/xsc_dev.c        | 33 ++++++++++++++++++
 drivers/net/xsc/xsc_dev.h        |  4 +++
 drivers/net/xsc/xsc_ethdev.c     | 60 ++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)

diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini
index eb88517104..d73cf9d136 100644
--- a/doc/guides/nics/features/xsc.ini
+++ b/doc/guides/nics/features/xsc.ini
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
diff --git a/drivers/net/xsc/xsc_dev.c b/drivers/net/xsc/xsc_dev.c
index 80813c2c82..b285a1e950 100644
--- a/drivers/net/xsc/xsc_dev.c
+++ b/drivers/net/xsc/xsc_dev.c
@@ -62,6 +62,39 @@ xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 					   data_out, out_len);
 }
 
+int
+xsc_dev_set_link_up(struct xsc_dev *xdev)
+{
+	if (xdev->dev_ops->set_link_up == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->set_link_up(xdev);
+}
+
+int
+xsc_dev_set_link_down(struct xsc_dev *xdev)
+{
+	if (xdev->dev_ops->set_link_down == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->set_link_down(xdev);
+}
+
+int
+xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete)
+{
+	if (xdev->dev_ops->link_update == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->link_update(xdev, funcid_type, wait_to_complete);
+}
+
+int
+xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu)
+{
+	return xdev->dev_ops->set_mtu(xdev, mtu);
+}
+
 int
 xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)
 {
diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h
index 4b5ab1d692..ef0933ab06 100644
--- a/drivers/net/xsc/xsc_dev.h
+++ b/drivers/net/xsc/xsc_dev.h
@@ -158,6 +158,9 @@ struct xsc_dev_ops {
 int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 			 int in_len, void *data_out, int out_len);
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
+int xsc_dev_set_link_up(struct xsc_dev *xdev);
+int xsc_dev_set_link_down(struct xsc_dev *xde);
+int xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete);
 int xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp);
 int xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq);
 int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode);
@@ -175,6 +178,7 @@ int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_et
 int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len);
 bool xsc_dev_is_vf(struct xsc_dev *xdev);
 int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id);
+int xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu);
 int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac);
 
 #endif /* _XSC_DEV_H_ */
diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c
index f4c127d7d4..9e60ea8b61 100644
--- a/drivers/net/xsc/xsc_ethdev.c
+++ b/drivers/net/xsc/xsc_ethdev.c
@@ -390,6 +390,41 @@ xsc_ethdev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+xsc_ethdev_set_link_up(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct xsc_dev *xdev = priv->xdev;
+
+	return xsc_dev_set_link_up(xdev);
+}
+
+static int
+xsc_ethdev_set_link_down(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct xsc_dev *xdev = priv->xdev;
+
+	return xsc_dev_set_link_down(xdev);
+}
+
+static int
+xsc_ethdev_link_update(struct rte_eth_dev *dev,
+		       int wait_to_complete)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct xsc_dev *xdev = priv->xdev;
+	int ret = 0;
+
+	ret = xsc_dev_link_update(xdev, priv->funcid_type, wait_to_complete);
+	if (ret == 0) {
+		dev->data->dev_link = xdev->pf_dev_link;
+		dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+				  RTE_ETH_LINK_SPEED_FIXED);
+	}
+	return ret;
+}
+
 static uint64_t
 xsc_get_rx_queue_offloads(struct rte_eth_dev *dev)
 {
@@ -529,6 +564,27 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	return 0;
 }
 
+static int
+xsc_ethdev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	int ret = 0;
+
+	if (priv->eth_type != RTE_ETH_REPRESENTOR_PF) {
+		priv->mtu = mtu;
+		return 0;
+	}
+
+	ret = xsc_dev_set_mtu(priv->xdev, mtu);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Mtu set to %u failure", mtu);
+		return -EAGAIN;
+	}
+
+	priv->mtu = mtu;
+	return 0;
+}
+
 static int
 xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
@@ -632,7 +688,10 @@ const struct eth_dev_ops xsc_eth_dev_ops = {
 	.dev_configure = xsc_ethdev_configure,
 	.dev_start = xsc_ethdev_start,
 	.dev_stop = xsc_ethdev_stop,
+	.dev_set_link_up = xsc_ethdev_set_link_up,
+	.dev_set_link_down = xsc_ethdev_set_link_down,
 	.dev_close = xsc_ethdev_close,
+	.link_update = xsc_ethdev_link_update,
 	.stats_get = xsc_ethdev_stats_get,
 	.stats_reset = xsc_ethdev_stats_reset,
 	.dev_infos_get = xsc_ethdev_infos_get,
@@ -640,6 +699,7 @@ const struct eth_dev_ops xsc_eth_dev_ops = {
 	.tx_queue_setup = xsc_ethdev_tx_queue_setup,
 	.rx_queue_release = xsc_ethdev_rxq_release,
 	.tx_queue_release = xsc_ethdev_txq_release,
+	.mtu_set = xsc_ethdev_set_mtu,
 	.rss_hash_update = xsc_ethdev_rss_hash_update,
 	.rss_hash_conf_get = xsc_ethdev_rss_hash_conf_get,
 };
-- 
2.25.1

      parent reply	other threads:[~2025-01-03 15:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-03 15:04 [PATCH v4 00/15] XSC PMD for Yunsilicon NICs WanRenyong
2025-01-03 15:04 ` [PATCH v4 01/15] net/xsc: add xsc PMD framework WanRenyong
2025-01-03 19:00   ` Stephen Hemminger
2025-01-06  1:36     ` WanRenyong
2025-01-03 15:04 ` [PATCH v4 02/15] net/xsc: add xsc device initialization WanRenyong
2025-01-03 18:58   ` Stephen Hemminger
2025-01-06  3:29     ` WanRenyong
2025-01-03 15:04 ` [PATCH v4 03/15] net/xsc: add xsc mailbox WanRenyong
2025-01-03 15:04 ` [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver WanRenyong
2025-01-03 19:02   ` Stephen Hemminger
2025-01-06  1:53     ` WanRenyong
2025-01-03 19:04   ` Stephen Hemminger
2025-01-06  2:01     ` WanRenyong
2025-01-03 19:06   ` Stephen Hemminger
2025-01-06  2:02     ` WanRenyong
2025-01-03 15:04 ` [PATCH v4 05/15] net/xsc: add PCT interfaces WanRenyong
2025-01-03 15:04 ` [PATCH v4 06/15] net/xsc: initialize xsc representors WanRenyong
2025-01-03 15:04 ` [PATCH v4 07/15] net/xsc: add ethdev configure and RSS ops WanRenyong
2025-01-03 19:14   ` Stephen Hemminger
2025-01-06  2:20     ` WanRenyong
2025-01-03 15:04 ` [PATCH v4 08/15] net/xsc: add Rx and Tx queue setup WanRenyong
2025-01-03 15:04 ` [PATCH v4 09/15] net/xsc: add ethdev start WanRenyong
2025-01-03 19:17   ` Stephen Hemminger
2025-01-06  3:01     ` WanRenyong
2025-01-03 15:04 ` [PATCH v4 10/15] net/xsc: add ethdev stop and close WanRenyong
2025-01-03 15:04 ` [PATCH v4 11/15] net/xsc: add ethdev Rx burst WanRenyong
2025-01-03 15:04 ` [PATCH v4 12/15] net/xsc: add ethdev Tx burst WanRenyong
2025-01-03 15:04 ` [PATCH v4 13/15] net/xsc: add basic stats ops WanRenyong
2025-01-03 15:04 ` [PATCH v4 14/15] net/xsc: add ethdev infos get WanRenyong
2025-01-03 19:22   ` Stephen Hemminger
2025-01-06  4:03     ` WanRenyong
2025-01-03 15:04 ` WanRenyong [this message]

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=20250103150436.1529663-16-wanry@yunsilicon.com \
    --to=wanry@yunsilicon.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=jacky@yunsilicon.com \
    --cc=nana@yunsilicon.com \
    --cc=qianr@yunsilicon.com \
    --cc=thomas@monjalon.net \
    --cc=weihg@yunsilicon.com \
    --cc=xudw@yunsilicon.com \
    --cc=zhangxx@yunsilicon.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).