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 Function paramaters re written to use vap.



details:   https://anonhg.NetBSD.org/src-all/rev/f93053672894
branches:  trunk
changeset: 948924:f93053672894
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sat May 16 10:54:05 2020 +1000

description:
Function paramaters re written to use vap.
Improved rx_done handling from urtwn.
Let state machine control scanning.
No functions except for newstate_cb override newstate callback.

iwn can now scan!

diffstat:

 sys/dev/pci/if_iwn.c |  132 ++++++++++++++++++++++++++++----------------------
 1 files changed, 75 insertions(+), 57 deletions(-)

diffs (truncated from 395 to 300 lines):

diff -r 7802a2f9d338 -r f93053672894 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c      Thu May 14 20:42:54 2020 +1000
+++ b/sys/dev/pci/if_iwn.c      Sat May 16 10:54:05 2020 +1000
@@ -182,7 +182,7 @@
 static void    iwn_calib_timeout(void *);
 static void    iwn_rx_phy(struct iwn_softc *, struct iwn_rx_desc *,
                    struct iwn_rx_data *);
-static void    iwn_rx_done(struct iwn_softc *, struct iwn_rx_desc *,
+static void    iwn_rx_done(struct ieee80211vap *, struct iwn_rx_desc *,
                    struct iwn_rx_data *);
 #ifndef IEEE80211_NO_HT
 static void    iwn_rx_compressed_ba(struct iwn_softc *, struct iwn_rx_desc *,
@@ -190,7 +190,7 @@
 #endif
 static void    iwn5000_rx_calib_results(struct iwn_softc *,
                    struct iwn_rx_desc *, struct iwn_rx_data *);
-static void    iwn_rx_statistics(struct iwn_softc *, struct iwn_rx_desc *,
+static void    iwn_rx_statistics(struct ieee80211vap *, struct iwn_rx_desc *,
                    struct iwn_rx_data *);
 static void    iwn4965_tx_done(struct iwn_softc *, struct iwn_rx_desc *,
                    struct iwn_rx_data *);
@@ -199,7 +199,7 @@
 static void    iwn_tx_done(struct iwn_softc *, struct iwn_rx_desc *, int,
                    uint8_t);
 static void    iwn_cmd_done(struct iwn_softc *, struct iwn_rx_desc *);
-static void    iwn_notif_intr(struct iwn_softc *);
+static void    iwn_notif_intr(struct ieee80211vap *);
 static void    iwn_wakeup_intr(struct iwn_softc *);
 static void    iwn_fatal_intr(struct iwn_softc *);
 static int     iwn_intr(void *);
@@ -254,13 +254,13 @@
 static int     iwn_config_bt_coex_adv2(struct iwn_softc *);
 
 static int     iwn_config(struct ieee80211vap *);
-static uint16_t        iwn_get_active_dwell_time(struct ieee80211vap *, uint16_t,
+static uint16_t        iwn_get_active_dwell_time(struct ieee80211_node *, uint16_t,
                    uint8_t);
-static uint16_t        iwn_limit_dwell(struct ieee80211vap *, uint16_t);
-static uint16_t        iwn_get_passive_dwell_time(struct ieee80211vap *, uint16_t);
+static uint16_t        iwn_limit_dwell(struct ieee80211_node *, uint16_t);
+static uint16_t        iwn_get_passive_dwell_time(struct ieee80211_node *, uint16_t);
 static void    iwn_scan(struct ieee80211com *);
-static int     iwn_auth(struct iwn_softc *);
-static int     iwn_run(struct iwn_softc *);
+static int     iwn_auth(struct ieee80211vap *);
+static int     iwn_run(struct ieee80211vap *);
 #ifdef IWN_HWCRYPTO
 static int     iwn_set_key(struct ieee80211com *, struct ieee80211_node *,
                    struct ieee80211_key *);
@@ -708,7 +708,6 @@
                return 0;
        }
 
-
        ieee80211_announce(ic);
 
        return 0;
@@ -788,6 +787,7 @@
 
        /* Local setup */
        vap->iv_reset = iwn_reset;
+       vap->iv_ic = ic;
 
        ifp = vap->iv_ifp;// = &sc->sc_ec.ec_if;
         if_initialize(ifp);
@@ -1006,8 +1006,6 @@
 {
        struct iwn_softc *sc = device_private(self);
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-       struct ifnet *ifp = vap->iv_ifp;
        int qid;
 
        if (!(sc->sc_flags & IWN_FLAG_ATTACHED))
@@ -1038,8 +1036,7 @@
 
        bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_sz);
 
-       ieee80211_ifdetach(&sc->sc_ic);
-       if_detach(ifp);
+       ieee80211_ifdetach(ic);
 
        return 0;
 }
@@ -2048,11 +2045,12 @@
 
        enum ieee80211_state ostate = vap->iv_state;
 
+       vap->iv_debug = ieee80211_debug;
        switch (nstate) {
        case IEEE80211_S_SCAN:
                /* XXX Do not abort a running scan. */
                if (sc->sc_flags & IWN_FLAG_SCANNING) {
-                       if (ostate != nstate)
+                       if (ostate == nstate)
                                aprint_debug_dev(sc->sc_dev, "scan request(%d) "
                                    "while scanning(%d) ignored\n", nstate,
                                    ostate);
@@ -2067,7 +2065,7 @@
                /* Make the link LED blink while we're scanning. */
                iwn_set_led(sc, IWN_LED_LINK, 10, 10);
 
-               iwn_scan(ic);
+               //iwn_scan(ic);
                //ic->ic_state = nstate;
                break;
 
@@ -2089,7 +2087,7 @@
                if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan))
                        sc->sc_beacon_wait = 1;
 
-               if ((error = iwn_auth(sc)) != 0) {
+               if ((error = iwn_auth(vap)) != 0) {
                        aprint_error_dev(sc->sc_dev,
                            "could not move to auth state\n");
                        return error;
@@ -2109,7 +2107,7 @@
                if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan))
                        sc->sc_beacon_wait = 1;
 
-               if ((error = iwn_run(sc)) != 0) {
+               if ((error = iwn_run(vap)) != 0) {
                        aprint_error_dev(sc->sc_dev,
                            "could not move to run state\n");
                        return error;
@@ -2123,13 +2121,15 @@
                 * Purge the xmit queue so we don't have old frames
                 * during a new association attempt.
                 */
+               error = iwn_init(ifp);
+               if (error)
+                       return error;
                sc->sc_beacon_wait = 0;
                ifp->if_flags &= ~IFF_OACTIVE;
                iwn_start(ifp);
                break;
        }
 
-       vap->iv_debug = ieee80211_debug;
        error = (*sc->sc_newstate)(vap, nstate, arg);
        return error;
 }
@@ -2200,12 +2200,12 @@
  * Each MPDU_RX_DONE notification must be preceded by an RX_PHY one.
  */
 static void
-iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
+iwn_rx_done(struct ieee80211vap *vap, struct iwn_rx_desc *desc,
     struct iwn_rx_data *data)
 {
+       struct ieee80211com *ic = vap->iv_ic;
+       struct iwn_softc *sc = ic->ic_softc;
        struct iwn_ops *ops = &sc->ops;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
        struct ifnet *ifp = vap->iv_ifp;
        struct iwn_rx_ring *ring = &sc->rxq;
        struct ieee80211_frame *wh;
@@ -2371,11 +2371,24 @@
                }
        }
 
-       /* Send the frame to the 802.11 layer. */
-       ieee80211_input(ni, m, rssi, 0);
-
-       /* Node is no longer needed. */
-       ieee80211_free_node(ni);
+       if (ni != NULL) {
+               if (ni->ni_vap == NULL) {
+                       ieee80211_free_node(ni);
+                       splx(s);
+                       return;
+               }
+               /* push the frame up to the 802.11 stack */
+               /* NNN Convert rssi to -10 to 110 ? for 802.11 layer */
+               ieee80211_input(ni, m, rssi, 0);
+
+               /* Node is no longer needed. */
+               ieee80211_free_node(ni);
+
+       } else {
+
+               /* No node found ... process differently. */
+               (void) ieee80211_input_all(ic, m, rssi, 0);
+       }
 
        splx(s);
 }
