From ed5cacb240b846c106f0fc6a3ab8e8721f4c70a5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 17 Aug 2011 22:44:07 +0200 Subject: src: port openBSC over libosmo-abis This is a big patch that ports openBSC over libosmo-abis. Sorry, the changes that are included here are all dependent of libosmo-abis, splitting them into smaller pieces would leave the repository in some intermediate state, which is not desired. The main changes are: - The directory libabis/ has been removed as it now lives in libosmo-abis. - new configuration file format for nanoBTS and HSL femto, we need to define the virtual e1_line and attach it to the OML link. - all the existing BTS drivers (nanoBTS, hsl femto, Nokia site, BS11 and rbs2000) now use the new libosmo-abis framework. - use r232 input driver available in libosmo-abis for bs11_config. - use ipa_msg_recv instead of old ipaccess_read_msg function. - delete definition of gsm_e1_subslot and input_signal_data. These structures now lives in libosmo-abis. Most of this patch are deletions of libabis/ which has been moved to libosmo-abis. This patch also modifies openBSC to use all the new definitions available in libosmocore and libosmo-abis. In order to do that, we have replaced the following: - DINP, DMI, DMIB and DMUX by their respective DL* correspondences. - SS_GLOBAL by SS_L_GLOBAL - SS_INPUT by SS_L_INPUT - S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN - SS_INPUT by SS_L_INPUT - S_INP_* by S_L_INP_* sub-signals - E1INP_NODE by L_E1INP_NODE vty node This patch has been tested with: - one nanoBTS - the HSL femto with the examples available under libosmo-abis - BS11 with both dahdi and misdn drivers. --- openbsc/include/openbsc/Makefile.am | 3 +- openbsc/include/openbsc/abis_nm.h | 3 + openbsc/include/openbsc/debug.h | 4 - openbsc/include/openbsc/e1_input.h | 200 ------------------------------ openbsc/include/openbsc/gsm_data.h | 4 + openbsc/include/openbsc/gsm_data_shared.h | 12 +- openbsc/include/openbsc/ipaccess.h | 5 +- openbsc/include/openbsc/misdn.h | 2 +- openbsc/include/openbsc/signal.h | 22 ---- openbsc/include/openbsc/subchan_demux.h | 101 --------------- openbsc/include/openbsc/trau_frame.h | 64 ---------- openbsc/include/openbsc/trau_mux.h | 3 + openbsc/include/openbsc/vty.h | 1 - 13 files changed, 15 insertions(+), 409 deletions(-) delete mode 100644 openbsc/include/openbsc/e1_input.h delete mode 100644 openbsc/include/openbsc/subchan_demux.h delete mode 100644 openbsc/include/openbsc/trau_frame.h (limited to 'openbsc/include') diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 9ec92c1d7..53cc5eeb9 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -1,8 +1,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ gsm_subscriber.h gsm_04_11.h debug.h signal.h \ misdn.h chan_alloc.h paging.h \ - subchan_demux.h trau_frame.h e1_input.h trau_mux.h \ - ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \ + trau_mux.h rs232.h openbscdefines.h rtp_proxy.h \ bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \ silent_call.h mgcp.h meas_rep.h rest_octets.h \ system_information.h handover.h mgcp_internal.h \ diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h index ae4f62549..f11ac117b 100644 --- a/openbsc/include/openbsc/abis_nm.h +++ b/openbsc/include/openbsc/abis_nm.h @@ -160,5 +160,8 @@ int abis_nm_vty_init(void); void abis_nm_clear_queue(struct gsm_bts *bts); +int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml); + +void abis_nm_queue_send_next(struct gsm_bts *bts); /* for bs11_config. */ #endif /* _NM_H */ diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index d78252a93..43f0ff808 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -19,10 +19,6 @@ enum { DSMS, DPAG, DMEAS, - DMI, - DMIB, - DMUX, - DINP, DSCCP, DMSC, DMGCP, diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h deleted file mode 100644 index 4a375ed82..000000000 --- a/openbsc/include/openbsc/e1_input.h +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef _E1_INPUT_H -#define _E1_INPUT_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -#define NUM_E1_TS 32 - -enum e1inp_sign_type { - E1INP_SIGN_NONE, - E1INP_SIGN_OML, - E1INP_SIGN_RSL, -}; -const char *e1inp_signtype_name(enum e1inp_sign_type tp); - -enum e1inp_ctr { - E1I_CTR_HDLC_ABORT, - E1I_CTR_HDLC_BADFCS, - E1I_CTR_HDLC_OVERR, - E1I_CTR_ALARM, - E1I_CTR_REMOVED, -}; - -struct e1inp_ts; - -struct e1inp_sign_link { - /* list of signalling links */ - struct llist_head list; - - /* to which timeslot do we belong? */ - struct e1inp_ts *ts; - - enum e1inp_sign_type type; - - /* trx for msg->trx of received msgs */ - struct gsm_bts_trx *trx; - - /* msgb queue of to-be-transmitted msgs */ - struct llist_head tx_list; - - /* SAPI and TEI on the E1 TS */ - uint8_t sapi; - uint8_t tei; - - union { - struct { - uint8_t channel; - } misdn; - } driver; -}; - -enum e1inp_ts_type { - E1INP_TS_TYPE_NONE, - E1INP_TS_TYPE_SIGN, - E1INP_TS_TYPE_TRAU, -}; -const char *e1inp_tstype_name(enum e1inp_ts_type tp); - -/* A timeslot in the E1 interface */ -struct e1inp_ts { - enum e1inp_ts_type type; - int num; - - /* to which line do we belong ? */ - struct e1inp_line *line; - - union { - struct { - /* list of all signalling links on this TS */ - struct llist_head sign_links; - /* delay for the queue */ - int delay; - /* timer when to dequeue next frame */ - struct osmo_timer_list tx_timer; - } sign; - struct { - /* subchannel demuxer for frames from E1 */ - struct subch_demux demux; - /* subchannel muxer for frames to E1 */ - struct subch_mux mux; - } trau; - }; - union { - struct { - /* mISDN driver has one fd for each ts */ - struct osmo_fd fd; - } misdn; - struct { - /* ip.access driver has one fd for each ts */ - struct osmo_fd fd; - } ipaccess; - struct { - /* DAHDI driver has one fd for each ts */ - struct osmo_fd fd; - struct lapd_instance *lapd; - } dahdi; - } driver; -}; - -struct e1inp_driver { - struct llist_head list; - const char *name; - int (*want_write)(struct e1inp_ts *ts); - int (*line_update)(struct e1inp_line *line); - int default_delay; -}; - -struct e1inp_line { - struct llist_head list; - unsigned int num; - const char *name; - struct rate_ctr_group *rate_ctr; - - /* array of timestlots */ - struct e1inp_ts ts[NUM_E1_TS]; - - struct e1inp_driver *driver; - void *driver_data; -}; - -/* register a driver with the E1 core */ -int e1inp_driver_register(struct e1inp_driver *drv); - -/* fine a previously registered driver */ -struct e1inp_driver *e1inp_driver_find(const char *name); - -/* register a line with the E1 core */ -int e1inp_line_register(struct e1inp_line *line); - -/* get a line by its ID */ -struct e1inp_line *e1inp_line_get(uint8_t e1_nr); - -/* create a line in the E1 input core */ -struct e1inp_line *e1inp_line_create(uint8_t e1_nr, const char *driver_name); - -/* find a sign_link for given TEI and SAPI in a TS */ -struct e1inp_sign_link * -e1inp_lookup_sign_link(struct e1inp_ts *ts, uint8_t tei, - uint8_t sapi); - -/* create a new signalling link in a E1 timeslot */ -struct e1inp_sign_link * -e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, - struct gsm_bts_trx *trx, uint8_t tei, - uint8_t sapi); - -/* configure and initialize one e1inp_ts */ -int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, - enum e1inp_ts_type type); - -/* Call from the Stack: configuration of this TS has changed */ -int e1inp_update_ts(struct e1inp_ts *ts); - -/* Receive a packet from the E1 driver */ -int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, - uint8_t tei, uint8_t sapi); - -/* called by driver if it wants to transmit on a given TS */ -struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, - struct e1inp_sign_link **sign_link); - -/* called by driver in case some kind of link state event */ -int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi); - -/* Write LAPD frames to the fd. */ -void e1_set_pcap_fd(int fd); - -/* called by TRAU muxer to obtain the destination mux entity */ -struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr); - -void e1inp_sign_link_destroy(struct e1inp_sign_link *link); -int e1inp_line_update(struct e1inp_line *line); - -/* e1_config.c */ -int e1_reconfig_ts(struct gsm_bts_trx_ts *ts); -int e1_reconfig_trx(struct gsm_bts_trx *trx); -int e1_reconfig_bts(struct gsm_bts *bts); - -int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin); -int ipaccess_setup(struct gsm_network *gsmnet); -int hsl_setup(struct gsm_network *gsmnet); - -extern struct llist_head e1inp_driver_list; -extern struct llist_head e1inp_line_list; - -int e1inp_vty_init(void); -void e1inp_init(void); - -int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml); - -int abis_sendmsg(struct msgb *msg); - -#endif /* _E1_INPUT_H */ diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 715ff1bdd..20b8fe720 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -7,6 +7,7 @@ #include #include +#include #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] @@ -382,4 +383,7 @@ void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked); int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat); struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); +/* generic E1 line operations for all ISDN-based BTS. */ +extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; + #endif /* _GSM_DATA_H */ diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index 89375cf42..1dec0e4a4 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -225,16 +225,6 @@ struct gsm_lchan { #endif }; - -struct gsm_e1_subslot { - /* Number of E1 link */ - uint8_t e1_nr; - /* Number of E1 TS inside E1 link */ - uint8_t e1_ts; - /* Sub-slot within the E1 TS, 0xff if full TS */ - uint8_t e1_ts_ss; -}; - #define TS_F_PDCH_MODE 0x1000 /* One Timeslot in a TRX */ struct gsm_bts_trx_ts { @@ -341,6 +331,8 @@ struct gsm_bts_model { int (*start)(struct gsm_network *net); int (*oml_rcvmsg)(struct msgb *msg); + void (*e1line_bind_ops)(struct e1inp_line *line); + void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h index c2ca2a530..d3c9d1dca 100644 --- a/openbsc/include/openbsc/ipaccess.h +++ b/openbsc/include/openbsc/ipaccess.h @@ -1,7 +1,7 @@ #ifndef _IPACCESS_H #define _IPACCESS_H -#include "e1_input.h" +#include #include "gsm_subscriber.h" #include #include @@ -26,13 +26,10 @@ struct ipac_ext_lac_cmd { uint8_t data[0]; } __attribute__((packed)); -int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa); - /* * methods for parsing and sending a message */ int ipaccess_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); -struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error); void ipaccess_prepend_header(struct msgb *msg, int proto); void ipaccess_prepend_header_ext(struct msgb *msg, int proto); int ipaccess_send_pong(int fd); diff --git a/openbsc/include/openbsc/misdn.h b/openbsc/include/openbsc/misdn.h index 0a8b063a4..9851ad32c 100644 --- a/openbsc/include/openbsc/misdn.h +++ b/openbsc/include/openbsc/misdn.h @@ -19,7 +19,7 @@ #ifndef MISDN_H #define MISDN_H -#include "e1_input.h" +#include int mi_setup(int cardnr, struct e1inp_line *line, int release_l2); int mi_e1_line_update(struct e1inp_line *line); diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 71e1deef9..7f30f4f47 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -40,14 +40,12 @@ enum signal_subsystems { SS_LCHAN, SS_SUBSCR, SS_SCALL, - SS_GLOBAL, SS_CHALLOC, SS_NS, SS_IPAC_NWL, SS_RF, SS_MSC, SS_HO, - SS_INPUT, }; /* SS_PAGING signals */ @@ -129,7 +127,6 @@ enum signal_ipaccess { }; enum signal_global { - S_GLOBAL_SHUTDOWN, S_GLOBAL_BTS_CLOSE_OM, }; @@ -140,17 +137,6 @@ enum signal_rf { S_RF_GRACE, }; -/* SS_INPUT signals */ -enum signal_input { - S_INP_NONE, - S_INP_TEI_UP, - S_INP_TEI_DN, - S_INP_TEI_UNKNOWN, - S_INP_LINE_INIT, - S_INP_LINE_ALARM, - S_INP_LINE_NOALARM, -}; - struct gsm_subscriber; struct paging_signal_data { @@ -261,12 +247,4 @@ struct ho_signal_data { struct gsm_lchan *new_lchan; }; -struct input_signal_data { - int link_type; - uint8_t tei; - uint8_t sapi; - struct gsm_bts_trx *trx; - struct e1inp_line *line; -}; - #endif diff --git a/openbsc/include/openbsc/subchan_demux.h b/openbsc/include/openbsc/subchan_demux.h deleted file mode 100644 index b71c856d9..000000000 --- a/openbsc/include/openbsc/subchan_demux.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _SUBCH_DEMUX_H -#define _SUBCH_DEMUX_H -/* A E1 sub-channel (de)multiplexer with TRAU frame sync */ - -/* (C) 2009 by Harald Welte - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -#include -#include - -#define NR_SUBCH 4 -#define TRAU_FRAME_SIZE 40 -#define TRAU_FRAME_BITS (TRAU_FRAME_SIZE*8) - -/***********************************************************************/ -/* DEMULTIPLEXER */ -/***********************************************************************/ - -struct demux_subch { - uint8_t out_bitbuf[TRAU_FRAME_BITS]; - uint16_t out_idx; /* next bit to be written in out_bitbuf */ - /* number of consecutive zeros that we have received (for sync) */ - unsigned int consecutive_zeros; - /* are we in TRAU frame sync or not? */ - unsigned int in_sync; -}; - -struct subch_demux { - /* bitmask of currently active subchannels */ - uint8_t chan_activ; - /* one demux_subch struct for every subchannel */ - struct demux_subch subch[NR_SUBCH]; - /* callback to be called once we have received a complete - * frame on a given subchannel */ - int (*out_cb)(struct subch_demux *dmx, int ch, uint8_t *data, int len, - void *); - /* user-provided data, transparently passed to out_cb() */ - void *data; -}; - -/* initialize one demultiplexer instance */ -int subch_demux_init(struct subch_demux *dmx); - -/* feed 'len' number of muxed bytes into the demultiplexer */ -int subch_demux_in(struct subch_demux *dmx, uint8_t *data, int len); - -/* activate decoding/processing for one subchannel */ -int subch_demux_activate(struct subch_demux *dmx, int subch); - -/* deactivate decoding/processing for one subchannel */ -int subch_demux_deactivate(struct subch_demux *dmx, int subch); - -/***********************************************************************/ -/* MULTIPLEXER */ -/***********************************************************************/ - -/* one element in the tx_queue of a muxer sub-channel */ -struct subch_txq_entry { - struct llist_head list; - - unsigned int bit_len; /* total number of bits in 'bits' */ - unsigned int next_bit; /* next bit to be transmitted */ - - uint8_t bits[0]; /* one bit per byte */ -}; - -struct mux_subch { - struct llist_head tx_queue; -}; - -/* structure representing one instance of the subchannel muxer */ -struct subch_mux { - struct mux_subch subch[NR_SUBCH]; -}; - -/* initialize a subchannel muxer instance */ -int subchan_mux_init(struct subch_mux *mx); - -/* request the output of 'len' multiplexed bytes */ -int subchan_mux_out(struct subch_mux *mx, uint8_t *data, int len); - -/* enqueue some data into one sub-channel of the muxer */ -int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const uint8_t *data, - int len); - -#endif /* _SUBCH_DEMUX_H */ diff --git a/openbsc/include/openbsc/trau_frame.h b/openbsc/include/openbsc/trau_frame.h deleted file mode 100644 index c15e24b7f..000000000 --- a/openbsc/include/openbsc/trau_frame.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _TRAU_FRAME_H -#define _TRAU_FRAME_H -/* TRAU frame handling according to GSM TS 08.60 */ - -/* (C) 2009 by Harald Welte - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -#include - -/* 21 for FR/EFR, 25 for AMR, 15 for OM, 15 for data, 13 for E-data, 21 idle */ -#define MAX_C_BITS 25 -/* 260 for FR/EFR, 256 for AMR, 264 for OM, 288 for E-data */ -#define MAX_D_BITS 288 -/* for all speech frames */ -#define MAX_T_BITS 4 -/* for OM */ -#define MAX_S_BITS 6 -/* for E-data */ -#define MAX_M_BITS 2 - -struct decoded_trau_frame { - uint8_t c_bits[MAX_C_BITS]; - uint8_t d_bits[MAX_D_BITS]; - uint8_t t_bits[MAX_T_BITS]; - uint8_t s_bits[MAX_S_BITS]; - uint8_t m_bits[MAX_M_BITS]; -}; - -#define TRAU_FT_FR_UP 0x02 /* 0 0 0 1 0 - 3.5.1.1.1 */ -#define TRAU_FT_FR_DOWN 0x1c /* 1 1 1 0 0 - 3.5.1.1.1 */ -#define TRAU_FT_EFR 0x1a /* 1 1 0 1 0 - 3.5.1.1.1 */ -#define TRAU_FT_AMR 0x06 /* 0 0 1 1 0 - 3.5.1.2 */ -#define TRAU_FT_OM_UP 0x07 /* 0 0 1 0 1 - 3.5.2 */ -#define TRAU_FT_OM_DOWN 0x1b /* 1 1 0 1 1 - 3.5.2 */ -#define TRAU_FT_DATA_UP 0x08 /* 0 1 0 0 0 - 3.5.3 */ -#define TRAU_FT_DATA_DOWN 0x16 /* 1 0 1 1 0 - 3.5.3 */ -#define TRAU_FT_D145_SYNC 0x14 /* 1 0 1 0 0 - 3.5.3 */ -#define TRAU_FT_EDATA 0x1f /* 1 1 1 1 1 - 3.5.4 */ -#define TRAU_FT_IDLE_UP 0x10 /* 1 0 0 0 0 - 3.5.5 */ -#define TRAU_FT_IDLE_DOWN 0x0e /* 0 1 1 1 0 - 3.5.5 */ - - -int decode_trau_frame(struct decoded_trau_frame *fr, const uint8_t *trau_bits); -int encode_trau_frame(uint8_t *trau_bits, const struct decoded_trau_frame *fr); -int trau_frame_up2down(struct decoded_trau_frame *fr); -uint8_t *trau_idle_frame(void); - - -#endif /* _TRAU_FRAME_H */ diff --git a/openbsc/include/openbsc/trau_mux.h b/openbsc/include/openbsc/trau_mux.h index 9936ba184..2c01b06db 100644 --- a/openbsc/include/openbsc/trau_mux.h +++ b/openbsc/include/openbsc/trau_mux.h @@ -50,3 +50,6 @@ int trau_recv_lchan(struct gsm_lchan *lchan, uint32_t callref); /* send trau from application */ int trau_send_frame(struct gsm_lchan *lchan, struct gsm_data_frame *frame); + +/* callback invoked if we receive TRAU frames */ +int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len, void *_priv); diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index 663589671..d455a2b81 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -29,7 +29,6 @@ enum bsc_vty_node { NS_NODE, BSSGP_NODE, OML_NODE, - E1INP_NODE, NAT_NODE, NAT_BSC_NODE, MSC_NODE, -- cgit v1.2.3