Module Name:    src
Committed By:   ozaki-r
Date:           Mon May 16 09:53:59 UTC 2016

Modified Files:
        src/sys/altq: altq_rio.c
        src/sys/dev/ic: rtw.c
        src/sys/net80211: ieee80211_netbsd.c ieee80211_output.c

Log Message:
Use M_GETCTX and M_SETCTX instead of open-coding rcvif

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/altq/altq_rio.c
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/ic/rtw.c
cvs rdiff -u -r1.26 -r1.27 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.53 -r1.54 src/sys/net80211/ieee80211_output.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/altq/altq_rio.c
diff -u src/sys/altq/altq_rio.c:1.22 src/sys/altq/altq_rio.c:1.23
--- src/sys/altq/altq_rio.c:1.22	Wed Apr 20 08:58:48 2016
+++ src/sys/altq/altq_rio.c	Mon May 16 09:53:59 2016
@@ -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, st
 		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) {

Index: src/sys/dev/ic/rtw.c
diff -u src/sys/dev/ic/rtw.c:1.121 src/sys/dev/ic/rtw.c:1.122
--- src/sys/dev/ic/rtw.c:1.121	Tue Feb 25 18:30:09 2014
+++ src/sys/dev/ic/rtw.c	Mon May 16 09:53:59 2016
@@ -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, ui
 			    "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, 
 		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;
 }

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.26 src/sys/net80211/ieee80211_netbsd.c:1.27
--- src/sys/net80211/ieee80211_netbsd.c:1.26	Mon Apr  7 00:07:40 2014
+++ src/sys/net80211/ieee80211_netbsd.c	Mon May 16 09:53:59 2016
@@ -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);
 	}

Index: src/sys/net80211/ieee80211_output.c
diff -u src/sys/net80211/ieee80211_output.c:1.53 src/sys/net80211/ieee80211_output.c:1.54
--- src/sys/net80211/ieee80211_output.c:1.53	Mon Aug 24 22:21:26 2015
+++ src/sys/net80211/ieee80211_output.c	Mon May 16 09:53:59 2016
@@ -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 ieee80211co
 	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
 		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
 	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,

Reply via email to