blob: ea380fb477fccc2d26d3b08915dbbd3c8a524fc1 [file] [log] [blame]
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -08001/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef DIAGCHAR_H
14#define DIAGCHAR_H
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/mempool.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/spinlock.h>
22#include <linux/workqueue.h>
23#include <linux/sched.h>
24#include <linux/wakelock.h>
25#include <linux/atomic.h>
26#include "diagfwd_bridge.h"
27
28/* Size of the USB buffers used for read and write*/
29#define USB_MAX_OUT_BUF 4096
30#define APPS_BUF_SIZE 4096
31#define IN_BUF_SIZE 16384
32#define MAX_SYNC_OBJ_NAME_SIZE 32
33
34#define DIAG_MAX_REQ_SIZE (16 * 1024)
35#define DIAG_MAX_RSP_SIZE (16 * 1024)
36#define APF_DIAG_PADDING 256
37/*
38 * In the worst case, the HDLC buffer can be atmost twice the size of the
39 * original packet. Add 3 bytes for 16 bit CRC (2 bytes) and a delimiter
40 * (1 byte)
41 */
42#define DIAG_MAX_HDLC_BUF_SIZE ((DIAG_MAX_REQ_SIZE * 2) + 3)
43
44/* The header of callback data type has remote processor token (of type int) */
45#define CALLBACK_HDR_SIZE (sizeof(int))
46#define CALLBACK_BUF_SIZE (DIAG_MAX_REQ_SIZE + CALLBACK_HDR_SIZE)
47
48#define MAX_SSID_PER_RANGE 200
49
50#define ALL_PROC -1
51
52#define REMOTE_DATA 4
53
54#define USER_SPACE_DATA 16384
55
56#define DIAG_CTRL_MSG_LOG_MASK 9
57#define DIAG_CTRL_MSG_EVENT_MASK 10
58#define DIAG_CTRL_MSG_F3_MASK 11
59#define CONTROL_CHAR 0x7E
60
61#define DIAG_CON_APSS (0x0001) /* Bit mask for APSS */
62#define DIAG_CON_MPSS (0x0002) /* Bit mask for MPSS */
63#define DIAG_CON_LPASS (0x0004) /* Bit mask for LPASS */
64#define DIAG_CON_WCNSS (0x0008) /* Bit mask for WCNSS */
65#define DIAG_CON_SENSORS (0x0010) /* Bit mask for Sensors */
66#define DIAG_CON_WDSP (0x0020) /* Bit mask for WDSP */
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -070067#define DIAG_CON_CDSP (0x0040)
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070068
69#define DIAG_CON_NONE (0x0000) /* Bit mask for No SS*/
70#define DIAG_CON_ALL (DIAG_CON_APSS | DIAG_CON_MPSS \
71 | DIAG_CON_LPASS | DIAG_CON_WCNSS \
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -070072 | DIAG_CON_SENSORS | DIAG_CON_WDSP \
73 | DIAG_CON_CDSP)
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070074
75#define DIAG_STM_MODEM 0x01
76#define DIAG_STM_LPASS 0x02
77#define DIAG_STM_WCNSS 0x04
78#define DIAG_STM_APPS 0x08
79#define DIAG_STM_SENSORS 0x10
80#define DIAG_STM_WDSP 0x20
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -070081#define DIAG_STM_CDSP 0x40
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070082
83#define INVALID_PID -1
84#define DIAG_CMD_FOUND 1
85#define DIAG_CMD_NOT_FOUND 0
86#define DIAG_CMD_POLLING 1
87#define DIAG_CMD_NOT_POLLING 0
88#define DIAG_CMD_ADD 1
89#define DIAG_CMD_REMOVE 0
90
91#define DIAG_CMD_VERSION 0
92#define DIAG_CMD_ERROR 0x13
93#define DIAG_CMD_DOWNLOAD 0x3A
94#define DIAG_CMD_DIAG_SUBSYS 0x4B
95#define DIAG_CMD_LOG_CONFIG 0x73
96#define DIAG_CMD_LOG_ON_DMND 0x78
97#define DIAG_CMD_EXT_BUILD 0x7c
98#define DIAG_CMD_MSG_CONFIG 0x7D
99#define DIAG_CMD_GET_EVENT_MASK 0x81
100#define DIAG_CMD_SET_EVENT_MASK 0x82
101#define DIAG_CMD_EVENT_TOGGLE 0x60
102#define DIAG_CMD_NO_SUBSYS 0xFF
103#define DIAG_CMD_STATUS 0x0C
104#define DIAG_SS_WCDMA 0x04
105#define DIAG_CMD_QUERY_CALL 0x0E
106#define DIAG_SS_GSM 0x08
107#define DIAG_CMD_QUERY_TMC 0x02
108#define DIAG_SS_TDSCDMA 0x57
109#define DIAG_CMD_TDSCDMA_STATUS 0x0E
110#define DIAG_CMD_DIAG_SUBSYS_DELAY 0x80
111
112#define DIAG_SS_DIAG 0x12
113#define DIAG_SS_PARAMS 0x32
114#define DIAG_SS_FILE_READ_MODEM 0x0816
115#define DIAG_SS_FILE_READ_ADSP 0x0E10
116#define DIAG_SS_FILE_READ_WCNSS 0x141F
117#define DIAG_SS_FILE_READ_SLPI 0x01A18
118#define DIAG_SS_FILE_READ_APPS 0x020F
119
120#define DIAG_DIAG_MAX_PKT_SZ 0x55
121#define DIAG_DIAG_STM 0x214
122#define DIAG_DIAG_POLL 0x03
123#define DIAG_DEL_RSP_WRAP 0x04
124#define DIAG_DEL_RSP_WRAP_CNT 0x05
125#define DIAG_EXT_MOBILE_ID 0x06
126#define DIAG_GET_TIME_API 0x21B
127#define DIAG_SET_TIME_API 0x21C
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800128#define DIAG_GET_DIAG_ID 0x222
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700129#define DIAG_SWITCH_COMMAND 0x081B
130#define DIAG_BUFFERING_MODE 0x080C
131
132#define DIAG_CMD_OP_LOG_DISABLE 0
133#define DIAG_CMD_OP_GET_LOG_RANGE 1
134#define DIAG_CMD_OP_SET_LOG_MASK 3
135#define DIAG_CMD_OP_GET_LOG_MASK 4
136
137#define DIAG_CMD_OP_GET_SSID_RANGE 1
138#define DIAG_CMD_OP_GET_BUILD_MASK 2
139#define DIAG_CMD_OP_GET_MSG_MASK 3
140#define DIAG_CMD_OP_SET_MSG_MASK 4
141#define DIAG_CMD_OP_SET_ALL_MSG_MASK 5
142
143#define DIAG_CMD_OP_GET_MSG_ALLOC 0x33
144#define DIAG_CMD_OP_GET_MSG_DROP 0x30
145#define DIAG_CMD_OP_RESET_MSG_STATS 0x2F
146#define DIAG_CMD_OP_GET_LOG_ALLOC 0x31
147#define DIAG_CMD_OP_GET_LOG_DROP 0x2C
148#define DIAG_CMD_OP_RESET_LOG_STATS 0x2B
149#define DIAG_CMD_OP_GET_EVENT_ALLOC 0x32
150#define DIAG_CMD_OP_GET_EVENT_DROP 0x2E
151#define DIAG_CMD_OP_RESET_EVENT_STATS 0x2D
152
153#define DIAG_CMD_OP_HDLC_DISABLE 0x218
154
155#define BAD_PARAM_RESPONSE_MESSAGE 20
156
157#define PERSIST_TIME_SUCCESS 0
158#define PERSIST_TIME_FAILURE 1
159#define PERSIST_TIME_NOT_SUPPORTED 2
160
161#define MODE_CMD 41
162#define RESET_ID 2
163
164#define PKT_DROP 0
165#define PKT_ALLOC 1
166#define PKT_RESET 2
167
168#define FEATURE_MASK_LEN 2
169
170#define DIAG_MD_NONE 0
171#define DIAG_MD_PERIPHERAL 1
172
173/*
174 * The status bit masks when received in a signal handler are to be
175 * used in conjunction with the peripheral list bit mask to determine the
176 * status for a peripheral. For instance, 0x00010002 would denote an open
177 * status on the MPSS
178 */
179#define DIAG_STATUS_OPEN (0x00010000) /* DCI channel open status mask */
180#define DIAG_STATUS_CLOSED (0x00020000) /* DCI channel closed status mask */
181
182#define MODE_NONREALTIME 0
183#define MODE_REALTIME 1
184#define MODE_UNKNOWN 2
185
186#define DIAG_BUFFERING_MODE_STREAMING 0
187#define DIAG_BUFFERING_MODE_THRESHOLD 1
188#define DIAG_BUFFERING_MODE_CIRCULAR 2
189
190#define DIAG_MIN_WM_VAL 0
191#define DIAG_MAX_WM_VAL 100
192
193#define DEFAULT_LOW_WM_VAL 15
194#define DEFAULT_HIGH_WM_VAL 85
195
196#define TYPE_DATA 0
197#define TYPE_CNTL 1
198#define TYPE_DCI 2
199#define TYPE_CMD 3
200#define TYPE_DCI_CMD 4
201#define NUM_TYPES 5
202
203#define PERIPHERAL_MODEM 0
204#define PERIPHERAL_LPASS 1
205#define PERIPHERAL_WCNSS 2
206#define PERIPHERAL_SENSORS 3
207#define PERIPHERAL_WDSP 4
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -0700208#define PERIPHERAL_CDSP 5
209#define NUM_PERIPHERALS 6
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700210#define APPS_DATA (NUM_PERIPHERALS)
211
212/* Number of sessions possible in Memory Device Mode. +1 for Apps data */
213#define NUM_MD_SESSIONS (NUM_PERIPHERALS + 1)
214
215#define MD_PERIPHERAL_MASK(x) (1 << x)
216
217/*
218 * Number of stm processors includes all the peripherals and
219 * apps.Added 1 below to indicate apps
220 */
221#define NUM_STM_PROCESSORS (NUM_PERIPHERALS + 1)
222/*
223 * Indicates number of peripherals that can support DCI and Apps
224 * processor. This doesn't mean that a peripheral has the
225 * feature.
226 */
227#define NUM_DCI_PERIPHERALS (NUM_PERIPHERALS + 1)
228
229#define DIAG_PROC_DCI 1
230#define DIAG_PROC_MEMORY_DEVICE 2
231
232/* Flags to vote the DCI or Memory device process up or down
233 * when it becomes active or inactive.
234 */
235#define VOTE_DOWN 0
236#define VOTE_UP 1
237
238#define DIAG_TS_SIZE 50
239
240#define DIAG_MDM_BUF_SIZE 2048
241/* The Maximum request size is 2k + DCI header + footer (6 bytes) */
242#define DIAG_MDM_DCI_BUF_SIZE (2048 + 6)
243
244#define DIAG_LOCAL_PROC 0
245
246#ifndef CONFIG_DIAGFWD_BRIDGE_CODE
247/* Local Processor only */
248#define DIAG_NUM_PROC 1
249#else
250/* Local Processor + Remote Devices */
251#define DIAG_NUM_PROC (1 + NUM_REMOTE_DEV)
252#endif
253
254#define DIAG_WS_DCI 0
255#define DIAG_WS_MUX 1
256
257#define DIAG_DATA_TYPE 1
258#define DIAG_CNTL_TYPE 2
259#define DIAG_DCI_TYPE 3
260
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800261/*
262 * List of diag ids
263 * 0 is reserved for unknown diag id, 1 for apps, diag ids
264 * for remaining pds are assigned dynamically.
265 */
266#define DIAG_ID_UNKNOWN 0
267#define DIAG_ID_APPS 1
268
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700269/* List of remote processor supported */
270enum remote_procs {
271 MDM = 1,
272 MDM2 = 2,
273 QSC = 5,
274};
275
276struct diag_pkt_header_t {
277 uint8_t cmd_code;
278 uint8_t subsys_id;
279 uint16_t subsys_cmd_code;
280} __packed;
281
282struct diag_cmd_ext_mobile_rsp_t {
283 struct diag_pkt_header_t header;
284 uint8_t version;
285 uint8_t padding[3];
286 uint32_t family;
287 uint32_t chip_id;
288} __packed;
289
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800290struct diag_cmd_diag_id_query_req_t {
291 struct diag_pkt_header_t header;
292 uint8_t version;
293} __packed;
294
295struct diag_id_tbl_t {
296 struct list_head link;
297 uint8_t diag_id;
298 char *process_name;
299} __packed;
300struct diag_id_t {
301 uint8_t diag_id;
302 uint8_t len;
303 char *process_name;
304} __packed;
305
306struct diag_cmd_diag_id_query_rsp_t {
307 struct diag_pkt_header_t header;
308 uint8_t version;
309 uint8_t num_entries;
310 struct diag_id_t entry;
311} __packed;
312
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700313struct diag_cmd_time_sync_query_req_t {
314 struct diag_pkt_header_t header;
315 uint8_t version;
316};
317
318struct diag_cmd_time_sync_query_rsp_t {
319 struct diag_pkt_header_t header;
320 uint8_t version;
321 uint8_t time_api;
322};
323
324struct diag_cmd_time_sync_switch_req_t {
325 struct diag_pkt_header_t header;
326 uint8_t version;
327 uint8_t time_api;
328 uint8_t persist_time;
329};
330
331struct diag_cmd_time_sync_switch_rsp_t {
332 struct diag_pkt_header_t header;
333 uint8_t version;
334 uint8_t time_api;
335 uint8_t time_api_status;
336 uint8_t persist_time_status;
337};
338
339struct diag_cmd_reg_entry_t {
340 uint16_t cmd_code;
341 uint16_t subsys_id;
342 uint16_t cmd_code_lo;
343 uint16_t cmd_code_hi;
344} __packed;
345
346struct diag_cmd_reg_t {
347 struct list_head link;
348 struct diag_cmd_reg_entry_t entry;
349 uint8_t proc;
350 int pid;
351};
352
353/*
354 * @sync_obj_name: name of the synchronization object associated with this proc
355 * @count: number of entries in the bind
356 * @entries: the actual packet registrations
357 */
358struct diag_cmd_reg_tbl_t {
359 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
360 uint32_t count;
361 struct diag_cmd_reg_entry_t *entries;
362};
363
364struct diag_client_map {
365 char name[20];
366 int pid;
367};
368
369struct real_time_vote_t {
370 int client_id;
371 uint16_t proc;
372 uint8_t real_time_vote;
373} __packed;
374
375struct real_time_query_t {
376 int real_time;
377 int proc;
378} __packed;
379
380struct diag_buffering_mode_t {
381 uint8_t peripheral;
382 uint8_t mode;
383 uint8_t high_wm_val;
384 uint8_t low_wm_val;
385} __packed;
386
387struct diag_callback_reg_t {
388 int proc;
389} __packed;
390
391struct diag_ws_ref_t {
392 int ref_count;
393 int copy_count;
394 spinlock_t lock;
395};
396
397/* This structure is defined in USB header file */
398#ifndef CONFIG_DIAG_OVER_USB
399struct diag_request {
400 char *buf;
401 int length;
402 int actual;
403 int status;
404 void *context;
405};
406#endif
407
408struct diag_pkt_stats_t {
409 uint32_t alloc_count;
410 uint32_t drop_count;
411};
412
413struct diag_cmd_stats_rsp_t {
414 struct diag_pkt_header_t header;
415 uint32_t payload;
416};
417
418struct diag_cmd_hdlc_disable_rsp_t {
419 struct diag_pkt_header_t header;
420 uint8_t framing_version;
421 uint8_t result;
422};
423
424struct diag_pkt_frame_t {
425 uint8_t start;
426 uint8_t version;
427 uint16_t length;
428};
429
430struct diag_partial_pkt_t {
431 uint32_t total_len;
432 uint32_t read_len;
433 uint32_t remaining;
434 uint32_t capacity;
435 uint8_t processing;
436 unsigned char *data;
437} __packed;
438
439struct diag_logging_mode_param_t {
440 uint32_t req_mode;
441 uint32_t peripheral_mask;
442 uint8_t mode_param;
443} __packed;
444
445struct diag_md_session_t {
446 int pid;
447 int peripheral_mask;
448 uint8_t hdlc_disabled;
449 struct timer_list hdlc_reset_timer;
450 struct diag_mask_info *msg_mask;
451 struct diag_mask_info *log_mask;
452 struct diag_mask_info *event_mask;
453 struct task_struct *task;
454};
455
456/*
457 * High level structure for storing Diag masks.
458 *
459 * @ptr: Pointer to the buffer that stores the masks
460 * @mask_len: Length of the buffer pointed by ptr
461 * @update_buf: Buffer for performing mask updates to peripherals
462 * @update_buf_len: Length of the buffer pointed by buf
463 * @status: status of the mask - all enable, disabled, valid
464 * @lock: To protect access to the mask variables
465 */
466struct diag_mask_info {
467 uint8_t *ptr;
468 int mask_len;
469 uint8_t *update_buf;
470 int update_buf_len;
471 uint8_t status;
472 struct mutex lock;
473};
474
475struct diag_md_proc_info {
476 int pid;
477 struct task_struct *socket_process;
478 struct task_struct *callback_process;
479 struct task_struct *mdlog_process;
480};
481
482struct diag_feature_t {
483 uint8_t feature_mask[FEATURE_MASK_LEN];
484 uint8_t rcvd_feature_mask;
485 uint8_t log_on_demand;
486 uint8_t separate_cmd_rsp;
487 uint8_t encode_hdlc;
488 uint8_t peripheral_buffering;
489 uint8_t mask_centralization;
490 uint8_t stm_support;
491 uint8_t sockets_enabled;
492 uint8_t sent_feature_mask;
493};
494
495struct diagchar_dev {
496
497 /* State for the char driver */
498 unsigned int major;
499 unsigned int minor_start;
500 int num;
501 struct cdev *cdev;
502 char *name;
503 struct class *diagchar_class;
504 struct device *diag_dev;
505 int ref_count;
506 int mask_clear;
507 struct mutex diag_maskclear_mutex;
508 struct mutex diagchar_mutex;
509 struct mutex diag_file_mutex;
510 wait_queue_head_t wait_q;
511 struct diag_client_map *client_map;
512 int *data_ready;
513 int num_clients;
514 int polling_reg_flag;
515 int use_device_tree;
516 int supports_separate_cmdrsp;
517 int supports_apps_hdlc_encoding;
518 int supports_sockets;
519 /* The state requested in the STM command */
520 int stm_state_requested[NUM_STM_PROCESSORS];
521 /* The current STM state */
522 int stm_state[NUM_STM_PROCESSORS];
523 uint16_t stm_peripheral;
524 struct work_struct stm_update_work;
525 uint16_t mask_update;
526 struct work_struct mask_update_work;
527 uint16_t close_transport;
528 struct work_struct close_transport_work;
529 struct workqueue_struct *cntl_wq;
530 struct mutex cntl_lock;
531 /* Whether or not the peripheral supports STM */
532 /* Delayed response Variables */
533 uint16_t delayed_rsp_id;
534 struct mutex delayed_rsp_mutex;
535 /* DCI related variables */
536 struct list_head dci_req_list;
537 struct list_head dci_client_list;
538 int dci_tag;
539 int dci_client_id;
540 struct mutex dci_mutex;
541 int num_dci_client;
542 unsigned char *apps_dci_buf;
543 int dci_state;
544 struct workqueue_struct *diag_dci_wq;
545 struct list_head cmd_reg_list;
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800546 struct list_head diag_id_list;
547 struct mutex diag_id_mutex;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700548 struct mutex cmd_reg_mutex;
549 uint32_t cmd_reg_count;
550 struct mutex diagfwd_channel_mutex;
551 /* Sizes that reflect memory pool sizes */
552 unsigned int poolsize;
553 unsigned int poolsize_hdlc;
554 unsigned int poolsize_dci;
555 unsigned int poolsize_user;
556 /* Buffers for masks */
557 struct mutex diag_cntl_mutex;
558 /* Members for Sending response */
559 unsigned char *encoded_rsp_buf;
560 int encoded_rsp_len;
561 uint8_t rsp_buf_busy;
562 spinlock_t rsp_buf_busy_lock;
563 int rsp_buf_ctxt;
564 struct diagfwd_info *diagfwd_data[NUM_PERIPHERALS];
565 struct diagfwd_info *diagfwd_cntl[NUM_PERIPHERALS];
566 struct diagfwd_info *diagfwd_dci[NUM_PERIPHERALS];
567 struct diagfwd_info *diagfwd_cmd[NUM_PERIPHERALS];
568 struct diagfwd_info *diagfwd_dci_cmd[NUM_PERIPHERALS];
569 struct diag_feature_t feature[NUM_PERIPHERALS];
570 struct diag_buffering_mode_t buffering_mode[NUM_PERIPHERALS];
571 uint8_t buffering_flag[NUM_PERIPHERALS];
572 struct mutex mode_lock;
573 unsigned char *user_space_data_buf;
574 uint8_t user_space_data_busy;
575 struct diag_pkt_stats_t msg_stats;
576 struct diag_pkt_stats_t log_stats;
577 struct diag_pkt_stats_t event_stats;
578 /* buffer for updating mask to peripherals */
579 unsigned char *buf_feature_mask_update;
580 uint8_t hdlc_disabled;
581 struct mutex hdlc_disable_mutex;
582 struct timer_list hdlc_reset_timer;
583 struct mutex diag_hdlc_mutex;
584 unsigned char *hdlc_buf;
585 uint32_t hdlc_buf_len;
586 unsigned char *apps_rsp_buf;
587 struct diag_partial_pkt_t incoming_pkt;
588 int in_busy_pktdata;
589 /* Variables for non real time mode */
590 int real_time_mode[DIAG_NUM_PROC];
591 int real_time_update_busy;
592 uint16_t proc_active_mask;
593 uint16_t proc_rt_vote_mask[DIAG_NUM_PROC];
594 struct mutex real_time_mutex;
595 struct work_struct diag_real_time_work;
596 struct workqueue_struct *diag_real_time_wq;
597#ifdef CONFIG_DIAG_OVER_USB
598 int usb_connected;
599#endif
600 struct workqueue_struct *diag_wq;
601 struct work_struct diag_drain_work;
602 struct work_struct update_user_clients;
603 struct work_struct update_md_clients;
604 struct workqueue_struct *diag_cntl_wq;
605 uint8_t log_on_demand_support;
606 uint8_t *apps_req_buf;
607 uint32_t apps_req_buf_len;
608 uint8_t *dci_pkt_buf; /* For Apps DCI packets */
609 uint32_t dci_pkt_length;
610 int in_busy_dcipktdata;
611 int logging_mode;
612 int logging_mask;
613 int mask_check;
614 uint32_t md_session_mask;
615 uint8_t md_session_mode;
616 struct diag_md_session_t *md_session_map[NUM_MD_SESSIONS];
617 struct mutex md_session_lock;
618 /* Power related variables */
619 struct diag_ws_ref_t dci_ws;
620 struct diag_ws_ref_t md_ws;
621 /* Pointers to Diag Masks */
622 struct diag_mask_info *msg_mask;
623 struct diag_mask_info *log_mask;
624 struct diag_mask_info *event_mask;
625 struct diag_mask_info *build_time_mask;
626 uint8_t msg_mask_tbl_count;
627 uint16_t event_mask_size;
628 uint16_t last_event_id;
629 /* Variables for Mask Centralization */
630 uint16_t num_event_id[NUM_PERIPHERALS];
631 uint32_t num_equip_id[NUM_PERIPHERALS];
632 uint32_t max_ssid_count[NUM_PERIPHERALS];
633#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
634 /* For sending command requests in callback mode */
635 unsigned char *hdlc_encode_buf;
636 int hdlc_encode_buf_len;
637#endif
638 int time_sync_enabled;
639 uint8_t uses_time_api;
640};
641
642extern struct diagchar_dev *driver;
643
644extern int wrap_enabled;
645extern uint16_t wrap_count;
646
647void diag_get_timestamp(char *time_str);
648void check_drain_timer(void);
649int diag_get_remote(int remote_info);
650
651void diag_ws_init(void);
652void diag_ws_on_notify(void);
653void diag_ws_on_read(int type, int pkt_len);
654void diag_ws_on_copy(int type);
655void diag_ws_on_copy_fail(int type);
656void diag_ws_on_copy_complete(int type);
657void diag_ws_reset(int type);
658void diag_ws_release(void);
659void chk_logging_wakeup(void);
660int diag_cmd_add_reg(struct diag_cmd_reg_entry_t *new_entry, uint8_t proc,
661 int pid);
662struct diag_cmd_reg_entry_t *diag_cmd_search(
663 struct diag_cmd_reg_entry_t *entry,
664 int proc);
665void diag_cmd_remove_reg(struct diag_cmd_reg_entry_t *entry, uint8_t proc);
666void diag_cmd_remove_reg_by_pid(int pid);
667void diag_cmd_remove_reg_by_proc(int proc);
668int diag_cmd_chk_polling(struct diag_cmd_reg_entry_t *entry);
669void diag_clear_masks(struct diag_md_session_t *info);
670
671void diag_record_stats(int type, int flag);
672
673struct diag_md_session_t *diag_md_session_get_pid(int pid);
674struct diag_md_session_t *diag_md_session_get_peripheral(uint8_t peripheral);
675
676#endif