From patchwork Mon Oct 10 08:30:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9369161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53D4B607D2 for ; Mon, 10 Oct 2016 08:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 453BB2940F for ; Mon, 10 Oct 2016 08:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36C992940C; Mon, 10 Oct 2016 08:53:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C2172940C for ; Mon, 10 Oct 2016 08:53:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btWId-0000zz-10; Mon, 10 Oct 2016 08:51:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btWIb-0000zt-1X for xen-devel@lists.xenproject.org; Mon, 10 Oct 2016 08:51:05 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id AA/B8-21986-8765BF75; Mon, 10 Oct 2016 08:51:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXitHSDvW552O9 wg0OnZS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oynDx+xFTRpVcxY95etgXGychcjJ4eEgL/E 2YaJjCA2m4COxNSnl1hBbBEBO4lLmw+wdzFycTALzGGUmDbpOwtIQlggUKJn8gcmEJtFQFVi1 8eDYHFeAXeJrRfb2SGGykmcP/6TGcQWElCRWD91FhtEjaDEyZlPwOqZBSQkDr54wQxRzy1x+/ RU5gmMPLOQlM1CUraAkWkVo3pxalFZapGuqV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5 yfu4mRmCQMADBDsbpl/0PMUpyMCmJ8iae+BEuxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXJvR3 uJBgUWp6akVaZg4wXGHSEhw8SiK8YSBp3uKCxNzizHSI1ClGRSlxXn2QhABIIqM0D64NFiOXG GWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMzrCzKFJzOvBG76K6DFTECLWRb/AFlckoiQkmpg5I h22Wv3r4stPb+m/7F7J+OTSSypm5877X+2h/nJX7HtHcsutXIKnEhzmqKe4n98FxdPtijnBhc BvnnnpNo8pM9NvXawTrjC6SHPqztzF8j9XFN4/qHLI81T83d8vfDwT1y55qFpbakXNxbw7JxT VPn7SAVj3DUmnv5Xrn/CmD12GKgfjN+/VomlOCPRUIu5qDgRADjBr/SMAgAA X-Env-Sender: prvs=084faaadd=Paul.Durrant@citrix.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1476089462!37315832!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24779 invoked from network); 10 Oct 2016 08:51:03 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 10 Oct 2016 08:51:03 -0000 X-IronPort-AV: E=Sophos;i="5.31,471,1473120000"; d="scan'208";a="391556544" From: Paul Durrant To: , Date: Mon, 10 Oct 2016 09:30:53 +0100 Message-ID: <1476088253-10685-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Paul Durrant , Wei Liu , "David S. Miller" Subject: [Xen-devel] [PATCH net] xen-netback: (re-)create a debugfs node for hash information X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paul Durrant 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 Cc: Wei Liu Cc: David S. Miller Acked-by: Wei Liu --- drivers/net/xen-netback/common.h | 4 +++ drivers/net/xen-netback/hash.c | 68 ++++++++++++++++++++++++++++++++++++++++ drivers/net/xen-netback/xenbus.c | 37 ++++++++++++++++++++-- 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h index cf68149..3ce1f7d 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, void xenvif_set_skb_hash(struct xenvif *vif, struct sk_buff *skb); +#ifdef CONFIG_DEBUG_FS +void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m); +#endif + #endif /* __XEN_NETBACK__COMMON_H__ */ diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c index 613bac0..e8c5ddd 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, return XEN_NETIF_CTRL_STATUS_SUCCESS; } +#ifdef CONFIG_DEBUG_FS +void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m) +{ + unsigned int i; + + switch (vif->hash.alg) { + case XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ: + seq_puts(m, "Hash Algorithm: TOEPLITZ\n"); + break; + + case XEN_NETIF_CTRL_HASH_ALGORITHM_NONE: + seq_puts(m, "Hash Algorithm: NONE\n"); + /* FALLTHRU */ + default: + return; + } + + if (vif->hash.flags) { + seq_puts(m, "\nHash Flags:\n"); + + if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4) + seq_puts(m, "- IPv4\n"); + if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP) + seq_puts(m, "- IPv4 + TCP\n"); + if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6) + seq_puts(m, "- IPv6\n"); + if (vif->hash.flags & XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP) + seq_puts(m, "- IPv6 + TCP\n"); + } + + seq_puts(m, "\nHash Key:\n"); + + for (i = 0; i < XEN_NETBK_MAX_HASH_KEY_SIZE; ) { + unsigned int j, n; + + n = 8; + if (i + n >= XEN_NETBK_MAX_HASH_KEY_SIZE) + n = XEN_NETBK_MAX_HASH_KEY_SIZE - i; + + seq_printf(m, "[%2u - %2u]: ", i, i + n - 1); + + for (j = 0; j < n; j++, i++) + seq_printf(m, "%02x ", vif->hash.key[i]); + + seq_puts(m, "\n"); + } + + if (vif->hash.size != 0) { + seq_puts(m, "\nHash Mapping:\n"); + + for (i = 0; i < vif->hash.size; ) { + unsigned int j, n; + + n = 8; + if (i + n >= vif->hash.size) + n = vif->hash.size - i; + + seq_printf(m, "[%4u - %4u]: ", i, i + n - 1); + + for (j = 0; j < n; j++, i++) + seq_printf(m, "%4u ", vif->hash.mapping[i]); + + seq_puts(m, "\n"); + } + } +} +#endif /* CONFIG_DEBUG_FS */ + void xenvif_init_hash(struct xenvif *vif) { if (xenvif_hash_cache_size == 0) diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 7056404..8674e18 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, return count; } -static int xenvif_dump_open(struct inode *inode, struct file *filp) +static int xenvif_io_ring_open(struct inode *inode, struct file *filp) { int ret; void *queue = NULL; @@ -179,13 +179,35 @@ static int xenvif_dump_open(struct inode *inode, struct file *filp) static const struct file_operations xenvif_dbg_io_ring_ops_fops = { .owner = THIS_MODULE, - .open = xenvif_dump_open, + .open = xenvif_io_ring_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = xenvif_write_io_ring, }; +static int xenvif_read_ctrl(struct seq_file *m, void *v) +{ + struct xenvif *vif = m->private; + + xenvif_dump_hash_info(vif, m); + + return 0; +} + +static int xenvif_ctrl_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, xenvif_read_ctrl, inode->i_private); +} + +static const struct file_operations xenvif_dbg_ctrl_ops_fops = { + .owner = THIS_MODULE, + .open = xenvif_ctrl_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static void xenvif_debugfs_addif(struct xenvif *vif) { struct dentry *pfile; @@ -210,6 +232,17 @@ static void xenvif_debugfs_addif(struct xenvif *vif) pr_warn("Creation of io_ring file returned %ld!\n", PTR_ERR(pfile)); } + + if (vif->ctrl_irq) { + pfile = debugfs_create_file("ctrl", + S_IRUSR, + vif->xenvif_dbg_root, + vif, + &xenvif_dbg_ctrl_ops_fops); + if (IS_ERR_OR_NULL(pfile)) + pr_warn("Creation of ctrl file returned %ld!\n", + PTR_ERR(pfile)); + } } else netdev_warn(vif->dev, "Creation of vif debugfs dir returned %ld!\n",