aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/809-jailhouse-0008-ivshmem-net-Add-ethtool-register-dump.patch
blob: 1a8b4c6844fc810a8ea83de30f114ebc40f50da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 65e624b3708cb35942297f699d886aa4c8a7e613 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Sun, 1 Jan 2017 15:46:26 +0100
Subject: [PATCH] ivshmem-net: Add ethtool register dump

Helps debugging inconsistent states.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 81674136b6936fb8219dac1dcdb6df8fe424143d)
---
 drivers/net/ivshmem-net.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

--- a/drivers/net/ivshmem-net.c
+++ b/drivers/net/ivshmem-net.c
@@ -748,10 +748,41 @@ static void ivshm_net_get_ethtool_stats(
 	memset(&in->stats, 0, sizeof(in->stats));
 }
 
+#define IVSHM_NET_REGS_LEN	(3 * sizeof(u32) + 6 * sizeof(u16))
+
+static int ivshm_net_get_regs_len(struct net_device *ndev)
+{
+	return IVSHM_NET_REGS_LEN;
+}
+
+static void ivshm_net_get_regs(struct net_device *ndev,
+			       struct ethtool_regs *regs, void *p)
+{
+	struct ivshm_net *in = netdev_priv(ndev);
+	u32 *reg32 = p;
+	u16 *reg16;
+
+	*reg32++ = in->lstate;
+	*reg32++ = in->rstate;
+	*reg32++ = in->qlen;
+
+	reg16 = (u16 *)reg32;
+
+	*reg16++ = in->tx.vr.avail ? in->tx.vr.avail->idx : 0;
+	*reg16++ = in->tx.vr.used ? in->tx.vr.used->idx : 0;
+	*reg16++ = in->tx.vr.avail ? vring_avail_event(&in->tx.vr) : 0;
+
+	*reg16++ = in->rx.vr.avail ? in->rx.vr.avail->idx : 0;
+	*reg16++ = in->rx.vr.used ? in->rx.vr.used->idx : 0;
+	*reg16++ = in->rx.vr.avail ? vring_avail_event(&in->rx.vr) : 0;
+}
+
 static const struct ethtool_ops ivshm_net_ethtool_ops = {
 	.get_sset_count		= ivshm_net_get_sset_count,
 	.get_strings		= ivshm_net_get_strings,
 	.get_ethtool_stats	= ivshm_net_get_ethtool_stats,
+	.get_regs_len		= ivshm_net_get_regs_len,
+	.get_regs		= ivshm_net_get_regs,
 };
 
 static int ivshm_net_probe(struct pci_dev *pdev,