Sat Aug 20 19:11:08 2022 UTC ()
ural_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success".

(This one was an even worse anti-pattern than the others!)


(thorpej)
diff -r1.65 -r1.66 src/sys/dev/usb/if_ural.c

cvs diff -r1.65 -r1.66 src/sys/dev/usb/if_ural.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_ural.c 2020/03/15 23:04:51 1.65
+++ src/sys/dev/usb/if_ural.c 2022/08/20 19:11:08 1.66
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: if_ural.c,v 1.65 2020/03/15 23:04:51 thorpej Exp $ */ 1/* $NetBSD: if_ural.c,v 1.66 2022/08/20 19:11:08 thorpej Exp $ */
2/* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */ 2/* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2005, 2006 5 * Copyright (c) 2005, 2006
6 * Damien Bergamini <damien.bergamini@free.fr> 6 * Damien Bergamini <damien.bergamini@free.fr>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21/*- 21/*-
22 * Ralink Technology RT2500USB chipset driver 22 * Ralink Technology RT2500USB chipset driver
23 * http://www.ralinktech.com/ 23 * http://www.ralinktech.com/
24 */ 24 */
25 25
26#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.65 2020/03/15 23:04:51 thorpej Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.66 2022/08/20 19:11:08 thorpej Exp $");
28 28
29#ifdef _KERNEL_OPT 29#ifdef _KERNEL_OPT
30#include "opt_usb.h" 30#include "opt_usb.h"
31#endif 31#endif
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/sockio.h> 34#include <sys/sockio.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36#include <sys/mbuf.h> 36#include <sys/mbuf.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/socket.h> 38#include <sys/socket.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/conf.h> 40#include <sys/conf.h>
@@ -1366,34 +1366,34 @@ ural_start(struct ifnet *ifp) @@ -1366,34 +1366,34 @@ ural_start(struct ifnet *ifp)
1366 break; 1366 break;
1367 } 1367 }
1368 IF_DEQUEUE(&ic->ic_mgtq, m0); 1368 IF_DEQUEUE(&ic->ic_mgtq, m0);
1369 1369
1370 ni = M_GETCTX(m0, struct ieee80211_node *); 1370 ni = M_GETCTX(m0, struct ieee80211_node *);
1371 M_CLEARCTX(m0); 1371 M_CLEARCTX(m0);
1372 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); 1372 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
1373 if (ural_tx_mgt(sc, m0, ni) != 0) 1373 if (ural_tx_mgt(sc, m0, ni) != 0)
1374 break; 1374 break;
1375 1375
1376 } else { 1376 } else {
1377 if (ic->ic_state != IEEE80211_S_RUN) 1377 if (ic->ic_state != IEEE80211_S_RUN)
1378 break; 1378 break;
1379 IFQ_DEQUEUE(&ifp->if_snd, m0); 1379 IFQ_POLL(&ifp->if_snd, m0);
1380 if (m0 == NULL) 1380 if (m0 == NULL)
1381 break; 1381 break;
1382 if (sc->tx_queued >= RAL_TX_LIST_COUNT) { 1382 if (sc->tx_queued >= RAL_TX_LIST_COUNT) {
1383 IF_PREPEND(&ifp->if_snd, m0); 
1384 ifp->if_flags |= IFF_OACTIVE; 1383 ifp->if_flags |= IFF_OACTIVE;
1385 break; 1384 break;
1386 } 1385 }
 1386 IFQ_DEQUEUE(&ifp->if_snd, m0);
1387 1387
1388 if (m0->m_len < sizeof(struct ether_header) && 1388 if (m0->m_len < sizeof(struct ether_header) &&
1389 !(m0 = m_pullup(m0, sizeof(struct ether_header)))) 1389 !(m0 = m_pullup(m0, sizeof(struct ether_header))))
1390 continue; 1390 continue;
1391 1391
1392 eh = mtod(m0, struct ether_header *); 1392 eh = mtod(m0, struct ether_header *);
1393 ni = ieee80211_find_txnode(ic, eh->ether_dhost); 1393 ni = ieee80211_find_txnode(ic, eh->ether_dhost);
1394 if (ni == NULL) { 1394 if (ni == NULL) {
1395 m_freem(m0); 1395 m_freem(m0);
1396 continue; 1396 continue;
1397 } 1397 }
1398 bpf_mtap(ifp, m0, BPF_D_OUT); 1398 bpf_mtap(ifp, m0, BPF_D_OUT);
1399 m0 = ieee80211_encap(ic, m0, ni); 1399 m0 = ieee80211_encap(ic, m0, ni);