git: c255d1a401c7 - main - IfAPI: Add if_llsoftc member accessors for TOEDEV

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Tue, 31 Jan 2023 20:03:17 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=c255d1a401c7ed736ba6bb7894deda584356bfaf

commit c255d1a401c7ed736ba6bb7894deda584356bfaf
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2023-01-23 15:11:02 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-01-31 20:02:16 +0000

    IfAPI: Add if_llsoftc member accessors for TOEDEV
    
    Summary:
    Keep TOEDEV() macro for backwards compatibility, and add a SETTOEDEV()
    macro to complement with the new accessors.
    
    Sponsored by:   Juniper Networks, Inc.
    Reviewed by:    glebius
    Differential Revision: https://reviews.freebsd.org/D38199
---
 sys/dev/cxgbe/tom/t4_tom.c |  2 +-
 sys/net/if.c               | 12 ++++++++++++
 sys/net/if_var.h           |  5 ++++-
 sys/net/if_vlan.c          |  2 +-
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index 869373515a3a..aae78d99abef 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -1901,7 +1901,7 @@ t4_tom_activate(struct adapter *sc)
 
 	for_each_port(sc, i) {
 		for_each_vi(sc->port[i], v, vi) {
-			TOEDEV(vi->ifp) = &td->tod;
+			SETTOEDEV(vi->ifp, &td->tod);
 		}
 	}
 
diff --git a/sys/net/if.c b/sys/net/if.c
index a6cf6d050875..1a42b562190d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -4827,6 +4827,18 @@ if_gettype(if_t ifp)
 	return (ifp->if_type);
 }
 
+void *
+if_getllsoftc(if_t ifp)
+{
+	return (ifp->if_llsoftc);
+}
+
+void
+if_setllsoftc(if_t ifp, void *llsoftc)
+{
+	ifp->if_llsoftc = llsoftc;
+};
+
 #ifdef DDB
 static void
 if_show_ifnet(struct ifnet *ifp)
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index e9e6086bfa89..3b293cdff26f 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -412,7 +412,8 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
 #define	IF_MINMTU	72
 #define	IF_MAXMTU	65535
 
-#define	TOEDEV(ifp)	((ifp)->if_llsoftc)
+#define	TOEDEV(ifp)		if_getllsoftc(ifp)
+#define	SETTOEDEV(ifp, sc)	if_setllsoftc((ifp), (sc))
 
 /*
  * The ifaddr structure contains information about one address
@@ -597,6 +598,8 @@ int if_togglehwassist(if_t ifp, int toggle_bits);
 int if_setsoftc(if_t ifp, void *softc);
 void *if_getsoftc(if_t ifp);
 int if_setflags(if_t ifp, int flags);
+void if_setllsoftc(if_t ifp, void *softc);
+void *if_getllsoftc(if_t ifp);
 int if_gethwaddr(const if_t ifp, struct ifreq *);
 int if_setmtu(if_t ifp, int mtu);
 int if_getmtu(const if_t ifp);
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index d908d97b6e6d..d8be44b105f1 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1922,7 +1922,7 @@ vlan_capabilities(struct ifvlan *ifv)
 	if (p->if_capabilities & IFCAP_VLAN_TOE)
 		cap |= p->if_capabilities & IFCAP_TOE;
 	if (p->if_capenable & IFCAP_VLAN_TOE) {
-		TOEDEV(ifp) = TOEDEV(p);
+		SETTOEDEV(ifp, TOEDEV(p));
 		ena |= mena & IFCAP_TOE;
 	}