Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

provide helper if_initbaudrate() to set if_baudrate_pf and if_baudrat…

…e_pf.

again, use ixgbe(4) as an example of how to use new helper function.

Reviewed by:	jhb
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@241646 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
  • Loading branch information...
commit 4de9cc890fcf0a2eacd3ad15dba814527aff316b 1 parent ce84d73
emax authored

Showing 3 changed files with 14 additions and 3 deletions. Show diff stats Hide diff stats

  1. +1 2  sys/dev/ixgbe/ixgbe.c
  2. +1 1  sys/net/if.h
  3. +12 0 sys/net/if_var.h
3  sys/dev/ixgbe/ixgbe.c
@@ -2597,8 +2597,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
2597 2597 return (-1);
2598 2598 }
2599 2599 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
2600   - ifp->if_baudrate = IF_Gbps(1);
2601   - ifp->if_baudrate_pf = 1; /* 1Gbps * 10^1 = 10Gbps */
  2600 + if_initbaudrate(ifp, IF_Gbps(10));
2602 2601 ifp->if_init = ixgbe_init;
2603 2602 ifp->if_softc = adapter;
2604 2603 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
2  sys/net/if.h
@@ -179,7 +179,7 @@ struct if_data {
179 179 * Some convenience macros used for setting ifi_baudrate.
180 180 * XXX 1000 vs. 1024? --thorpej@netbsd.org
181 181 */
182   -#define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */
  182 +#define IF_Kbps(x) ((uintmax_t)(x) * 1000) /* kilobits/sec. */
183 183 #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */
184 184 #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */
185 185
12 sys/net/if_var.h
@@ -591,6 +591,18 @@ do { \
591 591 } while (0)
592 592
593 593 #ifdef _KERNEL
  594 +static __inline void
  595 +if_initbaudrate(struct ifnet *ifp, uintmax_t baud)
  596 +{
  597 +
  598 + ifp->if_baudrate_pf = 0;
  599 + while (baud > (u_long)(~0UL)) {
  600 + baud /= 10;
  601 + ifp->if_baudrate_pf++;
  602 + }
  603 + ifp->if_baudrate = baud;
  604 +}
  605 +
594 606 static __inline int
595 607 drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
596 608 {

0 comments on commit 4de9cc8

Please sign in to comment.
Something went wrong with that request. Please try again.