Please note: This project is no longer active. The website is kept online for historic purposes only.
If you´re looking for a Linux driver for your Atheros WLAN device, you should continue here .

Ticket #1164: madwifi-0.9.2.1-stats.diff

File madwifi-0.9.2.1-stats.diff, 14.2 kB (added by Massimo Vellucci <m.vellucci@unicampus.it>, 15 years ago)

patch increasing the number of stats you can obtain using ioctl

  • madwifi-0.9.2.1/ath/if_ath.c

    old new  
    202202static void ath_set_channel(struct ieee80211com *); 
    203203static void ath_set_coverageclass(struct ieee80211com *); 
    204204static u_int ath_mhz2ieee(struct ieee80211com *, u_int, u_int); 
     205static void ath_update_input_wme_stats(struct ieee80211com *ic, int wme_ac, u_int32_t packetscount, u_int32_t packetslen); 
    205206#ifdef ATH_SUPERG_FF 
    206207static int athff_can_aggregate(struct ath_softc *, struct ether_header *, 
    207208        struct ath_node *, struct sk_buff *, u_int16_t, int *); 
     
    854856        ic->ic_set_coverageclass = ath_set_coverageclass; 
    855857        ic->ic_mhz2ieee = ath_mhz2ieee; 
    856858 
     859        ic->ic_update_input_wme_stats = ath_update_input_wme_stats; 
     860 
    857861        if (register_netdev(dev)) { 
    858862                printk(KERN_ERR "%s: unable to register device\n", dev->name); 
    859863                goto bad3; 
     
    25242528 
    25252529        txq = sc->sc_ac2q[skb->priority]; 
    25262530 
     2531        sc->sc_stats.ast_wme[skb->priority].tx_packetscount++; 
     2532        sc->sc_stats.ast_wme[skb->priority].tx_packetslen += skb->len; 
     2533 
    25272534        if (txq->axq_depth > TAIL_DROP_COUNT) { 
    25282535                sc->sc_stats.ast_tx_discard++; 
     2536                sc->sc_stats.ast_wme[skb->priority].tx_discard++; 
    25292537                goto hardstart_fail; 
    25302538        } 
    25312539 
     
    71037111#endif 
    71047112                                if (ds->ds_txstat.ts_status & HAL_TXERR_XRETRY) { 
    71057113                                        sc->sc_stats.ast_tx_xretries++; 
     7114                                        sc->sc_stats.ast_wme[bf->bf_skb->priority].tx_failed++; 
    71067115                                        if (ni->ni_flags & IEEE80211_NODE_UAPSD_TRIG) { 
    71077116                                                ni->ni_stats.ns_tx_eosplost++; 
    71087117                                                DPRINTF(sc, ATH_DEBUG_UAPSD, 
     
    71187127                        sr = ds->ds_txstat.ts_shortretry; 
    71197128                        lr = ds->ds_txstat.ts_longretry; 
    71207129                        sc->sc_stats.ast_tx_shortretry += sr; 
     7130                        sc->sc_stats.ast_wme[bf->bf_skb->priority].tx_shortretry += sr; 
    71217131                        sc->sc_stats.ast_tx_longretry += lr; 
     7132                        sc->sc_stats.ast_wme[bf->bf_skb->priority].tx_longretry += lr; 
     7133 
    71227134                        /* 
    71237135                         * Hand the descriptor to the rate control algorithm 
    71247136                         * if the frame wasn't dropped for filtering or sent 
     
    77927804        return (ath_hal_mhz2ieee(sc->sc_ah, freq, flags)); 
    77937805} 
    77947806 
     7807static void  
     7808ath_update_input_wme_stats(struct ieee80211com *ic, int wme_ac, u_int32_t packetscount, u_int32_t packetslen) 
     7809{ 
     7810        struct ath_softc *sc = ic->ic_dev->priv; 
     7811 
     7812        sc->sc_stats.ast_wme[wme_ac].rx_packetscount += packetscount; 
     7813        sc->sc_stats.ast_wme[wme_ac].rx_packetslen += packetslen; 
     7814} 
    77957815 
    77967816/* 
    77977817 * Context: softIRQ and process context 
     
    90009020{ 
    90019021        struct ath_softc *sc = dev->priv; 
    90029022        struct ieee80211com *ic = &sc->sc_ic; 
     9023        struct ieee80211_wme_state *wme = &ic->ic_wme; 
    90039024        int error; 
    90049025 
    90059026        ATH_LOCK(sc); 
    90069027        switch (cmd) { 
    90079028        case SIOCGATHSTATS: 
    9008                 sc->sc_stats.ast_tx_packets = sc->sc_devstats.tx_packets; 
    9009                 sc->sc_stats.ast_rx_packets = sc->sc_devstats.rx_packets; 
    9010                 sc->sc_stats.ast_rx_rssi = ieee80211_getrssi(ic); 
     9029                sc->sc_stats.ast_tx_packets = sc->sc_devstats.tx_packets; 
     9030                sc->sc_stats.ast_tx_bytes = sc->sc_devstats.tx_bytes; 
     9031                sc->sc_stats.ast_rx_packets = sc->sc_devstats.rx_packets; 
     9032                sc->sc_stats.ast_rx_bytes = sc->sc_devstats.rx_bytes; 
     9033                sc->sc_stats.ast_rx_rssi = ieee80211_getrssi(ic); 
     9034                sc->sc_stats.ast_wme[WME_AC_BE].tx_pending = ath_hal_numtxpending(sc->sc_ah, sc->sc_ac2q[WME_AC_BE]->axq_qnum); 
     9035                sc->sc_stats.ast_wme[WME_AC_BE].tx_queue = sc->sc_ac2q[WME_AC_BE]->axq_depth; 
     9036                sc->sc_stats.ast_wme[WME_AC_BE].tx_totalqueued = sc->sc_ac2q[WME_AC_BE]->axq_totalqueued; 
     9037                sc->sc_stats.ast_wme[WME_AC_BE].wme_chan_logcwmin = wme->wme_chanParams.cap_wmeParams[WME_AC_BE].wmep_logcwmin; 
     9038                sc->sc_stats.ast_wme[WME_AC_BE].wme_chan_logcwmax = wme->wme_chanParams.cap_wmeParams[WME_AC_BE].wmep_logcwmax; 
     9039                sc->sc_stats.ast_wme[WME_AC_BE].wme_chan_aifsn = wme->wme_chanParams.cap_wmeParams[WME_AC_BE].wmep_aifsn; 
     9040                sc->sc_stats.ast_wme[WME_AC_BE].wme_chan_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_chanParams.cap_wmeParams[WME_AC_BE].wmep_txopLimit); 
     9041                sc->sc_stats.ast_wme[WME_AC_BE].wme_bss_logcwmin = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE].wmep_logcwmin; 
     9042                sc->sc_stats.ast_wme[WME_AC_BE].wme_bss_logcwmax = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE].wmep_logcwmax; 
     9043                sc->sc_stats.ast_wme[WME_AC_BE].wme_bss_aifsn = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE].wmep_aifsn; 
     9044                sc->sc_stats.ast_wme[WME_AC_BE].wme_bss_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE].wmep_txopLimit); 
     9045                sc->sc_stats.ast_wme[WME_AC_BK].tx_pending = ath_hal_numtxpending(sc->sc_ah, sc->sc_ac2q[WME_AC_BK]->axq_qnum); 
     9046                sc->sc_stats.ast_wme[WME_AC_BK].tx_queue = sc->sc_ac2q[WME_AC_BK]->axq_depth; 
     9047                sc->sc_stats.ast_wme[WME_AC_BK].tx_totalqueued = sc->sc_ac2q[WME_AC_BK]->axq_totalqueued; 
     9048                sc->sc_stats.ast_wme[WME_AC_BK].wme_chan_logcwmin = wme->wme_chanParams.cap_wmeParams[WME_AC_BK].wmep_logcwmin; 
     9049                sc->sc_stats.ast_wme[WME_AC_BK].wme_chan_logcwmax = wme->wme_chanParams.cap_wmeParams[WME_AC_BK].wmep_logcwmax; 
     9050                sc->sc_stats.ast_wme[WME_AC_BK].wme_chan_aifsn = wme->wme_chanParams.cap_wmeParams[WME_AC_BK].wmep_aifsn; 
     9051                sc->sc_stats.ast_wme[WME_AC_BK].wme_chan_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_chanParams.cap_wmeParams[WME_AC_BK].wmep_txopLimit); 
     9052                sc->sc_stats.ast_wme[WME_AC_BK].wme_bss_logcwmin = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BK].wmep_logcwmin; 
     9053                sc->sc_stats.ast_wme[WME_AC_BK].wme_bss_logcwmax = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BK].wmep_logcwmax; 
     9054                sc->sc_stats.ast_wme[WME_AC_BK].wme_bss_aifsn = wme->wme_bssChanParams.cap_wmeParams[WME_AC_BK].wmep_aifsn; 
     9055                sc->sc_stats.ast_wme[WME_AC_BK].wme_bss_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_bssChanParams.cap_wmeParams[WME_AC_BK].wmep_txopLimit); 
     9056                sc->sc_stats.ast_wme[WME_AC_VI].tx_pending = ath_hal_numtxpending(sc->sc_ah, sc->sc_ac2q[WME_AC_VI]->axq_qnum); 
     9057                sc->sc_stats.ast_wme[WME_AC_VI].tx_queue = sc->sc_ac2q[WME_AC_VI]->axq_depth; 
     9058                sc->sc_stats.ast_wme[WME_AC_VI].tx_totalqueued = sc->sc_ac2q[WME_AC_VI]->axq_totalqueued; 
     9059                sc->sc_stats.ast_wme[WME_AC_VI].wme_chan_logcwmin = wme->wme_chanParams.cap_wmeParams[WME_AC_VI].wmep_logcwmin; 
     9060                sc->sc_stats.ast_wme[WME_AC_VI].wme_chan_logcwmax = wme->wme_chanParams.cap_wmeParams[WME_AC_VI].wmep_logcwmax; 
     9061                sc->sc_stats.ast_wme[WME_AC_VI].wme_chan_aifsn = wme->wme_chanParams.cap_wmeParams[WME_AC_VI].wmep_aifsn; 
     9062                sc->sc_stats.ast_wme[WME_AC_VI].wme_chan_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_chanParams.cap_wmeParams[WME_AC_VI].wmep_txopLimit); 
     9063                sc->sc_stats.ast_wme[WME_AC_VI].wme_bss_logcwmin = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VI].wmep_logcwmin; 
     9064                sc->sc_stats.ast_wme[WME_AC_VI].wme_bss_logcwmax = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VI].wmep_logcwmax; 
     9065                sc->sc_stats.ast_wme[WME_AC_VI].wme_bss_aifsn = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VI].wmep_aifsn; 
     9066                sc->sc_stats.ast_wme[WME_AC_VI].wme_bss_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_bssChanParams.cap_wmeParams[WME_AC_VI].wmep_txopLimit); 
     9067                sc->sc_stats.ast_wme[WME_AC_VO].tx_pending = ath_hal_numtxpending(sc->sc_ah, sc->sc_ac2q[WME_AC_VO]->axq_qnum); 
     9068                sc->sc_stats.ast_wme[WME_AC_VO].tx_queue = sc->sc_ac2q[WME_AC_VO]->axq_depth; 
     9069                sc->sc_stats.ast_wme[WME_AC_VO].tx_totalqueued = sc->sc_ac2q[WME_AC_VO]->axq_totalqueued; 
     9070                sc->sc_stats.ast_wme[WME_AC_VO].wme_chan_logcwmin = wme->wme_chanParams.cap_wmeParams[WME_AC_VO].wmep_logcwmin; 
     9071                sc->sc_stats.ast_wme[WME_AC_VO].wme_chan_logcwmax = wme->wme_chanParams.cap_wmeParams[WME_AC_VO].wmep_logcwmax; 
     9072                sc->sc_stats.ast_wme[WME_AC_VO].wme_chan_aifsn = wme->wme_chanParams.cap_wmeParams[WME_AC_VO].wmep_aifsn; 
     9073                sc->sc_stats.ast_wme[WME_AC_VO].wme_chan_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_chanParams.cap_wmeParams[WME_AC_VO].wmep_txopLimit); 
     9074                sc->sc_stats.ast_wme[WME_AC_VO].wme_bss_logcwmin = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VO].wmep_logcwmin; 
     9075                sc->sc_stats.ast_wme[WME_AC_VO].wme_bss_logcwmax = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VO].wmep_logcwmax; 
     9076                sc->sc_stats.ast_wme[WME_AC_VO].wme_bss_aifsn = wme->wme_bssChanParams.cap_wmeParams[WME_AC_VO].wmep_aifsn; 
     9077                sc->sc_stats.ast_wme[WME_AC_VO].wme_bss_txopLimit = IEEE80211_TXOP_TO_US(wme->wme_bssChanParams.cap_wmeParams[WME_AC_VO].wmep_txopLimit); 
    90119078                if (copy_to_user(ifr->ifr_data, &sc->sc_stats, sizeof (sc->sc_stats))) 
    90129079                        error = -EFAULT; 
    90139080                else 
  • madwifi-0.9.2.1/ath/if_athioctl.h

    old new  
    4242#ifndef _DEV_ATH_ATHIOCTL_H 
    4343#define _DEV_ATH_ATHIOCTL_H 
    4444 
     45#include "net80211/ieee80211.h"         /* XXX for WME_NUM_AC */ 
     46 
     47struct ath_stats_wme { 
     48        u_int32_t tx_packetscount; 
     49        u_int32_t tx_packetslen; 
     50        u_int32_t rx_packetscount; 
     51        u_int32_t rx_packetslen; 
     52        u_int32_t tx_shortretry;        /* tx on-chip retries (short) */ 
     53        u_int32_t tx_longretry;         /* tx on-chip retries (long) */ 
     54        u_int32_t tx_pending;           /* tx packet pending */ 
     55        u_int32_t tx_queue;             /* tx packet queue */ 
     56        u_int32_t tx_totalqueued;       /* tx packet total queued */ 
     57        u_int32_t tx_failed;            /* tx packet failed */ 
     58        u_int32_t tx_discard;           /* tx packet discard */ 
     59        u_int8_t wme_chan_logcwmin;     /* cwmin in exponential form */ 
     60        u_int8_t wme_chan_logcwmax;     /* cwmax in exponential form */ 
     61        u_int8_t wme_chan_aifsn;        /* AIFSN parameters */ 
     62        u_int16_t wme_chan_txopLimit;   /* txopLimit */ 
     63        u_int8_t wme_bss_logcwmin;      /* cwmin in exponential form */ 
     64        u_int8_t wme_bss_logcwmax;      /* cwmax in exponential form */ 
     65        u_int8_t wme_bss_aifsn;         /* AIFSN parameters */ 
     66        u_int16_t wme_bss_txopLimit;    /* txopLimit */ 
     67}; 
     68 
    4569struct ath_stats { 
    4670        u_int32_t ast_watchdog;         /* device reset by watchdog */ 
    4771        u_int32_t ast_hardware;         /* fatal hardware error interrupts */ 
     
    5175        u_int32_t ast_txurn;            /* tx underrun interrupts */ 
    5276        u_int32_t ast_mib;              /* mib interrupts */ 
    5377        u_int32_t ast_tx_packets;       /* packet sent on the interface */ 
     78        u_int32_t ast_tx_bytes;         /* total bytes transmitted */ 
    5479        u_int32_t ast_tx_mgmt;          /* management frames transmitted */ 
    5580        u_int32_t ast_tx_discard;       /* frames discarded prior to assoc */ 
    5681        u_int32_t ast_tx_invalid;       /* frames discarded due to is device gone */ 
     
    82107        u_int32_t ast_rx_toobig;                /* rx discarded due to frame too large */ 
    83108        u_int32_t ast_rx_nobuf;         /* rx setup failed due to of no skbuff */ 
    84109        u_int32_t ast_rx_packets;       /* packet recv on the interface */ 
     110        u_int32_t ast_rx_bytes;         /* total bytes received */ 
    85111        u_int32_t ast_rx_mgt;           /* management frames received */ 
    86112        u_int32_t ast_rx_ctl;           /* control frames received */ 
    87113        int8_t ast_tx_rssi;             /* tx rssi of last ack */ 
     
    98124        u_int32_t ast_ant_txswitch;     /* tx antenna switches */ 
    99125        u_int32_t ast_ant_rx[8];                /* rx frames with antenna */ 
    100126        u_int32_t ast_ant_tx[8];                /* tx frames with antenna */ 
     127        struct ath_stats_wme ast_wme[WME_NUM_AC]; 
    101128}; 
    102129 
    103130struct ath_diag { 
  • madwifi-0.9.2.1/net80211/ieee80211_input.c

    old new  
    239239        u_int8_t dir, type, subtype; 
    240240        u_int8_t *bssid; 
    241241        u_int16_t rxseq; 
     242        unsigned int rawlen; 
    242243 
    243244        KASSERT(ni != NULL, ("null node")); 
    244245        ni->ni_inact = ni->ni_inact_reload; 
    245246 
     247        rawlen = skb->len; 
    246248        KASSERT(skb->len >= sizeof(struct ieee80211_frame_min), 
    247249                ("frame length too short: %u", skb->len)); 
    248250 
     
    742744                        athff_decap(skb1); 
    743745 
    744746                        /* deliver the frames */ 
     747                        ic->ic_update_input_wme_stats(ic, ieee80211_getwmefromtos((struct ether_header *)skb->data), 1, (u_int32_t)((rawlen * skb->len) / (skb->len + skb1->len))); 
    745748                        ieee80211_deliver_data(ni, skb); 
     749 
     750                        ic->ic_update_input_wme_stats(ic, ieee80211_getwmefromtos((struct ether_header *)skb1->data), 1, (u_int32_t)((rawlen * skb1->len) / (skb->len + skb1->len))); 
    746751                        ieee80211_deliver_data(ni, skb1); 
    747752                } else { 
    748753                        /* assume non-atheros llc type */ 
     754                        ic->ic_update_input_wme_stats(ic, ieee80211_getwmefromtos((struct ether_header *)skb->data), 1, (u_int32_t)rawlen); 
    749755                        ieee80211_deliver_data(ni, skb); 
    750756                } 
    751757#else /* !ATH_SUPERG_FF */ 
     758                ic->ic_update_input_wme_stats(ic, ieee80211_getwmefromtos((struct ether_header *)skb->data), 1, (u_int32_t)rawlen); 
    752759                ieee80211_deliver_data(ni, skb); 
    753760#endif 
    754761                return IEEE80211_FC0_TYPE_DATA; 
  • madwifi-0.9.2.1/net80211/ieee80211_output.c

    old new  
    7373} 
    7474#endif 
    7575 
     76int  
     77ieee80211_getwmefromtos(struct ether_header *eh) 
     78{ 
     79        if (eh->ether_type == __constant_htons(ETHERTYPE_IP)) { 
     80                const struct iphdr *ip = (struct iphdr *)((char*)eh + sizeof(struct ether_header)); 
     81                /* 
     82                 * IP frame, map the TOS field. 
     83                 * 
     84                 * XXX: fill out these mappings??? 
     85                 */ 
     86                switch(ip->tos) { 
     87                case 0x08:                              /* Background */ 
     88                case 0x20: 
     89                        return WME_AC_BK; 
     90                case 0x28:                              /* Video */ 
     91                case 0xa0: 
     92                        return WME_AC_VI; 
     93                case 0x30:                              /* Voice */ 
     94                case 0xe0: 
     95                case 0x88:                              /* XXX UPSD */ 
     96                case 0xb8: 
     97                        return WME_AC_VO; 
     98                default:                                /* All others */ 
     99                        return WME_AC_BE; 
     100                } 
     101        } 
     102 
     103        return WME_AC_BE; 
     104} 
    76105 
    77106/* 
    78107 * Determine the priority based on VLAN and/or IP TOS. Priority is 
     
    134163                } 
    135164        } 
    136165 
     166        d_wme_ac = ieee80211_getwmefromtos(eh); 
     167 
    137168        if (eh->ether_type == __constant_htons(ETHERTYPE_IP)) { 
    138169                const struct iphdr *ip = (struct iphdr *) 
    139170                        (skb->data + sizeof (struct ether_header)); 
  • madwifi-0.9.2.1/net80211/ieee80211_var.h

    old new  
    247247 
    248248        /* mhz to ieee conversion */ 
    249249        u_int (*ic_mhz2ieee)(struct ieee80211com *, u_int, u_int); 
     250 
     251        /* update input wme stats */ 
     252        void (*ic_update_input_wme_stats)(struct ieee80211com *, int, u_int32_t, u_int32_t); 
    250253}; 
    251254 
    252255struct vlan_group; 
     
    555560int ieee80211_media_setup(struct ieee80211com *, struct ifmedia *, u_int32_t, 
    556561        ifm_change_cb_t, ifm_stat_cb_t); 
    557562 
     563struct ether_header; 
     564int ieee80211_getwmefromtos(struct ether_header *); 
     565 
    558566/*  
    559567 * Key update synchronization methods.  XXX should not be visible. 
    560568 */