~ubuntu-branches/debian/sid/osmo-pcu/sid

« back to all changes in this revision

Viewing changes to .pc/spelling.patch/src/tbf.h

  • Committer: Package Import Robot
  • Author(s): Thorsten Alteholz
  • Date: 2017-12-12 19:07:49 UTC
  • Revision ID: package-import@ubuntu.com-20171212190749-jicdjytnfb10cem5
Tags: 0.4.0-1
Initial release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 by Holger Hans Peter Freyther
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
17
 */
 
18
 
 
19
#pragma once
 
20
 
 
21
#ifdef __cplusplus
 
22
 
 
23
#include "gprs_rlcmac.h"
 
24
#include "llc.h"
 
25
#include "rlc.h"
 
26
#include "cxx_linuxlist.h"
 
27
#include <gprs_debug.h>
 
28
 
 
29
#include <stdint.h>
 
30
extern "C" {
 
31
#include <osmocom/core/utils.h>
 
32
}
 
33
 
 
34
struct bssgp_bvc_ctx;
 
35
struct rlc_ul_header;
 
36
struct msgb;
 
37
struct pcu_l1_meas;
 
38
class GprsMs;
 
39
 
 
40
/*
 
41
 * TBF instance
 
42
 */
 
43
 
 
44
#define Tassign_agch 0,200000   /* waiting after IMM.ASS confirm */
 
45
#define Tassign_pacch 2,0       /* timeout for pacch assigment */
 
46
#define Treject_pacch 0,2000    /* timeout for tbf reject for PRR*/
 
47
 
 
48
enum gprs_rlcmac_tbf_state {
 
49
        GPRS_RLCMAC_NULL = 0,   /* new created TBF */
 
50
        GPRS_RLCMAC_ASSIGN,     /* wait for downlink assignment */
 
51
        GPRS_RLCMAC_FLOW,       /* RLC/MAC flow, resource needed */
 
52
        GPRS_RLCMAC_FINISHED,   /* flow finished, wait for release */
 
53
        GPRS_RLCMAC_WAIT_RELEASE,/* wait for release or restart of DL TBF */
 
54
        GPRS_RLCMAC_RELEASING,  /* releasing, wait to free TBI/USF */
 
55
};
 
56
 
 
57
enum gprs_rlcmac_tbf_poll_type {
 
58
        GPRS_RLCMAC_POLL_UL_ASS,
 
59
        GPRS_RLCMAC_POLL_DL_ASS,
 
60
        GPRS_RLCMAC_POLL_UL_ACK,
 
61
        GPRS_RLCMAC_POLL_DL_ACK,
 
62
};
 
63
 
 
64
enum gprs_rlcmac_tbf_poll_state {
 
65
        GPRS_RLCMAC_POLL_NONE = 0,
 
66
        GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
 
67
};
 
68
 
 
69
enum gprs_rlcmac_tbf_dl_ass_state {
 
70
        GPRS_RLCMAC_DL_ASS_NONE = 0,
 
71
        GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */
 
72
        GPRS_RLCMAC_DL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
 
73
};
 
74
 
 
75
extern const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[];
 
76
 
 
77
enum gprs_rlcmac_tbf_ul_ass_state {
 
78
        GPRS_RLCMAC_UL_ASS_NONE = 0,
 
79
        GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
 
80
        GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
 
81
        GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
 
82
};
 
83
 
 
84
extern const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[];
 
85
 
 
86
enum gprs_rlcmac_tbf_ul_ack_state {
 
87
        GPRS_RLCMAC_UL_ACK_NONE = 0,
 
88
        GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */
 
89
        GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */
 
90
};
 
91
 
 
92
enum gprs_rlcmac_tbf_direction {
 
93
        GPRS_RLCMAC_DL_TBF,
 
94
        GPRS_RLCMAC_UL_TBF
 
95
};
 
96
 
 
97
enum tbf_counters {
 
98
        TBF_CTR_RLC_NACKED,
 
99
};
 
100
 
 
101
enum tbf_gprs_counters {
 
102
        TBF_CTR_GPRS_DL_CS1,
 
103
        TBF_CTR_GPRS_DL_CS2,
 
104
        TBF_CTR_GPRS_DL_CS3,
 
105
        TBF_CTR_GPRS_DL_CS4,
 
106
};
 
