Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Feb 2005 17:42:52 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 70524 for review
Message-ID:  <200502071742.j17Hgqcp028314@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=70524

Change 70524 by sam@sam_ebb on 2005/02/07 17:42:03

	use revised cloning support to create/destroy virtual ap's
	instead of using private support; update drivers for revised api's

Affected files ...

.. //depot/projects/vap/sys/dev/ath/if_ath.c#5 edit
.. //depot/projects/vap/sys/dev/iwi/if_iwi.c#3 edit
.. //depot/projects/vap/sys/dev/wi/if_wi.c#3 edit
.. //depot/projects/vap/sys/net80211/ieee80211.c#4 edit
.. //depot/projects/vap/sys/net80211/ieee80211_freebsd.c#3 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#4 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ioctl.h#3 edit
.. //depot/projects/vap/sys/net80211/ieee80211_var.h#6 edit

Differences ...

==== //depot/projects/vap/sys/dev/ath/if_ath.c#5 (text+ko) ====

@@ -99,7 +99,8 @@
 	ATH_LED_POLL,
 };
 
-static struct ieee80211vap *ath_vap_create(struct ieee80211com *, int opmode);
+static struct ieee80211vap *ath_vap_create(struct ieee80211com *, 
+			const char name[IFNAMSIZ], int unit, int opmode);
 static void	ath_vap_delete(struct ieee80211vap *);
 static void	ath_init(void *);
 static void	ath_stop_locked(struct ifnet *);
@@ -633,7 +634,8 @@
 }
 
 static struct ieee80211vap *
-ath_vap_create(struct ieee80211com *ic, int opmode)
+ath_vap_create(struct ieee80211com *ic,
+	const char name[IFNAMSIZ], int unit, int opmode)
 {
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ieee80211vap *vap;
@@ -683,7 +685,7 @@
 		/* XXX msg */
 		return NULL;
 	}
-	ieee80211_vap_setup(ic, vap, opmode);
+	ieee80211_vap_setup(ic, vap, name, unit, opmode);
 	/* override with driver methods */
 	sc->sc_newstate = vap->iv_newstate;	/* XXX per-vap */
 	vap->iv_newstate = ath_newstate;
@@ -4817,18 +4819,6 @@
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
 		break;
-	case SIOC80211IFCREATE:
-		error = suser(curthread);
-		if (error == 0) {
-			struct ieee80211vap *vap =
-				ic->ic_vap_create(ic, ifr->ifr_flags);
-			if (vap != NULL)
-				strlcpy(ifr->ifr_name,
-					vap->iv_if.if_xname, IFNAMSIZ);
-			else
-				error = EOPNOTSUPP;	/* XXX */
-		}
-		break;
 	default:
 		error = EINVAL;
 		break;

==== //depot/projects/vap/sys/dev/iwi/if_iwi.c#3 (text+ko) ====

@@ -111,7 +111,8 @@
 static const struct ieee80211_rateset iwi_rateset_11g =
 	{ 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } };
 
-static struct ieee80211vap *iwi_vap_create(struct ieee80211com *, int opmode);
+static struct ieee80211vap *iwi_vap_create(struct ieee80211com *, 
+			    const char name[IFNAMSIZ], int unit, int opmode);
 static void		iwi_vap_delete(struct ieee80211vap *);
 static int		iwi_dma_alloc(struct iwi_softc *);
 static void		iwi_release(struct iwi_softc *);
@@ -363,9 +364,6 @@
 	if (bootverbose)
 		ieee80211_announce(ic);
 
-	/* create an initial station mode instance */
-	(void) ic->ic_vap_create(ic, IEEE80211_M_STA);
-
 	return 0;
 
 fail:	iwi_detach(dev);
@@ -408,7 +406,8 @@
 }
 
 static struct ieee80211vap *
-iwi_vap_create(struct ieee80211com *ic, int opmode)
+iwi_vap_create(struct ieee80211com *ic,
+	const char name[IFNAMSIZ], int unit, int opmode)
 {
 	struct ieee80211vap *vap;
 
@@ -434,7 +433,7 @@
 		/* XXX msg */
 		return NULL;
 	}
-	ieee80211_vap_setup(ic, vap, opmode);
+	ieee80211_vap_setup(ic, vap, name, unit, opmode);
 	/* override with driver methods */
 	vap->iv_newstate = iwi_newstate;
 

