diff mbox series

[v4,2/2] kni: implement basic get_link_ksettings callback

Message ID 20210704160610.62682-2-iryzhov@nfware.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series [v4,1/2] kni: rework rte_kni_update_link using ioctl | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot fail github build: failed
ci/checkpatch warning coding style issues

Commit Message

Igor Ryzhov July 4, 2021, 4:06 p.m. UTC
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
---
 kernel/linux/kni/kni_net.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 99da8d37dd6b..84357bec1341 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -805,9 +805,34 @@  static void kni_get_drvinfo(struct net_device *dev,
 	strlcpy(info->driver, "kni", sizeof(info->driver));
 }
 
+#ifdef ETHTOOL_GLINKSETTINGS
+static int kni_get_link_ksettings(struct net_device *dev,
+				  struct ethtool_link_ksettings *settings)
+{
+	struct kni_dev *kni = netdev_priv(dev);
+
+	settings->base.port = PORT_OTHER;
+
+	if (netif_carrier_ok(dev)) {
+		settings->base.speed = kni->speed;
+		settings->base.duplex = kni->duplex;
+		settings->base.autoneg = kni->autoneg;
+	} else {
+		settings->base.speed = SPEED_UNKNOWN;
+		settings->base.duplex = DUPLEX_UNKNOWN;
+		settings->base.autoneg = AUTONEG_ENABLE;
+	}
+
+	return 0;
+}
+#endif
+
 static const struct ethtool_ops kni_net_ethtool_ops = {
 	.get_drvinfo	= kni_get_drvinfo,
 	.get_link	= ethtool_op_get_link,
+#ifdef ETHTOOL_GLINKSETTINGS
+	.get_link_ksettings	= kni_get_link_ksettings,
+#endif
 };
 
 void