107
 
 
108
enum tbf_egprs_counters {
 
109
        TBF_CTR_EGPRS_DL_MCS1,
 
110
        TBF_CTR_EGPRS_DL_MCS2,
 
111
        TBF_CTR_EGPRS_DL_MCS3,
 
112
        TBF_CTR_EGPRS_DL_MCS4,
 
113
        TBF_CTR_EGPRS_DL_MCS5,
 
114
        TBF_CTR_EGPRS_DL_MCS6,
 
115
        TBF_CTR_EGPRS_DL_MCS7,
 
116
        TBF_CTR_EGPRS_DL_MCS8,
 
117
        TBF_CTR_EGPRS_DL_MCS9,
 
118
};
 
119
 
 
120
enum tbf_gprs_ul_counters {
 
121
        TBF_CTR_GPRS_UL_CS1,
 
122
        TBF_CTR_GPRS_UL_CS2,
 
123
        TBF_CTR_GPRS_UL_CS3,
 
124
        TBF_CTR_GPRS_UL_CS4,
 
125
};
 
126
 
 
127
enum tbf_egprs_ul_counters {
 
128
        TBF_CTR_EGPRS_UL_MCS1,
 
129
        TBF_CTR_EGPRS_UL_MCS2,
 
130
        TBF_CTR_EGPRS_UL_MCS3,
 
131
        TBF_CTR_EGPRS_UL_MCS4,
 
132
        TBF_CTR_EGPRS_UL_MCS5,
 
133
        TBF_CTR_EGPRS_UL_MCS6,
 
134
        TBF_CTR_EGPRS_UL_MCS7,
 
135
        TBF_CTR_EGPRS_UL_MCS8,
 
136
        TBF_CTR_EGPRS_UL_MCS9,
 
137
};
 
138
 
 
139
#define GPRS_RLCMAC_FLAG_CCCH           0 /* assignment on CCCH */
 
140
#define GPRS_RLCMAC_FLAG_PACCH          1 /* assignment on PACCH */
 
141
#define GPRS_RLCMAC_FLAG_UL_DATA        2 /* uplink data received */
 
142
#define GPRS_RLCMAC_FLAG_DL_ACK         3 /* downlink acknowledge received  */
 
143
#define GPRS_RLCMAC_FLAG_TO_UL_ACK      4
 
144
#define GPRS_RLCMAC_FLAG_TO_DL_ACK      5
 
145
#define GPRS_RLCMAC_FLAG_TO_UL_ASS      6
 
146
#define GPRS_RLCMAC_FLAG_TO_DL_ASS      7
 
147
#define GPRS_RLCMAC_FLAG_TO_MASK        0xf0 /* timeout bits */
 
148
 
 
149
struct gprs_rlcmac_tbf {
 
150
        gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir);
 
151
 
 
152
        static void free_all(struct gprs_rlcmac_trx *trx);
 
153
        static void free_all(struct gprs_rlcmac_pdch *pdch);
 
154
 
 
155
        bool state_is(enum gprs_rlcmac_tbf_state rhs) const;
 
156
        bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
 
157
        void set_state(enum gprs_rlcmac_tbf_state new_state);
 
158
        const char *state_name() const;
 
159
 
 
160
        const char *name() const;
 
161
 
 
162
        struct msgb *create_dl_ass(uint32_t fn, uint8_t ts);
 
163
        struct msgb *create_ul_ass(uint32_t fn, uint8_t ts);
 
164
        struct msgb *create_packet_access_reject();
 
165
 
 
166
        GprsMs *ms() const;
 
167
        void set_ms(GprsMs *ms);
 
168
 
 
169
        gprs_rlc_window *window();
 
170
 
 
171
        uint8_t tsc() const;
 
172
 
 
173
        int rlcmac_diag();
 
174
 
 
175
        int update();
 
176
        void handle_timeout();
 
177
        void stop_timer();
 
178
        void stop_t3191();
 
179
        int establish_dl_tbf_on_pacch();
 
180
 
 
181
        int check_polling(uint32_t fn, uint8_t ts,
 
182
                uint32_t *poll_fn, unsigned int *rrbp);
 
183
        void set_polling(uint32_t poll_fn, uint8_t ts, enum gprs_rlcmac_tbf_poll_type t);
 
184
        void poll_timeout();
 
185
 
 
186
        /** tlli handling */
 
187
        uint32_t tlli() const;
 
188
        bool is_tlli_valid() const;
 
189
 
 
190
        /** MS updating */
 
191
        void update_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction);
 
192
 
 
193
        uint8_t tfi() const;
 
