PERFORCE change 137846 for review

Sam Leffler sam at FreeBSD.org
Sun Mar 16 17:39:45 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137846

Change 137846 by sam at sam_ebb on 2008/03/16 17:39:21

	switch to public phy routines

Affected files ...

.. //depot/projects/vap/sys/dev/usb/if_zyd.c#13 edit

Differences ...

==== //depot/projects/vap/sys/dev/usb/if_zyd.c#13 (text+ko) ====

@@ -47,6 +47,7 @@
 
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_amrr.h>
+#include <net80211/ieee80211_phy.h>
 #include <net80211/ieee80211_radiotap.h>
 #include <net80211/ieee80211_regdomain.h>
 
@@ -209,7 +210,6 @@
 static int	zyd_set_rxfilter(struct zyd_softc *);
 static void	zyd_set_chan(struct zyd_softc *, struct ieee80211_channel *);
 static int	zyd_set_beacon_interval(struct zyd_softc *, int);
-static uint8_t	zyd_plcp_signal(int);
 static void	zyd_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
 static void	zyd_rx_data(struct zyd_softc *, const uint8_t *, uint16_t);
 static void	zyd_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
@@ -1840,31 +1840,6 @@
 	return 0;
 }
 
-static uint8_t
-zyd_plcp_signal(int rate)
-{
-	switch (rate) {
-	/* CCK rates (returned values are device-dependent) */
-	case 2:		return 0x0;
-	case 4:		return 0x1;
-	case 11:	return 0x2;
-	case 22:	return 0x3;
-
-	/* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */
-	case 12:	return 0xb;
-	case 18:	return 0xf;
-	case 24:	return 0xa;
-	case 36:	return 0xe;
-	case 48:	return 0x9;
-	case 72:	return 0xd;
-	case 96:	return 0x8;
-	case 108:	return 0xc;
-
-	/* unsupported rates (should not get there) */
-	default:	return 0xff;
-	}
-}
-
 static void
 zyd_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
 {
@@ -1947,20 +1922,6 @@
 	}
 }
 
-static __inline uint8_t
-zyd_plcp2ieee(int signal, int isofdm)
-{
-       if (isofdm) {
-               static const uint8_t ofdmrates[16] =
-                   { 0, 0, 0, 0, 0, 0, 0, 96, 48, 24, 12, 108, 72, 36, 18 };
-               return ofdmrates[signal & 0xf];
-       } else {
-               static const uint8_t cckrates[16] =
-                   { 0, 0, 0, 0, 4, 0, 0, 11, 0, 0, 2, 0, 0, 0, 22, 0 };
-               return cckrates[signal & 0xf];
-       }
-}
-
 static void
 zyd_rx_data(struct zyd_softc *sc, const uint8_t *buf, uint16_t len)
 {
@@ -2018,8 +1979,8 @@
 		/* XXX toss, no way to express errors */
 		if (stat->flags & ZYD_RX_DECRYPTERR)
 			tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS;
-		tap->wr_rate =
-		    zyd_plcp2ieee(plcp->signal, stat->flags & ZYD_RX_OFDM);
+		tap->wr_rate = ieee80211_plcp2rate(plcp->signal,
+		    stat->flags & ZYD_RX_OFDM);
 		tap->wr_antsignal = stat->rssi + -95;
 		tap->wr_antnoise = -95;		/* XXX */
 		
@@ -2156,7 +2117,7 @@
 	    (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_PS_POLL))
 		desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL);
 
-	desc->phy = zyd_plcp_signal(rate);
+	desc->phy = ieee80211_rate2plcp(rate);
 	if (ZYD_RATE_IS_OFDM(rate)) {
 		desc->phy |= ZYD_TX_PHY_OFDM;
 		if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan))
@@ -2327,7 +2288,7 @@
 	    (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_PS_POLL))
 		desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL);
 
-	desc->phy = zyd_plcp_signal(rate);
+	desc->phy = ieee80211_rate2plcp(rate);
 	if (ZYD_RATE_IS_OFDM(rate)) {
 		desc->phy |= ZYD_TX_PHY_OFDM;
 		if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan))


More information about the p4-projects mailing list