Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 1 | /* 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 Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 14 | |
| 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 Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 35 | |
| 36 | extern unsigned int dci_max_reg; |
| 37 | extern unsigned int dci_max_clients; |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 38 | |
| 39 | struct dci_pkt_req_tracking_tbl { |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 40 | int pid; |
| 41 | int uid; |
| 42 | int tag; |
| 43 | }; |
| 44 | |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 45 | struct diag_dci_client_tbl { |
Shalabh Jain | 5e9a92b | 2012-06-07 21:53:49 -0700 | [diff] [blame] | 46 | struct task_struct *client; |
| 47 | uint16_t list; /* bit mask */ |
| 48 | int signal_type; |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 49 | 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 Jain | d63ae31 | 2012-10-23 12:51:30 -0700 | [diff] [blame] | 56 | int received_logs; |
| 57 | int received_events; |
| 58 | }; |
| 59 | |
| 60 | /* This is used for DCI health stats */ |
| 61 | struct 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 Jain | 5e9a92b | 2012-06-07 21:53:49 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 69 | enum { |
| 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 | |
| 79 | int diag_dci_init(void); |
| 80 | void diag_dci_exit(void); |
Dixon Peterson | 0fbd2ac | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 81 | void diag_update_smd_dci_work_fn(struct work_struct *); |
Dixon Peterson | 2061f85 | 2013-01-22 17:53:05 -0800 | [diff] [blame] | 82 | void diag_dci_notify_client(int peripheral_mask, int data); |
| 83 | int diag_process_smd_dci_read_data(struct diag_smd_info *smd_info, void *buf, |
| 84 | int recd_bytes); |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 85 | int diag_process_dci_transaction(unsigned char *buf, int len); |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 86 | int diag_send_dci_pkt(struct diag_master_table entry, unsigned char *buf, |
| 87 | int len, int index); |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 88 | void extract_dci_pkt_rsp(unsigned char *buf); |
| 89 | /* DCI Log streaming functions */ |
| 90 | void create_dci_log_mask_tbl(unsigned char *tbl_buf); |
Ravi Aravamudhan | 6f8a15e | 2012-11-16 18:10:05 -0800 | [diff] [blame] | 91 | void update_dci_cumulative_log_mask(int offset, int byte_index, |
| 92 | uint8_t byte_mask); |
Dixon Peterson | 0fbd2ac | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 93 | int diag_send_dci_log_mask(smd_channel_t *ch); |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 94 | void extract_dci_log(unsigned char *buf); |
| 95 | /* DCI event streaming functions */ |
Ravi Aravamudhan | 6f8a15e | 2012-11-16 18:10:05 -0800 | [diff] [blame] | 96 | void update_dci_cumulative_event_mask(int offset, uint8_t byte_mask); |
Dixon Peterson | 0fbd2ac | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 97 | int diag_send_dci_event_mask(smd_channel_t *ch); |
Shalabh Jain | 14f480d | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 98 | void extract_dci_events(unsigned char *buf); |
| 99 | void create_dci_event_mask_tbl(unsigned char *tbl_buf); |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 100 | #endif |