blob: 1e09f02539142bc289cf55e887184bcdd5cec347 [file] [log] [blame]
Jean-Francois Dionnec1e44902017-06-05 14:44:57 -04001/* 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 _OC2G_L1_IF_H
23#define _OC2G_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/core/timer.h>
29#include <osmocom/gsm/gsm_utils.h>
30
31#include "oc2gbts.h"
32
33enum {
34 MQ_SYS_READ,
35 MQ_L1_READ,
36 MQ_TCH_READ,
37 MQ_PDTCH_READ,
38 _NUM_MQ_READ
39};
40
41enum {
42 MQ_SYS_WRITE,
43 MQ_L1_WRITE,
44 MQ_TCH_WRITE,
45 MQ_PDTCH_WRITE,
46 _NUM_MQ_WRITE
47};
48
49struct oc2gl1_hdl {
50 struct gsm_time gsm_time;
51 uint32_t hLayer1; /* handle to the L1 instance in the DSP */
52 uint32_t dsp_trace_f;
53 struct llist_head wlc_list;
54
55 struct gsmtap_inst *gsmtap;
56 uint32_t gsmtap_sapi_mask;
57
58 uint8_t trx_no;
59
60 struct osmo_timer_list alive_timer;
61 unsigned int alive_prim_cnt;
62
63 struct osmo_fd read_ofd[_NUM_MQ_READ]; /* osmo file descriptors */
64 struct osmo_wqueue write_q[_NUM_MQ_WRITE];
65
66 struct {
67 int trx_nr; /* <1-2> */
68 } hw_info;
69};
70
71#define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h)
72#define msgb_sysprim(msg) ((Oc2g_Prim_t *)(msg)->l1h)
73
74typedef int l1if_compl_cb(struct msgb *l1_msg, void *data);
75
76/* send a request primitive to the L1 and schedule completion call-back */
77int l1if_req_compl(struct oc2gl1_hdl *fl1h, struct msgb *msg,
78 int is_system_prim, l1if_compl_cb *cb, void *data);
79
80int l1if_reset(struct oc2gl1_hdl *hdl);
81int l1if_activate_rf(struct oc2gl1_hdl *hdl, int on);
82int l1if_set_trace_flags(struct oc2gl1_hdl *hdl, uint32_t flags);
83int l1if_set_txpower(struct oc2gl1_hdl *fl1h, float tx_power);
84
85struct msgb *l1p_msgb_alloc(void);
86struct msgb *sysp_msgb_alloc(void);
87
88uint32_t l1if_lchan_to_hLayer2(struct gsm_lchan *lchan);
89struct gsm_lchan *l1if_hLayer2_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer2);
90
91int l1if_handle_sysprim(struct oc2gl1_hdl *fl1h, struct msgb *msg);
92int l1if_handle_l1prim(int wq, struct oc2gl1_hdl *fl1h, struct msgb *msg);
93
94/* tch.c */
95int l1if_tch_rx(struct gsm_lchan *lchan, struct msgb *l1p_msg);
96int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
97struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan);
98
99/*
100 * The implementation of these functions is selected by either compiling and
101 * linking sysmo_l1_hw.c or sysmo_l1_fwd.c
102 */
103int l1if_transport_open(int q, struct oc2gl1_hdl *hdl);
104int l1if_transport_close(int q, struct oc2gl1_hdl *hdl);
105
106#endif /* _OC2G_L1_IF_H */