From: Max msuraev@sysmocom.de
This is v2 of patchset to simplify new hardware support by restructuring sources, simplifying internal API and cleaining up various bits and pieces.
Max (4): Cleanup build Rename define for direct hw access Restructure sources Change internal API for consistency
.gitignore | 3 +- configure.ac | 2 +- src/Makefile.am | 51 +++++++++++++++++++-------------- src/{ => osmo-bts-sysmo}/femtobts.c | 0 src/{ => osmo-bts-sysmo}/femtobts.h | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_fwd.c | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_hw.c | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_if.c | 8 +++--- src/{ => osmo-bts-sysmo}/sysmo_l1_if.h | 2 +- src/osmobts_sock.cpp | 2 +- src/pcu_l1_if.cpp | 17 ++++++----- 11 files changed, 47 insertions(+), 38 deletions(-) rename src/{ => osmo-bts-sysmo}/femtobts.c (100%) rename src/{ => osmo-bts-sysmo}/femtobts.h (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_fwd.c (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_hw.c (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_if.c (98%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_if.h (98%)
From: Max msuraev@sysmocom.de
Ignore cross-compilation bild byproducts. Enable subdir-objects to increase compatibility with newer automake. --- .gitignore | 3 ++- configure.ac | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore index 6cc9aa5..df344ec 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,8 @@ configure depcomp install-sh missing -libtool +*libtool +compile ltmain.sh
core diff --git a/configure.ac b/configure.ac index 5274022..7a97954 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_INIT([osmo-pcu], m4_esyscmd([./git-version-gen .tarball-version]), [osmocom-net-gprs@lists.osmocom.org])
-AM_INIT_AUTOMAKE([dist-bzip2]) +AM_INIT_AUTOMAKE([dist-bzip2 subdir-objects]) AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages
From: Max msuraev@sysmocom.de
--- src/Makefile.am | 2 +- src/osmobts_sock.cpp | 2 +- src/pcu_l1_if.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index 6428bef..832c3b0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS)
if ENABLE_SYSMODSP -AM_CPPFLAGS += -DENABLE_SYSMODSP +AM_CPPFLAGS += -DENABLE_DIRECT_PHY endif
AM_CXXFLAGS = -Wall -ldl -pthread diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp index b42f042..21a404f 100644 --- a/src/osmobts_sock.cpp +++ b/src/osmobts_sock.cpp @@ -100,7 +100,7 @@ static void pcu_sock_close(struct pcu_sock_state *state, int lost)
/* disable all slots, kick all TBFs */ for (trx = 0; trx < 8; trx++) { -#ifdef ENABLE_SYSMODSP +#ifdef ENABLE_DIRECT_PHY if (bts->trx[trx].fl1h) { l1if_close_pdch(bts->trx[trx].fl1h); bts->trx[trx].fl1h = NULL; diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 9d7dbee..06cf234 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -124,7 +124,7 @@ static int pcu_tx_data_req(uint8_t trx, uint8_t ts, uint8_t sapi, void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, uint32_t fn, uint8_t block_nr) { -#ifdef ENABLE_SYSMODSP +#ifdef ENABLE_DIRECT_PHY struct gprs_rlcmac_bts *bts = bts_main_data();
if (bts->trx[trx].fl1h) @@ -140,7 +140,7 @@ void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, void pcu_l1if_tx_ptcch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, uint32_t fn, uint8_t block_nr) { -#ifdef ENABLE_SYSMODSP +#ifdef ENABLE_DIRECT_PHY struct gprs_rlcmac_bts *bts = bts_main_data();
if (bts->trx[trx].fl1h) @@ -430,7 +430,7 @@ bssgp_failed: bts->trx[trx].arfcn = info_ind->trx[trx].arfcn; if ((info_ind->flags & PCU_IF_FLAG_SYSMO) && info_ind->trx[trx].hlayer1) { -#ifdef ENABLE_SYSMODSP +#ifdef ENABLE_DIRECT_PHY LOGP(DL1IF, LOGL_DEBUG, " TRX %d hlayer1=%x\n", trx, info_ind->trx[trx].hlayer1); if (!bts->trx[trx].fl1h) @@ -455,7 +455,7 @@ bssgp_failed: if ((info_ind->trx[trx].pdch_mask & (1 << ts))) { /* FIXME: activate dynamically at RLCMAC */ if (!pdch->is_enabled()) { -#ifdef ENABLE_SYSMODSP +#ifdef ENABLE_DIRECT_PHY if ((info_ind->flags & PCU_IF_FLAG_SYSMO)) l1if_connect_pdch(
From: Max msuraev@sysmocom.de
Move hardware-spicefic files into subdirectory similar to the way it's done in OsmoBTS to make adding new hardware support easier. --- src/Makefile.am | 49 +++++++++++++++++++-------------- src/{ => osmo-bts-sysmo}/femtobts.c | 0 src/{ => osmo-bts-sysmo}/femtobts.h | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_fwd.c | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_hw.c | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_if.c | 0 src/{ => osmo-bts-sysmo}/sysmo_l1_if.h | 0 7 files changed, 29 insertions(+), 20 deletions(-) rename src/{ => osmo-bts-sysmo}/femtobts.c (100%) rename src/{ => osmo-bts-sysmo}/femtobts.h (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_fwd.c (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_hw.c (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_if.c (100%) rename src/{ => osmo-bts-sysmo}/sysmo_l1_if.h (100%)
diff --git a/src/Makefile.am b/src/Makefile.am index 832c3b0..3049744 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,11 +64,6 @@ bin_PROGRAMS = \
noinst_PROGRAMS =
-if ENABLE_SYSMODSP -noinst_PROGRAMS += \ - osmo-pcu-remote -endif - noinst_HEADERS = \ gprs_debug.h \ csn1.h \ @@ -83,8 +78,6 @@ noinst_HEADERS = \ bitvector.h \ pcu_vty.h \ pcu_vty_functions.h \ - sysmo_l1_if.h \ - femtobts.h \ tbf.h \ bts.h \ poll_controller.h \ @@ -101,30 +94,46 @@ noinst_HEADERS = \ osmo_pcu_SOURCES = pcu_main.cpp
if ENABLE_SYSMODSP -osmo_pcu_SOURCES += sysmo_l1_if.c \ - sysmo_l1_hw.c \ - femtobts.c - -osmo_pcu_remote_SOURCES = pcu_main.cpp \ - sysmo_l1_if.c \ - sysmo_l1_fwd.c \ - femtobts.c -endif +AM_CPPFLAGS += -I$(srcdir)/osmo-bts-sysmo
-osmo_pcu_LDADD = \ +EXTRA_DIST = \ + osmo-bts-sysmo/sysmo_l1_if.c \ + osmo-bts-sysmo/sysmo_l1_if.h \ + osmo-bts-sysmo/sysmo_l1_hw.c \ + osmo-bts-sysmo/femtobts.c \ + osmo-bts-sysmo/femtobts.h + +noinst_HEADERS += \ + osmo-bts-sysmo/sysmo_l1_if.h \ + osmo-bts-sysmo/femtobts.h + +noinst_PROGRAMS += \ + osmo-pcu-remote + +osmo_pcu_SOURCES += \ + osmo-bts-sysmo/sysmo_l1_if.c \ + osmo-bts-sysmo/sysmo_l1_hw.c \ + osmo-bts-sysmo/femtobts.c + +osmo_pcu_remote_SOURCES = \ + pcu_main.cpp \ + osmo-bts-sysmo/sysmo_l1_if.c \ + osmo-bts-sysmo/sysmo_l1_fwd.c \ + osmo-bts-sysmo/femtobts.c + +osmo_pcu_remote_LDADD = \ libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(COMMON_LA) +endif
-if ENABLE_SYSMODSP -osmo_pcu_remote_LDADD = \ +osmo_pcu_LDADD = \ libgprs.la \ $(LIBOSMOGB_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(COMMON_LA) -endif
#MOSTLYCLEANFILES += testSource testDestination diff --git a/src/femtobts.c b/src/osmo-bts-sysmo/femtobts.c similarity index 100% rename from src/femtobts.c rename to src/osmo-bts-sysmo/femtobts.c diff --git a/src/femtobts.h b/src/osmo-bts-sysmo/femtobts.h similarity index 100% rename from src/femtobts.h rename to src/osmo-bts-sysmo/femtobts.h diff --git a/src/sysmo_l1_fwd.c b/src/osmo-bts-sysmo/sysmo_l1_fwd.c similarity index 100% rename from src/sysmo_l1_fwd.c rename to src/osmo-bts-sysmo/sysmo_l1_fwd.c diff --git a/src/sysmo_l1_hw.c b/src/osmo-bts-sysmo/sysmo_l1_hw.c similarity index 100% rename from src/sysmo_l1_hw.c rename to src/osmo-bts-sysmo/sysmo_l1_hw.c diff --git a/src/sysmo_l1_if.c b/src/osmo-bts-sysmo/sysmo_l1_if.c similarity index 100% rename from src/sysmo_l1_if.c rename to src/osmo-bts-sysmo/sysmo_l1_if.c diff --git a/src/sysmo_l1_if.h b/src/osmo-bts-sysmo/sysmo_l1_if.h similarity index 100% rename from src/sysmo_l1_if.h rename to src/osmo-bts-sysmo/sysmo_l1_if.h
From: Max msuraev@sysmocom.de
Use uint8_t for TRX numbering everywhere (we don't expect hardware with more than 256 transceivers in the near future). This change helps to avoid unnecessary casts and make API much clearer. --- src/osmo-bts-sysmo/sysmo_l1_if.c | 8 ++++---- src/osmo-bts-sysmo/sysmo_l1_if.h | 2 +- src/pcu_l1_if.cpp | 9 ++++----- 3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/osmo-bts-sysmo/sysmo_l1_if.c b/src/osmo-bts-sysmo/sysmo_l1_if.c index 8572786..8ecbcfb 100644 --- a/src/osmo-bts-sysmo/sysmo_l1_if.c +++ b/src/osmo-bts-sysmo/sysmo_l1_if.c @@ -155,7 +155,7 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1h, switch (rts_ind->sapi) { case GsmL1_Sapi_Pdtch: case GsmL1_Sapi_Pacch: - rc = pcu_rx_rts_req_pdtch((long)fl1h->priv, rts_ind->u8Tn, + rc = pcu_rx_rts_req_pdtch(fl1h->trx, rts_ind->u8Tn, rts_ind->u16Arfcn, rts_ind->u32Fn, rts_ind->u8BlockNbr); case GsmL1_Sapi_Ptcch: // FIXME @@ -215,7 +215,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h, != GsmL1_PdtchPlType_Full) break; /* PDTCH / PACCH frame handling */ - pcu_rx_data_ind_pdtch((long)fl1h->priv, data_ind->u8Tn, + pcu_rx_data_ind_pdtch(fl1h->trx, data_ind->u8Tn, data_ind->msgUnitParam.u8Buffer + 1, data_ind->msgUnitParam.u8Size - 1, data_ind->u32Fn, @@ -357,7 +357,7 @@ int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn, return 0; }
-void *l1if_open_pdch(void *priv, uint32_t hlayer1) +void *l1if_open_pdch(uint8_t trx, uint32_t hlayer1) { struct femtol1_hdl *fl1h; int rc; @@ -367,7 +367,7 @@ void *l1if_open_pdch(void *priv, uint32_t hlayer1) return NULL;
fl1h->hLayer1 = hlayer1; - fl1h->priv = priv; + fl1h->trx = trx; fl1h->clk_cal = 0; /* default clock source: OCXO */ fl1h->clk_src = SuperFemto_ClkSrcId_Ocxo; diff --git a/src/osmo-bts-sysmo/sysmo_l1_if.h b/src/osmo-bts-sysmo/sysmo_l1_if.h index 6b50d4e..83ca481 100644 --- a/src/osmo-bts-sysmo/sysmo_l1_if.h +++ b/src/osmo-bts-sysmo/sysmo_l1_if.h @@ -38,7 +38,7 @@ struct femtol1_hdl { struct gsmtap_inst *gsmtap; uint32_t gsmtap_sapi_mask;
- void *priv; /* user reference */ + uint8_t trx;
struct osmo_timer_list alive_timer; unsigned int alive_prim_cnt; diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 06cf234..b938acf 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -42,7 +42,7 @@ extern "C" {
// FIXME: move this, when changed from c++ to c. extern "C" { -void *l1if_open_pdch(void *priv, uint32_t hlayer1); +void *l1if_open_pdch(uint8_t trx, uint32_t hlayer1); int l1if_connect_pdch(void *obj, uint8_t ts); int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn, uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len); @@ -315,9 +315,8 @@ static int pcu_rx_info_ind(struct gsm_pcu_if_info_ind *info_ind) struct gprs_bssgp_pcu *pcu; struct gprs_rlcmac_pdch *pdch; struct in_addr ia; - int rc = 0; - int trx, ts; - int i; + int rc = 0, ts, i; + uint8_t trx;
if (info_ind->version != PCU_IF_VERSION) { fprintf(stderr, "PCU interface version number of BTS (%d) is " @@ -435,7 +434,7 @@ bssgp_failed: info_ind->trx[trx].hlayer1); if (!bts->trx[trx].fl1h) bts->trx[trx].fl1h = l1if_open_pdch( - (void *)trx, + trx, info_ind->trx[trx].hlayer1); if (!bts->trx[trx].fl1h) { LOGP(DL1IF, LOGL_FATAL, "Failed to open direct "