Author: np
Date: Wed Aug 15 01:03:13 2012
New Revision: 239266
URL: http://svn.freebsd.org/changeset/base/239266

Log:
  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

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c Wed Aug 15 00:45:15 2012        (r239265)
+++ head/sys/dev/cxgbe/t4_sge.c Wed Aug 15 01:03:13 2012        (r239266)
@@ -542,6 +542,18 @@ port_intr_iq(struct port_info *pi, int i
        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 *p
        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 *p
 
                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;
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to