aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-07-11 11:48:32 +0200
committerHarald Welte <laforge@osmocom.org>2020-07-14 14:40:09 +0200
commit6473bf0fe0a3e42c7b0a1b0ec84e487da881256a (patch)
tree75c22ba52bdf35fbda7d906f569254dc179e1e55
parent570608313816b0a656587b76496c849880fcd794 (diff)
introduce concept of superchannel to data structures
We treat the superchannel as an extra, separate timeslot. Initially I thought of simply re-using TS1, but keeping the superchannel separate ensures that it doesn't inherit any state (like half-sent HDLC frames) from another timeslot when we switch between the modes at runtime. Change-Id: I0aacf251e155de2bb6ad03ffc4181067b22f1c90
-rw-r--r--include/osmocom/e1d/proto.h1
-rw-r--r--src/ctl.c7
-rw-r--r--src/e1d.h13
-rw-r--r--src/intf_line.c18
4 files changed, 33 insertions, 6 deletions
diff --git a/include/osmocom/e1d/proto.h b/include/osmocom/e1d/proto.h
index 56064b8..6711332 100644
--- a/include/osmocom/e1d/proto.h
+++ b/include/osmocom/e1d/proto.h
@@ -71,6 +71,7 @@ enum osmo_e1dp_ts_mode {
#define E1DP_MAGIC 0x00e1
#define E1DP_MAX_LEN 4096
+#define E1DP_TS_SUPERCHAN 0xfe
#define E1DP_INVALID 0xff
#define E1DP_DEFAULT_SOCKET "/tmp/osmo-e1d.ctl"
diff --git a/src/ctl.c b/src/ctl.c
index 482366f..5322ab4 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -68,7 +68,12 @@ e1_intf_find_line(struct e1_intf *intf, uint8_t id)
static struct e1_ts *
_e1d_get_ts(struct e1_line *line, uint8_t ts)
{
- return (ts < 32) ? &line->ts[ts] : NULL;
+ if (ts < 32)
+ return &line->ts[ts];
+ else if (ts == E1DP_TS_SUPERCHAN)
+ return &line->superchan;
+ else
+ return NULL;
}
static void
diff --git a/src/e1d.h b/src/e1d.h
index f556e8f..2b8e32b 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -55,15 +55,28 @@ struct e1_ts {
int fd;
};
+enum e1_line_mode {
+ /* 31 individual 64k timeslots, as used on 3GPP Abis, 3GPP A or ISDN */
+ E1_LINE_MODE_CHANNELIZED,
+ /* 1 channel group spanning all 31 TS, as used e.g. when using Frame Relay
+ * or raw HDLC over channelized E1. */
+ E1_LINE_MODE_SUPERCHANNEL,
+};
+
struct e1_line {
struct llist_head list;
struct e1_intf *intf;
uint8_t id;
+ enum e1_line_mode mode;
+
void *drv_data;
+ /* timeslots for channelized mode */
struct e1_ts ts[32];
+ /* superchannel */
+ struct e1_ts superchan;
};
enum e1_driver {
diff --git a/src/intf_line.c b/src/intf_line.c
index e206f76..421c528 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -33,6 +33,7 @@
#include <osmocom/core/isdnhdlc.h>
#include <osmocom/core/utils.h>
+#include <osmocom/e1d/proto.h>
#include "e1d.h"
#include "log.h"
@@ -90,6 +91,14 @@ e1_intf_destroy(struct e1_intf *intf)
talloc_free(intf);
}
+static void
+_ts_init(struct e1_ts *ts, struct e1_line *line, int id)
+{
+ ts->line = line;
+ ts->id = id;
+ ts->fd = -1;
+}
+
struct e1_line *
e1_line_new(struct e1_intf *intf, void *drv_data)
{
@@ -100,12 +109,11 @@ e1_line_new(struct e1_intf *intf, void *drv_data)
line->intf = intf;
line->drv_data = drv_data;
+ line->mode = E1_LINE_MODE_CHANNELIZED;
- for (int i=0; i<32; i++) {
- line->ts[i].line = line;
- line->ts[i].id = i;
- line->ts[i].fd = -1;
- }
+ for (int i=0; i<32; i++)
+ _ts_init(&line->ts[i], line, i);
+ _ts_init(&line->superchan, line, E1DP_TS_SUPERCHAN);
INIT_LLIST_HEAD(&line->list);