aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-05-08 09:18:54 +0200
committerHarald Welte <laforge@osmocom.org>2022-05-08 09:40:43 +0200
commit61e4d2c4ac06135c501147247e552d7397e1c2cc (patch)
treed6acb435a1a7c881093eb779fa8ba204151127b4 /src
parentd78ddab9ff2a9d9175f2d4a564443813b9c15403 (diff)
e1oip: Make batching-factor and prefill-frame-count configurable
This adds VTY commands at the 'account' level to configure those settings. They will only become active on the next [re]connect of the line. Change-Id: Ic455ef0ef82867db512e2ffdff24d9dd42d47eeb
Diffstat (limited to 'src')
-rw-r--r--src/octoi/e1oip.c7
-rw-r--r--src/octoi/e1oip.h2
-rw-r--r--src/octoi/octoi_clnt_fsm.c2
-rw-r--r--src/octoi/octoi_clnt_vty.c3
-rw-r--r--src/octoi/octoi_srv_fsm.c2
-rw-r--r--src/octoi/octoi_srv_vty.c43
-rw-r--r--src/octoi/octoi_vty.h3
7 files changed, 62 insertions, 0 deletions
diff --git a/src/octoi/e1oip.c b/src/octoi/e1oip.c
index a577a92..c4bf054 100644
--- a/src/octoi/e1oip.c
+++ b/src/octoi/e1oip.c
@@ -313,6 +313,13 @@ struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer)
return iline;
}
+void e1oip_line_configure(struct e1oip_line *iline, uint8_t batching_factor,
+ uint32_t prefill_frame_count)
+{
+ iline->cfg.batching_factor = batching_factor;
+ iline->cfg.prefill_frame_count = prefill_frame_count;
+}
+
void e1oip_line_reset(struct e1oip_line *iline)
{
frame_fifo_init(&iline->e1o.fifo, iline->cfg.batching_factor, fifo_threshold_cb, iline);
diff --git a/src/octoi/e1oip.h b/src/octoi/e1oip.h
index 2c88346..ccdebd5 100644
--- a/src/octoi/e1oip.h
+++ b/src/octoi/e1oip.h
@@ -83,6 +83,8 @@ static inline uint64_t iline_ctr_get_rate_1s(struct e1oip_line *iline, unsigned
struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer);
void e1oip_line_set_name(struct e1oip_line *line, const char *name);
void e1oip_line_reset(struct e1oip_line *iline);
+void e1oip_line_configure(struct e1oip_line *iline, uint8_t batching_factor,
+ uint32_t prefill_frame_count);
void e1oip_line_destroy(struct e1oip_line *iline);
int e1oip_rcvmsg_tdm_data(struct e1oip_line *iline, struct msgb *msg);
diff --git a/src/octoi/octoi_clnt_fsm.c b/src/octoi/octoi_clnt_fsm.c
index c4117d2..2ec5c8c 100644
--- a/src/octoi/octoi_clnt_fsm.c
+++ b/src/octoi/octoi_clnt_fsm.c
@@ -122,6 +122,8 @@ static void clnt_st_accepted_onenter(struct osmo_fsm_inst *fi, uint32_t prev_sta
{
struct clnt_state *st = fi->priv;
+ e1oip_line_configure(st->peer->iline, st->acc->batching_factor,
+ st->acc->prefill_frame_count);
/* reset RIFO/FIFO etc. */
e1oip_line_reset(st->peer->iline);
iline_ctr_add(st->peer->iline, LINE_CTR_E1oIP_CONNECT_ACCEPT, 1);
diff --git a/src/octoi/octoi_clnt_vty.c b/src/octoi/octoi_clnt_vty.c
index 756cc9a..ff50ddb 100644
--- a/src/octoi/octoi_clnt_vty.c
+++ b/src/octoi/octoi_clnt_vty.c
@@ -242,6 +242,7 @@ DEFUN(show_clnt, show_clnt_cmd,
llist_for_each_entry(clnt, &g_octoi->clients, list) {
struct octoi_sock *sock = clnt->sock;
+ octoi_vty_show_one_account(vty, "", clnt->cfg.account);
vty_show_octoi_sock(vty, sock);
}
@@ -278,6 +279,8 @@ void octoi_client_vty_init(void)
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_ice1_serno_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_ice1_line_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_mode_cmd);
+ install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_batching_factor_cmd);
+ install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_prefill_frame_count_cmd);
install_node(&clnt_node, config_write_octoi_clnt);
install_element(CONFIG_NODE, &cfg_client_cmd);
diff --git a/src/octoi/octoi_srv_fsm.c b/src/octoi/octoi_srv_fsm.c
index 1af3805..469436e 100644
--- a/src/octoi/octoi_srv_fsm.c
+++ b/src/octoi/octoi_srv_fsm.c
@@ -174,6 +174,8 @@ static void srv_st_accepted_onenter(struct osmo_fsm_inst *fi, uint32_t prev_stat
{
struct srv_state *st = fi->priv;
+ e1oip_line_configure(st->peer->iline, st->acc->batching_factor,
+ st->acc->prefill_frame_count);
/* reset RIFO/FIFO etc. */
e1oip_line_reset(st->peer->iline);
iline_ctr_add(st->peer->iline, LINE_CTR_E1oIP_CONNECT_ACCEPT, 1);
diff --git a/src/octoi/octoi_srv_vty.c b/src/octoi/octoi_srv_vty.c
index f616af5..58d18bc 100644
--- a/src/octoi/octoi_srv_vty.c
+++ b/src/octoi/octoi_srv_vty.c
@@ -34,6 +34,7 @@
#include <osmocom/vty/stats.h>
#include <osmocom/vty/misc.h>
+#include "e1oip.h"
#include "octoi.h"
#include "octoi_sock.h"
#include "octoi_fsm.h"
@@ -63,6 +64,9 @@ static struct octoi_account *_account_create(void *ctx, const char *user_id)
return NULL;
}
+ ac->batching_factor = DEFAULT_BATCHING_FACTOR;
+ ac->prefill_frame_count = DEFAULT_PREFILL_FRAME_COUNT;
+
return ac;
}
@@ -367,6 +371,35 @@ DEFUN(cfg_account_redir, cfg_account_redir_cmd,
return CMD_SUCCESS;
}
+gDEFUN(cfg_account_batching_factor, cfg_account_batching_factor_cmd,
+ "batching-factor <1-256>",
+ "E1oIP batching factor (E1 frames per Tx UDP packet)\n"
+ "E1oIP batching factor (E1 frames per Tx UDP packet)\n")
+{
+ struct octoi_account *acc = vty->index;
+
+ acc->batching_factor = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
+gDEFUN(cfg_account_prefill_frame_count, cfg_account_prefill_frame_count_cmd,
+ "prefill-frame-count <0-8000>",
+ "Number of E1 frames to pre-fill/pre-seed in Rx RIFO\n"
+ "Number of E1 frames to pre-fill/pre-seed in Rx RIFO\n")
+{
+ struct octoi_account *acc = vty->index;
+
+ acc->prefill_frame_count = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
+void octoi_vty_show_one_account(struct vty *vty, const char *pfx, struct octoi_account *acc)
+{
+ vty_out(vty, "%sAccount '%s': Mode=%s, Batching=%u, Prefill=%u%s", pfx,
+ acc->user_id, get_value_string(octoi_account_mode_name, acc->mode),
+ acc->batching_factor, acc->prefill_frame_count, VTY_NEWLINE);
+}
+
void octoi_vty_write_one_account(struct vty *vty, const struct octoi_account *acc)
{
if (!acc)
@@ -375,6 +408,10 @@ void octoi_vty_write_one_account(struct vty *vty, const struct octoi_account *ac
vty_out(vty, " account %s%s", acc->user_id, VTY_NEWLINE);
vty_out(vty, " mode %s%s", get_value_string(octoi_account_mode_name, acc->mode),
VTY_NEWLINE);
+ if (acc->batching_factor != DEFAULT_BATCHING_FACTOR)
+ vty_out(vty, " batching-factor %u%s", acc->batching_factor, VTY_NEWLINE);
+ if (acc->prefill_frame_count != DEFAULT_PREFILL_FRAME_COUNT)
+ vty_out(vty, " prefill-frame-count %u%s", acc->prefill_frame_count, VTY_NEWLINE);
switch (acc->mode) {
case ACCOUNT_MODE_NONE:
@@ -425,6 +462,7 @@ DEFUN(show_server, show_server_cmd,
SHOW_STR "Display information about the OCTOI Server\n")
{
struct octoi_server *srv = g_octoi->server;
+ struct octoi_account *acc;
if (!srv) {
vty_out(vty, "%% No OCTOI server present%s", VTY_NEWLINE);
@@ -433,6 +471,9 @@ DEFUN(show_server, show_server_cmd,
vty_show_octoi_sock(vty, srv->sock);
+ llist_for_each_entry(acc, &srv->cfg.accounts, list)
+ octoi_vty_show_one_account(vty, "", acc);
+
return CMD_SUCCESS;
}
@@ -446,6 +487,8 @@ void octoi_server_vty_init(void)
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_ice1_serno_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_ice1_line_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_redir_cmd);
+ install_element(OCTOI_ACCOUNT_NODE, &cfg_account_batching_factor_cmd);
+ install_element(OCTOI_ACCOUNT_NODE, &cfg_account_prefill_frame_count_cmd);
install_node(&srv_node, config_write_octoi_srv);
install_element(CONFIG_NODE, &cfg_server_cmd);
diff --git a/src/octoi/octoi_vty.h b/src/octoi/octoi_vty.h
index 6f18802..16c5337 100644
--- a/src/octoi/octoi_vty.h
+++ b/src/octoi/octoi_vty.h
@@ -7,9 +7,12 @@
extern struct cmd_element cfg_account_mode_cmd;
extern struct cmd_element cfg_account_ice1_serno_cmd;
extern struct cmd_element cfg_account_ice1_line_cmd;
+extern struct cmd_element cfg_account_batching_factor_cmd;
+extern struct cmd_element cfg_account_prefill_frame_count_cmd;
struct octoi_account *octoi_client_account_create(struct octoi_client *clnt, const char *user_id);
+void octoi_vty_show_one_account(struct vty *vty, const char *pfx, struct octoi_account *acc);
void octoi_vty_write_one_account(struct vty *vty, const struct octoi_account *acc);
void vty_show_octoi_sock(struct vty *vty, struct octoi_sock *sock);