194
        bool is_tfi_assigned() const;
 
195
 
 
196
        const char *imsi() const;
 
197
        void assign_imsi(const char *imsi);
 
198
        uint8_t ta() const;
 
199
        void set_ta(uint8_t);
 
200
        uint8_t ms_class() const;
 
201
        void set_ms_class(uint8_t);
 
202
        GprsCodingScheme current_cs() const;
 
203
        int llc_queue_size() const;
 
204
 
 
205
        time_t created_ts() const;
 
206
        uint8_t dl_slots() const;
 
207
        uint8_t ul_slots() const;
 
208
 
 
209
        bool is_control_ts(uint8_t ts) const;
 
210
 
 
211
        /* EGPRS */
 
212
        bool is_egprs_enabled() const;
 
213
        void enable_egprs();
 
214
        void disable_egprs();
 
215
 
 
216
        /* attempt to make things a bit more fair */
 
217
        void rotate_in_list();
 
218
 
 
219
        LListHead<gprs_rlcmac_tbf>& ms_list() {return this->m_ms_list;}
 
220
        const LListHead<gprs_rlcmac_tbf>& ms_list() const {return this->m_ms_list;}
 
221
 
 
222
        LListHead<gprs_rlcmac_tbf>& list();
 
223
        const LListHead<gprs_rlcmac_tbf>& list() const;
 
224
 
 
225
        uint32_t state_flags;
 
226
        enum gprs_rlcmac_tbf_direction direction;
 
227
        struct gprs_rlcmac_trx *trx;
 
228
        uint8_t first_ts; /* first TS used by TBF */
 
229
        uint8_t first_common_ts; /* first TS that the phone can send and
 
230
                reveive simultaniously */
 
231
        uint8_t control_ts; /* timeslot control messages and polling */
 
232
        struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */
 
233
 
 
234
        gprs_llc m_llc;
 
235
 
 
236
        enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
 
237
        enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
 
238
        enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
 
239
 
 
240
        enum gprs_rlcmac_tbf_poll_state poll_state;
 
241
        uint32_t poll_fn; /* frame number to poll */
 
242
        uint8_t poll_ts; /* TS to poll */
 
243
 
 
244
        gprs_rlc m_rlc;
 
245
        
 
246
        uint8_t n3105;  /* N3105 counter */
 
247
 
 
248
        struct osmo_timer_list  timer;
 
249
        unsigned int T; /* Txxxx number */
 
250
        unsigned int num_T_exp; /* number of consecutive T expirations */
 
251
        
 
252
        struct osmo_gsm_timer_list      gsm_timer;
 
253
        unsigned int fT; /* fTxxxx number */
 
254
        unsigned int num_fT_exp; /* number of consecutive fT expirations */
 
255
 
 
256
        struct Meas {
 
257
                struct timeval rssi_tv; /* timestamp for rssi calculation */
 
258
                int32_t rssi_sum; /* sum of rssi values */
 
259
                int rssi_num; /* number of rssi values added since rssi_tv */
 
260
 
 
261
                Meas();
 
262
        } meas;
 
263
 
 
264
        /* these should become protected but only after gprs_rlcmac_data.c
 
265
         * stops to iterate over all tbf in its current form */
 
266
        enum gprs_rlcmac_tbf_state state;
 
267
 
 
268
        /* Remember if the tbf was in wait_release state when we want to
 
269
         * schedule a new dl assignment */
 
270
        uint8_t was_releasing;
 
271
 
 
272
        /* Can/should we upgrade this tbf to use multiple slots? */
 
273
        uint8_t upgrade_to_multislot;
 
274
 
 
275
        /* store the BTS this TBF belongs to */
 
276
        BTS *bts;
 
277
 
 
278
        /*
 
279
         * private fields. We can't make it private as it is breaking the
 
280
         * llist macros.
 
281
         */
 
282
        uint8_t m_tfi;
 
283
        time_t m_created_ts;
 
284
 
 
285
        struct rate_ctr_group *m_ctrs;
 
286
 
 
287
protected:
 
288
        gprs_rlcmac_bts *bts_data() const;
 
289
 
 
290
        int set_tlli_from_ul(uint32_t new_tlli);
 
291
        void merge_and_clear_ms(GprsMs *old_ms);
 
292
 
 
293
        gprs_llc_queue *llc_queue();
 
294
        const gprs_llc_queue *llc_queue() const;
 
295
 
 
296
        static const char *tbf_state_name[6];
 
