blob: af89ac8dcc63979073f16eb72e6f1459371455dc [file] [log] [blame]
Shalabh Jain1c99e4c2012-03-26 18:47:59 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
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 Jain14f480d2012-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
25#define MAX_EVENT_SIZE 100
26
27/* 16 log code categories, each has:
28 * 1 bytes equip id + 1 dirty byte + 512 byte max log mask
29 */
30#define DCI_LOG_MASK_SIZE (16*514)
31#define DCI_EVENT_MASK_SIZE 512
32#define DCI_MASK_STREAM 2
33#define DCI_MAX_LOG_CODES 16
34#define DCI_MAX_ITEMS_PER_LOG_CODE 512
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070035
36extern unsigned int dci_max_reg;
37extern unsigned int dci_max_clients;
Shalabh Jain14f480d2012-09-14 10:56:49 -070038
39struct dci_pkt_req_tracking_tbl {
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070040 int pid;
41 int uid;
42 int tag;
43};
44
Shalabh Jain14f480d2012-09-14 10:56:49 -070045struct diag_dci_client_tbl {
Shalabh Jain5e9a92b2012-06-07 21:53:49 -070046 struct task_struct *client;
47 uint16_t list; /* bit mask */
48 int signal_type;
Shalabh Jain14f480d2012-09-14 10:56:49 -070049 unsigned char dci_log_mask[DCI_LOG_MASK_SIZE];
50 unsigned char dci_event_mask[DCI_EVENT_MASK_SIZE];
51 unsigned char *dci_data;
52 int data_len;
53 int total_capacity;
54 int dropped_logs;
55 int dropped_events;
Shalabh Jaind63ae312012-10-23 12:51:30 -070056 int received_logs;
57 int received_events;
58};
59
60/* This is used for DCI health stats */
61struct diag_dci_health_stats {
62 int dropped_logs;
63 int dropped_events;
64 int received_logs;
65 int received_events;
66 int reset_status;
Shalabh Jain5e9a92b2012-06-07 21:53:49 -070067};
68
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070069enum {
70 DIAG_DCI_NO_ERROR = 1001, /* No error */
71 DIAG_DCI_NO_REG, /* Could not register */
72 DIAG_DCI_NO_MEM, /* Failed memory allocation */
73 DIAG_DCI_NOT_SUPPORTED, /* This particular client is not supported */
74 DIAG_DCI_HUGE_PACKET, /* Request/Response Packet too huge */
75 DIAG_DCI_SEND_DATA_FAIL,/* writing to kernel or peripheral fails */
76 DIAG_DCI_TABLE_ERR /* Error dealing with registration tables */
77};
78
79int diag_dci_init(void);
80void diag_dci_exit(void);
Dixon Peterson0fbd2ac2012-11-15 17:26:17 -080081void diag_update_smd_dci_work_fn(struct work_struct *);
Dixon Peterson2061f852013-01-22 17:53:05 -080082void diag_dci_notify_client(int peripheral_mask, int data);
83int diag_process_smd_dci_read_data(struct diag_smd_info *smd_info, void *buf,
84 int recd_bytes);
Shalabh Jain14f480d2012-09-14 10:56:49 -070085int diag_process_dci_transaction(unsigned char *buf, int len);
Shalabh Jain1c99e4c2012-03-26 18:47:59 -070086int diag_send_dci_pkt(struct diag_master_table entry, unsigned char *buf,
87 int len, int index);
Shalabh Jain14f480d2012-09-14 10:56:49 -070088void extract_dci_pkt_rsp(unsigned char *buf);
89/* DCI Log streaming functions */
90void create_dci_log_mask_tbl(unsigned char *tbl_buf);
Ravi Aravamudhan6f8a15e2012-11-16 18:10:05 -080091void update_dci_cumulative_log_mask(int offset, int byte_index,
92 uint8_t byte_mask);
Dixon Peterson0fbd2ac2012-11-15 17:26:17 -080093int diag_send_dci_log_mask(smd_channel_t *ch);
Shalabh Jain14f480d2012-09-14 10:56:49 -070094void extract_dci_log(unsigned char *buf);
95/* DCI event streaming functions */
Ravi Aravamudhan6f8a15e2012-11-16 18:10:05 -080096void update_dci_cumulative_event_mask(int offset, uint8_t byte_mask);
Dixon Peterson0fbd2ac2012-11-15 17:26:17 -080097int diag_send_dci_event_mask(smd_channel_t *ch);
Shalabh Jain14f480d2012-09-14 10:56:49 -070098void extract_dci_events(unsigned char *buf);
99void create_dci_event_mask_tbl(unsigned char *tbl_buf);
Shalabh Jain1c99e4c2012-03-26 18:47:59 -0700100#endif