@@ -2463,11 +2476,11 @@
  * The latter is sent by the firmware after each received beacon.
  */
 static void
-iwn_rx_statistics(struct iwn_softc *sc, struct iwn_rx_desc *desc,
+iwn_rx_statistics(struct ieee80211vap *vap, struct iwn_rx_desc *desc,
     struct iwn_rx_data *data)
 {
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+       struct ieee80211com *ic = vap->iv_ic;
+       struct iwn_softc *sc = ic->ic_softc;
        struct iwn_ops *ops = &sc->ops;
        struct iwn_calib_state *calib = &sc->calib;
        struct iwn_stats *stats = (struct iwn_stats *)(desc + 1);
@@ -2629,11 +2642,11 @@
  * Process an INT_FH_RX or INT_SW_RX interrupt.
  */
 static void
-iwn_notif_intr(struct iwn_softc *sc)
-{
+iwn_notif_intr(struct ieee80211vap *vap)
+{
+       struct ieee80211com *ic = vap->iv_ic;
+       struct iwn_softc *sc = ic->ic_softc;
        struct iwn_ops *ops = &sc->ops;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
        struct ifnet *ifp = vap->iv_ifp;
        uint16_t hw;
        int s;
@@ -2664,7 +2677,7 @@
                case IWN_RX_DONE:               /* 4965AGN only. */
                case IWN_MPDU_RX_DONE:
                        /* An 802.11 frame has been received. */
-                       iwn_rx_done(sc, desc, data);
+                       iwn_rx_done(vap, desc, data);
                        break;
 #ifndef IEEE80211_NO_HT
                case IWN_RX_COMPRESSED_BA:
@@ -2679,7 +2692,7 @@
 
                case IWN_RX_STATISTICS:
                case IWN_BEACON_STATISTICS:
-                       iwn_rx_statistics(sc, desc, data);
+                       iwn_rx_statistics(vap, desc, data);
                        break;
 
                case IWN_BEACON_MISSED:
@@ -2780,10 +2793,10 @@
                                 */
                                sc->sc_flags &= ~IWN_FLAG_SCANNING_2GHZ;
                                sc->sc_flags |= IWN_FLAG_SCANNING_5GHZ;
-                               iwn_scan(ic);
+                               //iwn_scan(ic);
                        }
                        sc->sc_flags &= ~IWN_FLAG_SCANNING;
-               //      ieee80211_end_scan(ic);
+                       //ieee80211_end_scan(ic);
                        break;
                }
                case IWN5000_CALIBRATION_RESULT:
@@ -2971,13 +2984,13 @@
                        if (r1 & (IWN_INT_FH_RX | IWN_INT_SW_RX))
                                IWN_WRITE(sc, IWN_FH_INT, IWN_FH_INT_RX);
                        IWN_WRITE_1(sc, IWN_INT_PERIODIC, IWN_INT_PERIODIC_DIS);
-                       iwn_notif_intr(sc);
+                       iwn_notif_intr(vap);
                        if (r1 & (IWN_INT_FH_RX | IWN_INT_SW_RX)) {
                                IWN_WRITE_1(sc, IWN_INT_PERIODIC,
                                    IWN_INT_PERIODIC_ENA);
                        }
                } else
-                       iwn_notif_intr(sc);
+                       iwn_notif_intr(vap);
        }
 
        if ((r1 & IWN_INT_FH_TX) || (r2 & IWN_FH_INT_TX)) {
@@ -4768,7 +4781,7 @@
 }
 
 static uint16_t
