mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
wifi: Add implementation of driver/firmware memory dumps
am: cdb77f3cf2
Change-Id: I11fb9cc47f84a49b4a836da28266089f9971768c
This commit is contained in:
@@ -97,12 +97,46 @@ Return<void> WifiChip::requestChipDebugInfo() {
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestDriverDebugDump() {
|
||||
// TODO implement
|
||||
if (!legacy_hal_.lock())
|
||||
return Void();
|
||||
|
||||
std::pair<wifi_error, std::vector<char>> ret =
|
||||
legacy_hal_.lock()->requestWlanDriverMemoryDump();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get driver debug dump: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
return Void();
|
||||
}
|
||||
|
||||
auto& driver_dump = ret.second;
|
||||
hidl_vec<uint8_t> hidl_data;
|
||||
hidl_data.setToExternal(reinterpret_cast<uint8_t*>(driver_dump.data()),
|
||||
driver_dump.size());
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onDriverDebugDumpAvailable(hidl_data);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::requestFirmwareDebugDump() {
|
||||
// TODO implement
|
||||
if (!legacy_hal_.lock())
|
||||
return Void();
|
||||
|
||||
std::pair<wifi_error, std::vector<char>> ret =
|
||||
legacy_hal_.lock()->requestWlanFirmwareMemoryDump();
|
||||
if (ret.first != WIFI_SUCCESS) {
|
||||
LOG(ERROR) << "Failed to get firmware debug dump: "
|
||||
<< LegacyErrorToString(ret.first);
|
||||
return Void();
|
||||
}
|
||||
|
||||
auto& firmware_dump = ret.second;
|
||||
hidl_vec<uint8_t> hidl_data;
|
||||
hidl_data.setToExternal(reinterpret_cast<uint8_t*>(firmware_dump.data()),
|
||||
firmware_dump.size());
|
||||
for (const auto& callback : callbacks_) {
|
||||
callback->onFirmwareDebugDumpAvailable(hidl_data);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,22 @@ void onStopComplete(wifi_handle handle) {
|
||||
on_stop_complete_internal_callback(handle);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback to be invoked for driver dump.
|
||||
std::function<void(char*, int)> on_driver_memory_dump_internal_callback;
|
||||
void onDriverMemoryDump(char* buffer, int buffer_size) {
|
||||
if (on_driver_memory_dump_internal_callback) {
|
||||
on_driver_memory_dump_internal_callback(buffer, buffer_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback to be invoked for firmware dump.
|
||||
std::function<void(char*, int)> on_firmware_memory_dump_internal_callback;
|
||||
void onFirmwareMemoryDump(char* buffer, int buffer_size) {
|
||||
if (on_firmware_memory_dump_internal_callback) {
|
||||
on_firmware_memory_dump_internal_callback(buffer, buffer_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace android {
|
||||
@@ -120,6 +136,32 @@ std::pair<wifi_error, std::string> WifiLegacyHal::getWlanFirmwareVersion() {
|
||||
return std::make_pair(status, buffer.data());
|
||||
}
|
||||
|
||||
std::pair<wifi_error, std::vector<char>>
|
||||
WifiLegacyHal::requestWlanDriverMemoryDump() {
|
||||
std::vector<char> driver_dump;
|
||||
on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
|
||||
int buffer_size) {
|
||||
driver_dump.insert(driver_dump.end(), buffer, buffer + buffer_size);
|
||||
};
|
||||
wifi_error status = global_func_table_.wifi_get_driver_memory_dump(
|
||||
wlan_interface_handle_, {onDriverMemoryDump});
|
||||
on_driver_memory_dump_internal_callback = nullptr;
|
||||
return std::make_pair(status, std::move(driver_dump));
|
||||
}
|
||||
|
||||
std::pair<wifi_error, std::vector<char>>
|
||||
WifiLegacyHal::requestWlanFirmwareMemoryDump() {
|
||||
std::vector<char> firmware_dump;
|
||||
on_firmware_memory_dump_internal_callback = [&firmware_dump](
|
||||
char* buffer, int buffer_size) {
|
||||
firmware_dump.insert(firmware_dump.end(), buffer, buffer + buffer_size);
|
||||
};
|
||||
wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
|
||||
wlan_interface_handle_, {onFirmwareMemoryDump});
|
||||
on_firmware_memory_dump_internal_callback = nullptr;
|
||||
return std::make_pair(status, std::move(firmware_dump));
|
||||
}
|
||||
|
||||
wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
|
||||
const std::string& ifname_to_find = getWlanInterfaceName();
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ class WifiLegacyHal {
|
||||
// Wrappers for all the functions in the legacy HAL function table.
|
||||
std::pair<wifi_error, std::string> getWlanDriverVersion();
|
||||
std::pair<wifi_error, std::string> getWlanFirmwareVersion();
|
||||
std::pair<wifi_error, std::vector<char>> requestWlanDriverMemoryDump();
|
||||
std::pair<wifi_error, std::vector<char>> requestWlanFirmwareMemoryDump();
|
||||
|
||||
private:
|
||||
static const uint32_t kMaxVersionStringLength;
|
||||
|
||||
Reference in New Issue
Block a user