Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_lagg.h
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
struct lagg_counters { | struct lagg_counters { | ||||
uint64_t val[IFCOUNTERS]; | uint64_t val[IFCOUNTERS]; | ||||
}; | }; | ||||
struct lagg_softc { | struct lagg_softc { | ||||
struct ifnet *sc_ifp; /* virtual interface */ | struct ifnet *sc_ifp; /* virtual interface */ | ||||
struct rmlock sc_mtx; | struct rmlock sc_mtx; | ||||
struct sx sc_sx; | struct sx sc_sx; | ||||
bool sc_slowpath; | |||||
int sc_proto; /* lagg protocol */ | int sc_proto; /* lagg protocol */ | ||||
u_int sc_count; /* number of ports */ | u_int sc_count; /* number of ports */ | ||||
u_int sc_active; /* active port count */ | u_int sc_active; /* active port count */ | ||||
u_int sc_flapping; /* number of flapping | u_int sc_flapping; /* number of flapping | ||||
* events */ | * events */ | ||||
struct lagg_port *sc_primary; /* primary port */ | struct lagg_port *sc_primary; /* primary port */ | ||||
struct ifmedia sc_media; /* media config */ | struct ifmedia sc_media; /* media config */ | ||||
void *sc_psc; /* protocol data */ | void *sc_psc; /* protocol data */ | ||||
Show All 35 Lines | int (*lp_output)(struct ifnet *, struct mbuf *, | ||||
const struct sockaddr *, struct route *); | const struct sockaddr *, struct route *); | ||||
struct lagg_counters port_counters; /* ifp counters copy */ | struct lagg_counters port_counters; /* ifp counters copy */ | ||||
SLIST_ENTRY(lagg_port) lp_entries; | SLIST_ENTRY(lagg_port) lp_entries; | ||||
}; | }; | ||||
#define LAGG_LOCK_INIT(_sc) rm_init(&(_sc)->sc_mtx, "if_lagg rmlock") | #define LAGG_LOCK_INIT(_sc) rm_init(&(_sc)->sc_mtx, "if_lagg rmlock") | ||||
#define LAGG_LOCK_DESTROY(_sc) rm_destroy(&(_sc)->sc_mtx) | #define LAGG_LOCK_DESTROY(_sc) rm_destroy(&(_sc)->sc_mtx) | ||||
#define LAGG_RLOCK(_sc, _p) rm_rlock(&(_sc)->sc_mtx, (_p)) | |||||
#define LAGG_WLOCK(_sc) rm_wlock(&(_sc)->sc_mtx) | |||||
#define LAGG_RUNLOCK(_sc, _p) rm_runlock(&(_sc)->sc_mtx, (_p)) | |||||
#define LAGG_WUNLOCK(_sc) rm_wunlock(&(_sc)->sc_mtx) | |||||
#define LAGG_RLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_RLOCKED) | |||||
#define LAGG_WLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_WLOCKED) | |||||
#define LAGG_UNLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_UNLOCKED) | |||||
#define LAGG_SX_INIT(_sc) sx_init(&(_sc)->sc_sx, "if_lagg sx") | #define LAGG_SX_INIT(_sc) sx_init(&(_sc)->sc_sx, "if_lagg sx") | ||||
#define LAGG_SX_DESTROY(_sc) sx_destroy(&(_sc)->sc_sx) | #define LAGG_SX_DESTROY(_sc) sx_destroy(&(_sc)->sc_sx) | ||||
#define LAGG_SLOCK(_sc) sx_slock(&(_sc)->sc_sx) | |||||
#define LAGG_XLOCK(_sc) sx_xlock(&(_sc)->sc_sx) | |||||
#define LAGG_SUNLOCK(_sc) sx_sunlock(&(_sc)->sc_sx) | |||||
#define LAGG_XUNLOCK(_sc) sx_xunlock(&(_sc)->sc_sx) | |||||
#define LAGG_SXLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_LOCKED) | #define LAGG_SXLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_LOCKED) | ||||
melifaro: These primitives seem to be used in the control path. Why not convert them to functions?
This… | |||||
Not Done Inline ActionsDone. I also did the lagg_rlock and lagg_runlock() as inline. shurd: Done. I also did the lagg_rlock and lagg_runlock() as inline. | |||||
#define LAGG_SLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_SLOCKED) | #define LAGG_SLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_SLOCKED) | ||||
#define LAGG_XLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_XLOCKED) | #define LAGG_XLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_XLOCKED) | ||||
extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *); | extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *); | ||||
extern void (*lagg_linkstate_p)(struct ifnet *, int ); | extern void (*lagg_linkstate_p)(struct ifnet *, int ); | ||||
int lagg_enqueue(struct ifnet *, struct mbuf *); | int lagg_enqueue(struct ifnet *, struct mbuf *); | ||||
SYSCTL_DECL(_net_link_lagg); | SYSCTL_DECL(_net_link_lagg); | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* _NET_LAGG_H */ | #endif /* _NET_LAGG_H */ |
These primitives seem to be used in the control path. Why not convert them to functions?
This kind of spaghetti is unmaintainable.