==== //depot/projects/vap/sys/dev/wi/if_wi.c#3 (text+ko) ====

@@ -114,7 +114,8 @@
 #include <dev/wi/if_wireg.h>
 #include <dev/wi/if_wivar.h>
 
-static struct ieee80211vap *wi_vap_create(struct ieee80211com *, int opmode);
+static struct ieee80211vap *wi_vap_create(struct ieee80211com *,
+		const char name[IFNAMSIZ], int unit, int opmode);
 static void wi_vap_delete(struct ieee80211vap *);
 
 static void wi_start(struct ifnet *);
@@ -502,9 +503,6 @@
 	if (bootverbose)
 		ieee80211_announce(ic);
 
-	/* create an initial station mode instance */
-	(void) ic->ic_vap_create(ic, IEEE80211_M_STA);
-
 	return (0);
 }
 
@@ -536,7 +534,8 @@
 }
 
 static struct ieee80211vap *
-wi_vap_create(struct ieee80211com *ic, int opmode)
+wi_vap_create(struct ieee80211com *ic,
+	const char name[IFNAMSIZ], int unit, int opmode)
 {
 	struct wi_softc *sc = ic->ic_ifp->if_softc;
 	struct ieee80211vap *vap;
@@ -563,7 +562,7 @@
 		/* XXX msg */
 		return NULL;
 	}
-	ieee80211_vap_setup(ic, vap, opmode);
+	ieee80211_vap_setup(ic, vap, name, unit, opmode);
 	vap->iv_max_aid = WI_MAX_AID;	/* XXX */
 	/* override with driver methods */
 	sc->sc_newstate = vap->iv_newstate;	/* XXX per-vap */

==== //depot/projects/vap/sys/net80211/ieee80211.c#4 (text+ko) ====

@@ -192,12 +192,13 @@
 }
 
 int
-ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap, int opmode)
+ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
+	const char name[IFNAMSIZ], int unit, int opmode)
 {
 	struct ifnet *ifp;
 
 	ifp = &vap->iv_if;
-	if_initname(ifp, "wlan", ieee80211_alloc_wlanunit());
+	if_initname(ifp, name, unit);
 	ifp->if_softc = vap;			/* back pointer */
 	ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
 	ifp->if_start = ieee80211_start;
@@ -292,8 +293,8 @@
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ifnet *ifp = &vap->iv_if;
 
+	bpfdetach(ifp);
 	ether_ifdetach(ifp);
-	bpfdetach(ifp);
 
 	IEEE80211_LOCK(ic);
 	TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
@@ -303,8 +304,6 @@
 
 	ifmedia_removeall(&vap->iv_media);
 
-	ieee80211_delete_wlanunit(ifp->if_dunit);
-
 	ieee80211_sysctl_vdetach(vap);
 	ieee80211_proto_vdetach(vap);
 	ieee80211_crypto_vdetach(vap);

==== //depot/projects/vap/sys/net80211/ieee80211_freebsd.c#3 (text+ko) ====

@@ -44,6 +44,7 @@
 
 #include <net/if.h>
 #include <net/if_arp.h>
+#include <net/if_clone.h>
 #include <net/if_media.h>
 #include <net/ethernet.h>
 #include <net/route.h>
@@ -323,42 +324,39 @@
 #endif
 }
 
-static struct mtx ieee80211_unit_mtx;
-static u_int8_t wlan_units[32];		/* enough for 256 */
+static void
+wlan_clone_destroy(struct ifnet *ifp)
+{
+	struct ieee80211vap *vap = ifp->if_softc;
+	struct ieee80211com *ic = vap->iv_ic;
+	
+	ic->ic_vap_delete(vap);
+}
 
-u_int
-ieee80211_alloc_wlanunit(void)
+static int
+wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
-	u_int unit;
-	u_int8_t b;
-	int i;
+	struct ieee80211_clone_params cp;
+	struct ieee80211vap *vap;
+	struct ieee80211com *ic;
+	struct ifnet *ifp;
+	int error;
 
