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 More converted for iwi(4).



details:   https://anonhg.NetBSD.org/src-all/rev/11058c30553e
branches:  trunk
changeset: 363319:11058c30553e
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Tue Dec 21 13:03:21 2021 +1100

description:
More converted for iwi(4).

It does not compile as yet.  A few errors are remaining.

diffstat:

 sys/dev/pci/if_iwi.c    |  109 +++++++++++++++++++++++++++++++----------------
 sys/dev/pci/if_iwivar.h |    2 +
 2 files changed, 74 insertions(+), 37 deletions(-)

diffs (truncated from 308 to 300 lines):

diff -r 2d9b5532cfc5 -r 11058c30553e sys/dev/pci/if_iwi.c
--- a/sys/dev/pci/if_iwi.c      Sun Dec 19 08:23:10 2021 +1100
+++ b/sys/dev/pci/if_iwi.c      Tue Dec 21 13:03:21 2021 +1100
@@ -106,8 +106,8 @@
 static void    iwi_node_free(struct ieee80211_node *);
 
 static int     iwi_cvtrate(int);
-static int     iwi_media_change(struct ifnet *);
-static void    iwi_media_status(struct ifnet *, struct ifmediareq *);
+//static int   iwi_media_change(struct ifnet *);
+//static void  iwi_media_status(struct ifnet *, struct ifmediareq *);
 static int     iwi_wme_update(struct ieee80211com *);
 static void    iwi_scan_start(struct ieee80211com *);
 static void    iwi_set_chan(struct ieee80211com *);
@@ -129,8 +129,6 @@
 static void    iwi_softintr(void *);
 static int     iwi_cmd(struct iwi_softc *, uint8_t, void *, uint8_t, int);
 static void    iwi_write_ibssnode(struct iwi_softc *, const struct iwi_node *);
-static int     iwi_tx_start(struct ifnet *, struct mbuf *, struct ieee80211_node *,
-    int);
 static void    iwi_start(struct ifnet *);
 static void    iwi_watchdog(struct ifnet *);
 
@@ -386,8 +384,6 @@
 
        /* XXX media locking needs revisiting */
        mutex_init(&sc->sc_media_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
-       ieee80211_media_init_with_lock(ic,
-           iwi_media_change, iwi_media_status, &sc->sc_media_mtx);
 
        /*
         * Allocate rings.
@@ -906,6 +902,7 @@
        sc->sc_node_free(ni);
 }
 
+#if 0
 static int
 iwi_media_change(struct ifnet *ifp)
 {
@@ -917,6 +914,7 @@
 
        return 0;
 }
+#endif
 
 /*
  * Convert h/w rate code to IEEE rate code.
@@ -941,6 +939,7 @@
        return 0;
 }
 
+#if 0
 /*
  * The firmware automatically adapts the transmit speed.  We report its current
  * value here.
@@ -980,6 +979,7 @@
                break;
        }
 }
+#endif
 
 static void
 iwi_newassoc(struct ieee80211_node *ni, int isnew)
@@ -1253,7 +1253,7 @@
     struct iwi_frame *frame)
 {
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ifnet *ifp = ic->ic_ifp;
+       //struct ifnet *ifp = ic->ic_ifp;
        struct mbuf *m, *m_new;
        struct ieee80211_frame *wh;
        struct ieee80211_node *ni;
@@ -1608,7 +1608,7 @@
        if (r & IWI_INTR_FATAL_ERROR) {
                aprint_error_dev(sc->sc_dev, "fatal error\n");
                s = splnet();
-               sc->sc_ic.ic_ifp->if_flags &= ~IFF_UP;
+               //sc->sc_ic.ic_ifp->if_flags &= ~IFF_UP;
                iwi_stop(sc, 1);
                splx(s);
                return;
@@ -1622,7 +1622,7 @@
        if (r & IWI_INTR_RADIO_OFF) {
                DPRINTF(("radio transmitter off\n"));
                s = splnet();
-               sc->sc_ic.ic_ifp->if_flags &= ~IFF_UP;
+               //sc->sc_ic.ic_ifp->if_flags &= ~IFF_UP;
                iwi_stop(sc, 1);
                splx(s);
                return;
@@ -1698,20 +1698,22 @@
 }
 
 static int
-iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni,
-    int ac)
+iwi_raw_xmit(struct ieee80211_node *ni , struct mbuf *m0,
+    const struct ieee80211_bpf_params *bpfp)
 {
-       struct iwi_softc *sc = ifp->if_softc;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct iwi_node *in = (struct iwi_node *)ni;
+       struct ieee80211vap *vap = ni->ni_vap;
+       struct ieee80211com *ic = ni->ni_ic;
+       struct iwi_softc *sc = ic->ic_softc;
+       struct ifnet *ifp = vap->iv_ifp;
+       struct ether_header *eh;
        struct ieee80211_frame *wh;
        struct ieee80211_key *k;
        const struct chanAccParams *cap;
-       struct iwi_tx_ring *txq = &sc->txq[ac];
+       struct iwi_tx_ring *txq;
        struct iwi_tx_data *data;
        struct iwi_tx_desc *desc;
        struct mbuf *mnew;
-       int error, hdrlen, i, noack = 0;
+       int ac, error, hdrlen, i, noack = 0;
 
        wh = mtod(m0, struct ieee80211_frame *);
 
@@ -1759,6 +1761,11 @@
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0, BPF_D_OUT);
        }
 
+       /* No QoS encapsulation for EAPOL frames. */
+       ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ?
+           M_WME_GETAC(m0) : WME_AC_BE;
+       txq = &sc->txq[ac];
+
        data = &txq->data[txq->cur];
        desc = &txq->desc[txq->cur];
 
@@ -1865,6 +1872,34 @@
        return 0;
 }
 
