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 Adapt to VAP/struct ifnet vs. radio IC split.



details:   https://anonhg.NetBSD.org/src-all/rev/dfd8b11ebc95
branches:  trunk
changeset: 988519:dfd8b11ebc95
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Sun Sep 27 16:26:02 2020 +0200

description:
Adapt to VAP/struct ifnet vs. radio IC split.
Work in progress, does not fully work yet.

diffstat:

 sys/dev/pci/if_iwm.c    |  595 ++++++++++++++++-------------------------------
 sys/dev/pci/if_iwmvar.h |    6 +-
 2 files changed, 207 insertions(+), 394 deletions(-)

diffs (truncated from 1072 to 300 lines):

diff -r e2953be9121d -r dfd8b11ebc95 sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Sun Sep 27 16:21:43 2020 +0200
+++ b/sys/dev/pci/if_iwm.c      Sun Sep 27 16:26:02 2020 +0200
@@ -377,13 +377,14 @@
 static int     iwm_calc_rssi(struct iwm_softc *, struct iwm_rx_phy_info *);
 static int     iwm_get_signal_strength(struct iwm_softc *,
                    struct iwm_rx_phy_info *);
-static void    iwm_rx_rx_phy_cmd(struct ieee80211vap *,
+static void    iwm_rx_rx_phy_cmd(struct iwm_softc *,
                    struct iwm_rx_packet *, struct iwm_rx_data *);
 static int     iwm_get_noise(const struct iwm_statistics_rx_non_phy *);
-static void    iwm_rx_rx_mpdu(struct ieee80211vap *, struct iwm_rx_packet *,
+static void    iwm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *,
                    struct iwm_rx_data *);
-static void    iwm_rx_tx_cmd_single(struct ieee80211vap *, struct iwm_rx_packet *,                 struct iwm_node *);
-static void    iwm_rx_tx_cmd(struct ieee80211vap *, struct iwm_rx_packet *,
+static void    iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *,
+                   struct iwm_node *);
+static void    iwm_rx_tx_cmd(struct iwm_softc *, struct iwm_rx_packet *,
                    struct iwm_rx_data *);
 static int     iwm_binding_cmd(struct iwm_softc *, struct iwm_node *,
                    uint32_t);
@@ -414,8 +415,6 @@
 static const struct iwm_rate *
                iwm_tx_fill_cmd(struct iwm_softc *, struct iwm_node *,
                    struct ieee80211_frame *, struct iwm_tx_cmd *);
-static int     iwm_tx(struct ieee80211vap *, struct mbuf *,
-                   struct ieee80211_node *, int);
 static void    iwm_led_enable(struct iwm_softc *);
 static void    iwm_led_disable(struct iwm_softc *);
 static int     iwm_led_is_enabled(struct iwm_softc *);
@@ -469,7 +468,6 @@
 static void    iwm_setrates_task(void *);
 static int     iwm_setrates(struct iwm_node *);
 #endif
-static int     iwm_media_change(struct ifnet *);
 #if 0
 static int     iwm_do_newstate(struct ieee80211vap *, enum ieee80211_state,
                    int);
@@ -483,23 +481,22 @@
 static int     iwm_send_bt_init_conf(struct iwm_softc *);
 static int     iwm_send_update_mcc_cmd(struct iwm_softc *, const char *);
 static void    iwm_tt_tx_backoff(struct iwm_softc *, uint32_t);
-static int     iwm_init_hw(struct ieee80211vap *);
-static int     iwm_init(struct ifnet *);
-static void    iwm_start(struct ifnet *);
-static void    iwm_stop(struct ifnet *, int);
+static int     iwm_init_hw(struct iwm_softc *);
+static int     iwm_init(struct iwm_softc *);
+static void    iwm_start(struct iwm_softc *);
+static void    iwm_stop(struct iwm_softc *);
 #ifdef notyet
 static void    iwm_watchdog(struct ifnet *);
 #endif
-static int     iwm_ioctl(struct ifnet *, u_long, void *);
 #ifdef IWM_DEBUG
 static const char *iwm_desc_lookup(uint32_t);
 static void    iwm_nic_error(struct iwm_softc *);
 static void    iwm_nic_umac_error(struct iwm_softc *);
 #endif
-static void    iwm_notif_intr(struct ieee80211vap *);
+static void    iwm_notif_intr(struct iwm_softc *);
 static int     iwm_intr(void *);
 static void    iwm_softintr(void *);
-//static int   iwm_preinit(struct iwm_softc *);
+static int     iwm_preinit(struct iwm_softc *);
 static void    iwm_attach_hook(device_t);
 static void    iwm_attach(device_t, device_t, void *);
 static int     iwm_config_complete(struct iwm_softc *);
@@ -519,6 +516,15 @@
 #endif
 static char iwm_default_mcc[3] = IWM_DEFAULT_MCC;
 
+/*
+ * We ovveride the VAP's newstate method, so need to save the old
+ * function pointer for each VAP.
+ */
+struct iwm_vap {
+       struct ieee80211vap vap;
+       int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+};
+
 static int
 iwm_firmload(struct iwm_softc *sc)
 {
@@ -1924,79 +1930,24 @@
 }
 
 static int
-iwm_raw_xmit(struct ieee80211_node *ni , struct mbuf *m,
-    const struct ieee80211_bpf_params *bpfp)
-{
-       struct ieee80211vap *vap = ni->ni_vap;
-       struct ieee80211com *ic = ni->ni_ic;
+iwm_transmit(struct ieee80211com *ic, struct mbuf *m)
+{
        struct iwm_softc *sc = ic->ic_softc;
-       struct ifnet *ifp = vap->iv_ifp;
-       struct ether_header *eh;
-       int ac;
-
-       DPRINTFN(3, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
-
-       KASSERT(vap != NULL);   /*  NNN need these? */
-       KASSERT(ic != NULL);
-       KASSERT(sc != NULL);
-       KASSERT(m != NULL);
-
-       if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
-               return 0;
-
-       if (m->m_len < sizeof (*eh) &&
-           (m = m_pullup(m, sizeof (*eh))) == NULL) {
-               if_statinc(ifp, if_oerrors);
-                       return EIO;
-       }
-       eh = mtod(m, struct ether_header *);
-
-       /* No QoS encapsulation for EAPOL frames. */
-       ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ?
-           M_WME_GETAC(m) : WME_AC_BE;
-
-        bpf_mtap3(vap->iv_rawbpf, m, BPF_D_OUT);
-
-       if (iwm_tx(vap, m, ni, ac) != 0) {
-               ieee80211_free_node(ni);
-               if_statinc(ifp, if_oerrors);
-                       return ENXIO;
-       }
-
-       sc->sc_tx_timer = 5;
-       ifp->if_timer = 1;
+       int s;
+
+       DPRINTFN(5, ("%s: %s\n",ic->ic_name, __func__));
+
+       s = splnet();
+       IF_ENQUEUE(&sc->sc_sendq, m);
+       splx(s);
+
+       if (!(sc->sc_flags & IWM_FLAG_TX_RUNNING))
+               iwm_start(sc);
 
        return 0;
 }
 
 static int
-iwm_transmit(struct ieee80211com *ic, struct mbuf *m)
-{
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-       int s;
-
-       size_t pktlen = m->m_pkthdr.len;
-        bool mcast = (m->m_flags & M_MCAST) != 0;
-
-       DPRINTFN(3, ("%s: %s\n",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);
-
-       iwm_start(vap->iv_ifp);
-
-        return 0;
-}
-
-static int
 iwm_nic_tx_init(struct iwm_softc *sc)
 {
        int qid;
@@ -3791,6 +3742,8 @@
 {
        int err;
 
+       DPRINTFN(5, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+       
        if ((sc->sc_flags & IWM_FLAG_RFKILL) && !justnvm) {
                aprint_error_dev(sc->sc_dev,
                    "radio is disabled by hardware switch\n");
@@ -3811,8 +3764,7 @@
                        return err;
                }
 
-               memcpy(&sc->sc_ic.ic_macaddr, &sc->sc_nvm.hw_addr,
-                   ETHER_ADDR_LEN);
+               IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, sc->sc_nvm.hw_addr);
                return 0;
        }
 
@@ -3960,10 +3912,9 @@
 }
 
 static void
-iwm_rx_rx_phy_cmd(struct ieee80211vap *vap, struct iwm_rx_packet *pkt,
+iwm_rx_rx_phy_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
     struct iwm_rx_data *data)
 {
-       struct iwm_softc *sc = vap->iv_ic->ic_softc;
        struct iwm_rx_phy_info *phy_info = (void *)pkt->data;
 
        DPRINTFN(20, ("received PHY stats\n"));
@@ -3995,11 +3946,10 @@
 }
 
 static void
-iwm_rx_rx_mpdu(struct ieee80211vap *vap, struct iwm_rx_packet *pkt,
+iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
     struct iwm_rx_data *data)
 {
-       struct ieee80211com *ic = vap->iv_ic;
-       struct iwm_softc *sc = ic->ic_softc;
+       struct ieee80211com *ic = &sc->sc_ic;
        struct ieee80211_frame *wh;
        struct ieee80211_node *ni;
        struct ieee80211_channel *c = NULL;
@@ -4052,17 +4002,11 @@
        if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0)
                return;
 
-       m_set_rcvif(m, vap->iv_ifp);
-
        if (le32toh(phy_info->channel) < __arraycount(ic->ic_channels))
                c = &ic->ic_channels[le32toh(phy_info->channel)];
 
        s = splnet();
 
-       ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
-       if (c)
-               ni->ni_chan = c;
-
        if (__predict_false(sc->sc_drvbpf != NULL)) {
                struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap;
 
@@ -4107,6 +4051,11 @@
 
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m, BPF_D_IN);
        }
+
+       ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+       if (c)
+               ni->ni_chan = c;
+
        if (ni != NULL) {
                if (ni->ni_vap == NULL) {
                        ieee80211_free_node(ni);
@@ -4121,18 +4070,16 @@
                ieee80211_free_node(ni);
 
        } else {
-
-               /* No node found ... process differently. */
+               /* Managment frame */
                (void) ieee80211_input_all(ic, m, rssi + 116, 0);
        }
        splx(s);
 }
 
 static void
-iwm_rx_tx_cmd_single(struct ieee80211vap *vap, struct iwm_rx_packet *pkt,
+iwm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
     struct iwm_node *in)
 {
-       struct ifnet *ifp = vap->iv_ifp;
        struct iwm_tx_resp *tx_resp = (void *)pkt->data;
        int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK;
        int failack = tx_resp->failure_frame;
@@ -4147,17 +4094,15 @@
 
        if (status != IWM_TX_STATUS_SUCCESS &&
            status != IWM_TX_STATUS_DIRECT_DONE)
-               if_statinc(ifp, if_oerrors);
+               if_statinc(in->in_ni.ni_vap->iv_ifp, if_oerrors);
        else
-               if_statinc(ifp, if_opackets);
+               if_statinc(in->in_ni.ni_vap->iv_ifp, if_opackets);
 }
 
 static void
-iwm_rx_tx_cmd(struct ieee80211vap *vap, struct iwm_rx_packet *pkt,
+iwm_rx_tx_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
     struct iwm_rx_data *data)
 {
-       struct ifnet *ifp = vap->iv_ifp;
-       struct iwm_softc *sc = vap->iv_ic->ic_softc;
        struct iwm_cmd_header *cmd_hdr = &pkt->hdr;
        int idx = cmd_hdr->idx;
        int qid = cmd_hdr->qid;
@@ -4180,7 +4125,7 @@
 
        sc->sc_tx_timer = 0;
 
-       iwm_rx_tx_cmd_single(vap, pkt, in);
+       iwm_rx_tx_cmd_single(sc, pkt, in);



Home | Main Index | Thread Index | Old Index