-	mtx_lock(&ieee80211_unit_mtx);
-	unit = 0;
-	for (i = 0; i < N(wlan_units) && wlan_units[i] == 0xff; i++)
-		unit += NBBY;
-	if (i == N(wlan_units))
-		panic("vap table full");
-	for (b = wlan_units[i]; b & 1; b >>= 1)
-		unit++;
-	setbit(wlan_units, unit);
-	mtx_unlock(&ieee80211_unit_mtx);
+	error = copyin(params, &cp, sizeof(cp));
+	if (error)
+		return error;
+	ifp = ifunit(cp.icp_name);
+	if (ifp == NULL)
+		return ENXIO;
+	ic = ifp->if_softc;		/* XXX */
+	vap = ic->ic_vap_create(ic, ifc->ifc_name, unit, cp.icp_opmode);
+	if (vap == NULL)
+		return EIO;
 
-	return unit;
-#undef N
+	return 0;
 }
+IFC_SIMPLE_DECLARE(wlan, 0);
 
-void
-ieee80211_delete_wlanunit(u_int unit)
-{
-	mtx_lock(&ieee80211_unit_mtx);
-	KASSERT(unit < sizeof(wlan_units)*NBBY, ("invalid wlan unit %u", unit));
-	KASSERT(isset(wlan_units, unit), ("wlan unit %u not allocated", unit));
-	clrbit(wlan_units, unit);
-	mtx_unlock(&ieee80211_unit_mtx);
-}
-
 /*
  * Module glue.
  *
@@ -371,11 +369,10 @@
 	case MOD_LOAD:
 		if (bootverbose)
 			printf("wlan: <802.11 Link Layer>\n");
-		mtx_init(&ieee80211_unit_mtx, "wlan_unit",
-			"wlan unit numbers", MTX_DEF);
+		if_clone_attach(&wlan_cloner);
 		return 0;
 	case MOD_UNLOAD:
-		mtx_destroy(&ieee80211_unit_mtx);
+		if_clone_detach(&wlan_cloner);
 		return 0;
 	}
 	return EINVAL;

==== //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#4 (text+ko) ====

@@ -2401,11 +2401,6 @@
 					(struct ieee80211req *) data);
 		}
 		break;
-	case SIOC80211IFDESTROY:
-		error = suser(curthread);
-		if (error == 0)
-			ic->ic_vap_delete(vap);
-		break;
 	case SIOCGIFGENERIC:
 		error = ieee80211_cfgget(ifp, cmd, data);
 		break;

==== //depot/projects/vap/sys/net80211/ieee80211_ioctl.h#3 (text+ko) ====

@@ -361,8 +361,6 @@
 #define	SIOCS80211		 _IOW('i', 234, struct ieee80211req)
 #define	SIOCG80211		_IOWR('i', 235, struct ieee80211req)
 #define	SIOCG80211STATS		_IOWR('i', 236, struct ifreq)
-#define	SIOC80211IFCREATE	_IOWR('i', 237, struct ifreq)
-#define	SIOC80211IFDESTROY	 _IOW('i', 238, struct ifreq)
 
 #define IEEE80211_IOC_SSID		1
 #define IEEE80211_IOC_NUMSSIDS		2
@@ -456,6 +454,10 @@
 	/* variable length SSID followed by IE data */
 };
 
+struct ieee80211_clone_params {
+	char	icp_parent[IFNAMSIZ];		/* parent device */
+	int	icp_opmode;			/* operating mode */
+};
 #endif /* __FreeBSD__ */
 
 #endif /* _NET80211_IEEE80211_IOCTL_H_ */

==== //depot/projects/vap/sys/net80211/ieee80211_var.h#6 (text+ko) ====

@@ -139,6 +139,7 @@
 
 	/* virtual ap create/delete */
 	struct ieee80211vap 	*(*ic_vap_create)(struct ieee80211com *,
+				    const char name[IFNAMSIZ], int unit,
 				    int opmode);
 	void			(*ic_vap_delete)(struct ieee80211vap *);
 	/* send/recv 802.11 management frame */
@@ -297,7 +298,7 @@
 void	ieee80211_ifattach(struct ieee80211com *);
 void	ieee80211_ifdetach(struct ieee80211com *);
 int	ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *,
-		int opmode);
+		const char name[IFNAMSIZ], int unit, int opmode);
 int	ieee80211_vap_attach(struct ieee80211vap *,
 		ifm_change_cb_t, ifm_stat_cb_t);
 void	ieee80211_vap_detach(struct ieee80211vap *);



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