aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-07-20 22:54:13 +0200
committerHarald Welte <laforge@osmocom.org>2020-07-22 09:42:56 +0200
commit569726a72fd121481c9a52a49fe592e240c9e66c (patch)
treea9b392a0a4787eef2aeb589f092528b960cb0fab
parent79cda368acfb4c0845e9ad6d0814a494c25ec834 (diff)
make RAW read buffer size configurable (instead of hard-coded 160)
When opening a timeslot, the client can now specify the (from application perspective) timeslot read buffer size. This breaks ABI, but then we're still at a point where only prototype hardware exists, so we can get away with it. Change-Id: I6d603778cce14c5d72fe5f54904905ea7e66d7ff
-rw-r--r--include/osmocom/e1d/proto.h3
-rw-r--r--include/osmocom/e1d/proto_clnt.h2
-rw-r--r--src/ctl.c9
-rw-r--r--src/e1d-ts-pipe.c13
-rw-r--r--src/proto_clnt.c3
5 files changed, 20 insertions, 10 deletions
diff --git a/include/osmocom/e1d/proto.h b/include/osmocom/e1d/proto.h
index 243922d..5628e31 100644
--- a/include/osmocom/e1d/proto.h
+++ b/include/osmocom/e1d/proto.h
@@ -84,7 +84,7 @@ enum osmo_e1dp_ts_mode {
/* the idea here is to use the first byte as a version number, to prevent incompatible
* clients from connecting to e1d */
-#define E1DP_MAGIC 0x00e1
+#define E1DP_MAGIC 0x01e1
#define E1DP_MAX_LEN 4096
#define E1DP_TS_SUPERCHAN 0xfe
#define E1DP_INVALID 0xff
@@ -118,6 +118,7 @@ struct osmo_e1dp_line_info {
struct osmo_e1dp_ts_config {
uint8_t mode;
+ uint16_t read_bufsize;
} __attribute__((packed));
struct osmo_e1dp_ts_info {
diff --git a/include/osmocom/e1d/proto_clnt.h b/include/osmocom/e1d/proto_clnt.h
index ff2cebf..5a4f965 100644
--- a/include/osmocom/e1d/proto_clnt.h
+++ b/include/osmocom/e1d/proto_clnt.h
@@ -45,4 +45,4 @@ int osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
uint8_t intf, uint8_t line, enum osmo_e1dp_line_mode mode);
int osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
uint8_t intf, uint8_t line, uint8_t ts,
- enum osmo_e1dp_ts_mode mode);
+ enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize);
diff --git a/src/ctl.c b/src/ctl.c
index d62195a..fee96f8 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -138,7 +138,7 @@ _e1d_ts_raw_buf_realloc(struct e1_ts *ts, unsigned int size)
}
static int
-_e1d_ts_start(struct e1_ts *ts, enum e1_ts_mode mode)
+_e1d_ts_start(struct e1_ts *ts, enum e1_ts_mode mode, uint16_t bufsize)
{
int ret, sd[2];
int sock_type;
@@ -151,7 +151,7 @@ _e1d_ts_start(struct e1_ts *ts, enum e1_ts_mode mode)
break;
case E1_TS_MODE_RAW:
sock_type = SOCK_STREAM;
- _e1d_ts_raw_buf_realloc(ts, 160); /* TODO: make configurable */
+ _e1d_ts_raw_buf_realloc(ts, bufsize);
break;
default:
return -EINVAL;
@@ -383,11 +383,14 @@ _e1d_ctl_ts_open(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
return 0;
}
+ if (cfg->read_bufsize == 0)
+ return 0;
+
/* If already open, close previous */
e1_ts_stop(ts);
/* Init */
- ret = _e1d_ts_start(ts, mode);
+ ret = _e1d_ts_start(ts, mode, cfg->read_bufsize);
if (ret < 0)
return ret;
diff --git a/src/e1d-ts-pipe.c b/src/e1d-ts-pipe.c
index 6d3ec80..bae45de 100644
--- a/src/e1d-ts-pipe.c
+++ b/src/e1d-ts-pipe.c
@@ -44,9 +44,9 @@ static int infd = 0;
static int ts_open(uint8_t intf_nr, uint8_t line_nr, uint8_t ts_nr,
- enum osmo_e1dp_ts_mode mode)
+ enum osmo_e1dp_ts_mode mode, uint16_t bufsize)
{
- int rc = osmo_e1dp_client_ts_open(g_client, intf_nr, line_nr, ts_nr, mode);
+ int rc = osmo_e1dp_client_ts_open(g_client, intf_nr, line_nr, ts_nr, mode, bufsize);
if (rc < 0)
fprintf(stderr, "Cannot open e1d timeslot %u:%u:%u\n", intf_nr, line_nr, ts_nr);
return rc;
@@ -122,6 +122,7 @@ int main(int argc, char **argv)
int intf_nr = -1, line_nr = -1, ts_nr = -1;
enum osmo_e1dp_ts_mode mode = E1DP_TSMODE_RAW;
char *path = E1DP_DEFAULT_SOCKET;
+ int bufsize = 160;
int tsfd;
int option_index, rc;
@@ -141,10 +142,11 @@ int main(int argc, char **argv)
{ "timeslot", 1, 0, 't' },
{ "mode", 1, 0, 'm' },
{ "read", 1, 0, 'r' },
+ { "read-bufsize", 1, 0, 'b' },
{ 0,0,0,0 }
};
- c = getopt_long(argc, argv, "hp:i:l:t:m:r:", long_options, &option_index);
+ c = getopt_long(argc, argv, "hp:i:l:t:m:r:b:", long_options, &option_index);
if (c == -1)
break;
@@ -180,6 +182,9 @@ int main(int argc, char **argv)
}
infd = rc;
break;
+ case 'b':
+ bufsize = atoi(optarg);
+ break;
}
}
@@ -194,7 +199,7 @@ int main(int argc, char **argv)
exit(1);
}
- tsfd = ts_open(intf_nr, line_nr, ts_nr, mode);
+ tsfd = ts_open(intf_nr, line_nr, ts_nr, mode, bufsize);
if (tsfd < 0)
exit(2);
diff --git a/src/proto_clnt.c b/src/proto_clnt.c
index ca62abe..69c7234 100644
--- a/src/proto_clnt.c
+++ b/src/proto_clnt.c
@@ -318,7 +318,7 @@ osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
int
osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
uint8_t intf, uint8_t line, uint8_t ts,
- enum osmo_e1dp_ts_mode mode)
+ enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
{
struct msgb *msgb;
struct osmo_e1dp_msg_hdr hdr;
@@ -333,6 +333,7 @@ osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
memset(&cfg, 0x00, sizeof(struct osmo_e1dp_ts_config));
cfg.mode = mode;
+ cfg.read_bufsize = read_bufsize;
tsfd = -1;