Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 3 | * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | #pragma once |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #include <stdbool.h> |
| 26 | |
| 27 | #include <osmocom/core/gsmtap_util.h> |
| 28 | |
| 29 | #include "gprs_bssgp_pcu.h" |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 30 | #include "coding_scheme.h" |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 31 | |
Pau Espin Pedrol | c0a250d | 2021-01-21 18:46:13 +0100 | [diff] [blame] | 32 | #include "neigh_cache.h" |
| 33 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 34 | #define LLC_CODEL_DISABLE 0 |
| 35 | #define LLC_CODEL_USE_DEFAULT (-1) |
| 36 | |
| 37 | #define MAX_EDGE_MCS 9 |
| 38 | #define MAX_GPRS_CS 4 |
| 39 | |
Pau Espin Pedrol | 41a22a7 | 2021-01-26 19:00:37 +0100 | [diff] [blame] | 40 | #define PCU_TDEF_NEIGH_RESOLVE_TO (-1) |
| 41 | #define PCU_TDEF_SI_RESOLVE_TO (-2) |
Pau Espin Pedrol | ab7159f | 2021-01-26 17:51:44 +0100 | [diff] [blame] | 42 | #define PCU_TDEF_NEIGH_CACHE_ALIVE (-10) |
| 43 | #define PCU_TDEF_SI_CACHE_ALIVE (-11) |
| 44 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 45 | /* see bts->gsmtap_categ_mask */ |
| 46 | enum pcu_gsmtap_category { |
| 47 | PCU_GSMTAP_C_DL_UNKNOWN = 0, /* unknown or undecodable downlink blocks */ |
| 48 | PCU_GSMTAP_C_DL_DUMMY = 1, /* downlink dummy blocks */ |
| 49 | PCU_GSMTAP_C_DL_CTRL = 2, /* downlink control blocks */ |
| 50 | PCU_GSMTAP_C_DL_DATA_GPRS = 3, /* downlink GPRS data blocks */ |
| 51 | PCU_GSMTAP_C_DL_DATA_EGPRS = 4, /* downlink EGPRS data blocks */ |
| 52 | PCU_GSMTAP_C_DL_PTCCH = 5, /* downlink PTCCH blocks */ |
| 53 | PCU_GSMTAP_C_DL_AGCH = 6, /* downlink AGCH blocks */ |
| 54 | PCU_GSMTAP_C_DL_PCH = 7, /* downlink PCH blocks */ |
| 55 | |
| 56 | PCU_GSMTAP_C_UL_UNKNOWN = 15, /* unknown or undecodable uplink blocks */ |
| 57 | PCU_GSMTAP_C_UL_DUMMY = 16, /* uplink dummy blocks */ |
| 58 | PCU_GSMTAP_C_UL_CTRL = 17, /* uplink control blocks */ |
| 59 | PCU_GSMTAP_C_UL_DATA_GPRS = 18, /* uplink GPRS data blocks */ |
| 60 | PCU_GSMTAP_C_UL_DATA_EGPRS = 19, /* uplink EGPRS data blocks */ |
| 61 | PCU_GSMTAP_C_UL_RACH = 20, /* uplink RACH bursts */ |
| 62 | PCU_GSMTAP_C_UL_PTCCH = 21, /* uplink PTCCH bursts */ |
| 63 | }; |
| 64 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 65 | struct gprs_rlcmac_bts; |
| 66 | struct GprsMs; |
| 67 | struct gprs_rlcmac_tbf; |
| 68 | |
| 69 | typedef int (*alloc_algorithm_func_t)(struct gprs_rlcmac_bts *bts, |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 70 | struct gprs_rlcmac_tbf *tbf, |
| 71 | bool single, int8_t use_tbf); |
| 72 | |
| 73 | struct gprs_pcu { |
| 74 | |
| 75 | /* Path to be used for the pcu-bts socket */ |
| 76 | char *pcu_sock_path; |
| 77 | |
| 78 | struct { /* Config Values set by VTY */ |
Pau Espin Pedrol | e891222 | 2021-01-14 14:03:17 +0100 | [diff] [blame] | 79 | uint8_t fc_interval; |
| 80 | uint16_t fc_bucket_time; |
| 81 | uint32_t fc_bvc_bucket_size; |
| 82 | uint32_t fc_bvc_leak_rate; |
| 83 | uint32_t fc_ms_bucket_size; |
| 84 | uint32_t fc_ms_leak_rate; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 85 | bool force_initial_cs; /* false=use from BTS true=use from VTY */ |
| 86 | bool force_initial_mcs; /* false=use from BTS true=use from VTY */ |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 87 | uint8_t initial_cs_dl, initial_cs_ul; |
| 88 | uint8_t initial_mcs_dl, initial_mcs_ul; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 89 | uint8_t max_cs_dl, max_cs_ul; |
| 90 | uint8_t max_mcs_dl, max_mcs_ul; |
Pau Espin Pedrol | 03de898 | 2021-01-14 12:48:50 +0100 | [diff] [blame] | 91 | uint8_t force_two_phase; |
Pau Espin Pedrol | fe8de45 | 2021-02-09 18:47:34 +0100 | [diff] [blame] | 92 | uint8_t force_alpha, gamma; |
Pau Espin Pedrol | 05f9f59 | 2021-01-14 12:56:58 +0100 | [diff] [blame] | 93 | bool dl_tbf_preemptive_retransmission; |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 94 | enum egprs_arq_type dl_arq_type; /* EGPRS_ARQ1 to support resegmentation in DL, EGPRS_ARQ2 for no reseg */ |
Pau Espin Pedrol | e8dcf64 | 2021-01-14 13:17:01 +0100 | [diff] [blame] | 95 | bool cs_adj_enabled; /* whether cs_adj_{upper,lower}_limit are used to adjust DL CS */ |
| 96 | uint8_t cs_adj_upper_limit; /* downgrade DL CS if error rate above its value */ |
| 97 | uint8_t cs_adj_lower_limit; /* upgrade DL CS if error rate below its value */ |
Pau Espin Pedrol | ad79b85 | 2021-01-14 13:20:55 +0100 | [diff] [blame] | 98 | /* downgrade DL CS when less than specified octets are left in tx queue. Optimization, see paper: |
| 99 | "Theoretical Analysis of GPRS Throughput and Delay" */ |
| 100 | uint16_t cs_downgrade_threshold; |
Pau Espin Pedrol | 54b159a | 2021-01-14 13:30:04 +0100 | [diff] [blame] | 101 | /* Link quality range for each UL (M)CS. Below or above, next/prev (M)CS is selected. */ |
| 102 | struct {int16_t low; int16_t high; } cs_lqual_ranges[MAX_GPRS_CS]; |
| 103 | struct {int16_t low; int16_t high; } mcs_lqual_ranges[MAX_EDGE_MCS]; |
Pau Espin Pedrol | 113fb41 | 2021-01-14 13:36:02 +0100 | [diff] [blame] | 104 | enum gprs_ns2_dialect ns_dialect; /* Are we talking Gb with IP-SNS (true) or classic Gb? */ |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 105 | uint16_t ws_base; |
| 106 | uint16_t ws_pdch; /* increase WS by this value per PDCH */ |
Pau Espin Pedrol | f473ec9 | 2021-01-14 14:45:14 +0100 | [diff] [blame] | 107 | uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */ |
| 108 | uint32_t llc_discard_csec; |
| 109 | uint32_t llc_idle_ack_csec; |
| 110 | uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */ |
Pau Espin Pedrol | c0a250d | 2021-01-21 18:46:13 +0100 | [diff] [blame] | 111 | /* Remote BSS resolution sevice (CTRL iface) */ |
| 112 | char *neigh_ctrl_addr; |
| 113 | uint16_t neigh_ctrl_port; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 114 | } vty; |
| 115 | |
| 116 | struct gsmtap_inst *gsmtap; |
| 117 | uint32_t gsmtap_categ_mask; |
| 118 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 119 | struct llist_head bts_list; /* list of gprs_rlcmac_tbf */ |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 120 | |
| 121 | struct gprs_ns2_inst *nsi; |
| 122 | |
| 123 | alloc_algorithm_func_t alloc_algorithm; |
| 124 | |
| 125 | struct gprs_bssgp_pcu bssgp; |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 126 | |
| 127 | struct osmo_tdef *T_defs; /* timers controlled by PCU */ |
Pau Espin Pedrol | c0a250d | 2021-01-21 18:46:13 +0100 | [diff] [blame] | 128 | |
| 129 | struct neigh_cache *neigh_cache; /* ARFC+BSIC -> CGI PS cache */ |
| 130 | struct si_cache *si_cache; /* ARFC+BSIC -> CGI PS cache */ |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | |
| 134 | extern struct gprs_pcu *the_pcu; |
| 135 | |
| 136 | struct gprs_pcu *gprs_pcu_alloc(void *ctx); |
| 137 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 138 | struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_nr(struct gprs_pcu *pcu, uint8_t bts_nr); |
Pau Espin Pedrol | 3a27102 | 2021-01-21 18:44:23 +0100 | [diff] [blame] | 139 | struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_cgi_ps(struct gprs_pcu *pcu, struct osmo_cell_global_id_ps *cgi_ps); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 140 | |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 141 | void gprs_pcu_set_initial_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul); |
| 142 | void gprs_pcu_set_initial_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 143 | void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul); |
| 144 | void gprs_pcu_set_max_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul); |