Max | 6dc90b8 | 2018-02-19 17:17:28 +0100 | [diff] [blame] | 1 | /* 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 |
| 25 | extern "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 | */ |
| 41 | struct 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 |
| 96 | private: |
Pau Espin Pedrol | e13cdc5 | 2019-09-25 13:46:14 +0200 | [diff] [blame] | 97 | int rcv_control_block(const uint8_t *data, uint8_t data_len, uint32_t fn, |
| 98 | struct pcu_l1_meas *meas, GprsCodingScheme cs); |
Max | 6dc90b8 | 2018-02-19 17:17:28 +0100 | [diff] [blame] | 99 | |
| 100 | void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn); |
Pau Espin Pedrol | e13cdc5 | 2019-09-25 13:46:14 +0200 | [diff] [blame] | 101 | void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn, struct pcu_l1_meas *meas); |
| 102 | void rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *, uint32_t fn, struct pcu_l1_meas *meas); |
| 103 | void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn, struct pcu_l1_meas *meas); |
Max | 6dc90b8 | 2018-02-19 17:17:28 +0100 | [diff] [blame] | 104 | void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn); |
| 105 | gprs_rlcmac_tbf *tbf_from_list_by_tfi( |
| 106 | LListHead<gprs_rlcmac_tbf> *tbf_list, uint8_t tfi, |
| 107 | enum gprs_rlcmac_tbf_direction dir); |
| 108 | gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, |
| 109 | enum gprs_rlcmac_tbf_direction dir); |
| 110 | #endif |
| 111 | |
| 112 | uint8_t m_num_tbfs[2]; |
| 113 | uint8_t m_num_reserved[2]; |
| 114 | uint8_t m_assigned_usf; /* bit set */ |
| 115 | uint32_t m_assigned_tfi[2]; /* bit set */ |
| 116 | struct gprs_rlcmac_tbf *m_tbfs[2][32]; |
| 117 | }; |
| 118 | |
| 119 | #ifdef __cplusplus |
| 120 | |
| 121 | inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const |
| 122 | { |
| 123 | return m_num_tbfs[dir]; |
| 124 | } |
| 125 | |
| 126 | inline unsigned gprs_rlcmac_pdch::num_reserved( |
| 127 | enum gprs_rlcmac_tbf_direction dir) const |
| 128 | { |
| 129 | return gprs_rlcmac_pdch::m_num_reserved[dir]; |
| 130 | } |
| 131 | |
| 132 | inline uint8_t gprs_rlcmac_pdch::assigned_usf() const |
| 133 | { |
| 134 | return m_assigned_usf; |
| 135 | } |
| 136 | |
| 137 | inline uint32_t gprs_rlcmac_pdch::assigned_tfi( |
| 138 | enum gprs_rlcmac_tbf_direction dir) const |
| 139 | { |
| 140 | return m_assigned_tfi[dir]; |
| 141 | } |
| 142 | |
| 143 | inline bool gprs_rlcmac_pdch::is_enabled() const |
| 144 | { |
| 145 | return m_is_enabled; |
| 146 | } |
| 147 | |
| 148 | #endif /* __cplusplus */ |