blob: e8ae1a9ce30dd3080d69915d1c29aea9096b3fdf [file] [log] [blame]
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04001/* gprs_bssgp_pcu.h
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +04002 *
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04003 * Copyright (C) 2012 Ivan Klyuchnikov
Holger Hans Peter Freytherc0f16442013-08-22 08:40:33 +02004 * Copyright (C) 2013 by Holger Hans Peter Freyther
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +04005 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040020
21#ifndef GPRS_BSSGP_PCU_H
22#define GPRS_BSSGP_PCU_H
23
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040024
25extern "C" {
26#include <osmocom/core/talloc.h>
27#include <osmocom/core/rate_ctr.h>
Ivan Kluchnikova9f1ff22012-05-24 22:25:06 +040028#include <osmocom/core/logging.h>
Harald Welted6790092012-06-18 12:21:03 +080029#include <osmocom/core/signal.h>
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040030#include <osmocom/core/application.h>
Harald Welted6790092012-06-18 12:21:03 +080031#include <osmocom/gprs/gprs_ns.h>
32#include <osmocom/gprs/gprs_bssgp.h>
Andreas Eversberg4b39dd12012-09-23 05:03:56 +020033#include <osmocom/gprs/gprs_bssgp_bss.h>
Harald Welted6790092012-06-18 12:21:03 +080034#include <osmocom/gprs/gprs_msgb.h>
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040035
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040036struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei);
37}
Ivan Kluchnikova9f1ff22012-05-24 22:25:06 +040038#include <gprs_debug.h>
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040039
Andreas Eversberg4b39dd12012-09-23 05:03:56 +020040#define QOS_PROFILE 4
Ivan Kluchnikov3fa42b22012-06-04 19:07:25 +040041#define BSSGP_HDR_LEN 53
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040042#define NS_HDR_LEN 4
Ivan Kluchnikovb172b1b2012-06-07 01:51:49 +040043#define IE_LLC_PDU 14
Ivan Kluchnikov5c2f9fb2012-02-05 02:27:17 +040044
Holger Hans Peter Freythere8d9a5f2013-07-28 19:11:20 +020045struct gprs_bssgp_pcu {
46 struct gprs_nsvc *nsvc;
47 struct bssgp_bvc_ctx *bctx;
48
49 struct gprs_rlcmac_bts *bts;
50
51 struct osmo_timer_list bvc_timer;
52
53 int nsvc_unblocked;
54
55 int bvc_sig_reset;
56 int bvc_reset;
57 int bvc_unblocked;
Holger Hans Peter Freytherc0f16442013-08-22 08:40:33 +020058
Jacob Erlbeck6e4ccec2015-05-06 14:24:36 +020059 /* Flow control */
60 struct timeval queue_delay_sum;
61 unsigned queue_delay_count;
Jacob Erlbeck6eeb7c72015-05-06 15:26:08 +020062 uint8_t fc_tag;
Jacob Erlbeck2db0f082015-09-07 18:49:00 +020063 unsigned queue_frames_sent;
64 unsigned queue_bytes_recv;
65 unsigned queue_frames_recv;
Jacob Erlbeck6e4ccec2015-05-06 14:24:36 +020066
Holger Hans Peter Freytherc0f16442013-08-22 08:40:33 +020067 /** callbacks below */
68
69 /* The BSSGP has been unblocked */
70 void (*on_unblock_ack)(struct gprs_bssgp_pcu *pcu);
Holger Hans Peter Freyther416ce692013-08-22 08:44:04 +020071
72 /* When BSSGP data arrives. The msgb is not only for reference */
73 void (*on_dl_unit_data)(struct gprs_bssgp_pcu *pcu, struct msgb *msg,
74 struct tlv_parsed *tp);
Holger Hans Peter Freythere8d9a5f2013-07-28 19:11:20 +020075};
76
77struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts *bts,
78 uint16_t local_port,
Holger Hans Peter Freytherb67a8a32013-07-28 18:55:14 +020079 uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei,
Neels Hofmeyrbdc55fa2018-02-21 00:39:07 +010080 uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, bool mnc_3_digits,
Holger Hans Peter Freytherb67a8a32013-07-28 18:55:14 +020081 uint16_t lac, uint16_t rac, uint16_t cell_id);
Andreas Eversbergbf5a0f62012-07-06 08:58:22 +020082
Daniel Willmann6d8884d2014-06-04 18:30:59 +020083void gprs_bssgp_destroy(void);
Andreas Eversbergbf5a0f62012-07-06 08:58:22 +020084
Holger Hans Peter Freyther90692f92013-07-13 12:51:16 +020085struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void);
86
Jacob Erlbeck1e50a3d2015-06-16 10:18:42 +020087void gprs_bssgp_update_queue_delay(const struct timeval *tv_recv,
88 const struct timeval *tv_now);
Jacob Erlbeck2db0f082015-09-07 18:49:00 +020089void gprs_bssgp_update_frames_sent();
90void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv);
Jacob Erlbeck6e4ccec2015-05-06 14:24:36 +020091
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040092#endif // GPRS_BSSGP_PCU_H