summaryrefslogtreecommitdiffstats
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
parentc99724a9ec5f427a2a9d2ceda0cc7d9b1f847a0c (diff)
ss7: Implement AS traffic mode loadshare using round robin ASP selection
-rw-r--r--TODO-RELEASE1
-rw-r--r--include/osmocom/sigtran/osmo_ss7.h1
-rw-r--r--src/xua_as_fsm.c48
3 files changed, 46 insertions, 4 deletions
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 98b3b88..224f6bc 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -8,3 +8,4 @@
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmo-sigtran osmo_ss7_asp_peer ABI breakage (host is now an array of strings)
+libosmo-sigtran osmo_ss7_as ABI breakage (added field last_asp_idx_sent)
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 12aeea4..4f3d6f5 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -322,6 +322,7 @@ struct osmo_ss7_as {
} pc_override;
struct osmo_ss7_asp *asps[16];
+ uint8_t last_asp_idx_sent; /* used for load-sharing traffic mode (round robin implementation) */
} cfg;
};
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");