Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/dev/pcmcia Pullup rev. 1.29 (approved by jhawk):



details:   https://anonhg.NetBSD.org/src/rev/fe7234105aa3
branches:  netbsd-1-5
changeset: 489165:fe7234105aa3
user:      enami <enami%NetBSD.org@localhost>
date:      Tue Aug 22 02:32:45 2000 +0000

description:
Pullup rev. 1.29 (approved by jhawk):
Sync internal state and ifmedia state.  Addresses PR#10424.

diffstat:

 sys/dev/pcmcia/if_wi.c |  56 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 53 insertions(+), 3 deletions(-)

diffs (93 lines):

diff -r 0c0ad0cb57ab -r fe7234105aa3 sys/dev/pcmcia/if_wi.c
--- a/sys/dev/pcmcia/if_wi.c    Tue Aug 22 02:19:32 2000 +0000
+++ b/sys/dev/pcmcia/if_wi.c    Tue Aug 22 02:32:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wi.c,v 1.21.2.5 2000/07/21 18:56:01 onoe Exp $      */
+/*     $NetBSD: if_wi.c,v 1.21.2.6 2000/08/22 02:32:45 enami Exp $     */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -171,6 +171,7 @@
     struct ieee80211_nwid *));
 static int wi_set_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
 static int wi_get_nwkey __P((struct wi_softc *, struct ieee80211_nwkey *));
+static int wi_sync_media __P((struct wi_softc *, int, int));
 
 struct cfattach wi_ca = {
        sizeof(struct wi_softc), wi_match, wi_attach, wi_detach, wi_activate
@@ -428,6 +429,7 @@
        ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
        ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
            IFM_IEEE80211_ADHOC, 0), 0);
+       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_MANUAL, 0, 0), 0);
 #undef ADD
        ifmedia_set(&sc->sc_media, IFM_AUTOADHOC);
 
@@ -1136,10 +1138,10 @@
                bcopy((char *)&wreq->wi_val, LLADDR(sdl), ETHER_ADDR_LEN);
                break;
        case WI_RID_PORTTYPE:
-               sc->wi_ptype = wreq->wi_val[0];
+               error = wi_sync_media(sc, wreq->wi_val[0], sc->wi_tx_rate);
                break;
        case WI_RID_TX_RATE:
-               sc->wi_tx_rate = wreq->wi_val[0];
+               error = wi_sync_media(sc, sc->wi_ptype, wreq->wi_val[0]);
                break;
        case WI_RID_MAX_DATALEN:
                sc->wi_max_data_len = wreq->wi_val[0];
@@ -1837,6 +1839,54 @@
 }
 
 static int
+wi_sync_media(sc, ptype, txrate)
+       struct wi_softc *sc;
+       int ptype;
+       int txrate;
+{
+       int media = sc->sc_media.ifm_cur->ifm_media;
+       int options = IFM_OPTIONS(media);
+       int subtype;
+
+       switch (txrate) {
+       case 1:
+               subtype = IFM_IEEE80211_DS1;
+               break;
+       case 2:
+               subtype = IFM_IEEE80211_DS2;
+               break;
+       case 3:
+               subtype = IFM_AUTO;
+               break;
+       case 11:
+               subtype = IFM_IEEE80211_DS11;
+               break;
+       default:
+               subtype = IFM_MANUAL;           /* Unable to represent */
+               break;
+       }
+       switch (ptype) {
+       case WI_PORTTYPE_ADHOC:
+               options |= IFM_IEEE80211_ADHOC;
+               break;
+       case WI_PORTTYPE_BSS:
+               options &= ~IFM_IEEE80211_ADHOC;
+               break;
+       default:
+               subtype = IFM_MANUAL;           /* Unable to represent */
+               break;
+       }
+       media = IFM_MAKEWORD(IFM_TYPE(media), subtype, options,
+           IFM_INST(media));
+       if (ifmedia_match(&sc->sc_media, media, sc->sc_media.ifm_mask) == NULL)
+               return (EINVAL);
+       ifmedia_set(&sc->sc_media, media);
+       sc->wi_ptype = ptype;
+       sc->wi_tx_rate = txrate;
+       return (0);
+}
+
+static int
 wi_media_change(ifp)
        struct ifnet *ifp;
 {



Home | Main Index | Thread Index | Old Index