blob: 260cdf3d09991498eb8a46512418f418f690a87d [file] [log] [blame]
Ravi Aravamudhanc8a192a2013-02-22 10:23:15 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Shalabh Jain1c99e4c2012-03-26 18:47:59 -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#ifndef DIAG_DCI_H
13#define DIAG_DCI_H
Shalabh Jain16794902012-09-14 10:56:49 -070014
15#define MAX_DCI_CLIENTS 10
16#define DCI_PKT_RSP_CODE 0x93
17#define DCI_DELAYED_RSP_CODE 0x94
18#define LOG_CMD_CODE 0x10
19#define EVENT_CMD_CODE 0x60
20#define DCI_PKT_RSP_TYPE 0
21#define DCI_LOG_TYPE -1
22#define DCI_EVENT_TYPE -2
23#define SET_LOG_MASK 1
24#define DISABLE_LOG_MASK 0
Ravi Aravamudhanc8a192a2013-02-22 10:23:15 -080025#define MAX_EVENT_SIZE 512
Mohit Aggarwal65b69cf2013-02-15 11:33:04 -080026#define DCI_CLIENT_INDEX_INVALID -1
27
Shalabh Jain16794902012-09-14 10:56:49 -070028
29/* 16 log code categories, each has:
30 * 1 bytes equip id + 1 dirty byte + 512 byte max log mask
31 */
32#define DCI_LOG_MASK_SIZE (16*514)
33#define DCI_EVENT_MASK_SIZE 512
34#define DCI_MASK_STREAM 2
35#define DCI_MAX_LOG_CODES 16
36#define DCI_MAX_ITEMS_PER_LOG_CODE 512
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070037
38extern unsigned int dci_max_reg;
39extern unsigned int dci_max_clients;
Mohit Aggarwal3aa45862013-03-05 18:37:58 +053040extern struct mutex dci_health_mutex;
Shalabh Jain16794902012-09-14 10:56:49 -070041
42struct dci_pkt_req_tracking_tbl {
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070043 int pid;
44 int uid;
45 int tag;
46};
47
Shalabh Jain16794902012-09-14 10:56:49 -070048struct diag_dci_client_tbl {
Shalabh Jain5e9a92b2012-06-07 21:53:49 -070049 struct task_struct *client;
50 uint16_t list; /* bit mask */
51 int signal_type;
Shalabh Jain16794902012-09-14 10:56:49 -070052 unsigned char dci_log_mask[DCI_LOG_MASK_SIZE];
53 unsigned char dci_event_mask[DCI_EVENT_MASK_SIZE];
54 unsigned char *dci_data;
55 int data_len;
56 int total_capacity;
57 int dropped_logs;
58 int dropped_events;
Shalabh Jaina1c69a42012-10-23 12:51:30 -070059 int received_logs;
60 int received_events;
61};
62
63/* This is used for DCI health stats */
64struct diag_dci_health_stats {
65 int dropped_logs;
66 int dropped_events;
67 int received_logs;
68 int received_events;
69 int reset_status;
Shalabh Jain5e9a92b2012-06-07 21:53:49 -070070};
71
Mohit Aggarwal3aa45862013-03-05 18:37:58 +053072/* This is used for querying DCI Log
73 or Event Mask */
74struct diag_log_event_stats {
75 uint16_t code;
76 int is_set;
77};
78
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070079enum {
80 DIAG_DCI_NO_ERROR = 1001, /* No error */
81 DIAG_DCI_NO_REG, /* Could not register */
82 DIAG_DCI_NO_MEM, /* Failed memory allocation */
83 DIAG_DCI_NOT_SUPPORTED, /* This particular client is not supported */
84 DIAG_DCI_HUGE_PACKET, /* Request/Response Packet too huge */
85 DIAG_DCI_SEND_DATA_FAIL,/* writing to kernel or peripheral fails */
86 DIAG_DCI_TABLE_ERR /* Error dealing with registration tables */
87};
88
89int diag_dci_init(void);
90void diag_dci_exit(void);
Dixon Peterson5a26a302012-11-15 17:26:17 -080091void diag_update_smd_dci_work_fn(struct work_struct *);
Dixon Peterson66fb11b2012-12-04 20:30:54 -080092void diag_dci_notify_client(int peripheral_mask, int data);
93int diag_process_smd_dci_read_data(struct diag_smd_info *smd_info, void *buf,
94 int recd_bytes);
Shalabh Jain16794902012-09-14 10:56:49 -070095int diag_process_dci_transaction(unsigned char *buf, int len);
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070096int diag_send_dci_pkt(struct diag_master_table entry, unsigned char *buf,
97 int len, int index);
Shalabh Jain16794902012-09-14 10:56:49 -070098void extract_dci_pkt_rsp(unsigned char *buf);
Mohit Aggarwal65b69cf2013-02-15 11:33:04 -080099int diag_dci_find_client_index(int client_id);
Shalabh Jain16794902012-09-14 10:56:49 -0700100/* DCI Log streaming functions */
101void create_dci_log_mask_tbl(unsigned char *tbl_buf);
Ravi Aravamudhanf70200e2013-02-13 10:05:36 -0800102void update_dci_cumulative_log_mask(int offset, unsigned int byte_index,
Ravi Aravamudhandf2947a2012-11-16 18:10:05 -0800103 uint8_t byte_mask);
Mohit Aggarwal65b69cf2013-02-15 11:33:04 -0800104void clear_client_dci_cumulative_log_mask(int client_index);
Dixon Peterson5a26a302012-11-15 17:26:17 -0800105int diag_send_dci_log_mask(smd_channel_t *ch);
Shalabh Jain16794902012-09-14 10:56:49 -0700106void extract_dci_log(unsigned char *buf);
Mohit Aggarwal3aa45862013-03-05 18:37:58 +0530107int diag_dci_clear_log_mask(void);
108int diag_dci_query_log_mask(uint16_t log_code);
Shalabh Jain16794902012-09-14 10:56:49 -0700109/* DCI event streaming functions */
Ravi Aravamudhandf2947a2012-11-16 18:10:05 -0800110void update_dci_cumulative_event_mask(int offset, uint8_t byte_mask);
Mohit Aggarwal65b69cf2013-02-15 11:33:04 -0800111void clear_client_dci_cumulative_event_mask(int client_index);
Dixon Peterson5a26a302012-11-15 17:26:17 -0800112int diag_send_dci_event_mask(smd_channel_t *ch);
Shalabh Jain16794902012-09-14 10:56:49 -0700113void extract_dci_events(unsigned char *buf);
114void create_dci_event_mask_tbl(unsigned char *tbl_buf);
Mohit Aggarwal3aa45862013-03-05 18:37:58 +0530115int diag_dci_clear_event_mask(void);
116int diag_dci_query_event_mask(uint16_t event_id);
Shalabh Jain1c99e4c2012-03-26 18:47:59 -0700117#endif