blob: 18ad7d208b9bb001abac6b05989f0730b72559b8 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file l1sap.h */
2
Sylvain Munaut12ba7782014-06-16 10:13:40 +02003#pragma once
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +01004
5#include <osmocom/core/prim.h>
6
Neels Hofmeyr87e45502017-06-20 00:17:59 +02007/*! PH-SAP related primitives (L1<->L2 SAP) */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +01008enum osmo_ph_prim {
Neels Hofmeyr87e45502017-06-20 00:17:59 +02009 PRIM_PH_DATA, /*!< PH-DATA */
10 PRIM_PH_RACH, /*!< PH-RANDOM_ACCESS */
11 PRIM_PH_CONN, /*!< PH-CONNECT */
12 PRIM_PH_EMPTY_FRAME, /*!< PH-EMPTY_FRAME */
13 PRIM_PH_RTS, /*!< PH-RTS */
14 PRIM_MPH_INFO, /*!< MPH-INFO */
15 PRIM_TCH, /*!< TCH */
16 PRIM_TCH_RTS, /*!< TCH */
Andreas Eversberg227a9de2013-02-07 12:21:33 +010017};
18
Maxadef12a2016-05-25 15:25:02 +020019extern const struct value_string osmo_ph_prim_names[];
20
Neels Hofmeyr87e45502017-06-20 00:17:59 +020021/*! PH-SAP related primitives (L1<->L2 SAP) */
Andreas Eversberg227a9de2013-02-07 12:21:33 +010022enum osmo_mph_info_type {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020023 PRIM_INFO_TIME, /*!< Current GSM time */
24 PRIM_INFO_MEAS, /*!< Measurement indication */
25 PRIM_INFO_ACTIVATE, /*!< Activation of channel */
26 PRIM_INFO_DEACTIVATE, /*!< Deactivation of channel */
27 PRIM_INFO_MODIFY, /*!< Mode Modify of channel */
28 PRIM_INFO_ACT_CIPH, /*!< Activation of ciphering */
29 PRIM_INFO_DEACT_CIPH, /*!< Deactivation of ciphering */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010030};
31
Neels Hofmeyr87e45502017-06-20 00:17:59 +020032/*! PH-DATA presence information */
Maxcc00bf82016-02-22 11:03:26 +010033enum osmo_ph_pres_info_type {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020034 PRES_INFO_INVALID = 0, /*!< Data is invalid */
35 PRES_INFO_HEADER = 1, /*!< Only header is present and valid */
36 PRES_INFO_FIRST = 3, /*!< First half of data + header are valid (2nd half may be present but invalid) */
37 PRES_INFO_SECOND = 5, /*!< Second half of data + header are valid (1st halfmay be present but invalid) */
38 PRES_INFO_BOTH = 7, /*!< Both parts + header are present and valid */
Maxcc00bf82016-02-22 11:03:26 +010039 PRES_INFO_UNKNOWN
40};
41
Neels Hofmeyr87e45502017-06-20 00:17:59 +020042/*! for PH-RANDOM_ACCESS.req */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010043struct ph_rach_req_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020044 uint8_t ra; /*!< Random Access */
45 uint8_t ta; /*!< Timing Advance */
46 uint8_t tx_power; /*!< Transmit Power */
47 uint8_t is_combined_ccch;/*!< Are we using a combined CCCH? */
48 uint16_t offset; /*!< Timing Offset */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010049};
50
Neels Hofmeyr87e45502017-06-20 00:17:59 +020051/*! for PH_RA_IND burstType inforamtion */
bhargava1a969462016-07-14 13:15:09 +053052enum ph_burst_type {
53 GSM_L1_BURST_TYPE_NONE = 0,
54 GSM_L1_BURST_TYPE_ACCESS_0,
55 GSM_L1_BURST_TYPE_ACCESS_1,
56 GSM_L1_BURST_TYPE_ACCESS_2
57};
58
Neels Hofmeyr87e45502017-06-20 00:17:59 +020059/*! for PH-RANDOM_ACCESS.ind */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010060struct ph_rach_ind_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020061 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
62 uint16_t ra; /*!< Random Access */
63 uint8_t acc_delay; /*!< Delay in bit periods */
64 uint32_t fn; /*!< GSM Frame Number at time of RA */
65 uint8_t is_11bit; /*!< no.of bits in RACH*/
66 enum ph_burst_type burst_type; /*!< type of burst*/
Harald Weltea57f90c2018-02-26 11:49:59 +010067 /* elements added on 2018-02-26 */
68 int8_t rssi; /*!< RSSI of RACH indication */
69 uint16_t ber10k; /*!< BER in units of 0.01% */
70 int16_t acc_delay_256bits;/* !< Burst TA Offset in 1/256th bits */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010071};
72
Neels Hofmeyr87e45502017-06-20 00:17:59 +020073/*! for PH-[UNIT]DATA.{req,ind} | PH-RTS.ind */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010074struct ph_data_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020075 uint8_t link_id; /*!< Link Identifier (Like RSL) */
76 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
77 uint32_t fn; /*!< GSM Frame Number */
78 int8_t rssi; /*!< RSSI of receivedindication */
79 uint16_t ber10k; /*!< BER in units of 0.01% */
80 int16_t ta_offs_qbits; /* !< Burst TA Offset in quarter bits */
81 int16_t lqual_cb; /* !< Link quality in centiBel */
82 enum osmo_ph_pres_info_type pdch_presence_info; /*!< Info regarding presence/validity of header and data parts */
Andreas Eversberg227a9de2013-02-07 12:21:33 +010083};
84
Neels Hofmeyr87e45502017-06-20 00:17:59 +020085/*! for TCH.{req,ind} | TCH-RTS.ind */
Andreas Eversberg227a9de2013-02-07 12:21:33 +010086struct ph_tch_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020087 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
88 uint32_t fn; /*!< GSM Frame Number */
89 int8_t rssi; /*!< RSSI of received indication */
90 uint8_t marker; /*!< RTP Marker bit (speech onset indicator) */
Pau Espin Pedrol411402b2017-06-30 12:06:00 +020091 uint16_t ber10k; /*!< BER in units of 0.01% */
92 int16_t lqual_cb; /* !< Link quality in centiBel */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010093};
94
Neels Hofmeyr87e45502017-06-20 00:17:59 +020095/*! for PH-CONN.ind */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010096struct ph_conn_ind_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020097 uint32_t fn; /*!< GSM Frame Number */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +010098};
99
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200100/*! for TIME MPH-INFO.ind */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100101struct info_time_ind_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200102 uint32_t fn; /*!< GSM Frame Number */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100103};
104
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200105/*! for MEAS MPH-INFO.ind */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100106struct info_meas_ind_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200107 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
108 uint32_t fn; /*!< GSM Frame Number */
109 uint16_t ber10k; /*!< BER in units of 0.01% */
110 int16_t ta_offs_qbits; /*!< timing advance offset (in qbits) */
111 int16_t c_i_cb; /*!< C/I ratio in 0.1 dB */
112 uint8_t is_sub:1; /*!< flags */
113 uint8_t inv_rssi; /*!< RSSI in dBm * -1 */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100114};
115
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200116/*! for {ACTIVATE,DEACTIVATE,MODIFY} MPH-INFO.req */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100117struct info_act_req_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200118 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100119 uint8_t sacch_only; /*!< \breif Only deactivate SACCH */
120};
121
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200122/*! for {ACTIVATE,DEACTIVATE} MPH-INFO.cnf */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100123struct info_act_cnf_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200124 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
125 uint8_t cause; /*!< RSL cause in case of nack */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100126};
127
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200128/*! for {ACTIVATE,DEACTIVATE} MPH-INFO.{req,cnf} */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100129struct info_ciph_req_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200130 uint8_t chan_nr; /*!< Channel Number (Like RSL) */
131 uint8_t downlink; /*!< Apply to downlink */
132 uint8_t uplink; /*!< Apply to uplink */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100133};
134
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200135/*! for MPH-INFO.ind */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100136struct mph_info_param {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200137 enum osmo_mph_info_type type; /*!< Info message type */
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100138 union {
139 struct info_time_ind_param time_ind;
140 struct info_meas_ind_param meas_ind;
141 struct info_act_req_param act_req;
142 struct info_act_cnf_param act_cnf;
143 struct info_ciph_req_param ciph_req;
144 } u;
145};
146
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200147/*! primitive header for PH-SAP primitives */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +0100148struct osmo_phsap_prim {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200149 struct osmo_prim_hdr oph; /*!< generic primitive header */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +0100150 union {
151 struct ph_data_param data;
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100152 struct ph_tch_param tch;
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +0100153 struct ph_rach_req_param rach_req;
154 struct ph_rach_ind_param rach_ind;
155 struct ph_conn_ind_param conn_ind;
Andreas Eversberg227a9de2013-02-07 12:21:33 +0100156 struct mph_info_param info;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200157 } u; /*!< request-specific data */
Andreas Eversbergaa85a2d2013-02-07 12:18:37 +0100158};