Commit aad1a266 authored by Anjan Chanda's avatar Anjan Chanda

add radio info details including diagnostics

parent 939b0ae9
......@@ -449,23 +449,50 @@ static const struct blobmsg_policy wl_vif_policy[__WL_MAX] = {
[VIF_NAME] = { .name = "vif", .type = BLOBMSG_TYPE_STRING },
};
static void wifi_print_radio_stats(struct blob_buf *bb,
struct wifi_radio_stats *s)
{
blobmsg_add_u32(bb, "tx_bytes", s->tx_bytes);
blobmsg_add_u32(bb, "tx_packets", s->tx_pkts);
blobmsg_add_u32(bb, "tx_error_packets", s->tx_err_pkts);
blobmsg_add_u32(bb, "tx_dropped_packets", s->tx_dropped_pkts);
blobmsg_add_u32(bb, "rx_bytes", s->rx_bytes);
blobmsg_add_u32(bb, "rx_packets", s->rx_pkts);
blobmsg_add_u32(bb, "rx_error_packets", s->rx_err_pkts);
blobmsg_add_u32(bb, "rx_dropped_packets", s->rx_dropped_pkts);
blobmsg_add_u32(bb, "rx_fcs_error_packets", s->rx_fcs_err_pkts);
}
static void wifi_print_radio_diagnostics(struct blob_buf *bb,
struct wifi_radio_diagnostic *d)
{
blobmsg_add_u32(bb, "channel_busy", d->channel_busy);
blobmsg_add_u32(bb, "tx_airtime", d->tx_airtime);
blobmsg_add_u32(bb, "rx_airtime", d->rx_airtime);
blobmsg_add_u32(bb, "obss_airtime", d->obss_airtime);
blobmsg_add_u32(bb, "cca_time", d->cca_time);
blobmsg_add_u32(bb, "false_cca_count", d->false_cca_count);
}
static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__WL_MAX];
char syspath[32];
char std_buf2[32] = "802.11";
char std_buf[32] = {0};
const char *wldev;
ifstatus_t ifs = 0;
uint32_t channel;
enum wifi_bw bw;
int band = 0;
//char macaddr[17] = {0};
unsigned long rate;
unsigned long maxrate;
int bandwidth, noise;
struct wifi_radio radio;
struct blob_buf bb;
void *c;
int i;
memset(&bb, 0, sizeof(bb));
blobmsg_parse(wl_vif_policy, __WL_MAX, tb, blob_data(msg), blob_len(msg));
......@@ -481,7 +508,7 @@ static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
if (bw < bw20 || bw > bw160) { // FIXME: in libwifi
bw = bw8080 + 1; // Unknown
}
wifi_get_maxrate(wldev, &rate);
wifi_get_maxrate(wldev, &maxrate);
wifi_get_noise(wldev, &noise);
memset(&radio, 0, sizeof(struct wifi_radio));
......@@ -491,16 +518,57 @@ static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_string(&bb, "radio", wldev);
blobmsg_add_u8(&bb, "isup", (ifs & IFF_UP) ? true : false);
blobmsg_add_u32(&bb, "band", (band == 1) ? 5 : 2);
sprintf(std_buf2 + strlen(std_buf2), "%s",
etostr(radio.oper_std, std_buf, MODE_MAX, standard_str));
blobmsg_add_string(&bb, "standard", std_buf2);
blobmsg_add_u32(&bb, "channel", channel);
blobmsg_add_u32(&bb, "bandwidth", bw_int[bw]);
blobmsg_add_u32(&bb, "noise", noise);
blobmsg_add_u64(&bb, "rate", rate);
blobmsg_add_u64(&bb, "maxrate", maxrate);
blobmsg_add_u32(&bb, "tx_streams", radio.tx_streams);
blobmsg_add_u32(&bb, "rx_streams", radio.rx_streams);
blobmsg_add_u32(&bb, "noise", noise);
c = blobmsg_open_array(&bb, "supp_channels");
for (i = 0; i < 32 && radio.supp_channels[i] != 0; i++) {
blobmsg_add_u32(&bb, "", radio.supp_channels[i]);
}
blobmsg_close_array(&bb, c);
if (radio.acs_capable) {
c = blobmsg_open_table(&bb, "autochannel");
blobmsg_add_u8(&bb, "enabled", radio.acs_enabled ? true : false);
blobmsg_add_u32(&bb, "interval", radio.acs_interval);
blobmsg_close_table(&bb, c);
}
blobmsg_add_u32(&bb, "txpower", radio.txpower);
blobmsg_add_u8(&bb, "dot11h_capable", radio.dot11h_capable ? true : false);
blobmsg_add_u8(&bb, "dot11h_enabled", radio.dot11h_enabled ? true : false);
blobmsg_add_string(&bb, "regdomain", radio.regdomain);
blobmsg_add_u32(&bb, "beacon_int", radio.beacon_int);
blobmsg_add_u32(&bb, "dtim_period", radio.dtim_period);
blobmsg_add_string(&bb, "preamble",
radio.pr == short_preamble ? "short" :
radio.pr == long_preamble ? "long" : "auto");
blobmsg_add_u32(&bb, "short_retry_limit", radio.srl);
blobmsg_add_u32(&bb, "long_retry_limit", radio.lrl);
blobmsg_add_u32(&bb, "frag_threshold", radio.frag);
blobmsg_add_u32(&bb, "rts_threshold", radio.rts);
blobmsg_add_u8(&bb, "aggr_enabled", radio.aggr_enable ? true : false);
c = blobmsg_open_table(&bb, "stats");
wifi_print_radio_stats(&bb, &radio.stats);
blobmsg_close_table(&bb, c);
c = blobmsg_open_table(&bb, "diagnostics");
wifi_print_radio_diagnostics(&bb, &radio.diag);
blobmsg_close_table(&bb, c);
ubus_send_reply(ctx, req, bb.head);
blob_buf_free(&bb);
......@@ -524,17 +592,7 @@ static int wl_radio_stats(struct ubus_context *ctx, struct ubus_object *obj,
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
blobmsg_add_u32(&bb, "tx_bytes", s.tx_bytes);
blobmsg_add_u32(&bb, "tx_packets", s.tx_pkts);
blobmsg_add_u32(&bb, "tx_error_packets", s.tx_err_pkts);
blobmsg_add_u32(&bb, "tx_dropped_packets", s.tx_dropped_pkts);
blobmsg_add_u32(&bb, "rx_bytes", s.rx_bytes);
blobmsg_add_u32(&bb, "rx_packets", s.rx_pkts);
blobmsg_add_u32(&bb, "rx_error_packets", s.rx_err_pkts);
blobmsg_add_u32(&bb, "rx_dropped_packets", s.rx_dropped_pkts);
blobmsg_add_u32(&bb, "rx_fcs_error_packets", s.rx_fcs_err_pkts);
wifi_print_radio_stats(&bb, &s);
ubus_send_reply(ctx, req, bb.head);
blob_buf_free(&bb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment