From a717bb6c38096e149136b0eef90a30d50895e9d8 Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 18 Mar 2024 06:05:23 +0000 Subject: [PATCH] use high bits from the mbuf flowid to pick a port to transmit on. a port here is a physical interface used by an aggr. this leaves the low bits for a physical interface to use to pick a tx ring. without this, aggr used low bits for port selection, which takes bits away from the ring selection, which can lead to uneven distribution of packets over tx rings. ive been running this in production for well over a year now. --- sys/net/if_aggr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/net/if_aggr.c b/sys/net/if_aggr.c index 748b3c9224f..21a6cc06800 100644 --- a/sys/net/if_aggr.c +++ b/sys/net/if_aggr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aggr.c,v 1.43 2024/03/04 04:44:12 dlg Exp $ */ +/* $OpenBSD: if_aggr.c,v 1.44 2024/03/18 06:05:23 dlg Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -299,7 +299,10 @@ static const char *lacp_mux_event_names[] = { * aggr interface */ -#define AGGR_MAX_PORTS 32 +#define AGGR_PORT_BITS 5 +#define AGGR_FLOWID_SHIFT (16 - AGGR_PORT_BITS) + +#define AGGR_MAX_PORTS (1 << AGGR_PORT_BITS) #define AGGR_MAX_SLOW_PKTS (AGGR_MAX_PORTS * 3) struct aggr_multiaddr { @@ -660,7 +663,7 @@ aggr_transmit(struct aggr_softc *sc, const struct aggr_map *map, struct mbuf *m) #endif if (ISSET(m->m_pkthdr.csum_flags, M_FLOWID)) - flow = m->m_pkthdr.ph_flowid; + flow = m->m_pkthdr.ph_flowid >> AGGR_FLOWID_SHIFT; ifp0 = map->m_ifp0s[flow % AGGR_MAX_PORTS]; -- 2.20.1