Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2018 19:38:13 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342197 - head/sys/dev/usb/net
Message-ID:  <201812181938.wBIJcDEw014210@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Tue Dec 18 19:38:13 2018
New Revision: 342197
URL: https://svnweb.freebsd.org/changeset/base/342197

Log:
  Use mbufq instead of ifqueue to queue mbufs.

Modified:
  head/sys/dev/usb/net/uhso.c

Modified: head/sys/dev/usb/net/uhso.c
==============================================================================
--- head/sys/dev/usb/net/uhso.c	Tue Dec 18 19:05:57 2018	(r342196)
+++ head/sys/dev/usb/net/uhso.c	Tue Dec 18 19:38:13 2018	(r342197)
@@ -98,7 +98,7 @@ struct uhso_softc {
 	struct ifnet		*sc_ifp;
 	struct mbuf		*sc_mwait;	/* Partial packet */
 	size_t			sc_waitlen;	/* No. of outstanding bytes */
-	struct ifqueue		sc_rxq;
+	struct mbufq		sc_rxq;
 	struct callout		sc_c;
 
 	/* TTY related structures */
@@ -560,6 +560,7 @@ uhso_attach(device_t self)
 	sc->sc_dev = self;
 	sc->sc_udev = uaa->device;
 	mtx_init(&sc->sc_mtx, "uhso", NULL, MTX_DEF);
+	mbufq_init(&sc->sc_rxq, INT_MAX);	/* XXXGL: sane maximum */
 	ucom_ref(&sc->sc_super_ucom);
 
 	sc->sc_radio = 1;
@@ -1626,11 +1627,13 @@ uhso_ifnet_read_callback(struct usb_xfer *xfer, usb_er
 	case USB_ST_TRANSFERRED:
 		if (actlen > 0 && (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)) {
 			pc = usbd_xfer_get_frame(xfer, 0);
+			if (mbufq_full(&sc->sc_rxq))
+				break;
 			m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
 			usbd_copy_out(pc, 0, mtod(m, uint8_t *), actlen);
 			m->m_pkthdr.len = m->m_len = actlen;
 			/* Enqueue frame for further processing */
-			_IF_ENQUEUE(&sc->sc_rxq, m);
+			mbufq_enqueue(&sc->sc_rxq, m);
 			if (!callout_pending(&sc->sc_c) ||
 			    !callout_active(&sc->sc_c)) {
 				callout_schedule(&sc->sc_c, 1);
@@ -1676,8 +1679,7 @@ uhso_if_rxflush(void *arg)
 	mwait = sc->sc_mwait;
 	for (;;) {
 		if (m == NULL) {
-			_IF_DEQUEUE(&sc->sc_rxq, m);
-			if (m == NULL)
+			if ((m = mbufq_dequeue(&sc->sc_rxq)) == NULL)
 				break;
 			UHSO_DPRINTF(3, "dequeue m=%p, len=%d\n", m, m->m_len);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812181938.wBIJcDEw014210>