diff mbox series

[CATERPILLAR,v2,2/4] linux-gen: extend ethtool helper functions

Message ID 1513875625-25260-3-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [CATERPILLAR,v2,1/4] linux-gen: add memory-mapped I/O access API | expand

Commit Message

Github ODP bot Dec. 21, 2017, 5 p.m. UTC
From: Mykyta Iziumtsev <mykyta.iziumtsev@linaro.org>


Add helper function to query RX/TX queue lengths on network interface to
facilitate upcoming native and mediated device drivers.

Signed-off-by: Mykyta Iziumtsev <mykyta.iziumtsev@linaro.org>

---
/** Email created from pull request 359 (MykytaI:caterpillar_mdev_auxiliary)
 ** https://github.com/Linaro/odp/pull/359
 ** Patch: https://github.com/Linaro/odp/pull/359.patch
 ** Base sha: 63fd88635cc10caaa02fdccd3f52c9494487bdd2
 ** Merge commit sha: d90db23824f481750cb9bfe1de16df25e2b1767a
 **/
 platform/linux-generic/pktio/ethtool.c | 19 +++++++++++++++++--
 platform/linux-generic/pktio/ethtool.h | 27 +++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c
index b71666a32..119ad75a4 100644
--- a/platform/linux-generic/pktio/ethtool.c
+++ b/platform/linux-generic/pktio/ethtool.c
@@ -159,12 +159,27 @@  static int ethtool_stats(int fd, struct ifreq *ifr, odp_pktio_stats_t *stats)
 	return 0;
 }
 
-int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats)
+int ethtool_stats_get_fd(int fd, const char *netif_name,
+			 odp_pktio_stats_t *stats)
 {
 	struct ifreq ifr;
 
 	memset(&ifr, 0, sizeof(ifr));
-	snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name);
+	snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name);
 
 	return ethtool_stats(fd, &ifr, stats);
 }
+
+int ethtool_ringparam_get_fd(int fd, const char *netif_name,
+			     struct ethtool_ringparam *param)
+{
+	struct ifreq ifr;
+
+	memset(&ifr, 0, sizeof(ifr));
+	snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", netif_name);
+
+	param->cmd = ETHTOOL_GRINGPARAM;
+	ifr.ifr_data = (void *)param;
+
+	return ioctl(fd, SIOCETHTOOL, &ifr);
+}
diff --git a/platform/linux-generic/pktio/ethtool.h b/platform/linux-generic/pktio/ethtool.h
index c5a811238..c330c2e31 100644
--- a/platform/linux-generic/pktio/ethtool.h
+++ b/platform/linux-generic/pktio/ethtool.h
@@ -7,9 +7,32 @@ 
 #ifndef ODP_PKTIO_ETHTOOL_H_
 #define ODP_PKTIO_ETHTOOL_H_
 
+#include <linux/ethtool.h>
+
+/**
+ * Get statistics for a network interface
+ *
+ * @param fd		Arbitrary socket file descriptor
+ * @param netif_name    Network interface name
+ * @param stats[out]    Output buffer for counters
+ *
+ * @retval 0 on success
+ * @retval != 0 on failure
+ */
+int ethtool_stats_get_fd(int fd, const char *netif_name,
+			 odp_pktio_stats_t *stats);
+
 /**
- * Get ethtool statistics of a packet socket
+ * Get RX/TX queue parameters for a network interface
+ *
+ * @param fd		Arbitrary socket file descriptor
+ * @param netif_name	Network interface name
+ * @param param[out]	Output buffer for parameters
+ *
+ * @retval 0 on success
+ * @retval != 0 on failure
  */
-int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats);
+int ethtool_ringparam_get_fd(int fd, const char *netif_name,
+			     struct ethtool_ringparam *param);
 
 #endif /*ODP_PKTIO_ETHTOOL_H_*/