arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/33892 )
Change subject: bsc (WIP): Make socket queue max. length configurable ......................................................................
bsc (WIP): Make socket queue max. length configurable
Title refers to the maximum length of the osmo_wqueue used for the PCU socket connection.
Related: OS#5774 Change-Id: Ic5f19f4613bccaf582997a4d02b689adee083a0b --- M include/osmocom/bsc/gsm_data.h M include/osmocom/bsc/pcu_if.h M src/osmo-bsc/bsc_init.c M src/osmo-bsc/bsc_vty.c M src/osmo-bsc/pcu_sock.c 5 files changed, 47 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/92/33892/1
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index c2bd7ad..b8bf4e9 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1006,7 +1006,10 @@
/* PCU socket state */ char *pcu_sock_path; + unsigned int pcu_sock_wqueue_len_max; struct pcu_sock_state *pcu_state; + /* Needed by vty config command in order to update wqueue length */ + int pcu_sock_fd; };
struct gsm_audio_support { diff --git a/include/osmocom/bsc/pcu_if.h b/include/osmocom/bsc/pcu_if.h index 10d8640..55b2528 100644 --- a/include/osmocom/bsc/pcu_if.h +++ b/include/osmocom/bsc/pcu_if.h @@ -9,6 +9,7 @@ #define PCUIF_HDR_SIZE (sizeof(struct gsm_pcu_if) - sizeof(((struct gsm_pcu_if *)0)->u))
#define BSC_PCU_SOCK_WQUEUE_LEN_DEFAULT 100 +#define BSC_CFG_PCU_SOCK_WQUEUE_LEN_MAX_MAX 2147483646
struct pcu_sock_state { struct gsm_network *net; /* backpointer to GSM network */ diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c index c381c0f..c6c8052 100644 --- a/src/osmo-bsc/bsc_init.c +++ b/src/osmo-bsc/bsc_init.c @@ -204,6 +204,8 @@ net->cbc->client.remote_addr = (struct osmo_sockaddr_str){ .port = CBSP_TCP_PORT, }; net->cbc->client.local_addr = (struct osmo_sockaddr_str){};
+ net->pcu_sock_wqueue_len_max = BSC_PCU_SOCK_WQUEUE_LEN_DEFAULT; + net->pcu_sock_fd = -1; return net;
err_free_all: diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index e53b145..0850783 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -412,6 +412,9 @@
if (gsmnet->pcu_sock_path) vty_out(vty, " pcu-socket %s%s", gsmnet->pcu_sock_path, VTY_NEWLINE); + if (gsmnet->pcu_sock_wqueue_len_max != BSC_PCU_SOCK_WQUEUE_LEN_DEFAULT) + vty_out(vty, " pcu-socket-wqueue-length %u%s", gsmnet->pcu_sock_wqueue_len_max, + VTY_NEWLINE);
neighbor_ident_vty_write_network(vty, " "); mgcp_client_pool_config_write(vty, " "); @@ -2471,8 +2474,27 @@ return CMD_SUCCESS; }
-DEFUN_ATTR(cfg_net_pcu_sock, - cfg_net_pcu_sock_cmd, +DEFUN_ATTR(cfg_bts_pcu_sock_wqueue_len, cfg_bts_pcu_sock_wqueue_len_cmd, + "pcu-socket-wqueue-length <1-" OSMO_STRINGIFY_VAL(BSC_CFG_PCU_SOCK_WQUEUE_LEN_MAX_MAX) ">", + "Configure the PCU socket queue length\n" + "Queue length\n", + CMD_ATTR_IMMEDIATE) +{ + struct gsm_network *net = gsmnet_from_vty(vty); + struct osmo_fd *ofd; + int fd = net->pcu_sock_fd; + net->pcu_sock_wqueue_len_max = atoi(argv[0]); + if (fd >= 0 && ((ofd = osmo_fd_get_by_fd(fd)) != NULL)) { + /* The above condition should hold only if we have an open pcu socket */ + OSMO_ASSERT(net->pcu_state); + net->pcu_state->upqueue.max_length = net->pcu_sock_wqueue_len_max; + } + + return CMD_SUCCESS; +} + +DEFUN_ATTR(cfg_net_pcu_sock_path, + cfg_net_pcu_sock_path_cmd, "pcu-socket PATH", "PCU Socket Path for using OsmoPCU co-located with BSC\n" "Path in the file system for the unix-domain PCU socket\n", @@ -3581,7 +3603,8 @@ install_element(GSMNET_NODE, &cfg_net_meas_feed_scenario_cmd); install_element(GSMNET_NODE, &cfg_net_timer_cmd); install_element(GSMNET_NODE, &cfg_net_allow_unusable_timeslots_cmd); - install_element(GSMNET_NODE, &cfg_net_pcu_sock_cmd); + install_element(GSMNET_NODE, &cfg_net_pcu_sock_path_cmd); + install_element(GSMNET_NODE, &cfg_bts_pcu_sock_wqueue_len_cmd); install_element(GSMNET_NODE, &cfg_net_no_pcu_sock_cmd);
/* Timer configuration commands (generic osmo_tdef API) */ diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c index a4af984..3d8ea88 100644 --- a/src/osmo-bsc/pcu_sock.c +++ b/src/osmo-bsc/pcu_sock.c @@ -927,7 +927,7 @@ if (!state) return -ENOMEM;
- osmo_wqueue_init(&state->upqueue, BSC_PCU_SOCK_WQUEUE_LEN_DEFAULT); + osmo_wqueue_init(&state->upqueue, net->pcu_sock_wqueue_len_max); state->upqueue.read_cb = pcu_sock_read; state->upqueue.write_cb = pcu_sock_write; state->upqueue.bfd.fd = -1; @@ -953,6 +953,7 @@ talloc_free(state); return rc; } + net->pcu_sock_fd = rc;
LOGP(DPCU, LOGL_INFO, "Started listening on PCU socket (PCU IF v%u): %s\n", PCU_IF_VERSION, net->pcu_sock_path);