From owner-svn-src-head@FreeBSD.ORG Wed Oct 17 19:24:14 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1192FDF0; Wed, 17 Oct 2012 19:24:14 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D34E38FC08; Wed, 17 Oct 2012 19:24:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9HJODoK044648; Wed, 17 Oct 2012 19:24:13 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9HJODvL044644; Wed, 17 Oct 2012 19:24:13 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <201210171924.q9HJODvL044644@svn.freebsd.org> From: Maksim Yevmenkin Date: Wed, 17 Oct 2012 19:24:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241646 - in head/sys: dev/ixgbe net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2012 19:24:14 -0000 Author: emax Date: Wed Oct 17 19:24:13 2012 New Revision: 241646 URL: http://svn.freebsd.org/changeset/base/241646 Log: provide helper if_initbaudrate() to set if_baudrate_pf and if_baudrate_pf. again, use ixgbe(4) as an example of how to use new helper function. Reviewed by: jhb MFC after: 1 week Modified: head/sys/dev/ixgbe/ixgbe.c head/sys/net/if.h head/sys/net/if_var.h Modified: head/sys/dev/ixgbe/ixgbe.c ============================================================================== --- head/sys/dev/ixgbe/ixgbe.c Wed Oct 17 19:21:52 2012 (r241645) +++ head/sys/dev/ixgbe/ixgbe.c Wed Oct 17 19:24:13 2012 (r241646) @@ -2597,8 +2597,7 @@ ixgbe_setup_interface(device_t dev, stru return (-1); } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_baudrate = IF_Gbps(1); - ifp->if_baudrate_pf = 1; /* 1Gbps * 10^1 = 10Gbps */ + if_initbaudrate(ifp, IF_Gbps(10)); ifp->if_init = ixgbe_init; ifp->if_softc = adapter; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; Modified: head/sys/net/if.h ============================================================================== --- head/sys/net/if.h Wed Oct 17 19:21:52 2012 (r241645) +++ head/sys/net/if.h Wed Oct 17 19:24:13 2012 (r241646) @@ -179,7 +179,7 @@ struct if_data { * Some convenience macros used for setting ifi_baudrate. * XXX 1000 vs. 1024? --thorpej@netbsd.org */ -#define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */ +#define IF_Kbps(x) ((uintmax_t)(x) * 1000) /* kilobits/sec. */ #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ Modified: head/sys/net/if_var.h ============================================================================== --- head/sys/net/if_var.h Wed Oct 17 19:21:52 2012 (r241645) +++ head/sys/net/if_var.h Wed Oct 17 19:24:13 2012 (r241646) @@ -591,6 +591,18 @@ do { \ } while (0) #ifdef _KERNEL +static __inline void +if_initbaudrate(struct ifnet *ifp, uintmax_t baud) +{ + + ifp->if_baudrate_pf = 0; + while (baud > (u_long)(~0UL)) { + baud /= 10; + ifp->if_baudrate_pf++; + } + ifp->if_baudrate = baud; +} + static __inline int drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m) {