annotate abis/tx_func.c @ 33:351bd801cdce

abis: should be complete now
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Aug 2024 22:53:42 +0000
parents 5dd30224b70a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
2 * Here we are going to implement Tx on Abis toward the BTS.
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdint.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdbool.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
12 #include <osmocom/core/msgb.h>
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <osmocom/core/select.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <osmocom/isdn/i460_mux.h>
33
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
15 #include <osmocom/trau/trau_frame.h>
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "globals.h"
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "submux.h"
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
19 #include "dl_frames.h"
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
20
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
21 static void tx_service_subslot(int nr)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
22 {
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
23 struct abis_subslot *ab = &subslots[nr];
33
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
24 const uint8_t *srcbuf;
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
25 struct msgb *msg;
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
26 uint8_t *outbuf;
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
27
33
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
28 if (!ab->got_sync)
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
29 return;
33
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
30 switch (ab->frame_type) {
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
31 case TRAU_FT_FR_UP:
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
32 srcbuf = dl_frame_fr;
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
33 break;
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
34 case TRAU_FT_EFR:
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
35 srcbuf = dl_frame_efr;
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
36 break;
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
37 default:
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
38 return;
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
39 }
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
40 msg = msgb_alloc_c(g_ctx, DL_OUTPUT_LEN, "TRAU-DL-frame");
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
41 if (!msg)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
42 return;
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
43 outbuf = msgb_put(msg, DL_OUTPUT_LEN);
33
351bd801cdce abis: should be complete now
Mychaela Falconia <falcon@freecalypso.org>
parents: 30
diff changeset
44 memcpy(outbuf, srcbuf, DL_OUTPUT_LEN);
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
45 osmo_i460_mux_enqueue(ab->schan, msg);
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
46 }
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
47
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 void transmit_e1_ts(void)
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 {
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 uint8_t buf[160];
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
51 int nr;
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
30
5dd30224b70a abis: starting new program
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
53 for (nr = 0; nr < ABIS_SUBSLOTS; nr++)
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
54 tx_service_subslot(nr);
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 osmo_i460_mux_out(&i460_ts, buf, 160);
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 write(ts_fd, buf, 160);
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }