Yves Godin | 660709d | 2016-05-19 11:08:03 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com> |
| 2 | * based on: |
| 3 | * femto_l1_if.h |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (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 Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef _LC15_L1_IF_H |
| 23 | #define _LC15_L1_IF_H |
| 24 | |
| 25 | #include <osmocom/core/select.h> |
| 26 | #include <osmocom/core/write_queue.h> |
| 27 | #include <osmocom/core/gsmtap_util.h> |
| 28 | #include <osmocom/gsm/gsm_utils.h> |
| 29 | #include "lc15bts.h" |
| 30 | |
| 31 | enum { |
| 32 | MQ_SYS_READ, |
| 33 | MQ_L1_READ, |
| 34 | MQ_TCH_READ, |
| 35 | MQ_PDTCH_READ, |
| 36 | _NUM_MQ_READ |
| 37 | }; |
| 38 | |
| 39 | enum { |
| 40 | MQ_SYS_WRITE, |
| 41 | MQ_L1_WRITE, |
| 42 | MQ_TCH_WRITE, |
| 43 | MQ_PDTCH_WRITE, |
| 44 | _NUM_MQ_WRITE |
| 45 | }; |
| 46 | |
| 47 | struct lc15l1_hdl { |
| 48 | struct gsm_time gsm_time; |
| 49 | uint32_t hLayer1; /* handle to the L1 instance in the DSP */ |
| 50 | uint32_t dsp_trace_f; |
| 51 | struct llist_head wlc_list; |
| 52 | |
| 53 | struct gsmtap_inst *gsmtap; |
| 54 | uint32_t gsmtap_sapi_mask; |
| 55 | |
| 56 | uint8_t trx_no; |
| 57 | |
| 58 | struct osmo_timer_list alive_timer; |
| 59 | unsigned int alive_prim_cnt; |
| 60 | |
| 61 | struct osmo_fd read_ofd[_NUM_MQ_READ]; /* osmo file descriptors */ |
| 62 | struct osmo_wqueue write_q[_NUM_MQ_WRITE]; |
| 63 | |
| 64 | struct { |
| 65 | int trx_nr; /* <1-2> */ |
| 66 | } hw_info; |
| 67 | }; |
| 68 | |
| 69 | #define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h) |
| 70 | #define msgb_sysprim(msg) ((Litecell15_Prim_t *)(msg)->l1h) |
| 71 | |
| 72 | typedef int l1if_compl_cb(struct msgb *l1_msg, void *data); |
| 73 | |
| 74 | /* send a request primitive to the L1 and schedule completion call-back */ |
| 75 | int l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, |
| 76 | int is_system_prim, l1if_compl_cb *cb, void *data); |
| 77 | |
| 78 | int l1if_reset(struct lc15l1_hdl *hdl); |
| 79 | int l1if_activate_rf(struct lc15l1_hdl *hdl, int on); |
| 80 | int l1if_set_trace_flags(struct lc15l1_hdl *hdl, uint32_t flags); |
| 81 | int l1if_set_txpower(struct lc15l1_hdl *fl1h, float tx_power); |
| 82 | |
| 83 | struct msgb *l1p_msgb_alloc(void); |
| 84 | struct msgb *sysp_msgb_alloc(void); |
| 85 | |
| 86 | uint32_t l1if_lchan_to_hLayer2(struct gsm_lchan *lchan); |
| 87 | struct gsm_lchan *l1if_hLayer2_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer2); |
| 88 | |
| 89 | int l1if_handle_sysprim(struct lc15l1_hdl *fl1h, struct msgb *msg); |
| 90 | int l1if_handle_l1prim(int wq, struct lc15l1_hdl *fl1h, struct msgb *msg); |
| 91 | |
| 92 | /* tch.c */ |
| 93 | int l1if_tch_rx(struct gsm_lchan *lchan, struct msgb *l1p_msg); |
| 94 | int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer); |
| 95 | struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan); |
| 96 | |
| 97 | /* |
| 98 | * The implementation of these functions is selected by either compiling and |
| 99 | * linking sysmo_l1_hw.c or sysmo_l1_fwd.c |
| 100 | */ |
| 101 | int l1if_transport_open(int q, struct lc15l1_hdl *hdl); |
| 102 | int l1if_transport_close(int q, struct lc15l1_hdl *hdl); |
| 103 | |
| 104 | #endif /* _SYSMO_L1_IF_H */ |