297
 
 
298
        class GprsMs *m_ms;
 
299
 
 
300
        /* Fields to take the TA/MS class values if no MS is associated */
 
301
        uint8_t m_ta;
 
302
        uint8_t m_ms_class;
 
303
 
 
304
private:
 
305
        LListHead<gprs_rlcmac_tbf> m_list;
 
306
        LListHead<gprs_rlcmac_tbf> m_ms_list;
 
307
        bool m_egprs_enabled;
 
308
 
 
309
        mutable char m_name_buf[60];
 
310
};
 
311
 
 
312
 
 
313
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
 
314
        int8_t use_trx, uint8_t ms_class, uint8_t egprs_ms_class,
 
315
        uint32_t tlli, uint8_t ta, GprsMs *ms);
 
316
 
 
317
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
 
318
        GprsMs *ms, int8_t use_trx,
 
319
        uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot);
 
320
 
 
321
struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
 
322
        GprsMs *ms, int8_t use_trx,
 
323
        uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot);
 
324
 
 
325
void tbf_free(struct gprs_rlcmac_tbf *tbf);
 
326
 
 
327
struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
 
328
        GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts_no);
 
329
 
 
330
int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
 
331
 
 
332
void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T,
 
333
                        unsigned int seconds, unsigned int microseconds);
 
334
 
 
335
inline bool gprs_rlcmac_tbf::state_is(enum gprs_rlcmac_tbf_state rhs) const
 
336
{
 
337
        return state == rhs;
 
338
}
 
339
 
 
340
inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
 
341
{
 
342
        return state != rhs;
 
343
}
 
344
 
 
345
const char *tbf_name(gprs_rlcmac_tbf *tbf);
 
346
 
 
347
inline const char *gprs_rlcmac_tbf::state_name() const
 
348
{
 
349
        return tbf_state_name[state];
 
350
}
 
351
 
 
352
inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state)
 
353
{
 
354
        LOGP(DRLCMAC, LOGL_DEBUG, "%s changes state from %s to %s\n",
 
355
                tbf_name(this),
 
356
                tbf_state_name[state], tbf_state_name[new_state]);
 
357
        state = new_state;
 
358
}
 
359
 
 
360
inline LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list()
 
361
{
 
362
        return this->m_list;
 
363
}
 
364
 
 
365
inline const LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list() const
 
366
{
 
367
        return this->m_list;
 
368
}
 
369
 
 
370
inline GprsMs *gprs_rlcmac_tbf::ms() const
 
371
{
 
372
        return m_ms;
 
373
}
 
374
 
 
375
inline bool gprs_rlcmac_tbf::is_tlli_valid() const
 
376
{
 
377
        return tlli() != 0;
 
378
}
 
379
 
 
380
inline bool gprs_rlcmac_tbf::is_tfi_assigned() const
 
381
{
 
382
        /* The TBF is established or has been assigned by a IMM.ASS for
 
383
         * download */
 
384
        return state > GPRS_RLCMAC_ASSIGN ||
 
385
                (direction == GPRS_RLCMAC_DL_TBF &&
 
386
                 state == GPRS_RLCMAC_ASSIGN &&
 
387
                 (state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)));
 
388
}
 
389
 
 
390
inline uint8_t gprs_rlcmac_tbf::tfi() const
 
391
{
 
392
        return m_tfi;
 
393
}
 
394
 
 
395
inline time_t gprs_rlcmac_tbf::created_ts() const
 
396
{
 
397
        return m_created_ts;
 
398
}
 
399
 
 
400
inline bool gprs_rlcmac_tbf::is_egprs_enabled() const
 
401
{
 
402
        return m_egprs_enabled;
 
403
}
 
404
 
 
405
inline void gprs_rlcmac_tbf::enable_egprs()
 
406
{
 
407
        m_egprs_enabled = true;
 
408
}
 
409
 
 
410
inline void gprs_rlcmac_tbf::disable_egprs()
 
411
{
 
412
        m_egprs_enabled = false;
 
413
}
 
414
 
 
415
struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
 
416
        gprs_rlcmac_dl_tbf(BTS *bts);
 
417
 
 
418
        void cleanup();
 
419
 
 
420
        /* dispatch Unitdata.DL messages */
 
421
        static int handle(struct gprs_rlcmac_bts *bts,
 
422
                const uint32_t tlli, const uint32_t old_tlli,
 
423
                const char *imsi, const uint8_t ms_class,
 
424
                const uint8_t egprs_ms_class, const uint16_t delay_csec,
 
425
                const uint8_t *data, const uint16_t len);
 
