K 10 svn:author V 7 glebius K 8 svn:date V 27 2015-01-13T09:02:06.883528Z K 7 svn:log V 2264 Welcome first real hardware NIC driver successfully converted to new API, which hides struct ifnet from drivers entirely. This driver can be taken as an example, and this commit message will probably be used to start a wiki page on conversion. List of changes required: o Remove at least if_var.h, bpf.h, if_arp.h, if_types.h, if_vlan_var.h from includes list. o Declare struct ifdriver in the beginning of a file. o Convert from xxx_start(ifp) to xxx_transmit(ifp, m). A simple conversion itself is quite straight: * In ifdriver declaration define .ifdrv_maxqlen, take the value from IFQ_SET_MAXLEN() macro. * In ifdriver ifops declaration define if_transmit function. * Rename xxx_start() to xxx_transmit() and change its prototype. * The new named xxx_transmit() should: - Try to if_snd_enqueue() the mbuf or return. - Try to mtx_lock() the driver softc or return. - Process the queue in loop starting with the if_snd_dequeue(). The loop is simply based on previous loop that did IFQ_DRV_IS_EMPTY/IFQ_DRV_DEQUEUE. * Do not do any statistic accounting in xxx_transmit(). This should be done in TX completion interrupt. o Forget IFF_DRV_RUNNING. Many drivers utilize this flag a lot for its internal state keeping. So, simply move it into softc flags. This can be achieved with sed(1). o Convert all accesses to if_flags, if_capenable, if_mtu to if_get(). The most heavy functions is usually xxx_ioctl(). o Rewrite device attach method xxx_attach(). New method should look like: * Declare struct if_attach_args on stack and initialize it with static values. * Do all important hardware initialization. No modification needed here except of mii_attach(), which now doesn't take if_t argument. * When all hardware successfully inited, fill in the rest of if_attach_args and call if_attach(). It can't fail. o Miibus now doesn't modify ifnet(9). * You need to init the baudrate in xxx_attach() and later maintain it in miibus_statchg method. * You need to maintain the if_link_state in miibus_linkchg method. o Run through the file and change rest of 'struct ifnet *' to if_t. A converted file should return 0 on "grep ifnet if_xxx.c". Committed via: msk0 Sponsored by: Nginx, Inc. END