Use M_GETCTX and M_SETCTX instead of open-coding rcvif
No functional change.
This commit is contained in:
parent
5da2f1cee0
commit
cef59834c4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: altq_rio.c,v 1.22 2016/04/20 08:58:48 knakahara Exp $ */
|
||||
/* $NetBSD: altq_rio.c,v 1.23 2016/05/16 09:53:59 ozaki-r Exp $ */
|
||||
/* $KAME: altq_rio.c,v 1.19 2005/04/13 03:44:25 suz Exp $ */
|
||||
|
||||
/*
|
||||
@ -60,7 +60,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.22 2016/04/20 08:58:48 knakahara Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.23 2016/05/16 09:53:59 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_altq.h"
|
||||
@ -326,19 +326,6 @@ dscp2index(u_int8_t dscp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/*
|
||||
* kludge: when a packet is dequeued, we need to know its drop precedence
|
||||
* in order to keep the queue length of each drop precedence.
|
||||
* use m_pkthdr.rcvif to pass this info.
|
||||
*/
|
||||
#define RIOM_SET_PRECINDEX(m, idx) \
|
||||
do { (m)->m_pkthdr.rcvif = (struct ifnet *)((long)(idx)); } while (0)
|
||||
#define RIOM_GET_PRECINDEX(m) \
|
||||
({ long idx; idx = (long)((m)->m_pkthdr.rcvif); \
|
||||
(m)->m_pkthdr.rcvif = NULL; idx; })
|
||||
#endif
|
||||
|
||||
int
|
||||
rio_addq(rio_t *rp, class_queue_t *q, struct mbuf *m,
|
||||
struct altq_pktattr *pktattr)
|
||||
@ -436,7 +423,7 @@ rio_addq(rio_t *rp, class_queue_t *q, struct mbuf *m,
|
||||
rp->rio_precstate[i].qlen++;
|
||||
|
||||
/* save drop precedence index in mbuf hdr */
|
||||
RIOM_SET_PRECINDEX(m, dpindex);
|
||||
M_SETCTX(m, (intptr_t)dpindex);
|
||||
|
||||
if (rp->rio_flags & RIOF_CLEARDSCP)
|
||||
dsfield &= ~DSCP_MASK;
|
||||
@ -461,7 +448,7 @@ rio_getq(rio_t *rp, class_queue_t *q)
|
||||
if ((m = _getq(q)) == NULL)
|
||||
return NULL;
|
||||
|
||||
dpindex = RIOM_GET_PRECINDEX(m);
|
||||
dpindex = M_GETCTX(m, intptr_t);
|
||||
for (i = dpindex; i < RIO_NDROPPREC; i++) {
|
||||
if (--rp->rio_precstate[i].qlen == 0) {
|
||||
if (rp->rio_precstate[i].idle == 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtw.c,v 1.121 2014/02/25 18:30:09 pooka Exp $ */
|
||||
/* $NetBSD: rtw.c,v 1.122 2016/05/16 09:53:59 ozaki-r Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights
|
||||
* reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.121 2014/02/25 18:30:09 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.122 2016/05/16 09:53:59 ozaki-r Exp $");
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -1902,7 +1902,7 @@ rtw_intr_beacon(struct rtw_softc *sc, uint16_t isr)
|
||||
"could not allocate beacon\n");
|
||||
return;
|
||||
}
|
||||
m->m_pkthdr.rcvif = (void *)ieee80211_ref_node(ic->ic_bss);
|
||||
M_SETCTX(m, ieee80211_ref_node(ic->ic_bss));
|
||||
IF_ENQUEUE(&sc->sc_beaconq, m);
|
||||
rtw_start(&sc->sc_if);
|
||||
}
|
||||
@ -3062,8 +3062,8 @@ rtw_80211_dequeue(struct rtw_softc *sc, struct ifqueue *ifq, int pri,
|
||||
return NULL;
|
||||
}
|
||||
IF_DEQUEUE(ifq, m);
|
||||
*nip = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
*nip = M_GETCTX(m, struct ieee80211_node *);
|
||||
M_SETCTX(m, NULL);
|
||||
KASSERT(*nip != NULL);
|
||||
return m;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_netbsd.c,v 1.26 2014/04/07 00:07:40 pooka Exp $ */
|
||||
/* $NetBSD: ieee80211_netbsd.c,v 1.27 2016/05/16 09:53:59 ozaki-r Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.26 2014/04/07 00:07:40 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.27 2016/05/16 09:53:59 ozaki-r Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -515,10 +515,10 @@ ieee80211_drain_ifq(struct ifqueue *ifq)
|
||||
if (m == NULL)
|
||||
break;
|
||||
|
||||
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
||||
ni = M_GETCTX(m, struct ieee80211_node *);
|
||||
KASSERT(ni != NULL);
|
||||
ieee80211_free_node(ni);
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
M_SETCTX(m, NULL);
|
||||
|
||||
m_freem(m);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_output.c,v 1.53 2015/08/24 22:21:26 pooka Exp $ */
|
||||
/* $NetBSD: ieee80211_output.c,v 1.54 2016/05/16 09:53:59 ozaki-r Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
|
||||
@ -36,7 +36,7 @@
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
|
||||
#endif
|
||||
#ifdef __NetBSD__
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.53 2015/08/24 22:21:26 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.54 2016/05/16 09:53:59 ozaki-r Exp $");
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
@ -185,9 +185,9 @@ ieee80211_mgmt_output(struct ieee80211com *ic, struct ieee80211_node *ni,
|
||||
if (m == NULL)
|
||||
return ENOMEM;
|
||||
#ifdef __FreeBSD__
|
||||
KASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
|
||||
KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
|
||||
#endif
|
||||
m->m_pkthdr.rcvif = (void *)ni;
|
||||
M_SETCTX(m, ni);
|
||||
|
||||
wh = mtod(m, struct ieee80211_frame *);
|
||||
ieee80211_send_setup(ic, ni, wh,
|
||||
@ -247,7 +247,7 @@ ieee80211_send_nulldata(struct ieee80211_node *ni)
|
||||
ieee80211_unref_node(&ni);
|
||||
return ENOMEM;
|
||||
}
|
||||
m->m_pkthdr.rcvif = (void *) ni;
|
||||
M_SETCTX(m, ni);
|
||||
|
||||
wh = mtod(m, struct ieee80211_frame *);
|
||||
ieee80211_send_setup(ic, ni, wh,
|
||||
@ -1344,8 +1344,8 @@ ieee80211_send_probereq(struct ieee80211_node *ni,
|
||||
M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT);
|
||||
if (m == NULL)
|
||||
return ENOMEM;
|
||||
IASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
|
||||
m->m_pkthdr.rcvif = (void *)ni;
|
||||
KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
|
||||
M_SETCTX(m, ni);
|
||||
|
||||
wh = mtod(m, struct ieee80211_frame *);
|
||||
ieee80211_send_setup(ic, ni, wh,
|
||||
|
Loading…
Reference in New Issue
Block a user