aboutsummaryrefslogtreecommitdiffstats
path: root/src/xua_as_fsm.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-10-16 14:50:06 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-10-24 13:23:09 +0200
commit3eae8ec9ef15fd9b4e63b5dbff8f2fd5aba52221 (patch)
treec5fe3d88d34285a4ab12d920c18880d68f308b93 /src/xua_as_fsm.c
parentc99724a9ec5f427a2a9d2ceda0cc7d9b1f847a0c (diff)
ss7: Implement AS traffic mode loadshare using round robin ASP selection
Diffstat (limited to 'src/xua_as_fsm.c')
-rw-r--r--src/xua_as_fsm.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index 541e52c..cf75ef3 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -71,14 +71,12 @@ static int asp_notify_all_as(struct osmo_ss7_as *as, struct osmo_xlm_prim_notify
return sent;
}
-/* actually transmit a message through this AS */
-int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg)
+static struct osmo_ss7_asp *xua_as_select_asp_override(struct osmo_ss7_as *as)
{
struct osmo_ss7_asp *asp;
unsigned int i;
- /* FIXME: proper selection of the ASP based on the SLS and the
- * traffic mode type! */
+ /* FIXME: proper selection of the ASP based on the SLS! */
for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
asp = as->cfg.asps[i];
if (!asp)
@@ -86,6 +84,48 @@ int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg)
if (asp)
break;
}
+ return asp;
+}
+
+static struct osmo_ss7_asp *xua_as_select_asp_roundrobin(struct osmo_ss7_as *as)
+{
+ struct osmo_ss7_asp *asp;
+ unsigned int i;
+ unsigned int first_idx;
+
+ first_idx = (as->cfg.last_asp_idx_sent + 1) % ARRAY_SIZE(as->cfg.asps);
+ i = first_idx;
+ do {
+ asp = as->cfg.asps[i];
+ if (asp)
+ break;
+ i = (i + 1) % ARRAY_SIZE(as->cfg.asps);
+ } while (i != first_idx);
+ as->cfg.last_asp_idx_sent = i;
+
+ return asp;
+}
+
+/* actually transmit a message through this AS */
+int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg)
+{
+ struct osmo_ss7_asp *asp = NULL;
+
+ switch (as->cfg.mode) {
+ case OSMO_SS7_AS_TMOD_OVERRIDE:
+ asp = xua_as_select_asp_override(as);
+ break;
+ case OSMO_SS7_AS_TMOD_LOADSHARE:
+ case OSMO_SS7_AS_TMOD_ROUNDROBIN:
+ asp = xua_as_select_asp_roundrobin(as);
+ break;
+ case OSMO_SS7_AS_TMOD_BCAST:
+ LOGPFSM(as->fi, "Traffic mode broadcast not implemented, dropping message\n");
+ msgb_free(msg);
+ return -1;
+ case _NUM_OSMO_SS7_ASP_TMOD:
+ OSMO_ASSERT(false);
+ }
if (!asp) {
LOGPFSM(as->fi, "No ASP in AS, dropping message\n");