blob: 53b967051ef8f386255c62fb58693c5b488c277b [file] [log] [blame]
Holger Hans Peter Freythera7d50bf2013-12-23 14:26:36 +01001#ifndef protocol_h
2#define protocol_h
3
4#include <stdint.h>
5
Harald Weltebd448582016-12-23 23:41:14 +01006struct msgb;
7
Harald Welte272b4ae2016-12-23 23:28:28 +01008/* 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 Freythera7d50bf2013-12-23 14:26:36 +010014/*
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 Welte654f1172016-12-24 00:01:25 +010022/***********************************************************************
23 * Extended Message Service (DIAG_EXT_MSG_F)
24 ***********************************************************************/
25
Holger Hans Peter Freythera7d50bf2013-12-23 14:26:36 +010026struct ext_log_msg {
Harald Weltecd877f12016-12-23 20:04:27 +010027 /* msg_hdr_type equivalent */
Holger Hans Peter Freythera7d50bf2013-12-23 14:26:36 +010028 uint8_t type;
Harald Weltecd877f12016-12-23 20:04:27 +010029 uint8_t ts_type; /* timestamp tyoe */
30 uint8_t num_args; /* number of arguments */
31 uint8_t drop_cnt; /* dropped messages */
Holger Hans Peter Freythera7d50bf2013-12-23 14:26:36 +010032 uint64_t timestamp; /* More 32 bit but dm-commands.h */
Harald Weltecd877f12016-12-23 20:04:27 +010033
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 Freythera7d50bf2013-12-23 14:26:36 +010040} __attribute__((packed));
41
Harald Weltef5d6fee2016-01-13 22:29:10 +010042
43/* message header */
44struct 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 */
53struct 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 */
60struct 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 Welte654f1172016-12-24 00:01:25 +010068/***********************************************************************
69 * Log Service (IAG_LOG_F)
70 ***********************************************************************/
71
Harald Weltef5d6fee2016-01-13 22:29:10 +010072/* message header for DIAG_LOG_F */
73struct 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
80struct 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 Welte654f1172016-12-24 00:01:25 +010088/***********************************************************************
89 * Command Service (DIAG_SUBSYS_CMD_F)
90 ***********************************************************************/
91
Harald Weltef5d6fee2016-01-13 22:29:10 +010092/* extended DIAG packet, */
93struct 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
99int diag_push_subsys_hdr(struct msgb *msg, uint8_t subsys, uint8_t code);
Harald Welte2c363752016-12-24 00:19:55 +0100100uint32_t diag_ts_to_fn(uint64_t ts);
101uint32_t diag_ts_to_epoch(uint64_t qd_time);
Harald Weltef5d6fee2016-01-13 22:29:10 +0100102
Holger Hans Peter Freythera7d50bf2013-12-23 14:26:36 +0100103#endif