Skip to content

Commit c0c64c1

Browse files
Paul Durrantdavem330
authored andcommitted
xen-netback: 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. Signed-off-by: Paul Durrant <[email protected]> Cc: Wei Liu <[email protected]> Acked-by: Wei Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c7b256f commit c0c64c1

File tree

3 files changed

+107
-2
lines changed

3 files changed

+107
-2
lines changed

drivers/net/xen-netback/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,8 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
412412

413413
void xenvif_set_skb_hash(struct xenvif *vif, struct sk_buff *skb);
414414

415+
#ifdef CONFIG_DEBUG_FS
416+
void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m);
417+
#endif
418+
415419
#endif /* __XEN_NETBACK__COMMON_H__ */

drivers/net/xen-netback/hash.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,74 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
369369
return XEN_NETIF_CTRL_STATUS_SUCCESS;
370370
}
371371

372+
#ifdef CONFIG_DEBUG_FS
373+
void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m)
374+
{
375+
unsigned int i;
376+
377+
switch (vif->hash.alg) {
378+
case XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ:
379+
seq_puts(m, "Hash Algorithm: TOEPLITZ\n");
380+
break;
381+
382+
case XEN_NETIF_CTRL_HASH_ALGORITHM_NONE:
383+
seq_puts(m, "Hash Algorithm: NONE\n");
384+
/* FALLTHRU */
385+
default:
386+
return;
387+
}
388+
389+
if (vif->hash.flags) {
390+
seq_puts(m, "\nHash Flags:\n");
391+
392+
if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4)
393+
seq_puts(m, "- IPv4\n");
394+
if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP)
395+
seq_puts(m, "- IPv4 + TCP\n");
396+
if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6)
397+
seq_puts(m, "- IPv6\n");
398+
if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP)
399+
seq_puts(m, "- IPv6 + TCP\n");
400+
}
401+
402+
seq_puts(m, "\nHash Key:\n");
403+
404+
for (i = 0; i < XEN_NETBK_MAX_HASH_KEY_SIZE; ) {
405+
unsigned int j, n;
406+
407+
n = 8;
408+
if (i + n >= XEN_NETBK_MAX_HASH_KEY_SIZE)
409+
n = XEN_NETBK_MAX_HASH_KEY_SIZE - i;
410+
411+
seq_printf(m, "[%2u - %2u]: ", i, i + n - 1);
412+
413+
for (j = 0; j < n; j++, i++)
414+
seq_printf(m, "%02x ", vif->hash.key[i]);
415+
416+
seq_puts(m, "\n");
417+
}
418+
419+
if (vif->hash.size != 0) {
420+
seq_puts(m, "\nHash Mapping:\n");
421+
422+
for (i = 0; i < vif->hash.size; ) {
423+
unsigned int j, n;
424+
425+
n = 8;
426+
if (i + n >= vif->hash.size)
427+
n = vif->hash.size - i;
428+
429+
seq_printf(m, "[%4u - %4u]: ", i, i + n - 1);
430+
431+
for (j = 0; j < n; j++, i++)
432+
seq_printf(m, "%4u ", vif->hash.mapping[i]);
433+
434+
seq_puts(m, "\n");
435+
}
436+
}
437+
}
438+
#endif /* CONFIG_DEBUG_FS */
439+
372440
void xenvif_init_hash(struct xenvif *vif)
373441
{
374442
if (xenvif_hash_cache_size == 0)

drivers/net/xen-netback/xenbus.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
165165
return count;
166166
}
167167

168-
static int xenvif_dump_open(struct inode *inode, struct file *filp)
168+
static int xenvif_io_ring_open(struct inode *inode, struct file *filp)
169169
{
170170
int ret;
171171
void *queue = NULL;
@@ -179,13 +179,35 @@ static int xenvif_dump_open(struct inode *inode, struct file *filp)
179179

180180
static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
181181
.owner = THIS_MODULE,
182-
.open = xenvif_dump_open,
182+
.open = xenvif_io_ring_open,
183183
.read = seq_read,
184184
.llseek = seq_lseek,
185185
.release = single_release,
186186
.write = xenvif_write_io_ring,
187187
};
188188

189+
static 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+
198+
static int xenvif_ctrl_open(struct inode *inode, struct file *filp)
199+
{
200+
return single_open(filp, xenvif_read_ctrl, inode->i_private);
201+
}
202+
203+
static 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+
189211
static void xenvif_debugfs_addif(struct xenvif *vif)
190212
{
191213
struct dentry *pfile;
@@ -210,6 +232,17 @@ static void xenvif_debugfs_addif(struct xenvif *vif)
210232
pr_warn("Creation of io_ring file returned %ld!\n",
211233
PTR_ERR(pfile));
212234
}
235+
236+
if (vif->ctrl_task) {
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+
}
213246
} else
214247
netdev_warn(vif->dev,
215248
"Creation of vif debugfs dir returned %ld!\n",

0 commit comments

Comments
 (0)