[ Jira id - ODUHIGH-593 ] Pack and unpack function nomenclature correction
[o-du/l2.git] / src / intel_fapi / nfapi_interface.h
1  /*******************************************************************************
2  ################################################################################
3  #   Copyright (c) [2017-2019] [Radisys]                                        #
4  #                                                                              #
5  #   Licensed under the Apache License, Version 2.0 (the "License");            #
6  #   you may not use this file except in compliance with the License.           #
7  #   You may obtain a copy of the License at                                    #
8  #                                                                              #
9  #       http://www.apache.org/licenses/LICENSE-2.0                             #
10  #                                                                              #
11  #   Unless required by applicable law or agreed to in writing, software        #
12  #   distributed under the License is distributed on an "AS IS" BASIS,          #
13  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14  #   See the License for the specific language governing permissions and        #
15  #   limitations under the License.                                             #
16  ################################################################################
17  *******************************************************************************/
18
19 /*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/
20
21 #ifndef _NFAPI_INTERFACE_H
22 #define _NFAPI_INTERFACE_H
23
24 #include "fapi_interface.h"
25 /*Table 2-7 Dedicated NFAPI message IDs*/
26
27 /*P5 Messages*/
28 #define NFAPI_PNF_PARAM_REQ    0x0100
29 #define NFAPI_PNF_PARAM_RESP   0x0101
30 #define NFAPI_PNF_CONFIG_REQ   0x0102
31 #define NFAPI_PNF_CONFIG_RESP  0x0103
32 #define NFAPI_PNF_START_REQ    0x0104
33 #define NFAPI_PNF_START_RESP   0x0105
34 #define NFAPI_PNF_STOP_REQ     0x0106
35 #define NFAPI_PNF_STOP_RESP    0x0107
36 #define NFAPI_START_RESPONSE         0x0108
37 #define NFAPI_PNF_READY_IND    0x0109
38
39 /*Reserved for P5 Dedicated NFAPI Messages 0x010A - 0x017F */
40
41 /*P7 messages*/
42 #define NFAPI_DL_NODE_SYNC     0x0180
43 #define NFAPI_UL_NODE_SYNC     0x0181
44 #define NFAPI_TIMING_INFO      0x0182
45
46 /*Reserved for P7 Dedicated NFAPI Messages 0x0183 - 0x01ff*/
47 /*RESERVED for Vendor Extension messages 0x0300 - 0x03ff*/
48
49 /*Table 3-16 nFAPI TLVs included in PARAM.response and 
50  *Table 3-19 nFAPI TLVs included in CONFIG.request*/
51 //PNF and VNF Parameters
52 #define NFAPI_P7_VNF_ADD_IPV4              0x0100
53 #define NFAPI_P7_VNF_ADD_IPV6              0x0101
54 #define NFAPI_P7_VNF_PORT                  0x0102
55 #define NFAPI_P7_PNF_ADD_IPV4              0x0103
56 #define NFAPI_P7_PNF_ADD_IPV6              0x0104
57 #define NFAPI_P7_PNF_PORT                  0x0105
58 //TTI Related Parameters
59 #define NFAPI_DL_TTI_TIMING_OFFSET         0x0106
60 #define NFAPI_UL_TTI_TIMING_OFFSET         0x0107
61 #define NFAPI_UL_DCI_TIMING_OFFSET         0x0108
62 #define NFAPI_TX_DATA_TIMING_OFFSET        0x0109
63 //Timing Related Parameters
64 #define NFAPI_TIMING_WINDOW                0x011E
65 #define NFAPI_TIMING_INFO_MODE             0x011F
66 #define NFAPI_TIMING_INFO_PERIOD           0x0120
67 //P7 Transport Related Parameters
68 #define NFAPI_P7_IP_FRAGMENTATION_ALLOWED  0x0121
69 #define NFAPI_P7_TRANSPORT                 0x0122
70 #define NFAPI_P7_PNF_ETHERNET_ADD          0x0123
71 #define NFAPI_P7_VNF_ETHERNET_ADD          0x0124
72 //CPRI Related Parameters
73 #define NFAPI_ECPRI_MSG_TYPE               0x0125
74 #define NFAPI_ECPRI_PHY_TRANSPORT_ID       0x0126
75
76 #define NFAPI_5G_FAPI_MSG_BODY             0x0F00
77
78 /*Table 3-2*/
79 #define NFAPI_PNF_PARAM_GENERAL            0x1000 
80
81 /*As per Table 3-15 and Table 3-17*/
82 #define MAX_NUM_TLV_IN_PARAM_RESP          19
83 /*As per Table 3-19*/
84 #define MAX_NUM_TLV_IN_CONFIG_REQ          9
85
86 typedef enum {
87    PNF_STATE_IDLE = 0,
88    PNF_STATE_CONFIGURED,
89    PNF_STATE_RUNNING
90 }nFapi_pnf_state;
91
92 /*Table 3-4 and Table 3-7*/
93 typedef enum {
94    NFAPI_MSG_OK = 0,
95    NFAPI_MSG_INVALID_STATE,
96    NFAPI_MSG_INVALID_CONFIG
97 }nFapi_error_code;
98
99 /*Table 3-21: "Timing info mode"*/
100 typedef enum {
101    NFAPI_TIMING_INFO_MODE_DISABLE = 0,
102    NFAPI_TIMING_INFO_MODE_PERIODIC,
103    NFAPI_TIMING_INFO_MODE_APERIODIC,
104    NFAPI_TIMING_INFO_MODE_PERIODIC_APERIODIC
105 }nFapi_timing_info_mode;
106
107
108 /*Table 2-3*/
109 typedef struct nFapi_p5_hdr_t{
110    uint16_t seg_len;       /*Segment Length*/
111    uint8_t  more_segNum;   /*Combination of MORE(1 bit = MSB) and SEGMENT NUMBER(7 bits)*/
112    uint8_t  seq_num;       /*Sequence Number*/
113    uint32_t timeStamp;     /*Transit TimeStamp*/
114 }nFapi_p5_hdr;
115
116 /*Table 2-5*/
117 typedef struct nFapi_p7_hdr_t{
118    uint16_t seq_num;       /*Sequence Number*/
119    uint16_t pad;           /*Padding for Byte alignment*/
120    uint32_t tot_SDU_len;   /*Total SDU length*/
121    uint32_t byteOffset;    /*Byte Offset: Offset specifying the start of a segment*/
122    uint32_t timeStamp;     /*Transit TimeStamp*/
123 }nFapi_p7_hdr;
124
125 /*Table 2-4*/
126 typedef struct nFapi_msg_header_t{
127    uint8_t  sRU_termination_type;  /*RU termination Type: 0x01 = P5/P7 msgs*/
128    uint8_t  phy_id;                /*PHY instance: [1..ā€¯Maximum Number Of PHYs]*/
129    uint16_t msg_id;                /*msg ID of FAPI or NFAPI msg*/
130    uint32_t length;                /*len of msg body in octets excluding msg hdr.*/
131 }nFapi_msg_header;
132
133 typedef struct {
134    uint16_t tag;
135    uint16_t length;
136    void     *value;
137 }nFapi_tlv;
138
139 //Section 2.1.1 P5 PNF Procedures
140 /*Table 3-1*/
141 typedef struct nFapi_pnf_ready_ind_t{
142    nFapi_p5_hdr      nFapiP5Hdr;
143    nFapi_msg_header  nFapiMsghdr;
144    uint32_t          versionInfo;
145 }nFapi_pnf_ready_ind;
146
147 typedef struct nFapi_pnf_param_req_t{
148    nFapi_p5_hdr      nFapiP5Hdr;
149    nFapi_msg_header  nFapiMsghdr;
150 }nFapi_pnf_param_req;
151
152 /*Table 3-3*/
153 typedef struct nFapi_pnf_param_general_t{
154    uint8_t   nFapi_sync_mode;
155    uint8_t   loc_mode;
156    uint8_t   *loc_coordinates; /*Spec 38.455, 'NG-RANAccessPointPosition'*/
157    uint16_t  max_num_phy;
158    uint8_t   oui[3];
159    uint16_t  numRfInstances;
160    uint16_t  numDfeInstances;
161 }nFapi_pnf_param_general;
162
163 /*Table 3-2*/
164 typedef struct nFapi_pnf_param_resp_t{
165    nFapi_p5_hdr      nFapiP5Hdr;
166    nFapi_msg_header  nFapiMsghdr;
167    nFapi_error_code  errCode;
168    uint8_t           numTLVs;
169    nFapi_tlv         tlvs[1]; /*As per Spec only 1 TLV is defined (nFapi_pnf_param_general)*/
170 }nFapi_pnf_param_resp;
171
172 /*Table 3-5*/
173 typedef struct nFapi_pnf_config_req_t{
174    nFapi_p5_hdr      nFapiP5Hdr;
175    nFapi_msg_header  nFapiMsghdr;
176    uint8_t           numTLVs;
177 }nFapi_pnf_config_req;
178
179 /*Table 3-6*/
180 typedef struct nFapi_pnf_config_resp_t{
181    nFapi_p5_hdr      nFapiP5Hdr;
182    nFapi_msg_header  nFapiMsghdr;
183    nFapi_error_code  errCode;
184 }nFapi_pnf_config_resp;
185
186 typedef struct nFapi_pnf_start_req_t{
187    nFapi_p5_hdr      nFapiP5Hdr;
188    nFapi_msg_header  nFapiMsghdr;
189 }nFapi_pnf_start_req;
190
191 /*Table 3-9*/
192 typedef struct nFapi_pnf_start_resp_t{
193    nFapi_p5_hdr      nFapiP5Hdr;
194    nFapi_msg_header  nFapiMsghdr;
195    nFapi_error_code  errCode;
196 }nFapi_pnf_start_resp;
197
198 typedef struct nFapi_pnf_stop_req_t{
199    nFapi_p5_hdr      nFapiP5Hdr;
200    nFapi_msg_header  nFapiMsghdr;
201 }nFapi_pnf_stop_req;
202
203 /*Table 3-10*/
204 typedef struct nFapi_pnf_stop_resp_t{
205    nFapi_p5_hdr      nFapiP5Hdr;
206    nFapi_msg_header  nFapiMsghdr;
207    nFapi_error_code  errCode;
208 }nFapi_pnf_stop_resp;
209
210 //Section 2.1.2 P5 PHY Procedures
211 typedef struct nFapi_param_req_t{
212    nFapi_p5_hdr      nFapiP5Hdr;
213    nFapi_msg_header  nFapiMsghdr;
214    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Table 3-5*/ 
215 }nFapi_param_req;
216
217 /*Table 3-14*/
218 typedef struct nFapi_param_resp_t{
219    nFapi_p5_hdr      nFapiP5Hdr;
220    nFapi_msg_header  nFapiMsghdr;
221    nFapi_error_code  errCode;
222    uint8_t           numTLVs;
223    nFapi_tlv         tlvs[MAX_NUM_TLV_IN_PARAM_RESP];
224 }nFapi_param_resp;
225
226 /*Table 3-18*/
227 typedef struct nFapi_config_req_t{
228    nFapi_p5_hdr      nFapiP5Hdr;
229    nFapi_msg_header  nFapiMsghdr;
230    uint8_t           numTLVs;
231    nFapi_tlv         tlvs[MAX_NUM_TLV_IN_CONFIG_REQ];
232 }nFapi_config_req;
233
234 typedef struct nFapi_config_resp_t{
235    nFapi_p5_hdr      nFapiP5Hdr;
236    nFapi_msg_header  nFapiMsghdr;
237    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Table 3-27*/ 
238 }nFapi_config_resp;
239
240 typedef struct nFapi_start_req_t{
241    nFapi_p5_hdr      nFapiP5Hdr;
242    nFapi_msg_header  nFapiMsghdr;
243    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Sec 3.3.4.1*/
244 }nFapi_start_req;
245
246 /*Table 3-12*/
247 typedef struct nFapi_start_resp_t{
248    nFapi_p5_hdr      nFapiP5Hdr;
249    nFapi_msg_header  nFapiMsghdr;
250    nFapi_error_code  errCode;
251 }nFapi_start_resp;
252
253 typedef struct nFapi_error_ind_t{
254    nFapi_p5_hdr      nFapiP5Hdr;
255    nFapi_msg_header  nFapiMsghdr;
256    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Sec 3.3.6.1*/
257 }nFapi_error_ind;
258
259 typedef struct nFapi_stop_req_t{
260    nFapi_p5_hdr      nFapiP5Hdr;
261    nFapi_msg_header  nFapiMsghdr;
262    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Sec 3.3.5.1*/
263 }nFapi_stop_req;
264
265 typedef struct nFapi_stop_ind_t{
266    nFapi_p5_hdr      nFapiP5Hdr;
267    nFapi_msg_header  nFapiMsghdr;
268    uint8_t           *fapiMsgBody; /*SCF222 v222.10.03, Sec 3.3.5.2*/
269 }nFapi_stop_ind;
270
271 //P7 Procedures
272 /*Table 4-1*/
273 typedef struct nFapi_dl_node_sync_info_t{
274    uint32_t t1;   /*In micro-sec, timeDiff between [VNF's SFN 0/0] and [DL NodeSYnc Tx time]*/
275    int32_t  delta_sfnSlot;
276    uint8_t  scs;
277 }nFapi_dl_node_sync_info;
278
279 typedef struct nFapi_dl_node_sync_t{
280    nFapi_p7_hdr             nFapiP7Hdr;
281    nFapi_msg_header         nFapiMsghdr;
282    nFapi_dl_node_sync_info  dlNodeSyncInfo;
283 }nFapi_dl_node_sync;
284
285 /*Table 4-2*/
286 typedef struct nFapi_ul_node_sync_info_t{
287    uint32_t t1;   /*In micro-sec, timeDiff between [VNF's SFN 0/0] and [DL NodeSYnc Tx time]*/
288    uint32_t t2;   /*In micro-sec, timeDiff between [PNF's SFN 0/0] and [DL NodeSYnc Rx time]*/
289    uint32_t t3;   /*In micro-sec, timeDiff between [PNF's SFN 0/0] and [UL NodeSYnc Tx time]*/
290 }nFapi_ul_node_sync_info;
291
292 typedef struct nFapi_ul_node_sync_t{
293    nFapi_p7_hdr             nFapiP7Hdr;
294    nFapi_msg_header         nFapiMsghdr;
295    nFapi_ul_node_sync_info  ulNodeSyncInfo;
296 }nFapi_ul_node_sync;
297
298 /*Table 4-3*/
299 typedef struct nFapi_timing_parameter_t{
300    uint16_t lastSFN;
301    uint16_t lastSlot;
302    uint32_t time_elapsed; /*In ms, Time since the last timing Info*/
303    uint32_t dl_tti_jitter;  /*Units: micro-sec(ms)*/
304    uint32_t tx_data_jitter; /*Units: ms*/
305    uint32_t ul_tti_jitter;  /*Units: ms*/
306    uint32_t ul_dci_jitter;  /*Units: ms*/
307    int32_t  dl_tti_latest_delay; /*Units: ms*/
308    int32_t  tx_data_latest_delay;
309    int32_t  ul_tti_latest_delay; /*Units: ms*/
310    int32_t  ul_dci_latest_delay; /*Units: ms*/
311    int32_t  dl_tti_early_arr; /*Units: ms*/
312    int32_t  tx_data_early_arr; /*Units: ms*/
313    int32_t  ul_tti_early_arr; /*Units: ms*/
314    int32_t  ul_dci_early_arr; /*Units: ms*/
315    uint8_t  subCarrierSpacing;
316 }nFapi_timing_parameter;
317
318 typedef struct nFapi_timing_info_t{
319    nFapi_p7_hdr             nFapiP7Hdr;
320    nFapi_msg_header         nFapiMsghdr;
321    nFapi_timing_parameter   timingParam;
322 }nFapi_timing_info;
323
324 /*SCF222 v222.10.03, Table 3-54*/
325 typedef struct fapi_dl_tti_req_msg_body_t{
326    uint16_t sfn;
327    uint16_t slot;
328    uint8_t nPdus;
329    uint8_t nGroup;
330    uint8_t pad[2];
331    fapi_dl_tti_req_pdu_t pdus[FAPI_MAX_PDUS_PER_SLOT]; // 5G FAPI Table 3-35
332    fapi_ue_info_t ue_grp_info[FAPI_MAX_NUMBER_OF_GROUPS_PER_TTI];
333 }fapi_dl_tti_req_msg_body;
334
335 typedef struct nFapi_dl_tti_req_t{
336    nFapi_p7_hdr              nFapiP7Hdr;
337    nFapi_msg_header          nFapiMsghdr;
338    fapi_dl_tti_req_msg_body  fapiMsgBody;
339 }nFapi_dl_tti_req;
340
341 typedef struct nFapi_dl_tti_resp_t{
342    nFapi_p7_hdr       nFapiP7Hdr;
343    nFapi_msg_header   nFapiMsghdr;
344    uint8_t            *fapiMsgBody; /*TODO: In fapi_interface.h, dl_tti_resp not present*/
345 }nFapi_dl_tti_resp;
346
347 typedef struct fapi_ul_tti_req_msg_body_t{
348    uint16_t sfn;
349    uint16_t slot;
350    uint8_t nPdus;
351    uint8_t rachPresent;
352    uint8_t nUlsch;
353    uint8_t nUlcch;
354    uint8_t nGroup;
355    uint8_t pad[3];
356    fapi_ul_tti_req_pdu_t pdus[FAPI_MAX_NUMBER_UL_PDUS_PER_TTI];    // 5G FAPI Table 3-44
357    fapi_ue_info_t ueGrpInfo[FAPI_MAX_NUMBER_OF_GROUPS_PER_TTI];
358 }fapi_ul_tti_req_msg_body;
359
360 typedef struct nFapi_ul_tti_req_t{
361    nFapi_p7_hdr              nFapiP7Hdr;
362    nFapi_msg_header          nFapiMsghdr;
363    fapi_ul_tti_req_msg_body  fapiMsgBody;
364 }nFapi_ul_tti_req;
365
366 typedef struct fapi_ul_dci_req_msg_body_t{
367    uint16_t sfn;
368    uint16_t slot;
369    uint8_t numPdus;
370    uint8_t pad[3];
371    fapi_dci_pdu_t pdus[FAPI_MAX_NUMBER_UCI_PDUS_PER_SLOT]; // 5G FAPI Table 3-54
372 }fapi_ul_dci_req_msg_body;
373
374 typedef struct nFapi_ul_dci_req_t{
375    nFapi_p7_hdr              nFapiP7Hdr;
376    nFapi_msg_header          nFapiMsghdr;
377    fapi_ul_dci_req_msg_body  fapiMsgBody;
378 }nFapi_ul_dci_req;
379
380 typedef struct fapi_tx_data_req_msg_body_t{ 
381    uint16_t sfn;
382    uint16_t slot;
383    uint16_t num_pdus;
384    uint8_t pad[2];
385    fapi_tx_pdu_desc_t pdu_desc[FAPI_MAX_NUMBER_DL_PDUS_PER_TTI];   // 5G FAPI Table 3-58
386 }fapi_tx_data_req_msg_body;
387
388 typedef struct nFapi_tx_data_req_t{
389    nFapi_p7_hdr               nFapiP7Hdr;
390    nFapi_msg_header           nFapiMsghdr;
391    fapi_tx_data_req_msg_body  fapiMsgBody;
392 }nFapi_tx_data_req;
393
394 typedef struct fapi_rx_data_ind_msg_body_t{
395    uint16_t sfn;
396    uint16_t slot;
397    uint16_t numPdus;
398    uint8_t pad[2];
399    fapi_pdu_ind_info_t pdus[FAPI_MAX_NUMBER_OF_ULSCH_PDUS_PER_SLOT];   // 5G FAPI Table 3-61
400 }fapi_rx_data_ind_msg_body;
401
402 typedef struct nFapi_rx_data_ind_t{
403    nFapi_p7_hdr               nFapiP7Hdr;
404    nFapi_msg_header           nFapiMsghdr;
405    fapi_rx_data_ind_msg_body  fapiMsgBody;
406 }nFapi_rx_data_ind;
407
408 typedef struct fapi_crc_ind_msg_body_t{
409    uint16_t sfn;
410    uint16_t slot;
411    uint16_t numCrcs;
412    uint8_t pad[2];
413    fapi_crc_ind_info_t crc[FAPI_MAX_NUMBER_OF_CRCS_PER_SLOT];  // 5G FAPI Table 3-62
414 }fapi_crc_ind_msg_body;
415
416 typedef struct nFapi_crc_ind_t{
417    nFapi_p7_hdr           nFapiP7Hdr;
418    nFapi_msg_header       nFapiMsghdr;
419    fapi_crc_ind_msg_body  fapiMsgBody;
420 }nFapi_crc_ind;
421
422 typedef struct fapi_uci_ind_msg_body_t{
423    uint16_t sfn;
424    uint16_t slot;
425    uint16_t numUcis;       // 5G FAPI Table 3-63
426    uint8_t pad[2];
427    fapi_uci_pdu_info_t uciPdu[FAPI_MAX_NUMBER_UCI_PDUS_PER_SLOT];
428 }fapi_uci_ind_msg_body;
429
430 typedef struct nFapi_uci_ind_t{
431    nFapi_p7_hdr           nFapiP7Hdr;
432    nFapi_msg_header       nFapiMsghdr;
433    fapi_uci_ind_msg_body  fapiMsgBody;
434 }nFapi_uci_ind;
435
436 typedef struct fapi_srs_ind_msg_body_t{
437    uint16_t sfn;
438    uint16_t slot;
439    uint8_t numPdus;
440    uint8_t pad[3];
441    fapi_srs_pdu_t srsPdus[FAPI_MAX_NUMBER_SRS_PDUS_PER_SLOT];  // 5G FAPI Table 3-73
442 }fapi_srs_ind_msg_body;
443
444 typedef struct nFapi_srs_ind_t{
445    nFapi_p7_hdr           nFapiP7Hdr;
446    nFapi_msg_header       nFapiMsghdr;
447    fapi_srs_ind_msg_body  fapiMsgBody;
448 }nFapi_srs_ind;
449
450 typedef struct fapi_rach_ind_msg_body_t{
451    uint16_t sfn;
452    uint16_t slot;
453    uint8_t numPdus;
454    uint8_t pad[3];
455    fapi_rach_pdu_t rachPdu[FAPI_MAX_NUMBER_RACH_PDUS_PER_SLOT];    // 5G FAPI Table 3-74
456 }fapi_rach_ind_msg_body;
457
458 typedef struct nFapi_rach_ind_t{
459    nFapi_p7_hdr           nFapiP7Hdr;
460    nFapi_msg_header       nFapiMsghdr;
461    fapi_rach_ind_msg_body  fapiMsgBody;
462 }nFapi_rach_ind;
463
464 #endif