blob: 1b0227f44df0ef0810bcb0d29c243833f67c02b8 [file] [log] [blame]
Pau Espin Pedrolff335972023-07-26 16:14:52 +02001/* RLC Window (common for both UL/DL TBF), 3GPP TS 44.060
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
4 * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
5 * Copyright (C) 2023 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17#pragma once
18
19#include <stdint.h>
20
21#include "rlc.h"
22
23#define RLC_GPRS_WS 64 /* max window size */
24#define RLC_EGPRS_MIN_WS 64 /* min window size */
25#define RLC_EGPRS_MAX_WS 1024 /* min window size */
26#define RLC_EGPRS_MAX_BSN_DELTA 512
27#define RLC_MAX_WS RLC_EGPRS_MAX_WS
28
29class gprs_rlc_window {
30public:
31 gprs_rlc_window();
32
33 const uint16_t mod_sns(void) const;
34 const uint16_t mod_sns(uint16_t bsn) const;
35 const uint16_t sns(void) const;
36 const uint16_t ws(void) const;
37
38 void set_sns(uint16_t sns);
39 void set_ws(uint16_t ws);
40
41protected:
42 uint16_t m_sns;
43 uint16_t m_ws;
44};
45
46
47inline gprs_rlc_window::gprs_rlc_window(void)
48 : m_sns(RLC_GPRS_SNS)
49 , m_ws(RLC_GPRS_WS)
50{
51}
52
53inline const uint16_t gprs_rlc_window::sns(void) const
54{
55 return m_sns;
56}
57
58inline const uint16_t gprs_rlc_window::ws(void) const
59{
60 return m_ws;
61}
62
63inline const uint16_t gprs_rlc_window::mod_sns(void) const
64{
65 return sns() - 1;
66}
67
68inline const uint16_t gprs_rlc_window::mod_sns(uint16_t bsn) const
69{
70 return bsn & mod_sns();
71}