summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2015-05-12 20:20:18 +0000
committerkettenis <kettenis@openbsd.org>2015-05-12 20:20:18 +0000
commit9a39b166e45206f985fb015f90a387e6545f07ce (patch)
tree672b6e476c6949294799808d642999a95ef60994
parentAdd dlclose(3) to SEE ALSO (diff)
downloadwireguard-openbsd-9a39b166e45206f985fb015f90a387e6545f07ce.tar.xz
wireguard-openbsd-9a39b166e45206f985fb015f90a387e6545f07ce.zip
Make sure the rx ring lwm is set to at least 4. As far as we know, all
hardware variants need at least 4 descriptors on the rx ring to be able to receive packets. Should fix the issue reported by Christian Schulte on bugs@. ok mikeb@, sthen@
-rw-r--r--sys/dev/pci/if_em.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c
index cc55e79f685..908e74ff506 100644
--- a/sys/dev/pci/if_em.c
+++ b/sys/dev/pci/if_em.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_em.c,v 1.296 2015/05/12 02:33:39 jsg Exp $ */
+/* $OpenBSD: if_em.c,v 1.297 2015/05/12 20:20:18 kettenis Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@@ -2599,6 +2599,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);
@@ -2610,8 +2611,8 @@ em_setup_receive_structures(struct em_softc *sc)
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",