pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/38616?usp=email )
Change subject: Add PFCP stats item group ...................................................................... Add PFCP stats item group This will be used by TTCN3 testsuite to figure out whether it should expect a PFCP Assoc Setup from HNBGW. Depends: libosmo-pfcp.git Change-Id Ibc8047856ddcc9c71f2b4cf30f577862b6b414ca Change-Id: Ic71df8df83e97f4015077677e426c803f84d31ea --- M include/osmocom/hnbgw/hnbgw.h M include/osmocom/hnbgw/hnbgw_pfcp.h M src/osmo-hnbgw/hnbgw_pfcp.c M src/osmo-hnbgw/osmo_hnbgw_main.c 4 files changed, 50 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/16/38616/1 diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index caaff5f..afceca8 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -490,6 +490,8 @@ struct { struct osmo_pfcp_endpoint *ep; struct osmo_pfcp_cp_peer *cp_peer; + /* Running counters for the PFCP conn */ + struct osmo_stat_item_group *statg; } pfcp; struct osmo_timer_list hnb_store_rab_durations_timer; diff --git a/include/osmocom/hnbgw/hnbgw_pfcp.h b/include/osmocom/hnbgw/hnbgw_pfcp.h index 585d3f7..376d144 100644 --- a/include/osmocom/hnbgw/hnbgw_pfcp.h +++ b/include/osmocom/hnbgw/hnbgw_pfcp.h @@ -1,3 +1,9 @@ #pragma once +enum hnbgw_upf_stats { + HNBGW_UPF_STAT_ASSOCIATED, +}; +#define HNBGW_UPF_STAT_SET(stat, val) osmo_stat_item_set(osmo_stat_item_group_get_item(g_hnbgw->pfcp.statg, (stat)), (val)) + int hnbgw_pfcp_init(void); +void hnbgw_pfcp_release(void); diff --git a/src/osmo-hnbgw/hnbgw_pfcp.c b/src/osmo-hnbgw/hnbgw_pfcp.c index c7b2b08..dc82f04 100644 --- a/src/osmo-hnbgw/hnbgw_pfcp.c +++ b/src/osmo-hnbgw/hnbgw_pfcp.c @@ -20,12 +20,27 @@ */ #include <osmocom/core/sockaddr_str.h> +#include <osmocom/core/stats.h> +#include <osmocom/core/stat_item.h> #include <osmocom/pfcp/pfcp_endpoint.h> #include <osmocom/pfcp/pfcp_cp_peer.h> #include <osmocom/hnbgw/hnbgw.h> #include <osmocom/hnbgw/context_map.h> #include <osmocom/hnbgw/ps_rab_fsm.h> +#include <osmocom/hnbgw/hnbgw_pfcp.h> + +static const struct osmo_stat_item_desc hnbgw_upf_stat_item_description[] = { + [HNBGW_UPF_STAT_ASSOCIATED] = { "pfcp_associated", "Associated to UPF through PFCP", OSMO_STAT_ITEM_NO_UNIT, 16, 0}, +}; + +static const struct osmo_stat_item_group_desc hnbgw_upf_statg_desc = { + "upf", + "UPF Peer Statistics", + OSMO_STATS_CLASS_PEER, + ARRAY_SIZE(hnbgw_upf_stat_item_description), + hnbgw_upf_stat_item_description, +}; static void pfcp_set_msg_ctx(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m, struct osmo_pfcp_msg *req) { @@ -62,6 +77,12 @@ } } +static void pfcp_cp_peer_assoc_cb(struct osmo_pfcp_cp_peer *cp_peer, bool associated) +{ + LOGP(DLPFCP, LOGL_NOTICE, "PFCP Peer associated: %s\n", associated ? "true" : "false"); + HNBGW_UPF_STAT_SET(HNBGW_UPF_STAT_ASSOCIATED, associated ? 1 : 0); +} + int hnbgw_pfcp_init(void) { struct osmo_pfcp_endpoint_cfg cfg; @@ -81,6 +102,12 @@ return -1; } + g_hnbgw->pfcp.statg = osmo_stat_item_group_alloc(g_hnbgw, &hnbgw_upf_statg_desc, 0); + if (!g_hnbgw->pfcp.statg) { + LOGP(DLPFCP, LOGL_ERROR, "Failed creating UPF stats item group\n"); + return -1; + } + cfg = (struct osmo_pfcp_endpoint_cfg){ .set_msg_ctx_cb = pfcp_set_msg_ctx, .rx_msg_cb = pfcp_rx_msg, @@ -136,6 +163,11 @@ LOGP(DLPFCP, LOGL_ERROR, "Cannot allocate PFCP CP Peer FSM\n"); return -1; } + if (osmo_pfcp_cp_peer_set_associated_cb(g_hnbgw->pfcp.cp_peer, pfcp_cp_peer_assoc_cb)) { + LOGP(DLPFCP, LOGL_ERROR, "Cannot Set PFCP CP Peer associated callback\n"); + return -1; + } + if (osmo_pfcp_cp_peer_associate(g_hnbgw->pfcp.cp_peer)) { LOGP(DLPFCP, LOGL_ERROR, "Cannot start PFCP CP Peer FSM\n"); return -1; @@ -143,3 +175,10 @@ return 0; } + +void hnbgw_pfcp_release(void) +{ + if (!hnb_gw_is_gtp_mapping_enabled()) + return; + osmo_stat_item_group_free(g_hnbgw->pfcp.statg); +} diff --git a/src/osmo-hnbgw/osmo_hnbgw_main.c b/src/osmo-hnbgw/osmo_hnbgw_main.c index 3e715b0..2034490 100644 --- a/src/osmo-hnbgw/osmo_hnbgw_main.c +++ b/src/osmo-hnbgw/osmo_hnbgw_main.c @@ -369,5 +369,8 @@ } /* not reached */ +#if ENABLE_PFCP + hnbgw_pfcp_release(); +#endif exit(0); } -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/38616?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ic71df8df83e97f4015077677e426c803f84d31ea Gerrit-Change-Number: 38616 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de>