blob: c9ae689e241eec317318dfa1d50be73725c1e02c [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>
Stephen Boyd73f8c492017-09-07 14:57:14 -070024#include <linux/device.h>
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070025#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
Manoj Prabhu B571cf422017-08-08 19:01:41 +053061#define DIAG_ID_ROOT_STRING "root"
62
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070063#define DIAG_CON_APSS (0x0001) /* Bit mask for APSS */
64#define DIAG_CON_MPSS (0x0002) /* Bit mask for MPSS */
65#define DIAG_CON_LPASS (0x0004) /* Bit mask for LPASS */
66#define DIAG_CON_WCNSS (0x0008) /* Bit mask for WCNSS */
67#define DIAG_CON_SENSORS (0x0010) /* Bit mask for Sensors */
Manoj Prabhu B571cf422017-08-08 19:01:41 +053068#define DIAG_CON_WDSP (0x0020) /* Bit mask for WDSP */
69#define DIAG_CON_CDSP (0x0040) /* Bit mask for CDSP */
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070070
Manoj Prabhu B571cf422017-08-08 19:01:41 +053071#define DIAG_CON_UPD_WLAN (0x1000) /*Bit mask for WLAN PD*/
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070072#define DIAG_CON_NONE (0x0000) /* Bit mask for No SS*/
73#define DIAG_CON_ALL (DIAG_CON_APSS | DIAG_CON_MPSS \
74 | DIAG_CON_LPASS | DIAG_CON_WCNSS \
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -070075 | DIAG_CON_SENSORS | DIAG_CON_WDSP \
76 | DIAG_CON_CDSP)
Manoj Prabhu B571cf422017-08-08 19:01:41 +053077#define DIAG_CON_UPD_ALL (DIAG_CON_UPD_WLAN)
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070078
79#define DIAG_STM_MODEM 0x01
80#define DIAG_STM_LPASS 0x02
81#define DIAG_STM_WCNSS 0x04
82#define DIAG_STM_APPS 0x08
83#define DIAG_STM_SENSORS 0x10
84#define DIAG_STM_WDSP 0x20
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -070085#define DIAG_STM_CDSP 0x40
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070086
87#define INVALID_PID -1
88#define DIAG_CMD_FOUND 1
89#define DIAG_CMD_NOT_FOUND 0
90#define DIAG_CMD_POLLING 1
91#define DIAG_CMD_NOT_POLLING 0
92#define DIAG_CMD_ADD 1
93#define DIAG_CMD_REMOVE 0
94
95#define DIAG_CMD_VERSION 0
96#define DIAG_CMD_ERROR 0x13
97#define DIAG_CMD_DOWNLOAD 0x3A
98#define DIAG_CMD_DIAG_SUBSYS 0x4B
99#define DIAG_CMD_LOG_CONFIG 0x73
100#define DIAG_CMD_LOG_ON_DMND 0x78
101#define DIAG_CMD_EXT_BUILD 0x7c
102#define DIAG_CMD_MSG_CONFIG 0x7D
103#define DIAG_CMD_GET_EVENT_MASK 0x81
104#define DIAG_CMD_SET_EVENT_MASK 0x82
105#define DIAG_CMD_EVENT_TOGGLE 0x60
106#define DIAG_CMD_NO_SUBSYS 0xFF
107#define DIAG_CMD_STATUS 0x0C
108#define DIAG_SS_WCDMA 0x04
109#define DIAG_CMD_QUERY_CALL 0x0E
110#define DIAG_SS_GSM 0x08
111#define DIAG_CMD_QUERY_TMC 0x02
112#define DIAG_SS_TDSCDMA 0x57
113#define DIAG_CMD_TDSCDMA_STATUS 0x0E
114#define DIAG_CMD_DIAG_SUBSYS_DELAY 0x80
115
116#define DIAG_SS_DIAG 0x12
117#define DIAG_SS_PARAMS 0x32
118#define DIAG_SS_FILE_READ_MODEM 0x0816
119#define DIAG_SS_FILE_READ_ADSP 0x0E10
120#define DIAG_SS_FILE_READ_WCNSS 0x141F
121#define DIAG_SS_FILE_READ_SLPI 0x01A18
122#define DIAG_SS_FILE_READ_APPS 0x020F
123
124#define DIAG_DIAG_MAX_PKT_SZ 0x55
125#define DIAG_DIAG_STM 0x214
126#define DIAG_DIAG_POLL 0x03
127#define DIAG_DEL_RSP_WRAP 0x04
128#define DIAG_DEL_RSP_WRAP_CNT 0x05
129#define DIAG_EXT_MOBILE_ID 0x06
130#define DIAG_GET_TIME_API 0x21B
131#define DIAG_SET_TIME_API 0x21C
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800132#define DIAG_GET_DIAG_ID 0x222
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700133#define DIAG_SWITCH_COMMAND 0x081B
134#define DIAG_BUFFERING_MODE 0x080C
135
136#define DIAG_CMD_OP_LOG_DISABLE 0
137#define DIAG_CMD_OP_GET_LOG_RANGE 1
138#define DIAG_CMD_OP_SET_LOG_MASK 3
139#define DIAG_CMD_OP_GET_LOG_MASK 4
140
141#define DIAG_CMD_OP_GET_SSID_RANGE 1
142#define DIAG_CMD_OP_GET_BUILD_MASK 2
143#define DIAG_CMD_OP_GET_MSG_MASK 3
144#define DIAG_CMD_OP_SET_MSG_MASK 4
145#define DIAG_CMD_OP_SET_ALL_MSG_MASK 5
146
147#define DIAG_CMD_OP_GET_MSG_ALLOC 0x33
148#define DIAG_CMD_OP_GET_MSG_DROP 0x30
149#define DIAG_CMD_OP_RESET_MSG_STATS 0x2F
150#define DIAG_CMD_OP_GET_LOG_ALLOC 0x31
151#define DIAG_CMD_OP_GET_LOG_DROP 0x2C
152#define DIAG_CMD_OP_RESET_LOG_STATS 0x2B
153#define DIAG_CMD_OP_GET_EVENT_ALLOC 0x32
154#define DIAG_CMD_OP_GET_EVENT_DROP 0x2E
155#define DIAG_CMD_OP_RESET_EVENT_STATS 0x2D
156
157#define DIAG_CMD_OP_HDLC_DISABLE 0x218
158
159#define BAD_PARAM_RESPONSE_MESSAGE 20
160
161#define PERSIST_TIME_SUCCESS 0
162#define PERSIST_TIME_FAILURE 1
163#define PERSIST_TIME_NOT_SUPPORTED 2
164
165#define MODE_CMD 41
166#define RESET_ID 2
167
168#define PKT_DROP 0
169#define PKT_ALLOC 1
170#define PKT_RESET 2
171
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530172#define FEATURE_MASK_LEN 4
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700173
174#define DIAG_MD_NONE 0
175#define DIAG_MD_PERIPHERAL 1
176
177/*
178 * The status bit masks when received in a signal handler are to be
179 * used in conjunction with the peripheral list bit mask to determine the
180 * status for a peripheral. For instance, 0x00010002 would denote an open
181 * status on the MPSS
182 */
183#define DIAG_STATUS_OPEN (0x00010000) /* DCI channel open status mask */
184#define DIAG_STATUS_CLOSED (0x00020000) /* DCI channel closed status mask */
185
186#define MODE_NONREALTIME 0
187#define MODE_REALTIME 1
188#define MODE_UNKNOWN 2
189
190#define DIAG_BUFFERING_MODE_STREAMING 0
191#define DIAG_BUFFERING_MODE_THRESHOLD 1
192#define DIAG_BUFFERING_MODE_CIRCULAR 2
193
194#define DIAG_MIN_WM_VAL 0
195#define DIAG_MAX_WM_VAL 100
196
197#define DEFAULT_LOW_WM_VAL 15
198#define DEFAULT_HIGH_WM_VAL 85
199
200#define TYPE_DATA 0
201#define TYPE_CNTL 1
202#define TYPE_DCI 2
203#define TYPE_CMD 3
204#define TYPE_DCI_CMD 4
205#define NUM_TYPES 5
206
207#define PERIPHERAL_MODEM 0
208#define PERIPHERAL_LPASS 1
209#define PERIPHERAL_WCNSS 2
210#define PERIPHERAL_SENSORS 3
211#define PERIPHERAL_WDSP 4
Sreelakshmi Gownipalli588a31d2016-11-02 13:33:43 -0700212#define PERIPHERAL_CDSP 5
213#define NUM_PERIPHERALS 6
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700214#define APPS_DATA (NUM_PERIPHERALS)
215
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530216#define UPD_WLAN 7
217#define NUM_UPD 1
218#define MAX_PERIPHERAL_UPD 1
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700219/* Number of sessions possible in Memory Device Mode. +1 for Apps data */
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530220#define NUM_MD_SESSIONS (NUM_PERIPHERALS \
221 + NUM_UPD + 1)
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700222
223#define MD_PERIPHERAL_MASK(x) (1 << x)
224
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530225#define MD_PERIPHERAL_PD_MASK(x) \
226 ((x == PERIPHERAL_MODEM) ? (1 << UPD_WLAN) : 0)\
227
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700228/*
229 * Number of stm processors includes all the peripherals and
230 * apps.Added 1 below to indicate apps
231 */
232#define NUM_STM_PROCESSORS (NUM_PERIPHERALS + 1)
233/*
234 * Indicates number of peripherals that can support DCI and Apps
235 * processor. This doesn't mean that a peripheral has the
236 * feature.
237 */
238#define NUM_DCI_PERIPHERALS (NUM_PERIPHERALS + 1)
239
240#define DIAG_PROC_DCI 1
241#define DIAG_PROC_MEMORY_DEVICE 2
242
243/* Flags to vote the DCI or Memory device process up or down
244 * when it becomes active or inactive.
245 */
246#define VOTE_DOWN 0
247#define VOTE_UP 1
248
249#define DIAG_TS_SIZE 50
250
251#define DIAG_MDM_BUF_SIZE 2048
252/* The Maximum request size is 2k + DCI header + footer (6 bytes) */
253#define DIAG_MDM_DCI_BUF_SIZE (2048 + 6)
254
255#define DIAG_LOCAL_PROC 0
256
257#ifndef CONFIG_DIAGFWD_BRIDGE_CODE
258/* Local Processor only */
259#define DIAG_NUM_PROC 1
260#else
261/* Local Processor + Remote Devices */
262#define DIAG_NUM_PROC (1 + NUM_REMOTE_DEV)
263#endif
264
265#define DIAG_WS_DCI 0
266#define DIAG_WS_MUX 1
267
268#define DIAG_DATA_TYPE 1
269#define DIAG_CNTL_TYPE 2
270#define DIAG_DCI_TYPE 3
271
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800272/*
273 * List of diag ids
274 * 0 is reserved for unknown diag id, 1 for apps, diag ids
275 * for remaining pds are assigned dynamically.
276 */
277#define DIAG_ID_UNKNOWN 0
278#define DIAG_ID_APPS 1
279
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700280/* List of remote processor supported */
281enum remote_procs {
282 MDM = 1,
283 MDM2 = 2,
284 QSC = 5,
285};
286
287struct diag_pkt_header_t {
288 uint8_t cmd_code;
289 uint8_t subsys_id;
290 uint16_t subsys_cmd_code;
291} __packed;
292
293struct diag_cmd_ext_mobile_rsp_t {
294 struct diag_pkt_header_t header;
295 uint8_t version;
296 uint8_t padding[3];
297 uint32_t family;
298 uint32_t chip_id;
299} __packed;
300
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800301struct diag_cmd_diag_id_query_req_t {
302 struct diag_pkt_header_t header;
303 uint8_t version;
304} __packed;
305
306struct diag_id_tbl_t {
307 struct list_head link;
308 uint8_t diag_id;
309 char *process_name;
310} __packed;
311struct diag_id_t {
312 uint8_t diag_id;
313 uint8_t len;
314 char *process_name;
315} __packed;
316
317struct diag_cmd_diag_id_query_rsp_t {
318 struct diag_pkt_header_t header;
319 uint8_t version;
320 uint8_t num_entries;
321 struct diag_id_t entry;
322} __packed;
323
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700324struct diag_cmd_time_sync_query_req_t {
325 struct diag_pkt_header_t header;
326 uint8_t version;
327};
328
329struct diag_cmd_time_sync_query_rsp_t {
330 struct diag_pkt_header_t header;
331 uint8_t version;
332 uint8_t time_api;
333};
334
335struct diag_cmd_time_sync_switch_req_t {
336 struct diag_pkt_header_t header;
337 uint8_t version;
338 uint8_t time_api;
339 uint8_t persist_time;
340};
341
342struct diag_cmd_time_sync_switch_rsp_t {
343 struct diag_pkt_header_t header;
344 uint8_t version;
345 uint8_t time_api;
346 uint8_t time_api_status;
347 uint8_t persist_time_status;
348};
349
350struct diag_cmd_reg_entry_t {
351 uint16_t cmd_code;
352 uint16_t subsys_id;
353 uint16_t cmd_code_lo;
354 uint16_t cmd_code_hi;
355} __packed;
356
357struct diag_cmd_reg_t {
358 struct list_head link;
359 struct diag_cmd_reg_entry_t entry;
360 uint8_t proc;
361 int pid;
362};
363
364/*
365 * @sync_obj_name: name of the synchronization object associated with this proc
366 * @count: number of entries in the bind
367 * @entries: the actual packet registrations
368 */
369struct diag_cmd_reg_tbl_t {
370 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
371 uint32_t count;
372 struct diag_cmd_reg_entry_t *entries;
373};
374
375struct diag_client_map {
376 char name[20];
377 int pid;
378};
379
380struct real_time_vote_t {
381 int client_id;
382 uint16_t proc;
383 uint8_t real_time_vote;
384} __packed;
385
386struct real_time_query_t {
387 int real_time;
388 int proc;
389} __packed;
390
391struct diag_buffering_mode_t {
392 uint8_t peripheral;
393 uint8_t mode;
394 uint8_t high_wm_val;
395 uint8_t low_wm_val;
396} __packed;
397
398struct diag_callback_reg_t {
399 int proc;
400} __packed;
401
402struct diag_ws_ref_t {
403 int ref_count;
404 int copy_count;
405 spinlock_t lock;
406};
407
408/* This structure is defined in USB header file */
409#ifndef CONFIG_DIAG_OVER_USB
410struct diag_request {
411 char *buf;
412 int length;
413 int actual;
414 int status;
415 void *context;
416};
417#endif
418
419struct diag_pkt_stats_t {
420 uint32_t alloc_count;
421 uint32_t drop_count;
422};
423
424struct diag_cmd_stats_rsp_t {
425 struct diag_pkt_header_t header;
426 uint32_t payload;
427};
428
429struct diag_cmd_hdlc_disable_rsp_t {
430 struct diag_pkt_header_t header;
431 uint8_t framing_version;
432 uint8_t result;
433};
434
435struct diag_pkt_frame_t {
436 uint8_t start;
437 uint8_t version;
438 uint16_t length;
439};
440
441struct diag_partial_pkt_t {
442 uint32_t total_len;
443 uint32_t read_len;
444 uint32_t remaining;
445 uint32_t capacity;
446 uint8_t processing;
447 unsigned char *data;
448} __packed;
449
450struct diag_logging_mode_param_t {
451 uint32_t req_mode;
452 uint32_t peripheral_mask;
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530453 uint32_t pd_mask;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700454 uint8_t mode_param;
455} __packed;
456
457struct diag_md_session_t {
458 int pid;
459 int peripheral_mask;
460 uint8_t hdlc_disabled;
461 struct timer_list hdlc_reset_timer;
462 struct diag_mask_info *msg_mask;
463 struct diag_mask_info *log_mask;
464 struct diag_mask_info *event_mask;
465 struct task_struct *task;
466};
467
468/*
469 * High level structure for storing Diag masks.
470 *
471 * @ptr: Pointer to the buffer that stores the masks
472 * @mask_len: Length of the buffer pointed by ptr
473 * @update_buf: Buffer for performing mask updates to peripherals
474 * @update_buf_len: Length of the buffer pointed by buf
475 * @status: status of the mask - all enable, disabled, valid
476 * @lock: To protect access to the mask variables
477 */
478struct diag_mask_info {
479 uint8_t *ptr;
480 int mask_len;
481 uint8_t *update_buf;
482 int update_buf_len;
483 uint8_t status;
484 struct mutex lock;
485};
486
487struct diag_md_proc_info {
488 int pid;
489 struct task_struct *socket_process;
490 struct task_struct *callback_process;
491 struct task_struct *mdlog_process;
492};
493
494struct diag_feature_t {
495 uint8_t feature_mask[FEATURE_MASK_LEN];
496 uint8_t rcvd_feature_mask;
497 uint8_t log_on_demand;
498 uint8_t separate_cmd_rsp;
499 uint8_t encode_hdlc;
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530500 uint8_t untag_header;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700501 uint8_t peripheral_buffering;
502 uint8_t mask_centralization;
503 uint8_t stm_support;
504 uint8_t sockets_enabled;
505 uint8_t sent_feature_mask;
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530506 uint8_t diag_id_support;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700507};
508
509struct diagchar_dev {
510
511 /* State for the char driver */
512 unsigned int major;
513 unsigned int minor_start;
514 int num;
515 struct cdev *cdev;
516 char *name;
517 struct class *diagchar_class;
518 struct device *diag_dev;
519 int ref_count;
520 int mask_clear;
521 struct mutex diag_maskclear_mutex;
Manoj Prabhu B2a428272016-12-22 15:22:03 +0530522 struct mutex diag_notifier_mutex;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700523 struct mutex diagchar_mutex;
524 struct mutex diag_file_mutex;
525 wait_queue_head_t wait_q;
526 struct diag_client_map *client_map;
527 int *data_ready;
528 int num_clients;
529 int polling_reg_flag;
530 int use_device_tree;
531 int supports_separate_cmdrsp;
532 int supports_apps_hdlc_encoding;
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530533 int supports_apps_header_untagging;
534 int peripheral_untag[NUM_PERIPHERALS];
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700535 int supports_sockets;
536 /* The state requested in the STM command */
537 int stm_state_requested[NUM_STM_PROCESSORS];
538 /* The current STM state */
539 int stm_state[NUM_STM_PROCESSORS];
540 uint16_t stm_peripheral;
541 struct work_struct stm_update_work;
542 uint16_t mask_update;
543 struct work_struct mask_update_work;
544 uint16_t close_transport;
545 struct work_struct close_transport_work;
546 struct workqueue_struct *cntl_wq;
547 struct mutex cntl_lock;
548 /* Whether or not the peripheral supports STM */
549 /* Delayed response Variables */
550 uint16_t delayed_rsp_id;
551 struct mutex delayed_rsp_mutex;
552 /* DCI related variables */
553 struct list_head dci_req_list;
554 struct list_head dci_client_list;
555 int dci_tag;
556 int dci_client_id;
557 struct mutex dci_mutex;
558 int num_dci_client;
559 unsigned char *apps_dci_buf;
560 int dci_state;
561 struct workqueue_struct *diag_dci_wq;
562 struct list_head cmd_reg_list;
Sreelakshmi Gownipalli8d477d32017-02-08 19:49:06 -0800563 struct list_head diag_id_list;
564 struct mutex diag_id_mutex;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700565 struct mutex cmd_reg_mutex;
566 uint32_t cmd_reg_count;
Manoj Prabhu B98325462017-01-10 20:19:28 +0530567 struct mutex diagfwd_channel_mutex[NUM_PERIPHERALS];
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700568 /* Sizes that reflect memory pool sizes */
569 unsigned int poolsize;
570 unsigned int poolsize_hdlc;
571 unsigned int poolsize_dci;
572 unsigned int poolsize_user;
573 /* Buffers for masks */
574 struct mutex diag_cntl_mutex;
575 /* Members for Sending response */
576 unsigned char *encoded_rsp_buf;
577 int encoded_rsp_len;
578 uint8_t rsp_buf_busy;
579 spinlock_t rsp_buf_busy_lock;
580 int rsp_buf_ctxt;
581 struct diagfwd_info *diagfwd_data[NUM_PERIPHERALS];
582 struct diagfwd_info *diagfwd_cntl[NUM_PERIPHERALS];
583 struct diagfwd_info *diagfwd_dci[NUM_PERIPHERALS];
584 struct diagfwd_info *diagfwd_cmd[NUM_PERIPHERALS];
585 struct diagfwd_info *diagfwd_dci_cmd[NUM_PERIPHERALS];
586 struct diag_feature_t feature[NUM_PERIPHERALS];
587 struct diag_buffering_mode_t buffering_mode[NUM_PERIPHERALS];
588 uint8_t buffering_flag[NUM_PERIPHERALS];
589 struct mutex mode_lock;
590 unsigned char *user_space_data_buf;
591 uint8_t user_space_data_busy;
592 struct diag_pkt_stats_t msg_stats;
593 struct diag_pkt_stats_t log_stats;
594 struct diag_pkt_stats_t event_stats;
595 /* buffer for updating mask to peripherals */
596 unsigned char *buf_feature_mask_update;
597 uint8_t hdlc_disabled;
598 struct mutex hdlc_disable_mutex;
Hardik Arya62dce9f2017-06-15 10:39:34 +0530599 struct mutex hdlc_recovery_mutex;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700600 struct timer_list hdlc_reset_timer;
601 struct mutex diag_hdlc_mutex;
602 unsigned char *hdlc_buf;
603 uint32_t hdlc_buf_len;
604 unsigned char *apps_rsp_buf;
605 struct diag_partial_pkt_t incoming_pkt;
606 int in_busy_pktdata;
607 /* Variables for non real time mode */
608 int real_time_mode[DIAG_NUM_PROC];
609 int real_time_update_busy;
610 uint16_t proc_active_mask;
611 uint16_t proc_rt_vote_mask[DIAG_NUM_PROC];
612 struct mutex real_time_mutex;
613 struct work_struct diag_real_time_work;
614 struct workqueue_struct *diag_real_time_wq;
615#ifdef CONFIG_DIAG_OVER_USB
616 int usb_connected;
617#endif
618 struct workqueue_struct *diag_wq;
619 struct work_struct diag_drain_work;
620 struct work_struct update_user_clients;
621 struct work_struct update_md_clients;
622 struct workqueue_struct *diag_cntl_wq;
623 uint8_t log_on_demand_support;
624 uint8_t *apps_req_buf;
625 uint32_t apps_req_buf_len;
626 uint8_t *dci_pkt_buf; /* For Apps DCI packets */
627 uint32_t dci_pkt_length;
628 int in_busy_dcipktdata;
629 int logging_mode;
630 int logging_mask;
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530631 int pd_logging_mode[NUM_UPD];
632 int pd_session_clear[NUM_UPD];
633 int num_pd_session;
634 int diag_id_sent[NUM_PERIPHERALS];
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700635 int mask_check;
636 uint32_t md_session_mask;
637 uint8_t md_session_mode;
638 struct diag_md_session_t *md_session_map[NUM_MD_SESSIONS];
639 struct mutex md_session_lock;
640 /* Power related variables */
641 struct diag_ws_ref_t dci_ws;
642 struct diag_ws_ref_t md_ws;
643 /* Pointers to Diag Masks */
644 struct diag_mask_info *msg_mask;
645 struct diag_mask_info *log_mask;
646 struct diag_mask_info *event_mask;
647 struct diag_mask_info *build_time_mask;
648 uint8_t msg_mask_tbl_count;
Gopikrishna Mogasati9a44d8d2017-05-05 16:04:35 +0530649 uint8_t bt_msg_mask_tbl_count;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700650 uint16_t event_mask_size;
651 uint16_t last_event_id;
Gopikrishna Mogasati9a44d8d2017-05-05 16:04:35 +0530652 struct mutex msg_mask_lock;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700653 /* Variables for Mask Centralization */
654 uint16_t num_event_id[NUM_PERIPHERALS];
655 uint32_t num_equip_id[NUM_PERIPHERALS];
656 uint32_t max_ssid_count[NUM_PERIPHERALS];
657#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
658 /* For sending command requests in callback mode */
659 unsigned char *hdlc_encode_buf;
660 int hdlc_encode_buf_len;
661#endif
662 int time_sync_enabled;
663 uint8_t uses_time_api;
664};
665
666extern struct diagchar_dev *driver;
667
668extern int wrap_enabled;
669extern uint16_t wrap_count;
670
671void diag_get_timestamp(char *time_str);
672void check_drain_timer(void);
673int diag_get_remote(int remote_info);
674
675void diag_ws_init(void);
676void diag_ws_on_notify(void);
677void diag_ws_on_read(int type, int pkt_len);
678void diag_ws_on_copy(int type);
679void diag_ws_on_copy_fail(int type);
680void diag_ws_on_copy_complete(int type);
681void diag_ws_reset(int type);
682void diag_ws_release(void);
683void chk_logging_wakeup(void);
684int diag_cmd_add_reg(struct diag_cmd_reg_entry_t *new_entry, uint8_t proc,
685 int pid);
686struct diag_cmd_reg_entry_t *diag_cmd_search(
687 struct diag_cmd_reg_entry_t *entry,
688 int proc);
689void diag_cmd_remove_reg(struct diag_cmd_reg_entry_t *entry, uint8_t proc);
690void diag_cmd_remove_reg_by_pid(int pid);
691void diag_cmd_remove_reg_by_proc(int proc);
692int diag_cmd_chk_polling(struct diag_cmd_reg_entry_t *entry);
Manoj Prabhu B95427a22016-11-04 11:58:11 +0530693int diag_mask_param(void);
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700694void diag_clear_masks(struct diag_md_session_t *info);
Manoj Prabhu B571cf422017-08-08 19:01:41 +0530695uint8_t diag_mask_to_pd_value(uint32_t peripheral_mask);
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -0700696
697void diag_record_stats(int type, int flag);
698
699struct diag_md_session_t *diag_md_session_get_pid(int pid);
700struct diag_md_session_t *diag_md_session_get_peripheral(uint8_t peripheral);
701
702#endif