syntax = "proto2";
package protocol;

import "config_common.proto"; // for flex_plmn

//
// UE related statistics
//

// RLC buffer status for a specific logical channel of a UE
message flex_rlc_bsr {
	optional uint32 lc_id = 1;
	optional uint32 tx_queue_size = 2;
	optional uint32 tx_queue_hol_delay = 3;
	optional uint32 retransmission_queue_size = 4;
	optional uint32 retransmission_queue_hol_delay = 5;
	optional uint32 status_pdu_size = 6;
}

// Flags for MAC Control Elements
enum flex_ce_type {
     FLPCET_TA = 1;
     FLPCET_DRX = 2;
     FLPCET_CR = 4;
     FLPCET_CA = 8;
}

// Types of DL CSI reports
enum flex_csi_type {
     FLCSIT_P10 = 0;
     FLCSIT_P11 = 1;
     FLCSIT_P20 = 2;
     FLCSIT_P21 = 3;
     FLCSIT_A12 = 4;
     FLCSIT_A22 = 5;
     FLCSIT_A20 = 6;
     FLCSIT_A30 = 7;
     FLCSIT_A31 = 8;
}

// CSI type P10
message flex_csi_p10 {
	optional uint32 wb_cqi = 1;
}

// CSI type P11
message flex_csi_p11 {
	repeated uint32 wb_cqi = 1;
	optional uint32 wb_pmi = 2;
}

// CSI type P20
message flex_csi_p20 {
	optional uint32 wb_cqi = 1;
	optional uint32 sb_cqi = 2;
	optional uint32 bandwidth_part_index = 3;
	optional uint32 sb_index = 4;
}

// CSI type P21
message flex_csi_p21 {
	repeated uint32 wb_cqi = 1;
	optional uint32 wb_pmi = 2;
	repeated uint32 sb_cqi = 3;
	optional uint32 badwidth_part_index = 4;
	optional uint32 sb_index = 5;
}

// CSI type A12
message flex_csi_a12 {
	repeated uint32 wb_cqi = 1;
	repeated uint32 sb_pmi = 2;
}

// CSI type A22
message flex_csi_a22 {
	repeated uint32 wb_cqi = 1;
	repeated uint32 sb_cqi = 2;
	optional uint32 wb_pmi = 3;
	optional uint32 sb_pmi = 4;
	repeated uint32 sb_list = 5;
}

// CSI type A20
message flex_csi_a20 {
	optional uint32 wb_cqi = 1;
	optional uint32 sb_cqi = 2;
	repeated uint32 sb_list = 3;
}

// CSI type A30
message flex_csi_a30 {
	optional uint32 wb_cqi = 1;
	repeated uint32 sb_cqi = 2;
}

// CSI type A31
message flex_csi_a31 {
	repeated uint32 wb_cqi = 1;
	repeated flex_msb_cqi sb_cqi = 2;
	optional uint32 wb_pmi = 3;
}

// The CQI for the M-preffered subband
message flex_msb_cqi {
	repeated uint32 sb_cqi = 1;
}

// The CSI report of the UE for a specific servCellIndex
message flex_dl_csi {
	optional uint32 serv_cell_index = 1;
	optional uint32 ri = 2;
	optional flex_csi_type type = 3;
	oneof report {
	      flex_csi_p10 p10csi = 4;
	      flex_csi_p11 p11csi = 5;
	      flex_csi_p20 p20csi = 6;
	      flex_csi_p21 p21csi = 7;
	      flex_csi_a12 a12csi = 8;
	      flex_csi_a22 a22csi = 9;
	      flex_csi_a20 a20csi = 10;
	      flex_csi_a30 a30csi = 11;
	      flex_csi_a31 a31csi = 12;
	}
}

// The full DL CQI report for all CC of a UE
message flex_dl_cqi_report {
	optional uint32 sfn_sn = 1;
	repeated flex_dl_csi csi_report = 2;
}

// Paging message info
message flex_paging_info {
	optional uint32 paging_index = 1;
	optional uint32 paging_message_size = 2;
	optional uint32 paging_subframe = 3;
	optional uint32 carrier_index = 4;
}

// Report for the paging buffer status
message flex_paging_buffer_report {
	repeated flex_paging_info paging_info = 1;
}

// The type of UL CQI
enum flex_ul_cqi_type {
     FLUCT_SRS = 0;
     FLUCT_PUSCH = 1;
     FLUCT_PUCCH_1 = 2;
     FLUCT_PUCCH_2 = 3;
     FLUCT_PRACH = 4;
}

// UL CQI report for a specific UE for a given report type
message flex_ul_cqi {
	optional flex_ul_cqi_type type = 1;
	repeated uint32 sinr = 2;
	optional uint32 serv_cell_index = 3;
}

// Full UL CQI report for a specific UE
message flex_ul_cqi_report {
	optional uint32 sfn_sn = 1;
	repeated flex_ul_cqi cqi_meas = 2;
	repeated flex_pucch_dbm pucch_dbm = 3;
}

message flex_pucch_dbm {
	optional int32 p0_pucch_dbm = 1;
	optional uint32 serv_cell_index = 2;
	optional uint32 p0_pucch_updated = 3;
}

