Ravi Aravamudhan | c8a192a | 2013-02-22 10:23:15 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 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 | 1679490 | 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 |
Ravi Aravamudhan | c8a192a | 2013-02-22 10:23:15 -0800 | [diff] [blame] | 25 | #define MAX_EVENT_SIZE 512 |
Mohit Aggarwal | 65b69cf | 2013-02-15 11:33:04 -0800 | [diff] [blame] | 26 | #define DCI_CLIENT_INDEX_INVALID -1 |
| 27 | |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 28 | |
| 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 Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 37 | |
| 38 | extern unsigned int dci_max_reg; |
| 39 | extern unsigned int dci_max_clients; |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 40 | extern struct mutex dci_health_mutex; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 41 | |
| 42 | struct dci_pkt_req_tracking_tbl { |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 43 | int pid; |
| 44 | int uid; |
| 45 | int tag; |
| 46 | }; |
| 47 | |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 48 | struct diag_dci_client_tbl { |
Shalabh Jain | 5e9a92b | 2012-06-07 21:53:49 -0700 | [diff] [blame] | 49 | struct task_struct *client; |
| 50 | uint16_t list; /* bit mask */ |
| 51 | int signal_type; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 52 | 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 Jain | a1c69a4 | 2012-10-23 12:51:30 -0700 | [diff] [blame] | 59 | int received_logs; |
| 60 | int received_events; |
| 61 | }; |
| 62 | |
| 63 | /* This is used for DCI health stats */ |
| 64 | struct 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 Jain | 5e9a92b | 2012-06-07 21:53:49 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 72 | /* This is used for querying DCI Log |
| 73 | or Event Mask */ |
| 74 | struct diag_log_event_stats { |
| 75 | uint16_t code; |
| 76 | int is_set; |
| 77 | }; |
| 78 | |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 79 | enum { |
| 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 | |
| 89 | int diag_dci_init(void); |
| 90 | void diag_dci_exit(void); |
Dixon Peterson | 5a26a30 | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 91 | void diag_update_smd_dci_work_fn(struct work_struct *); |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 92 | void diag_dci_notify_client(int peripheral_mask, int data); |
| 93 | int diag_process_smd_dci_read_data(struct diag_smd_info *smd_info, void *buf, |
| 94 | int recd_bytes); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 95 | int diag_process_dci_transaction(unsigned char *buf, int len); |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 96 | int diag_send_dci_pkt(struct diag_master_table entry, unsigned char *buf, |
| 97 | int len, int index); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 98 | void extract_dci_pkt_rsp(unsigned char *buf); |
Mohit Aggarwal | 65b69cf | 2013-02-15 11:33:04 -0800 | [diff] [blame] | 99 | int diag_dci_find_client_index(int client_id); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 100 | /* DCI Log streaming functions */ |
| 101 | void create_dci_log_mask_tbl(unsigned char *tbl_buf); |
Ravi Aravamudhan | f70200e | 2013-02-13 10:05:36 -0800 | [diff] [blame] | 102 | void update_dci_cumulative_log_mask(int offset, unsigned int byte_index, |
Ravi Aravamudhan | df2947a | 2012-11-16 18:10:05 -0800 | [diff] [blame] | 103 | uint8_t byte_mask); |
Mohit Aggarwal | 65b69cf | 2013-02-15 11:33:04 -0800 | [diff] [blame] | 104 | void clear_client_dci_cumulative_log_mask(int client_index); |
Dixon Peterson | 5a26a30 | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 105 | int diag_send_dci_log_mask(smd_channel_t *ch); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 106 | void extract_dci_log(unsigned char *buf); |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 107 | int diag_dci_clear_log_mask(void); |
| 108 | int diag_dci_query_log_mask(uint16_t log_code); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 109 | /* DCI event streaming functions */ |
Ravi Aravamudhan | df2947a | 2012-11-16 18:10:05 -0800 | [diff] [blame] | 110 | void update_dci_cumulative_event_mask(int offset, uint8_t byte_mask); |
Mohit Aggarwal | 65b69cf | 2013-02-15 11:33:04 -0800 | [diff] [blame] | 111 | void clear_client_dci_cumulative_event_mask(int client_index); |
Dixon Peterson | 5a26a30 | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 112 | int diag_send_dci_event_mask(smd_channel_t *ch); |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 113 | void extract_dci_events(unsigned char *buf); |
| 114 | void create_dci_event_mask_tbl(unsigned char *tbl_buf); |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 115 | int diag_dci_clear_event_mask(void); |
| 116 | int diag_dci_query_event_mask(uint16_t event_id); |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 117 | #endif |