wlan_logging_sock_svc.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  1. /*
  2. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /******************************************************************************
  19. * wlan_logging_sock_svc.c
  20. *
  21. ******************************************************************************/
  22. #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
  23. #include <linux/vmalloc.h>
  24. #include <wlan_logging_sock_svc.h>
  25. #include <linux/kthread.h>
  26. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0))
  27. #include <linux/panic_notifier.h>
  28. #endif
  29. #include <qdf_time.h>
  30. #include <qdf_trace.h>
  31. #include <qdf_mc_timer.h>
  32. #include <qdf_timer.h>
  33. #include <qdf_lock.h>
  34. #include <wlan_ptt_sock_svc.h>
  35. #include <host_diag_core_event.h>
  36. #include "host_diag_core_log.h"
  37. #include <qdf_event.h>
  38. #include <qdf_module.h>
  39. #include <qdf_str.h>
  40. #ifdef WLAN_FEATURE_CONNECTIVITY_LOGGING
  41. #include <wlan_connectivity_logging.h>
  42. #endif
  43. #ifdef CNSS_GENL
  44. #ifdef CONFIG_CNSS_OUT_OF_TREE
  45. #include "cnss_nl.h"
  46. #else
  47. #include <net/cnss_nl.h>
  48. #endif
  49. #endif
  50. #if defined(FEATURE_FW_LOG_PARSING) || defined(FEATURE_WLAN_DIAG_SUPPORT) || \
  51. defined(FEATURE_PKTLOG)
  52. #include <cds_api.h>
  53. #include "ani_global.h"
  54. #endif
  55. #ifdef FEATURE_PKTLOG
  56. #ifndef REMOVE_PKT_LOG
  57. #include "wma.h"
  58. #include "pktlog_ac.h"
  59. #include <cdp_txrx_misc.h>
  60. #endif
  61. #endif
  62. #define MAX_NUM_PKT_LOG 32
  63. #define LOGGING_TRACE(level, args ...) \
  64. QDF_TRACE(QDF_MODULE_ID_HDD, level, ## args)
  65. /* Global variables */
  66. #define ANI_NL_MSG_LOG_TYPE 89
  67. #define ANI_NL_MSG_READY_IND_TYPE 90
  68. #ifndef MAX_LOGMSG_COUNT
  69. #define MAX_LOGMSG_COUNT 256
  70. #endif
  71. #define MAX_LOGMSG_LENGTH 2048
  72. #define MAX_SKBMSG_LENGTH 4096
  73. #define WLAN_LOG_BUFFER_SIZE 2048
  74. #if defined(FEATURE_PKTLOG) && !defined(REMOVE_PKT_LOG)
  75. /**
  76. * Buffer to accommodate -
  77. * pktlog buffer (2048 bytes)
  78. * ath_pktlog_hdr (16 bytes)
  79. * pkt_dump (8 bytes)
  80. * extra padding (40 bytes)
  81. *
  82. * Note: pktlog buffer size is dependent on RX_BUFFER_SIZE and
  83. * HTT_T2H_MAX_MSG_SIZE. Adjust WLAN_LOG_BUFFER_SIZE
  84. * based on the above mentioned macros.
  85. */
  86. #define ATH_PKTLOG_HDR_SIZE (sizeof(struct ath_pktlog_hdr))
  87. #define PKT_DUMP_HDR_SIZE (sizeof(struct packet_dump))
  88. #define EXTRA_PADDING 40
  89. #define MAX_PKTSTATS_LENGTH \
  90. ((WLAN_LOG_BUFFER_SIZE) + (ATH_PKTLOG_HDR_SIZE) + \
  91. (PKT_DUMP_HDR_SIZE) + (EXTRA_PADDING))
  92. #else
  93. #define MAX_PKTSTATS_LENGTH WLAN_LOG_BUFFER_SIZE
  94. #endif /* FEATURE_PKTLOG */
  95. #define MAX_PKTSTATS_BUFF 16
  96. #define HOST_LOG_DRIVER_MSG 0x001
  97. #define HOST_LOG_PER_PKT_STATS 0x002
  98. #define HOST_LOG_FW_FLUSH_COMPLETE 0x003
  99. #define HOST_LOG_DRIVER_CONNECTIVITY_MSG 0x004
  100. #define DIAG_TYPE_LOGS 1
  101. #define PTT_MSG_DIAG_CMDS_TYPE 0x5050
  102. #define MAX_LOG_LINE 500
  103. /* default rate limit period - 2sec */
  104. #define PANIC_WIFILOG_PRINT_RATE_LIMIT_PERIOD (2*HZ)
  105. /* default burst for rate limit */
  106. #define PANIC_WIFILOG_PRINT_RATE_LIMIT_BURST_DEFAULT 500
  107. DEFINE_RATELIMIT_STATE(panic_wifilog_ratelimit,
  108. PANIC_WIFILOG_PRINT_RATE_LIMIT_PERIOD,
  109. PANIC_WIFILOG_PRINT_RATE_LIMIT_BURST_DEFAULT);
  110. #define FLUSH_LOG_COMPLETION_TIMEOUT 3000
  111. struct log_msg {
  112. struct list_head node;
  113. unsigned int radio;
  114. unsigned int index;
  115. /* indicates the current filled log length in logbuf */
  116. unsigned int filled_length;
  117. /*
  118. * Buf to hold the log msg
  119. * tAniHdr + log
  120. */
  121. char logbuf[MAX_LOGMSG_LENGTH];
  122. };
  123. /**
  124. * struct packet_dump - This data structure contains the
  125. * Tx/Rx packet stats
  126. * @status: Status
  127. * @type: Type
  128. * @driver_ts: driver timestamp
  129. * @fw_ts: fw timestamp
  130. */
  131. struct packet_dump {
  132. unsigned char status;
  133. unsigned char type;
  134. uint32_t driver_ts;
  135. uint16_t fw_ts;
  136. } __attribute__((__packed__));
  137. /**
  138. * struct pkt_stats_msg - This data structure contains the
  139. * pkt stats node for link list
  140. * @node: LinkList node
  141. * @node: Pointer to skb
  142. */
  143. struct pkt_stats_msg {
  144. struct list_head node;
  145. struct sk_buff *skb;
  146. };
  147. #define MAX_FLUSH_TIMER_PERIOD_VALUE 3600000 /* maximum of 1 hour (in ms) */
  148. struct wlan_logging {
  149. /* Console log levels */
  150. uint32_t console_log_levels;
  151. /* Number of buffers to be used for logging */
  152. uint32_t num_buf;
  153. uint32_t buffer_length;
  154. /* Lock to synchronize access to shared logging resource */
  155. spinlock_t spin_lock;
  156. /* Holds the free node which can be used for filling logs */
  157. struct list_head free_list;
  158. /* Holds the filled nodes which needs to be indicated to APP */
  159. struct list_head filled_list;
  160. /* Holds nodes for console printing in case of kernel panic */
  161. struct list_head panic_list;
  162. /* Wait queue for Logger thread */
  163. wait_queue_head_t wait_queue;
  164. /* Logger thread */
  165. struct task_struct *thread;
  166. /* Logging thread sets this variable on exit */
  167. struct completion shutdown_comp;
  168. /* Indicates to logger thread to exit */
  169. bool exit;
  170. /* Holds number of dropped logs */
  171. unsigned int drop_count;
  172. /* current logbuf to which the log will be filled to */
  173. struct log_msg *pcur_node;
  174. /* Event flag used for wakeup and post indication*/
  175. unsigned long eventFlag;
  176. /* Indicates logger thread is activated */
  177. bool is_active;
  178. /* Flush completion check */
  179. bool is_flush_complete;
  180. /* paramaters for pkt stats */
  181. struct list_head pkt_stat_free_list;
  182. struct list_head pkt_stat_filled_list;
  183. struct pkt_stats_msg *pkt_stats_pcur_node;
  184. unsigned int pkt_stat_drop_cnt;
  185. spinlock_t pkt_stats_lock;
  186. unsigned int pkt_stats_msg_idx;
  187. qdf_timer_t flush_timer;
  188. bool is_flush_timer_initialized;
  189. uint32_t flush_timer_period;
  190. qdf_spinlock_t flush_timer_lock;
  191. qdf_event_t flush_log_completion;
  192. };
  193. /* This global variable is intentionally not marked static because it
  194. * is used by offline tools. Please do not use it outside this file.
  195. */
  196. struct wlan_logging gwlan_logging;
  197. static struct pkt_stats_msg *gpkt_stats_buffers;
  198. #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY
  199. static struct log_msg *gplog_msg;
  200. static inline QDF_STATUS allocate_log_msg_buffer(void)
  201. {
  202. gplog_msg = qdf_mem_valloc(MAX_LOGMSG_COUNT * sizeof(*gplog_msg));
  203. return gplog_msg ? QDF_STATUS_SUCCESS : QDF_STATUS_E_NOMEM;
  204. }
  205. static inline void free_log_msg_buffer(void)
  206. {
  207. qdf_mem_vfree(gplog_msg);
  208. gplog_msg = NULL;
  209. }
  210. #else
  211. static struct log_msg gplog_msg[MAX_LOGMSG_COUNT];
  212. static inline QDF_STATUS allocate_log_msg_buffer(void)
  213. {
  214. qdf_minidump_log(gplog_msg, sizeof(gplog_msg), "wlan_logs");
  215. return QDF_STATUS_SUCCESS;
  216. }
  217. static inline void free_log_msg_buffer(void)
  218. {
  219. qdf_minidump_remove(gplog_msg, sizeof(gplog_msg), "wlan_logs");
  220. }
  221. #endif
  222. /* Need to call this with spin_lock acquired */
  223. static int wlan_queue_logmsg_for_app(void)
  224. {
  225. char *ptr;
  226. int ret = 0;
  227. ptr = &gwlan_logging.pcur_node->logbuf[sizeof(tAniHdr)];
  228. ptr[gwlan_logging.pcur_node->filled_length] = '\0';
  229. *(unsigned short *)(gwlan_logging.pcur_node->logbuf) =
  230. ANI_NL_MSG_LOG_TYPE;
  231. *(unsigned short *)(gwlan_logging.pcur_node->logbuf + 2) =
  232. gwlan_logging.pcur_node->filled_length;
  233. list_add_tail(&gwlan_logging.pcur_node->node,
  234. &gwlan_logging.filled_list);
  235. if (!list_empty(&gwlan_logging.free_list)) {
  236. /* Get buffer from free list */
  237. gwlan_logging.pcur_node =
  238. (struct log_msg *)(gwlan_logging.free_list.next);
  239. list_del_init(gwlan_logging.free_list.next);
  240. } else if (!list_empty(&gwlan_logging.filled_list)) {
  241. /* Get buffer from filled list */
  242. /* This condition will drop the packet from being
  243. * indicated to app
  244. */
  245. gwlan_logging.pcur_node =
  246. (struct log_msg *)(gwlan_logging.filled_list.next);
  247. ++gwlan_logging.drop_count;
  248. list_del_init(gwlan_logging.filled_list.next);
  249. ret = 1;
  250. }
  251. /* Reset the current node values */
  252. gwlan_logging.pcur_node->filled_length = 0;
  253. return ret;
  254. }
  255. static const char *current_process_name(void)
  256. {
  257. if (in_irq())
  258. return "irq";
  259. if (in_softirq())
  260. return "soft_irq";
  261. return current->comm;
  262. }
  263. /**
  264. * wlan_add_user_log_time_stamp() - populate firmware and kernel timestamps
  265. * @tbuf: Pointer to time stamp buffer
  266. * @tbuf_sz: Time buffer size
  267. * @ts: Time stamp value
  268. *
  269. * For adrastea time stamp is QTIMER raw tick which will be used by cnss_diag
  270. * to convert it into user visible time stamp. In adrstea FW also uses QTIMER
  271. * raw ticks which is needed to synchronize host and fw log time stamps
  272. *
  273. * Also add logcat timestamp so that driver logs and
  274. * logcat logs can be co-related
  275. *
  276. * For discrete solution e.g rome use system tick and convert it into
  277. * seconds.milli seconds
  278. *
  279. * Return: number of characters written in target buffer not including
  280. * trailing '/0'
  281. */
  282. static int wlan_add_user_log_time_stamp(char *tbuf, size_t tbuf_sz, uint64_t ts)
  283. {
  284. char time_buf[20];
  285. qdf_get_time_of_the_day_in_hr_min_sec_usec(time_buf, sizeof(time_buf));
  286. return scnprintf(tbuf, tbuf_sz, "[%.6s][0x%llx]%s",
  287. current_process_name(), (unsigned long long)ts,
  288. time_buf);
  289. }
  290. #ifdef WLAN_MAX_LOGS_PER_SEC
  291. static inline void wlan_panic_on_excessive_logging(void)
  292. {
  293. if (qdf_detected_excessive_logging())
  294. QDF_DEBUG_PANIC("Exceeded %d logs per second",
  295. WLAN_MAX_LOGS_PER_SEC);
  296. }
  297. #else
  298. static inline void wlan_panic_on_excessive_logging(void) {}
  299. #endif /* WLAN_MAX_LOGS_PER_SEC */
  300. #ifdef QDF_TRACE_PRINT_ENABLE
  301. static inline void
  302. log_to_console(QDF_TRACE_LEVEL level, const char *timestamp, const char *msg)
  303. {
  304. if (qdf_detected_excessive_logging()) {
  305. qdf_rl_print_supressed_inc();
  306. return;
  307. }
  308. qdf_rl_print_supressed_log();
  309. pr_err("%s %s\n", timestamp, msg);
  310. }
  311. #else
  312. static inline void
  313. log_to_console(QDF_TRACE_LEVEL level, const char *timestamp, const char *msg)
  314. {
  315. switch (level) {
  316. case QDF_TRACE_LEVEL_FATAL:
  317. pr_alert("%s %s\n", timestamp, msg);
  318. wlan_panic_on_excessive_logging();
  319. break;
  320. case QDF_TRACE_LEVEL_ERROR:
  321. pr_err("%s %s\n", timestamp, msg);
  322. wlan_panic_on_excessive_logging();
  323. break;
  324. case QDF_TRACE_LEVEL_WARN:
  325. pr_warn("%s %s\n", timestamp, msg);
  326. wlan_panic_on_excessive_logging();
  327. break;
  328. case QDF_TRACE_LEVEL_INFO:
  329. pr_info("%s %s\n", timestamp, msg);
  330. wlan_panic_on_excessive_logging();
  331. break;
  332. case QDF_TRACE_LEVEL_INFO_HIGH:
  333. case QDF_TRACE_LEVEL_INFO_MED:
  334. case QDF_TRACE_LEVEL_INFO_LOW:
  335. case QDF_TRACE_LEVEL_DEBUG:
  336. default:
  337. /* these levels should not be logged to console */
  338. break;
  339. }
  340. }
  341. #endif
  342. int wlan_log_to_user(QDF_TRACE_LEVEL log_level, char *to_be_sent, int length)
  343. {
  344. char *ptr;
  345. char tbuf[60];
  346. int tlen;
  347. int total_log_len;
  348. unsigned int *pfilled_length;
  349. bool wake_up_thread = false;
  350. unsigned long flags;
  351. uint64_t ts;
  352. /* Add the current time stamp */
  353. ts = qdf_get_log_timestamp();
  354. tlen = wlan_add_user_log_time_stamp(tbuf, sizeof(tbuf), ts);
  355. /* if logging isn't up yet, just dump to dmesg */
  356. if (!gwlan_logging.is_active) {
  357. log_to_console(log_level, tbuf, to_be_sent);
  358. return 0;
  359. }
  360. /* 1+1 indicate '\n'+'\0' */
  361. total_log_len = length + tlen + 1 + 1;
  362. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  363. /* wlan logging svc resources are not yet initialized */
  364. if (!gwlan_logging.pcur_node) {
  365. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  366. return -EIO;
  367. }
  368. pfilled_length = &gwlan_logging.pcur_node->filled_length;
  369. /* Check if we can accommodate more log into current node/buffer */
  370. if ((MAX_LOGMSG_LENGTH - (*pfilled_length +
  371. sizeof(tAniNlHdr))) < total_log_len) {
  372. wake_up_thread = true;
  373. wlan_queue_logmsg_for_app();
  374. pfilled_length = &gwlan_logging.pcur_node->filled_length;
  375. }
  376. ptr = &gwlan_logging.pcur_node->logbuf[sizeof(tAniHdr)];
  377. if (unlikely(MAX_LOGMSG_LENGTH < (sizeof(tAniNlHdr) + total_log_len))) {
  378. /*
  379. * Assumption here is that we receive logs which is less than
  380. * MAX_LOGMSG_LENGTH, where we can accommodate the
  381. * tAniNlHdr + [context][timestamp] + log
  382. * If log length is over MAX_LOGMSG_LENGTH,
  383. * the overflow part will be discarded.
  384. */
  385. length = MAX_LOGMSG_LENGTH - sizeof(tAniNlHdr) - tlen - 2;
  386. /*
  387. * QDF_ASSERT if complete log was not accommodated into
  388. * the available buffer.
  389. */
  390. QDF_ASSERT(0);
  391. }
  392. memcpy(&ptr[*pfilled_length], tbuf, tlen);
  393. memcpy(&ptr[*pfilled_length + tlen], to_be_sent, length);
  394. *pfilled_length += tlen + length;
  395. ptr[*pfilled_length] = '\n';
  396. *pfilled_length += 1;
  397. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  398. /* Wakeup logger thread */
  399. if (wake_up_thread) {
  400. set_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
  401. wake_up_interruptible(&gwlan_logging.wait_queue);
  402. }
  403. if (gwlan_logging.console_log_levels & BIT(log_level))
  404. log_to_console(log_level, tbuf, to_be_sent);
  405. return 0;
  406. }
  407. /**
  408. * nl_srv_bcast_host_logs() - Wrapper to send bcast msgs to host logs mcast grp
  409. * @skb: sk buffer pointer
  410. *
  411. * Sends the bcast message to host logs multicast group with generic nl socket
  412. * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
  413. *
  414. * Return: zero on success, error code otherwise
  415. */
  416. #ifdef CNSS_GENL
  417. static int nl_srv_bcast_host_logs(struct sk_buff *skb)
  418. {
  419. return nl_srv_bcast(skb, CLD80211_MCGRP_HOST_LOGS, ANI_NL_MSG_LOG);
  420. }
  421. #else
  422. static int nl_srv_bcast_host_logs(struct sk_buff *skb)
  423. {
  424. return nl_srv_bcast(skb);
  425. }
  426. #endif
  427. #ifndef REMOVE_PKT_LOG
  428. /**
  429. * pkt_stats_fill_headers() - This function adds headers to skb
  430. * @skb: skb to which headers need to be added
  431. *
  432. * Return: 0 on success or Errno on failure
  433. */
  434. static int pkt_stats_fill_headers(struct sk_buff *skb)
  435. {
  436. struct host_log_pktlog_info cds_pktlog;
  437. int cds_pkt_size = sizeof(struct host_log_pktlog_info);
  438. tAniNlHdr msg_header;
  439. int extra_header_len, nl_payload_len;
  440. static int nlmsg_seq;
  441. int diag_type;
  442. qdf_mem_zero(&cds_pktlog, cds_pkt_size);
  443. cds_pktlog.version = VERSION_LOG_WLAN_PKT_LOG_INFO_C;
  444. cds_pktlog.buf_len = skb->len;
  445. cds_pktlog.seq_no = gwlan_logging.pkt_stats_msg_idx++;
  446. host_diag_log_set_code(&cds_pktlog, LOG_WLAN_PKT_LOG_INFO_C);
  447. host_diag_log_set_length(&cds_pktlog.log_hdr, skb->len +
  448. cds_pkt_size);
  449. if (unlikely(skb_headroom(skb) < cds_pkt_size)) {
  450. qdf_nofl_err("VPKT [%d]: Insufficient headroom, head[%pK], data[%pK], req[%zu]",
  451. __LINE__, skb->head, skb->data,
  452. sizeof(msg_header));
  453. return -EIO;
  454. }
  455. qdf_mem_copy(skb_push(skb, cds_pkt_size),
  456. &cds_pktlog, cds_pkt_size);
  457. if (unlikely(skb_headroom(skb) < sizeof(int))) {
  458. qdf_nofl_err("VPKT [%d]: Insufficient headroom, head[%pK], data[%pK], req[%zu]",
  459. __LINE__, skb->head, skb->data,
  460. sizeof(int));
  461. return -EIO;
  462. }
  463. diag_type = DIAG_TYPE_LOGS;
  464. qdf_mem_copy(skb_push(skb, sizeof(int)), &diag_type, sizeof(int));
  465. extra_header_len = sizeof(msg_header.radio) + sizeof(tAniHdr) +
  466. sizeof(struct nlmsghdr);
  467. nl_payload_len = extra_header_len + skb->len;
  468. msg_header.nlh.nlmsg_type = ANI_NL_MSG_PUMAC;
  469. msg_header.nlh.nlmsg_len = nl_payload_len;
  470. msg_header.nlh.nlmsg_flags = NLM_F_REQUEST;
  471. msg_header.nlh.nlmsg_pid = 0;
  472. msg_header.nlh.nlmsg_seq = nlmsg_seq++;
  473. msg_header.radio = 0;
  474. msg_header.wmsg.type = PTT_MSG_DIAG_CMDS_TYPE;
  475. msg_header.wmsg.length = cpu_to_be16(skb->len);
  476. if (unlikely(skb_headroom(skb) < sizeof(msg_header))) {
  477. qdf_nofl_err("VPKT [%d]: Insufficient headroom, head[%pK], data[%pK], req[%zu]",
  478. __LINE__, skb->head, skb->data,
  479. sizeof(msg_header));
  480. return -EIO;
  481. }
  482. qdf_mem_copy(skb_push(skb, sizeof(msg_header)), &msg_header,
  483. sizeof(msg_header));
  484. return 0;
  485. }
  486. /**
  487. * nl_srv_bcast_diag() - Wrapper to send bcast msgs to diag events mcast grp
  488. * @skb: sk buffer pointer
  489. *
  490. * Sends the bcast message to diag events multicast group with generic nl socket
  491. * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send.
  492. *
  493. * Return: zero on success, error code otherwise
  494. */
  495. static int nl_srv_bcast_diag(struct sk_buff *skb)
  496. {
  497. #ifdef CNSS_GENL
  498. return nl_srv_bcast(skb, CLD80211_MCGRP_DIAG_EVENTS, ANI_NL_MSG_PUMAC);
  499. #else
  500. return nl_srv_bcast(skb);
  501. #endif
  502. }
  503. /**
  504. * pktlog_send_per_pkt_stats_to_user() - This function is used to send the per
  505. * packet statistics to the user
  506. *
  507. * This function is used to send the per packet statistics to the user
  508. *
  509. * Return: Success if the message is posted to user
  510. */
  511. static int pktlog_send_per_pkt_stats_to_user(void)
  512. {
  513. int ret = -1;
  514. struct pkt_stats_msg *pstats_msg;
  515. unsigned long flags;
  516. struct sk_buff *skb_new = NULL;
  517. static int rate_limit;
  518. bool free_old_skb = false;
  519. while (!list_empty(&gwlan_logging.pkt_stat_filled_list)
  520. && !gwlan_logging.exit) {
  521. skb_new = dev_alloc_skb(MAX_SKBMSG_LENGTH);
  522. if (!skb_new) {
  523. if (!rate_limit) {
  524. qdf_err("dev_alloc_skb() failed for msg size[%d] drop count = %u",
  525. MAX_SKBMSG_LENGTH,
  526. gwlan_logging.drop_count);
  527. }
  528. rate_limit = 1;
  529. ret = -ENOMEM;
  530. break;
  531. }
  532. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags);
  533. pstats_msg = (struct pkt_stats_msg *)
  534. (gwlan_logging.pkt_stat_filled_list.next);
  535. list_del_init(gwlan_logging.pkt_stat_filled_list.next);
  536. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags);
  537. ret = pkt_stats_fill_headers(pstats_msg->skb);
  538. if (ret < 0) {
  539. qdf_err("Failed to fill headers %d", ret);
  540. free_old_skb = true;
  541. goto err;
  542. }
  543. ret = nl_srv_bcast_diag(pstats_msg->skb);
  544. if (ret < 0) {
  545. qdf_info("Send Failed %d drop_count = %u", ret,
  546. ++gwlan_logging.pkt_stat_drop_cnt);
  547. } else {
  548. ret = 0;
  549. }
  550. err:
  551. /*
  552. * Free old skb in case or error before assigning new skb
  553. * to the free list.
  554. */
  555. if (free_old_skb)
  556. dev_kfree_skb(pstats_msg->skb);
  557. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags);
  558. pstats_msg->skb = skb_new;
  559. list_add_tail(&pstats_msg->node,
  560. &gwlan_logging.pkt_stat_free_list);
  561. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags);
  562. ret = 0;
  563. }
  564. return ret;
  565. }
  566. #else
  567. static inline
  568. int pktlog_send_per_pkt_stats_to_user(void)
  569. {
  570. return 0;
  571. }
  572. #endif
  573. static int send_filled_buffers_to_user(void)
  574. {
  575. int ret = -1;
  576. struct log_msg *plog_msg;
  577. int payload_len;
  578. int tot_msg_len;
  579. tAniNlHdr *wnl;
  580. struct sk_buff *skb = NULL;
  581. struct nlmsghdr *nlh;
  582. static int nlmsg_seq;
  583. unsigned long flags;
  584. static int rate_limit;
  585. while (!list_empty(&gwlan_logging.filled_list)
  586. && !gwlan_logging.exit) {
  587. skb = dev_alloc_skb(MAX_LOGMSG_LENGTH);
  588. if (!skb) {
  589. if (!rate_limit) {
  590. qdf_err("dev_alloc_skb() failed for msg size[%d] drop count = %u",
  591. MAX_LOGMSG_LENGTH,
  592. gwlan_logging.drop_count);
  593. }
  594. rate_limit = 1;
  595. ret = -ENOMEM;
  596. break;
  597. }
  598. rate_limit = 0;
  599. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  600. plog_msg = (struct log_msg *)
  601. (gwlan_logging.filled_list.next);
  602. list_del_init(gwlan_logging.filled_list.next);
  603. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  604. /* 4 extra bytes for the radio idx */
  605. payload_len = plog_msg->filled_length +
  606. sizeof(wnl->radio) + sizeof(tAniHdr);
  607. tot_msg_len = NLMSG_SPACE(payload_len);
  608. nlh = nlmsg_put(skb, 0, nlmsg_seq++,
  609. ANI_NL_MSG_LOG, payload_len, NLM_F_REQUEST);
  610. if (!nlh) {
  611. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  612. list_add_tail(&plog_msg->node,
  613. &gwlan_logging.free_list);
  614. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  615. qdf_err("drop_count = %u", ++gwlan_logging.drop_count);
  616. qdf_err("nlmsg_put() failed for msg size[%d]",
  617. tot_msg_len);
  618. dev_kfree_skb(skb);
  619. skb = NULL;
  620. ret = -EINVAL;
  621. continue;
  622. }
  623. wnl = (tAniNlHdr *) nlh;
  624. wnl->radio = plog_msg->radio;
  625. memcpy(&wnl->wmsg, plog_msg->logbuf,
  626. plog_msg->filled_length + sizeof(tAniHdr));
  627. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  628. list_add_tail(&plog_msg->node, &gwlan_logging.free_list);
  629. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  630. ret = nl_srv_bcast_host_logs(skb);
  631. /* print every 64th drop count */
  632. if (ret < 0 && (!(gwlan_logging.drop_count % 0x40))) {
  633. qdf_err("Send Failed %d drop_count = %u",
  634. ret, ++gwlan_logging.drop_count);
  635. }
  636. }
  637. return ret;
  638. }
  639. #ifdef FEATURE_WLAN_DIAG_SUPPORT
  640. /**
  641. * wlan_report_log_completion() - Report bug report completion to userspace
  642. * @is_fatal: Type of event, fatal or not
  643. * @indicator: Source of bug report, framework/host/firmware
  644. * @reason_code: Reason for triggering bug report
  645. * @ring_id: Ring id of logging entities
  646. *
  647. * This function is used to report the bug report completion to userspace
  648. *
  649. * Return: None
  650. */
  651. void wlan_report_log_completion(uint32_t is_fatal,
  652. uint32_t indicator,
  653. uint32_t reason_code,
  654. uint8_t ring_id)
  655. {
  656. WLAN_HOST_DIAG_EVENT_DEF(wlan_diag_event,
  657. struct host_event_wlan_log_complete);
  658. wlan_diag_event.is_fatal = is_fatal;
  659. wlan_diag_event.indicator = indicator;
  660. wlan_diag_event.reason_code = reason_code;
  661. wlan_diag_event.reserved = ring_id;
  662. WLAN_HOST_DIAG_EVENT_REPORT(&wlan_diag_event, EVENT_WLAN_LOG_COMPLETE);
  663. }
  664. #endif
  665. #ifdef FEATURE_WLAN_DIAG_SUPPORT
  666. /**
  667. * send_flush_completion_to_user() - Indicate flush completion to the user
  668. * @ring_id: Ring id of logging entities
  669. *
  670. * This function is used to send the flush completion message to user space
  671. *
  672. * Return: None
  673. */
  674. static void send_flush_completion_to_user(uint8_t ring_id)
  675. {
  676. uint32_t is_fatal, indicator, reason_code;
  677. bool recovery_needed;
  678. cds_get_and_reset_log_completion(&is_fatal,
  679. &indicator, &reason_code, &recovery_needed);
  680. /* Error on purpose, so that it will get logged in the kmsg */
  681. LOGGING_TRACE(QDF_TRACE_LEVEL_DEBUG,
  682. "%s: Sending flush done to userspace reason code %d",
  683. __func__, reason_code);
  684. wlan_report_log_completion(is_fatal, indicator, reason_code, ring_id);
  685. if (recovery_needed)
  686. cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
  687. }
  688. #endif
  689. static void wlan_logging_set_flush_log_completion(void)
  690. {
  691. qdf_event_set(&gwlan_logging.flush_log_completion);
  692. }
  693. QDF_STATUS wlan_logging_wait_for_flush_log_completion(void)
  694. {
  695. qdf_event_reset(&gwlan_logging.flush_log_completion);
  696. return qdf_wait_for_event_completion(
  697. &gwlan_logging.flush_log_completion,
  698. FLUSH_LOG_COMPLETION_TIMEOUT);
  699. }
  700. static void setup_flush_timer(void)
  701. {
  702. qdf_spin_lock(&gwlan_logging.flush_timer_lock);
  703. if (!gwlan_logging.is_flush_timer_initialized ||
  704. (gwlan_logging.flush_timer_period == 0)) {
  705. qdf_spin_unlock(&gwlan_logging.flush_timer_lock);
  706. return;
  707. }
  708. qdf_timer_mod(&gwlan_logging.flush_timer,
  709. gwlan_logging.flush_timer_period);
  710. qdf_spin_unlock(&gwlan_logging.flush_timer_lock);
  711. }
  712. #ifdef WLAN_FEATURE_CONNECTIVITY_LOGGING
  713. static QDF_STATUS
  714. wlan_logging_send_connectivity_event(void)
  715. {
  716. return wlan_connectivity_log_dequeue();
  717. }
  718. #else
  719. static inline QDF_STATUS
  720. wlan_logging_send_connectivity_event(void)
  721. {
  722. return QDF_STATUS_E_NOSUPPORT;
  723. }
  724. #endif
  725. /**
  726. * wlan_logging_thread() - The WLAN Logger thread
  727. * @Arg - pointer to the HDD context
  728. *
  729. * This thread logs log message to App registered for the logs.
  730. */
  731. static int wlan_logging_thread(void *Arg)
  732. {
  733. int ret_wait_status = 0;
  734. int ret = 0;
  735. unsigned long flags;
  736. while (!gwlan_logging.exit) {
  737. setup_flush_timer();
  738. ret_wait_status =
  739. wait_event_interruptible(gwlan_logging.wait_queue,
  740. (!list_empty
  741. (&gwlan_logging.filled_list)
  742. || test_bit(
  743. HOST_LOG_DRIVER_MSG,
  744. &gwlan_logging.eventFlag)
  745. || test_bit(
  746. HOST_LOG_PER_PKT_STATS,
  747. &gwlan_logging.eventFlag)
  748. || test_bit(
  749. HOST_LOG_FW_FLUSH_COMPLETE,
  750. &gwlan_logging.eventFlag)
  751. || test_bit(
  752. HOST_LOG_DRIVER_CONNECTIVITY_MSG,
  753. &gwlan_logging.eventFlag)
  754. || gwlan_logging.exit));
  755. if (ret_wait_status == -ERESTARTSYS) {
  756. qdf_err("wait_event_interruptible returned -ERESTARTSYS");
  757. break;
  758. }
  759. if (gwlan_logging.exit)
  760. break;
  761. if (test_and_clear_bit(HOST_LOG_DRIVER_MSG,
  762. &gwlan_logging.eventFlag)) {
  763. ret = send_filled_buffers_to_user();
  764. if (-ENOMEM == ret)
  765. msleep(200);
  766. #ifdef FEATURE_WLAN_DIAG_SUPPORT
  767. if (WLAN_LOG_INDICATOR_HOST_ONLY ==
  768. cds_get_log_indicator()) {
  769. send_flush_completion_to_user(
  770. RING_ID_DRIVER_DEBUG);
  771. }
  772. #endif
  773. }
  774. if (test_and_clear_bit(HOST_LOG_PER_PKT_STATS,
  775. &gwlan_logging.eventFlag)) {
  776. ret = pktlog_send_per_pkt_stats_to_user();
  777. if (-ENOMEM == ret)
  778. msleep(200);
  779. }
  780. if (test_and_clear_bit(HOST_LOG_FW_FLUSH_COMPLETE,
  781. &gwlan_logging.eventFlag)) {
  782. /* Flush bit could have been set while we were mid
  783. * way in the logging thread. So, need to check other
  784. * buffers like log messages, per packet stats again
  785. * to flush any residual data in them
  786. */
  787. if (gwlan_logging.is_flush_complete == true) {
  788. gwlan_logging.is_flush_complete = false;
  789. #ifdef FEATURE_WLAN_DIAG_SUPPORT
  790. send_flush_completion_to_user(
  791. RING_ID_DRIVER_DEBUG);
  792. #endif
  793. wlan_logging_set_flush_log_completion();
  794. } else {
  795. gwlan_logging.is_flush_complete = true;
  796. /* Flush all current host logs*/
  797. spin_lock_irqsave(&gwlan_logging.spin_lock,
  798. flags);
  799. wlan_queue_logmsg_for_app();
  800. spin_unlock_irqrestore(&gwlan_logging.spin_lock,
  801. flags);
  802. set_bit(HOST_LOG_DRIVER_MSG,
  803. &gwlan_logging.eventFlag);
  804. set_bit(HOST_LOG_PER_PKT_STATS,
  805. &gwlan_logging.eventFlag);
  806. set_bit(HOST_LOG_FW_FLUSH_COMPLETE,
  807. &gwlan_logging.eventFlag);
  808. wake_up_interruptible(
  809. &gwlan_logging.wait_queue);
  810. }
  811. }
  812. /* Dequeue the connectivity_log */
  813. wlan_logging_send_connectivity_event();
  814. clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
  815. &gwlan_logging.eventFlag);
  816. }
  817. complete_and_exit(&gwlan_logging.shutdown_comp, 0);
  818. return 0;
  819. }
  820. void wlan_logging_set_active(bool active)
  821. {
  822. gwlan_logging.is_active = active;
  823. }
  824. void wlan_set_console_log_levels(uint32_t console_log_levels)
  825. {
  826. gwlan_logging.console_log_levels = console_log_levels;
  827. }
  828. qdf_export_symbol(wlan_set_console_log_levels);
  829. static void flush_log_buffers_timer(void *dummy)
  830. {
  831. wlan_flush_host_logs_for_fatal();
  832. }
  833. int wlan_logging_set_flush_timer(uint32_t milliseconds)
  834. {
  835. if (milliseconds > MAX_FLUSH_TIMER_PERIOD_VALUE) {
  836. QDF_TRACE_ERROR(QDF_MODULE_ID_QDF,
  837. "ERROR! value should be (0 - %d)\n",
  838. MAX_FLUSH_TIMER_PERIOD_VALUE);
  839. return -EINVAL;
  840. }
  841. if (!gwlan_logging.is_active) {
  842. QDF_TRACE_ERROR(QDF_MODULE_ID_QDF,
  843. "WLAN-Logging not active");
  844. return -EINVAL;
  845. }
  846. qdf_spin_lock(&gwlan_logging.flush_timer_lock);
  847. if (!gwlan_logging.is_flush_timer_initialized) {
  848. qdf_spin_unlock(&gwlan_logging.flush_timer_lock);
  849. return -EINVAL;
  850. }
  851. gwlan_logging.flush_timer_period = milliseconds;
  852. if (milliseconds) {
  853. qdf_timer_mod(&gwlan_logging.flush_timer,
  854. gwlan_logging.flush_timer_period);
  855. }
  856. qdf_spin_unlock(&gwlan_logging.flush_timer_lock);
  857. return 0;
  858. }
  859. static int panic_wifilog_ratelimit_print(void)
  860. {
  861. return __ratelimit(&panic_wifilog_ratelimit);
  862. }
  863. /**
  864. * wlan_logging_dump_last_logs() - Panic notifier callback's helper function
  865. *
  866. * This function prints buffered logs one line at a time.
  867. */
  868. static void wlan_logging_dump_last_logs(void)
  869. {
  870. char *log;
  871. struct log_msg *plog_msg;
  872. char textbuf[MAX_LOG_LINE];
  873. unsigned int filled_length;
  874. unsigned int text_len;
  875. unsigned long flags;
  876. /* Iterate over panic list */
  877. pr_err("\n");
  878. while (!list_empty(&gwlan_logging.panic_list)) {
  879. plog_msg = (struct log_msg *)
  880. (gwlan_logging.panic_list.next);
  881. list_del_init(gwlan_logging.panic_list.next);
  882. log = &plog_msg->logbuf[sizeof(tAniHdr)];
  883. filled_length = plog_msg->filled_length;
  884. while (filled_length) {
  885. text_len = qdf_str_copy_all_before_char(log, filled_length,
  886. textbuf,
  887. sizeof(textbuf) - 1,
  888. '\n');
  889. textbuf[text_len] = '\0';
  890. if (panic_wifilog_ratelimit_print())
  891. pr_err("%s\n", textbuf);
  892. if (log[text_len] == '\n')
  893. text_len += 1; /* skip newline */
  894. log += text_len;
  895. filled_length -= text_len;
  896. }
  897. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  898. list_add_tail(&plog_msg->node,
  899. &gwlan_logging.free_list);
  900. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  901. }
  902. }
  903. /**
  904. * wlan_logging_panic_handler() - Panic notifier callback
  905. *
  906. * This function extracts log buffers in filled list and
  907. * current node.Sends them to helper function for printing.
  908. */
  909. static int wlan_logging_panic_handler(struct notifier_block *this,
  910. unsigned long event, void *ptr)
  911. {
  912. char *log;
  913. struct log_msg *plog_msg;
  914. unsigned long flags;
  915. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  916. /* Iterate over nodes queued for app */
  917. while (!list_empty(&gwlan_logging.filled_list)) {
  918. plog_msg = (struct log_msg *)
  919. (gwlan_logging.filled_list.next);
  920. list_del_init(gwlan_logging.filled_list.next);
  921. list_add_tail(&plog_msg->node,
  922. &gwlan_logging.panic_list);
  923. }
  924. /* Check current node */
  925. if (gwlan_logging.pcur_node &&
  926. gwlan_logging.pcur_node->filled_length) {
  927. plog_msg = gwlan_logging.pcur_node;
  928. log = &plog_msg->logbuf[sizeof(tAniHdr)];
  929. log[plog_msg->filled_length] = '\0';
  930. list_add_tail(&gwlan_logging.pcur_node->node,
  931. &gwlan_logging.panic_list);
  932. if (!list_empty(&gwlan_logging.free_list)) {
  933. gwlan_logging.pcur_node =
  934. (struct log_msg *)(gwlan_logging.free_list.next);
  935. list_del_init(gwlan_logging.free_list.next);
  936. gwlan_logging.pcur_node->filled_length = 0;
  937. } else
  938. gwlan_logging.pcur_node = NULL;
  939. }
  940. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  941. wlan_logging_dump_last_logs();
  942. return NOTIFY_DONE;
  943. }
  944. static struct notifier_block panic_nb = {
  945. .notifier_call = wlan_logging_panic_handler,
  946. };
  947. int wlan_logging_notifier_init(bool dump_at_kernel_enable)
  948. {
  949. int ret;
  950. if (gwlan_logging.is_active &&
  951. !dump_at_kernel_enable) {
  952. ret = atomic_notifier_chain_register(&panic_notifier_list,
  953. &panic_nb);
  954. if (ret) {
  955. QDF_TRACE_ERROR(QDF_MODULE_ID_QDF,
  956. "Failed to register panic notifier");
  957. return -EINVAL;
  958. }
  959. }
  960. return 0;
  961. }
  962. int wlan_logging_notifier_deinit(bool dump_at_kernel_enable)
  963. {
  964. if (gwlan_logging.is_active &&
  965. !dump_at_kernel_enable) {
  966. atomic_notifier_chain_unregister(&panic_notifier_list,
  967. &panic_nb);
  968. }
  969. return 0;
  970. }
  971. static void flush_timer_init(void)
  972. {
  973. qdf_spinlock_create(&gwlan_logging.flush_timer_lock);
  974. qdf_timer_init(NULL, &gwlan_logging.flush_timer,
  975. flush_log_buffers_timer, NULL,
  976. QDF_TIMER_TYPE_SW);
  977. gwlan_logging.is_flush_timer_initialized = true;
  978. gwlan_logging.flush_timer_period = 0;
  979. }
  980. static void flush_timer_deinit(void)
  981. {
  982. gwlan_logging.is_flush_timer_initialized = false;
  983. qdf_spin_lock(&gwlan_logging.flush_timer_lock);
  984. qdf_timer_stop(&gwlan_logging.flush_timer);
  985. qdf_timer_free(&gwlan_logging.flush_timer);
  986. qdf_spin_unlock(&gwlan_logging.flush_timer_lock);
  987. qdf_spinlock_destroy(&gwlan_logging.flush_timer_lock);
  988. }
  989. int wlan_logging_sock_init_svc(void)
  990. {
  991. int i = 0, j, pkt_stats_size;
  992. unsigned long irq_flag;
  993. QDF_STATUS status;
  994. spin_lock_init(&gwlan_logging.spin_lock);
  995. spin_lock_init(&gwlan_logging.pkt_stats_lock);
  996. gwlan_logging.console_log_levels = 0;
  997. gwlan_logging.num_buf = MAX_LOGMSG_COUNT;
  998. gwlan_logging.buffer_length = MAX_LOGMSG_LENGTH;
  999. if (allocate_log_msg_buffer() != QDF_STATUS_SUCCESS) {
  1000. qdf_err("Could not allocate memory for log_msg");
  1001. return -ENOMEM;
  1002. }
  1003. spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag);
  1004. INIT_LIST_HEAD(&gwlan_logging.free_list);
  1005. INIT_LIST_HEAD(&gwlan_logging.filled_list);
  1006. INIT_LIST_HEAD(&gwlan_logging.panic_list);
  1007. for (i = 0; i < gwlan_logging.num_buf; i++) {
  1008. list_add(&gplog_msg[i].node, &gwlan_logging.free_list);
  1009. gplog_msg[i].index = i;
  1010. }
  1011. gwlan_logging.pcur_node = (struct log_msg *)
  1012. (gwlan_logging.free_list.next);
  1013. list_del_init(gwlan_logging.free_list.next);
  1014. spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag);
  1015. flush_timer_init();
  1016. /* Initialize the pktStats data structure here */
  1017. pkt_stats_size = sizeof(struct pkt_stats_msg);
  1018. gpkt_stats_buffers = qdf_mem_valloc(MAX_PKTSTATS_BUFF * pkt_stats_size);
  1019. if (!gpkt_stats_buffers) {
  1020. qdf_err("Could not allocate memory for Pkt stats");
  1021. goto err1;
  1022. }
  1023. qdf_mem_zero(gpkt_stats_buffers,
  1024. MAX_PKTSTATS_BUFF * pkt_stats_size);
  1025. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag);
  1026. gwlan_logging.pkt_stats_msg_idx = 0;
  1027. INIT_LIST_HEAD(&gwlan_logging.pkt_stat_free_list);
  1028. INIT_LIST_HEAD(&gwlan_logging.pkt_stat_filled_list);
  1029. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag);
  1030. for (i = 0; i < MAX_PKTSTATS_BUFF; i++) {
  1031. gpkt_stats_buffers[i].skb = dev_alloc_skb(MAX_PKTSTATS_LENGTH);
  1032. if (!gpkt_stats_buffers[i].skb) {
  1033. qdf_err("Memory alloc failed for skb");
  1034. /* free previously allocated skb and return */
  1035. for (j = 0; j < i ; j++)
  1036. dev_kfree_skb(gpkt_stats_buffers[j].skb);
  1037. goto err2;
  1038. }
  1039. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag);
  1040. list_add(&gpkt_stats_buffers[i].node,
  1041. &gwlan_logging.pkt_stat_free_list);
  1042. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag);
  1043. }
  1044. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag);
  1045. gwlan_logging.pkt_stats_pcur_node = (struct pkt_stats_msg *)
  1046. (gwlan_logging.pkt_stat_free_list.next);
  1047. list_del_init(gwlan_logging.pkt_stat_free_list.next);
  1048. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag);
  1049. /* Pkt Stats intialization done */
  1050. init_waitqueue_head(&gwlan_logging.wait_queue);
  1051. gwlan_logging.exit = false;
  1052. clear_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
  1053. clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
  1054. clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
  1055. clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
  1056. init_completion(&gwlan_logging.shutdown_comp);
  1057. gwlan_logging.thread = kthread_create(wlan_logging_thread, NULL,
  1058. "wlan_logging_thread");
  1059. if (IS_ERR(gwlan_logging.thread)) {
  1060. qdf_err("Could not Create LogMsg Thread Controller");
  1061. goto err3;
  1062. }
  1063. wake_up_process(gwlan_logging.thread);
  1064. gwlan_logging.is_active = true;
  1065. gwlan_logging.is_flush_complete = false;
  1066. status = qdf_event_create(&gwlan_logging.flush_log_completion);
  1067. if (!QDF_IS_STATUS_SUCCESS(status)) {
  1068. qdf_err("Flush log completion event init failed");
  1069. goto err3;
  1070. }
  1071. return 0;
  1072. err3:
  1073. for (i = 0; i < MAX_PKTSTATS_BUFF; i++) {
  1074. if (gpkt_stats_buffers[i].skb)
  1075. dev_kfree_skb(gpkt_stats_buffers[i].skb);
  1076. }
  1077. err2:
  1078. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag);
  1079. gwlan_logging.pkt_stats_pcur_node = NULL;
  1080. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag);
  1081. qdf_mem_vfree(gpkt_stats_buffers);
  1082. gpkt_stats_buffers = NULL;
  1083. err1:
  1084. flush_timer_deinit();
  1085. spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag);
  1086. gwlan_logging.pcur_node = NULL;
  1087. spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag);
  1088. free_log_msg_buffer();
  1089. return -ENOMEM;
  1090. }
  1091. int wlan_logging_sock_deinit_svc(void)
  1092. {
  1093. unsigned long irq_flag;
  1094. int i;
  1095. if (!gwlan_logging.pcur_node)
  1096. return 0;
  1097. qdf_event_destroy(&gwlan_logging.flush_log_completion);
  1098. INIT_COMPLETION(gwlan_logging.shutdown_comp);
  1099. gwlan_logging.exit = true;
  1100. gwlan_logging.is_active = false;
  1101. #if defined(FEATURE_FW_LOG_PARSING) || defined(FEATURE_WLAN_DIAG_SUPPORT)
  1102. cds_set_multicast_logging(0);
  1103. #endif
  1104. gwlan_logging.is_flush_complete = false;
  1105. clear_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
  1106. clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
  1107. clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
  1108. clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
  1109. wake_up_interruptible(&gwlan_logging.wait_queue);
  1110. wait_for_completion(&gwlan_logging.shutdown_comp);
  1111. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag);
  1112. gwlan_logging.pkt_stats_pcur_node = NULL;
  1113. gwlan_logging.pkt_stats_msg_idx = 0;
  1114. gwlan_logging.pkt_stat_drop_cnt = 0;
  1115. for (i = 0; i < MAX_PKTSTATS_BUFF; i++) {
  1116. if (gpkt_stats_buffers[i].skb)
  1117. dev_kfree_skb(gpkt_stats_buffers[i].skb);
  1118. }
  1119. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag);
  1120. qdf_mem_vfree(gpkt_stats_buffers);
  1121. gpkt_stats_buffers = NULL;
  1122. /* Delete the Flush timer then mark pcur_node NULL */
  1123. flush_timer_deinit();
  1124. spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag);
  1125. gwlan_logging.pcur_node = NULL;
  1126. spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag);
  1127. free_log_msg_buffer();
  1128. return 0;
  1129. }
  1130. /**
  1131. * wlan_logging_set_per_pkt_stats() - This function triggers per packet logging
  1132. *
  1133. * This function is used to send signal to the logger thread for logging per
  1134. * packet stats
  1135. *
  1136. * Return: None
  1137. *
  1138. */
  1139. void wlan_logging_set_per_pkt_stats(void)
  1140. {
  1141. if (gwlan_logging.is_active == false)
  1142. return;
  1143. set_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
  1144. wake_up_interruptible(&gwlan_logging.wait_queue);
  1145. }
  1146. void wlan_logging_set_connectivity_log(void)
  1147. {
  1148. if (gwlan_logging.is_active == false)
  1149. return;
  1150. set_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
  1151. wake_up_interruptible(&gwlan_logging.wait_queue);
  1152. }
  1153. /*
  1154. * wlan_logging_set_fw_flush_complete() - FW log flush completion
  1155. *
  1156. * This function is used to send signal to the logger thread to indicate
  1157. * that the flushing of FW logs is complete by the FW
  1158. *
  1159. * Return: None
  1160. *
  1161. */
  1162. void wlan_logging_set_fw_flush_complete(void)
  1163. {
  1164. if (!gwlan_logging.is_active)
  1165. return;
  1166. set_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
  1167. wake_up_interruptible(&gwlan_logging.wait_queue);
  1168. }
  1169. /**
  1170. * wlan_flush_host_logs_for_fatal() - Flush host logs
  1171. *
  1172. * This function is used to send signal to the logger thread to
  1173. * Flush the host logs
  1174. *
  1175. * Return: None
  1176. */
  1177. void wlan_flush_host_logs_for_fatal(void)
  1178. {
  1179. unsigned long flags;
  1180. if (gwlan_logging.flush_timer_period == 0)
  1181. qdf_info("Flush all host logs Setting HOST_LOG_POST_MAS");
  1182. spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
  1183. wlan_queue_logmsg_for_app();
  1184. spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
  1185. set_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
  1186. wake_up_interruptible(&gwlan_logging.wait_queue);
  1187. }
  1188. #ifdef FEATURE_PKTLOG
  1189. #ifndef REMOVE_PKT_LOG
  1190. static uint8_t gtx_count;
  1191. static uint8_t grx_count;
  1192. /**
  1193. * wlan_get_pkt_stats_free_node() - Get the free node for pkt stats
  1194. *
  1195. * This function is used to get the free node for pkt stats from
  1196. * free list/filles list
  1197. *
  1198. * Return: int
  1199. *
  1200. */
  1201. static int wlan_get_pkt_stats_free_node(void)
  1202. {
  1203. int ret = 0;
  1204. list_add_tail(&gwlan_logging.pkt_stats_pcur_node->node,
  1205. &gwlan_logging.pkt_stat_filled_list);
  1206. if (!list_empty(&gwlan_logging.pkt_stat_free_list)) {
  1207. /* Get buffer from free list */
  1208. gwlan_logging.pkt_stats_pcur_node =
  1209. (struct pkt_stats_msg *)(gwlan_logging.pkt_stat_free_list.next);
  1210. list_del_init(gwlan_logging.pkt_stat_free_list.next);
  1211. } else if (!list_empty(&gwlan_logging.pkt_stat_filled_list)) {
  1212. /* Get buffer from filled list. This condition will drop the
  1213. * packet from being indicated to app
  1214. */
  1215. gwlan_logging.pkt_stats_pcur_node =
  1216. (struct pkt_stats_msg *)
  1217. (gwlan_logging.pkt_stat_filled_list.next);
  1218. ++gwlan_logging.pkt_stat_drop_cnt;
  1219. /* print every 64th drop count */
  1220. if (
  1221. cds_is_multicast_logging() &&
  1222. (!(gwlan_logging.pkt_stat_drop_cnt % 0x40))) {
  1223. qdf_err("drop_count = %u",
  1224. gwlan_logging.pkt_stat_drop_cnt);
  1225. }
  1226. list_del_init(gwlan_logging.pkt_stat_filled_list.next);
  1227. ret = 1;
  1228. }
  1229. /* Reset the skb values, essential if dequeued from filled list */
  1230. skb_trim(gwlan_logging.pkt_stats_pcur_node->skb, 0);
  1231. return ret;
  1232. }
  1233. /**
  1234. * wlan_pkt_stats_to_logger_thread() - Add the pkt stats to SKB
  1235. * @pl_hdr: Pointer to pl_hdr
  1236. * @pkt_dump: Pointer to pkt_dump
  1237. * @data: Pointer to data
  1238. *
  1239. * This function adds the pktstats hdr and data to current
  1240. * skb node of free list.
  1241. *
  1242. * Return: None
  1243. */
  1244. void wlan_pkt_stats_to_logger_thread(void *pl_hdr, void *pkt_dump, void *data)
  1245. {
  1246. struct ath_pktlog_hdr *pktlog_hdr;
  1247. struct packet_dump *pkt_stats_dump;
  1248. int total_stats_len = 0;
  1249. bool wake_up_thread = false;
  1250. unsigned long flags;
  1251. struct sk_buff *ptr;
  1252. int hdr_size;
  1253. pktlog_hdr = (struct ath_pktlog_hdr *)pl_hdr;
  1254. if (!pktlog_hdr) {
  1255. qdf_err("Invalid pkt_stats_header");
  1256. return;
  1257. }
  1258. pkt_stats_dump = (struct packet_dump *)pkt_dump;
  1259. total_stats_len = sizeof(struct ath_pktlog_hdr) +
  1260. pktlog_hdr->size;
  1261. spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags);
  1262. if (!gwlan_logging.pkt_stats_pcur_node) {
  1263. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags);
  1264. return;
  1265. }
  1266. /* Check if we can accommodate more log into current node/buffer */
  1267. hdr_size = sizeof(struct host_log_pktlog_info) +
  1268. sizeof(tAniNlHdr);
  1269. if ((total_stats_len + hdr_size) >=
  1270. skb_tailroom(gwlan_logging.pkt_stats_pcur_node->skb)) {
  1271. wake_up_thread = true;
  1272. wlan_get_pkt_stats_free_node();
  1273. }
  1274. ptr = gwlan_logging.pkt_stats_pcur_node->skb;
  1275. qdf_mem_copy(skb_put(ptr,
  1276. sizeof(struct ath_pktlog_hdr)),
  1277. pktlog_hdr,
  1278. sizeof(struct ath_pktlog_hdr));
  1279. if (pkt_stats_dump) {
  1280. qdf_mem_copy(skb_put(ptr,
  1281. sizeof(struct packet_dump)),
  1282. pkt_stats_dump,
  1283. sizeof(struct packet_dump));
  1284. pktlog_hdr->size -= sizeof(struct packet_dump);
  1285. }
  1286. if (data)
  1287. qdf_mem_copy(skb_put(ptr,
  1288. pktlog_hdr->size),
  1289. data, pktlog_hdr->size);
  1290. if (pkt_stats_dump && pkt_stats_dump->type == STOP_MONITOR) {
  1291. wake_up_thread = true;
  1292. wlan_get_pkt_stats_free_node();
  1293. }
  1294. spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags);
  1295. /* Wakeup logger thread */
  1296. if (true == wake_up_thread) {
  1297. set_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
  1298. wake_up_interruptible(&gwlan_logging.wait_queue);
  1299. }
  1300. }
  1301. /**
  1302. * driver_hal_status_map() - maps driver to hal
  1303. * status
  1304. * @status: status to be mapped
  1305. *
  1306. * This function is used to map driver to hal status
  1307. *
  1308. * Return: None
  1309. *
  1310. */
  1311. static void driver_hal_status_map(uint8_t *status)
  1312. {
  1313. switch (*status) {
  1314. case tx_status_ok:
  1315. *status = TX_PKT_FATE_ACKED;
  1316. break;
  1317. case tx_status_discard:
  1318. *status = TX_PKT_FATE_DRV_DROP_OTHER;
  1319. break;
  1320. case tx_status_no_ack:
  1321. *status = TX_PKT_FATE_SENT;
  1322. break;
  1323. case tx_status_download_fail:
  1324. *status = TX_PKT_FATE_FW_QUEUED;
  1325. break;
  1326. default:
  1327. *status = TX_PKT_FATE_DRV_DROP_OTHER;
  1328. break;
  1329. }
  1330. }
  1331. /*
  1332. * send_packetdump() - send packet dump
  1333. * @soc: soc handle
  1334. * @vdev_id: ID of the virtual device handle
  1335. * @netbuf: netbuf
  1336. * @status: status of tx packet
  1337. * @type: type of packet
  1338. *
  1339. * This function is used to send packet dump to HAL layer
  1340. * using wlan_pkt_stats_to_logger_thread
  1341. *
  1342. * Return: None
  1343. *
  1344. */
  1345. static void send_packetdump(ol_txrx_soc_handle soc,
  1346. uint8_t vdev_id, qdf_nbuf_t netbuf,
  1347. uint8_t status, uint8_t type)
  1348. {
  1349. struct ath_pktlog_hdr pktlog_hdr = {0};
  1350. struct packet_dump pd_hdr = {0};
  1351. if (!netbuf) {
  1352. qdf_err("Invalid netbuf");
  1353. return;
  1354. }
  1355. /* Send packet dump only for STA interface */
  1356. if (wlan_op_mode_sta != cdp_get_opmode(soc, vdev_id))
  1357. return;
  1358. #if defined(HELIUMPLUS)
  1359. pktlog_hdr.flags |= PKTLOG_HDR_SIZE_16;
  1360. #endif
  1361. pktlog_hdr.log_type = PKTLOG_TYPE_PKT_DUMP;
  1362. pktlog_hdr.size = sizeof(pd_hdr) + netbuf->len;
  1363. pd_hdr.status = status;
  1364. pd_hdr.type = type;
  1365. pd_hdr.driver_ts = qdf_get_monotonic_boottime();
  1366. if ((type == TX_MGMT_PKT) || (type == TX_DATA_PKT))
  1367. gtx_count++;
  1368. else if ((type == RX_MGMT_PKT) || (type == RX_DATA_PKT))
  1369. grx_count++;
  1370. wlan_pkt_stats_to_logger_thread(&pktlog_hdr, &pd_hdr, netbuf->data);
  1371. }
  1372. /*
  1373. * send_packetdump_monitor() - sends start/stop packet dump indication
  1374. * @type: type of packet
  1375. *
  1376. * This function is used to indicate HAL layer to start/stop monitoring
  1377. * of packets
  1378. *
  1379. * Return: None
  1380. *
  1381. */
  1382. static void send_packetdump_monitor(uint8_t type)
  1383. {
  1384. struct ath_pktlog_hdr pktlog_hdr = {0};
  1385. struct packet_dump pd_hdr = {0};
  1386. #if defined(HELIUMPLUS)
  1387. pktlog_hdr.flags |= PKTLOG_HDR_SIZE_16;
  1388. #endif
  1389. pktlog_hdr.log_type = PKTLOG_TYPE_PKT_DUMP;
  1390. pktlog_hdr.size = sizeof(pd_hdr);
  1391. pd_hdr.type = type;
  1392. LOGGING_TRACE(QDF_TRACE_LEVEL_DEBUG,
  1393. "fate Tx-Rx %s: type: %d", __func__, type);
  1394. wlan_pkt_stats_to_logger_thread(&pktlog_hdr, &pd_hdr, NULL);
  1395. }
  1396. void wlan_deregister_txrx_packetdump(uint8_t pdev_id)
  1397. {
  1398. void *soc = cds_get_context(QDF_MODULE_ID_SOC);
  1399. if (!soc)
  1400. return;
  1401. if (gtx_count || grx_count) {
  1402. cdp_deregister_packetdump_cb(soc, pdev_id);
  1403. wma_deregister_packetdump_callback();
  1404. send_packetdump_monitor(STOP_MONITOR);
  1405. csr_packetdump_timer_stop();
  1406. gtx_count = 0;
  1407. grx_count = 0;
  1408. } else
  1409. LOGGING_TRACE(QDF_TRACE_LEVEL_DEBUG,
  1410. "%s: deregistered packetdump already", __func__);
  1411. }
  1412. /*
  1413. * check_txrx_packetdump_count() - function to check
  1414. * tx/rx packet dump global counts
  1415. * @pdev_id: datapath pdev identifier
  1416. *
  1417. * This function is used to check global counts of tx/rx
  1418. * packet dump functionality.
  1419. *
  1420. * Return: 1 if either gtx_count or grx_count reached 32
  1421. * 0 otherwise
  1422. *
  1423. */
  1424. static bool check_txrx_packetdump_count(uint8_t pdev_id)
  1425. {
  1426. if (gtx_count == MAX_NUM_PKT_LOG ||
  1427. grx_count == MAX_NUM_PKT_LOG) {
  1428. LOGGING_TRACE(QDF_TRACE_LEVEL_DEBUG,
  1429. "%s gtx_count: %d grx_count: %d deregister packetdump",
  1430. __func__, gtx_count, grx_count);
  1431. wlan_deregister_txrx_packetdump(pdev_id);
  1432. return 1;
  1433. }
  1434. return 0;
  1435. }
  1436. /*
  1437. * tx_packetdump_cb() - tx packet dump callback
  1438. * @soc: soc handle
  1439. * @pdev_id: datapath pdev id
  1440. * @vdev_id: vdev id
  1441. * @netbuf: netbuf
  1442. * @status: status of tx packet
  1443. * @type: packet type
  1444. *
  1445. * This function is used to send tx packet dump to HAL layer
  1446. * and deregister packet dump callbacks
  1447. *
  1448. * Return: None
  1449. *
  1450. */
  1451. static void tx_packetdump_cb(ol_txrx_soc_handle soc,
  1452. uint8_t pdev_id, uint8_t vdev_id,
  1453. qdf_nbuf_t netbuf,
  1454. uint8_t status, uint8_t type)
  1455. {
  1456. bool temp;
  1457. if (!soc)
  1458. return;
  1459. temp = check_txrx_packetdump_count(pdev_id);
  1460. if (temp)
  1461. return;
  1462. driver_hal_status_map(&status);
  1463. send_packetdump(soc, vdev_id, netbuf, status, type);
  1464. }
  1465. /*
  1466. * rx_packetdump_cb() - rx packet dump callback
  1467. * @soc: soc handle
  1468. * @pdev_id: datapath pdev id
  1469. * @vdev_id: vdev id
  1470. * @netbuf: netbuf
  1471. * @status: status of rx packet
  1472. * @type: packet type
  1473. *
  1474. * This function is used to send rx packet dump to HAL layer
  1475. * and deregister packet dump callbacks
  1476. *
  1477. * Return: None
  1478. *
  1479. */
  1480. static void rx_packetdump_cb(ol_txrx_soc_handle soc,
  1481. uint8_t pdev_id, uint8_t vdev_id,
  1482. qdf_nbuf_t netbuf,
  1483. uint8_t status, uint8_t type)
  1484. {
  1485. bool temp;
  1486. if (!soc)
  1487. return;
  1488. temp = check_txrx_packetdump_count(pdev_id);
  1489. if (temp)
  1490. return;
  1491. send_packetdump(soc, vdev_id, netbuf, status, type);
  1492. }
  1493. void wlan_register_txrx_packetdump(uint8_t pdev_id)
  1494. {
  1495. void *soc = cds_get_context(QDF_MODULE_ID_SOC);
  1496. if (!soc)
  1497. return;
  1498. cdp_register_packetdump_cb(soc, pdev_id,
  1499. tx_packetdump_cb, rx_packetdump_cb);
  1500. wma_register_packetdump_callback(tx_packetdump_cb,
  1501. rx_packetdump_cb);
  1502. send_packetdump_monitor(START_MONITOR);
  1503. gtx_count = 0;
  1504. grx_count = 0;
  1505. csr_packetdump_timer_start();
  1506. }
  1507. #endif /* REMOVE_PKT_LOG */
  1508. #endif /* FEATURE_PKTLOG */
  1509. #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */