aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback
diff options
context:
space:
mode:
authorPaul Durrant <Paul.Durrant@citrix.com>2016-10-10 04:30:53 -0400
committerDavid S. Miller <davem@davemloft.net>2016-10-13 09:53:09 -0400
commita9339b8e138d81b6ee928d0de3372c551cbd3d34 (patch)
tree8ba868830044aabc17536ac7b123fc0c35d3414d /drivers/net/xen-netback
parentfa59b27c9d6f84e91e333175a242afa4aee79283 (diff)
xen-netback: (re-)create a debugfs node for hash information
It is useful to be able to see the hash configuration when running tests. This patch adds a debugfs node for that purpose. The original version of this patch (commit c0c64c152389) was reverted due to build failures caused by a conflict with commit 0364a8824c02 ("xen-netback: switch to threaded irq for control ring"). This new version of the patch is nearly identical to the original, the only difference being that creation of the debugfs node is predicated on 'ctrl_irq' being non-zero rather then the now non-existent 'ctrl_task'. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> Cc: David S. Miller <davem@davemloft.net> Acked-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netback')
-rw-r--r--drivers/net/xen-netback/common.h4
-rw-r--r--drivers/net/xen-netback/hash.c68
-rw-r--r--drivers/net/xen-netback/xenbus.c37
3 files changed, 107 insertions, 2 deletions
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index cf68149cbb55..3ce1f7da8647 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -407,4 +407,8 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
407 407
408void xenvif_set_skb_hash(struct xenvif *vif, struct sk_buff *skb); 408void xenvif_set_skb_hash(struct xenvif *vif, struct sk_buff *skb);
409 409
410#ifdef CONFIG_DEBUG_FS
411void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m);
412#endif
413
410#endif /* __XEN_NETBACK__COMMON_H__ */ 414#endif /* __XEN_NETBACK__COMMON_H__ */
diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
index 613bac057650..e8c5dddc54ba 100644
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -360,6 +360,74 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
360 return XEN_NETIF_CTRL_STATUS_SUCCESS; 360 return XEN_NETIF_CTRL_STATUS_SUCCESS;
361} 361}
362 362
363#ifdef CONFIG_DEBUG_FS
364void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m)
365{
366 unsigned int i;
367
368 switch (vif->hash.alg) {
369 case XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ:
370 seq_puts(m, "Hash Algorithm: TOEPLITZ\n");
371 break;
372
373 case XEN_NETIF_CTRL_HASH_ALGORITHM_NONE:
374 seq_puts(m, "Hash Algorithm: NONE\n");
375 /* FALLTHRU */
376 default:
377 return;
378 }
379
380 if (vif->hash.flags) {
381 seq_puts(m, "\nHash Flags:\n");
382
383 if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4)
384 seq_puts(m, "- IPv4\n");
385 if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP)
386 seq_puts(m, "- IPv4 + TCP\n");
387 if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6)
388 seq_puts(m, "- IPv6\n");
389 if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP)
390 seq_puts(m, "- IPv6 + TCP\n");
391 }
392
393 seq_puts(m, "\nHash Key:\n");
394
395 for (i = 0; i < XEN_NETBK_MAX_HASH_KEY_SIZE; ) {
396 unsigned int j, n;
397
398 n = 8;
399 if (i + n >= XEN_NETBK_MAX_HASH_KEY_SIZE)
400 n = XEN_NETBK_MAX_HASH_KEY_SIZE - i;
401
402 seq_printf(m, "[%2u - %2u]: ", i, i + n - 1);
403
404 for (j = 0; j < n; j++, i++)
405 seq_printf(m, "%02x ", vif->hash.key[i]);
406
407 seq_puts(m, "\n");
408 }
409
410 if (vif->hash.size != 0) {
411 seq_puts(m, "\nHash Mapping:\n");
412
413 for (i = 0; i < vif->hash.size; ) {
414 unsigned int j, n;
415
416 n = 8;
417 if (i + n >= vif->hash.size)
418 n = vif->hash.size - i;
419
420 seq_printf(m, "[%4u - %4u]: ", i, i + n - 1);
421
422 for (j = 0; j < n; j++, i++)
423 seq_printf(m, "%4u ", vif->hash.mapping[i]);
424
425 seq_puts(m, "\n");
426 }
427 }
428}
429#endif /* CONFIG_DEBUG_FS */
430
363void xenvif_init_hash(struct xenvif *vif) 431void xenvif_init_hash(struct xenvif *vif)
364{ 432{
365 if (xenvif_hash_cache_size == 0) 433 if (xenvif_hash_cache_size == 0)
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 7056404e3cb8..8674e188b697 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -165,7 +165,7 @@ xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
165 return count; 165 return count;
166} 166}
167 167
168static int xenvif_dump_open(struct inode *inode, struct file *filp) 168static int xenvif_io_ring_open(struct inode *inode, struct file *filp)
169{ 169{
170 int ret; 170 int ret;
171 void *queue = NULL; 171 void *queue = NULL;
@@ -179,13 +179,35 @@ static int xenvif_dump_open(struct inode *inode, struct file *filp)
179 179
180static const struct file_operations xenvif_dbg_io_ring_ops_fops = { 180static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
181 .owner = THIS_MODULE, 181 .owner = THIS_MODULE,
182 .open = xenvif_dump_open, 182 .open = xenvif_io_ring_open,
183 .read = seq_read, 183 .read = seq_read,
184 .llseek = seq_lseek, 184 .llseek = seq_lseek,
185 .release = single_release, 185 .release = single_release,
186 .write = xenvif_write_io_ring, 186 .write = xenvif_write_io_ring,
187}; 187};
188 188
189static int xenvif_read_ctrl(struct seq_file *m, void *v)
190{
191 struct xenvif *vif = m->private;
192
193 xenvif_dump_hash_info(vif, m);
194
195 return 0;
196}
197
198static int xenvif_ctrl_open(struct inode *inode, struct file *filp)
199{
200 return single_open(filp, xenvif_read_ctrl, inode->i_private);
201}
202
203static const struct file_operations xenvif_dbg_ctrl_ops_fops = {
204 .owner = THIS_MODULE,
205 .open = xenvif_ctrl_open,
206 .read = seq_read,
207 .llseek = seq_lseek,
208 .release = single_release,
209};
210
189static void xenvif_debugfs_addif(struct xenvif *vif) 211static void xenvif_debugfs_addif(struct xenvif *vif)
190{ 212{
191 struct dentry *pfile; 213 struct dentry *pfile;
@@ -210,6 +232,17 @@ static void xenvif_debugfs_addif(struct xenvif *vif)
210 pr_warn("Creation of io_ring file returned %ld!\n", 232 pr_warn("Creation of io_ring file returned %ld!\n",
211 PTR_ERR(pfile)); 233 PTR_ERR(pfile));
212 } 234 }
235
236 if (vif->ctrl_irq) {
237 pfile = debugfs_create_file("ctrl",
238 S_IRUSR,
239 vif->xenvif_dbg_root,
240 vif,
241 &xenvif_dbg_ctrl_ops_fops);
242 if (IS_ERR_OR_NULL(pfile))
243 pr_warn("Creation of ctrl file returned %ld!\n",
244 PTR_ERR(pfile));
245 }
213 } else 246 } else
214 netdev_warn(vif->dev, 247 netdev_warn(vif->dev,
215 "Creation of vif debugfs dir returned %ld!\n", 248 "Creation of vif debugfs dir returned %ld!\n",