blob: ab6b8acf5ed59486b0c48371a3a271571cca5c6d [file] [log] [blame]
Harald Welte9fe1f9f2018-11-29 13:47:39 +01001#pragma once
2
3#include <stdint.h>
4
5#include <osmocom/core/prim.h>
6#include <osmocom/gsm/protocol/gsm_25_415.h>
7
8/***********************************************************************
9 * Primitives towards the lower layers (typically RTP transport)
10 ***********************************************************************/
11enum osmo_iuup_tnl_prim_type {
12 OSMO_IUUP_TNL_UNITDATA,
13};
14
15struct osmo_iuup_tnl_prim {
16 struct osmo_prim_hdr oph;
17};
18
19/***********************************************************************
20 * Primitives towards the upper layers at the RNL SAP
21 ***********************************************************************/
22
23/* 3GPP TS 25.415 Section 7.2.1 */
24enum osmo_iuup_rnl_prim_type {
25 OSMO_IUUP_RNL_CONFIG,
26 OSMO_IUUP_RNL_DATA,
27 OSMO_IUUP_RNL_STATUS,
28 OSMO_IUUP_RNL_UNIT_DATA,
29};
30
31/* TS 25.413 9.2.1.3*/
32#define IUUP_MAX_SUBFLOWS 7
33#define IUUP_MAX_RFCIS 64
34
35#define IUUP_TIMER_INIT_T_DEFAULT 1000
36#define IUUP_TIMER_TA_T_DEFAULT 500
37#define IUUP_TIMER_RC_T_DEFAULT 500
38#define IUUP_TIMER_INIT_N_DEFAULT 3
39#define IUUP_TIMER_TA_N_DEFAULT 1
40#define IUUP_TIMER_RC_N_DEFAULT 1
41struct osmo_iuup_rnl_config_timer {
42 uint32_t t_ms; /* time in ms */
43 uint32_t n_max; /* max number of repetitions */
44};
Pau Espin Pedrol510f4c92022-05-24 18:44:10 +020045struct osmo_iuup_rfci {
46 uint8_t used:1,
Pau Espin Pedrolfe1dceb2022-05-25 19:43:13 +020047 spare1:1,
48 id:6;
Pau Espin Pedrol510f4c92022-05-24 18:44:10 +020049 uint8_t spare2:4,
Pau Espin Pedrolfe1dceb2022-05-25 19:43:13 +020050 IPTI:4; /* values range 0-15, 4 bits */;
Pau Espin Pedrol510f4c92022-05-24 18:44:10 +020051 uint16_t subflow_sizes[IUUP_MAX_SUBFLOWS];
52};
Harald Welte9fe1f9f2018-11-29 13:47:39 +010053struct osmo_iuup_rnl_config {
54 /* transparent (true) or SMpSDU (false): */
55 bool transparent;
56
57 /* should we actively transmit INIT in SmpSDU mode? */
58 bool active;
59
60 /* Currently Version 0 or 1: */
61 uint8_t data_pdu_type;
62
63 /* Supported mode versions */
64 uint16_t supported_versions_mask;
65 uint8_t num_rfci;
66 uint8_t num_subflows;
Harald Welte9fe1f9f2018-11-29 13:47:39 +010067 bool IPTIs_present;
Pau Espin Pedrol510f4c92022-05-24 18:44:10 +020068 struct osmo_iuup_rfci rfci[IUUP_MAX_RFCIS];
Harald Welte9fe1f9f2018-11-29 13:47:39 +010069
70 /* TODO: Indication of delivery of erroneous SDUs*/
71 struct osmo_iuup_rnl_config_timer t_init;
72 struct osmo_iuup_rnl_config_timer t_ta;
73 struct osmo_iuup_rnl_config_timer t_rc;
74};
75
76struct osmo_iuup_rnl_data {
77 uint8_t rfci;
78 uint8_t frame_nr;
79 uint8_t fqc;
80};
81
82struct osmo_iuup_rnl_status {
83 enum iuup_procedure procedure;
84 union {
85 struct {
86 enum iuup_error_cause cause;
87 enum iuup_error_distance distance;
88 } error_event;
89 struct {
Pau Espin Pedrol604eaba2022-01-03 16:57:45 +010090 uint16_t mode_version;
91 uint8_t data_pdu_type;
Harald Welte9fe1f9f2018-11-29 13:47:39 +010092 uint8_t num_rfci;
Pau Espin Pedrol604eaba2022-01-03 16:57:45 +010093 uint8_t num_subflows;
Harald Welte9fe1f9f2018-11-29 13:47:39 +010094 bool IPTIs_present;
Pau Espin Pedrol510f4c92022-05-24 18:44:10 +020095 struct osmo_iuup_rfci rfci[IUUP_MAX_RFCIS];
Harald Welte9fe1f9f2018-11-29 13:47:39 +010096 } initialization;
97 struct {
98 } rate_control;
99 struct {
100 } time_alignment;
101 } u;
102};
103
104/* SAP on the upper side of IuUP, towards the user */
105struct osmo_iuup_rnl_prim {
106 struct osmo_prim_hdr oph;
107 union {
108 struct osmo_iuup_rnl_config config;
109 struct osmo_iuup_rnl_data data;
110 struct osmo_iuup_rnl_status status;
111 //struct osmo_iuup_rnl_unitdata unitdata;
112 } u;
113};
114
115struct osmo_iuup_instance;
116struct osmo_iuup_instance *osmo_iuup_instance_alloc(void *ctx, const char *id);
117void osmo_iuup_instance_free(struct osmo_iuup_instance *iui);
118
119void osmo_iuup_instance_set_user_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
120void osmo_iuup_instance_set_transport_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
121int osmo_iuup_tnl_prim_up(struct osmo_iuup_instance *iui, struct osmo_iuup_tnl_prim *itp);
122int osmo_iuup_rnl_prim_down(struct osmo_iuup_instance *inst, struct osmo_iuup_rnl_prim *irp);
123
124
125int osmo_iuup_compute_header_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);
126int osmo_iuup_compute_payload_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);
127
128struct osmo_iuup_rnl_prim *osmo_iuup_rnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);
129struct osmo_iuup_tnl_prim *osmo_iuup_tnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);