mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	[GPSR] SGSN: Keep traffic counters for each PDP context
This commit is contained in:
		@@ -42,6 +42,13 @@ enum gprs_mm_ctr {
 | 
			
		||||
	GMM_CTR_RA_UPDATE,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum gprs_pdp_ctx {
 | 
			
		||||
	PDP_CTR_PKTS_UDATA_IN,
 | 
			
		||||
	PDP_CTR_PKTS_UDATA_OUT,
 | 
			
		||||
	PDP_CTR_BYTES_UDATA_IN,
 | 
			
		||||
	PDP_CTR_BYTES_UDATA_OUT,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum gprs_t3350_mode {
 | 
			
		||||
	GMM_T3350_MODE_ATT,
 | 
			
		||||
	GMM_T3350_MODE_RAU,
 | 
			
		||||
@@ -137,6 +144,7 @@ struct sgsn_pdp_ctx {
 | 
			
		||||
	struct llist_head	g_list;	/* list_head for global list */
 | 
			
		||||
	struct sgsn_mm_ctx	*mm;	/* back pointer to MM CTX */
 | 
			
		||||
	struct sgsn_ggsn_ctx	*ggsn;	/* which GGSN serves this PDP */
 | 
			
		||||
	struct rate_ctr_group	*ctrg;
 | 
			
		||||
 | 
			
		||||
	//unsigned int		id;
 | 
			
		||||
	struct pdp_t		*lib;	/* pointer to libgtp PDP ctx */
 | 
			
		||||
 
 | 
			
		||||
@@ -110,7 +110,7 @@ DEFUN(show_bssgp_stats, show_bssgp_stats_cmd, "show bssgp stats",
 | 
			
		||||
 | 
			
		||||
DEFUN(show_bvc, show_bvc_cmd, "show bssgp nsei <0-65535> [stats]",
 | 
			
		||||
	SHOW_STR BSSGP_STR
 | 
			
		||||
	"Show all BVCSE by its NSE Identifier\n"
 | 
			
		||||
	"Show all BVCs on one NSE\n"
 | 
			
		||||
	"The NSEI\n" "Include Statistics\n")
 | 
			
		||||
{
 | 
			
		||||
	struct bssgp_bvc_ctx *bvc;
 | 
			
		||||
 
 | 
			
		||||
@@ -61,6 +61,20 @@ static const struct rate_ctr_group_desc mmctx_ctrg_desc = {
 | 
			
		||||
	.ctr_desc = mmctx_ctr_description,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct rate_ctr_desc pdpctx_ctr_description[] = {
 | 
			
		||||
	{ "udata.packets.in",	"User Data  Messages ( In)" },
 | 
			
		||||
	{ "udata.packets.out",	"User Data  Messages (Out)" },
 | 
			
		||||
	{ "udata.bytes.in",	"User Data  Bytes    ( In)" },
 | 
			
		||||
	{ "udata.bytes.out",	"User Data  Bytes    (Out)" },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct rate_ctr_group_desc pdpctx_ctrg_desc = {
 | 
			
		||||
	.group_name_prefix = "sgsn.pdpctx",
 | 
			
		||||
	.group_description = "SGSN PDP Context Statistics",
 | 
			
		||||
	.num_ctr = ARRAY_SIZE(pdpctx_ctr_description),
 | 
			
		||||
	.ctr_desc = pdpctx_ctr_description,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int ra_id_equals(const struct gprs_ra_id *id1,
 | 
			
		||||
			const struct gprs_ra_id *id2)
 | 
			
		||||
{
 | 
			
		||||
@@ -182,6 +196,7 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
 | 
			
		||||
 | 
			
		||||
	pdp->mm = mm;
 | 
			
		||||
	pdp->nsapi = nsapi;
 | 
			
		||||
	pdp->ctrg = rate_ctr_group_alloc(pdp, &pdpctx_ctrg_desc, nsapi);
 | 
			
		||||
	llist_add(&pdp->list, &mm->pdp_list);
 | 
			
		||||
	llist_add(&pdp->g_list, &sgsn_pdp_ctxts);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -393,6 +393,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len)
 | 
			
		||||
		pinfo.drx_params = mm->drx_parms;
 | 
			
		||||
		pinfo.qos[0] = 0; // FIXME
 | 
			
		||||
		rc = gprs_bssgp_tx_paging(mm->nsei, 0, &pinfo);
 | 
			
		||||
		rate_ctr_inc(&mm->ctrg->ctr[GMM_CTR_PAGING_PS]);
 | 
			
		||||
		/* FIXME: queue the packet we received from GTP */
 | 
			
		||||
		break;
 | 
			
		||||
	case GMM_REGISTERED_NORMAL:
 | 
			
		||||
@@ -404,6 +405,11 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len)
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rate_ctr_inc(&pdp->ctrg->ctr[PDP_CTR_PKTS_UDATA_OUT]);
 | 
			
		||||
	rate_ctr_add(&pdp->ctrg->ctr[PDP_CTR_BYTES_UDATA_OUT], len);
 | 
			
		||||
	rate_ctr_inc(&mm->ctrg->ctr[GMM_CTR_PKTS_UDATA_OUT]);
 | 
			
		||||
	rate_ctr_add(&mm->ctrg->ctr[GMM_CTR_BYTES_UDATA_OUT], len);
 | 
			
		||||
 | 
			
		||||
	return sndcp_unitdata_req(msg, &mm->llme->lle[pdp->sapi],
 | 
			
		||||
				  pdp->nsapi, mm);
 | 
			
		||||
}
 | 
			
		||||
@@ -435,6 +441,14 @@ int sgsn_rx_sndcp_ud_ind(uint32_t tlli, uint8_t nsapi, struct msgb *msg,
 | 
			
		||||
		LOGP(DGPRS, LOGL_ERROR, "PDP CTX without libgtp\n");
 | 
			
		||||
		return -EIO;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rate_ctr_inc(&pdp->ctrg->ctr[PDP_CTR_PKTS_UDATA_IN]);
 | 
			
		||||
	rate_ctr_add(&pdp->ctrg->ctr[PDP_CTR_BYTES_UDATA_IN], npdu_len);
 | 
			
		||||
	rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_UDATA_IN]);
 | 
			
		||||
	rate_ctr_add(&mmctx->ctrg->ctr[GMM_CTR_BYTES_UDATA_IN], npdu_len);
 | 
			
		||||
 | 
			
		||||
	return gtp_data_req(pdp->ggsn->gsn, pdp->lib, npdu, npdu_len);
 | 
			
		||||
 | 
			
		||||
	return gtp_data_req(pdp->ggsn->gsn, pdp->lib, npdu, npdu_len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -149,8 +149,7 @@ static void vty_dump_pdp(struct vty *vty, const char *pfx,
 | 
			
		||||
	vty_out(vty, "%sPDP Context IMSI: %s, SAPI: %u, NSAPI: %u%s",
 | 
			
		||||
		pfx, pdp->mm->imsi, pdp->sapi, pdp->nsapi, VTY_NEWLINE);
 | 
			
		||||
	vty_out(vty, "%s  APN: %s\n", pfx, pdp->lib->apn_use.v);
 | 
			
		||||
	/* FIXME: statistics */
 | 
			
		||||
	//vty_out_rate_ctr_group(vty, " ", pdp->ctrg);
 | 
			
		||||
	vty_out_rate_ctr_group(vty, " ", pdp->ctrg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void vty_dump_mmctx(struct vty *vty, const char *pfx,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user