3 #include <sys/socket.h>
4 #include <netlink/genl/genl.h>
5 #include <netlink/genl/family.h>
6 #include <netlink/genl/ctrl.h>
7 #include <linux/rtnetlink.h>
8 #include <netpacket/packet.h>
9 #include <linux/filter.h>
10 #include <linux/errqueue.h>
12 #include <linux/pkt_sched.h>
13 #include <netlink/object-api.h>
14 #include <netlink/netlink.h>
15 #include <netlink/socket.h>
16 #include <netlink-private/object-api.h>
17 #include <netlink-private/types.h>
19 #include "nl80211_copy.h"
22 #define LOG_TAG "WifiHAL"
24 #include <utils/Log.h>
28 #include "cpp_bindings.h"
30 /* using namespace android; */
33 ENHANCE_LOGGER_START_LOGGING
= ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START
,
34 ENHANCE_LOGGER_TRIGGER_FW_MEM_DUMP
,
35 ENHANCE_LOGGER_GET_FW_MEM_DUMP
,
36 ENHANCE_LOGGER_GET_VER
,
37 ENHANCE_LOGGER_GET_RING_STATUS
,
38 ENHANCE_LOGGER_GET_RING_DATA
,
39 ENHANCE_LOGGER_GET_FEATURE
,
40 ENHANCE_LOGGER_RESET_LOGGING
,
41 ENHANCE_LOGGER_TRIGGER_DRIVER_MEM_DUMP
,
42 ENHANCE_LOGGER_GET_DRIVER_MEM_DUMP
,
43 ENHANCE_LOGGER_START_PKT_FATE_MONITORING
,
44 ENHANCE_LOGGER_GET_TX_PKT_FATES
,
45 ENHANCE_LOGGER_GET_RX_PKT_FATES
,
46 ENHANCE_LOGGER_GET_WAKE_REASON_STATS
,
50 ENHANCE_LOGGER_ATTRIBUTE_DRIVER_VER
,
51 ENHANCE_LOGGER_ATTRIBUTE_FW_VER
,
52 ENHANCE_LOGGER_ATTRIBUTE_RING_ID
,
53 ENHANCE_LOGGER_ATTRIBUTE_RING_NAME
,
54 ENHANCE_LOGGER_ATTRIBUTE_RING_FLAGS
,
55 ENHANCE_LOGGER_ATTRIBUTE_LOG_LEVEL
,
56 ENHANCE_LOGGER_ATTRIBUTE_LOG_TIME_INTVAL
,
57 ENHANCE_LOGGER_ATTRIBUTE_LOG_MIN_DATA_SIZE
,
58 ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
,
59 ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
,
60 // LOGGER_ATTRIBUTE_FW_ERR_CODE,
61 ENHANCE_LOGGER_ATTRIBUTE_RING_DATA
,
62 ENHANCE_LOGGER_ATTRIBUTE_RING_STATUS
,
63 ENHANCE_LOGGER_ATTRIBUTE_RING_NUM
,
64 ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_LEN
,
65 ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA
,
66 ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
,
67 ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA
,
68 //Attributes for data used by wake stats subcmd.
69 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_INVALID
= 0,
70 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_CMD_EVENT_WAKE
,
71 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_PTR
,
72 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_SZ
,
73 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_DRIVER_FW_LOCAL_WAKE
,
74 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_PTR
,
75 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_SZ
,
76 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_RX_DATA_WAKE
,
77 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_UNICAST_CNT
,
78 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_MULTICAST_CNT
,
79 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_BROADCAST_CNT
,
80 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP_PKT
,
81 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_PKT
,
82 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RA
,
83 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NA
,
84 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NS
,
85 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP4_RX_MULTICAST_CNT
,
86 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RX_MULTICAST_CNT
,
87 ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_OTHER_RX_MULTICAST_CNT
,
88 } ENHANCE_LOGGER_ATTRIBUTE
;
96 } ENHANCE_LOGGER_LEVEL
;
110 PACKET_MONITOR_START
,
115 class DebugCommand
: public WifiCommand
118 int *mBuffSize
= NULL
;
119 u32
*mNumRings
= NULL
;
120 wifi_ring_buffer_status
*mStatus
= NULL
;
121 unsigned int *mSupport
= NULL
;
122 u32 mVerboseLevel
= 0;
124 u32 mMaxIntervalSec
= 0;
125 u32 mMinDataSize
= 0;
126 char *mRingName
= NULL
;
131 // constructor for get version
132 DebugCommand(wifi_interface_handle iface
, char *buffer
, int *buffer_size
,
134 : WifiCommand(iface
, 0), mBuff(buffer
), mBuffSize(buffer_size
), mType
137 memset(mBuff
, 0, *mBuffSize
);
140 // constructor for ring data
141 DebugCommand(wifi_interface_handle iface
, char *ring_name
, GetCmdType cmdType
)
142 : WifiCommand(iface
, 0), mRingName(ring_name
), mType(cmdType
)
145 // constructor for ring status
146 DebugCommand(wifi_interface_handle iface
, u32
*num_rings
,
147 wifi_ring_buffer_status
*status
, GetCmdType cmdType
)
148 : WifiCommand(iface
, 0), mNumRings(num_rings
), mStatus(status
), mType(cmdType
)
150 memset(mStatus
, 0, sizeof(wifi_ring_buffer_status
) * (*mNumRings
));
153 // constructor for feature set
154 DebugCommand(wifi_interface_handle iface
, unsigned int *support
, GetCmdType cmdType
)
155 : WifiCommand(iface
, 0), mSupport(support
), mType(cmdType
)
158 // constructor for ring params
159 DebugCommand(wifi_interface_handle iface
, u32 verbose_level
, u32 flags
,
160 u32 max_interval_sec
, u32 min_data_size
, char *ring_name
, GetCmdType cmdType
)
161 : WifiCommand(iface
, 0), mVerboseLevel(verbose_level
), mFlags(flags
),
162 mMaxIntervalSec(max_interval_sec
), mMinDataSize(min_data_size
),
163 mRingName(ring_name
), mType(cmdType
)
166 int createRingRequest(WifiRequest
& request
) {
167 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_START_LOGGING
);
168 if (result
!= WIFI_SUCCESS
) {
169 ALOGE("Failed to create start ring logger request; result = %d", result
);
173 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
175 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_LOG_LEVEL
, mVerboseLevel
);
176 if (result
!= WIFI_SUCCESS
) {
177 ALOGE("Failed to put log level; result = %d", result
);
180 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_RING_FLAGS
, mFlags
);
181 if (result
!= WIFI_SUCCESS
) {
182 ALOGE("Failed to put ring flags; result = %d", result
);
185 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_LOG_TIME_INTVAL
, mMaxIntervalSec
);
186 if (result
!= WIFI_SUCCESS
) {
187 ALOGE("Failed to put log time interval; result = %d", result
);
190 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_LOG_MIN_DATA_SIZE
, mMinDataSize
);
191 if (result
!= WIFI_SUCCESS
) {
192 ALOGE("Failed to put min data size; result = %d", result
);
195 result
= request
.put_string(ENHANCE_LOGGER_ATTRIBUTE_RING_NAME
, mRingName
);
196 if (result
!= WIFI_SUCCESS
) {
197 ALOGE("Failed to put ringbuffer name; result = %d", result
);
200 request
.attr_end(data
);
205 int createRequest(WifiRequest
&request
) {
211 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_VER
);
212 if (result
!= WIFI_SUCCESS
) {
213 ALOGE("Failed to create get fw version request; result = %d", result
);
217 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
219 // Driver expecting only attribute type, passing mbuff as data with
220 // length 0 to avoid undefined state
221 result
= request
.put(ENHANCE_LOGGER_ATTRIBUTE_FW_VER
, mBuff
, 0);
222 if (result
!= WIFI_SUCCESS
) {
223 ALOGE("Failed to put get fw version request; result = %d", result
);
226 request
.attr_end(data
);
232 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_VER
);
233 if (result
!= WIFI_SUCCESS
) {
234 ALOGE("Failed to create get drv version request; result = %d", result
);
238 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
240 // Driver expecting only attribute type, passing mbuff as data with
241 // length 0 to avoid undefined state
242 result
= request
.put(ENHANCE_LOGGER_ATTRIBUTE_DRIVER_VER
, mBuff
, 0);
244 if (result
!= WIFI_SUCCESS
) {
245 ALOGE("Failed to put get drv version request; result = %d", result
);
248 request
.attr_end(data
);
254 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_RING_DATA
);
255 if (result
!= WIFI_SUCCESS
) {
256 ALOGE("Failed to create get ring data request; result = %d", result
);
260 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
261 result
= request
.put_string(ENHANCE_LOGGER_ATTRIBUTE_RING_NAME
, mRingName
);
262 if (result
!= WIFI_SUCCESS
) {
263 ALOGE("Failed to put ring data request; result = %d", result
);
266 request
.attr_end(data
);
270 case GET_RING_STATUS
:
272 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_RING_STATUS
);
273 if (result
!= WIFI_SUCCESS
) {
274 ALOGE("Failed to create get ring status request; result = %d", result
);
282 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_FEATURE
);
283 if (result
!= WIFI_SUCCESS
) {
284 ALOGE("Failed to create get feature request; result = %d", result
);
291 result
= createRingRequest(request
);
295 ALOGE("Unknown Debug command");
296 result
= WIFI_ERROR_UNKNOWN
;
302 // ALOGD("Start debug command");
303 WifiRequest
request(familyId(), ifaceId());
304 int result
= createRequest(request
);
305 if (result
!= WIFI_SUCCESS
) {
306 ALOGE("Failed to create debug request; result = %d", result
);
310 result
= requestResponse(request
);
311 if (result
!= WIFI_SUCCESS
) {
312 ALOGE("Failed to register debug response; result = %d", result
);
317 virtual int handleResponse(WifiEvent
& reply
) {
318 ALOGD("In DebugCommand::handleResponse");
320 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
321 ALOGD("Ignoring reply with cmd = %d", reply
.get_cmd());
329 void *data
= reply
.get_vendor_data();
330 int len
= reply
.get_vendor_data_len();
332 ALOGD("len = %d, expected len = %d", len
, *mBuffSize
);
333 memcpy(mBuff
, data
, min(len
, *mBuffSize
));
334 if (*mBuffSize
< len
)
344 case GET_RING_STATUS
:
346 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
347 int len
= reply
.get_vendor_data_len();
348 wifi_ring_buffer_status
*status(mStatus
);
350 if (vendor_data
== NULL
|| len
== 0) {
351 ALOGE("No Debug data found");
355 nl_iterator
it(vendor_data
);
356 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_NUM
) {
357 unsigned int num_rings
= it
.get_u32();
358 if (*mNumRings
< num_rings
) {
359 ALOGE("Not enough status buffers provided, available: %d required: %d",
360 *mNumRings
, num_rings
);
362 *mNumRings
= num_rings
;
365 ALOGE("Unknown attribute: %d expecting %d",
366 it
.get_type(), ENHANCE_LOGGER_ATTRIBUTE_RING_NUM
);
371 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_STATUS
) {
372 memcpy(status
, it
.get_data(), sizeof(wifi_ring_buffer_status
) * (*mNumRings
));
374 ALOGW("Ignoring invalid attribute type = %d, size = %d",
375 it
.get_type(), it
.get_len());
382 void *data
= reply
.get_vendor_data();
384 ALOGD("len = %d, expected len = %lu", reply
.get_vendor_data_len(), (unsigned long)sizeof(unsigned int));
385 memcpy(mSupport
, data
, sizeof(unsigned int));
390 ALOGW("Unknown Debug command");
395 virtual int handleEvent(WifiEvent
& event
) {
401 /* API to get supportable feature */
402 wifi_error
wifi_get_logger_supported_feature_set(wifi_interface_handle iface
,
403 unsigned int *support
)
406 DebugCommand
*cmd
= new DebugCommand(iface
, support
, GET_FEATURE
);
407 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
408 wifi_error result
= (wifi_error
)cmd
->start();
412 ALOGE("Get support buffer NULL");
413 return WIFI_ERROR_INVALID_ARGS
;
417 /* API to get the status of all ring buffers supported by driver */
418 wifi_error
wifi_get_ring_buffers_status(wifi_interface_handle iface
,
419 u32
*num_rings
, wifi_ring_buffer_status
*status
)
421 if (status
&& num_rings
) {
422 DebugCommand
*cmd
= new DebugCommand(iface
, num_rings
, status
, GET_RING_STATUS
);
423 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
424 wifi_error result
= (wifi_error
)cmd
->start();
428 ALOGE("Ring status buffer NULL");
429 return WIFI_ERROR_INVALID_ARGS
;
433 /* API to collect driver records */
434 wifi_error
wifi_get_ring_data(wifi_interface_handle iface
, char *ring_name
)
436 DebugCommand
*cmd
= new DebugCommand(iface
, ring_name
, GET_RING_DATA
);
437 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
438 wifi_error result
= (wifi_error
)cmd
->start();
443 wifi_error
wifi_start_logging(wifi_interface_handle iface
, u32 verbose_level
,
444 u32 flags
, u32 max_interval_sec
, u32 min_data_size
, char *ring_name
)
447 DebugCommand
*cmd
= new DebugCommand(iface
, verbose_level
, flags
, max_interval_sec
,
448 min_data_size
, ring_name
, START_RING_LOG
);
449 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
450 wifi_error result
= (wifi_error
)cmd
->start();
454 ALOGE("Ring name NULL");
455 return WIFI_ERROR_INVALID_ARGS
;
459 /* API to collect a firmware version string */
460 wifi_error
wifi_get_firmware_version(wifi_interface_handle iface
, char *buffer
,
463 if (buffer
&& (buffer_size
> 0)) {
464 DebugCommand
*cmd
= new DebugCommand(iface
, buffer
, &buffer_size
, GET_FW_VER
);
465 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
466 wifi_error result
= (wifi_error
)cmd
->start();
470 ALOGE("FW version buffer NULL");
471 return WIFI_ERROR_INVALID_ARGS
;
475 /* API to collect a driver version string */
476 wifi_error
wifi_get_driver_version(wifi_interface_handle iface
, char *buffer
, int buffer_size
)
478 if (buffer
&& (buffer_size
> 0)) {
479 DebugCommand
*cmd
= new DebugCommand(iface
, buffer
, &buffer_size
, GET_DRV_VER
);
480 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
481 wifi_error result
= (wifi_error
)cmd
->start();
485 ALOGE("Driver version buffer NULL");
486 return WIFI_ERROR_INVALID_ARGS
;
491 ///////////////////////////////////////////////////////////////////////////////
492 class SetLogHandler
: public WifiCommand
494 wifi_ring_buffer_data_handler mHandler
;
497 SetLogHandler(wifi_interface_handle iface
, int id
, wifi_ring_buffer_data_handler handler
)
498 : WifiCommand(iface
, id
), mHandler(handler
)
502 ALOGV("Register loghandler");
503 registerVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_RING_EVENT
);
507 virtual int cancel() {
508 /* Send a command to driver to stop generating logging events */
509 ALOGV("Clear loghandler");
511 /* unregister event handler */
512 unregisterVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_RING_EVENT
);
514 WifiRequest
request(familyId(), ifaceId());
515 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_RESET_LOGGING
);
516 if (result
!= WIFI_SUCCESS
) {
517 ALOGE("failed to create reset request; result = %d", result
);
521 result
= requestResponse(request
);
522 if (result
!= WIFI_SUCCESS
) {
523 ALOGE("failed to request reset; result = %d", result
);
527 ALOGD("Success to clear loghandler");
531 virtual int handleEvent(WifiEvent
& event
) {
535 // ALOGD("In SetLogHandler::handleEvent");
536 nlattr
*vendor_data
= event
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
537 int len
= event
.get_vendor_data_len();
538 int event_id
= event
.get_vendor_subcmd();
539 // ALOGI("Got Logger event: %d", event_id);
541 if (vendor_data
== NULL
|| len
== 0) {
542 ALOGE("No Debug data found");
546 if(event_id
== ENHANCE_LOGGER_RING_EVENT
) {
547 wifi_ring_buffer_status status
;
548 memset(&status
, 0, sizeof(status
));
550 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
551 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_STATUS
) {
552 memcpy(&status
, it
.get_data(), sizeof(status
));
553 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_DATA
) {
554 buffer_size
= it
.get_len();
555 buffer
= (char *)it
.get_data();
557 ALOGW("Ignoring invalid attribute type = %d, size = %d",
558 it
.get_type(), it
.get_len());
562 // ALOGI("Retrieved Debug data");
563 if (mHandler
.on_ring_buffer_data
) {
564 (*mHandler
.on_ring_buffer_data
)((char *)status
.name
, buffer
, buffer_size
,
568 ALOGE("Unknown Event");
575 wifi_error
wifi_set_log_handler(wifi_request_id id
, wifi_interface_handle iface
,
576 wifi_ring_buffer_data_handler handler
)
578 wifi_handle handle
= getWifiHandle(iface
);
579 ALOGV("Loghandler start, handle = %p", handle
);
581 SetLogHandler
*cmd
= new SetLogHandler(iface
, id
, handler
);
582 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
583 wifi_error result
= wifi_register_cmd(handle
, id
, cmd
);
584 if (result
!= WIFI_SUCCESS
) {
588 result
= (wifi_error
)cmd
->start();
589 if (result
!= WIFI_SUCCESS
) {
590 wifi_unregister_cmd(handle
, id
);
597 wifi_error
wifi_reset_log_handler(wifi_request_id id
, wifi_interface_handle iface
)
599 wifi_handle handle
= getWifiHandle(iface
);
600 ALOGV("Loghandler reset, wifi_request_id = %d, handle = %p", id
, handle
);
603 wifi_ring_buffer_data_handler handler
;
604 memset(&handler
, 0, sizeof(handler
));
606 SetLogHandler
*cmd
= new SetLogHandler(iface
, id
, handler
);
607 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
613 return wifi_cancel_cmd(id
, iface
);
616 ///////////////////////////////////////////////////////////////////////////////
617 class SetAlertHandler
: public WifiCommand
619 wifi_alert_handler mHandler
;
625 SetAlertHandler(wifi_interface_handle iface
, int id
, wifi_alert_handler handler
)
626 : WifiCommand(iface
, id
), mHandler(handler
), mBuffSize(0), mBuff(NULL
),
631 ALOGV("Start Alerting");
632 registerVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
636 virtual int cancel() {
637 ALOGV("Clear alerthandler");
639 /* unregister alert handler */
640 unregisterVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
641 wifi_unregister_cmd(wifiHandle(), id());
642 ALOGD("Success to clear alerthandler");
646 virtual int handleResponse(WifiEvent
& reply
) {
647 ALOGD("In SetAlertHandler::handleResponse");
649 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
650 ALOGD("Ignoring reply with cmd = %d", reply
.get_cmd());
654 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
655 int len
= reply
.get_vendor_data_len();
657 ALOGD("len = %d", len
);
658 if (vendor_data
== NULL
|| len
== 0) {
659 ALOGE("no vendor data in memory dump response; ignoring it");
663 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
664 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
) {
665 ALOGI("Initiating alert callback");
666 if (mHandler
.on_alert
) {
667 (*mHandler
.on_alert
)(id(), mBuff
, mBuffSize
, mErrCode
);
678 virtual int handleEvent(WifiEvent
& event
) {
683 nlattr
*vendor_data
= event
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
684 int len
= event
.get_vendor_data_len();
685 int event_id
= event
.get_vendor_subcmd();
686 ALOGI("Got event: %d", event_id
);
688 if (vendor_data
== NULL
|| len
== 0) {
689 ALOGE("No Debug data found");
693 if (event_id
== ENHANCE_LOGGER_MEM_DUMP_EVENT
) {
694 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
695 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
) {
696 mBuffSize
= it
.get_u32();
697 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_DATA
) {
698 buffer_size
= it
.get_len();
699 buffer
= (char *)it
.get_data();
701 } else if (it.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_ERR_CODE) {
702 mErrCode = it.get_u32();
705 ALOGW("Ignoring invalid attribute type = %d, size = %d",
706 it
.get_type(), it
.get_len());
710 ALOGD("dump size: %d meta data size: %d", mBuffSize
, buffer_size
);
711 if (mBuff
) free(mBuff
);
712 mBuff
= (char *)malloc(mBuffSize
+ buffer_size
);
714 ALOGE("Buffer allocation failed");
717 memcpy(mBuff
, buffer
, buffer_size
);
719 WifiRequest
request(familyId(), ifaceId());
720 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
721 if (result
!= WIFI_SUCCESS
) {
722 ALOGE("Failed to create get memory dump request; result = %d", result
);
726 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
727 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
, mBuffSize
);
728 if (result
!= WIFI_SUCCESS
) {
729 ALOGE("Failed to put get memory dump request; result = %d", result
);
733 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
,
734 (uint64_t)(mBuff
+buffer_size
));
735 if (result
!= WIFI_SUCCESS
) {
736 ALOGE("Failed to put get memory dump request; result = %d", result
);
740 request
.attr_end(data
);
741 mBuffSize
+= buffer_size
;
743 result
= requestResponse(request
);
745 if (result
!= WIFI_SUCCESS
) {
746 ALOGE("Failed to register get momory dump response; result = %d", result
);
749 ALOGE("dump event missing dump length attribute");
757 wifi_error
wifi_set_alert_handler(wifi_request_id id
, wifi_interface_handle iface
,
758 wifi_alert_handler handler
)
760 wifi_handle handle
= getWifiHandle(iface
);
761 ALOGV("Alerthandler start, handle = %p", handle
);
763 SetAlertHandler
*cmd
= new SetAlertHandler(iface
, id
, handler
);
764 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
765 wifi_error result
= wifi_register_cmd(handle
, id
, cmd
);
766 if (result
!= WIFI_SUCCESS
) {
770 result
= (wifi_error
)cmd
->start();
771 if (result
!= WIFI_SUCCESS
) {
772 wifi_unregister_cmd(handle
, id
);
779 wifi_error
wifi_reset_alert_handler(wifi_request_id id
, wifi_interface_handle iface
)
781 wifi_handle handle
= getWifiHandle(iface
);
782 ALOGV("Alerthandler reset, wifi_request_id = %d, handle = %p", id
, handle
);
785 wifi_alert_handler handler
;
786 memset(&handler
, 0, sizeof(handler
));
788 SetAlertHandler
*cmd
= new SetAlertHandler(iface
, id
, handler
);
789 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
795 return wifi_cancel_cmd(id
, iface
);
799 class PacketFateCommand
: public WifiCommand
801 void *mReportBufs
= NULL
;
802 size_t mNoReqFates
= 0;
803 size_t *mNoProvidedFates
= NULL
;
804 PktFateReqType mReqType
;
807 PacketFateCommand(wifi_interface_handle handle
)
808 : WifiCommand(handle
, 0), mReqType(PACKET_MONITOR_START
)
811 PacketFateCommand(wifi_interface_handle handle
, wifi_tx_report
*tx_report_bufs
,
812 size_t n_requested_fates
, size_t *n_provided_fates
)
813 : WifiCommand(handle
, 0), mReportBufs(tx_report_bufs
),
814 mNoReqFates(n_requested_fates
), mNoProvidedFates(n_provided_fates
),
815 mReqType(TX_PACKET_FATE
)
818 PacketFateCommand(wifi_interface_handle handle
, wifi_rx_report
*rx_report_bufs
,
819 size_t n_requested_fates
, size_t *n_provided_fates
)
820 : WifiCommand(handle
, 0), mReportBufs(rx_report_bufs
),
821 mNoReqFates(n_requested_fates
), mNoProvidedFates(n_provided_fates
),
822 mReqType(RX_PACKET_FATE
)
825 int createRequest(WifiRequest
& request
) {
826 if (mReqType
== TX_PACKET_FATE
) {
827 ALOGD("%s Get Tx packet fate request\n", __FUNCTION__
);
828 return createTxPktFateRequest(request
);
829 } else if (mReqType
== RX_PACKET_FATE
) {
830 ALOGD("%s Get Rx packet fate request\n", __FUNCTION__
);
831 return createRxPktFateRequest(request
);
832 } else if (mReqType
== PACKET_MONITOR_START
) {
833 ALOGD("%s Monitor packet fate request\n", __FUNCTION__
);
834 return createMonitorPktFateRequest(request
);
836 ALOGE("%s Unknown packet fate request\n", __FUNCTION__
);
837 return WIFI_ERROR_NOT_SUPPORTED
;
842 int createMonitorPktFateRequest(WifiRequest
& request
) {
843 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_START_PKT_FATE_MONITORING
);
848 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
849 request
.attr_end(data
);
853 int createTxPktFateRequest(WifiRequest
& request
) {
854 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_TX_PKT_FATES
);
859 memset(mReportBufs
, 0, (mNoReqFates
* sizeof(wifi_tx_report
)));
860 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
861 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
, mNoReqFates
);
865 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA
, (uint64_t)mReportBufs
);
869 request
.attr_end(data
);
873 int createRxPktFateRequest(WifiRequest
& request
) {
874 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_RX_PKT_FATES
);
879 memset(mReportBufs
, 0, (mNoReqFates
* sizeof(wifi_rx_report
)));
880 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
881 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
, mNoReqFates
);
885 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA
, (uint64_t)mReportBufs
);
889 request
.attr_end(data
);
894 ALOGD("Start get packet fate command\n");
895 WifiRequest
request(familyId(), ifaceId());
897 int result
= createRequest(request
);
899 ALOGE("Failed to create get pkt fate request; result = %d\n", result
);
903 result
= requestResponse(request
);
904 if (result
!= WIFI_SUCCESS
) {
905 ALOGE("Failed to register get pkt fate response; result = %d\n", result
);
910 int handleResponse(WifiEvent
& reply
) {
911 ALOGD("In GetPktFateCommand::handleResponse\n");
913 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
914 ALOGI("Ignoring reply with cmd = %d", reply
.get_cmd());
918 int id
= reply
.get_vendor_id();
919 int subcmd
= reply
.get_vendor_subcmd();
920 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
921 int len
= reply
.get_vendor_data_len();
923 ALOGI("Id = %0x, subcmd = %d, len = %d", id
, subcmd
, len
);
925 if (mReqType
== TX_PACKET_FATE
) {
926 ALOGI("Response recieved for get TX pkt fate command\n");
927 } else if (mReqType
== RX_PACKET_FATE
) {
928 ALOGI("Response recieved for get RX pkt fate command\n");
929 } else if (mReqType
== PACKET_MONITOR_START
) {
930 ALOGI("Response recieved for monitor pkt fate command\n");
933 ALOGE("Response recieved for unknown pkt fate command\n");
937 if (vendor_data
== NULL
|| len
== 0) {
938 ALOGE("no vendor data in GetPktFateCommand response; ignoring it\n");
942 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
943 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
) {
944 *mNoProvidedFates
= it
.get_u32();
945 ALOGI("No: of pkt fates provided is %zu\n", *mNoProvidedFates
);
947 ALOGE("Ignoring invalid attribute type = %d, size = %d\n",
948 it
.get_type(), it
.get_len());
955 int handleEvent(WifiEvent
& event
) {
956 /* NO events to handle here! */
961 wifi_error
wifi_start_pkt_fate_monitoring(wifi_interface_handle handle
)
963 PacketFateCommand
*cmd
= new PacketFateCommand(handle
);
964 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
965 wifi_error result
= (wifi_error
)cmd
->start();
970 wifi_error
wifi_get_tx_pkt_fates(wifi_interface_handle handle
,
971 wifi_tx_report
*tx_report_bufs
, size_t n_requested_fates
,
972 size_t *n_provided_fates
)
974 PacketFateCommand
*cmd
= new PacketFateCommand(handle
, tx_report_bufs
,
975 n_requested_fates
, n_provided_fates
);
976 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
977 wifi_error result
= (wifi_error
)cmd
->start();
979 memset(tx_report_bufs
, 0, (n_requested_fates
* sizeof(wifi_tx_report
)));
983 wifi_error
wifi_get_rx_pkt_fates(wifi_interface_handle handle
,
984 wifi_rx_report
*rx_report_bufs
, size_t n_requested_fates
,
985 size_t *n_provided_fates
)
987 PacketFateCommand
*cmd
= new PacketFateCommand(handle
, rx_report_bufs
,
988 n_requested_fates
, n_provided_fates
);
989 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
990 wifi_error result
= (wifi_error
)cmd
->start();
992 memset(rx_report_bufs
, 0, (n_requested_fates
* sizeof(wifi_rx_report
)));
996 class MemoryDumpCommand
: public WifiCommand
998 wifi_firmware_memory_dump_handler mHandler
;
999 wifi_driver_memory_dump_callbacks mcallback
;
1005 MemoryDumpCommand(wifi_interface_handle iface
, wifi_firmware_memory_dump_handler handler
, GetCmdType cmdtype
)
1006 : WifiCommand(iface
, 0), mHandler(handler
), mBuffSize(0), mBuff(NULL
), mType(cmdtype
)
1008 memset(&mcallback
, 0, sizeof(wifi_driver_memory_dump_callbacks
));
1011 MemoryDumpCommand(wifi_interface_handle iface
, wifi_driver_memory_dump_callbacks callback
, GetCmdType cmdtype
)
1012 : WifiCommand(iface
, 0), mcallback(callback
), mBuffSize(0), mBuff(NULL
), mType(cmdtype
)
1014 memset(&mHandler
, 0, sizeof(wifi_firmware_memory_dump_handler
));
1017 int createRequest(WifiRequest
&request
) {
1023 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_TRIGGER_FW_MEM_DUMP
);
1024 if (result
!= WIFI_SUCCESS
) {
1025 ALOGE("Failed to create trigger fw memory dump request; result = %d", result
);
1030 case GET_DRIVER_DUMP
:
1032 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_TRIGGER_DRIVER_MEM_DUMP
);
1033 if (result
!= WIFI_SUCCESS
) {
1034 ALOGE("Failed to create trigger driver memory dump request; result = %d", result
);
1040 ALOGE("Unknown Debug command");
1041 result
= WIFI_ERROR_UNKNOWN
;
1046 ALOGD("Start memory dump command");
1047 WifiRequest
request(familyId(), ifaceId());
1049 int result
= createRequest(request
);
1050 if (result
!= WIFI_SUCCESS
) {
1051 ALOGE("Failed to create trigger memory dump request; result = %d", result
);
1055 result
= requestResponse(request
);
1056 if (result
!= WIFI_SUCCESS
) {
1057 ALOGE("Failed to register trigger memory dump response; result = %d", result
);
1062 virtual int handleResponse(WifiEvent
& reply
) {
1063 ALOGD("In MemoryDumpCommand::handleResponse");
1065 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
1066 ALOGD("Ignoring reply with cmd = %d", reply
.get_cmd());
1070 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
1071 int len
= reply
.get_vendor_data_len();
1073 ALOGD("len = %d", len
);
1074 if (vendor_data
== NULL
|| len
== 0) {
1075 ALOGE("no vendor data in memory dump response; ignoring it");
1080 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
1081 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
) {
1082 mBuffSize
= it
.get_u32();
1085 mBuff
= (char *)malloc(mBuffSize
);
1087 ALOGE("Buffer allocation failed");
1090 WifiRequest
request(familyId(), ifaceId());
1091 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_FW_MEM_DUMP
);
1092 if (result
!= WIFI_SUCCESS
) {
1093 ALOGE("Failed to create get fw memory dump request; result = %d", result
);
1097 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1098 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
, mBuffSize
);
1099 if (result
!= WIFI_SUCCESS
) {
1100 ALOGE("Failed to put get fw memory dump request; result = %d", result
);
1103 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
, (uint64_t)mBuff
);
1104 if (result
!= WIFI_SUCCESS
) {
1105 ALOGE("Failed to put get fw memory dump request; result = %d", result
);
1108 request
.attr_end(data
);
1109 result
= requestResponse(request
);
1110 if (result
!= WIFI_SUCCESS
) {
1111 ALOGE("Failed to register get fw momory dump response; result = %d", result
);
1113 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
) {
1114 ALOGI("Initiating memory dump callback");
1115 if (mHandler
.on_firmware_memory_dump
) {
1116 (*mHandler
.on_firmware_memory_dump
)(mBuff
, mBuffSize
);
1123 ALOGW("Ignoring invalid attribute type = %d, size = %d",
1124 it
.get_type(), it
.get_len());
1127 case GET_DRIVER_DUMP
:
1128 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
1129 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_LEN
) {
1130 mBuffSize
= it
.get_u32();
1133 mBuff
= (char *)malloc(mBuffSize
);
1135 ALOGE("Buffer allocation failed");
1138 WifiRequest
request(familyId(), ifaceId());
1139 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_DRIVER_MEM_DUMP
);
1140 if (result
!= WIFI_SUCCESS
) {
1141 ALOGE("Failed to create get driver memory dump request; result = %d", result
);
1145 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1146 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_LEN
, mBuffSize
);
1147 if (result
!= WIFI_SUCCESS
) {
1148 ALOGE("Failed to put get driver memory dump request; result = %d", result
);
1151 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA
, (uint64_t)mBuff
);
1152 if (result
!= WIFI_SUCCESS
) {
1153 ALOGE("Failed to put get driver memory dump request; result = %d", result
);
1156 request
.attr_end(data
);
1157 result
= requestResponse(request
);
1158 if (result
!= WIFI_SUCCESS
) {
1159 ALOGE("Failed to register get driver momory dump response; result = %d", result
);
1161 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA
) {
1162 ALOGI("Initiating memory dump callback");
1163 if (mcallback
.on_driver_memory_dump
) {
1164 (*mcallback
.on_driver_memory_dump
)(mBuff
, mBuffSize
);
1171 ALOGW("Ignoring invalid attribute type = %d, size = %d",
1172 it
.get_type(), it
.get_len());
1178 case GET_RING_STATUS
:
1180 case START_RING_LOG
:
1183 ALOGW("Ignoring GetCmdType %d \n", mType
);
1189 virtual int handleEvent(WifiEvent
& event
) {
1195 /* API to collect a firmware memory dump for a given iface */
1196 wifi_error
wifi_get_firmware_memory_dump( wifi_interface_handle iface
,
1197 wifi_firmware_memory_dump_handler handler
)
1199 MemoryDumpCommand
*cmd
= new MemoryDumpCommand(iface
, handler
, GET_FW_DUMP
);
1200 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1201 wifi_error result
= (wifi_error
)cmd
->start();
1206 wifi_error
wifi_get_driver_memory_dump(wifi_interface_handle iface
,
1207 wifi_driver_memory_dump_callbacks callbacks
)
1209 MemoryDumpCommand
*cmd
= new MemoryDumpCommand(iface
, callbacks
, GET_DRIVER_DUMP
);
1210 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1211 wifi_error result
= (wifi_error
)cmd
->start();
1215 class WifiLoggerCommand
: public WifiCommand
1217 WLAN_DRIVER_WAKE_REASON_CNT
*mGetWakeStats
;
1220 WifiLoggerCommand(wifi_interface_handle handle
, WLAN_DRIVER_WAKE_REASON_CNT
*wifi_wake_reason_cnt
)
1221 : WifiCommand(handle
, 0), mGetWakeStats(wifi_wake_reason_cnt
)
1224 int createRequest(WifiRequest
& request
) {
1225 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_WAKE_REASON_STATS
);
1230 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1232 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_SZ
, mGetWakeStats
->cmd_event_wake_cnt_sz
);
1233 if (result
!= WIFI_SUCCESS
) {
1234 ALOGE("Failed to put wake_cnt_sz; result = %d", result
);
1237 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_SZ
, mGetWakeStats
->driver_fw_local_wake_cnt_sz
);
1238 if (result
!= WIFI_SUCCESS
) {
1239 ALOGE("Failed to put driver_fw_local_wake_cnt; result = %d", result
);
1242 request
.attr_end(data
);
1247 ALOGD("Start get wake reason stats command\n");
1248 WifiRequest
request(familyId(), ifaceId());
1249 int result
= createRequest(request
);
1251 ALOGE("Failed to create get wake reason stats request; result = %d\n", result
);
1254 result
= requestResponse(request
);
1255 if (result
!= WIFI_SUCCESS
) {
1256 ALOGE("Failed to register get wake reason stats response; result = %d\n", result
);
1261 int handleResponse(WifiEvent
& reply
) {
1263 ALOGD("In WifiLoggerCommand::handleResponse\n");
1265 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
1266 ALOGI("Ignoring reply with cmd = %d", reply
.get_cmd());
1269 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
1270 len
= reply
.get_vendor_data_len();
1271 if (vendor_data
== NULL
|| len
== 0) {
1272 ALOGE("No Debug data found");
1275 nl_iterator
it(vendor_data
);
1277 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_CMD_EVENT_WAKE
) {
1278 ALOGE("TOTAL_CMD_EVENT_WAKE not found %d", it
.get_type());
1282 mGetWakeStats
->total_cmd_event_wake
= it
.get_u32();
1285 if(mGetWakeStats
->total_cmd_event_wake
&& mGetWakeStats
->cmd_event_wake_cnt
) {
1286 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_PTR
) {
1287 ALOGE("CMD_EVENT_WAKE_CNT_PTR not found %d", it
.get_type());
1292 mGetWakeStats
->cmd_event_wake_cnt_used
= (len
< mGetWakeStats
->cmd_event_wake_cnt_sz
) ? len
: mGetWakeStats
->cmd_event_wake_cnt_sz
;
1293 memcpy(mGetWakeStats
->cmd_event_wake_cnt
, it
.get_data(), mGetWakeStats
->cmd_event_wake_cnt_used
* sizeof(int));
1295 mGetWakeStats
->cmd_event_wake_cnt_used
= 0;
1300 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_DRIVER_FW_LOCAL_WAKE
) {
1301 ALOGE("TOTAL_DRIVER_FW_LOCAL_WAKE not found %d", it
.get_type());
1305 mGetWakeStats
->total_driver_fw_local_wake
= it
.get_u32();
1308 if(mGetWakeStats
->total_driver_fw_local_wake
&& mGetWakeStats
->driver_fw_local_wake_cnt
) {
1309 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_PTR
) {
1310 ALOGE("DRIVER_FW_LOCAL_WAKE_CNT_PTR not found %d", it
.get_type());
1315 mGetWakeStats
->driver_fw_local_wake_cnt_used
= (len
< mGetWakeStats
->driver_fw_local_wake_cnt_sz
) ? len
: mGetWakeStats
->driver_fw_local_wake_cnt_sz
;
1316 memcpy(mGetWakeStats
->driver_fw_local_wake_cnt
, it
.get_data(), mGetWakeStats
->driver_fw_local_wake_cnt_used
* sizeof(int));
1318 mGetWakeStats
->driver_fw_local_wake_cnt_used
= 0;
1323 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_RX_DATA_WAKE
) {
1324 ALOGE("TOTAL_RX_DATA_WAKE not found %d", it
.get_type());
1328 mGetWakeStats
->total_rx_data_wake
= it
.get_u32();
1331 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_UNICAST_CNT
) {
1332 ALOGE("RX_UNICAST_CNT not found %d", it
.get_type());
1336 mGetWakeStats
->rx_wake_details
.rx_unicast_cnt
= it
.get_u32();
1339 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_MULTICAST_CNT
) {
1340 ALOGE("RX_MULTICAST_CNT not found %d", it
.get_type());
1344 mGetWakeStats
->rx_wake_details
.rx_multicast_cnt
= it
.get_u32();
1347 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_BROADCAST_CNT
) {
1348 ALOGE("RX_BROADCAST_CNT not found %d", it
.get_type());
1352 mGetWakeStats
->rx_wake_details
.rx_broadcast_cnt
= it
.get_u32();
1355 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP_PKT
) {
1356 ALOGE("ICMP_PKT not found %d", it
.get_type());
1360 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp_pkt
= it
.get_u32();
1363 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_PKT
) {
1364 ALOGE("ICMP6_PKT not found %d", it
.get_type());
1368 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_pkt
= it
.get_u32();
1371 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RA
) {
1372 ALOGE("ICMP6_RA not found %d", it
.get_type());
1376 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_ra
= it
.get_u32();
1379 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NA
) {
1380 ALOGE("ICMP6_NA not found %d", it
.get_type());
1384 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_na
= it
.get_u32();
1387 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NS
) {
1388 ALOGE("ICMP6_NS not found %d", it
.get_type());
1392 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_ns
= it
.get_u32();
1395 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP4_RX_MULTICAST_CNT
) {
1396 ALOGE("ICMP4_RX_MULTICAST_CNT not found %d", it
.get_type());
1400 mGetWakeStats
->rx_multicast_wake_pkt_info
.ipv4_rx_multicast_addr_cnt
= it
.get_u32();
1403 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RX_MULTICAST_CNT
) {
1404 ALOGE("ICMP6_RX_MULTICAST_CNT not found %d", it
.get_type());
1408 mGetWakeStats
->rx_multicast_wake_pkt_info
.ipv6_rx_multicast_addr_cnt
= it
.get_u32();
1411 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_OTHER_RX_MULTICAST_CNT
) {
1412 ALOGE("OTHER_RX_MULTICAST_CNT not found %d", it
.get_type());
1416 mGetWakeStats
->rx_multicast_wake_pkt_info
.other_rx_multicast_addr_cnt
= it
.get_u32();
1421 int handleEvent(WifiEvent
& event
) {
1422 /* NO events to handle here! */
1427 /* Function to get wake lock stats */
1428 wifi_error
wifi_get_wake_reason_stats(wifi_interface_handle iface
,
1429 WLAN_DRIVER_WAKE_REASON_CNT
*wifi_wake_reason_cnt
)
1431 if(wifi_wake_reason_cnt
) {
1432 WifiLoggerCommand
*cmd
= new WifiLoggerCommand(iface
,wifi_wake_reason_cnt
);
1433 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1434 wifi_error result
= (wifi_error
)cmd
->start();
1438 ALOGE("Reason cnt NULL");
1439 return WIFI_ERROR_INVALID_ARGS
;