git: dbe86dd5de18 - main - lagg(4): Refactor out some lagg protocol input routines into a default one
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Mar 2023 16:32:39 UTC
The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=dbe86dd5de18fdf61e1300f6575e0f50785bf6b3 commit dbe86dd5de18fdf61e1300f6575e0f50785bf6b3 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2023-03-29 16:16:21 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2023-03-29 16:22:13 +0000 lagg(4): Refactor out some lagg protocol input routines into a default one Those input routines are identical. Also inline two fast paths. No functional change intended. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39251 --- sys/net/if_lagg.c | 64 ++++++++++++++++++------------------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 42c194233a89..7acfa524670c 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -171,8 +171,6 @@ static struct lagg_port *lagg_link_active(struct lagg_softc *, /* Simple round robin */ static void lagg_rr_attach(struct lagg_softc *); static int lagg_rr_start(struct lagg_softc *, struct mbuf *); -static struct mbuf *lagg_rr_input(struct lagg_softc *, struct lagg_port *, - struct mbuf *); /* Active failover */ static int lagg_fail_start(struct lagg_softc *, struct mbuf *); @@ -185,14 +183,10 @@ static void lagg_lb_detach(struct lagg_softc *); static int lagg_lb_port_create(struct lagg_port *); static void lagg_lb_port_destroy(struct lagg_port *); static int lagg_lb_start(struct lagg_softc *, struct mbuf *); -static struct mbuf *lagg_lb_input(struct lagg_softc *, struct lagg_port *, - struct mbuf *); static int lagg_lb_porttable(struct lagg_softc *, struct lagg_port *); /* Broadcast */ static int lagg_bcast_start(struct lagg_softc *, struct mbuf *); -static struct mbuf *lagg_bcast_input(struct lagg_softc *, struct lagg_port *, - struct mbuf *); /* 802.3ad LACP */ static void lagg_lacp_attach(struct lagg_softc *); @@ -202,6 +196,10 @@ static struct mbuf *lagg_lacp_input(struct lagg_softc *, struct lagg_port *, struct mbuf *); static void lagg_lacp_lladdr(struct lagg_softc *); +/* Default input */ +static struct mbuf *lagg_default_input(struct lagg_softc *, struct lagg_port *, + struct mbuf *); + /* lagg protocol table */ static const struct lagg_proto { lagg_proto pr_num; @@ -226,7 +224,7 @@ static const struct lagg_proto { .pr_num = LAGG_PROTO_ROUNDROBIN, .pr_attach = lagg_rr_attach, .pr_start = lagg_rr_start, - .pr_input = lagg_rr_input, + .pr_input = lagg_default_input, }, { .pr_num = LAGG_PROTO_FAILOVER, @@ -238,7 +236,7 @@ static const struct lagg_proto { .pr_attach = lagg_lb_attach, .pr_detach = lagg_lb_detach, .pr_start = lagg_lb_start, - .pr_input = lagg_lb_input, + .pr_input = lagg_default_input, .pr_addport = lagg_lb_port_create, .pr_delport = lagg_lb_port_destroy, }, @@ -260,7 +258,7 @@ static const struct lagg_proto { { .pr_num = LAGG_PROTO_BROADCAST, .pr_start = lagg_bcast_start, - .pr_input = lagg_bcast_input, + .pr_input = lagg_default_input, }, }; @@ -387,14 +385,14 @@ lagg_proto_detach(struct lagg_softc *sc) lagg_protos[pr].pr_detach(sc); } -static int +static inline int lagg_proto_start(struct lagg_softc *sc, struct mbuf *m) { return (lagg_protos[sc->sc_proto].pr_start(sc, m)); } -static struct mbuf * +static inline struct mbuf * lagg_proto_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) { @@ -2427,17 +2425,6 @@ lagg_rr_start(struct lagg_softc *sc, struct mbuf *m) return (lagg_enqueue(lp->lp_ifp, m)); } -static struct mbuf * -lagg_rr_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) -{ - struct ifnet *ifp = sc->sc_ifp; - - /* Just pass in the packet to our lagg device */ - m->m_pkthdr.rcvif = ifp; - - return (m); -} - /* * Broadcast mode */ @@ -2485,16 +2472,6 @@ lagg_bcast_start(struct lagg_softc *sc, struct mbuf *m) return (ret); } -static struct mbuf* -lagg_bcast_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) -{ - struct ifnet *ifp = sc->sc_ifp; - - /* Just pass in the packet to our lagg device */ - m->m_pkthdr.rcvif = ifp; - return (m); -} - /* * Active failover */ @@ -2638,17 +2615,6 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m) return (lagg_enqueue(lp->lp_ifp, m)); } -static struct mbuf * -lagg_lb_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) -{ - struct ifnet *ifp = sc->sc_ifp; - - /* Just pass in the packet to our lagg device */ - m->m_pkthdr.rcvif = ifp; - - return (m); -} - /* * 802.3ad LACP */ @@ -2740,3 +2706,15 @@ lagg_lacp_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) m->m_pkthdr.rcvif = ifp; return (m); } + +/* Default input */ +static struct mbuf * +lagg_default_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) +{ + struct ifnet *ifp = sc->sc_ifp; + + /* Just pass in the packet to our lagg device */ + m->m_pkthdr.rcvif = ifp; + + return (m); +}