mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
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
This commit is contained in:
parent
458beb5d92
commit
608ae712d3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241646
@ -2597,8 +2597,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
|
||||
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;
|
||||
|
@ -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. */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user