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
This commit is contained in:
Pau Espin Pedrol
2024-11-04 11:45:00 +01:00
parent 89504050ea
commit 1d4811e38c
5 changed files with 52 additions and 1 deletions

View File

@@ -7,4 +7,5 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmo-sigtran >2.0.0 use API osmo_sua_sccp_cause_name()
libosmo-sigtran >2.0.0 use API osmo_sua_sccp_cause_name()
libosmo-pfcp >0.4.0 use API osmo_pfcp_cp_peer_set_associated_cb()

View File

@@ -490,6 +490,8 @@ struct hnbgw {
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;

View File

@@ -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);

View File

@@ -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_rx_msg(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m,
}
}
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 @@ int hnbgw_pfcp_init(void)
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 @@ int hnbgw_pfcp_init(void)
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 @@ int hnbgw_pfcp_init(void)
return 0;
}
void hnbgw_pfcp_release(void)
{
if (!hnb_gw_is_gtp_mapping_enabled())
return;
osmo_stat_item_group_free(g_hnbgw->pfcp.statg);
}

View File

@@ -369,5 +369,8 @@ int main(int argc, char **argv)
}
/* not reached */
#if ENABLE_PFCP
hnbgw_pfcp_release();
#endif
exit(0);
}