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();
383 int len
= reply
.get_vendor_data_len();
385 ALOGD("len = %d, expected len = %d", len
, sizeof(unsigned int));
386 memcpy(mSupport
, data
, sizeof(unsigned int));
391 ALOGW("Unknown Debug command");
396 virtual int handleEvent(WifiEvent
& event
) {
402 /* API to get supportable feature */
403 wifi_error
wifi_get_logger_supported_feature_set(wifi_interface_handle iface
,
404 unsigned int *support
)
407 DebugCommand
*cmd
= new DebugCommand(iface
, support
, GET_FEATURE
);
408 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
409 wifi_error result
= (wifi_error
)cmd
->start();
413 ALOGE("Get support buffer NULL");
414 return WIFI_ERROR_INVALID_ARGS
;
418 /* API to get the status of all ring buffers supported by driver */
419 wifi_error
wifi_get_ring_buffers_status(wifi_interface_handle iface
,
420 u32
*num_rings
, wifi_ring_buffer_status
*status
)
422 if (status
&& num_rings
) {
423 DebugCommand
*cmd
= new DebugCommand(iface
, num_rings
, status
, GET_RING_STATUS
);
424 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
425 wifi_error result
= (wifi_error
)cmd
->start();
429 ALOGE("Ring status buffer NULL");
430 return WIFI_ERROR_INVALID_ARGS
;
434 /* API to collect driver records */
435 wifi_error
wifi_get_ring_data(wifi_interface_handle iface
, char *ring_name
)
437 DebugCommand
*cmd
= new DebugCommand(iface
, ring_name
, GET_RING_DATA
);
438 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
439 wifi_error result
= (wifi_error
)cmd
->start();
444 wifi_error
wifi_start_logging(wifi_interface_handle iface
, u32 verbose_level
,
445 u32 flags
, u32 max_interval_sec
, u32 min_data_size
, char *ring_name
)
448 DebugCommand
*cmd
= new DebugCommand(iface
, verbose_level
, flags
, max_interval_sec
,
449 min_data_size
, ring_name
, START_RING_LOG
);
450 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
451 wifi_error result
= (wifi_error
)cmd
->start();
455 ALOGE("Ring name NULL");
456 return WIFI_ERROR_INVALID_ARGS
;
460 /* API to collect a firmware version string */
461 wifi_error
wifi_get_firmware_version(wifi_interface_handle iface
, char *buffer
,
464 if (buffer
&& (buffer_size
> 0)) {
465 DebugCommand
*cmd
= new DebugCommand(iface
, buffer
, &buffer_size
, GET_FW_VER
);
466 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
467 wifi_error result
= (wifi_error
)cmd
->start();
471 ALOGE("FW version buffer NULL");
472 return WIFI_ERROR_INVALID_ARGS
;
476 /* API to collect a driver version string */
477 wifi_error
wifi_get_driver_version(wifi_interface_handle iface
, char *buffer
, int buffer_size
)
479 if (buffer
&& (buffer_size
> 0)) {
480 DebugCommand
*cmd
= new DebugCommand(iface
, buffer
, &buffer_size
, GET_DRV_VER
);
481 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
482 wifi_error result
= (wifi_error
)cmd
->start();
486 ALOGE("Driver version buffer NULL");
487 return WIFI_ERROR_INVALID_ARGS
;
492 ///////////////////////////////////////////////////////////////////////////////
493 class SetLogHandler
: public WifiCommand
495 wifi_ring_buffer_data_handler mHandler
;
498 SetLogHandler(wifi_interface_handle iface
, int id
, wifi_ring_buffer_data_handler handler
)
499 : WifiCommand(iface
, id
), mHandler(handler
)
503 ALOGV("Register loghandler");
504 registerVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_RING_EVENT
);
508 virtual int cancel() {
509 /* Send a command to driver to stop generating logging events */
510 ALOGV("Clear loghandler");
512 /* unregister event handler */
513 unregisterVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_RING_EVENT
);
515 WifiRequest
request(familyId(), ifaceId());
516 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_RESET_LOGGING
);
517 if (result
!= WIFI_SUCCESS
) {
518 ALOGE("failed to create reset request; result = %d", result
);
522 result
= requestResponse(request
);
523 if (result
!= WIFI_SUCCESS
) {
524 ALOGE("failed to request reset; result = %d", result
);
528 ALOGD("Success to clear loghandler");
532 virtual int handleEvent(WifiEvent
& event
) {
536 // ALOGD("In SetLogHandler::handleEvent");
537 nlattr
*vendor_data
= event
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
538 int len
= event
.get_vendor_data_len();
539 int event_id
= event
.get_vendor_subcmd();
540 // ALOGI("Got Logger event: %d", event_id);
542 if (vendor_data
== NULL
|| len
== 0) {
543 ALOGE("No Debug data found");
547 if(event_id
== ENHANCE_LOGGER_RING_EVENT
) {
548 wifi_ring_buffer_status status
;
549 memset(&status
, 0, sizeof(status
));
551 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
552 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_STATUS
) {
553 memcpy(&status
, it
.get_data(), sizeof(status
));
554 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_DATA
) {
555 buffer_size
= it
.get_len();
556 buffer
= (char *)it
.get_data();
558 ALOGW("Ignoring invalid attribute type = %d, size = %d",
559 it
.get_type(), it
.get_len());
563 // ALOGI("Retrieved Debug data");
564 if (mHandler
.on_ring_buffer_data
) {
565 (*mHandler
.on_ring_buffer_data
)((char *)status
.name
, buffer
, buffer_size
,
569 ALOGE("Unknown Event");
576 wifi_error
wifi_set_log_handler(wifi_request_id id
, wifi_interface_handle iface
,
577 wifi_ring_buffer_data_handler handler
)
579 wifi_handle handle
= getWifiHandle(iface
);
580 ALOGV("Loghandler start, handle = %p", handle
);
582 SetLogHandler
*cmd
= new SetLogHandler(iface
, id
, handler
);
583 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
584 wifi_error result
= wifi_register_cmd(handle
, id
, cmd
);
585 if (result
!= WIFI_SUCCESS
) {
589 result
= (wifi_error
)cmd
->start();
590 if (result
!= WIFI_SUCCESS
) {
591 wifi_unregister_cmd(handle
, id
);
598 wifi_error
wifi_reset_log_handler(wifi_request_id id
, wifi_interface_handle iface
)
600 wifi_handle handle
= getWifiHandle(iface
);
601 ALOGV("Loghandler reset, wifi_request_id = %d, handle = %p", id
, handle
);
604 wifi_ring_buffer_data_handler handler
;
605 memset(&handler
, 0, sizeof(handler
));
607 SetLogHandler
*cmd
= new SetLogHandler(iface
, id
, handler
);
608 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
614 return wifi_cancel_cmd(id
, iface
);
617 ///////////////////////////////////////////////////////////////////////////////
618 class SetAlertHandler
: public WifiCommand
620 wifi_alert_handler mHandler
;
626 SetAlertHandler(wifi_interface_handle iface
, int id
, wifi_alert_handler handler
)
627 : WifiCommand(iface
, id
), mHandler(handler
), mBuffSize(0), mBuff(NULL
),
632 ALOGV("Start Alerting");
633 registerVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
637 virtual int cancel() {
638 ALOGV("Clear alerthandler");
640 /* unregister alert handler */
641 unregisterVendorHandler(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
642 wifi_unregister_cmd(wifiHandle(), id());
643 ALOGD("Success to clear alerthandler");
647 virtual int handleResponse(WifiEvent
& reply
) {
648 ALOGD("In SetAlertHandler::handleResponse");
650 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
651 ALOGD("Ignoring reply with cmd = %d", reply
.get_cmd());
655 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
656 int len
= reply
.get_vendor_data_len();
658 ALOGD("len = %d", len
);
659 if (vendor_data
== NULL
|| len
== 0) {
660 ALOGE("no vendor data in memory dump response; ignoring it");
664 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
665 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
) {
666 ALOGI("Initiating alert callback");
667 if (mHandler
.on_alert
) {
668 (*mHandler
.on_alert
)(id(), mBuff
, mBuffSize
, mErrCode
);
679 virtual int handleEvent(WifiEvent
& event
) {
680 wifi_ring_buffer_id ring_id
;
685 nlattr
*vendor_data
= event
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
686 int len
= event
.get_vendor_data_len();
687 int event_id
= event
.get_vendor_subcmd();
688 ALOGI("Got event: %d", event_id
);
690 if (vendor_data
== NULL
|| len
== 0) {
691 ALOGE("No Debug data found");
695 if (event_id
== ENHANCE_LOGGER_MEM_DUMP_EVENT
) {
696 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
697 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
) {
698 mBuffSize
= it
.get_u32();
699 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_RING_DATA
) {
700 buffer_size
= it
.get_len();
701 buffer
= (char *)it
.get_data();
703 } else if (it.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_ERR_CODE) {
704 mErrCode = it.get_u32();
707 ALOGW("Ignoring invalid attribute type = %d, size = %d",
708 it
.get_type(), it
.get_len());
712 ALOGD("dump size: %d meta data size: %d", mBuffSize
, buffer_size
);
713 if (mBuff
) free(mBuff
);
714 mBuff
= (char *)malloc(mBuffSize
+ buffer_size
);
716 ALOGE("Buffer allocation failed");
719 memcpy(mBuff
, buffer
, buffer_size
);
721 WifiRequest
request(familyId(), ifaceId());
722 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_MEM_DUMP_EVENT
);
723 if (result
!= WIFI_SUCCESS
) {
724 ALOGE("Failed to create get memory dump request; result = %d", result
);
728 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
729 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
, mBuffSize
);
730 if (result
!= WIFI_SUCCESS
) {
731 ALOGE("Failed to put get memory dump request; result = %d", result
);
735 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
,
736 (uint64_t)(mBuff
+buffer_size
));
737 if (result
!= WIFI_SUCCESS
) {
738 ALOGE("Failed to put get memory dump request; result = %d", result
);
742 request
.attr_end(data
);
743 mBuffSize
+= buffer_size
;
745 result
= requestResponse(request
);
747 if (result
!= WIFI_SUCCESS
) {
748 ALOGE("Failed to register get momory dump response; result = %d", result
);
751 ALOGE("dump event missing dump length attribute");
759 wifi_error
wifi_set_alert_handler(wifi_request_id id
, wifi_interface_handle iface
,
760 wifi_alert_handler handler
)
762 wifi_handle handle
= getWifiHandle(iface
);
763 ALOGV("Alerthandler start, handle = %p", handle
);
765 SetAlertHandler
*cmd
= new SetAlertHandler(iface
, id
, handler
);
766 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
767 wifi_error result
= wifi_register_cmd(handle
, id
, cmd
);
768 if (result
!= WIFI_SUCCESS
) {
772 result
= (wifi_error
)cmd
->start();
773 if (result
!= WIFI_SUCCESS
) {
774 wifi_unregister_cmd(handle
, id
);
781 wifi_error
wifi_reset_alert_handler(wifi_request_id id
, wifi_interface_handle iface
)
783 wifi_handle handle
= getWifiHandle(iface
);
784 ALOGV("Alerthandler reset, wifi_request_id = %d, handle = %p", id
, handle
);
787 wifi_alert_handler handler
;
788 memset(&handler
, 0, sizeof(handler
));
790 SetAlertHandler
*cmd
= new SetAlertHandler(iface
, id
, handler
);
791 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
797 return wifi_cancel_cmd(id
, iface
);
801 class PacketFateCommand
: public WifiCommand
803 void *mReportBufs
= NULL
;
804 size_t mNoReqFates
= 0;
805 size_t *mNoProvidedFates
= NULL
;
806 PktFateReqType mReqType
;
809 PacketFateCommand(wifi_interface_handle handle
)
810 : WifiCommand(handle
, 0), mReqType(PACKET_MONITOR_START
)
813 PacketFateCommand(wifi_interface_handle handle
, wifi_tx_report
*tx_report_bufs
,
814 size_t n_requested_fates
, size_t *n_provided_fates
)
815 : WifiCommand(handle
, 0), mReportBufs(tx_report_bufs
),
816 mNoReqFates(n_requested_fates
), mNoProvidedFates(n_provided_fates
),
817 mReqType(TX_PACKET_FATE
)
820 PacketFateCommand(wifi_interface_handle handle
, wifi_rx_report
*rx_report_bufs
,
821 size_t n_requested_fates
, size_t *n_provided_fates
)
822 : WifiCommand(handle
, 0), mReportBufs(rx_report_bufs
),
823 mNoReqFates(n_requested_fates
), mNoProvidedFates(n_provided_fates
),
824 mReqType(RX_PACKET_FATE
)
827 int createRequest(WifiRequest
& request
) {
828 if (mReqType
== TX_PACKET_FATE
) {
829 ALOGD("%s Get Tx packet fate request\n", __FUNCTION__
);
830 return createTxPktFateRequest(request
);
831 } else if (mReqType
== RX_PACKET_FATE
) {
832 ALOGD("%s Get Rx packet fate request\n", __FUNCTION__
);
833 return createRxPktFateRequest(request
);
834 } else if (mReqType
== PACKET_MONITOR_START
) {
835 ALOGD("%s Monitor packet fate request\n", __FUNCTION__
);
836 return createMonitorPktFateRequest(request
);
838 ALOGE("%s Unknown packet fate request\n", __FUNCTION__
);
839 return WIFI_ERROR_NOT_SUPPORTED
;
844 int createMonitorPktFateRequest(WifiRequest
& request
) {
845 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_START_PKT_FATE_MONITORING
);
850 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
851 request
.attr_end(data
);
855 int createTxPktFateRequest(WifiRequest
& request
) {
856 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_TX_PKT_FATES
);
861 memset(mReportBufs
, 0, (mNoReqFates
* sizeof(wifi_tx_report
)));
862 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
863 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
, mNoReqFates
);
867 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA
, (uint64_t)mReportBufs
);
871 request
.attr_end(data
);
875 int createRxPktFateRequest(WifiRequest
& request
) {
876 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_RX_PKT_FATES
);
881 memset(mReportBufs
, 0, (mNoReqFates
* sizeof(wifi_rx_report
)));
882 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
883 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
, mNoReqFates
);
887 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA
, (uint64_t)mReportBufs
);
891 request
.attr_end(data
);
896 ALOGD("Start get packet fate command\n");
897 WifiRequest
request(familyId(), ifaceId());
899 int result
= createRequest(request
);
901 ALOGE("Failed to create get pkt fate request; result = %d\n", result
);
905 result
= requestResponse(request
);
906 if (result
!= WIFI_SUCCESS
) {
907 ALOGE("Failed to register get pkt fate response; result = %d\n", result
);
912 int handleResponse(WifiEvent
& reply
) {
913 ALOGD("In GetPktFateCommand::handleResponse\n");
915 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
916 ALOGI("Ignoring reply with cmd = %d", reply
.get_cmd());
920 int id
= reply
.get_vendor_id();
921 int subcmd
= reply
.get_vendor_subcmd();
922 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
923 int len
= reply
.get_vendor_data_len();
925 ALOGI("Id = %0x, subcmd = %d, len = %d", id
, subcmd
, len
);
927 if (mReqType
== TX_PACKET_FATE
) {
928 ALOGI("Response recieved for get TX pkt fate command\n");
929 } else if (mReqType
== RX_PACKET_FATE
) {
930 ALOGI("Response recieved for get RX pkt fate command\n");
931 } else if (mReqType
== PACKET_MONITOR_START
) {
932 ALOGI("Response recieved for monitor pkt fate command\n");
935 ALOGE("Response recieved for unknown pkt fate command\n");
939 if (vendor_data
== NULL
|| len
== 0) {
940 ALOGE("no vendor data in GetPktFateCommand response; ignoring it\n");
944 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
945 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM
) {
946 *mNoProvidedFates
= it
.get_u32();
947 ALOGI("No: of pkt fates provided is %d\n", *mNoProvidedFates
);
949 ALOGE("Ignoring invalid attribute type = %d, size = %d\n",
950 it
.get_type(), it
.get_len());
957 int handleEvent(WifiEvent
& event
) {
958 /* NO events to handle here! */
963 wifi_error
wifi_start_pkt_fate_monitoring(wifi_interface_handle handle
)
965 PacketFateCommand
*cmd
= new PacketFateCommand(handle
);
966 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
967 wifi_error result
= (wifi_error
)cmd
->start();
972 wifi_error
wifi_get_tx_pkt_fates(wifi_interface_handle handle
,
973 wifi_tx_report
*tx_report_bufs
, size_t n_requested_fates
,
974 size_t *n_provided_fates
)
976 PacketFateCommand
*cmd
= new PacketFateCommand(handle
, tx_report_bufs
,
977 n_requested_fates
, n_provided_fates
);
978 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
979 wifi_error result
= (wifi_error
)cmd
->start();
981 memset(tx_report_bufs
, 0, (n_requested_fates
* sizeof(wifi_tx_report
)));
985 wifi_error
wifi_get_rx_pkt_fates(wifi_interface_handle handle
,
986 wifi_rx_report
*rx_report_bufs
, size_t n_requested_fates
,
987 size_t *n_provided_fates
)
989 PacketFateCommand
*cmd
= new PacketFateCommand(handle
, rx_report_bufs
,
990 n_requested_fates
, n_provided_fates
);
991 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
992 wifi_error result
= (wifi_error
)cmd
->start();
994 memset(rx_report_bufs
, 0, (n_requested_fates
* sizeof(wifi_rx_report
)));
998 class MemoryDumpCommand
: public WifiCommand
1000 wifi_firmware_memory_dump_handler mHandler
;
1001 wifi_driver_memory_dump_callbacks mcallback
;
1007 MemoryDumpCommand(wifi_interface_handle iface
, wifi_firmware_memory_dump_handler handler
, GetCmdType cmdtype
)
1008 : WifiCommand(iface
, 0), mHandler(handler
), mBuffSize(0), mBuff(NULL
), mType(cmdtype
)
1010 memset(&mcallback
, 0, sizeof(wifi_driver_memory_dump_callbacks
));
1013 MemoryDumpCommand(wifi_interface_handle iface
, wifi_driver_memory_dump_callbacks callback
, GetCmdType cmdtype
)
1014 : WifiCommand(iface
, 0), mcallback(callback
), mBuffSize(0), mBuff(NULL
), mType(cmdtype
)
1016 memset(&mHandler
, 0, sizeof(wifi_firmware_memory_dump_handler
));
1019 int createRequest(WifiRequest
&request
) {
1025 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_TRIGGER_FW_MEM_DUMP
);
1026 if (result
!= WIFI_SUCCESS
) {
1027 ALOGE("Failed to create trigger fw memory dump request; result = %d", result
);
1032 case GET_DRIVER_DUMP
:
1034 result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_TRIGGER_DRIVER_MEM_DUMP
);
1035 if (result
!= WIFI_SUCCESS
) {
1036 ALOGE("Failed to create trigger driver memory dump request; result = %d", result
);
1042 ALOGE("Unknown Debug command");
1043 result
= WIFI_ERROR_UNKNOWN
;
1048 ALOGD("Start memory dump command");
1049 WifiRequest
request(familyId(), ifaceId());
1051 int result
= createRequest(request
);
1052 if (result
!= WIFI_SUCCESS
) {
1053 ALOGE("Failed to create trigger memory dump request; result = %d", result
);
1057 result
= requestResponse(request
);
1058 if (result
!= WIFI_SUCCESS
) {
1059 ALOGE("Failed to register trigger memory dump response; result = %d", result
);
1064 virtual int handleResponse(WifiEvent
& reply
) {
1065 ALOGD("In MemoryDumpCommand::handleResponse");
1067 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
1068 ALOGD("Ignoring reply with cmd = %d", reply
.get_cmd());
1072 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
1073 int len
= reply
.get_vendor_data_len();
1075 ALOGD("len = %d", len
);
1076 if (vendor_data
== NULL
|| len
== 0) {
1077 ALOGE("no vendor data in memory dump response; ignoring it");
1082 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
1083 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
) {
1084 mBuffSize
= it
.get_u32();
1087 mBuff
= (char *)malloc(mBuffSize
);
1089 ALOGE("Buffer allocation failed");
1092 WifiRequest
request(familyId(), ifaceId());
1093 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_FW_MEM_DUMP
);
1094 if (result
!= WIFI_SUCCESS
) {
1095 ALOGE("Failed to create get fw memory dump request; result = %d", result
);
1099 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1100 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_LEN
, mBuffSize
);
1101 if (result
!= WIFI_SUCCESS
) {
1102 ALOGE("Failed to put get fw memory dump request; result = %d", result
);
1105 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
, (uint64_t)mBuff
);
1106 if (result
!= WIFI_SUCCESS
) {
1107 ALOGE("Failed to put get fw memory dump request; result = %d", result
);
1110 request
.attr_end(data
);
1111 result
= requestResponse(request
);
1112 if (result
!= WIFI_SUCCESS
) {
1113 ALOGE("Failed to register get fw momory dump response; result = %d", result
);
1115 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_FW_DUMP_DATA
) {
1116 ALOGI("Initiating memory dump callback");
1117 if (mHandler
.on_firmware_memory_dump
) {
1118 (*mHandler
.on_firmware_memory_dump
)(mBuff
, mBuffSize
);
1125 ALOGW("Ignoring invalid attribute type = %d, size = %d",
1126 it
.get_type(), it
.get_len());
1129 case GET_DRIVER_DUMP
:
1130 for (nl_iterator
it(vendor_data
); it
.has_next(); it
.next()) {
1131 if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_LEN
) {
1132 mBuffSize
= it
.get_u32();
1135 mBuff
= (char *)malloc(mBuffSize
);
1137 ALOGE("Buffer allocation failed");
1140 WifiRequest
request(familyId(), ifaceId());
1141 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_DRIVER_MEM_DUMP
);
1142 if (result
!= WIFI_SUCCESS
) {
1143 ALOGE("Failed to create get driver memory dump request; result = %d", result
);
1147 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1148 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_LEN
, mBuffSize
);
1149 if (result
!= WIFI_SUCCESS
) {
1150 ALOGE("Failed to put get driver memory dump request; result = %d", result
);
1153 result
= request
.put_u64(ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA
, (uint64_t)mBuff
);
1154 if (result
!= WIFI_SUCCESS
) {
1155 ALOGE("Failed to put get driver memory dump request; result = %d", result
);
1158 request
.attr_end(data
);
1159 result
= requestResponse(request
);
1160 if (result
!= WIFI_SUCCESS
) {
1161 ALOGE("Failed to register get driver momory dump response; result = %d", result
);
1163 } else if (it
.get_type() == ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA
) {
1164 ALOGI("Initiating memory dump callback");
1165 if (mcallback
.on_driver_memory_dump
) {
1166 (*mcallback
.on_driver_memory_dump
)(mBuff
, mBuffSize
);
1173 ALOGW("Ignoring invalid attribute type = %d, size = %d",
1174 it
.get_type(), it
.get_len());
1181 virtual int handleEvent(WifiEvent
& event
) {
1187 /* API to collect a firmware memory dump for a given iface */
1188 wifi_error
wifi_get_firmware_memory_dump( wifi_interface_handle iface
,
1189 wifi_firmware_memory_dump_handler handler
)
1191 MemoryDumpCommand
*cmd
= new MemoryDumpCommand(iface
, handler
, GET_FW_DUMP
);
1192 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1193 wifi_error result
= (wifi_error
)cmd
->start();
1198 wifi_error
wifi_get_driver_memory_dump(wifi_interface_handle iface
,
1199 wifi_driver_memory_dump_callbacks callbacks
)
1201 MemoryDumpCommand
*cmd
= new MemoryDumpCommand(iface
, callbacks
, GET_DRIVER_DUMP
);
1202 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1203 wifi_error result
= (wifi_error
)cmd
->start();
1207 class WifiLoggerCommand
: public WifiCommand
1209 WLAN_DRIVER_WAKE_REASON_CNT
*mGetWakeStats
;
1212 WifiLoggerCommand(wifi_interface_handle handle
, WLAN_DRIVER_WAKE_REASON_CNT
*wifi_wake_reason_cnt
)
1213 : WifiCommand(handle
, 0), mGetWakeStats(wifi_wake_reason_cnt
)
1216 int createRequest(WifiRequest
& request
) {
1217 int result
= request
.create(GOOGLE_OUI
, ENHANCE_LOGGER_GET_WAKE_REASON_STATS
);
1222 nlattr
*data
= request
.attr_start(NL80211_ATTR_VENDOR_DATA
);
1224 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_SZ
, mGetWakeStats
->cmd_event_wake_cnt_sz
);
1225 if (result
!= WIFI_SUCCESS
) {
1226 ALOGE("Failed to put wake_cnt_sz; result = %d", result
);
1229 result
= request
.put_u32(ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_SZ
, mGetWakeStats
->driver_fw_local_wake_cnt_sz
);
1230 if (result
!= WIFI_SUCCESS
) {
1231 ALOGE("Failed to put driver_fw_local_wake_cnt; result = %d", result
);
1234 request
.attr_end(data
);
1239 ALOGD("Start get wake reason stats command\n");
1240 WifiRequest
request(familyId(), ifaceId());
1241 int result
= createRequest(request
);
1243 ALOGE("Failed to create get wake reason stats request; result = %d\n", result
);
1246 result
= requestResponse(request
);
1247 if (result
!= WIFI_SUCCESS
) {
1248 ALOGE("Failed to register get wake reason stats response; result = %d\n", result
);
1253 int handleResponse(WifiEvent
& reply
) {
1255 ALOGD("In WifiLoggerCommand::handleResponse\n");
1257 if (reply
.get_cmd() != NL80211_CMD_VENDOR
) {
1258 ALOGI("Ignoring reply with cmd = %d", reply
.get_cmd());
1261 nlattr
*vendor_data
= reply
.get_attribute(NL80211_ATTR_VENDOR_DATA
);
1262 len
= reply
.get_vendor_data_len();
1263 if (vendor_data
== NULL
|| len
== 0) {
1264 ALOGE("No Debug data found");
1267 nl_iterator
it(vendor_data
);
1269 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_CMD_EVENT_WAKE
) {
1270 ALOGE("TOTAL_CMD_EVENT_WAKE not found %d", it
.get_type());
1274 mGetWakeStats
->total_cmd_event_wake
= it
.get_u32();
1277 if(mGetWakeStats
->total_cmd_event_wake
&& mGetWakeStats
->cmd_event_wake_cnt
) {
1278 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_CMD_EVENT_WAKE_CNT_PTR
) {
1279 ALOGE("CMD_EVENT_WAKE_CNT_PTR not found %d", it
.get_type());
1284 mGetWakeStats
->cmd_event_wake_cnt_used
= (len
< mGetWakeStats
->cmd_event_wake_cnt_sz
) ? len
: mGetWakeStats
->cmd_event_wake_cnt_sz
;
1285 memcpy(mGetWakeStats
->cmd_event_wake_cnt
, it
.get_data(), mGetWakeStats
->cmd_event_wake_cnt_used
* sizeof(int));
1287 mGetWakeStats
->cmd_event_wake_cnt_used
= 0;
1292 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_DRIVER_FW_LOCAL_WAKE
) {
1293 ALOGE("TOTAL_DRIVER_FW_LOCAL_WAKE not found %d", it
.get_type());
1297 mGetWakeStats
->total_driver_fw_local_wake
= it
.get_u32();
1300 if(mGetWakeStats
->total_driver_fw_local_wake
&& mGetWakeStats
->driver_fw_local_wake_cnt
) {
1301 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_DRIVER_FW_LOCAL_WAKE_CNT_PTR
) {
1302 ALOGE("DRIVER_FW_LOCAL_WAKE_CNT_PTR not found %d", it
.get_type());
1307 mGetWakeStats
->driver_fw_local_wake_cnt_used
= (len
< mGetWakeStats
->driver_fw_local_wake_cnt_sz
) ? len
: mGetWakeStats
->driver_fw_local_wake_cnt_sz
;
1308 memcpy(mGetWakeStats
->driver_fw_local_wake_cnt
, it
.get_data(), mGetWakeStats
->driver_fw_local_wake_cnt_used
* sizeof(int));
1310 mGetWakeStats
->driver_fw_local_wake_cnt_used
= 0;
1315 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_RX_DATA_WAKE
) {
1316 ALOGE("TOTAL_RX_DATA_WAKE not found %d", it
.get_type());
1320 mGetWakeStats
->total_rx_data_wake
= it
.get_u32();
1323 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_UNICAST_CNT
) {
1324 ALOGE("RX_UNICAST_CNT not found %d", it
.get_type());
1328 mGetWakeStats
->rx_wake_details
.rx_unicast_cnt
= it
.get_u32();
1331 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_MULTICAST_CNT
) {
1332 ALOGE("RX_MULTICAST_CNT not found %d", it
.get_type());
1336 mGetWakeStats
->rx_wake_details
.rx_multicast_cnt
= it
.get_u32();
1339 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_RX_BROADCAST_CNT
) {
1340 ALOGE("RX_BROADCAST_CNT not found %d", it
.get_type());
1344 mGetWakeStats
->rx_wake_details
.rx_broadcast_cnt
= it
.get_u32();
1347 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP_PKT
) {
1348 ALOGE("ICMP_PKT not found %d", it
.get_type());
1352 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp_pkt
= it
.get_u32();
1355 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_PKT
) {
1356 ALOGE("ICMP6_PKT not found %d", it
.get_type());
1360 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_pkt
= it
.get_u32();
1363 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RA
) {
1364 ALOGE("ICMP6_RA not found %d", it
.get_type());
1368 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_ra
= it
.get_u32();
1371 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NA
) {
1372 ALOGE("ICMP6_NA not found %d", it
.get_type());
1376 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_na
= it
.get_u32();
1379 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_NS
) {
1380 ALOGE("ICMP6_NS not found %d", it
.get_type());
1384 mGetWakeStats
->rx_wake_pkt_classification_info
.icmp6_ns
= it
.get_u32();
1387 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP4_RX_MULTICAST_CNT
) {
1388 ALOGE("ICMP4_RX_MULTICAST_CNT not found %d", it
.get_type());
1392 mGetWakeStats
->rx_multicast_wake_pkt_info
.ipv4_rx_multicast_addr_cnt
= it
.get_u32();
1395 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RX_MULTICAST_CNT
) {
1396 ALOGE("ICMP6_RX_MULTICAST_CNT not found %d", it
.get_type());
1400 mGetWakeStats
->rx_multicast_wake_pkt_info
.ipv6_rx_multicast_addr_cnt
= it
.get_u32();
1403 if (it
.get_type() != ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_OTHER_RX_MULTICAST_CNT
) {
1404 ALOGE("OTHER_RX_MULTICAST_CNT not found %d", it
.get_type());
1408 mGetWakeStats
->rx_multicast_wake_pkt_info
.other_rx_multicast_addr_cnt
= it
.get_u32();
1413 int handleEvent(WifiEvent
& event
) {
1414 /* NO events to handle here! */
1419 /* Function to get wake lock stats */
1420 wifi_error
wifi_get_wake_reason_stats(wifi_interface_handle iface
,
1421 WLAN_DRIVER_WAKE_REASON_CNT
*wifi_wake_reason_cnt
)
1423 if(wifi_wake_reason_cnt
) {
1424 WifiLoggerCommand
*cmd
= new WifiLoggerCommand(iface
,wifi_wake_reason_cnt
);
1425 NULL_CHECK_RETURN(cmd
, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY
);
1426 wifi_error result
= (wifi_error
)cmd
->start();
1430 ALOGE("Reason cnt NULL");
1431 return WIFI_ERROR_INVALID_ARGS
;