-iwn_get_active_dwell_time(struct ieee80211vap *vap, uint16_t flags,
+iwn_get_active_dwell_time(struct ieee80211_node *ni, uint16_t flags,
     uint8_t n_probes)
 {
        /* No channel? Default to 2GHz settings */
@@ -4787,9 +4800,9 @@
  * Returns the dwell time in milliseconds.
  */
 static uint16_t
-iwn_limit_dwell(struct ieee80211vap *vap, uint16_t dwell_time)
-{
-       struct ieee80211_node *ni = vap->iv_bss;
+iwn_limit_dwell(struct ieee80211_node *ni, uint16_t dwell_time)
+{
+       
        int bintval = 0;
 
        /* bintval is in TU (1.024mS) */
@@ -4811,7 +4824,7 @@
 }
 
 static uint16_t
-iwn_get_passive_dwell_time(struct ieee80211vap *vap, uint16_t flags)
+iwn_get_passive_dwell_time(struct ieee80211_node *ni, uint16_t flags)
 {
        uint16_t passive;
        if (flags & IEEE80211_CHAN_2GHZ)
@@ -4820,13 +4833,13 @@
                passive = IWN_PASSIVE_DWELL_BASE + IWN_PASSIVE_DWELL_TIME_5GHZ;
 



Home | Main Index | Thread Index | Old Index