+static int
+iwi_transmit(struct ieee80211com *ic, struct mbuf *m)
+{
+       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+       //struct iwi_softc *sc = vap->iv_ic->ic_softc;
+       int s;
+
+       size_t pktlen = m->m_pkthdr.len;
+        bool mcast = (m->m_flags & M_MCAST) != 0;
+
+       DPRINTFN(DBG_FN, ("%s: %s\n",vap->iv_ic->ic_name, __func__));
+
+       s = splnet();
+
+       IF_ENQUEUE(&vap->iv_ifp->if_snd, m);
+        if_statadd(vap->iv_ifp, if_obytes, pktlen);
+        if (mcast)
+                if_statinc(vap->iv_ifp, if_omcasts);
+
+        if ((vap->iv_ifp->if_flags & IFF_OACTIVE) == 0)
+                if_start_lock(vap->iv_ifp);
+        splx(s);
+
+       iwi_start(vap->iv_ifp);
+
+        return 0;
+}
+
 static void
 iwi_start(struct ifnet *ifp)
 {
@@ -1928,9 +1963,9 @@
                        continue;
                }
 
-               bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
-
-               if (iwi_tx_start(ifp, m0, ni, ac) != 0) {
+               bpf_mtap3(vap->iv_rawbpf, m0, BPF_D_OUT);
+
+               if (iwi_raw_xmit(ni, m0, NULL) != 0) {
                        ieee80211_free_node(ni);
                        if_statinc(ifp, if_oerrors);
                        break;
@@ -2434,6 +2469,7 @@
 iwi_config(struct iwi_softc *sc)
 {
        struct ieee80211com *ic = &sc->sc_ic;
+       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
        struct ifnet *ifp = &sc->sc_if;
        struct iwi_configuration config;
        struct iwi_rateset rs;
@@ -2470,7 +2506,7 @@
        if (error != 0)
                return error;
 
-       data = htole32(ic->ic_rtsthreshold);
+       data = htole32(vap->iv_rtsthreshold);
        DPRINTF(("Setting RTS threshold to %u\n", le32toh(data)));
        error = iwi_cmd(sc, IWI_CMD_SET_RTS_THRESHOLD, &data, sizeof data, 0);
        if (error != 0)
@@ -2540,23 +2576,21 @@
        if (error != 0)
                return error;
 
-#if 0  /* XXX: how to handle this */
        /* if we have a desired ESSID, set it now */
-       if (ic->ic_des_esslen != 0) {
+       if (sc->sc_des_esslen != 0) {
 #ifdef IWI_DEBUG
                if (iwi_debug > 0) {
                        printf("Setting desired ESSID to ");
-                       ieee80211_print_essid(ic->ic_des_essid,
-                           ic->ic_des_esslen);
+                       ieee80211_print_essid(sc->sc_des_essid,
+                           sc->sc_des_esslen);
                        printf("\n");
                }
 #endif
-               error = iwi_cmd(sc, IWI_CMD_SET_ESSID, ic->ic_des_essid,
-                   ic->ic_des_esslen, 0);
+               error = iwi_cmd(sc, IWI_CMD_SET_ESSID, sc->sc_des_essid,
+                   sc->sc_des_esslen, 0);
                if (error != 0)
                        return error;
        }
-#endif
 
        cprng_fast(&data, sizeof(data));
        data = htole32(data);
@@ -2626,25 +2660,22 @@
        scan.dwelltime[IWI_SCAN_TYPE_ACTIVE_BDIRECT] =
            htole16(sc->dwelltime);
 
-#if 0
-       /* XXX: how to handle this */
        /* tell the firmware about the desired essid */
-       if (ic->ic_des_esslen) {
+       if (sc->sc_des_esslen) {
                int error;
 
                DPRINTF(("%s: Setting adapter desired ESSID to %s\n",
-                   __func__, ic->ic_des_essid));
+                   __func__, sc->sc_des_essid));
 
                error = iwi_cmd(sc, IWI_CMD_SET_ESSID,
-                   ic->ic_des_essid, ic->ic_des_esslen, 1);
+                   sc->sc_des_essid, sc->sc_des_esslen, 1);
                if (error)
                        return;
 
                type = IWI_SCAN_TYPE_ACTIVE_BDIRECT;
        } else {
-#endif
                type = IWI_SCAN_TYPE_ACTIVE_BROADCAST;
-//     }
+       }
 
        p = &scan.channels[0];
        count = idx = 0;
@@ -2686,7 +2717,7 @@
        struct ieee80211com *ic = &sc->sc_ic;
        struct ieee80211_node *ni = ic->ic_bss;
        struct ifnet *ifp = &sc->sc_if;
-       struct ieee80211_wme_info wme;
+       //struct ieee80211_wme_info wme;
        struct iwi_configuration config;
        struct iwi_associate assoc;
        struct iwi_rateset rs;
@@ -2739,7 +2770,8 @@
        if (error != 0)
                return error;
 
-       if ((ic->ic_flags & IEEE80211_F_WME) && ni->ni_wme_ie != NULL) {
+#if 0
+       if ((ic->ic_flags & IEEE80211_F_WME) && ni->ni_wme != NULL) {
                wme.wme_id = IEEE80211_ELEMID_VENDOR;
                wme.wme_len = sizeof (struct ieee80211_wme_info) - 2;
                wme.wme_oui[0] = 0x00;
@@ -2763,6 +2795,7 @@
                if (error != 0)
                        return error;
        }
+#endif
        data = 0; //htole32(ni->ni_rssi);
        DPRINTF(("Setting sensitivity to %d\n", (int8_t)ni->ni_rssi));
        error = iwi_cmd(sc, IWI_CMD_SET_SENSITIVITY, &data, sizeof data, 1);
@@ -2785,8 +2818,10 @@
        if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
                assoc.plen = IWI_ASSOC_SHPREAMBLE;
 
-       if ((ic->ic_flags & IEEE80211_F_WME) && ni->ni_wme_ie != NULL)
+#if 0
+       if ((ic->ic_flags & IEEE80211_F_WME) && ni->ni_wme != NULL)
                assoc.policy |= htole16(IWI_POLICY_WME);
+#endif
        if (ic->ic_flags & IEEE80211_F_WPA)
                assoc.policy |= htole16(IWI_POLICY_WPA);
        if (ic->ic_opmode == IEEE80211_M_IBSS && ni->ni_tstamp.tsf == 0)
diff -r 2d9b5532cfc5 -r 11058c30553e sys/dev/pci/if_iwivar.h
--- a/sys/dev/pci/if_iwivar.h   Sun Dec 19 08:23:10 2021 +1100
+++ b/sys/dev/pci/if_iwivar.h   Tue Dec 21 13:03:21 2021 +1100
@@ -174,6 +174,8 @@



Home | Main Index | Thread Index | Old Index