diff options
author | Xinming Hu <huxm@marvell.com> | 2017-12-12 02:38:11 -0500 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2018-01-08 12:36:55 -0500 |
commit | d0e2b44ef32814bdde8aaed307d1ae663fcf251c (patch) | |
tree | 725826544d63850b60babfedf6d49e15a8c48f4a | |
parent | c3929a980b16277cf3cd5e797adcb9bdf877ef4e (diff) |
mwifiex: refactor device dump code to make it generic for usb interface
This patch refactor current device dump code to make it generic
for subsequent implementation on usb interface.
Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Ganapathi Bhat <gbhat@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/init.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/main.c | 97 | ||||
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/main.h | 11 | ||||
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/pcie.c | 13 | ||||
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/sdio.c | 14 |
5 files changed, 79 insertions, 57 deletions
diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c index e1aa86042469..b0d3d681a76a 100644 --- a/drivers/net/wireless/marvell/mwifiex/init.c +++ b/drivers/net/wireless/marvell/mwifiex/init.c | |||
@@ -314,6 +314,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) | |||
314 | adapter->iface_limit.p2p_intf = MWIFIEX_MAX_P2P_NUM; | 314 | adapter->iface_limit.p2p_intf = MWIFIEX_MAX_P2P_NUM; |
315 | adapter->active_scan_triggered = false; | 315 | adapter->active_scan_triggered = false; |
316 | timer_setup(&adapter->wakeup_timer, wakeup_timer_fn, 0); | 316 | timer_setup(&adapter->wakeup_timer, wakeup_timer_fn, 0); |
317 | adapter->devdump_len = 0; | ||
317 | } | 318 | } |
318 | 319 | ||
319 | /* | 320 | /* |
diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index a96bd7e653bf..12e739950332 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c | |||
@@ -1051,9 +1051,30 @@ void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) | |||
1051 | } | 1051 | } |
1052 | EXPORT_SYMBOL_GPL(mwifiex_multi_chan_resync); | 1052 | EXPORT_SYMBOL_GPL(mwifiex_multi_chan_resync); |
1053 | 1053 | ||
1054 | int mwifiex_drv_info_dump(struct mwifiex_adapter *adapter, void **drv_info) | 1054 | void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) |
1055 | { | 1055 | { |
1056 | void *p; | 1056 | /* Dump all the memory data into single file, a userspace script will |
1057 | * be used to split all the memory data to multiple files | ||
1058 | */ | ||
1059 | mwifiex_dbg(adapter, MSG, | ||
1060 | "== mwifiex dump information to /sys/class/devcoredump start\n"); | ||
1061 | dev_coredumpv(adapter->dev, adapter->devdump_data, adapter->devdump_len, | ||
1062 | GFP_KERNEL); | ||
1063 | mwifiex_dbg(adapter, MSG, | ||
1064 | "== mwifiex dump information to /sys/class/devcoredump end\n"); | ||
1065 | |||
1066 | /* Device dump data will be freed in device coredump release function | ||
1067 | * after 5 min. Here reset adapter->devdump_data and ->devdump_len | ||
1068 | * to avoid it been accidentally reused. | ||
1069 | */ | ||
1070 | adapter->devdump_data = NULL; | ||
1071 | adapter->devdump_len = 0; | ||
1072 | } | ||
1073 | EXPORT_SYMBOL_GPL(mwifiex_upload_device_dump); | ||
1074 | |||
1075 | void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) | ||
1076 | { | ||
1077 | char *p; | ||
1057 | char drv_version[64]; | 1078 | char drv_version[64]; |
1058 | struct usb_card_rec *cardp; | 1079 | struct usb_card_rec *cardp; |
1059 | struct sdio_mmc_card *sdio_card; | 1080 | struct sdio_mmc_card *sdio_card; |
@@ -1061,17 +1082,12 @@ int mwifiex_drv_info_dump(struct mwifiex_adapter *adapter, void **drv_info) | |||
1061 | int i, idx; | 1082 | int i, idx; |
1062 | struct netdev_queue *txq; | 1083 | struct netdev_queue *txq; |
1063 | struct mwifiex_debug_info *debug_info; | 1084 | struct mwifiex_debug_info *debug_info; |
1064 | void *drv_info_dump; | ||
1065 | 1085 | ||
1066 | mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); | 1086 | mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); |
1067 | 1087 | ||
1068 | /* memory allocate here should be free in mwifiex_upload_device_dump*/ | 1088 | p = adapter->devdump_data; |
1069 | drv_info_dump = vzalloc(MWIFIEX_DRV_INFO_SIZE_MAX); | 1089 | strcpy(p, "========Start dump driverinfo========\n"); |
1070 | 1090 | p += strlen("========Start dump driverinfo========\n"); | |
1071 | if (!drv_info_dump) | ||
1072 | return 0; | ||
1073 | |||
1074 | p = (char *)(drv_info_dump); | ||
1075 | p += sprintf(p, "driver_name = " "\"mwifiex\"\n"); | 1091 | p += sprintf(p, "driver_name = " "\"mwifiex\"\n"); |
1076 | 1092 | ||
1077 | mwifiex_drv_get_driver_version(adapter, drv_version, | 1093 | mwifiex_drv_get_driver_version(adapter, drv_version, |
@@ -1155,21 +1171,18 @@ int mwifiex_drv_info_dump(struct mwifiex_adapter *adapter, void **drv_info) | |||
1155 | kfree(debug_info); | 1171 | kfree(debug_info); |
1156 | } | 1172 | } |
1157 | 1173 | ||
1174 | strcpy(p, "\n========End dump========\n"); | ||
1175 | p += strlen("\n========End dump========\n"); | ||
1158 | mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); | 1176 | mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); |
1159 | *drv_info = drv_info_dump; | 1177 | adapter->devdump_len = p - (char *)adapter->devdump_data; |
1160 | return p - drv_info_dump; | ||
1161 | } | 1178 | } |
1162 | EXPORT_SYMBOL_GPL(mwifiex_drv_info_dump); | 1179 | EXPORT_SYMBOL_GPL(mwifiex_drv_info_dump); |
1163 | 1180 | ||
1164 | void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, | 1181 | void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) |
1165 | int drv_info_size) | ||
1166 | { | 1182 | { |
1167 | u8 idx, *dump_data, *fw_dump_ptr; | 1183 | u8 idx; |
1168 | u32 dump_len; | 1184 | char *fw_dump_ptr; |
1169 | 1185 | u32 dump_len = 0; | |
1170 | dump_len = (strlen("========Start dump driverinfo========\n") + | ||
1171 | drv_info_size + | ||
1172 | strlen("\n========End dump========\n")); | ||
1173 | 1186 | ||
1174 | for (idx = 0; idx < adapter->num_mem_types; idx++) { | 1187 | for (idx = 0; idx < adapter->num_mem_types; idx++) { |
1175 | struct memory_type_mapping *entry = | 1188 | struct memory_type_mapping *entry = |
@@ -1184,24 +1197,24 @@ void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, | |||
1184 | } | 1197 | } |
1185 | } | 1198 | } |
1186 | 1199 | ||
1187 | dump_data = vzalloc(dump_len + 1); | 1200 | if (dump_len + 1 + adapter->devdump_len > MWIFIEX_FW_DUMP_SIZE) { |
1188 | if (!dump_data) | 1201 | /* Realloc in case buffer overflow */ |
1189 | goto done; | 1202 | fw_dump_ptr = vzalloc(dump_len + 1 + adapter->devdump_len); |
1190 | 1203 | mwifiex_dbg(adapter, MSG, "Realloc device dump data.\n"); | |
1191 | fw_dump_ptr = dump_data; | 1204 | if (!fw_dump_ptr) { |
1205 | vfree(adapter->devdump_data); | ||
1206 | mwifiex_dbg(adapter, ERROR, | ||
1207 | "vzalloc devdump data failure!\n"); | ||
1208 | return; | ||
1209 | } | ||
1192 | 1210 | ||
1193 | /* Dump all the memory data into single file, a userspace script will | 1211 | memmove(fw_dump_ptr, adapter->devdump_data, |
1194 | * be used to split all the memory data to multiple files | 1212 | adapter->devdump_len); |
1195 | */ | 1213 | vfree(adapter->devdump_data); |
1196 | mwifiex_dbg(adapter, MSG, | 1214 | adapter->devdump_data = fw_dump_ptr; |
1197 | "== mwifiex dump information to /sys/class/devcoredump start"); | 1215 | } |
1198 | 1216 | ||
1199 | strcpy(fw_dump_ptr, "========Start dump driverinfo========\n"); | 1217 | fw_dump_ptr = (char *)adapter->devdump_data + adapter->devdump_len; |
1200 | fw_dump_ptr += strlen("========Start dump driverinfo========\n"); | ||
1201 | memcpy(fw_dump_ptr, drv_info, drv_info_size); | ||
1202 | fw_dump_ptr += drv_info_size; | ||
1203 | strcpy(fw_dump_ptr, "\n========End dump========\n"); | ||
1204 | fw_dump_ptr += strlen("\n========End dump========\n"); | ||
1205 | 1218 | ||
1206 | for (idx = 0; idx < adapter->num_mem_types; idx++) { | 1219 | for (idx = 0; idx < adapter->num_mem_types; idx++) { |
1207 | struct memory_type_mapping *entry = | 1220 | struct memory_type_mapping *entry = |
@@ -1225,14 +1238,8 @@ void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, | |||
1225 | } | 1238 | } |
1226 | } | 1239 | } |
1227 | 1240 | ||
1228 | /* device dump data will be free in device coredump release function | 1241 | adapter->devdump_len = fw_dump_ptr - (char *)adapter->devdump_data; |
1229 | * after 5 min | ||
1230 | */ | ||
1231 | dev_coredumpv(adapter->dev, dump_data, dump_len, GFP_KERNEL); | ||
1232 | mwifiex_dbg(adapter, MSG, | ||
1233 | "== mwifiex dump information to /sys/class/devcoredump end"); | ||
1234 | 1242 | ||
1235 | done: | ||
1236 | for (idx = 0; idx < adapter->num_mem_types; idx++) { | 1243 | for (idx = 0; idx < adapter->num_mem_types; idx++) { |
1237 | struct memory_type_mapping *entry = | 1244 | struct memory_type_mapping *entry = |
1238 | &adapter->mem_type_mapping_tbl[idx]; | 1245 | &adapter->mem_type_mapping_tbl[idx]; |
@@ -1241,10 +1248,8 @@ done: | |||
1241 | entry->mem_ptr = NULL; | 1248 | entry->mem_ptr = NULL; |
1242 | entry->mem_size = 0; | 1249 | entry->mem_size = 0; |
1243 | } | 1250 | } |
1244 | |||
1245 | vfree(drv_info); | ||
1246 | } | 1251 | } |
1247 | EXPORT_SYMBOL_GPL(mwifiex_upload_device_dump); | 1252 | EXPORT_SYMBOL_GPL(mwifiex_prepare_fw_dump_info); |
1248 | 1253 | ||
1249 | /* | 1254 | /* |
1250 | * CFG802.11 network device handler for statistics retrieval. | 1255 | * CFG802.11 network device handler for statistics retrieval. |
diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index 154c0796c0c5..8b6241afb3f6 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h | |||
@@ -94,6 +94,8 @@ enum { | |||
94 | 94 | ||
95 | #define MAX_EVENT_SIZE 2048 | 95 | #define MAX_EVENT_SIZE 2048 |
96 | 96 | ||
97 | #define MWIFIEX_FW_DUMP_SIZE (2 * 1024 * 1024) | ||
98 | |||
97 | #define ARP_FILTER_MAX_BUF_SIZE 68 | 99 | #define ARP_FILTER_MAX_BUF_SIZE 68 |
98 | 100 | ||
99 | #define MWIFIEX_KEY_BUFFER_SIZE 16 | 101 | #define MWIFIEX_KEY_BUFFER_SIZE 16 |
@@ -1032,6 +1034,9 @@ struct mwifiex_adapter { | |||
1032 | bool wake_by_wifi; | 1034 | bool wake_by_wifi; |
1033 | /* Aggregation parameters*/ | 1035 | /* Aggregation parameters*/ |
1034 | struct bus_aggr_params bus_aggr; | 1036 | struct bus_aggr_params bus_aggr; |
1037 | /* Device dump data/length */ | ||
1038 | void *devdump_data; | ||
1039 | int devdump_len; | ||
1035 | }; | 1040 | }; |
1036 | 1041 | ||
1037 | void mwifiex_process_tx_queue(struct mwifiex_adapter *adapter); | 1042 | void mwifiex_process_tx_queue(struct mwifiex_adapter *adapter); |
@@ -1656,9 +1661,9 @@ void mwifiex_hist_data_add(struct mwifiex_private *priv, | |||
1656 | u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv, | 1661 | u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv, |
1657 | u8 rx_rate, u8 ht_info); | 1662 | u8 rx_rate, u8 ht_info); |
1658 | 1663 | ||
1659 | int mwifiex_drv_info_dump(struct mwifiex_adapter *adapter, void **drv_info); | 1664 | void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter); |
1660 | void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, | 1665 | void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter); |
1661 | int drv_info_size); | 1666 | void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter); |
1662 | void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags); | 1667 | void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags); |
1663 | void mwifiex_queue_main_work(struct mwifiex_adapter *adapter); | 1668 | void mwifiex_queue_main_work(struct mwifiex_adapter *adapter); |
1664 | int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action, | 1669 | int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action, |
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index cd314946452c..f666cb2ea7e0 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c | |||
@@ -2769,12 +2769,17 @@ static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter) | |||
2769 | 2769 | ||
2770 | static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) | 2770 | static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) |
2771 | { | 2771 | { |
2772 | int drv_info_size; | 2772 | adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); |
2773 | void *drv_info; | 2773 | if (!adapter->devdump_data) { |
2774 | mwifiex_dbg(adapter, ERROR, | ||
2775 | "vzalloc devdump data failure!\n"); | ||
2776 | return; | ||
2777 | } | ||
2774 | 2778 | ||
2775 | drv_info_size = mwifiex_drv_info_dump(adapter, &drv_info); | 2779 | mwifiex_drv_info_dump(adapter); |
2776 | mwifiex_pcie_fw_dump(adapter); | 2780 | mwifiex_pcie_fw_dump(adapter); |
2777 | mwifiex_upload_device_dump(adapter, drv_info, drv_info_size); | 2781 | mwifiex_prepare_fw_dump_info(adapter); |
2782 | mwifiex_upload_device_dump(adapter); | ||
2778 | } | 2783 | } |
2779 | 2784 | ||
2780 | static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter) | 2785 | static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter) |
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index fd5183c10c4e..a82880132af4 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c | |||
@@ -2505,15 +2505,21 @@ done: | |||
2505 | static void mwifiex_sdio_device_dump_work(struct mwifiex_adapter *adapter) | 2505 | static void mwifiex_sdio_device_dump_work(struct mwifiex_adapter *adapter) |
2506 | { | 2506 | { |
2507 | struct sdio_mmc_card *card = adapter->card; | 2507 | struct sdio_mmc_card *card = adapter->card; |
2508 | int drv_info_size; | ||
2509 | void *drv_info; | ||
2510 | 2508 | ||
2511 | drv_info_size = mwifiex_drv_info_dump(adapter, &drv_info); | 2509 | adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); |
2510 | if (!adapter->devdump_data) { | ||
2511 | mwifiex_dbg(adapter, ERROR, | ||
2512 | "vzalloc devdump data failure!\n"); | ||
2513 | return; | ||
2514 | } | ||
2515 | |||
2516 | mwifiex_drv_info_dump(adapter); | ||
2512 | if (card->fw_dump_enh) | 2517 | if (card->fw_dump_enh) |
2513 | mwifiex_sdio_generic_fw_dump(adapter); | 2518 | mwifiex_sdio_generic_fw_dump(adapter); |
2514 | else | 2519 | else |
2515 | mwifiex_sdio_fw_dump(adapter); | 2520 | mwifiex_sdio_fw_dump(adapter); |
2516 | mwifiex_upload_device_dump(adapter, drv_info, drv_info_size); | 2521 | mwifiex_prepare_fw_dump_info(adapter); |
2522 | mwifiex_upload_device_dump(adapter); | ||
2517 | } | 2523 | } |
2518 | 2524 | ||
2519 | static void mwifiex_sdio_work(struct work_struct *work) | 2525 | static void mwifiex_sdio_work(struct work_struct *work) |