Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1 | /* gprs_bssgp_pcu.h |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 2 | * |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
Holger Hans Peter Freyther | c0f1644 | 2013-08-22 08:40:33 +0200 | [diff] [blame] | 4 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 15 | */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 16 | |
| 17 | #ifndef GPRS_BSSGP_PCU_H |
| 18 | #define GPRS_BSSGP_PCU_H |
| 19 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 20 | #ifdef __cplusplus |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 21 | extern "C" { |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 22 | #endif |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 23 | #include <osmocom/core/talloc.h> |
| 24 | #include <osmocom/core/rate_ctr.h> |
Ivan Kluchnikov | a9f1ff2 | 2012-05-24 22:25:06 +0400 | [diff] [blame] | 25 | #include <osmocom/core/logging.h> |
Harald Welte | d679009 | 2012-06-18 12:21:03 +0800 | [diff] [blame] | 26 | #include <osmocom/core/signal.h> |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 27 | #include <osmocom/core/application.h> |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 28 | #include <osmocom/gprs/gprs_ns2.h> |
Harald Welte | d679009 | 2012-06-18 12:21:03 +0800 | [diff] [blame] | 29 | #include <osmocom/gprs/gprs_bssgp.h> |
Andreas Eversberg | 4b39dd1 | 2012-09-23 05:03:56 +0200 | [diff] [blame] | 30 | #include <osmocom/gprs/gprs_bssgp_bss.h> |
Harald Welte | d679009 | 2012-06-18 12:21:03 +0800 | [diff] [blame] | 31 | #include <osmocom/gprs/gprs_msgb.h> |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 32 | |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 33 | struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 34 | |
Ivan Kluchnikov | a9f1ff2 | 2012-05-24 22:25:06 +0400 | [diff] [blame] | 35 | #include <gprs_debug.h> |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 36 | |
Pau Espin Pedrol | 1de6873 | 2020-03-11 14:04:52 +0100 | [diff] [blame] | 37 | #include <time.h> |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 38 | #include <unistd.h> |
Pau Espin Pedrol | 1de6873 | 2020-03-11 14:04:52 +0100 | [diff] [blame] | 39 | |
Andreas Eversberg | 4b39dd1 | 2012-09-23 05:03:56 +0200 | [diff] [blame] | 40 | #define QOS_PROFILE 4 |
Ivan Kluchnikov | 3fa42b2 | 2012-06-04 19:07:25 +0400 | [diff] [blame] | 41 | #define BSSGP_HDR_LEN 53 |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 42 | #define NS_HDR_LEN 4 |
Ivan Kluchnikov | b172b1b | 2012-06-07 01:51:49 +0400 | [diff] [blame] | 43 | #define IE_LLC_PDU 14 |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 44 | |
Oliver Smith | 9783967 | 2021-07-05 11:11:42 +0200 | [diff] [blame] | 45 | enum sgsn_counter_id { |
| 46 | SGSN_CTR_RX_PAGING_CS, |
| 47 | SGSN_CTR_RX_PAGING_PS, |
| 48 | }; |
| 49 | |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 50 | struct gprs_bssgp_pcu { |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 51 | struct bssgp_bvc_ctx *bctx; |
| 52 | |
| 53 | struct gprs_rlcmac_bts *bts; |
| 54 | |
| 55 | struct osmo_timer_list bvc_timer; |
| 56 | |
Oliver Smith | 9783967 | 2021-07-05 11:11:42 +0200 | [diff] [blame] | 57 | struct rate_ctr_group *ctrs; |
| 58 | |
Alexander Couzens | 5d37684 | 2021-02-22 01:45:17 +0100 | [diff] [blame] | 59 | /* state: is the NSVC unblocked? */ |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 60 | int nsvc_unblocked; |
| 61 | |
Alexander Couzens | 5d37684 | 2021-02-22 01:45:17 +0100 | [diff] [blame] | 62 | /* state: true if bvc signalling needs to be reseted or waiting for reset ack */ |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 63 | int bvc_sig_reset; |
Alexander Couzens | 5d37684 | 2021-02-22 01:45:17 +0100 | [diff] [blame] | 64 | /* state: true if bvc ptp needs to be reseted or waiting for reset ack */ |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 65 | int bvc_reset; |
Alexander Couzens | 5d37684 | 2021-02-22 01:45:17 +0100 | [diff] [blame] | 66 | /* state: true if bvc ptp is unblocked */ |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 67 | int bvc_unblocked; |
Holger Hans Peter Freyther | c0f1644 | 2013-08-22 08:40:33 +0200 | [diff] [blame] | 68 | |
Jacob Erlbeck | 6e4ccec | 2015-05-06 14:24:36 +0200 | [diff] [blame] | 69 | /* Flow control */ |
Pau Espin Pedrol | 1de6873 | 2020-03-11 14:04:52 +0100 | [diff] [blame] | 70 | struct timespec queue_delay_sum; |
Jacob Erlbeck | 6e4ccec | 2015-05-06 14:24:36 +0200 | [diff] [blame] | 71 | unsigned queue_delay_count; |
Jacob Erlbeck | 6eeb7c7 | 2015-05-06 15:26:08 +0200 | [diff] [blame] | 72 | uint8_t fc_tag; |
Jacob Erlbeck | 2db0f08 | 2015-09-07 18:49:00 +0200 | [diff] [blame] | 73 | unsigned queue_frames_sent; |
| 74 | unsigned queue_bytes_recv; |
| 75 | unsigned queue_frames_recv; |
Jacob Erlbeck | 6e4ccec | 2015-05-06 14:24:36 +0200 | [diff] [blame] | 76 | |
Holger Hans Peter Freyther | c0f1644 | 2013-08-22 08:40:33 +0200 | [diff] [blame] | 77 | /** callbacks below */ |
| 78 | |
| 79 | /* The BSSGP has been unblocked */ |
| 80 | void (*on_unblock_ack)(struct gprs_bssgp_pcu *pcu); |
Holger Hans Peter Freyther | 416ce69 | 2013-08-22 08:44:04 +0200 | [diff] [blame] | 81 | |
| 82 | /* When BSSGP data arrives. The msgb is not only for reference */ |
| 83 | void (*on_dl_unit_data)(struct gprs_bssgp_pcu *pcu, struct msgb *msg, |
| 84 | struct tlv_parsed *tp); |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 85 | }; |
| 86 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 87 | int gprs_gp_send_cb(void *ctx, struct msgb *msg); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 88 | int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx); |
| 89 | void gprs_bssgp_update_queue_delay(const struct timespec *tv_recv, |
| 90 | const struct timespec *tv_now); |
| 91 | void gprs_bssgp_update_frames_sent(); |
| 92 | void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv); |
| 93 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 94 | struct gprs_bssgp_pcu *gprs_bssgp_init( |
| 95 | struct gprs_rlcmac_bts *bts, |
| 96 | uint16_t nsei, uint16_t bvci, |
| 97 | uint16_t mcc, uint16_t mnc, bool mnc_3_digits, |
Holger Hans Peter Freyther | b67a8a3 | 2013-07-28 18:55:14 +0200 | [diff] [blame] | 98 | uint16_t lac, uint16_t rac, uint16_t cell_id); |
Andreas Eversberg | bf5a0f6 | 2012-07-06 08:58:22 +0200 | [diff] [blame] | 99 | |
Alexander Couzens | 94a367f | 2021-02-16 16:57:15 +0100 | [diff] [blame] | 100 | int gprs_ns_update_config(struct gprs_rlcmac_bts *bts, uint16_t nsei, |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 101 | const struct osmo_sockaddr *local, |
| 102 | const struct osmo_sockaddr *remote, |
| 103 | uint16_t *nsvci, uint16_t valid); |
Alexander Couzens | eb64d43 | 2019-05-25 03:10:51 +0200 | [diff] [blame] | 104 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 105 | void gprs_bssgp_destroy(struct gprs_rlcmac_bts *bts); |
Andreas Eversberg | bf5a0f6 | 2012-07-06 08:58:22 +0200 | [diff] [blame] | 106 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 107 | #ifdef __cplusplus |
| 108 | } |
| 109 | #endif |
Jacob Erlbeck | 6e4ccec | 2015-05-06 14:24:36 +0200 | [diff] [blame] | 110 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 111 | #endif // GPRS_BSSGP_PCU_H |