426
 
 
427
        int append_data(const uint8_t ms_class,
 
428
                        const uint16_t pdu_delay_csec,
 
429
                        const uint8_t *data, const uint16_t len);
 
430
 
 
431
        int rcvd_dl_ack(uint8_t final, uint8_t ssn, uint8_t *rbb);
 
432
        int rcvd_dl_ack(uint8_t final_ack, unsigned first_bsn, struct bitvec *rbb);
 
433
        struct msgb *create_dl_acked_block(uint32_t fn, uint8_t ts);
 
434
        void trigger_ass(struct gprs_rlcmac_tbf *old_tbf);
 
435
        void clear_poll_timeout_flag();
 
436
        bool handle_ack_nack();
 
437
        void request_dl_ack();
 
438
        bool need_control_ts() const;
 
439
        bool have_data() const;
 
440
        int frames_since_last_poll(unsigned fn) const;
 
441
        int frames_since_last_drain(unsigned fn) const;
 
442
        bool keep_open(unsigned fn) const;
 
443
        int release();
 
444
        int abort();
 
445
 
 
446
        void egprs_calc_window_size();
 
447
        void update_coding_scheme_counter_dl(const GprsCodingScheme cs);
 
448
 
 
449
        /* TODO: add the gettimeofday as parameter */
 
450
        struct msgb *llc_dequeue(bssgp_bvc_ctx *bctx);
 
451
 
 
452
        /* Please note that all variables here will be reset when changing
 
453
         * from WAIT RELEASE back to FLOW state (re-use of TBF).
 
454
         * All states that need reset must be in this struct, so this is why
 
455
         * variables are in both (dl and ul) structs and not outside union.
 
456
         */
 
457
        gprs_rlc_dl_window m_window;
 
458
        int32_t m_tx_counter; /* count all transmitted blocks */
 
459
        uint8_t m_wait_confirm; /* wait for CCCH IMM.ASS cnf */
 
460
        bool m_dl_ack_requested;
 
461
        int32_t m_last_dl_poll_fn;
 
462
        int32_t m_last_dl_drained_fn;
 
463
 
 
464
        struct BandWidth {
 
465
                struct timeval dl_bw_tv; /* timestamp for dl bw calculation */
 
466
                uint32_t dl_bw_octets; /* number of octets since bw_tv */
 
467
                uint32_t dl_throughput; /* throughput to be displayed in stats */
 
468
 
 
469
                struct timeval dl_loss_tv; /* timestamp for loss calculation */
 
470
                uint16_t dl_loss_lost; /* sum of lost packets */
 
471
                uint16_t dl_loss_received; /* sum of received packets */
 
472
 
 
473
                BandWidth();
 
474
        } m_bw;
 
475
 
 
476
        struct rate_ctr_group *m_dl_gprs_ctrs;
 
477
        struct rate_ctr_group *m_dl_egprs_ctrs;
 
478
 
 
479
protected:
 
480
        struct ana_result {
 
481
                unsigned received_packets;
 
482
                unsigned lost_packets;
 
483
                unsigned received_bytes;
 
484
                unsigned lost_bytes;
 
485
        };
 
486
 
 
487
        int take_next_bsn(uint32_t fn, int previous_bsn,
 
488
                bool *may_combine);
 
489
        bool restart_bsn_cycle();
 
490
        int create_new_bsn(const uint32_t fn, GprsCodingScheme cs);
 
491
        struct msgb *create_dl_acked_block(const uint32_t fn, const uint8_t ts,
 
492
                                        int index, int index2 = -1);
 
493
        int update_window(const uint8_t ssn, const uint8_t *rbb);
 
494
        int update_window(unsigned first_bsn, const struct bitvec *rbb);
 
495
        int maybe_start_new_window();
 
496
        bool dl_window_stalled() const;
 
497
        void reuse_tbf();
 
498
        void start_llc_timer();
 
499
        int analyse_errors(char *show_rbb, uint8_t ssn, ana_result *res);
 
500
        void schedule_next_frame();
 
501
 
 
502
        enum egprs_rlc_dl_reseg_bsn_state egprs_dl_get_data
 
503
                (int bsn, uint8_t **block_data);
 
504
        unsigned int get_egprs_dl_spb_status(int bsn);
 
505
        enum egprs_rlcmac_dl_spb get_egprs_dl_spb(int bsn);
 
