[RFC] how to get real ifi_baudrate from network interface

Maksim Yevmenkin maksim.yevmenkin at gmail.com
Wed Sep 19 21:16:18 UTC 2012


hello,

for sometime now i've been repeatedly annoyed by the fact that 10G
interfaces lie about their ifi_baudrate. i would like to propose
simple (hopefuly) change to address this.

quick summary of the problem:

struct if_data {
...
        u_char  ifi_spare_char1;        /* spare byte */
        u_char  ifi_spare_char2;        /* spare byte */
...
        u_long  ifi_baudrate;           /* linespeed */
...
};

as you can see ifi_baudrate is an u_long which is an arch specific
type. on 32-bit arch it does not have enough bits to hold 10G line
speed value (in bits per second)

proposal

we reuse one of the ifi_spare_char1 or ifi_spare_char2 bytes and
re-purpose it as power factor to be applied to ifi_baudrate, i.e.

real_ifi_baudrate = ifi_baudrate * 10 ** ifi_spare_char1

obviously, 10G nic drivers will have to set ifi_spare_char1 to
appropriate value, but it should not be a big deal. also, legacy tools
that do not know about ifi_spare_char1 would continue to report
"wrong" ifi_baudrate as they used to.

any objections?

thanks,
max


More information about the freebsd-current mailing list