> Date: Mon, 11 May 2015 12:37:19 -0400
> From: Brad Smith <[email protected]>
>
> On 05/11/15 10:23, Stuart Henderson wrote:
> > If all em(4) need 4 descriptors, would it make more sense to just enforce
> > lwm >= 4? Both from a self-documentation point of view, and to avoid a
> > potential trap if some nic was discovered to support <2k baby jumbos
> > i.e. give the same result for the if_hardmtu/MCLBYTES sum.
>
> That is the whole point of the diff.
>
> That doesn't involve chaining so it doesn't make any sense.
Well, I agree with sthen@. It is far from obvious that this code
guarantees that we have at least 4 descriptors available for the
receive ring.
I'd go with something like the diff below instead.
Index: if_em.c
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/if_em.c,v
retrieving revision 1.295
diff -u -p -r1.295 if_em.c
--- if_em.c 11 Feb 2015 23:21:47 -0000 1.295
+++ if_em.c 11 May 2015 18:36:32 -0000
@@ -2597,6 +2597,7 @@ int
em_setup_receive_structures(struct em_softc *sc)
{
struct ifnet *ifp = &sc->interface_data.ac_if;
+ u_int lwm;
memset(sc->rx_desc_base, 0,
sizeof(struct em_rx_desc) * sc->num_rx_desc);
@@ -2608,8 +2609,8 @@ em_setup_receive_structures(struct em_so
sc->next_rx_desc_to_check = 0;
sc->last_rx_desc_filled = sc->num_rx_desc - 1;
- if_rxr_init(&sc->rx_ring, 2 * ((ifp->if_hardmtu / MCLBYTES) + 1),
- sc->num_rx_desc);
+ lwm = max(4, 2 * ((ifp->if_hardmtu / MCLBYTES) + 1));
+ if_rxr_init(&sc->rx_ring, lwm, sc->num_rx_desc);
if (em_rxfill(sc) == 0) {
printf("%s: unable to fill any rx descriptors\n",