Re: git: eb1da3e52582 - main - DrvAPI: Extend driver KPI with more accessors

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Fri, 23 Dec 2022 18:42:14 UTC
On Fri, 23 Dec 2022 10:35:54 -0800
Gleb Smirnoff <glebius@freebsd.org> wrote:

>   Justin,
> 
> On Tue, Dec 20, 2022 at 04:23:35PM +0000, Justin Hibbits wrote:
> J> The branch main has been updated by jhibbits:
> J> 
> J> URL:
> J> https://cgit.FreeBSD.org/src/commit/?id=eb1da3e5258238e1c0555c6a006a341df0821d8e
> J> 
> J> commit eb1da3e5258238e1c0555c6a006a341df0821d8e
> J> Author:     Justin Hibbits <jhibbits@FreeBSD.org>
> J> AuthorDate: 2022-12-09 20:54:51 +0000
> J> Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
> J> CommitDate: 2022-12-20 16:18:50 +0000
> J> 
> J>     DrvAPI: Extend driver KPI with more accessors
> J>     
> J>     Summary:
> J>     Add the following accessors to hide some more netstack details:
> J>     * if_get/setcapabilities2 and *bits analogue
> J>     * if_setdname
> J>     * if_getxname
> J>     * if_transmit - wrapper for call to ifp->if_transmit()
> J>     - This required changing the existing if_transmit to
> J>     if_transmit_default, since that's its purpose.
> J>     * if_getalloctype
> J>     * if_getindex
> J>     * if_foreach_addr_type - Like if_foreach_lladdr() but for any
> J> address family type.  Used by some drivers to iterate over all
> J> AF_INET addresses.
> J>     * if_init() - wrapper for ifp->if_init() call
> J>     * if_setinputfn
> J>     * if_setsndtagallocfn
> J>     * if_togglehwassist
> J>     
> J>     Reviewers: #transport, #network, glebius, melifaro
> J>     
> J>     Reviewed by:    #network, melifaro
> J>     Sponsored by:   Juniper Networks, Inc.
> J>     Differential Revision: https://reviews.freebsd.org/D37664  
> 
> sorry for not reviewing in time. I got a question. Lots of added code
> uses (struct ifnet *) cast on an argument that is already if_t. Why
> could this be necessary? Example:
> 
> void
> if_setsndtagallocfn(if_t ifp, if_snd_tag_alloc_t alloc_fn)
> {
>         ((struct ifnet *)ifp)->if_snd_tag_alloc = alloc_fn;
> }
> 

Hi Gleb,

You're right, none of it should have the struct ifnet cast, it's
completely redundant.  I'm going to remove *all* of these casts
(even all existing ones) in one fell swoop at the end of this
conversion, around mid January.

- Justin