Module Name:    src
Committed By:   nat
Date:           Thu Apr 16 15:30:00 UTC 2020

Modified Files:
        src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_netbsd.c
            ieee80211_netbsd.h

Log Message:
Use if_stat functions.


To generate a diff of this commit:
cvs rdiff -u -r1.56.18.8 -r1.56.18.9 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.31.2.9 -r1.31.2.10 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.11 -r1.21.2.12 src/sys/net80211/ieee80211_netbsd.h

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

Modified files:

Index: src/sys/net80211/ieee80211.c
diff -u src/sys/net80211/ieee80211.c:1.56.18.8 src/sys/net80211/ieee80211.c:1.56.18.9
--- src/sys/net80211/ieee80211.c:1.56.18.8	Mon Apr 13 08:05:15 2020
+++ src/sys/net80211/ieee80211.c	Thu Apr 16 15:30:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.56.18.8 2020/04/13 08:05:15 martin Exp $ */
+/*	$NetBSD: ieee80211.c,v 1.56.18.9 2020/04/16 15:30:00 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.56.18.8 2020/04/13 08:05:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.56.18.9 2020/04/16 15:30:00 nat Exp $");
 #endif
 
 /*
@@ -2016,7 +2016,13 @@ ieee80211_media_init(struct ieee80211com
 	ifm_change_cb_t media_change, ifm_stat_cb_t media_stat)
 {
 
-	ieee80211_media_init_with_lock(ic, media_change, media_stat, NULL);
+	struct ieee80211vap *vap;
+
+	vap = TAILQ_FIRST(&ic->ic_vaps);
+	KASSERT(vap != NULL, ("media vap is null"));
+
+	ifmedia_init_with_lock(&vap->iv_media, 0, media_change,
+	    media_stat, NULL);
 }
 
 void
@@ -2030,8 +2036,8 @@ ieee80211_announce(struct ieee80211com *
 	for (mode = IEEE80211_MODE_AUTO+1; mode < IEEE80211_MODE_11NA; mode++) {
 		if (isclr(ic->ic_modecaps, mode))
 			continue;
-		aprint_debug("%s: %s rates: ", ifp->if_xname,
-		    ieee80211_phymode_name[mode]);
+		//aprint_debug("%s: %s rates: ", ifp->if_xname,
+		 //   ieee80211_phymode_name[mode]);
 		ic_printf(ic, "%s rates: ", ieee80211_phymode_name[mode]);
 		rs = &ic->ic_sup_rates[mode];
 		for (i = 0; i < rs->rs_nrates; i++) {

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.31.2.9 src/sys/net80211/ieee80211_netbsd.c:1.31.2.10
--- src/sys/net80211/ieee80211_netbsd.c:1.31.2.9	Tue Nov 19 19:17:16 2019
+++ src/sys/net80211/ieee80211_netbsd.c	Thu Apr 16 15:30:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.9 2019/11/19 19:17:16 phil Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.10 2020/04/16 15:30:00 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.9 2019/11/19 19:17:16 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.10 2020/04/16 15:30:00 nat Exp $");
 #endif
 
 /*
@@ -1183,45 +1183,59 @@ wlan_iflladdr(void *arg __unused, struct
 }
 #endif
 
+int64_t
+if_get_counter_default(struct ifnet * ifp, ift_counter cnt)
+{
+	struct if_data if_stats;
+	int64_t result;
+
+	if_stats_to_if_data(ifp, &if_stats, false);
+
+	result = (cnt == IFCOUNTER_OERRORS ? if_stats.ifi_oerrors :
+	    (cnt == IFCOUNTER_IERRORS ? if_stats.ifi_ierrors : 0 ));
+
+	return result;
+}
+
 void
 if_inc_counter(struct ifnet *ifp, ift_counter ifc, int64_t value)
 {
 	switch (ifc) {
 	case IFCOUNTER_IPACKETS:
-		ifp->if_data.ifi_ipackets += value;
+		if_statadd(ifp, if_ipackets, value);
 		break;
 	case IFCOUNTER_IERRORS:
-		ifp->if_data.ifi_ierrors += value;
+		if_statadd(ifp, if_ierrors, value);
 		break;
 	case IFCOUNTER_OPACKETS:
-		ifp->if_data.ifi_opackets += value;
+		if_statadd(ifp, if_opackets, value);
 		break;
 	case IFCOUNTER_OERRORS:
-		ifp->if_data.ifi_oerrors += value;
+		if_statadd(ifp, if_oerrors, value);
 		break;
         case IFCOUNTER_COLLISIONS:
-		ifp->if_data.ifi_collisions += value;
+		if_statadd(ifp, if_collisions, value);
 		break;
         case IFCOUNTER_IBYTES:
-		ifp->if_data.ifi_ibytes += value;
+		if_statadd(ifp, if_ibytes, value);
 		break;
         case IFCOUNTER_OBYTES:
-		ifp->if_data.ifi_obytes += value;
+		if_statadd(ifp, if_obytes, value);
 		break;
         case IFCOUNTER_IMCASTS:
-		ifp->if_data.ifi_imcasts += value;
+		if_statadd(ifp, if_imcasts, value);
 		break;
         case IFCOUNTER_OMCASTS:
-		ifp->if_data.ifi_omcasts += value;
+		if_statadd(ifp, if_omcasts, value);
 		break;
         case IFCOUNTER_IQDROPS:
-		ifp->if_data.ifi_iqdrops += value;
+		if_statadd(ifp, if_iqdrops, value);
 		break;
         case IFCOUNTER_OQDROPS:
 		/* ifp->if_data.ifi_oqdrops += value; No such field, just ignore it q*/
 		break;
         case IFCOUNTER_NOPROTO:
-		ifp->if_data.ifi_noproto += value;
+		if_statadd(ifp, if_noproto, value);
 		break;
 	default:
 		panic("if_inc_counter: non-existant counter");

Index: src/sys/net80211/ieee80211_netbsd.h
diff -u src/sys/net80211/ieee80211_netbsd.h:1.21.2.11 src/sys/net80211/ieee80211_netbsd.h:1.21.2.12
--- src/sys/net80211/ieee80211_netbsd.h:1.21.2.11	Mon Apr 13 08:05:16 2020
+++ src/sys/net80211/ieee80211_netbsd.h	Thu Apr 16 15:30:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.21.2.11 2020/04/13 08:05:16 martin Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.21.2.12 2020/04/16 15:30:00 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -172,10 +172,7 @@ typedef enum {
         IFCOUNTERS /* Array size. */
 } ift_counter;
 void       if_inc_counter(struct ifnet *, ift_counter, int64_t);
-
-#define if_get_counter_default(ipf,cnt)                 \
-	(cnt == IFCOUNTER_OERRORS ? ipf->if_oerrors :   \
-	    (cnt == IFCOUNTER_IERRORS ? ipf->if_ierrors : 0 ))
+int64_t    if_get_counter_default(struct ifnet *, ift_counter);
 
 #define IF_LLADDR(ifp)     (((struct ieee80211vap *)ifp->if_softc)->iv_myaddr)
 

Reply via email to