From owner-svn-src-all@freebsd.org Fri Aug 28 05:58:18 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 546919C414D; Fri, 28 Aug 2015 05:58:18 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38D7B178; Fri, 28 Aug 2015 05:58:18 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7S5wIkF079248; Fri, 28 Aug 2015 05:58:18 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7S5wH0t079239; Fri, 28 Aug 2015 05:58:17 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201508280558.t7S5wH0t079239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Fri, 28 Aug 2015 05:58:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287245 - in head/sys: net netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 05:58:18 -0000 Author: adrian Date: Fri Aug 28 05:58:16 2015 New Revision: 287245 URL: https://svnweb.freebsd.org/changeset/base/287245 Log: Replace the printf()s with optional rate limited debugging for RSS. Submitted by: Tiwei Bie Differential Revision: https://reviews.freebsd.org/D3471 Modified: head/sys/net/rss_config.c head/sys/net/rss_config.h head/sys/netinet/in_rss.c head/sys/netinet6/in6_rss.c Modified: head/sys/net/rss_config.c ============================================================================== --- head/sys/net/rss_config.c Fri Aug 28 05:29:52 2015 (r287244) +++ head/sys/net/rss_config.c Fri Aug 28 05:58:16 2015 (r287245) @@ -152,6 +152,15 @@ SYSCTL_INT(_net_inet_rss, OID_AUTO, base __DECONST(int *, &rss_basecpu), 0, "RSS base CPU"); /* + * Print verbose debugging messages. + * 0 - disable + * non-zero - enable + */ +int rss_debug = 0; +SYSCTL_INT(_net_inet_rss, OID_AUTO, debug, CTLFLAG_RWTUN, &rss_debug, 0, + "RSS debug level"); + +/* * RSS secret key, intended to prevent attacks on load-balancing. Its * effectiveness may be limited by algorithm choice and available entropy * during the boot. @@ -194,8 +203,8 @@ rss_init(__unused void *arg) break; default: - printf("%s: invalid RSS hashalgo %u, coercing to %u", - __func__, rss_hashalgo, RSS_HASH_TOEPLITZ); + RSS_DEBUG("invalid RSS hashalgo %u, coercing to %u\n", + rss_hashalgo, RSS_HASH_TOEPLITZ); rss_hashalgo = RSS_HASH_TOEPLITZ; } @@ -229,8 +238,8 @@ rss_init(__unused void *arg) * ones. */ if (rss_bits == 0 || rss_bits > RSS_MAXBITS) { - printf("%s: RSS bits %u not valid, coercing to %u", - __func__, rss_bits, RSS_MAXBITS); + RSS_DEBUG("RSS bits %u not valid, coercing to %u\n", + rss_bits, RSS_MAXBITS); rss_bits = RSS_MAXBITS; } @@ -241,9 +250,8 @@ rss_init(__unused void *arg) */ rss_buckets = (1 << rss_bits); if (rss_buckets < rss_ncpus) - printf("%s: WARNING: rss_buckets (%u) less than " - "rss_ncpus (%u)\n", __func__, rss_buckets, - rss_ncpus); + RSS_DEBUG("WARNING: rss_buckets (%u) less than " + "rss_ncpus (%u)\n", rss_buckets, rss_ncpus); rss_mask = rss_buckets - 1; } else { rss_bits = 0; Modified: head/sys/net/rss_config.h ============================================================================== --- head/sys/net/rss_config.h Fri Aug 28 05:29:52 2015 (r287244) +++ head/sys/net/rss_config.h Fri Aug 28 05:58:16 2015 (r287245) @@ -93,6 +93,21 @@ #define RSS_HASH_PKT_EGRESS 1 /* + * Rate limited debugging routines. + */ +#define RSS_DEBUG(format, ...) do { \ + if (rss_debug) { \ + static struct timeval lastfail; \ + static int curfail; \ + if (ppsratecheck(&lastfail, &curfail, 5)) \ + printf("RSS (%s:%u): " format, __func__, __LINE__,\ + ##__VA_ARGS__); \ + } \ +} while (0) + +extern int rss_debug; + +/* * Device driver interfaces to query RSS properties that must be programmed * into hardware. */ Modified: head/sys/netinet/in_rss.c ============================================================================== --- head/sys/netinet/in_rss.c Fri Aug 28 05:29:52 2015 (r287244) +++ head/sys/netinet/in_rss.c Fri Aug 28 05:58:16 2015 (r287245) @@ -147,7 +147,7 @@ rss_proto_software_hash_v4(struct in_add } /* No configured available hashtypes! */ - printf("%s: no available hashtypes!\n", __func__); + RSS_DEBUG("no available hashtypes!\n"); return (-1); } @@ -183,7 +183,7 @@ rss_mbuf_software_hash_v4(const struct m * XXX For now this only handles hashing on incoming mbufs. */ if (dir != RSS_HASH_PKT_INGRESS) { - printf("%s: called on EGRESS packet!\n", __func__); + RSS_DEBUG("called on EGRESS packet!\n"); return (-1); } @@ -192,11 +192,11 @@ rss_mbuf_software_hash_v4(const struct m * to have an IPv4 header in it. */ if (m->m_pkthdr.len < (sizeof(struct ip))) { - printf("%s: short mbuf pkthdr\n", __func__); + RSS_DEBUG("short mbuf pkthdr\n"); return (-1); } if (m->m_len < (sizeof(struct ip))) { - printf("%s: short mbuf len\n", __func__); + RSS_DEBUG("short mbuf len\n"); return (-1); } @@ -280,7 +280,7 @@ rss_mbuf_software_hash_v4(const struct m (proto == IPPROTO_TCP) && (is_frag == 0)) { if (m->m_len < iphlen + sizeof(struct tcphdr)) { - printf("%s: short TCP frame?\n", __func__); + RSS_DEBUG("short TCP frame?\n"); return (-1); } th = (const struct tcphdr *)((c_caddr_t)ip + iphlen); @@ -295,7 +295,7 @@ rss_mbuf_software_hash_v4(const struct m (is_frag == 0)) { uh = (const struct udphdr *)((c_caddr_t)ip + iphlen); if (m->m_len < iphlen + sizeof(struct udphdr)) { - printf("%s: short UDP frame?\n", __func__); + RSS_DEBUG("short UDP frame?\n"); return (-1); } return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, @@ -313,7 +313,7 @@ rss_mbuf_software_hash_v4(const struct m hashval, hashtype); } else { - printf("%s: no available hashtypes!\n", __func__); + RSS_DEBUG("no available hashtypes!\n"); return (-1); } } Modified: head/sys/netinet6/in6_rss.c ============================================================================== --- head/sys/netinet6/in6_rss.c Fri Aug 28 05:29:52 2015 (r287244) +++ head/sys/netinet6/in6_rss.c Fri Aug 28 05:58:16 2015 (r287245) @@ -147,6 +147,6 @@ rss_proto_software_hash_v6(const struct } /* No configured available hashtypes! */ - printf("%s: no available hashtypes!\n", __func__); + RSS_DEBUG("no available hashtypes!\n"); return (-1); }