From 8340ece577b9a6c1bcd060ba5ce9f17d9544af62 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Wed, 15 Aug 2012 01:03:13 +0000 Subject: [PATCH] The size of the buffers in an Ethernet freelist has to be higher than the interface's MTU. Initialize such freelists with correct values. This wasn't a problem for common MTUs (1500 and 9000) as the buffers (2048 and 9216 in size) happened to have enough spare room. I ran into it when playing around with unusual MTUs. MFC after: 2 weeks --- sys/dev/cxgbe/t4_sge.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index eee27421cda..09e5518da08 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -542,6 +542,18 @@ port_intr_iq(struct port_info *pi, int idx) return (iq); } +static inline int +mtu_to_bufsize(int mtu) +{ + int bufsize; + + /* large enough for a frame even when VLAN extraction is disabled */ + bufsize = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + mtu; + bufsize = roundup(bufsize + fl_pktshift, fl_pad); + + return (bufsize); +} + int t4_setup_port_queues(struct port_info *pi) { @@ -558,6 +570,7 @@ t4_setup_port_queues(struct port_info *pi) struct adapter *sc = pi->adapter; struct sysctl_oid *oid = device_get_sysctl_tree(pi->dev); struct sysctl_oid_list *children = SYSCTL_CHILDREN(oid); + int bufsize = mtu_to_bufsize(pi->ifp->if_mtu); oid = SYSCTL_ADD_NODE(&pi->ctx, children, OID_AUTO, "rxq", CTLFLAG_RD, NULL, "rx queues"); @@ -587,7 +600,7 @@ t4_setup_port_queues(struct port_info *pi) snprintf(name, sizeof(name), "%s rxq%d-fl", device_get_nameunit(pi->dev), i); - init_fl(&rxq->fl, pi->qsize_rxq / 8, pi->ifp->if_mtu, name); + init_fl(&rxq->fl, pi->qsize_rxq / 8, bufsize, name); if (sc->flags & INTR_DIRECT #ifdef TCP_OFFLOAD @@ -1451,11 +1464,8 @@ t4_update_fl_bufsize(struct ifnet *ifp) struct port_info *pi = ifp->if_softc; struct sge_rxq *rxq; struct sge_fl *fl; - int i, bufsize; + int i, bufsize = mtu_to_bufsize(ifp->if_mtu); - /* large enough for a frame even when VLAN extraction is disabled */ - bufsize = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ifp->if_mtu; - bufsize = roundup(bufsize + fl_pktshift, fl_pad); for_each_rxq(pi, i, rxq) { fl = &rxq->fl;