From patchwork Tue Oct 15 11:45:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 283603 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 737DA2C00A9 for ; Tue, 15 Oct 2013 23:02:35 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932585Ab3JOMB2 (ORCPT ); Tue, 15 Oct 2013 08:01:28 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:5473 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932534Ab3JOL6Y (ORCPT ); Tue, 15 Oct 2013 07:58:24 -0400 Received: from 172.24.2.119 (EHLO szxeml214-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BKI15903; Tue, 15 Oct 2013 19:57:57 +0800 (CST) Received: from SZXEML461-HUB.china.huawei.com (10.82.67.204) by szxeml214-edg.china.huawei.com (172.24.2.29) with Microsoft SMTP Server (TLS) id 14.3.146.0; Tue, 15 Oct 2013 19:57:57 +0800 Received: from localhost (10.135.68.221) by szxeml461-hub.china.huawei.com (10.82.67.204) with Microsoft SMTP Server id 14.3.146.0; Tue, 15 Oct 2013 19:57:46 +0800 From: Kefeng Wang To: CC: Greg Kroah-Hartman , "David S. Miller" , Pablo Neira Ayuso , "Stephen Hemminger" , Johannes Berg , "John W. Linville" , Stanislaw Gruszka , Johannes Berg , Francois Romieu , "Ben Hutchings" , Chas Williams , Marc Kleine-Budde , Samuel Ortiz , Paul Mackerras , Oliver Neukum , Konrad Rzeszutek Wilk , "Boris Ostrovsky" , David Vrabel , Rusty Russell , "Michael S. Tsirkin" , , , , Subject: [PATCH 15/18] net: xen: use wrapper functions of net_ratelimit() to simplify code Date: Tue, 15 Oct 2013 19:45:11 +0800 Message-ID: <1381837514-50660-16-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.8.3.msysgit.0 In-Reply-To: <1381837514-50660-1-git-send-email-wangkefeng.wang@huawei.com> References: <1381837514-50660-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.68.221] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Wrapper functions net_ratelimited_function() and net_XXX_ratelimited() are called to simplify code. Signed-off-by: Kefeng Wang --- drivers/net/xen-netback/netback.c | 21 +++++++++------------ drivers/net/xen-netfront.c | 27 +++++++++------------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index f3e591c..bceb2ad 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -776,10 +776,9 @@ static int xenvif_count_requests(struct xenvif *vif, * dropped */ if (!drop_err && slots >= XEN_NETBK_LEGACY_SLOTS_MAX) { - if (net_ratelimit()) - netdev_dbg(vif->dev, - "Too many slots (%d) exceeding limit (%d), dropping packet\n", - slots, XEN_NETBK_LEGACY_SLOTS_MAX); + net_ratelimited_function(netdev_dbg, vif->dev, + "Too many slots (%d) exceeding limit (%d), dropping packet\n", + slots, XEN_NETBK_LEGACY_SLOTS_MAX); drop_err = -E2BIG; } @@ -799,10 +798,9 @@ static int xenvif_count_requests(struct xenvif *vif, * Consume all slots and drop the packet. */ if (!drop_err && txp->size > first->size) { - if (net_ratelimit()) - netdev_dbg(vif->dev, - "Invalid tx request, slot size %u > remaining size %u\n", - txp->size, first->size); + net_ratelimited_function(netdev_dbg, vif->dev, + "Invalid tx request, slot size %u > remaining size %u\n", + txp->size, first->size); drop_err = -EIO; } @@ -1170,10 +1168,9 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb) } break; default: - if (net_ratelimit()) - netdev_err(vif->dev, - "Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n", - iph->protocol); + net_ratelimited_function(netdev_err, vif->dev, + "Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n", + iph->protocol); goto out; } diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 36808bf..11eeef1 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -690,8 +690,7 @@ static int xennet_get_extras(struct netfront_info *np, grant_ref_t ref; if (unlikely(cons + 1 == rp)) { - if (net_ratelimit()) - dev_warn(dev, "Missing extra info\n"); + net_ratelimited_function(dev_warn, dev, "Missing extra info\n"); err = -EBADR; break; } @@ -701,8 +700,7 @@ static int xennet_get_extras(struct netfront_info *np, if (unlikely(!extra->type || extra->type >= XEN_NETIF_EXTRA_TYPE_MAX)) { - if (net_ratelimit()) - dev_warn(dev, "Invalid extra type: %d\n", + net_ratelimited_function(dev_warn, dev, "Invalid extra type: %d\n", extra->type); err = -EINVAL; } else { @@ -742,8 +740,7 @@ static int xennet_get_responses(struct netfront_info *np, for (;;) { if (unlikely(rx->status < 0 || rx->offset + rx->status > PAGE_SIZE)) { - if (net_ratelimit()) - dev_warn(dev, "rx->offset: %x, size: %u\n", + net_ratelimited_function(dev_warn, dev, "rx->offset: %x, size: %u\n", rx->offset, rx->status); xennet_move_rx_slot(np, skb, ref); err = -EINVAL; @@ -756,8 +753,7 @@ static int xennet_get_responses(struct netfront_info *np, * situation to the system controller to reboot the backend. */ if (ref == GRANT_INVALID_REF) { - if (net_ratelimit()) - dev_warn(dev, "Bad rx response id %d.\n", + net_ratelimited_function(dev_warn, dev, "Bad rx response id %d.\n", rx->id); err = -EINVAL; goto next; @@ -775,8 +771,7 @@ next: break; if (cons + slots == rp) { - if (net_ratelimit()) - dev_warn(dev, "Need more slots\n"); + net_ratelimited_function(dev_warn, dev, "Need more slots\n"); err = -ENOENT; break; } @@ -788,8 +783,7 @@ next: } if (unlikely(slots > max)) { - if (net_ratelimit()) - dev_warn(dev, "Too many slots\n"); + net_ratelimited_function(dev_warn, dev, "Too many slots\n"); err = -E2BIG; } @@ -803,15 +797,13 @@ static int xennet_set_skb_gso(struct sk_buff *skb, struct xen_netif_extra_info *gso) { if (!gso->u.gso.size) { - if (net_ratelimit()) - pr_warn("GSO size must not be zero\n"); + net_warn_ratelimited("GSO size must not be zero\n"); return -EINVAL; } /* Currently only TCPv4 S.O. is supported. */ if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) { - if (net_ratelimit()) - pr_warn("Bad GSO type %d\n", gso->u.gso.type); + net_warn_ratelimited("Bad GSO type %d\n", gso->u.gso.type); return -EINVAL; } @@ -910,8 +902,7 @@ static int checksum_setup(struct net_device *dev, struct sk_buff *skb) } break; default: - if (net_ratelimit()) - pr_err("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n", + net_err_ratelimited("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n", iph->protocol); goto out; }