Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 1 | #ifndef protocol_h |
| 2 | #define protocol_h |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Harald Welte | bd44858 | 2016-12-23 23:41:14 +0100 | [diff] [blame] | 6 | struct msgb; |
| 7 | |
Harald Welte | 272b4ae | 2016-12-23 23:28:28 +0100 | [diff] [blame] | 8 | /* From Qualcomm Linux kernel diagchar.h */ |
| 9 | #define DIAG_MAX_REQ_SIZE (16 * 1024) |
| 10 | #define DIAG_MAX_HDLC_BUF_SIZE ((DIAG_MAX_REQ_SIZE * 2) + 3) |
| 11 | #define HDLC_FOOTER_LEN 3 |
| 12 | |
| 13 | |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 14 | /* |
| 15 | * 79 00 03 00 06 00 9C 76 B6 07 00 00 D4 00 00 00 y......v¶...Ô... |
| 16 | * 02 00 00 00 39 00 00 00 63 F9 FF FF 00 00 00 00 ....9...cùÿÿ.... |
| 17 | * 41 43 51 20 53 74 61 72 74 65 64 2C 20 41 52 46 ACQ.Started,.ARF |
| 18 | * 43 4E 3D 25 64 2C 20 52 78 50 57 52 78 31 36 3D CN=%d,.RxPWRx16= |
| 19 | * 25 64 00 6C 31 5F 61 63 71 2E 63 00 %d.l1_acq.c. |
| 20 | */ |
| 21 | |
Harald Welte | 654f117 | 2016-12-24 00:01:25 +0100 | [diff] [blame] | 22 | /*********************************************************************** |
| 23 | * Extended Message Service (DIAG_EXT_MSG_F) |
| 24 | ***********************************************************************/ |
| 25 | |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 26 | struct ext_log_msg { |
Harald Welte | cd877f1 | 2016-12-23 20:04:27 +0100 | [diff] [blame] | 27 | /* msg_hdr_type equivalent */ |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 28 | uint8_t type; |
Harald Welte | cd877f1 | 2016-12-23 20:04:27 +0100 | [diff] [blame] | 29 | uint8_t ts_type; /* timestamp tyoe */ |
| 30 | uint8_t num_args; /* number of arguments */ |
| 31 | uint8_t drop_cnt; /* dropped messages */ |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 32 | uint64_t timestamp; /* More 32 bit but dm-commands.h */ |
Harald Welte | cd877f1 | 2016-12-23 20:04:27 +0100 | [diff] [blame] | 33 | |
| 34 | /* msg_desc_type */ |
| 35 | uint16_t line_nr; |
| 36 | uint16_t subsys_id; |
| 37 | uint32_t subsys_mask; |
| 38 | |
| 39 | int32_t params[0]; /* three params */ |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 40 | } __attribute__((packed)); |
| 41 | |
Harald Welte | f5d6fee | 2016-01-13 22:29:10 +0100 | [diff] [blame] | 42 | |
| 43 | /* message header */ |
| 44 | struct diag_msg_hdr { |
| 45 | uint8_t cmd_code; |
| 46 | uint8_t timestamp_type; |
| 47 | uint8_t num_args; |
| 48 | uint8_t drop_count; |
| 49 | uint64_t ts; |
| 50 | } __attribute__((packed)); |
| 51 | |
| 52 | /* message descriptor */ |
| 53 | struct diag_msg_desc { |
| 54 | uint16_t line; |
| 55 | uint16_t subsys_id; |
| 56 | uint16_t subsys_mask; |
| 57 | } __attribute__((packed)); |
| 58 | |
| 59 | /* message header for DIAG_EXT_MSG_F */ |
| 60 | struct diag_msg_ext { |
| 61 | struct diag_msg_hdr hdr; |
| 62 | struct diag_msg_desc desc; |
| 63 | uint32_t args[0]; /* see hdr.num_args */ |
| 64 | /* followed by null-terminated strings */ |
| 65 | } __attribute__((packed)); |
| 66 | |
| 67 | |
Harald Welte | 654f117 | 2016-12-24 00:01:25 +0100 | [diff] [blame] | 68 | /*********************************************************************** |
| 69 | * Log Service (IAG_LOG_F) |
| 70 | ***********************************************************************/ |
| 71 | |
Harald Welte | f5d6fee | 2016-01-13 22:29:10 +0100 | [diff] [blame] | 72 | /* message header for DIAG_LOG_F */ |
| 73 | struct diag_log_hdr { |
| 74 | uint8_t cmd_code; |
| 75 | uint8_t more; |
| 76 | uint16_t len; |
| 77 | uint8_t data[0]; |
| 78 | } __attribute__((packed)); |
| 79 | |
| 80 | struct log_hdr { |
| 81 | uint16_t len; |
| 82 | uint16_t code; |
| 83 | uint64_t ts; |
| 84 | uint8_t data[0]; |
| 85 | } __attribute__((packed)); |
| 86 | |
| 87 | |
Harald Welte | 654f117 | 2016-12-24 00:01:25 +0100 | [diff] [blame] | 88 | /*********************************************************************** |
| 89 | * Command Service (DIAG_SUBSYS_CMD_F) |
| 90 | ***********************************************************************/ |
| 91 | |
Harald Welte | f5d6fee | 2016-01-13 22:29:10 +0100 | [diff] [blame] | 92 | /* extended DIAG packet, */ |
| 93 | struct diagpkt_subsys_hdr { |
| 94 | uint8_t command; /* DIAG_SUBSYS_CMD_F */ |
| 95 | uint8_t subsys_id; |
| 96 | uint8_t subsys_cmd_code; |
| 97 | } __attribute__((packed)); |
| 98 | |
| 99 | int diag_push_subsys_hdr(struct msgb *msg, uint8_t subsys, uint8_t code); |
Harald Welte | 2c36375 | 2016-12-24 00:19:55 +0100 | [diff] [blame] | 100 | uint32_t diag_ts_to_fn(uint64_t ts); |
| 101 | uint32_t diag_ts_to_epoch(uint64_t qd_time); |
Harald Welte | f5d6fee | 2016-01-13 22:29:10 +0100 | [diff] [blame] | 102 | |
Holger Hans Peter Freyther | a7d50bf | 2013-12-23 14:26:36 +0100 | [diff] [blame] | 103 | #endif |