laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/28066 )

Change subject: e1oip: Make batching-factor and prefill-frame-count configurable
......................................................................

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
---
M include/osmocom/octoi/octoi.h
M src/octoi/e1oip.c
M src/octoi/e1oip.h
M src/octoi/octoi_clnt_fsm.c
M src/octoi/octoi_clnt_vty.c
M src/octoi/octoi_srv_fsm.c
M src/octoi/octoi_srv_vty.c
M src/octoi/octoi_vty.h
8 files changed, 64 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  manawyrm: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/octoi/octoi.h b/include/osmocom/octoi/octoi.h
index e7ebcaa..c9fa3d5 100644
--- a/include/osmocom/octoi/octoi.h
+++ b/include/osmocom/octoi/octoi.h
@@ -21,6 +21,8 @@
        struct llist_head list;                         /* member in 
octoi_server.cfg.accounts */
        char *user_id;                                  /* user ID (IMSI) */
        enum octoi_account_mode mode;
+       uint8_t batching_factor;                        /* E1 frames per UDP 
packet (Tx) */
+       uint32_t prefill_frame_count;                   /* FIFO prefill/preseed 
count (Rx) */
        union {
                struct {
                        char *usb_serial;               /* USB serial string 
(ASCII) of icE1usb */
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 @@
        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 @@
 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 @@
 {
        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 @@
        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 @@
        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 @@
 {
        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 @@
                return NULL;
        }

+       ac->batching_factor = DEFAULT_BATCHING_FACTOR;
+       ac->prefill_frame_count = DEFAULT_PREFILL_FRAME_COUNT;
+
        return ac;
 }

@@ -367,6 +371,35 @@
        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 @@
        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 @@
        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 @@

        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 @@
        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);

--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/28066
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: Ic455ef0ef82867db512e2ffdff24d9dd42d47eeb
Gerrit-Change-Number: 28066
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: manawyrm <[email protected]>
Gerrit-Reviewer: tnt <[email protected]>
Gerrit-MessageType: merged

Reply via email to