RDKB: refine radio counter for loop all bss
1. radio counter loop all bss
2. per wifi interface counter revert to use ifconfig command
Test: Pass
Change-Id: I8e6a52bc00a3039d4be230ee057072682ae9b87f
diff --git a/src/wifi/wifi_hal.c b/src/wifi/wifi_hal.c
index 6103c34..e58b87e 100644
--- a/src/wifi/wifi_hal.c
+++ b/src/wifi/wifi_hal.c
@@ -3563,45 +3563,18 @@
return RETURN_OK;
}
-static ULONG File_ReadValuefromMultiLine(CHAR *file)
-{
- FILE *fp = NULL;
- char buf[MAX_BUF_SIZE] = {0};
- int buf_len = 0;
- ULONG sum = 0, num = 0;
-
- WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
- fp = popen(file,"r");
- if(fp == NULL)
- return 0;
-
- while(fgets(buf,MAX_BUF_SIZE,fp) != NULL)
- {
- buf_len = strlen(buf);
- if(buf_len) {
- num= strtoul(buf, NULL, 10);
- sum += num;
- WIFI_ENTRY_EXIT_DEBUG("%s sum=%ld num=%ld\n", __func__, sum, num);
- memset(buf, 0, MAX_BUF_SIZE);
- }
- }
-
- pclose(fp);
- WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
-
- return sum;
-}
INT wifi_halGetIfStats(char *ifname, wifi_radioTrafficStats2_t *pStats)
{
WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n", __func__, __LINE__);
- CHAR buf[MAX_BUF_SIZE] = {0};
+ CHAR buf[MAX_CMD_SIZE] = {0};
+ CHAR Value[MAX_BUF_SIZE] = {0};
FILE *fp = NULL;
if (ifname == NULL || strlen(ifname) <= 1)
return RETURN_OK;
- snprintf(buf, sizeof(buf), "iw dev %s station dump > /tmp/Radio_Stats.txt", ifname);
+ snprintf(buf, sizeof(buf), "ifconfig -a %s > /tmp/Radio_Stats.txt", ifname);
system(buf);
fp = fopen("/tmp/Radio_Stats.txt", "r");
@@ -3612,29 +3585,37 @@
}
fclose(fp);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'rx packets' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_PacketsReceived = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'RX packets' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_PacketsReceived = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'tx packets' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_PacketsSent = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'TX packets' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_PacketsSent = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'rx bytes' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_BytesReceived = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'RX bytes' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_BytesReceived = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'tx bytes' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_BytesSent = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'TX bytes' | tr -s ' ' | cut -d ':' -f3 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_BytesSent = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'rx drop misc' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_ErrorsReceived = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'RX packets' | tr -s ' ' | cut -d ':' -f3 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_ErrorsReceived = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'tx failed' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_ErrorsSent = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'TX packets' | tr -s ' ' | cut -d ':' -f3 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_ErrorsSent = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'rx drop misc' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_DiscardPacketsReceived = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'RX packets' | tr -s ' ' | cut -d ':' -f4 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_DiscardPacketsReceived = strtoul(Value, NULL, 10);
- sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'tx failed' | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f1");
- pStats->radio_DiscardPacketsSent = File_ReadValuefromMultiLine(buf);
+ sprintf(buf, "cat /tmp/Radio_Stats.txt | grep 'TX packets' | tr -s ' ' | cut -d ':' -f4 | cut -d ' ' -f1");
+ File_Reading(buf, Value);
+ pStats->radio_DiscardPacketsSent = strtoul(Value, NULL, 10);
WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n", __func__, __LINE__);
return RETURN_OK;