Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1 | /* pcu_l1_if.h |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 2 | * |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 20 | #ifndef PCU_L1_IF_H |
| 21 | #define PCU_L1_IF_H |
Ivan Kluchnikov | 5c2f9fb | 2012-02-05 02:27:17 +0400 | [diff] [blame] | 22 | |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 23 | #include <stdint.h> |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 24 | #ifdef __cplusplus |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 25 | extern "C" { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 26 | #endif |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 27 | #include <osmocom/core/write_queue.h> |
| 28 | #include <osmocom/core/socket.h> |
| 29 | #include <osmocom/core/timer.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 30 | #include <osmocom/core/bitvec.h> |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 31 | #include <osmocom/gsm/gsm_utils.h> |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 32 | #ifdef __cplusplus |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 33 | } |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 34 | #endif |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 35 | |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 36 | /* |
| 37 | * L1 Measurement values |
| 38 | */ |
| 39 | |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 40 | struct pcu_l1_meas_ts { |
| 41 | unsigned have_ms_i_level:1; |
| 42 | |
| 43 | int16_t ms_i_level; /* I_LEVEL in dB */ |
| 44 | |
| 45 | #ifdef __cplusplus |
| 46 | pcu_l1_meas_ts& set_ms_i_level(int16_t v) { |
| 47 | ms_i_level = v; have_ms_i_level = 1; return *this; |
| 48 | } |
| 49 | |
| 50 | pcu_l1_meas_ts() : |
| 51 | have_ms_i_level(0) |
| 52 | {} |
| 53 | #endif |
| 54 | }; |
| 55 | |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 56 | struct pcu_l1_meas { |
| 57 | unsigned have_rssi:1; |
| 58 | unsigned have_ber:1; |
| 59 | unsigned have_bto:1; |
| 60 | unsigned have_link_qual:1; |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 61 | unsigned have_ms_rx_qual:1; |
| 62 | unsigned have_ms_c_value:1; |
| 63 | unsigned have_ms_sign_var:1; |
| 64 | unsigned have_ms_i_level:1; |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 65 | |
| 66 | int8_t rssi; /* RSSI in dBm */ |
| 67 | uint8_t ber; /* Bit error rate in % */ |
| 68 | int16_t bto; /* Burst timing offset in quarter bits */ |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 69 | int16_t link_qual; /* Link quality in dB */ |
| 70 | int16_t ms_rx_qual; /* MS RXQUAL value in % */ |
| 71 | int16_t ms_c_value; /* C value in dB */ |
| 72 | int16_t ms_sign_var; /* SIGN_VAR in dB */ |
| 73 | |
| 74 | struct pcu_l1_meas_ts ts[8]; |
| 75 | |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 76 | #ifdef __cplusplus |
| 77 | pcu_l1_meas& set_rssi(int8_t v) { rssi = v; have_rssi = 1; return *this;} |
| 78 | pcu_l1_meas& set_ber(uint8_t v) { ber = v; have_ber = 1; return *this;} |
| 79 | pcu_l1_meas& set_bto(int16_t v) { bto = v; have_bto = 1; return *this;} |
| 80 | pcu_l1_meas& set_link_qual(int16_t v) { |
| 81 | link_qual = v; have_link_qual = 1; return *this; |
| 82 | } |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 83 | pcu_l1_meas& set_ms_rx_qual(int16_t v) { |
| 84 | ms_rx_qual = v; have_ms_rx_qual = 1; return *this; |
| 85 | } |
| 86 | pcu_l1_meas& set_ms_c_value(int16_t v) { |
| 87 | ms_c_value = v; have_ms_c_value = 1; return *this; |
| 88 | } |
| 89 | pcu_l1_meas& set_ms_sign_var(int16_t v) { |
| 90 | ms_sign_var = v; have_ms_sign_var = 1; return *this; |
| 91 | } |
| 92 | pcu_l1_meas& set_ms_i_level(size_t idx, int16_t v) { |
| 93 | ts[idx].set_ms_i_level(v); have_ms_i_level = 1; return *this; |
| 94 | } |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 95 | pcu_l1_meas() : |
| 96 | have_rssi(0), |
| 97 | have_ber(0), |
| 98 | have_bto(0), |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 99 | have_link_qual(0), |
| 100 | have_ms_rx_qual(0), |
| 101 | have_ms_c_value(0), |
| 102 | have_ms_sign_var(0), |
| 103 | have_ms_i_level(0) |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 104 | {} |
| 105 | #endif |
| 106 | }; |
| 107 | |
| 108 | #ifdef __cplusplus |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 109 | void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 110 | uint32_t fn, uint8_t block_nr); |
| 111 | void pcu_l1if_tx_ptcch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 112 | uint32_t fn, uint8_t block_nr); |
| 113 | void pcu_l1if_tx_agch(bitvec * block, int len); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 114 | |
Holger Hans Peter Freyther | 52c911b | 2013-08-24 18:30:54 +0200 | [diff] [blame] | 115 | void pcu_l1if_tx_pch(bitvec * block, int plen, const char *imsi); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 116 | |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 117 | int pcu_l1if_open(void); |
| 118 | void pcu_l1if_close(void); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 119 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 120 | int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim); |
| 121 | int pcu_sock_send(struct msgb *msg); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 122 | #endif |
| 123 | |
| 124 | #ifdef __cplusplus |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 125 | extern "C" { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 126 | #endif |
| 127 | int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 128 | uint32_t fn, uint8_t block_nr); |
| 129 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 130 | int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data, |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 131 | uint8_t len, uint32_t fn, struct pcu_l1_meas *meas); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 132 | |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 133 | void pcu_rx_block_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no); |
| 134 | void pcu_rx_ra_time(uint16_t arfcn, uint32_t fn, uint8_t ts_no); |
| 135 | |
| 136 | #ifdef __cplusplus |
| 137 | } |
| 138 | #endif |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 139 | #endif // PCU_L1_IF_H |