diff mbox series

[20/38] net/sfc: implement port representor link update

Message ID 20210827065717.1838258-21-andrew.rybchenko@oktetlabs.ru (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series net/sfc: support port representors | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Aug. 27, 2021, 6:56 a.m. UTC
From: Igor Romanov <igor.romanov@oktetlabs.ru>

Implement the callback by reporting link down if the representor
is not started, otherwise report link up with undefined link speed.

Link speed is undefined since representors can pass traffic to each
other even if the PF link is down.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
 drivers/net/sfc/sfc_repr.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c
index bfe6dd4c9b..207e7c77a0 100644
--- a/drivers/net/sfc/sfc_repr.c
+++ b/drivers/net/sfc/sfc_repr.c
@@ -471,6 +471,24 @@  sfc_repr_dev_infos_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+sfc_repr_dev_link_update(struct rte_eth_dev *dev,
+			 __rte_unused int wait_to_complete)
+{
+	struct sfc_repr *sr = sfc_repr_by_eth_dev(dev);
+	struct rte_eth_link link;
+
+	if (sr->state != SFC_ETHDEV_STARTED) {
+		sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, &link);
+	} else {
+		memset(&link, 0, sizeof(link));
+		link.link_status = ETH_LINK_UP;
+		link.link_speed = ETH_SPEED_NUM_UNKNOWN;
+	}
+
+	return rte_eth_linkstatus_set(dev, &link);
+}
+
 static int
 sfc_repr_ring_create(uint16_t pf_port_id, uint16_t repr_id,
 		     const char *type_name, uint16_t qid, uint16_t nb_desc,
@@ -782,6 +800,7 @@  static const struct eth_dev_ops sfc_repr_dev_ops = {
 	.dev_stop			= sfc_repr_dev_stop,
 	.dev_close			= sfc_repr_dev_close,
 	.dev_infos_get			= sfc_repr_dev_infos_get,
+	.link_update			= sfc_repr_dev_link_update,
 	.rx_queue_setup			= sfc_repr_rx_queue_setup,
 	.rx_queue_release		= sfc_repr_rx_queue_release,
 	.tx_queue_setup			= sfc_repr_tx_queue_setup,