//
// Cell related statistics
//

// The UL noise and interference report for a UE
message flex_noise_interference_report {
	optional uint32 sfn_sf = 1;
	optional uint32 rip = 2;
	optional uint32 tnp = 3;
	optional int32 p0_nominal_pucch = 4;
}

//
// RRC Measurements Primitives
//


message flex_rrc_measurements {
	// Measurement identifier.
	optional int32 measid = 1;
	// Primary Cell Reference Signal Received Power (RSRP).
	optional int32 pcell_rsrp = 2;
	// Primary Cell Reference Signal Received Quality (RSRQ).
	optional int32 pcell_rsrq = 3;
	// Neighboring cells measurements performed by UE.
	optional flex_neigh_cells_measurements neigh_meas = 4;
}

message flex_neigh_cells_measurements {
	// Neighboring EUTRA cells measurements.
	repeated flex_eutra_measurements eutra_meas = 1;
}

message flex_eutra_measurements {
	// Physical Cell identifier.
	optional int32 phys_cell_id = 1;
	// EUTRA Cell Global Identity (CGI) measurement.
	optional flex_eutra_cgi_measurements cgi_meas = 2;
	// EUTRA nearby cell reference signal measurement.
	optional flex_eutra_ref_signal_meas meas_result = 3;
}

message flex_eutra_cgi_measurements {
	// EUTRA Cell Global Identity (CGI).
	optional flex_cell_global_eutra_id cgi = 1;
	// Tracking area code of the neighbor cell.
	optional uint32 tracking_area_code = 2;
	// Public land mobile network identifiers of neighbor cell.
	repeated flex_plmn plmn = 3;
}

message flex_cell_global_eutra_id {
	// Public land mobile network identifier of neighbor cell.
	optional flex_plmn plmn = 1;
	// Cell identifier of neighbor cell.
	optional uint32 cell_id = 2;
}

message flex_eutra_ref_signal_meas {
	// Neighboring Cell RSRP
	optional int32 rsrp = 1;
	// Neighboring Cell RSRQ	
	optional int32 rsrq = 2;
}

//
// PDCP Statistics
//

message flex_pdcp_stats {

	optional uint32 pkt_tx = 1;
	optional uint32 pkt_tx_bytes = 2;
	optional uint32 pkt_tx_sn = 3;
	optional uint32 pkt_tx_w = 4;
	optional uint32 pkt_tx_bytes_w = 5;
	optional uint32 pkt_tx_aiat = 7;
	optional uint32 pkt_tx_aiat_w = 8;
	
	optional uint32 pkt_rx = 9;
	optional uint32 pkt_rx_bytes = 10;
	optional uint32 pkt_rx_sn = 11;
	optional uint32 pkt_rx_w = 12;
	optional uint32 pkt_rx_bytes_w = 13;
	optional uint32 pkt_rx_aiat = 14;
	optional uint32 pkt_rx_aiat_w = 15;
	optional uint32 pkt_rx_oo = 16;

	optional uint64 sfn=17;
}

//
// MAC Stats
//

message flex_mac_stats {

    optional uint32 tbs_dl = 1;
    optional uint32 tbs_ul = 2;
    optional uint32 prb_retx_dl = 3;
    optional uint32 prb_retx_ul = 4;
    optional uint32 prb_dl = 5;
    optional uint32 prb_ul = 6;
    optional uint32 mcs1_dl = 7;
    optional uint32 mcs2_dl = 8;
    optional uint32 mcs1_ul = 9;
    optional uint32 mcs2_ul = 10;
    optional uint32 total_bytes_sdus_ul = 11;
    optional uint32 total_bytes_sdus_dl = 12;
    optional uint32 total_prb_retx_dl = 13;
    optional uint32 total_prb_retx_ul = 14;
    optional uint32 total_prb_dl = 15;
    optional uint32 total_prb_ul = 16;
    optional uint32 total_pdu_dl = 17;
    optional uint32 total_pdu_ul = 18;
    optional uint32 total_tbs_dl = 19;
    optional uint32 total_tbs_ul = 20;
    repeated flex_mac_sdus_dl mac_sdus_dl = 21;
    optional uint32 harq_round = 22;
}

message flex_mac_sdus_dl {
    
    optional uint32 sdu_length = 1; 
    optional uint32 lcid = 2;
}

//
// GTP stats
//

message flex_gtp_stats {
    optional uint32 e_rab_id = 1;
    optional uint32 teid_enb = 2;
    optional string addr_enb = 3;
    optional uint32 teid_sgw = 4;
    optional string addr_sgw = 5;
}

//
// S1AP stats
//

message flex_s1ap_ue {
        optional string mme_s1_ip = 1;                  // IP of MME to which UE is connected
        optional uint32 enb_ue_s1ap_id = 2;             // S1AP ID on eNodeB side for UE
        optional uint32 mme_ue_s1ap_id = 3;             // S1AP ID on MME side for UE
        optional flex_plmn selected_plmn = 4;           // UE-selected PLMN in RRC Conn Setup Cplt
}

