xref: /dpdk/lib/net/rte_ecpri.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4 
5 #ifndef _RTE_ECPRI_H_
6 #define _RTE_ECPRI_H_
7 
8 /**
9  * @file
10  *
11  * eCPRI headers definition.
12  *
13  * eCPRI (Common Public Radio Interface) is used in internal interfaces
14  * of radio base station in a 5G infrastructure.
15  */
16 
17 #include <stdint.h>
18 #include <rte_byteorder.h>
19 
20 /*
21  * eCPRI Protocol Revision 1.0, 1.1, 1.2, 2.0: 0001b
22  * Other values are reserved for future
23  */
24 #define RTE_ECPRI_REV_UP_TO_20		1
25 
26 /*
27  * eCPRI message types in specifications
28  * IWF* types will only be supported from rev.2
29  * 12-63: Reserved for future revision
30  * 64-255: Vendor Specific
31  */
32 #define RTE_ECPRI_MSG_TYPE_IQ_DATA	0
33 #define RTE_ECPRI_MSG_TYPE_BIT_SEQ	1
34 #define RTE_ECPRI_MSG_TYPE_RTC_CTRL	2
35 #define RTE_ECPRI_MSG_TYPE_GEN_DATA	3
36 #define RTE_ECPRI_MSG_TYPE_RM_ACC	4
37 #define RTE_ECPRI_MSG_TYPE_DLY_MSR	5
38 #define RTE_ECPRI_MSG_TYPE_RMT_RST	6
39 #define RTE_ECPRI_MSG_TYPE_EVT_IND	7
40 #define RTE_ECPRI_MSG_TYPE_IWF_UP	8
41 #define RTE_ECPRI_MSG_TYPE_IWF_OPT	9
42 #define RTE_ECPRI_MSG_TYPE_IWF_MAP	10
43 #define RTE_ECPRI_MSG_TYPE_IWF_DCTRL	11
44 
45 /*
46  * Event Type of Message Type #7: Event Indication
47  * 0x00: Fault(s) Indication
48  * 0x01: Fault(s) Indication Acknowledge
49  * 0x02: Notification(s) Indication
50  * 0x03: Synchronization Request
51  * 0x04: Synchronization Acknowledge
52  * 0x05: Synchronization End Indication
53  * 0x06...0xFF: Reserved
54  */
55 #define RTE_ECPRI_EVT_IND_FAULT_IND	0x00
56 #define RTE_ECPRI_EVT_IND_FAULT_ACK	0x01
57 #define RTE_ECPRI_EVT_IND_NTFY_IND	0x02
58 #define RTE_ECPRI_EVT_IND_SYNC_REQ	0x03
59 #define RTE_ECPRI_EVT_IND_SYNC_ACK	0x04
60 #define RTE_ECPRI_EVT_IND_SYNC_END	0x05
61 
62 /**
63  * eCPRI Common Header
64  */
65 struct rte_ecpri_common_hdr {
66 	union {
67 		rte_be32_t u32;			/**< 4B common header in BE */
68 		struct {
69 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
70 			uint32_t size:16;	/**< Payload Size */
71 			uint32_t type:8;	/**< Message Type */
72 			uint32_t c:1;		/**< Concatenation Indicator */
73 			uint32_t res:3;		/**< Reserved */
74 			uint32_t revision:4;	/**< Protocol Revision */
75 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
76 			uint32_t revision:4;	/**< Protocol Revision */
77 			uint32_t res:3;		/**< Reserved */
78 			uint32_t c:1;		/**< Concatenation Indicator */
79 			uint32_t type:8;	/**< Message Type */
80 			uint32_t size:16;	/**< Payload Size */
81 #endif
82 		};
83 	};
84 };
85 
86 /**
87  * eCPRI Message Header of Type #0: IQ Data
88  */
89 struct rte_ecpri_msg_iq_data {
90 	rte_be16_t pc_id;		/**< Physical channel ID */
91 	rte_be16_t seq_id;		/**< Sequence ID */
92 };
93 
94 /**
95  * eCPRI Message Header of Type #1: Bit Sequence
96  */
97 struct rte_ecpri_msg_bit_seq {
98 	rte_be16_t pc_id;		/**< Physical channel ID */
99 	rte_be16_t seq_id;		/**< Sequence ID */
100 };
101 
102 /**
103  * eCPRI Message Header of Type #2: Real-Time Control Data
104  */
105 struct rte_ecpri_msg_rtc_ctrl {
106 	rte_be16_t rtc_id;		/**< Real-Time Control Data ID */
107 	rte_be16_t seq_id;		/**< Sequence ID */
108 };
109 
110 /**
111  * eCPRI Message Header of Type #3: Generic Data Transfer
112  */
113 struct rte_ecpri_msg_gen_data {
114 	rte_be32_t pc_id;		/**< Physical channel ID */
115 	rte_be32_t seq_id;		/**< Sequence ID */
116 };
117 
118 /**
119  * eCPRI Message Header of Type #4: Remote Memory Access
120  */
121 struct rte_ecpri_msg_rm_access {
122 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
123 	uint32_t ele_id:16;		/**< Element ID */
124 	uint32_t rr:4;			/**< Req/Resp */
125 	uint32_t rw:4;			/**< Read/Write */
126 	uint32_t rma_id:8;		/**< Remote Memory Access ID */
127 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
128 	uint32_t rma_id:8;		/**< Remote Memory Access ID */
129 	uint32_t rw:4;			/**< Read/Write */
130 	uint32_t rr:4;			/**< Req/Resp */
131 	uint32_t ele_id:16;		/**< Element ID */
132 #endif
133 	uint8_t addr[6];		/**< 48-bits address */
134 	rte_be16_t length;		/**< number of bytes */
135 };
136 
137 /**
138  * eCPRI Message Header of Type #5: One-Way Delay Measurement
139  */
140 struct rte_ecpri_msg_delay_measure {
141 	uint8_t msr_id;			/**< Measurement ID */
142 	uint8_t act_type;		/**< Action Type */
143 };
144 
145 /**
146  * eCPRI Message Header of Type #6: Remote Reset
147  */
148 struct rte_ecpri_msg_remote_reset {
149 	rte_be16_t rst_id;		/**< Reset ID */
150 	uint8_t rst_op;			/**< Reset Code Op */
151 };
152 
153 /**
154  * eCPRI Message Header of Type #7: Event Indication
155  */
156 struct rte_ecpri_msg_event_ind {
157 	uint8_t evt_id;			/**< Event ID */
158 	uint8_t evt_type;		/**< Event Type */
159 	uint8_t seq;			/**< Sequence Number */
160 	uint8_t number;			/**< Number of Faults/Notif */
161 };
162 
163 /**
164  * eCPRI Combined Message Header Format: Common Header + Message Types
165  */
166 struct rte_ecpri_combined_msg_hdr {
167 	struct rte_ecpri_common_hdr common;
168 	union {
169 		struct rte_ecpri_msg_iq_data type0;
170 		struct rte_ecpri_msg_bit_seq type1;
171 		struct rte_ecpri_msg_rtc_ctrl type2;
172 		struct rte_ecpri_msg_gen_data type3;
173 		struct rte_ecpri_msg_rm_access type4;
174 		struct rte_ecpri_msg_delay_measure type5;
175 		struct rte_ecpri_msg_remote_reset type6;
176 		struct rte_ecpri_msg_event_ind type7;
177 		rte_be32_t dummy[3];
178 	};
179 };
180 
181 #endif /* _RTE_ECPRI_H_ */
182