Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 1 | #ifndef _SYSMO_L1_IF_H |
| 2 | #define _SYSMO_L1_IF_H |
| 3 | |
| 4 | #include <osmocom/core/select.h> |
| 5 | #include <osmocom/core/write_queue.h> |
| 6 | #include <osmocom/core/gsmtap_util.h> |
| 7 | #include <osmocom/gsm/gsm_utils.h> |
| 8 | #include "femtobts.h" |
| 9 | |
| 10 | enum { |
| 11 | MQ_SYS_READ, |
| 12 | MQ_L1_READ, |
| 13 | #ifndef HW_SYSMOBTS_V1 |
| 14 | MQ_TCH_READ, |
| 15 | MQ_PDTCH_READ, |
| 16 | #endif |
| 17 | _NUM_MQ_READ |
| 18 | }; |
| 19 | |
| 20 | enum { |
| 21 | MQ_SYS_WRITE, |
| 22 | MQ_L1_WRITE, |
| 23 | #ifndef HW_SYSMOBTS_V1 |
| 24 | MQ_TCH_WRITE, |
| 25 | MQ_PDTCH_WRITE, |
| 26 | #endif |
| 27 | _NUM_MQ_WRITE |
| 28 | }; |
| 29 | |
| 30 | struct femtol1_hdl { |
| 31 | struct gsm_time gsm_time; |
| 32 | uint32_t hLayer1; /* handle to the L1 instance in the DSP */ |
| 33 | uint32_t dsp_trace_f; |
| 34 | int clk_cal; |
| 35 | uint8_t clk_src; |
| 36 | struct llist_head wlc_list; |
| 37 | |
| 38 | struct gsmtap_inst *gsmtap; |
| 39 | uint32_t gsmtap_sapi_mask; |
| 40 | |
Max | 58b6646 | 2016-05-13 10:34:15 +0200 | [diff] [blame] | 41 | uint8_t trx_no; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 42 | |
| 43 | struct osmo_timer_list alive_timer; |
| 44 | unsigned int alive_prim_cnt; |
| 45 | |
| 46 | struct osmo_fd read_ofd[_NUM_MQ_READ]; /* osmo file descriptors */ |
| 47 | struct osmo_wqueue write_q[_NUM_MQ_WRITE]; |
| 48 | |
| 49 | struct { |
| 50 | uint8_t dsp_version[3]; |
| 51 | uint8_t fpga_version[3]; |
| 52 | uint32_t band_support; /* bitmask of GSM_BAND_* */ |
| 53 | } hw_info; |
| 54 | }; |
| 55 | |
| 56 | #define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h) |
| 57 | #define msgb_sysprim(msg) ((SuperFemto_Prim_t *)(msg)->l1h) |
| 58 | |
| 59 | typedef int l1if_compl_cb(struct msgb *l1_msg, void *data); |
| 60 | |
| 61 | /* send a request primitive to the L1 and schedule completion call-back */ |
| 62 | int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, |
| 63 | int is_system_prim, l1if_compl_cb *cb, void *data); |
| 64 | |
| 65 | int l1if_reset(struct femtol1_hdl *hdl); |
| 66 | int l1if_activate_rf(struct femtol1_hdl *hdl, int on); |
| 67 | int l1if_set_trace_flags(struct femtol1_hdl *hdl, uint32_t flags); |
| 68 | int l1if_set_txpower(struct femtol1_hdl *fl1h, float tx_power); |
| 69 | |
| 70 | struct msgb *l1p_msgb_alloc(void); |
| 71 | struct msgb *sysp_msgb_alloc(void); |
| 72 | |
| 73 | uint32_t l1if_lchan_to_hLayer2(struct gsm_lchan *lchan); |
| 74 | struct gsm_lchan *l1if_hLayer2_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer2); |
| 75 | |
Jacob Erlbeck | 0d39dc9 | 2015-05-04 09:13:28 +0200 | [diff] [blame] | 76 | int l1if_handle_sysprim(struct femtol1_hdl *fl1h, struct msgb *msg); |
| 77 | int l1if_handle_l1prim(int wq, struct femtol1_hdl *fl1h, struct msgb *msg); |
| 78 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 79 | /* tch.c */ |
| 80 | int l1if_tch_rx(struct gsm_lchan *lchan, struct msgb *l1p_msg); |
| 81 | int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer); |
| 82 | struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan); |
| 83 | |
Jacob Erlbeck | 0d39dc9 | 2015-05-04 09:13:28 +0200 | [diff] [blame] | 84 | /* |
| 85 | * The implementation of these functions is selected by either compiling and |
| 86 | * linking sysmo_l1_hw.c or sysmo_l1_fwd.c |
| 87 | */ |
| 88 | int l1if_transport_open(int q, struct femtol1_hdl *hdl); |
| 89 | int l1if_transport_close(int q, struct femtol1_hdl *hdl); |
| 90 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 91 | #endif /* _SYSMO_L1_IF_H */ |