Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/dev/pci ipw(4) fucnctions for vap creation/deletio...



details:   https://anonhg.NetBSD.org/src-all/rev/8983e5eb4c2e
branches:  trunk
changeset: 371643:8983e5eb4c2e
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sun Mar 06 03:14:09 2022 +1100

description:
ipw(4) fucnctions for vap creation/deletion and ipw_parent added.

diffstat:

 sys/dev/pci/if_ipw.c |  89 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 83 insertions(+), 6 deletions(-)

diffs (136 lines):

diff -r 19a2fa631d0b -r 8983e5eb4c2e sys/dev/pci/if_ipw.c
--- a/sys/dev/pci/if_ipw.c      Tue Mar 01 23:07:22 2022 +1100
+++ b/sys/dev/pci/if_ipw.c      Sun Mar 06 03:14:09 2022 +1100
@@ -100,7 +100,7 @@
 static void    ipw_parent(struct ieee80211com *);
 static int     ipw_media_change(struct ifnet *);
 static void    ipw_media_status(struct ifnet *, struct ifmediareq *);
-static int     ipw_newstate(struct ieee80211com *, enum ieee80211_state, int);
+static int     ipw_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static uint16_t        ipw_read_prom_word(struct ipw_softc *, uint8_t);
 static void    ipw_command_intr(struct ipw_softc *, struct ipw_soft_buf *);
 static void    ipw_newstate_intr(struct ipw_softc *, struct ipw_soft_buf *);
@@ -135,6 +135,17 @@
 static void    ipw_write_mem_1(struct ipw_softc *, bus_size_t, uint8_t *,
     bus_size_t);
 
+static struct ieee80211vap *
+ipw_vap_create(struct ieee80211com *ic,  const char name[IFNAMSIZ],
+    int unit, enum ieee80211_opmode opmode, int flags,
+    const uint8_t bssid[IEEE80211_ADDR_LEN],
+    const uint8_t macaddr[IEEE80211_ADDR_LEN]);
+static void
+ipw_vap_delete(struct ieee80211vap *vap);
+static void
+ipw_get_radiocaps(struct ieee80211com *ic,
+    int maxchans, int *nchans, struct ieee80211_channel chans[]);
+
 static inline uint8_t
 MEM_READ_1(struct ipw_softc *sc, uint32_t addr)
 {
@@ -152,6 +163,15 @@
 CFATTACH_DECL_NEW(ipw, sizeof (struct ipw_softc), ipw_match, ipw_attach,
     ipw_detach, NULL);
 
+/*
+ * We ovveride the VAP's newstate method, so need to save the old
+ * function pointer for each VAP.
+ */
+struct ipw_vap {
+       struct ieee80211vap vap;
+       int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+};
+
 static int
 ipw_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -370,6 +390,62 @@
        return 0;
 }
 
+static struct ieee80211vap *
+ipw_vap_create(struct ieee80211com *ic,  const char name[IFNAMSIZ],
+    int unit, enum ieee80211_opmode opmode, int flags,
+    const uint8_t bssid[IEEE80211_ADDR_LEN],
+    const uint8_t macaddr[IEEE80211_ADDR_LEN])
+{
+       struct ipw_vap *vap;
+
+       /* Allocate the vap and setup. */
+       vap = kmem_zalloc(sizeof(*vap), KM_SLEEP);
+       if (ieee80211_vap_setup(ic, &vap->vap, name, unit, opmode,
+           flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
+               kmem_free(vap, sizeof(*vap));
+               return NULL;
+       }
+
+       /* Local overrides... */
+       vap->newstate = vap->vap.iv_newstate;
+       vap->vap.iv_newstate = ipw_newstate;
+
+       /* Use common softint-based if_input */
+       vap->vap.iv_ifp->if_percpuq = if_percpuq_create(vap->vap.iv_ifp);
+
+       /* Finish setup */
+       ieee80211_vap_attach(&vap->vap, ieee80211_media_change,
+           ieee80211_media_status, macaddr);
+
+       ic->ic_opmode = opmode;
+
+       return &vap->vap;
+}
+
+static void
+rtwn_vap_delete(struct ieee80211vap *arg)
+{       
+       struct ifnet *ifp = arg->iv_ifp;
+       struct ipw_vap *vap = (struct ipw_vap *)arg;
+
+       bpf_detach(ifp);
+       ieee80211_vap_detach(arg);
+       kmem_free(vap, sizeof(*vap));
+}
+
+static void
+rtwn_get_radiocaps(struct ieee80211com *ic,
+    int maxchans, int *nchans, struct ieee80211_channel chans[])
+{
+       uint8_t bands[IEEE80211_MODE_BYTES];
+        
+       memset(bands, 0, sizeof(bands));   
+       setbit(bands, IEEE80211_MODE_11B); 
+       setbit(bands, IEEE80211_MODE_11G); 
+//     setbit(bands, IEEE80211_MODE_11NG);
+       ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0);
+}
+
 static int
 ipw_dma_alloc(struct ipw_softc *sc)
 {
@@ -788,11 +864,13 @@
 }
 
 static int
-ipw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate,
+ipw_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate,
     int arg)
 {
-       struct ifnet *ifp = ic->ic_ifp;
-       struct ipw_softc *sc = ifp->if_softc;
+       struct ipw_vap *myvap = (struct ipw_vap *)vap;
+       struct ieee80211_com *ic = vap->iv_ic
+       struct ifnet *ifp = vap->iv_ifp;
+       struct ipw_softc *sc = ic->ic_softc;
        struct ieee80211_node *ni;
        uint8_t macaddr[IEEE80211_ADDR_LEN];
        uint32_t len;
@@ -838,8 +916,7 @@
                break;
        }
 
-       ic->ic_state = nstate;
-       return 0;
+       return (*my_vap->newstate)(vap, nstate, arg);
 }
 
 static void



Home | Main Index | Thread Index | Old Index