gbproxy: Implement scaling of BVC flow control in SGSN pool

When there are multiple SGSNs inside a pool, we need to decide
how much of the per-BVC capacity advertised by the BSS in its
BVC-FLOW-CONTROL we should announce to each of the pool members.

A conservative approach would be to advertise 1/num_sgsn, but
there may also be use case where over-provisioning (announcing more
than an equal share of the capacity) is useful.

Hence, let's introduce "pool bvc-flow-control-ratio <1-100>" in order
to allow the administrator to decide.

Related: OS#4891
Change-Id: Ibe5addf657e7237499ca0205bacfe999ecd1e771
diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c
index a9db596..49ec91c 100644
--- a/src/gbproxy/gb_proxy_vty.c
+++ b/src/gbproxy/gb_proxy_vty.c
@@ -76,6 +76,9 @@
 
 	vty_out(vty, "gbproxy%s", VTY_NEWLINE);
 
+	if (g_cfg->pool.bvc_fc_ratio != 100)
+		vty_out(vty, " pool bvc-flow-control-ratio %u%s", g_cfg->pool.bvc_fc_ratio, VTY_NEWLINE);
+
 	hash_for_each(g_cfg->sgsn_nses, i, nse, list) {
 		vty_out(vty, " sgsn nsei %u%s", nse->nsei, VTY_NEWLINE);
 	}
@@ -134,6 +137,17 @@
 	return CMD_WARNING;
 }
 
+DEFUN(cfg_pool_bvc_fc_ratio,
+      cfg_pool_bvc_fc_ratio_cmd,
+      "pool bvc-flow-control-ratio <1-100>",
+      "SGSN Pool related configuration\n"
+      "Ratio of BSS-advertised bucket size + leak rate advertised to each SGSN\n"
+      "Ratio of BSS-advertised bucket size + leak rate advertised to each SGSN (Percent)\n")
+{
+	g_cfg->pool.bvc_fc_ratio = atoi(argv[0]);
+	return CMD_SUCCESS;
+}
+
 static void log_set_bvc_filter(struct log_target *target,
 				const uint16_t *bvci)
 {
@@ -315,6 +329,7 @@
 	install_element(CONFIG_NODE, &cfg_gbproxy_cmd);
 	install_node(&gbproxy_node, config_write_gbproxy);
 	install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd);
+	install_element(GBPROXY_NODE, &cfg_pool_bvc_fc_ratio_cmd);
 
 	return 0;
 }