Changeset View
Changeset View
Standalone View
Standalone View
tools/tools/iwn/iwnstats/main.c
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | iwnstats_new(const char *ifname) | ||||
is->s = open(buf, O_RDWR); | is->s = open(buf, O_RDWR); | ||||
if (is->s < 0) | if (is->s < 0) | ||||
err(1, "open"); | err(1, "open"); | ||||
return (is); | return (is); | ||||
} | } | ||||
static void | static void | ||||
iwn_stats_phy_print(struct iwnstats *is, struct iwn_rx_phy_stats *rxphy, | iwn_stats_phy_print(struct iwn_rx_phy_stats *rxphy, const char *prefix) | ||||
const char *prefix) | |||||
{ | { | ||||
printf("%s: %s: ina=%d, fina=%d, bad_plcp=%d, bad_crc32=%d, overrun=%d, eoverrun=%d\n", | printf("%s: %s: ina=%d, fina=%d, bad_plcp=%d, bad_crc32=%d, overrun=%d, eoverrun=%d\n", | ||||
__func__, | __func__, | ||||
prefix, | prefix, | ||||
le32toh(rxphy->ina), | le32toh(rxphy->ina), | ||||
le32toh(rxphy->fina), | le32toh(rxphy->fina), | ||||
le32toh(rxphy->bad_plcp), | le32toh(rxphy->bad_plcp), | ||||
Show All 18 Lines | printf("%s: %s: rxe_limit=%d, ack=%d, cts=%d, ba_resp=%d, dsp_kill=%d, bad_mh=%d, rssi_sum=%d\n", | ||||
le32toh(rxphy->cts), | le32toh(rxphy->cts), | ||||
le32toh(rxphy->ba_resp), | le32toh(rxphy->ba_resp), | ||||
le32toh(rxphy->dsp_kill), | le32toh(rxphy->dsp_kill), | ||||
le32toh(rxphy->bad_mh), | le32toh(rxphy->bad_mh), | ||||
le32toh(rxphy->rssi_sum)); | le32toh(rxphy->rssi_sum)); | ||||
} | } | ||||
static void | static void | ||||
iwn_stats_rx_general_print(struct iwnstats *is, struct iwn_rx_general_stats *g) | iwn_stats_rx_general_print(struct iwn_rx_general_stats *g) | ||||
{ | { | ||||
printf("%s: bad_cts=%d, bad_ack=%d, not_bss=%d, filtered=%d, bad_chan=%d, beacons=%d\n", | printf("%s: bad_cts=%d, bad_ack=%d, not_bss=%d, filtered=%d, bad_chan=%d, beacons=%d\n", | ||||
__func__, | __func__, | ||||
le32toh(g->bad_cts), | le32toh(g->bad_cts), | ||||
le32toh(g->bad_ack), | le32toh(g->bad_ack), | ||||
le32toh(g->not_bss), | le32toh(g->not_bss), | ||||
le32toh(g->filtered), | le32toh(g->filtered), | ||||
Show All 22 Lines | printf("%s: rssi=[%d, %d, %d] energy=[%d %d %d]\n", | ||||
le32toh(g->rssi[1]), | le32toh(g->rssi[1]), | ||||
le32toh(g->rssi[2]), | le32toh(g->rssi[2]), | ||||
le32toh(g->energy[0]), | le32toh(g->energy[0]), | ||||
le32toh(g->energy[1]), | le32toh(g->energy[1]), | ||||
le32toh(g->energy[2])); | le32toh(g->energy[2])); | ||||
} | } | ||||
static void | static void | ||||
iwn_stats_tx_print(struct iwnstats *is, struct iwn_tx_stats *tx) | iwn_stats_tx_print(struct iwn_tx_stats *tx) | ||||
{ | { | ||||
printf("%s: preamble=%d, rx_detected=%d, bt_defer=%d, bt_kill=%d, short_len=%d\n", | printf("%s: preamble=%d, rx_detected=%d, bt_defer=%d, bt_kill=%d, short_len=%d\n", | ||||
__func__, | __func__, | ||||
le32toh(tx->preamble), | le32toh(tx->preamble), | ||||
le32toh(tx->rx_detected), | le32toh(tx->rx_detected), | ||||
le32toh(tx->bt_defer), | le32toh(tx->bt_defer), | ||||
le32toh(tx->bt_kill), | le32toh(tx->bt_kill), | ||||
Show All 27 Lines | printf("%s: query_mismatch=%d, not_ready=%d, underrun=%d, bt_ht_kill=%d, rx_ba_resp=%d\n", | ||||
le32toh(tx->query_mismatch), | le32toh(tx->query_mismatch), | ||||
le32toh(tx->not_ready), | le32toh(tx->not_ready), | ||||
le32toh(tx->underrun), | le32toh(tx->underrun), | ||||
le32toh(tx->bt_ht_kill), | le32toh(tx->bt_ht_kill), | ||||
le32toh(tx->rx_ba_resp)); | le32toh(tx->rx_ba_resp)); | ||||
} | } | ||||
static void | static void | ||||
iwn_stats_ht_phy_print(struct iwnstats *is, struct iwn_rx_ht_phy_stats *ht) | iwn_stats_ht_phy_print(struct iwn_rx_ht_phy_stats *ht) | ||||
{ | { | ||||
printf("%s: bad_plcp=%d, overrun=%d, eoverrun=%d, good_crc32=%d, bad_crc32=%d\n", | printf("%s: bad_plcp=%d, overrun=%d, eoverrun=%d, good_crc32=%d, bad_crc32=%d\n", | ||||
__func__, | __func__, | ||||
le32toh(ht->bad_plcp), | le32toh(ht->bad_plcp), | ||||
le32toh(ht->overrun), | le32toh(ht->overrun), | ||||
le32toh(ht->eoverrun), | le32toh(ht->eoverrun), | ||||
le32toh(ht->good_crc32), | le32toh(ht->good_crc32), | ||||
le32toh(ht->bad_crc32)); | le32toh(ht->bad_crc32)); | ||||
printf("%s: bad_mh=%d, good_ampdu_crc32=%d, ampdu=%d, fragment=%d\n", | printf("%s: bad_mh=%d, good_ampdu_crc32=%d, ampdu=%d, fragment=%d\n", | ||||
__func__, | __func__, | ||||
le32toh(ht->bad_plcp), | le32toh(ht->bad_plcp), | ||||
le32toh(ht->good_ampdu_crc32), | le32toh(ht->good_ampdu_crc32), | ||||
le32toh(ht->ampdu), | le32toh(ht->ampdu), | ||||
le32toh(ht->fragment)); | le32toh(ht->fragment)); | ||||
} | } | ||||
static void | static void | ||||
iwn_stats_general_print(struct iwnstats *is, struct iwn_stats *stats) | iwn_stats_general_print(struct iwn_stats *stats) | ||||
{ | { | ||||
/* General */ | /* General */ | ||||
printf("%s: temp=%d, temp_m=%d, burst_check=%d, burst=%d, sleep=%d, slot_out=%d, slot_idle=%d\n", | printf("%s: temp=%d, temp_m=%d, burst_check=%d, burst=%d, sleep=%d, slot_out=%d, slot_idle=%d\n", | ||||
__func__, | __func__, | ||||
le32toh(stats->general.temp), | le32toh(stats->general.temp), | ||||
le32toh(stats->general.temp_m), | le32toh(stats->general.temp_m), | ||||
le32toh(stats->general.burst_check), | le32toh(stats->general.burst_check), | ||||
Show All 20 Lines | iwn_print(struct iwnstats *is) | ||||
struct iwn_stats *s; | struct iwn_stats *s; | ||||
struct timeval tv; | struct timeval tv; | ||||
s = &is->st; | s = &is->st; | ||||
gettimeofday(&tv, NULL); | gettimeofday(&tv, NULL); | ||||
printf("time=%ld.%.6ld\n", (long)tv.tv_sec, (long)tv.tv_usec); | printf("time=%ld.%.6ld\n", (long)tv.tv_sec, (long)tv.tv_usec); | ||||
iwn_stats_general_print(is, s); | iwn_stats_general_print(s); | ||||
/* RX */ | /* RX */ | ||||
iwn_stats_phy_print(is, &s->rx.ofdm, "ofdm"); | iwn_stats_phy_print(&s->rx.ofdm, "ofdm"); | ||||
iwn_stats_phy_print(is, &s->rx.cck, "cck"); | iwn_stats_phy_print(&s->rx.cck, "cck"); | ||||
iwn_stats_ht_phy_print(is, &s->rx.ht); | iwn_stats_ht_phy_print(&s->rx.ht); | ||||
iwn_stats_rx_general_print(is, &s->rx.general); | iwn_stats_rx_general_print(&s->rx.general); | ||||
/* TX */ | /* TX */ | ||||
iwn_stats_tx_print(is, &s->tx); | iwn_stats_tx_print(&s->tx); | ||||
printf("--\n"); | printf("--\n"); | ||||
} | } | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
printf("Usage: iwnstats [-h] [-i ifname]\n"); | printf("Usage: iwnstats [-h] [-i ifname]\n"); | ||||
printf(" -h: Help\n"); | printf(" -h: Help\n"); | ||||
printf(" -i <ifname>: Use ifname (default %s)\n", | printf(" -i <ifname>: Use ifname (default %s)\n", | ||||
IWN_DEFAULT_IF); | IWN_DEFAULT_IF); | ||||
} | } | ||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
struct iwnstats *is; | struct iwnstats *is; | ||||
int ch; | int ch; | ||||
char *ifname; | char *ifname; | ||||
bool first; | bool first; | ||||
char *sysctlname; | |||||
size_t len; | |||||
int ret; | |||||
ifname = strdup(IWN_DEFAULT_IF); | ifname = strdup(IWN_DEFAULT_IF); | ||||
/* Parse command line arguments */ | /* Parse command line arguments */ | ||||
while ((ch = getopt(argc, argv, | while ((ch = getopt(argc, argv, | ||||
"hi:")) != -1) { | "hi:")) != -1) { | ||||
switch (ch) { | switch (ch) { | ||||
case 'i': | case 'i': | ||||
Show All 39 Lines |