blob: cf9804d095f1baaece95842508f8485eef5719e9 [file] [log] [blame]
Max6dc90b82018-02-19 17:17:28 +01001/* pdch.h
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
4 * Copyright (C) 2013 by Holger Hans Peter Freyther
5 * Copyright (C) 2018 by 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 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#pragma once
23
24#ifdef __cplusplus
25extern "C" {
26#include <osmocom/core/linuxlist.h>
27}
28
29#include <gsm_rlcmac.h>
30#include <gprs_coding_scheme.h>
31#include <bts.h>
32#endif
33
34#include <tbf.h>
35
36#include <stdint.h>
37
38/*
39 * PDCH instance
40 */
41struct gprs_rlcmac_pdch {
42#ifdef __cplusplus
43 struct gprs_rlcmac_paging *dequeue_paging();
44 struct msgb *packet_paging_request();
45
46 bool add_paging(uint8_t chan_needed, uint8_t *identity_lv);
47
48 void free_resources();
49
50 bool is_enabled() const;
51
52 void enable();
53 void disable();
54
55 /* dispatching of messages */
56 int rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
57 struct pcu_l1_meas *meas);
58 int rcv_block_gprs(uint8_t *data, uint8_t data_len, uint32_t fn,
59 struct pcu_l1_meas *meas, GprsCodingScheme cs);
60 int rcv_data_block(uint8_t *data, uint8_t data_len, uint32_t fn,
61 struct pcu_l1_meas *meas, GprsCodingScheme cs);
62
63 gprs_rlcmac_bts *bts_data() const;
64 BTS *bts() const;
65 uint8_t trx_no() const;
66
67 struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi);
68 struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi);
69
70 void attach_tbf(gprs_rlcmac_tbf *tbf);
71 void detach_tbf(gprs_rlcmac_tbf *tbf);
72
73 unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const;
74
75 void reserve(enum gprs_rlcmac_tbf_direction dir);
76 void unreserve(enum gprs_rlcmac_tbf_direction dir);
77 unsigned num_reserved(enum gprs_rlcmac_tbf_direction dir) const;
78
79 uint8_t assigned_usf() const;
80 uint32_t assigned_tfi(enum gprs_rlcmac_tbf_direction dir) const;
81#endif
82
83 uint8_t m_is_enabled; /* TS is enabled */
84 uint8_t tsc; /* TSC of this slot */
85 uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */
86 uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */
87 uint8_t next_ctrl_prio; /* next kind of ctrl message to schedule */
88 struct llist_head paging_list; /* list of paging messages */
89 uint32_t last_rts_fn; /* store last frame number of RTS */
90
91 /* back pointers */
92 struct gprs_rlcmac_trx *trx;
93 uint8_t ts_no;
94
95#ifdef __cplusplus
96private:
97 int rcv_control_block(const uint8_t *data, uint8_t data_len, bitvec *rlc_block, uint32_t fn);
98
99 void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn);
100 void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn);
101 void rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *, uint32_t fn);
102 void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn);
103 void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn);
104 gprs_rlcmac_tbf *tbf_from_list_by_tfi(
105 LListHead<gprs_rlcmac_tbf> *tbf_list, uint8_t tfi,
106 enum gprs_rlcmac_tbf_direction dir);
107 gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi,
108 enum gprs_rlcmac_tbf_direction dir);
109#endif
110
111 uint8_t m_num_tbfs[2];
112 uint8_t m_num_reserved[2];
113 uint8_t m_assigned_usf; /* bit set */
114 uint32_t m_assigned_tfi[2]; /* bit set */
115 struct gprs_rlcmac_tbf *m_tbfs[2][32];
116};
117
118#ifdef __cplusplus
119
120inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const
121{
122 return m_num_tbfs[dir];
123}
124
125inline unsigned gprs_rlcmac_pdch::num_reserved(
126 enum gprs_rlcmac_tbf_direction dir) const
127{
128 return gprs_rlcmac_pdch::m_num_reserved[dir];
129}
130
131inline uint8_t gprs_rlcmac_pdch::assigned_usf() const
132{
133 return m_assigned_usf;
134}
135
136inline uint32_t gprs_rlcmac_pdch::assigned_tfi(
137 enum gprs_rlcmac_tbf_direction dir) const
138{
139 return m_assigned_tfi[dir];
140}
141
142inline bool gprs_rlcmac_pdch::is_enabled() const
143{
144 return m_is_enabled;
145}
146
147#endif /* __cplusplus */