# HG changeset patch # User Mychaela Falconia # Date 1723589622 0 # Node ID 351bd801cdce2fbba7a5bdbc595967582eccc581 # Parent 94f11dc0d4749b2cbc62beeacb5c50a3cd7ec120 abis: should be complete now diff -r 94f11dc0d474 -r 351bd801cdce abis/submux.h --- a/abis/submux.h Tue Aug 13 22:07:49 2024 +0000 +++ b/abis/submux.h Tue Aug 13 22:53:42 2024 +0000 @@ -16,10 +16,10 @@ struct abis_subslot { struct osmo_i460_subchan *schan; + struct osmo_fsm_inst *sync; int nr; - bool is_active; - bool is_efr; - struct osmo_fsm_inst *sync; + bool got_sync; + uint8_t frame_type; }; extern struct abis_subslot subslots[ABIS_SUBSLOTS]; diff -r 94f11dc0d474 -r 351bd801cdce abis/subslot_rx.c --- a/abis/subslot_rx.c Tue Aug 13 22:07:49 2024 +0000 +++ b/abis/subslot_rx.c Tue Aug 13 22:53:42 2024 +0000 @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -23,9 +24,49 @@ osmo_trau_sync_rx_ubits(ab->sync, bits, num_bits); } +static void sync_lost(struct abis_subslot *ab) +{ + if (!ab->got_sync) + return; + printf("Subslot %d lost frame sync\n", ab->nr); + ab->got_sync = false; +} + +/* function copied from libosmo-abis/src/trau/trau_frame.c */ +static uint32_t get_bits(const ubit_t *bitbuf, int offset, int num) +{ + int i; + uint32_t ret = 0; + + for (i = offset; i < offset + num; i++) { + ret = ret << 1; + if (bitbuf[i]) + ret |= 1; + } + return ret; +} + void sync_rx_func(void *user_data, const ubit_t *bits, unsigned int num_bits) { struct abis_subslot *ab = user_data; - + uint8_t ft; + if (!bits) { + sync_lost(ab); + return; + } + OSMO_ASSERT(num_bits == 320); + ft = get_bits(bits, 17, 5); + if (!ab->got_sync) { + printf("Subslot %d got frame sync with FT=0x%02X\n", + ab->nr, ft); + ab->got_sync = true; + ab->frame_type = ft; + return; + } + if (ft == ab->frame_type) + return; + printf("Subslot %d changed frame type from 0x%02X to 0x%02X\n", ab->nr, + ab->frame_type, ft); + ab->frame_type = ft; } diff -r 94f11dc0d474 -r 351bd801cdce abis/tx_func.c --- a/abis/tx_func.c Tue Aug 13 22:07:49 2024 +0000 +++ b/abis/tx_func.c Tue Aug 13 22:53:42 2024 +0000 @@ -12,6 +12,7 @@ #include #include #include +#include #include "globals.h" #include "submux.h" @@ -20,16 +21,27 @@ static void tx_service_subslot(int nr) { struct abis_subslot *ab = &subslots[nr]; + const uint8_t *srcbuf; struct msgb *msg; uint8_t *outbuf; - if (!ab->is_active) + if (!ab->got_sync) return; + switch (ab->frame_type) { + case TRAU_FT_FR_UP: + srcbuf = dl_frame_fr; + break; + case TRAU_FT_EFR: + srcbuf = dl_frame_efr; + break; + default: + return; + } msg = msgb_alloc_c(g_ctx, DL_OUTPUT_LEN, "TRAU-DL-frame"); if (!msg) return; outbuf = msgb_put(msg, DL_OUTPUT_LEN); - memcpy(outbuf, ab->is_efr ? dl_frame_efr : dl_frame_fr, DL_OUTPUT_LEN); + memcpy(outbuf, srcbuf, DL_OUTPUT_LEN); osmo_i460_mux_enqueue(ab->schan, msg); }