506
 
 
507
        struct osmo_timer_list m_llc_timer;
 
508
};
 
509
 
 
510
struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
 
511
        gprs_rlcmac_ul_tbf(BTS *bts);
 
512
 
 
513
        struct msgb *create_ul_ack(uint32_t fn, uint8_t ts);
 
514
        bool ctrl_ack_to_toggle();
 
515
        bool handle_ctrl_ack();
 
516
 
 
517
        /* blocks were acked */
 
518
        int rcv_data_block_acknowledged(
 
519
                const struct gprs_rlc_data_info *rlc,
 
520
                uint8_t *data, struct pcu_l1_meas *meas);
 
521
 
 
522
 
 
523
        /* TODO: extract LLC class? */
 
524
        int assemble_forward_llc(const gprs_rlc_data *data);
 
525
        int snd_ul_ud();
 
526
 
 
527
        egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_spb(
 
528
                const struct gprs_rlc_data_info *rlc,
 
529
                struct gprs_rlc_data *block,
 
530
                uint8_t *data, const uint8_t block_idx);
 
531
 
 
532
        egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_first_seg(
 
533
                const struct gprs_rlc_data_info *rlc,
 
534
                struct gprs_rlc_data *block,
 
535
                uint8_t *data, const uint8_t block_idx);
 
536
 
 
537
        egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_second_seg(
 
538
                const struct gprs_rlc_data_info *rlc,
 
539
                struct gprs_rlc_data *block,
 
540
                uint8_t *data, const uint8_t block_idx);
 
541
 
 
542
        void egprs_calc_ulwindow_size();
 
543
 
 
544
        void update_coding_scheme_counter_ul(const GprsCodingScheme cs);
 
545
 
 
546
        /* Please note that all variables here will be reset when changing
 
547
         * from WAIT RELEASE back to FLOW state (re-use of TBF).
 
548
         * All states that need reset must be in this struct, so this is why
 
549
         * variables are in both (dl and ul) structs and not outside union.
 
550
         */
 
551
        gprs_rlc_ul_window m_window;
 
552
        int32_t m_rx_counter; /* count all received blocks */
 
553
        uint8_t m_n3103;        /* N3103 counter */
 
554
        uint8_t m_usf[8];       /* list USFs per PDCH (timeslot) */
 
555
        uint8_t m_contention_resolution_done; /* set after done */
 
556
        uint8_t m_final_ack_sent; /* set if we sent final ack */
 
557
 
 
558
        struct rate_ctr_group *m_ul_gprs_ctrs;
 
559
        struct rate_ctr_group *m_ul_egprs_ctrs;
 
560
 
 
561
protected:
 
562
        void maybe_schedule_uplink_acknack(const gprs_rlc_data_info *rlc);
 
563
};
 
564
 
 
565
inline enum gprs_rlcmac_tbf_direction reverse(enum gprs_rlcmac_tbf_direction dir)
 
566
{
 
567
        return (enum gprs_rlcmac_tbf_direction)
 
568
                ((int)GPRS_RLCMAC_UL_TBF - (int)dir + (int)GPRS_RLCMAC_DL_TBF);
 
569
}
 
570
 
 
571
inline gprs_rlcmac_ul_tbf *as_ul_tbf(gprs_rlcmac_tbf *tbf)
 
572
{
 
573
        if (tbf && tbf->direction == GPRS_RLCMAC_UL_TBF)
 
574
                return static_cast<gprs_rlcmac_ul_tbf *>(tbf);
 
575
        else
 
576
                return NULL;
 
577
}
 
578
 
 
579
inline gprs_rlcmac_dl_tbf *as_dl_tbf(gprs_rlcmac_tbf *tbf)
 
580
{
 
581
        if (tbf && tbf->direction == GPRS_RLCMAC_DL_TBF)
 
582
                return static_cast<gprs_rlcmac_dl_tbf *>(tbf);
 
583
        else
 
584
                return NULL;
 
585
}
 
586
 
 
587
inline gprs_rlc_window *gprs_rlcmac_tbf::window()
 
588
{
 
589
        switch (direction)
 
590
        {
 
591
        case GPRS_RLCMAC_UL_TBF: return &as_ul_tbf(this)->m_window;
 
592
        case GPRS_RLCMAC_DL_TBF: return &as_dl_tbf(this)->m_window;
 
593
        }
 
594
        return NULL;
 
595
}
 
596
 
 
597
#endif