From patchwork Thu Aug 30 17:17:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuhao Zheng X-Patchwork-Id: 180848 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 481AC2C00A5 for ; Fri, 31 Aug 2012 03:24:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E4F249D248; Thu, 30 Aug 2012 13:24:33 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LNCTiYtG0kim; Thu, 30 Aug 2012 13:24:33 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9128C17C010; Thu, 30 Aug 2012 13:24:29 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2234F17C00E for ; Thu, 30 Aug 2012 13:24:28 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KAsg-9SDD+Vq for ; Thu, 30 Aug 2012 13:24:24 -0400 (EDT) Received: from mail-lpp01m010-f74.google.com (mail-lpp01m010-f74.google.com [209.85.215.74]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id DEE0017C010 for ; Thu, 30 Aug 2012 13:24:23 -0400 (EDT) Received: by lagw12 with SMTP id w12so111610lag.5 for ; Thu, 30 Aug 2012 10:24:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:date:subject:to:message-id:x-gm-message-state; bh=1YCb9doRa+CA9TLfG7fe9SOtvL2T6N9jZcYyydIuLOs=; b=mag+M1QkCfNH8Jb8U472QZyZ2hWoiAdPEKM/yBo3nON0rUnrZMSmTJy4tEAtYkAt10 BlUI60sY2sGxHSTwG41veLm+PdELhYAKuSHReGAXs5gYuMLh0T6fBuHVxJAgfN6fkqnj PKv/czUYzW62PgTp97GsCRwiMB5sNuuehCGkhj1wmH2wQS6csAQh2q+1xHMfJTPUN2o7 L6E1CumO50aLdzD8NQI+L9lnR6o+smzDzKRUr6dkrge+XDS8bq3QqYHELb67j93qX6l5 9RwgKyalp8Df13jDCIy8ZXCz+5S2ckKMVytIOOwkWxBQYqUl1imnkjBUvGoms46YcfPI hAxQ== Received: by 10.216.192.22 with SMTP id h22mr282723wen.10.1346347461907; Thu, 30 Aug 2012 10:24:21 -0700 (PDT) Received: by 10.216.192.22 with SMTP id h22mr282719wen.10.1346347461792; Thu, 30 Aug 2012 10:24:21 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id e5si240796wiw.0.2012.08.30.10.24.21 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 30 Aug 2012 10:24:21 -0700 (PDT) Received: from ushik.mtv.corp.google.com (ushik.mtv.corp.google.com [172.18.104.41]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 358CB20004E for ; Thu, 30 Aug 2012 10:24:21 -0700 (PDT) Received: by ushik.mtv.corp.google.com (Postfix, from userid 57417) id 76BE137FD0; Thu, 30 Aug 2012 10:24:20 -0700 (PDT) From: Yuhao Zheng Date: Thu, 30 Aug 2012 10:17:55 -0700 Subject: [PATCH] wpa_supplicant: Add PKTCNT_POLL command to get TX packet counters To: hostap@lists.shmoo.com Message-Id: <20120830172420.76BE137FD0@ushik.mtv.corp.google.com> X-Gm-Message-State: ALoCoQl4KvBttetZKihnb8J5oYGYzn/1UZYZ/5RiQOWycRA6YlTdtVh/CCPsoH155xlB0m5k3PPcreTl4ngU93wZaxQTlXcjhds6s5x5XmtHrGyydKbyT/jRtLlLJx00U261rAM6DCCbWcUJogO41MRTqLjrcVPUP1MlCQe+QasgMCN1ljtI3UeXqS9zgVUm0/GIBL0SneQJr5ukfT1hixp6Eskpwj09lkelVsb783522JIRTczTPjQ= X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Signed-off-by: Dmitry Shmidt --- src/drivers/driver_nl80211.c | 4 ++++ wpa_supplicant/ctrl_iface.c | 21 +++++++++++++++++++++ wpa_supplicant/driver_i.h | 8 ++++++++ wpa_supplicant/wpa_cli.c | 10 ++++++++++ 4 files changed, 43 insertions(+), 0 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 069e026..180e2f9 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -7373,6 +7373,7 @@ static int get_sta_handler(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 }, [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 }, + [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 }, }; nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), @@ -7408,6 +7409,9 @@ static int get_sta_handler(struct nl_msg *msg, void *arg) if (stats[NL80211_STA_INFO_TX_PACKETS]) data->tx_packets = nla_get_u32(stats[NL80211_STA_INFO_TX_PACKETS]); + if (stats[NL80211_STA_INFO_TX_FAILED]) + data->tx_retry_failed = + nla_get_u32(stats[NL80211_STA_INFO_TX_FAILED]); return NL_SKIP; } diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index d7ce6fe..916daa4 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -4305,6 +4305,24 @@ static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf, } +static int wpa_supplicant_pktcnt_poll(struct wpa_supplicant *wpa_s, char *buf, + size_t buflen) +{ + struct hostap_sta_driver_data sta; + int ret; + + ret = wpa_drv_pktcnt_poll(wpa_s, &sta); + if (ret) + return -1; + + ret = os_snprintf(buf, buflen, "TXGOOD=%lu\nTXBAD=%lu\nRXGOOD=%lu\n", + sta.tx_packets, sta.tx_retry_failed, sta.rx_packets); + if (ret < 0 || (size_t)ret > buflen) + return -1; + return ret; +} + + char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, char *buf, size_t *resp_len) { @@ -4806,6 +4824,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "SIGNAL_POLL", 11) == 0) { reply_len = wpa_supplicant_signal_poll(wpa_s, reply, reply_size); + } else if (os_strncmp(buf, "PKTCNT_POLL", 11) == 0) { + reply_len = wpa_supplicant_pktcnt_poll(wpa_s, reply, + reply_size); #ifdef CONFIG_AUTOSCAN } else if (os_strncmp(buf, "AUTOSCAN ", 9) == 0) { if (wpa_supplicant_ctrl_iface_autoscan(wpa_s, buf + 9)) diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index ac0936a..e28fecb 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -463,6 +463,14 @@ static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s, return -1; } +static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s, + struct hostap_sta_driver_data *sta) +{ + if (wpa_s->driver->read_sta_data) + return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta, wpa_s->bssid); + return -1; +} + static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s, const struct wpabuf *beacon, const struct wpabuf *proberesp, diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 2cb9513..e510b9b 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -2174,6 +2174,13 @@ static int wpa_cli_cmd_signal_poll(struct wpa_ctrl *ctrl, int argc, } +static int wpa_cli_cmd_pktcnt_poll(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_ctrl_command(ctrl, "PKTCNT_POLL"); +} + + static int wpa_cli_cmd_reauthenticate(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -2619,6 +2626,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { { "signal_poll", wpa_cli_cmd_signal_poll, NULL, cli_cmd_flag_none, "= get signal parameters" }, + { "pktcnt_poll", wpa_cli_cmd_pktcnt_poll, NULL, + cli_cmd_flag_none, + "= get TX/RX packet counters" }, { "reauthenticate", wpa_cli_cmd_reauthenticate, NULL, cli_cmd_flag_none, "= trigger IEEE 802.1X/EAPOL reauthentication" },