linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: hyperv: Add attributes to show RX/TX indirection table
@ 2020-07-17  6:04 Chi Song
  2020-07-17 10:43 ` Wei Liu
  2020-07-17 15:24 ` Stephen Hemminger
  0 siblings, 2 replies; 8+ messages in thread
From: Chi Song @ 2020-07-17  6:04 UTC (permalink / raw)
  To: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, John Fastabend, KP Singh
  Cc: linux-hyperv, netdev, linux-kernel, bpf

The network is observed with low performance, if TX indirection table is imbalance.
But the table is in memory and set in runtime, it's hard to know. Add them to attributes can help on troubleshooting.
---
 drivers/net/hyperv/netvsc_drv.c | 46 +++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 6267f706e8ee..cd6fe96e10c1 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2370,6 +2370,51 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
 	return NOTIFY_OK;
 }
 
+static ssize_t tx_indirection_table_show(struct device *dev,
+					 struct device_attribute *dev_attr,
+					 char *buf)
+{
+	struct net_device *ndev = to_net_dev(dev);
+	struct net_device_context *ndc = netdev_priv(ndev);
+	int i = 0;
+	ssize_t offset = 0;
+
+	for (i = 0; i < VRSS_SEND_TAB_SIZE; i++)
+		offset += sprintf(buf + offset, "%u ", ndc->tx_table[i]);
+	buf[offset - 1] = '\n';
+
+	return offset;
+}
+static DEVICE_ATTR_RO(tx_indirection_table);
+
+static ssize_t rx_indirection_table_show(struct device *dev,
+					 struct device_attribute *dev_attr,
+					 char *buf)
+{
+	struct net_device *ndev = to_net_dev(dev);
+	struct net_device_context *ndc = netdev_priv(ndev);
+	int i = 0;
+	ssize_t offset = 0;
+
+	for (i = 0; i < ITAB_NUM; i++)
+		offset += sprintf(buf + offset, "%u ", ndc->rx_table[i]);
+	buf[offset - 1] = '\n';
+
+	return offset;
+}
+static DEVICE_ATTR_RO(rx_indirection_table);
+
+static struct attribute *netvsc_dev_attrs[] = {
+	&dev_attr_tx_indirection_table.attr,
+	&dev_attr_rx_indirection_table.attr,
+	NULL
+};
+
+const struct attribute_group netvsc_dev_group = {
+	.name = NULL,
+	.attrs = netvsc_dev_attrs,
+};
+
 static int netvsc_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
@@ -2410,6 +2455,7 @@ static int netvsc_probe(struct hv_device *dev,
 
 	net->netdev_ops = &device_ops;
 	net->ethtool_ops = &ethtool_ops;
+	net->sysfs_groups[0] = &netvsc_dev_group;
 	SET_NETDEV_DEV(net, &dev->device);
 
 	/* We always need headroom for rndis header */
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-17 17:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17  6:04 [PATCH net-next] net: hyperv: Add attributes to show RX/TX indirection table Chi Song
2020-07-17 10:43 ` Wei Liu
2020-07-17 15:24 ` Stephen Hemminger
2020-07-17 16:18   ` Haiyang Zhang
2020-07-17 16:55     ` David Miller
2020-07-17 16:59       ` Haiyang Zhang
2020-07-17 17:15       ` Stephen Hemminger
2020-07-17 17:33         ` Haiyang Zhang

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).