Commit cdebf27e authored by Yangxiong Peng's avatar Yangxiong Peng

Bug #123766: [L3 SIMU] add trace points and plugin for MAC packets

   -- Fix display of raw data
   -- Merge plugin for nFPI
parent 26ec3a6f
......@@ -616,7 +616,7 @@ void logRecord_tp(const char *file,
else
snprintf(header, sizeof(header)-1, "SS-%s", c->name);
LOG_SS(header, buf) ;
LOG_SS(header, func, line, buf) ;
}
void vlogRecord_mt(const char *file,
......
......@@ -488,11 +488,17 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
if(g_log->log_component[c].level >= OAILOG_TRACE) { \
logRecord_tp(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_TRACE, x); \
} } while(0)
# define LOG_P(lvl, _string, buf, len) do { \
if(g_log->log_component[PKT].level >= lvl) { \
LOG_SS_PKT(PKT, _string, buf, len); \
} } while(0)
# define LOG_MAC_P(lvl, _string, sfn, sf, mac_pack_info, buf, len) do { \
if(g_log->log_component[PKT].level >= lvl) { \
LOG_SS_MAC_PKT(PKT, _string, sfn, sf, mac_pack_info, buf, len); \
} } while(0)
/* avoid warnings for variables only used in LOG macro's but set outside debug section */
#define GCC_NOTUSED __attribute__((unused))
#define LOG_USEDINLOG_VAR(A,B) GCC_NOTUSED A B
......
......@@ -51,13 +51,23 @@
evId, g_log->sfn, g_log->sf, \
__func__, __LINE__, buf); \
} } while (0)
#define LOG_SS(component, log) tracepoint(SSeNB, SS_LOG, \
component, -1, g_log->sfn, \
g_log->sf, __func__, __LINE__,\
log)
#define LOG_SS(component, func, line, log) do { \
tracepoint(SSeNB, SS_LOG, \
component, -1, g_log->sfn, \
g_log->sf, func, line, log); \
} while(0)
#define LOG_SS_PKT(component, _string, buf, len) do { \
tracepoint(SSeNB, SS_PKT, \
"SS-PDU", -1, g_log->sfn, \
g_log->sf, _string, buf, len); \
} while(0)
#define LOG_SS_MAC_PKT(component, _string, sfn, sf, mac_pack_info, buf, len) do { \
tracepoint(SSeNB, SS_MAC_PKT, \
"SS-MAC-PDU", -1, sfn, sf, \
__func__, __LINE__, mac_pack_info, \
_string, buf, len); \
} while(0)
#endif /** __SS_LOG_H__ */
......@@ -153,7 +153,48 @@ TRACEPOINT_EVENT(
)
)
#if !defined(_SS_MAC_PKT_T)
typedef struct mac_pkt_info_s {
int direction;
int rnti_type;
int rnti;
int harq_pid;
int preamble;
} mac_pkt_info_t;
#define _SS_MAC_PKT_T
#endif
TRACEPOINT_EVENT(
SSeNB,
SS_MAC_PKT,
TP_ARGS(
const char*, component,
int, event_id,
int, sfn,
int, slot,
const char*, funcName,
int, lineNo,
mac_pkt_info_t, mac_pkt,
const char*, log_string,
uint8_t *, array_arg,
unsigned int, length
),
TP_FIELDS(
ctf_string(MODNAME, component)
ctf_integer(int32_t, EVENTID, event_id)
ctf_integer(int32_t, SFN, sfn)
ctf_integer(int32_t, SLOT, slot)
ctf_string(FUNCTION, funcName)
ctf_integer(int32_t, LINE, lineNo)
ctf_integer(int32_t, DIRECTION, mac_pkt.direction)
ctf_integer(int32_t, RNTI_TYPE, mac_pkt.rnti_type)
ctf_integer(int32_t, RNTI, mac_pkt.rnti)
ctf_integer(int32_t, HARQ_PID, mac_pkt.harq_pid)
ctf_integer(int32_t, PREAMBLE, mac_pkt.preamble)
ctf_string(Event, log_string)
ctf_sequence_hex(uint8_t, Buffer, array_arg, unsigned int, length)
)
)
#endif /* _SS_TP_H */
......
......@@ -1474,6 +1474,15 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->RA_rnti), T_INT(frameP),
T_INT(slotP), T_INT(0), T_BUFFER(&tx_req->TLVs[0].value.direct[0], tx_req->TLVs[0].length));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_DOWNLINK;
mac_pkt.rnti_type = map_nr_rnti_type(NR_RNTI_RA);
mac_pkt.rnti = ra->RA_rnti;
mac_pkt.harq_pid = 0;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_DL_RAR_PDU", frameP, slotP, mac_pkt, (uint8_t *)&tx_req->TLVs[0].value.direct[0], (int)tx_req->TLVs[0].length);
tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0];
tx_req->PDU_index = pduindex;
tx_req->num_TLV = 1;
......@@ -1863,6 +1872,15 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->rnti),
T_INT(frameP), T_INT(slotP), T_INT(current_harq_pid), T_BUFFER(harq->tb, harq->tb_size));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_DOWNLINK;
mac_pkt.rnti_type = map_nr_rnti_type(NR_RNTI_C);
mac_pkt.rnti = ra->rnti;
mac_pkt.harq_pid = current_harq_pid;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_DL_PDU", frameP, slotP, mac_pkt, (uint8_t *)harq->tb, (int)harq->tb_size);
// DL TX request
nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
memcpy(tx_req->TLVs[0].value.direct, harq->tb, sizeof(uint8_t) * harq->tb_size);
......
......@@ -170,6 +170,15 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
frameP,
CC_id,
mib_sdu_length);
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIRECTION_DOWNLINK;
mac_pkt.rnti_type = WS_NO_RNTI;
mac_pkt.rnti = 0xFFFF;
mac_pkt.harq_pid = 0;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_DL_PDU", frameP, slotP, mac_pkt, (uint8_t *)&cc->MIB_pdu.payload[0], (int)mib_sdu_length);
}
int8_t ssb_period = *scc->ssb_periodicityServingCell;
......@@ -657,6 +666,14 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(SI_RNTI),
T_INT(frameP), T_INT(slotP), T_INT(0), T_BUFFER(sib1_payload, sib1_sdu_length));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_DOWNLINK;
mac_pkt.rnti_type = map_nr_rnti_type(NR_RNTI_SI);
mac_pkt.rnti = SI_RNTI;
mac_pkt.harq_pid = 0;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_DL_PDU", frameP, slotP, mac_pkt, (uint8_t *)sib1_payload, (int)sib1_sdu_length);
}
}
}
......@@ -30,6 +30,7 @@
*/
#include "common/utils/nr/nr_common.h"
#include "UTIL/OPT/opt.h"
/*MAC*/
#include "NR_MAC_COMMON/nr_mac.h"
#include "NR_MAC_gNB/nr_mac_gNB.h"
......@@ -1321,6 +1322,16 @@ void nr_schedule_ue_spec(module_id_t module_id,
T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->tb, TBS));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_DOWNLINK;
mac_pkt.rnti_type = map_nr_rnti_type(rnti_type);
mac_pkt.rnti = rnti;
mac_pkt.harq_pid = current_harq_pid;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_RETRANSMISSION_DL_PDU", frame, slot, mac_pkt, (uint8_t *)harq->tb, (int)TBS);
} else { /* initial transmission */
LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot);
......@@ -1456,6 +1467,15 @@ void nr_schedule_ue_spec(module_id_t module_id,
T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(harq->tb, TBS));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_DOWNLINK;
mac_pkt.rnti_type = map_nr_rnti_type(rnti_type);
mac_pkt.rnti = rnti;
mac_pkt.harq_pid = current_harq_pid;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_DL_PDU", frame, slot, mac_pkt, (uint8_t *)harq->tb, (int)TBS);
}
const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs;
......
......@@ -676,11 +676,21 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id];
const int8_t harq_pid = UE_scheduling_control->feedback_ul_harq.head;
if (sduP)
if (sduP) {
T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP),
T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(harq_pid),
T_BUFFER(sduP, sdu_lenP));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_UPLINK;
mac_pkt.rnti_type = map_nr_rnti_type(NR_RNTI_C);
mac_pkt.rnti = current_rnti;
mac_pkt.harq_pid = harq_pid;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_UL_PDU", frameP, slotP, mac_pkt, (uint8_t *)sduP, (int)sdu_lenP);
}
UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP;
LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p, rssi %d\n",
gnb_mod_idP,
......@@ -770,6 +780,15 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */,
T_BUFFER(sduP, sdu_lenP));
// Trace MACPDU
mac_pkt_info_t mac_pkt;
mac_pkt.direction = DIR_UPLINK;
mac_pkt.rnti_type = map_nr_rnti_type(NR_RNTI_TC);
mac_pkt.rnti = rntiP;
mac_pkt.harq_pid = -1;
mac_pkt.preamble = -1; /* TODO */
LOG_MAC_P(OAILOG_INFO, "MAC_UL_PDU", frameP, slotP, mac_pkt, (uint8_t *)sduP, (int)sdu_lenP);
/* we don't know this UE (yet). Check whether there is a ongoing RA (Msg 3)
* and check the corresponding UE's RNTI match, in which case we activate
* it. */
......
......@@ -60,6 +60,7 @@ typedef uint32_t guint32;
typedef guint8 gboolean;
#include <openair2/UTIL/OPT/wireshark_headers.h>
#include <openair2/LAYER2/NR_MAC_COMMON/nr_mac.h>
#include "mac_pcap.h"
......@@ -121,4 +122,33 @@ void terminate_opt(void);
//double *timing_analyzer(int index, int direction );
/* In Wireshark, only these RNTI Types are support today */
static inline int map_nr_rnti_type(nr_rnti_type_t r_type)
{
switch(r_type) {
case NR_RNTI_C:
return WS_C_RNTI;
case NR_RNTI_RA:
return WS_RA_RNTI;
case NR_RNTI_P:
return WS_P_RNTI;
case NR_RNTI_CS:
return WS_CS_RNTI;
case NR_RNTI_SI:
return WS_SI_RNTI;
case NR_RNTI_new:
return WS_NO_RNTI;
case NR_RNTI_TC:
case NR_RNTI_SP_CSI:
case NR_RNTI_SFI:
case NR_RNTI_INT:
case NR_RNTI_TPC_PUSCH:
case NR_RNTI_TPC_PUCCH:
case NR_RNTI_TPC_SRS:
case NR_RNTI_MCS_C:
return WS_NO_RNTI;
}
}
#endif /* OPT_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment