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