From b8a86fecfdaf89f6789b2098e8c8d2ea3ca62b40 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 21 Jun 2024 16:57:49 +0200 Subject: [PATCH 01/61] fix for regressions in prach scheduling functions at MAC UE in presence of multiple SSBs --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 63 +++++++++++++++------ 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 29b36d3e9d..66dffd2c9d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1597,7 +1597,6 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) uint8_t prach_conf_start_symbol; // Starting symbol of the PRACH occasions in the PRACH slot uint8_t N_t_slot; // Number of PRACH occasions in a 14-symbols PRACH slot uint8_t N_dur; // Duration of a PRACH occasion (nb of symbols) - uint8_t frame; // Maximum is NB_FRAMES_IN_MAX_ASSOCIATION_PATTERN_PERIOD uint16_t format = 0xffff; uint8_t format2 = 0xff; int nb_fdm; @@ -1708,11 +1707,11 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) // For every frames in a PRACH configuration period // ------------------------------------------------ for (int frame_idx = 0; frame_idx < nb_of_frames_per_prach_conf_period; frame_idx++) { - frame = (period_idx * nb_of_frames_per_prach_conf_period) + frame_idx; + int frame_rach = (period_idx * nb_of_frames_per_prach_conf_period) + frame_idx; - LOG_D(NR_MAC,"PRACH Conf Period Frame Idx %d - Frame %d\n", frame_idx, frame); + LOG_D(NR_MAC,"PRACH Conf Period Frame Idx %d - Frame %d\n", frame_idx, frame_rach); // Is it a valid frame for this PRACH configuration index? (n_sfn mod x = y) - if ((frame%x)==y || (frame%x)==y2) { + if ((frame_rach % x) == y || (frame_rach % x) == y2) { // For every slot in a frame // ------------------------- @@ -1742,13 +1741,19 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) slot_map->prach_occasion[n_prach_occ_in_time * nb_fdm + n_prach_occ_in_freq] = (prach_occasion_info_t){.start_symbol = start_symbol, .fdm = n_prach_occ_in_freq, - .frame = frame, + .frame = frame_idx, .slot = slot, .format = format}; prach_assoc_pattern->prach_conf_period_list[period_idx].nb_of_prach_occasion++; - LOG_D(NR_MAC,"Adding a PRACH occasion: frame %u, slot-symbol %d-%d, occ_in_time-occ_in-freq %d-%d, nb ROs in conf period %d, for this slot: RO# in time %d, RO# in freq %d\n", - frame, slot, start_symbol, n_prach_occ_in_time, n_prach_occ_in_freq, prach_conf_period_list->nb_of_prach_occasion, + LOG_D(NR_MAC, + "Adding a PRACH occasion: frame %u, slot-symbol %d-%d, occ_in_time-occ_in-freq %d-%d, nb ROs in conf period %d, for this slot: RO# in time %d, RO# in freq %d\n", + frame_rach, + slot, + start_symbol, + n_prach_occ_in_time, + n_prach_occ_in_freq, + prach_conf_period_list->nb_of_prach_occasion, slot_map->nb_of_prach_occasion_in_time, slot_map->nb_of_prach_occasion_in_freq); } // For every freq in the slot @@ -1871,6 +1876,7 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // Map all the association periods within the association pattern period LOG_D(NR_MAC,"Proceed to the SSB to RO mapping\n"); // Check if we need to map multiple SSBs per RO or multiple ROs per SSB + if (multiple_ssb_per_ro) { const prach_association_period_t *end = prach_assoc_pattern->prach_association_period_list + prach_assoc_pattern->nb_of_assoc_period; @@ -1933,13 +1939,17 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) } } } else { + int frame = 0; + int slot = 0; + int ro_in_time = 0; + int ro_in_freq = 0; prach_association_period_t *end = prach_assoc_pattern->prach_association_period_list + prach_assoc_pattern->nb_of_assoc_period; for (prach_association_period_t *prach_period = prach_assoc_pattern->prach_association_period_list; prach_period < end; prach_period++) { // Go through the list of transmitted SSBs for (int idx = 0; idx < ssb_list->nb_tx_ssb; idx++) { ssb_info_t *tx_ssb = ssb_list->tx_ssb + idx; - uint8_t nb_mapped_ro_in_association_period=0; // Reset the nb of mapped ROs for the new SSB index + uint8_t nb_mapped_ro_in_association_period = 0; // Reset the nb of mapped ROs for the new SSB index bool done = false; // Map all the required ROs to this SSB // Go through the list of PRACH config periods within this association period @@ -1947,11 +1957,11 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // Build the association period with its association PRACH Configuration indexes prach_period->prach_conf_period_list[i] = &prach_assoc_pattern->prach_conf_period_list[prach_configuration_period_idx]; prach_conf_period_t *prach_conf = prach_period->prach_conf_period_list[i]; - for (int frame = 0; frame < prach_conf->nb_of_frame && !done; frame++) { - for (int slot = 0; slot < prach_conf->nb_of_slot && !done; slot++) { + for (; frame < prach_conf->nb_of_frame; frame++) { + for (; slot < prach_conf->nb_of_slot; slot++) { prach_occasion_slot_t *slot_map = &prach_conf->prach_occasion_slot_map[frame][slot]; - for (int ro_in_time = 0; ro_in_time < slot_map->nb_of_prach_occasion_in_time && !done; ro_in_time++) { - for (int ro_in_freq = 0; ro_in_freq < slot_map->nb_of_prach_occasion_in_freq && !done; ro_in_freq++) { + for (; ro_in_time < slot_map->nb_of_prach_occasion_in_time; ro_in_time++) { + for (; ro_in_freq < slot_map->nb_of_prach_occasion_in_freq; ro_in_freq++) { prach_occasion_info_t *ro_p = slot_map->prach_occasion + ro_in_time * slot_map->nb_of_prach_occasion_in_freq + ro_in_freq; int ssb_idx = get_ssb_idx_from_list(ssb_list, idx); @@ -1963,14 +1973,15 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) tx_ssb->mapped_ro[tx_ssb->nb_mapped_ro] = ro_p; tx_ssb->nb_mapped_ro++; nb_mapped_ro_in_association_period++; - done = nb_mapped_ro_in_association_period == ssb_rach_ratio; LOG_D(NR_MAC, - "Mapped ssb_idx %u to RO slot-symbol %u-%u, %u-%u-%u/%u\n" + "Mapped ssb_idx %u to RO slot-symbol %u-%u-%u, %u-%u-%u-%u/%u\n" "Nb mapped ROs for this ssb idx: in the association period only %u / total %u\n", ssb_idx, + ro_p->frame, ro_p->slot, ro_p->start_symbol, + frame, slot, ro_in_time, ro_in_freq, @@ -1982,10 +1993,30 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) // WIP: Assuming that ssb_rach_ratio equals the maximum nb of times a given ssb_idx is mapped within an // association period: // this is true if no PRACH occasions are conflicting with SSBs nor TDD_UL_DL_ConfigurationCommon schedule + if (nb_mapped_ro_in_association_period == ssb_rach_ratio) { + ro_in_freq++; + break; + } } + if (nb_mapped_ro_in_association_period == ssb_rach_ratio) + break; + else + ro_in_freq = 0; } + if (nb_mapped_ro_in_association_period == ssb_rach_ratio) + break; + else + ro_in_time = 0; } + if (nb_mapped_ro_in_association_period == ssb_rach_ratio) + break; + else + slot = 0; } + if (nb_mapped_ro_in_association_period == ssb_rach_ratio) + break; + else + frame = 0; } } } @@ -2036,8 +2067,8 @@ static int get_nr_prach_info_from_ssb_index(prach_association_pattern_t *prach_a // First count the number of times the SSB index is found in that RO uint8_t nb_mapped_ssb = 0; - for (int ro_in_time=0; ro_in_time < prach_occasion_slot_p->nb_of_prach_occasion_in_time; ro_in_time++) { - for (int ro_in_freq=0; ro_in_freq < prach_occasion_slot_p->nb_of_prach_occasion_in_freq; ro_in_freq++) { + for (int ro_in_time = 0; ro_in_time < prach_occasion_slot_p->nb_of_prach_occasion_in_time; ro_in_time++) { + for (int ro_in_freq = 0; ro_in_freq < prach_occasion_slot_p->nb_of_prach_occasion_in_freq; ro_in_freq++) { prach_occasion_info_t *ro_p = prach_occasion_slot_p->prach_occasion + ro_in_time * prach_occasion_slot_p->nb_of_prach_occasion_in_freq + ro_in_freq; for (uint8_t ssb_nb = 0; ssb_nb < ro_p->nb_mapped_ssb; ssb_nb++) { From e5900e0757341bd8d1ec46a02543a6a83cb6e7d8 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 4 Jul 2024 13:51:34 +0200 Subject: [PATCH 02/61] replacing assertions with LOG_E in UL locking mechanism --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 20b0e80f61..c9f1656fb3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -81,7 +81,10 @@ fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_ NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; // Check if requested on the right slot - AssertFatal(is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type) != 0, "UL config_request called at wrong slot %d\n", slot_tx); + if (!is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type)) { + LOG_E(NR_MAC, "Lock of UL config for PDU type %d called for slot %d which is not UL\n", pdu_type, slot_tx); + return NULL; + } AssertFatal(mac->ul_config_request != NULL, "mac->ul_config_request not initialized, logic bug\n"); fapi_nr_ul_config_request_t *ul_config = mac->ul_config_request + slot_tx; @@ -220,7 +223,10 @@ fapi_nr_ul_config_request_pdu_t *lockGet_ul_iterator(NR_UE_MAC_INST_t *mac, fram { NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; //Check if requested on the right slot - AssertFatal(is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type) != 0, "UL config_request called at wrong slot %d\n", slot_tx); + if (!is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type)) { + LOG_E(NR_MAC, "UL lock iterator called for slot %d which is not UL\n", slot_tx); + return NULL; + } AssertFatal(mac->ul_config_request != NULL, "mac->ul_config_request not initialized, logic bug\n"); return fapiLockIterator(mac->ul_config_request + slot_tx, frame_tx, slot_tx); } From ed05c94c3e741f1e232523eccccf8ee1eaf2add7 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Tue, 30 Jul 2024 07:01:48 +0200 Subject: [PATCH 03/61] Fix signal_energy_nodc for lengths that are not multiples of 4 --- openair1/PHY/CMakeLists.txt | 7 +- .../PHY/LTE_ESTIMATION/lte_eNB_measurements.c | 18 ++--- .../PHY/LTE_ESTIMATION/lte_ue_measurements.c | 12 +-- .../PHY/LTE_TRANSPORT/ulsch_demodulation.c | 2 +- .../PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 6 +- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 6 +- .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 2 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 4 +- .../PHY/NR_UE_ESTIMATION/nr_ue_measurements.c | 2 +- openair1/PHY/TOOLS/CMakeLists.txt | 58 ++++++++------ openair1/PHY/TOOLS/signal_energy.c | 77 +++++-------------- openair1/PHY/TOOLS/tests/CMakeLists.txt | 5 ++ .../PHY/TOOLS/tests/test_signal_energy.cpp | 31 ++++++++ openair1/PHY/TOOLS/tools_defs.h | 2 +- openair1/SCHED/ru_procedures.c | 2 +- openair1/SCHED_NR/nr_ru_procedures.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 +- 17 files changed, 121 insertions(+), 119 deletions(-) create mode 100644 openair1/PHY/TOOLS/tests/CMakeLists.txt create mode 100644 openair1/PHY/TOOLS/tests/test_signal_energy.cpp diff --git a/openair1/PHY/CMakeLists.txt b/openair1/PHY/CMakeLists.txt index 6f364e4daf..b841d00601 100644 --- a/openair1/PHY/CMakeLists.txt +++ b/openair1/PHY/CMakeLists.txt @@ -1,7 +1,2 @@ -add_boolean_option(ENABLE_UESCOPE OFF "Whether to build the lte uescope" OFF) -add_boolean_option(ENABLE_ENBSCOPE OFF "Whether to build the lte enbcope" OFF) -add_boolean_option(ENABLE_NRSCOPE OFF "Whether to build the 5G scope" OFF) -if(ENABLE_UESCOPE OR ENABLE_ENBSCOPE OR ENABLE_NRSCOPE) - add_subdirectory(TOOLS) -endif() add_subdirectory(nr_phy_common) +add_subdirectory(TOOLS) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 9393bfc048..db6bdff2cd 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -69,7 +69,7 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB, uint32_t aarx /* ,rx_power_correction */; uint32_t rb; - int32_t *ul_ch; + c16_t *ul_ch; int32_t n0_power_tot; int64_t n0_power_tot2; int len; @@ -112,9 +112,9 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB, for (aarx=0; aarxnb_antennas_rx; aarx++) { measurements->n0_subband_power[aarx][rb] = 0; for (int s=0;s<(14-(frame_parms->Ncp<<1));s++) { - offset = offset0 + (s*frame_parms->ofdm_symbol_size); - ul_ch = &common_vars->rxdataF[aarx][offset]; - len = 12; + offset = offset0 + (s*frame_parms->ofdm_symbol_size); + ul_ch = (c16_t *)&common_vars->rxdataF[aarx][offset]; + len = 12; // just do first half of middle PRB for odd number of PRBs if (((frame_parms->N_RB_UL&1) == 1) && (rb==(frame_parms->N_RB_UL>>1))) { @@ -154,7 +154,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, int32_t aarx,rx_power_correction; int32_t rx_power; uint32_t rb; - int32_t *ul_ch; + c16_t *ul_ch; //printf("Running eNB_srs_measurements for eNB_id %d\n",eNB_id); @@ -176,9 +176,9 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, measurements->rx_spatial_power[srs_id][0][aarx] = - ((signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset], + ((signal_energy_nodc((c16_t*)&srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset], (frame_parms->N_RB_DL*6)) + - signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][1], + signal_energy_nodc((c16_t*)&srs_vars->srs_ch_estimates[aarx][1], (frame_parms->N_RB_DL*6)))*rx_power_correction) - measurements->n0_power[aarx]; @@ -219,9 +219,9 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, // printf("common_vars->srs_ch_estimates[0] => %x\n",common_vars->srs_ch_estimates[0]); if (rb < 12) - ul_ch = &srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset + (rb*12)]; + ul_ch = (c16_t *)&srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset + (rb * 12)]; else if (rb>12) - ul_ch = &srs_vars->srs_ch_estimates[aarx][6 + (rb-13)*12]; + ul_ch = (c16_t *)&srs_vars->srs_ch_estimates[aarx][6 + (rb - 13) * 12]; else { measurements->subband_cqi_dB[srs_id][aarx][rb] = 0; continue; diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index 453b8a3e79..c9ec2449e1 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -1062,7 +1062,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue, for (aarx=0; aarxnb_antennas_rx; aarx++) { for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) { ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = - (signal_energy_nodc(&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], + (signal_energy_nodc((c16_t*)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], (N_RB_DL*12))); //- ue->measurements.n0_power[aarx]; @@ -1169,7 +1169,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue, msg("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); */ ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,subband_size) + signal_energy_nodc(dl_ch1,subband_size)); + (signal_energy_nodc((c16_t*)dl_ch0,subband_size) + signal_energy_nodc((c16_t*)dl_ch1,subband_size)); if ( ue->measurements.subband_cqi[eNB_id][aarx][subband] < 0) ue->measurements.subband_cqi[eNB_id][aarx][subband]=0; @@ -1185,8 +1185,8 @@ void lte_ue_measurements(PHY_VARS_UE *ue, } else { // this is for the last subband which is smaller in size // for (i=0;i<12;i++) // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,last_subband_size) + - signal_energy_nodc(dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc((c16_t*)dl_ch0,last_subband_size) + + signal_energy_nodc((c16_t*)dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], ue->measurements.n0_power[aarx]); @@ -1297,7 +1297,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue, // for (i=0;i<48;i++) // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,48) ) - ue->measurements.n0_power[aarx]; + (signal_energy_nodc((c16_t*)dl_ch0,48) ) - ue->measurements.n0_power[aarx]; ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], @@ -1305,7 +1305,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue, } else { // for (i=0;i<12;i++) // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,12) ) - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc((c16_t*)dl_ch0,12) ) - ue->measurements.n0_power[aarx]; ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], ue->measurements.n0_power[aarx]); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 33425766ab..897f4b1371 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -843,7 +843,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, } for (i=0; inb_antennas_rx; i++) { - pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[i], + pusch_vars->ulsch_power[i] = signal_energy_nodc((c16_t*)pusch_vars->drs_ch_estimates[i], ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor; LOG_D(PHY,"%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_x10(pusch_vars->ulsch_power[i])); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index 2e29fd41d1..b9ba9347cf 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -1955,7 +1955,7 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, } Nre = (pilots==0) ? 12 : 8; - precoded_signal_strength += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre], + precoded_signal_strength += ((signal_energy_nodc((c16_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre], (nb_rb*Nre))) - (measurements->n0_power[aarx])); } // rx_antennas @@ -2349,9 +2349,9 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, } // rb loop Nre = (pilots==0) ? 12 : 8; - precoded_signal_strength0 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre], + precoded_signal_strength0 += ((signal_energy_nodc((c16_t*)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*Nre], (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx])); - precoded_signal_strength1 += ((signal_energy_nodc(&dl_ch_estimates_ext[aarx+2][symbol*frame_parms->N_RB_DL*Nre], + precoded_signal_strength1 += ((signal_energy_nodc((c16_t*)&dl_ch_estimates_ext[aarx+2][symbol*frame_parms->N_RB_DL*Nre], (nb_rb*Nre))*rx_power_correction) - (measurements->n0_power[aarx])); } // rx_antennas diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index a45734e791..e36471c25d 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -143,12 +143,12 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_sy int offset = offset0 + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; nb_symb[rb]++; for (int aarx=0; aarxnb_antennas_rx; aarx++) { - int32_t *ul_ch = (int32_t *)&common_vars->rxdataF[aarx][offset]; + c16_t *ul_ch = &common_vars->rxdataF[aarx][offset]; int32_t signal_energy; if (((frame_parms->N_RB_UL&1) == 1) && (rb==(frame_parms->N_RB_UL>>1))) { signal_energy = signal_energy_nodc(ul_ch, 6); - ul_ch = (int32_t *)&common_vars->rxdataF[aarx][offset0]; + ul_ch = &common_vars->rxdataF[aarx][offset0]; signal_energy += signal_energy_nodc(ul_ch, 6); } else { signal_energy = signal_energy_nodc(ul_ch, 12); @@ -229,7 +229,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, for (int aatx = 0; aatx < nrOfLayers; aatx++){ rx_spatial_power[aatx][aarx] = - (signal_energy_nodc(&pusch_vars->ul_ch_estimates[aatx * fp->nb_antennas_rx + aarx][ch_offset], + (signal_energy_nodc((c16_t*)&pusch_vars->ul_ch_estimates[aatx * fp->nb_antennas_rx + aarx][ch_offset], N_RB_UL * NR_NB_SC_PER_RB)); if (rx_spatial_power[aatx][aarx] < 0) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 96266e279a..2d33e0f55b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -1522,7 +1522,7 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, } for (int aatx = 0; aatx < rel15_ul->nrOfLayers; aatx++) { pusch_vars->ulsch_power[aarx] += signal_energy_nodc( - &pusch_vars->ul_ch_estimates[aatx * gNB->frame_parms.nb_antennas_rx + aarx][symbol * frame_parms->ofdm_symbol_size], + (c16_t*)&pusch_vars->ul_ch_estimates[aatx * gNB->frame_parms.nb_antennas_rx + aarx][symbol * frame_parms->ofdm_symbol_size], rel15_ul->rb_size * 12); } for (int rb = 0; rb < rel15_ul->rb_size; rb++) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 05d7f03832..412edf9d35 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -266,7 +266,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, printf("x (%d,%d), xr (%ld,%ld)\n", x_re[l][n], x_im[l][n], xr[aa][l][n].r, xr[aa][l][n].i); #endif } - int energ = signal_energy_nodc((int32_t *)rp, nb_re_pucch); + int energ = signal_energy_nodc(rp, nb_re_pucch); signal_energy += energ; if (aa == 0) signal_energy_ant0 += energ; @@ -1629,7 +1629,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uci_pdu->pucch_format=0; uci_pdu->ul_cqi=cqi; uci_pdu->timing_advance=0xffff; // currently not valid - uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc((int32_t *)&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size))); + uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size))); if (pucch_pdu->bit_len_harq>0) { int harq_bytes=pucch_pdu->bit_len_harq>>3; if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 30ff7a2f9b..28d8062588 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -113,7 +113,7 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, ue->measurements.rx_power[gNB_id][aarx] = 0; for (aatx = 0; aatx < frame_parms->nb_antenna_ports_gNB; aatx++){ - const int z=signal_energy_nodc(&dl_ch_estimates[gNB_id][ch_offset], N_RB_DL * NR_NB_SC_PER_RB); + const int z=signal_energy_nodc((c16_t*)&dl_ch_estimates[gNB_id][ch_offset], N_RB_DL * NR_NB_SC_PER_RB); rx_spatial_power[gNB_id][aatx][aarx] = z; if (rx_spatial_power[gNB_id][aatx][aarx] < 0) diff --git a/openair1/PHY/TOOLS/CMakeLists.txt b/openair1/PHY/TOOLS/CMakeLists.txt index 8acd528617..93ef4f5cc7 100644 --- a/openair1/PHY/TOOLS/CMakeLists.txt +++ b/openair1/PHY/TOOLS/CMakeLists.txt @@ -29,29 +29,37 @@ #* \warning #*/ -find_library(forms NAMES forms) -if(NOT forms) - message(FATAL_ERROR "required library forms not found for building scopes") -else() - message(STATUS "libforms library, required for scopes, found at ${forms}") +add_boolean_option(ENABLE_UESCOPE OFF "Whether to build the lte uescope" OFF) +add_boolean_option(ENABLE_ENBSCOPE OFF "Whether to build the lte enbcope" OFF) +add_boolean_option(ENABLE_NRSCOPE OFF "Whether to build the 5G scope" OFF) +if(ENABLE_UESCOPE OR ENABLE_ENBSCOPE OR ENABLE_NRSCOPE) + find_library(forms NAMES forms) + if(NOT forms) + message(FATAL_ERROR "required library forms not found for building scopes") + else() + message(STATUS "libforms library, required for scopes, found at ${forms}") + endif() + + include_directories ("/usr/include/X11") + add_library(xforms_common OBJECT + lte_phy_scope.c + ../../../executables/stats.c) + target_link_libraries(xforms_common PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) + + add_library(enbscope MODULE lte_enb_scope.c $) + target_link_libraries(enbscope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) + + add_library(uescope MODULE lte_ue_scope.c $) + target_link_libraries(uescope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) + + add_library(nrscope MODULE nr_phy_scope.c) + target_link_libraries(nrscope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) + + # all libraries should be written to root build dir (default creates the same hierarchie under build as existing for sources) + set_target_properties(enbscope uescope nrscope + PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../../.. + ) +endif() +if (ENABLE_TESTS) + add_subdirectory(tests) endif() - -include_directories ("/usr/include/X11") -add_library(xforms_common OBJECT - lte_phy_scope.c - ../../../executables/stats.c) -target_link_libraries(xforms_common PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) - -add_library(enbscope MODULE lte_enb_scope.c $) -target_link_libraries(enbscope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) - -add_library(uescope MODULE lte_ue_scope.c $) -target_link_libraries(uescope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) - -add_library(nrscope MODULE nr_phy_scope.c) -target_link_libraries(nrscope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) - -# all libraries should be written to root build dir (default creates the same hierarchie under build as existing for sources) -set_target_properties(enbscope uescope nrscope - PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../../.. -) diff --git a/openair1/PHY/TOOLS/signal_energy.c b/openair1/PHY/TOOLS/signal_energy.c index 3f2b9a456d..affee5dac4 100644 --- a/openair1/PHY/TOOLS/signal_energy.c +++ b/openair1/PHY/TOOLS/signal_energy.c @@ -112,30 +112,32 @@ int32_t signal_energy_amp_shift(int32_t *input,uint32_t length) return((temp>0)?temp:1); } -int32_t signal_energy_nodc(int32_t *input,uint32_t length) +int32_t signal_energy_nodc(const c16_t *input, uint32_t length) { - int32_t i; - int32_t temp; + // init + simde__m128 mm0 = simde_mm_setzero_ps(); - simde__m128i in; - simde__m128 mm0; - -//init - mm0 = simde_mm_setzero_ps(); -//Acc - for (i=0; i<(length>>2); i++) { - in = simde_mm_loadu_si128((simde__m128i *)input); - mm0 = simde_mm_add_ps(mm0,simde_mm_cvtepi32_ps(simde_mm_madd_epi16(in,in))); + // Acc + for (int32_t i = 0; i < (length >> 2); i++) { + simde__m128i in = simde_mm_loadu_si128((simde__m128i *)input); + mm0 = simde_mm_add_ps(mm0, simde_mm_cvtepi32_ps(simde_mm_madd_epi16(in, in))); input += 4; } - //Ave - temp = (int)((((float*)&mm0)[0] + - ((float*)&mm0)[1] + - ((float*)&mm0)[2] + - ((float*)&mm0)[3])/(float)length); - return temp; + // leftover + float leftover_sum = 0; + c16_t *leftover_input = (c16_t *)input; + uint16_t lefover_count = length - ((length >> 2) << 2); + for (int32_t i = 0; i < lefover_count; i++) { + leftover_sum += leftover_input[i].r * leftover_input[i].r + leftover_input[i].i * leftover_input[i].i; + } + + // Ave + float sums[4]; + simde_mm_store_ps(sums, mm0); + return (int)((sums[0] + sums[1] + sums[2] + sums[3] + leftover_sum) / (float)length); } + double signal_energy_fp(double *s_re[2],double *s_im[2],uint32_t nb_antennas,uint32_t length,uint32_t offset) { @@ -164,45 +166,6 @@ double signal_energy_fp2(struct complexd *s,uint32_t length) } return(V/length); } - // -#ifdef MAIN -#define LENGTH 256 -#include -#include -#include -#include -main(int argc,char **argv) -{ - - int input[LENGTH]; - int energy=0,dc_r=0,dc_i=0; - int16_t s=1,i; - int amp; - - amp = atoi(argv[1]);// arguments to integer - - if (argc>1) - printf("Amp = %d\n",amp); - - for (i=0; i +extern "C" { +#include "openair1/PHY/TOOLS/tools_defs.h" +extern int32_t signal_energy_nodc(const c16_t *input, uint32_t length); +} +#include +#include + +int32_t signal_energy_nodc_ref(const c16_t *input, uint32_t length) +{ + float sum = 0; + for (auto i = 0U; i < length; i++) { + sum += input[i].r * input[i].r + input[i].i * input[i].i; + } + return sum / length; +} + +TEST(signal_energy_nodc, size_6) +{ + std::vector input; + input.resize(6); + std::fill(input.begin(), input.end(), (c16_t){42, 42}); + EXPECT_EQ(signal_energy_nodc(input.data(), input.size()), + signal_energy_nodc_ref(input.data(), input.size())); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h index 771f488b54..c6926ff752 100644 --- a/openair1/PHY/TOOLS/tools_defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -761,7 +761,7 @@ int32_t subcarrier_energy(int32_t *,uint32_t, int32_t *subcarrier_energy, uint16 /*!\fn int32_t signal_energy_nodc(int32_t *,uint32_t); \brief Computes the signal energy per subcarrier, without DC removal */ -int32_t signal_energy_nodc(int32_t *,uint32_t); +int32_t signal_energy_nodc(const c16_t *input, uint32_t length); int32_t signal_power(int32_t *,uint32_t); int32_t interference_power(int32_t *,uint32_t); diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index fdeb58ead1..96e32c6444 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -444,7 +444,7 @@ void feptx_ofdm(RU_t *ru, stop_meas(&ru->ofdm_mod_stats); LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, subframe %d: txp (time %p) %d dB, txp (freq) %d dB\n", frame,subframe,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_tti)), - dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); + dB_fixed(signal_energy_nodc((c16_t*)ru->common.txdataF_BF[aa],2*slot_sizeF))); } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+ru->idx , 0 ); diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 93619732ae..16a06c6e97 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -166,7 +166,7 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) { LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %p) %d dB, txp (freq) %d dB\n", frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->get_samples_per_slot( - slot,fp))),dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); + slot,fp))),dB_fixed(signal_energy_nodc((c16_t*)ru->common.txdataF_BF[aa],2*slot_sizeF))); } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index a12d203ae7..15ae40fac2 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -746,7 +746,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) "frame %d, slot %d: UL signal energy %d\n", frame_rx, slot_rx, - signal_energy_nodc((int32_t *)&gNB->common_vars.rxdataF[0][soffset + offset + (47 * 12)], 12 * 18)); + signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset + (47 * 12)], 12 * 18)); start_meas(&gNB->phy_proc_rx); @@ -778,7 +778,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) "frame %d, slot %d: PUCCH signal energy %d\n", frame_rx, slot_rx, - signal_energy_nodc((int32_t *)&gNB->common_vars.rxdataF[0][soffset + offset], 12)); + signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset], 12)); nr_decode_pucch0(gNB, frame_rx, From 77af1ab97b46548551d49c15ed4f6a036ba7ce33 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 30 Jul 2024 17:37:17 +0200 Subject: [PATCH 04/61] nr rlc: fix decode_poll_byte() The returned value was 1024 times too big. --- openair2/LAYER2/nr_rlc/asn1_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/nr_rlc/asn1_utils.c b/openair2/LAYER2/nr_rlc/asn1_utils.c index 999cb79a52..fd64d89481 100644 --- a/openair2/LAYER2/nr_rlc/asn1_utils.c +++ b/openair2/LAYER2/nr_rlc/asn1_utils.c @@ -135,7 +135,7 @@ int decode_poll_byte(int v) } if (tab[v] == -1) return -1; - return tab[v] * 1024; + return tab[v]; } int decode_max_retx_threshold(int v) From b242a483f10998993bf09460bd1d3544c36f95ca Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Mon, 1 Jul 2024 10:01:55 +0200 Subject: [PATCH 05/61] Rewrite NR UE PHY cpu measurements --- CMakeLists.txt | 6 +- .../telnetsrv/telnetsrv_5Gue_measurements.c | 10 +- .../utils/telnetsrv/telnetsrv_cpumeasur_def.h | 47 --------- executables/nr-ue.c | 19 ++-- executables/nr-uesoftmodem.c | 1 + openair1/PHY/MODULATION/slot_fep_nr.c | 6 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 6 +- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 48 +++++----- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 20 ++-- openair1/PHY/defs_nr_UE.h | 61 +++--------- openair1/PHY/nr_phy_common/CMakeLists.txt | 4 + .../PHY/nr_phy_common/inc/nr_ue_phy_meas.h | 66 +++++++++++++ .../PHY/nr_phy_common/src/nr_ue_phy_meas.c | 40 ++++++++ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 96 +++++++------------ openair1/SIMULATION/LTE_PHY/common_sim.h | 10 +- openair1/SIMULATION/NR_PHY/dlsim.c | 35 +------ openair1/SIMULATION/NR_PHY/ulsim.c | 13 +-- 17 files changed, 228 insertions(+), 260 deletions(-) create mode 100644 openair1/PHY/nr_phy_common/inc/nr_ue_phy_meas.h create mode 100644 openair1/PHY/nr_phy_common/src/nr_ue_phy_meas.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 94c49f8922..b85faff905 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2124,7 +2124,7 @@ target_link_libraries(nr-uesoftmodem PRIVATE ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU SIMU_ETH shlib_loader -Wl,--end-group z dl) -target_link_libraries(nr-uesoftmodem PRIVATE pthread m CONFIG_LIB rt) +target_link_libraries(nr-uesoftmodem PRIVATE pthread m CONFIG_LIB rt nr_ue_phy_meas) target_link_libraries(nr-uesoftmodem PRIVATE ${T_LIB}) target_link_libraries(nr-uesoftmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -2256,7 +2256,7 @@ add_executable(nr_dlsim ) target_link_libraries(nr_dlsim PRIVATE -Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas ) target_link_libraries(nr_dlsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -2297,7 +2297,7 @@ endif() target_link_libraries(nr_ulsim PRIVATE -Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas ) target_link_libraries(nr_ulsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) diff --git a/common/utils/telnetsrv/telnetsrv_5Gue_measurements.c b/common/utils/telnetsrv/telnetsrv_5Gue_measurements.c index bdf508e6ef..82f791cd2a 100644 --- a/common/utils/telnetsrv/telnetsrv_5Gue_measurements.c +++ b/common/utils/telnetsrv/telnetsrv_5Gue_measurements.c @@ -86,7 +86,15 @@ int get_measurgroups(telnet_measurgroupdef_t **measurgroups) { void measurcmd_display_phycpu(telnet_printfunc_t prnt) { PHY_VARS_NR_UE *UE = PHY_vars_UE_g[0][0]; - telnet_cpumeasurdef_t cpumeasur[]=CPU_PHYNRUE_MEASURE; + telnet_cpumeasurdef_t cpumeasur[MAX_CPU_STAT_TYPE]; + for (int i = 0; i < MAX_CPU_STAT_TYPE; i++) { + sprintf(cpumeasur[i].statname, "%s", UE->phy_cpu_stats.cpu_time_stats[i].meas_name); + cpumeasur[i].astatptr = &UE->phy_cpu_stats.cpu_time_stats[i]; + cpumeasur[i].statemask = 0; + cpumeasur[i].num_occur1 = 1; + cpumeasur[i].num_occur2 = 0; + cpumeasur[i].num_occur3 = 0; + } prnt("%s cpu (%1.1g GHz) measurements: PHY (cpustats %s) %s\n",HDR,cpufreq, PRINT_CPUMEAS_STATE,HDR); measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t)); diff --git a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h index bbc9cb664d..896c42d08a 100644 --- a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h +++ b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h @@ -95,51 +95,4 @@ {"ip_pdcp", &(pdcpvars->ip_pdcp),0,1},\ } -/* from openair1/PHY/defs_nr_UE.h */ -#define CPU_PHYNRUE_MEASURE \ -{ \ - {"phy_proc", &(UE->phy_proc),0,1},\ - {"phy_proc_rx", &(UE-> phy_proc_rx),0,1},\ - {"phy_proc_tx", &(UE->phy_proc_tx),0,1},\ - {"ue_ul_indication_stats", &(UE->ue_ul_indication_stats),0,1},\ - {"ofdm_mod_stats", &(UE->ofdm_mod_stats),0,1},\ - {"ulsch_encoding_stats", &(UE->ulsch_encoding_stats),0,1},\ - {"ulsch_modulation_stats", &(UE->ulsch_modulation_stats),0,1},\ - {"ulsch_segmentation_stats", &(UE->ulsch_segmentation_stats),0,1},\ - {"ulsch_rate_matching_stats", &(UE->ulsch_rate_matching_stats),0,1},\ - {"ulsch_ldpc_encoding_stats", &(UE->ulsch_ldpc_encoding_stats),0,1},\ - {"ulsch_interleaving_stats", &(UE->ulsch_interleaving_stats),0,1},\ - {"ulsch_multiplexing_stats", &(UE->ulsch_multiplexing_stats),0,1},\ - {"ofdm_demod_stats", &(UE->ofdm_demod_stats),0,1},\ - {"dlsch_rx_pdcch_stats", &(UE->dlsch_rx_pdcch_stats),0,1},\ - {"rx_dft_stats", &(UE->rx_dft_stats),0,1},\ - {"dlsch_c...timation_stats", &(UE->dlsch_channel_estimation_stats),0,1},\ - {"dlsch_f...timation_stats", &(UE->dlsch_freq_offset_estimation_stats),0,1},\ - {"dlsch_demodulation_stats", &(UE->dlsch_demodulation_stats),0,1},\ - {"dlsch_rate_unmatching_stats", &(UE->dlsch_rate_unmatching_stats),0,1},\ - {"dlsch_ldpc_decoding_stats", &(UE->dlsch_ldpc_decoding_stats),0,1},\ - {"dlsch_deinterleaving_stats", &(UE->dlsch_deinterleaving_stats),0,1},\ - {"dlsch_llr_stats", &(UE->dlsch_llr_stats),0,1},\ - {"dlsch_unscrambling_stats", &(UE->dlsch_unscrambling_stats),0,1},\ - {"dlsch_rate_matching_stats", &(UE->dlsch_rate_matching_stats),0,1},\ - {"dlsch_ldpc_encoding_stats", &(UE->dlsch_ldpc_encoding_stats),0,1},\ - {"dlsch_interleaving_stats", &(UE->dlsch_interleaving_stats),0,1},\ - {"dlsch_tc_init_stats", &(UE->dlsch_tc_init_stats),0,1},\ - {"dlsch_tc_alpha_stats", &(UE->dlsch_tc_alpha_stats),0,1},\ - {"dlsch_tc_beta_stats", &(UE->dlsch_tc_beta_stats),0,1},\ - {"dlsch_tc_gamma_stats", &(UE->dlsch_tc_gamma_stats),0,1},\ - {"dlsch_tc_ext_stats", &(UE->dlsch_tc_ext_stats),0,1},\ - {"dlsch_tc_intl1_stats", &(UE->dlsch_tc_intl1_stats),0,1},\ - {"dlsch_tc_intl2_stats", &(UE->dlsch_tc_intl2_stats),0,1},\ - {"tx_prach", &(UE->tx_prach),0,1},\ - {"ue_front_end_stat", &(UE->ue_front_end_stat),0,1},\ - {"ue_front_end_per_slot_stat", &(UE->ue_front_end_per_slot_stat[0]),0,LTE_SLOTS_PER_SUBFRAME},\ - {"pdcch_procedures_stat", &(UE->pdcch_procedures_stat),0,1},\ - {"rx_pdsch_stats", &(UE->rx_pdsch_stats), 0, 1}, \ - {"pdsch_procedures_stat", &(UE->pdsch_procedures_stat),0,1},\ - {"pdsch_procedures_per_slot_stat", &(UE->pdsch_procedures_per_slot_stat[0]),0,LTE_SLOTS_PER_SUBFRAME},\ - {"dlsch_procedures_stat", &(UE->dlsch_procedures_stat),0,1},\ - {"dlsch_decoding_stats", &(UE->dlsch_decoding_stats),0,1},\ - {"dlsch_llr_stats_para", &(UE->dlsch_llr_stats_parallelization[0]),0,LTE_SLOTS_PER_SUBFRAME},\ -} #endif diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e3595f6cf8..d0f23437cc 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -100,17 +100,14 @@ static size_t dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, size_t max { const char *begin = output; const char *end = output + max_len; - output += print_meas_log(&ue->phy_proc_tx, "L1 TX processing", NULL, NULL, output, end - output); - output += print_meas_log(&ue->ulsch_encoding_stats, "ULSCH encoding", NULL, NULL, output, end - output); - output += print_meas_log(&ue->phy_proc_rx, "L1 RX processing", NULL, NULL, output, end - output); - output += print_meas_log(&ue->ue_ul_indication_stats, "UL Indication", NULL, NULL, output, end - output); - output += print_meas_log(&ue->rx_pdsch_stats, "PDSCH receiver", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_decoding_stats, "PDSCH decoding", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_deinterleaving_stats, " -> Deinterleive", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_rate_unmatching_stats, " -> Rate Unmatch", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_ldpc_decoding_stats, " -> LDPC Decode", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_unscrambling_stats, "PDSCH unscrambling", NULL, NULL, output, end - output); - output += print_meas_log(&ue->dlsch_rx_pdcch_stats, "PDCCH handling", NULL, NULL, output, end - output); + for (int i = 0; i < MAX_CPU_STAT_TYPE; i++) { + output += print_meas_log(&ue->phy_cpu_stats.cpu_time_stats[i], + ue->phy_cpu_stats.cpu_time_stats[i].meas_name, + NULL, + NULL, + output, + end - output); + } return output - begin; } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 105ffdbbaa..20fc4248bd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -503,6 +503,7 @@ int main(int argc, char **argv) set_options(CC_id, UE[CC_id]); NR_UE_MAC_INST_t *mac = get_mac_inst(inst); + init_nr_ue_phy_cpu_stats(&UE[CC_id]->phy_cpu_stats); if (get_softmodem_params()->sa || get_softmodem_params()->sl_mode) { // set frame config to initial values from command line // and assume that the SSB is centered on the grid diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index ffcd0b13ad..faee44cc9e 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -184,14 +184,12 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, rxdata_ptr = (int16_t *)tmp_dft_in; } - start_meas(&ue->rx_dft_stats); - + start_meas_nr_ue_phy(ue, RX_DFT_STATS); dft(dftsize, rxdata_ptr, (int16_t *)&rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], 1); - - stop_meas(&ue->rx_dft_stats); + stop_meas_nr_ue_phy(ue, RX_DFT_STATS); apply_nr_rotation_RX(frame_parms, rxdataF[aa], frame_parms->symbol_rotation[linktype], Ns, frame_parms->N_RB_DL, 0, symbol, 1); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 6c57130b3d..e295681ae0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -83,9 +83,9 @@ static bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, NR_UE_DLSCH_t *dlsch = (NR_UE_DLSCH_t *) rdata->dlsch; int r = rdata->segment_r; - merge_meas(&phy_vars_ue->dlsch_deinterleaving_stats, &rdata->ts_deinterleave); - merge_meas(&phy_vars_ue->dlsch_rate_unmatching_stats, &rdata->ts_rate_unmatch); - merge_meas(&phy_vars_ue->dlsch_ldpc_decoding_stats, &rdata->ts_ldpc_decode); + merge_meas(&phy_vars_ue->phy_cpu_stats.cpu_time_stats[DLSCH_DEINTERLEAVING_STATS], &rdata->ts_deinterleave); + merge_meas(&phy_vars_ue->phy_cpu_stats.cpu_time_stats[DLSCH_RATE_UNMATCHING_STATS], &rdata->ts_rate_unmatch); + merge_meas(&phy_vars_ue->phy_cpu_stats.cpu_time_stats[DLSCH_LDPC_DECODING_STATS], &rdata->ts_ldpc_decode); bool decodeSuccess = (rdata->decodeIterations < (1+dlsch->max_ldpc_iterations)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 7476309ad8..6537e4b840 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -438,12 +438,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //--------------------- RBs extraction --------------------- //---------------------------------------------------------- const int n_rx = frame_parms->nb_antennas_rx; - time_stats_t meas = {0}; const bool meas_enabled = cpumeas(CPUMEAS_GETSTATE); - if (meas_enabled) - start_meas(&meas); { + start_meas_nr_ue_phy(ue, DLSCH_EXTRACT_RBS_STATS); __attribute__((aligned(32))) c16_t rxdataF_ext[nbRx][rx_size_symbol]; memset(rxdataF_ext, 0, sizeof(rxdataF_ext)); @@ -469,15 +467,15 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch_config->dlDmrsSymbPos, csi_res_bitmap, ue->chest_time); + stop_meas_nr_ue_phy(ue, DLSCH_EXTRACT_RBS_STATS); if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Pilot/Data extraction %5.2f \n", frame, nr_slot_rx, slot, symbol, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_EXTRACT_RBS_STATS].p_time / (cpuf * 1000.0)); } if (ue->phy_sim_pdsch_rxdataF_ext) for (unsigned char aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { @@ -491,25 +489,23 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //---------------------------------------------------------- //--------------------- Channel Scaling -------------------- //---------------------------------------------------------- - if (meas_enabled) - start_meas(&meas); + start_meas_nr_ue_phy(ue, DLSCH_CHANNEL_SCALE_STATS); nr_dlsch_scale_channel(rx_size_symbol, dl_ch_estimates_ext, frame_parms, nl, n_rx, symbol, pilots, nb_re_pdsch, nb_rb_pdsch); + stop_meas_nr_ue_phy(ue, DLSCH_CHANNEL_SCALE_STATS); if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n", frame, nr_slot_rx, slot, symbol, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_CHANNEL_SCALE_STATS].p_time / (cpuf * 1000.0)); } //---------------------------------------------------------- //--------------------- Channel Level Calc. ---------------- //---------------------------------------------------------- - if (meas_enabled) - start_meas(&meas); + start_meas_nr_ue_phy(ue, DLSCH_CHANNEL_LEVEL_STATS); if (first_symbol_flag) { int32_t avg[MAX_ANT][MAX_ANT] = {}; if (nb_re_pdsch) @@ -537,8 +533,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, // LOG_I(PHY, "avgs Power per SC is %d lg2_maxh %d\n", avgs, log2_maxh); LOG_D(PHY, "[DLSCH] AbsSubframe %d.%d log2_maxh = %d (%d)\n", frame % 1024, nr_slot_rx, *log2_maxh, avgs); } + stop_meas_nr_ue_phy(ue, DLSCH_CHANNEL_LEVEL_STATS); if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n", frame, @@ -546,7 +542,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, slot, symbol, first_symbol_flag, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_CHANNEL_LEVEL_STATS].p_time / (cpuf * 1000.0)); } #if T_TRACER T(T_UE_PHY_PDSCH_ENERGY, T_INT(gNB_id), T_INT(0), T_INT(frame % 1024), T_INT(nr_slot_rx)); @@ -556,8 +552,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //--------------------- channel compensation --------------- //---------------------------------------------------------- // Disable correlation measurement for optimizing UE - if (meas_enabled) - start_meas(&meas); + start_meas_nr_ue_phy(ue, DLSCH_CHANNEL_COMPENSATION_STATS); nr_dlsch_channel_compensation(rx_size_symbol, nbRx, rxdataF_ext, @@ -576,8 +571,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_rb_pdsch, *log2_maxh, measurements); // log2_maxh+I0_shift + stop_meas_nr_ue_phy(ue, DLSCH_CHANNEL_COMPENSATION_STATS); if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d Channel Comp %5.2f \n", frame, @@ -585,13 +580,11 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, slot, symbol, *log2_maxh, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_CHANNEL_COMPENSATION_STATS].p_time / (cpuf * 1000.0)); } } - if (meas_enabled) - start_meas(&meas); - + start_meas_nr_ue_phy(ue, DLSCH_MRC_MMSE_STATS); if (n_rx > 1) { nr_dlsch_detection_mrc(rx_size_symbol, nl, @@ -620,20 +613,20 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_re_pdsch, nvar); } + stop_meas_nr_ue_phy(ue, DLSCH_MRC_MMSE_STATS); if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine and MMSE %5.2f \n", frame, nr_slot_rx, slot, symbol, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_MRC_MMSE_STATS].p_time / (cpuf * 1000.0)); } - if (meas_enabled) - start_meas(&meas); + + /* Store the valid DL RE's */ dl_valid_re[symbol-1] = nb_re_pdsch; int startSymbIdx = 0; @@ -682,6 +675,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, else first_symbol_flag = 0; /* Calculate LLR's for each symbol */ + start_meas_nr_ue_phy(ue, DLSCH_LLR_STATS); nr_dlsch_llr(rx_size_symbol, nbRx, rx_llr_layer_size, @@ -703,8 +697,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nr_slot_rx, dlsch, llr_offset); + stop_meas_nr_ue_phy(ue, DLSCH_LLR_STATS); } + start_meas_nr_ue_phy(ue, DLSCH_LAYER_DEMAPPING); nr_dlsch_layer_demapping(llr, dlsch[0].Nl, dlsch[0].dlsch_config.qamModOrder, @@ -713,6 +709,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, codeword_TB1, rx_llr_layer_size, layer_llr); + stop_meas_nr_ue_phy(ue, DLSCH_LAYER_DEMAPPING); // Please keep it: useful for debugging #ifdef DEBUG_PDSCH_RX char filename[50]; @@ -742,14 +739,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } if (meas_enabled) { - stop_meas(&meas); LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n", frame, nr_slot_rx, slot, symbol, - meas.p_time / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_LLR_STATS].p_time / (cpuf * 1000.0)); } #if T_TRACER diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 1d7a8fd6d8..98c6dc3dfb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -48,7 +48,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, uint32_t tb_size, unsigned int G) { - start_meas(&ue->ulsch_encoding_stats); + start_meas_nr_ue_phy(ue, ULSCH_ENCODING_STATS); /////////////////////////parameters and variables initialization///////////////////////// @@ -107,7 +107,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, harq_process->BG = ulsch->pusch_pdu.ldpcBaseGraph; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_IN); - start_meas(&ue->ulsch_segmentation_stats); + start_meas_nr_ue_phy(ue, ULSCH_SEGMENTATION_STATS); impp.Kb = nr_segmentation(harq_process->payload_AB, harq_process->c, B, @@ -126,7 +126,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, LOG_E(PHY, "nr_segmentation.c: too many segments %d, B %d\n", impp.n_segments, B); return(-1); } - stop_meas(&ue->ulsch_segmentation_stats); + stop_meas_nr_ue_phy(ue, ULSCH_SEGMENTATION_STATS); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_OUT); #ifdef DEBUG_ULSCH_CODING @@ -148,7 +148,8 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); } - start_meas(&ue->ulsch_ldpc_encoding_stats); + + start_meas_nr_ue_phy(ue, ULSCH_LDPC_ENCODING_STATS); if (ldpc_interface_offload.LDPCencoder) { for (int j = 0; j < impp.n_segments; j++) { impp.perCB[j].E_cb = nr_get_E(G, impp.n_segments, impp.Qm, ulsch->pusch_pdu.nrOfLayers, j); @@ -168,6 +169,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, write_output("ulsch_enc_output0.m", "enc0", &harq_process->d[0][0], (3 * 8 * Kr_bytes) + 12, 1, 4); #endif } + stop_meas_nr_ue_phy(ue, ULSCH_LDPC_ENCODING_STATS); /////////////////////////////////////////////////////////////////////////////// for (int r = 0; r < impp.n_segments; r++) { // looping over C segments if (impp.F > 0) { @@ -191,7 +193,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, impp.perCB[r].E_cb = nr_get_E(G, impp.n_segments, impp.Qm, ulsch->pusch_pdu.nrOfLayers, r); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN); - start_meas(&ue->ulsch_rate_matching_stats); + start_meas(&ue->phy_cpu_stats.cpu_time_stats[ULSCH_RATE_MATCHING_STATS]); if (nr_rate_matching_ldpc(ulsch->pusch_pdu.tbslbrm, impp.BG, impp.Zc, @@ -205,7 +207,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, == -1) return -1; - stop_meas(&ue->ulsch_rate_matching_stats); + stop_meas(&ue->phy_cpu_stats.cpu_time_stats[ULSCH_RATE_MATCHING_STATS]); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_OUT); #ifdef DEBUG_ULSCH_CODING @@ -215,9 +217,9 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ///////////////////////// e---->| Rate matching bit interleaving |---->f ///////////////////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INTERLEAVING_LDPC, VCD_FUNCTION_IN); - start_meas(&ue->ulsch_interleaving_stats); + start_meas_nr_ue_phy(ue, ULSCH_INTERLEAVING_STATS); nr_interleaving_ldpc(impp.perCB[r].E_cb, impp.Qm, harq_process->e + r_offset, harq_process->f + r_offset); - stop_meas(&ue->ulsch_interleaving_stats); + stop_meas_nr_ue_phy(ue, ULSCH_INTERLEAVING_STATS); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INTERLEAVING_LDPC, VCD_FUNCTION_OUT); #ifdef DEBUG_ULSCH_CODING @@ -231,6 +233,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, } /////////////////////////////////////////////////////////////////////////////////////////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT); - stop_meas(&ue->ulsch_encoding_stats); + stop_meas_nr_ue_phy(ue, ULSCH_ENCODING_STATS); return(0); } diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 70b0dc041f..4fc26193cf 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -40,6 +40,7 @@ #include "defs_nr_common.h" #include "CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/defs_nr_sl_UE.h" +#include "openair1/PHY/nr_phy_common/inc/nr_ue_phy_meas.h" #include #include @@ -527,56 +528,10 @@ typedef struct PHY_VARS_NR_UE_s { scheduling_request_config_t scheduling_request_config_nr[NUMBER_OF_CONNECTED_gNB_MAX]; #endif - - time_stats_t phy_proc; - time_stats_t phy_proc_tx; - time_stats_t phy_proc_rx; - - time_stats_t ue_ul_indication_stats; - uint32_t use_ia_receiver; - - time_stats_t ofdm_mod_stats; - time_stats_t ulsch_encoding_stats; - time_stats_t ulsch_ldpc_encoding_stats; - time_stats_t ulsch_modulation_stats; - time_stats_t ulsch_segmentation_stats; - time_stats_t ulsch_rate_matching_stats; - time_stats_t ulsch_interleaving_stats; - time_stats_t ulsch_multiplexing_stats; - - time_stats_t ue_front_end_stat; - time_stats_t ue_front_end_per_slot_stat[LTE_SLOTS_PER_SUBFRAME]; - time_stats_t pdcch_procedures_stat; - time_stats_t pdsch_procedures_stat; - time_stats_t pdsch_procedures_per_slot_stat[LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_procedures_stat; - - time_stats_t rx_pdsch_stats; - time_stats_t ofdm_demod_stats; - time_stats_t dlsch_rx_pdcch_stats; - time_stats_t rx_dft_stats; - time_stats_t dlsch_channel_estimation_stats; - time_stats_t dlsch_freq_offset_estimation_stats; - time_stats_t dlsch_decoding_stats; - time_stats_t dlsch_demodulation_stats; - time_stats_t dlsch_rate_unmatching_stats; - time_stats_t dlsch_ldpc_decoding_stats; - time_stats_t dlsch_deinterleaving_stats; - time_stats_t dlsch_llr_stats; - time_stats_t dlsch_llr_stats_parallelization[LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_unscrambling_stats; - time_stats_t dlsch_rate_matching_stats; - time_stats_t dlsch_ldpc_encoding_stats; - time_stats_t dlsch_interleaving_stats; - time_stats_t dlsch_tc_init_stats; - time_stats_t dlsch_tc_alpha_stats; - time_stats_t dlsch_tc_beta_stats; - time_stats_t dlsch_tc_gamma_stats; - time_stats_t dlsch_tc_ext_stats; - time_stats_t dlsch_tc_intl1_stats; - time_stats_t dlsch_tc_intl2_stats; - time_stats_t tx_prach; + // TODO: move this out of phy + time_stats_t ue_ul_indication_stats; + nr_ue_phy_cpu_stat_t phy_cpu_stats; /// RF and Interface devices per CC openair0_device rfdevice; @@ -706,5 +661,13 @@ typedef struct LDPCDecode_ue_s { UE_nr_rxtx_proc_t proc; } ldpcDecode_ue_t; +static inline void start_meas_nr_ue_phy(PHY_VARS_NR_UE *ue, int meas_index) { + start_meas(&ue->phy_cpu_stats.cpu_time_stats[meas_index]); +} + +static inline void stop_meas_nr_ue_phy(PHY_VARS_NR_UE *ue, int meas_index) { + stop_meas(&ue->phy_cpu_stats.cpu_time_stats[meas_index]); +} + #include "SIMULATION/ETH_TRANSPORT/defs.h" #endif diff --git a/openair1/PHY/nr_phy_common/CMakeLists.txt b/openair1/PHY/nr_phy_common/CMakeLists.txt index 3ba2666b08..ebbc3fcbc7 100644 --- a/openair1/PHY/nr_phy_common/CMakeLists.txt +++ b/openair1/PHY/nr_phy_common/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(nr_phy_common src/nr_phy_common.c) target_link_libraries(nr_phy_common PRIVATE UTIL) target_include_directories(nr_phy_common PUBLIC inc/) + +add_library(nr_ue_phy_meas src/nr_ue_phy_meas.c) +target_include_directories(nr_ue_phy_meas PUBLIC inc/) +target_link_libraries(nr_ue_phy_meas PUBLIC utils) diff --git a/openair1/PHY/nr_phy_common/inc/nr_ue_phy_meas.h b/openair1/PHY/nr_phy_common/inc/nr_ue_phy_meas.h new file mode 100644 index 0000000000..6c667e3c1d --- /dev/null +++ b/openair1/PHY/nr_phy_common/inc/nr_ue_phy_meas.h @@ -0,0 +1,66 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef __NR_UE_PHY_MEAS__H__ +#define __NR_UE_PHY_MEAS__H__ +#include "time_meas.h" +#include "utils.h" + +#define NOOP(a) a +#define FOREACH_NR_PHY_CPU_MEAS(FN) \ + FN(RX_PDSCH_STATS),\ + FN(DLSCH_RX_PDCCH_STATS),\ + FN(RX_DFT_STATS),\ + FN(DLSCH_CHANNEL_ESTIMATION_STATS),\ + FN(DLSCH_DECODING_STATS),\ + FN(DLSCH_RATE_UNMATCHING_STATS),\ + FN(DLSCH_LDPC_DECODING_STATS),\ + FN(DLSCH_DEINTERLEAVING_STATS),\ + FN(DLSCH_EXTRACT_RBS_STATS),\ + FN(DLSCH_CHANNEL_SCALE_STATS),\ + FN(DLSCH_CHANNEL_LEVEL_STATS),\ + FN(DLSCH_MRC_MMSE_STATS),\ + FN(DLSCH_UNSCRAMBLING_STATS),\ + FN(DLSCH_CHANNEL_COMPENSATION_STATS),\ + FN(DLSCH_LLR_STATS),\ + FN(DLSCH_LAYER_DEMAPPING),\ + FN(PHY_RX_PDCCH_STATS),\ + FN(DLSCH_PROCEDURES_STATS),\ + FN(PHY_PROC_TX),\ + FN(ULSCH_SEGMENTATION_STATS),\ + FN(ULSCH_LDPC_ENCODING_STATS),\ + FN(ULSCH_RATE_MATCHING_STATS),\ + FN(ULSCH_INTERLEAVING_STATS),\ + FN(ULSCH_ENCODING_STATS) + +typedef enum { + FOREACH_NR_PHY_CPU_MEAS(NOOP), + MAX_CPU_STAT_TYPE +} nr_ue_phy_cpu_stat_type_t; + +typedef struct nr_ue_phy_cpu_stat_t { + time_stats_t cpu_time_stats[MAX_CPU_STAT_TYPE]; +} nr_ue_phy_cpu_stat_t; + +void init_nr_ue_phy_cpu_stats(nr_ue_phy_cpu_stat_t *ue_phy_cpu_stats); +void reset_nr_ue_phy_cpu_stats(nr_ue_phy_cpu_stat_t *ue_phy_cpu_stats); + +#endif diff --git a/openair1/PHY/nr_phy_common/src/nr_ue_phy_meas.c b/openair1/PHY/nr_phy_common/src/nr_ue_phy_meas.c new file mode 100644 index 0000000000..75ad7a5b72 --- /dev/null +++ b/openair1/PHY/nr_phy_common/src/nr_ue_phy_meas.c @@ -0,0 +1,40 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include +#include "nr_ue_phy_meas.h" +#include + +void init_nr_ue_phy_cpu_stats(nr_ue_phy_cpu_stat_t *ue_phy_cpu_stats) { + reset_nr_ue_phy_cpu_stats(ue_phy_cpu_stats); + const char* cpu_stats_enum_to_string_table[] = { + FOREACH_NR_PHY_CPU_MEAS(TO_STRING) + }; + for (int i = 0; i < MAX_CPU_STAT_TYPE; i++) { + ue_phy_cpu_stats->cpu_time_stats[i].meas_name = strdup(cpu_stats_enum_to_string_table[i]); + } +} + +void reset_nr_ue_phy_cpu_stats(nr_ue_phy_cpu_stat_t *ue_phy_cpu_stats) { + for (int i = 0; i < MAX_CPU_STAT_TYPE; i++) { + reset_meas(&ue_phy_cpu_stats->cpu_time_stats[i]); + } +} diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index cfb52f3266..123423283f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -275,8 +275,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, n LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); - start_meas(&ue->phy_proc_tx); - + start_meas_nr_ue_phy(ue, PHY_PROC_TX); for (uint8_t harq_pid = 0; harq_pid < NR_MAX_ULSCH_HARQ_PROCESSES; harq_pid++) { if (ue->ul_harq_processes[harq_pid].ULstatus == ACTIVE) { nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, gNB_id, phy_data, (c16_t **)&txdataF); @@ -300,7 +299,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, n LOG_D(PHY, "****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); - stop_meas(&ue->phy_proc_tx); + stop_meas_nr_ue_phy(ue, PHY_PROC_TX); } void nr_ue_measurement_procedures(uint16_t l, @@ -426,7 +425,7 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &phy_pdcch_config->pdcch_config[n_ss]; - start_meas(&ue->dlsch_rx_pdcch_stats); + start_meas_nr_ue_phy(ue, DLSCH_RX_PDCCH_STATS); /// PDCCH/DCI e-sequence (input to rate matching). int32_t pdcch_e_rx_size = NR_MAX_PDCCH_SIZE; @@ -454,9 +453,7 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, nr_fill_dl_indication(&dl_indication, &dci_ind, NULL, proc, ue, phy_data); // send to mac ue->if_inst->dl_indication(&dl_indication); - - stop_meas(&ue->dlsch_rx_pdcch_stats); - + stop_meas_nr_ue_phy(ue, DLSCH_RX_PDCCH_STATS); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); return (dci_ind.number_of_dcis); } @@ -468,7 +465,6 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], int G) { - int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; // We handle only one CW now @@ -510,6 +506,7 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, uint32_t nvar = 0; + start_meas_nr_ue_phy(ue, DLSCH_CHANNEL_ESTIMATION_STATS); for (int m = dlschCfg->start_symbol; m < (dlschCfg->start_symbol + dlschCfg->number_symbols); m++) { if (dlschCfg->dlDmrsSymbPos & (1 << m)) { for (int nl = 0; nl < dlsch0->Nl; nl++) { //for MIMO Config: it shall loop over no_layers @@ -546,6 +543,7 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, } } } + stop_meas_nr_ue_phy(ue, DLSCH_CHANNEL_ESTIMATION_STATS); nvar /= (dlschCfg->number_symbols * dlsch0->Nl * ue->frame_parms.nb_antennas_rx); @@ -576,16 +574,12 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, uint32_t llr_offset[NR_SYMBOLS_PER_SLOT] = {0}; int32_t log2_maxh = 0; - start_meas(&ue->rx_pdsch_stats); + start_meas_nr_ue_phy(ue, RX_PDSCH_STATS); for (int m = dlschCfg->start_symbol; m < (dlschCfg->number_symbols + dlschCfg->start_symbol); m++) { bool first_symbol_flag = false; if (m == first_symbol_with_data) first_symbol_flag = true; - uint8_t slot = 0; - if(m >= ue->frame_parms.symbols_per_slot>>1) - slot = 1; - start_meas(&ue->dlsch_llr_stats_parallelization[slot]); // process DLSCH received symbols in the slot // symbol by symbol processing (if data/DMRS are multiplexed is checked inside the function) if (nr_rx_pdsch(ue, @@ -610,17 +604,8 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, nvar) < 0) return -1; - - stop_meas(&ue->dlsch_llr_stats_parallelization[slot]); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, - "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n", - frame_rx, - nr_slot_rx, - m, - ue->dlsch_llr_stats_parallelization[slot].p_time / (cpuf * 1000.0)); } // CRNTI active - stop_meas(&ue->rx_pdsch_stats); + stop_meas_nr_ue_phy(ue, RX_PDSCH_STATS); } return 0; } @@ -734,13 +719,11 @@ static bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, return false; } - start_meas(&ue->dlsch_unscrambling_stats); + start_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS); nr_dlsch_unscrambling(llr[0], G, 0, dlsch[0].dlsch_config.dlDataScramblingId, dlsch[0].rnti); + stop_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS); - stop_meas(&ue->dlsch_unscrambling_stats); - - start_meas(&ue->dlsch_decoding_stats); - + start_meas_nr_ue_phy(ue, DLSCH_DECODING_STATS); // create memory to store decoder output int a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated int num_rb = dlsch[0].dlsch_config.number_rbs; @@ -796,12 +779,16 @@ static bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_D(PHY, "DL PDU length in bits: %d, in bytes: %d \n", dlsch[0].dlsch_config.TBS, dlsch[0].dlsch_config.TBS / 8); - stop_meas(&ue->dlsch_decoding_stats); - if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", - frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); + stop_meas_nr_ue_phy(ue, DLSCH_DECODING_STATS); + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, + " --> Unscrambling for CW0 %5.3f\n", + ue->phy_cpu_stats.cpu_time_stats[DLSCH_UNSCRAMBLING_STATS].p_time / (cpuf * 1000.0)); + LOG_D(PHY, + "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", + frame_rx % 1024, + nr_slot_rx, + ue->phy_cpu_stats.cpu_time_stats[DLSCH_DECODING_STATS].p_time / (cpuf * 1000.0)); } if(is_cw1_active) { @@ -819,14 +806,13 @@ static bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymbPos, dlsch_config->start_symbol, dlsch_config->number_symbols); unav_res = n_ptrs * ptrsSymbPerSlot; } + start_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS); unav_res += compute_csi_rm_unav_res(dlsch_config); G = nr_get_G(dlsch_config->number_rbs, nb_symb_sch, nb_re_dmrs, dmrs_len, unav_res, dlsch_config->qamModOrder, dlsch[1].Nl); - start_meas(&ue->dlsch_unscrambling_stats); nr_dlsch_unscrambling(llr[1], G, 0, dlsch[1].dlsch_config.dlDataScramblingId, dlsch[1].rnti); - stop_meas(&ue->dlsch_unscrambling_stats); - - start_meas(&ue->dlsch_decoding_stats); + stop_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS); + start_meas_nr_ue_phy(ue, DLSCH_DECODING_STATS); ret1 = nr_dlsch_decoding(ue, proc, gNB_id, @@ -843,14 +829,16 @@ static bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, G); LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); - stop_meas(&ue->dlsch_decoding_stats); + stop_meas_nr_ue_phy(ue, DLSCH_DECODING_STATS); if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n", (ue->dlsch_unscrambling_stats.p_time) / (cpuf * 1000.0)); + LOG_D(PHY, + " --> Unscrambling for CW1 %5.3f\n", + ue->phy_cpu_stats.cpu_time_stats[DLSCH_UNSCRAMBLING_STATS].p_time / (cpuf * 1000.0)); LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx % 1024, nr_slot_rx, - (ue->dlsch_decoding_stats.p_time) / (cpuf * 1000.0)); + ue->phy_cpu_stats.cpu_time_stats[DLSCH_DECODING_STATS].p_time / (cpuf * 1000.0)); } LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch[1].dlsch_config.TBS); } @@ -884,7 +872,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ nr_ue_dlsch_init(phy_data->dlsch, NR_MAX_NB_LAYERS>4 ? 2:1, ue->max_ldpc_iterations); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); - start_meas(&ue->phy_proc_rx); LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_slot_rx); @@ -913,7 +900,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ for (int i=1; i<4; i++) { nr_slot_fep(ue, fp, proc, (ssb_start_symbol + i) % (fp->symbols_per_slot), rxdataF, link_type_dl); - start_meas(&ue->dlsch_channel_estimation_stats); nr_pbch_channel_estimation(&ue->frame_parms, NULL, ue->nr_gold_pbch, @@ -929,7 +915,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ rxdataF, false, fp->Nid_cell); - stop_meas(&ue->dlsch_channel_estimation_stats); if (i - 1 == 2) UEscopeCopy(ue, @@ -1007,8 +992,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; for (uint16_t l=0; lofdm_demod_stats); nr_slot_fep(ue, fp, proc, l, rxdataF, link_type_dl); } @@ -1032,8 +1015,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ pdcch_dl_ch_estimates, rxdataF); - stop_meas(&ue->ofdm_demod_stats); - } dci_cnt = dci_cnt + nr_ue_pdcch_procedures(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_data, n_ss, rxdataF); } @@ -1050,8 +1031,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ int gNB_id = proc->gNB_id; NR_UE_DLSCH_t *dlsch = &phy_data->dlsch[0]; - time_stats_t meas = {0}; - start_meas(&meas); // do procedures for C-RNTI bool slot_fep_map[14] = {0}; @@ -1146,7 +1125,7 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d\n", nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - start_meas(&ue->dlsch_procedures_stat); + start_meas_nr_ue_phy(ue, DLSCH_PROCEDURES_STATS); if (ret_pdsch >= 0) nr_ue_dlsch_procedures(ue, proc, dlsch, llr, G); @@ -1158,10 +1137,9 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ LOG_W(NR_PHY, "nr_ue_pdsch_procedures failed in slot %d\n", proc->nr_slot_rx); } - stop_meas(&ue->dlsch_procedures_stat); + stop_meas_nr_ue_phy(ue, DLSCH_PROCEDURES_STATS); if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->phy_cpu_stats.cpu_time_stats[DLSCH_PROCEDURES_STATS].p_time/(cpuf*1000.0)); } if (ue->phy_sim_rxdataF) @@ -1174,8 +1152,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ free(llr[i]); } - start_meas(&meas); - if (nr_slot_rx==9) { if (frame_rx % 10 == 0) { if ((ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]) != 0) @@ -1200,10 +1176,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ } - stop_meas(&meas); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "after ldpc decode until end of Rx %5.2f \n", meas.p_time / (cpuf * 1000.0)); - #ifdef EMOS phy_procedures_emos_UE_RX(ue,slot,gNB_id); #endif @@ -1211,10 +1183,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); - stop_meas(&ue->phy_proc_rx); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx.p_time/(cpuf*1000.0)); - LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, nr_slot_rx); UEscopeCopy(ue, commonRxdataF, rxdataF, sizeof(int32_t), ue->frame_parms.nb_antennas_rx, rxdataF_sz, 0); } diff --git a/openair1/SIMULATION/LTE_PHY/common_sim.h b/openair1/SIMULATION/LTE_PHY/common_sim.h index 5625cf8e2f..aaea26c5bb 100644 --- a/openair1/SIMULATION/LTE_PHY/common_sim.h +++ b/openair1/SIMULATION/LTE_PHY/common_sim.h @@ -62,18 +62,20 @@ void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) { } void printStatIndent(time_stats_t *ptr, char *txt) { - printf("|__ %-38s %6.2f us (%3d trials)\n", + printf("|__ %-38s %6.2f us (%3d trials)\t\t(%6.2f total [ms])\n", txt, ptr->trials?inMicroS(ptr->diff/ptr->trials):0, - ptr->trials); + ptr->trials, + ptr->trials?inMicroS(ptr->diff)/1000:0); } void printStatIndent2(time_stats_t *ptr, char *txt) { double timeBase=1/(1000*get_cpu_freq_GHz()); - printf(" |__ %-34s %6.2f us (%3d trials)\n", + printf(" |__ %-34s %6.2f us (%3d trials)\t\t(%6.2f total [ms])\n", txt, ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, - ptr->trials); + ptr->trials, + ptr->trials?inMicroS(ptr->diff)/1000:0); } void printStatIndent3(time_stats_t *ptr, char *txt) { diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 27236d140e..61835126f6 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -826,6 +826,7 @@ int main(int argc, char **argv) UE->frame_parms.nb_antennas_rx = n_rx; UE->frame_parms.nb_antenna_ports_gNB = n_tx; UE->max_ldpc_iterations = max_ldpc_iterations; + init_nr_ue_phy_cpu_stats(&UE->phy_cpu_stats); if (run_initial_sync==1) UE->is_synchronized = 0; @@ -1244,36 +1245,10 @@ int main(int argc, char **argv) printStatIndent2(&gNB->dlsch_resource_mapping_stats, "DLSCH Resource Mapping time"); printStatIndent2(&gNB->dlsch_precoding_stats,"DLSCH Layer Precoding time"); - printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing); - /* - printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx"); - printStatIndent(&ue_front_end_tot,"Front end processing"); - printStatIndent(&dlsch_llr_tot,"rx_pdsch processing"); - printStatIndent2(&pdsch_procedures_tot,"pdsch processing"); - printStatIndent2(&dlsch_procedures_tot,"dlsch processing"); - printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing"); - printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation"); - printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time"); - printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time"); - printStatIndent(&dlsch_decoding_tot, "DLSCH Decoding time "); - printStatIndent(&UE->dlsch_unscrambling_stats,"DLSCH unscrambling time"); - printStatIndent(&UE->dlsch_rate_unmatching_stats,"DLSCH Rate Unmatching"); - printf("|__ DLSCH Turbo Decoding(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", - UE->dlsch[0][0]->harq_processes[0]->Cminus ? - UE->dlsch[0][0]->harq_processes[0]->Kminus : - UE->dlsch[0][0]->harq_processes[0]->Kplus, - UE->dlsch_tc_intl1_stats.trials/(double)UE->dlsch_tc_init_stats.trials, - (double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase, - (int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials), - UE->dlsch_turbo_decoding_stats.trials); - printStatIndent2(&UE->dlsch_tc_init_stats,"init"); - printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha"); - printStatIndent2(&UE->dlsch_tc_beta_stats,"beta"); - printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma"); - printStatIndent2(&UE->dlsch_tc_ext_stats,"ext"); - printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver"); - printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC"); - */ + printf("\nUE function statistics (per %d us slot)\n", 1000 >> *scc->ssbSubcarrierSpacing); + for (int i = RX_PDSCH_STATS; i <= DLSCH_PROCEDURES_STATS; i++) { + printStatIndent(&UE->phy_cpu_stats.cpu_time_stats[i], UE->phy_cpu_stats.cpu_time_stats[i].meas_name); + } } if (n_trials == 1) { diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index c280bd64de..91046d920d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -955,10 +955,6 @@ int main(int argc, char *argv[]) reset_meas(&gNB->rx_pusch_symbol_processing_stats); reset_meas(&gNB->ulsch_decoding_stats); reset_meas(&gNB->ulsch_channel_estimation_stats); - reset_meas(&UE->ulsch_ldpc_encoding_stats); - reset_meas(&UE->ulsch_rate_matching_stats); - reset_meas(&UE->ulsch_interleaving_stats); - reset_meas(&UE->ulsch_encoding_stats); reset_meas(&gNB->rx_srs_stats); reset_meas(&gNB->generate_srs_stats); reset_meas(&gNB->get_srs_signal_stats); @@ -967,6 +963,7 @@ int main(int argc, char *argv[]) reset_meas(&gNB->srs_report_tlv_stats); reset_meas(&gNB->srs_beam_report_stats); reset_meas(&gNB->srs_iq_matrix_stats); + init_nr_ue_phy_cpu_stats(&UE->phy_cpu_stats); uint32_t errors_scrambling[16] = {0}; int n_errors[16] = {0}; @@ -1580,11 +1577,9 @@ int main(int argc, char *argv[]) printStatIndent(&gNB->ulsch_decoding_stats,"ULSCH total decoding time"); printf("\nUE TX\n"); - printStatIndent(&UE->ulsch_encoding_stats,"ULSCH total encoding time"); - printStatIndent2(&UE->ulsch_segmentation_stats,"ULSCH segmentation time"); - printStatIndent2(&UE->ulsch_ldpc_encoding_stats,"ULSCH LDPC encoder time"); - printStatIndent2(&UE->ulsch_rate_matching_stats,"ULSCH rate-matching time"); - printStatIndent2(&UE->ulsch_interleaving_stats,"ULSCH interleaving time"); + for (int i = PHY_PROC_TX; i <= ULSCH_ENCODING_STATS; i++) { + printStatIndent(&UE->phy_cpu_stats.cpu_time_stats[i], UE->phy_cpu_stats.cpu_time_stats[i].meas_name); + } printStatIndent(&gNB->rx_srs_stats,"RX SRS time"); printStatIndent2(&gNB->generate_srs_stats,"Generate SRS sequence time"); printStatIndent2(&gNB->get_srs_signal_stats,"Get SRS signal time"); From 9d77057775c52656e28af285543f308b16a90159 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jul 2024 19:20:21 +0200 Subject: [PATCH 06/61] Remove LFDS credit: we don't use it anymore --- NOTICE.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/NOTICE.md b/NOTICE.md index b92941540d..10f3bd295b 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -4,15 +4,6 @@ For more details of the license, refer to [LICENSE](LICENSE) file in the same di However, the source code also contains third party software that is acknowledged here for reference. -## Credits for LFDS user space source code located in folder openair2/UTILS/LFDS/ ## - -See on [liblfds website](https://liblfds.org/) the license section. - -
-"There is no license. You are free to use this software in any way, for any purpose. Go forth and create wealth!
-If however for legal reasons a licence is required, the license of your choice will be granted."
-
- ## Credits for source code common/utils/collection/queue.h: ## The Regents of the University of California: BSD 3-Clause Licence. From 6da87cf0622724cb9f62e6329e991d28a87614dd Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 12 Jul 2024 17:12:14 +0200 Subject: [PATCH 07/61] Remove unused Makefile --- openair1/SIMULATION/ETH_TRANSPORT/Makefile.inc | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/Makefile.inc diff --git a/openair1/SIMULATION/ETH_TRANSPORT/Makefile.inc b/openair1/SIMULATION/ETH_TRANSPORT/Makefile.inc deleted file mode 100644 index b865ef7612..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -ETHERNET_TRANSPORT_OBJS = $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/netlink_init.o -ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/multicast_link.o -ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/socket.o -ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/bypass_session_layer.o -ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/emu_transport.o -ETHERNET_TRANSPORT_OBJS += $(TOP_DIR)/SIMULATION/ETH_TRANSPORT/pgm_link.o From 836563094628927198c990e7841404237ab96da6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 19:40:49 +0200 Subject: [PATCH 08/61] Remove unused emu_transport.c --- .../SIMULATION/ETH_TRANSPORT/emu_transport.c | 517 ------------------ openair1/SIMULATION/ETH_TRANSPORT/proto.h | 28 - 2 files changed, 545 deletions(-) delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c diff --git a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c deleted file mode 100644 index d0f0eab4a6..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file phy_emulation.c - * \brief implements the underlying protocol for emulated data exchange over Ethernet using IP multicast - * \author Navid Nikaein - * \date 2011 - 2014 - * \version 1.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - - -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "common/ran_context.h" -#include "defs.h" -#include "extern.h" -#include "proto.h" -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "openair1/SIMULATION/ETH_TRANSPORT/extern.h" -unsigned char Emulation_status; -unsigned char emu_tx_status; -unsigned char emu_rx_status; - -#if !defined(ENABLE_NEW_MULTICAST) -pthread_mutex_t Tx_mutex; -pthread_cond_t Tx_cond; -char Tx_mutex_var; -#endif - -/* Handlers for RX and TX */ -rx_handler_t rx_handler; -tx_handler_t tx_handler; - -eNB_transport_info_t eNB_transport_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs]; -uint16_t eNB_transport_info_TB_index[NUMBER_OF_eNB_MAX][MAX_NUM_CCs]; - -UE_transport_info_t UE_transport_info[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - -UE_cntl ue_cntl_delay[NUMBER_OF_UE_MAX][MAX_NUM_CCs][2]; - -extern unsigned int Master_list_rx; - -extern unsigned char NB_INST; -//#define DEBUG_CONTROL 1 -//#define DEBUG_EMU 1 - -void emu_transport_sync(void) -{ - LOG_D(EMU, "Entering EMU transport SYNC is primary master %d\n", - oai_emulation.info.is_primary_master); - - if (oai_emulation.info.is_primary_master == 0) { -retry: - bypass_tx_data(WAIT_SM_TRANSPORT,0,0); - // just wait to recieve the master 0 msg - Master_list_rx = oai_emulation.info.master_list - 1; - - if (bypass_rx_data(0,0,0,1) == -1) { - /* In case the master is not ready at time we send the first message */ - sleep(1); - goto retry; - } - } else { - bypass_rx_data(0,0,0,0); - bypass_tx_data(WAIT_PM_TRANSPORT,0,0); - } - - if (oai_emulation.info.master_list!=0) { -retry2: - bypass_tx_data(SYNC_TRANSPORT,0,0); - - if (bypass_rx_data(0,0,0,0) == -1) { - goto retry2; - } - - // i received the sync from all secondary masters - if (emu_rx_status == SYNCED_TRANSPORT) { - emu_tx_status = SYNCED_TRANSPORT; - } - - LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n"); - } - - LOG_D(EMU, "Leaving EMU transport SYNC is primary master %d\n", - oai_emulation.info.is_primary_master); -} - -void emu_transport(unsigned int frame, unsigned int last_slot, - unsigned int next_slot,lte_subframe_t direction, - unsigned char frame_type, - int ethernet_flag ) -{ - if (ethernet_flag == 0) { - return; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( - VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_IN); - - if ((frame_type == 1) && (direction == SF_S)) { - if ((next_slot % 2) == 0) { - emu_transport_DL(frame, last_slot, next_slot); - } else { - emu_transport_UL(frame, last_slot , next_slot); - } - - //DL - } else { - if ((next_slot % 2) == 0) { - if (((frame_type == 1) && (direction == SF_DL )) || (frame_type == 0) ) { - emu_transport_DL(frame, last_slot, next_slot); - } - } - - // UL - if (((frame_type == 1) && (direction == SF_UL)) || (frame_type == 0) ) { - emu_transport_UL(frame, last_slot, next_slot); - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( - VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_OUT); -} - - -void emu_transport_DL(unsigned int frame, unsigned int last_slot, - unsigned int next_slot) -{ - LOG_D(EMU, "Entering EMU transport DL, is primary master %d\n", - oai_emulation.info.is_primary_master); - - if (oai_emulation.info.is_primary_master == 0) { - if (oai_emulation.info.nb_enb_local > 0) { // send in DL if - bypass_tx_data(ENB_TRANSPORT, frame, next_slot); - bypass_rx_data(frame, last_slot, next_slot, 1); - } else { - bypass_tx_data(WAIT_SM_TRANSPORT,frame,next_slot); - bypass_rx_data(frame, last_slot, next_slot, 0); - } - } else { // PM - if (oai_emulation.info.nb_enb_local>0) { // send in DL if - bypass_rx_data(frame, last_slot, next_slot, 1); - bypass_tx_data(ENB_TRANSPORT, frame, next_slot); - } else { - bypass_rx_data(frame, last_slot, next_slot, 0); - bypass_tx_data(WAIT_SM_TRANSPORT,frame,next_slot); - } - } - - LOG_D(EMU, "Leaving EMU transport DL, is primary master %d\n", - oai_emulation.info.is_primary_master); -} - -void emu_transport_UL(unsigned int frame, unsigned int last_slot, - unsigned int next_slot) -{ - LOG_D(EMU, "Entering EMU transport UL, is primary master %d\n", - oai_emulation.info.is_primary_master); - - if (oai_emulation.info.is_primary_master == 0) { - if (oai_emulation.info.nb_ue_local > 0) { - bypass_tx_data(UE_TRANSPORT, frame, next_slot); - bypass_rx_data(frame, last_slot, next_slot, 1); - } else { - bypass_tx_data(WAIT_SM_TRANSPORT, frame, next_slot); - bypass_rx_data(frame,last_slot, next_slot, 0); - } - } else { - if (oai_emulation.info.nb_ue_local > 0) { - bypass_rx_data(frame, last_slot, next_slot, 1); - bypass_tx_data(UE_TRANSPORT, frame, next_slot); - } else { - bypass_rx_data(frame,last_slot, next_slot, 0); - bypass_tx_data(WAIT_SM_TRANSPORT, frame, next_slot); - } - } - - LOG_D(EMU, "Leaving EMU transport UL, is primary master %d\n", - oai_emulation.info.is_primary_master); -} - -void emu_transport_release(void) -{ - bypass_tx_data(RELEASE_TRANSPORT,0,0); - LOG_E(EMU," tx RELEASE_TRANSPORT \n"); -} - -unsigned int emul_tx_handler(unsigned char Mode,char *Tx_buffer, - unsigned int *Nbytes,unsigned int *Nb_flows) -{ - - return *Nbytes; -} - -unsigned int emul_rx_data(void) -{ - return(0); -} - -unsigned int emul_rx_handler(unsigned char Mode,char *rx_buffer, - unsigned int Nbytes) -{ - unsigned short Rx_size=0; - return (Rx_size+2); -} - -void clear_eNB_transport_info(uint8_t nb_eNB) -{ - uint8_t eNB_id; - uint8_t CC_id; - - for (eNB_id=0; eNB_idpbch_pdu = - eNB_transport_info[enb_id][CC_id].cntl.pbch_payload; - /* LOG_I(EMU," RX slot %d ENB TRANSPORT pbch payload %d pdu[0] %d pdu[0] %d \n", - next_slot , - eNB_transport_info[enb_id][CC_id].cntl.pbch_payload, - ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[0], - ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[1]); - */ - // } - //CFI - // not needed yet - - //PHICH - // to be added later - - //DCI - nb_total_dci= eNB_transport_info[enb_id][CC_id].num_pmch + - eNB_transport_info[enb_id][CC_id].num_ue_spec_dci + - eNB_transport_info[enb_id][CC_id].num_common_dci; - - RC.eNB[enb_id][CC_id]->num_ue_spec_dci[(next_slot>>1)&1] = - eNB_transport_info[enb_id][CC_id].num_ue_spec_dci; - RC.eNB[enb_id][CC_id]->num_common_dci[(next_slot>>1)&1] = - eNB_transport_info[enb_id][CC_id].num_common_dci; -#ifdef DEBUG_EMU - LOG_D(EMU, "Fill phy vars eNB %d for slot %d, DCI found %d \n", - enb_id, next_slot, nb_total_dci); -#endif - - if (nb_total_dci >0) { - - memcpy(RC.eNB[enb_id][CC_id]->dci_alloc[(next_slot>>1)&1], - eNB_transport_info[enb_id][CC_id].dci_alloc, - (nb_total_dci) * sizeof(DCI_ALLOC_t)); - - n_dci_dl=0; - - // fill dlsch_eNB structure from DCI - for (n_dci = 0; n_dci < nb_total_dci; n_dci++) { - - //exclude ul dci - if ((eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].format > 0) || (eNB_transport_info[enb_id][CC_id].num_pmch > 0 )) { -#ifdef DEBUG_EMU - LOG_D(EMU, "dci spec %d common %d pmch %d tbs is %d payload offset %d\n", - eNB_transport_info[enb_id][CC_id].num_ue_spec_dci, - eNB_transport_info[enb_id][CC_id].num_common_dci, - eNB_transport_info[enb_id][CC_id].num_pmch, - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl], - payload_offset); -#endif - - switch (eNB_transport_info[enb_id][CC_id].dlsch_type[n_dci_dl]) { - case 0: //SI: - memcpy(RC.eNB[enb_id][CC_id]->dlsch_SI->harq_processes[0]->b, - &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset], - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#ifdef DEBUG_EMU - LOG_D(EMU, "SI eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]%d \n", - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#endif - break; - - case 1: //RA: - memcpy(RC.eNB[enb_id][CC_id]->dlsch_ra->harq_processes[0]->b, - &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset], - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#ifdef DEBUG_EMU - LOG_D(EMU, "RA eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]%d \n", - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#endif - break; - - case 2://TB0: - harq_pid = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl]; - ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl]; - RC.eNB[enb_id][CC_id]->dlsch[ue_id][0]->rnti= - eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti; - dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][0]; -#ifdef DEBUG_EMU - LOG_D(EMU, - " enb_id %d ue id is %d rnti is %x dci index %d, harq_pid %d tbs %d \n", - enb_id, ue_id, eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti, - n_dci_dl, harq_pid, eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); - - for (i=0; iharq_processes[harq_pid]->b, - &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset], - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); - break; - - case 3://TB1: - harq_pid = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl]; - ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl]; - RC.eNB[enb_id][CC_id]->dlsch[ue_id][1]->rnti= - eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti; - dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][1]; - - memcpy(dlsch_eNB->harq_processes[harq_pid]->b, - &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset], - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); - break; - - case 5: - memcpy(RC.eNB[enb_id][CC_id]->dlsch_MCH->harq_processes[0]->b, - &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset], - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#ifdef DEBUG_EMU - LOG_D(EMU, "PMCH eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl] %d \n", - eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]); -#endif - break; - - default: - LOG_W(EMU,"not supported dlsch type %d \n", eNB_transport_info[enb_id][CC_id].dlsch_type[n_dci_dl]); - break; - } - - payload_offset += eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]; - } - - n_dci_dl++; - } - -#ifdef DEBUG_EMU - LOG_D(EMU, "Fill phy eNB vars done next slot %d !\n", next_slot); -#endif - } -} - -void fill_phy_ue_vars(unsigned int ue_id, uint8_t CC_id,unsigned int last_slot) -{ - int n_enb;//index - int enb_id; - // int harq_id; - // int payload_offset = 0; - unsigned short rnti; - unsigned int harq_pid; - LTE_UE_ULSCH_t *ulsch; - PUCCH_FMT_t pucch_format; - // uint8_t ue_transport_info_index[NUMBER_OF_eNB_MAX]; - uint8_t subframe = (last_slot+1)>>1; - - memcpy(&ue_cntl_delay[ue_id][CC_id][(last_slot+1)%2], &UE_transport_info[ue_id][CC_id].cntl, - sizeof(UE_cntl)); - -#ifdef DEBUG_EMU - LOG_D(EMU, - "Last slot %d subframe %d CC_id %d: Fill phy vars UE %d : PRACH is (%d,%d) preamble (%d,%d) SR (%d,%d), pucch_sel (%d, %d)\n", - - last_slot,subframe,CC_id, ue_id, - UE_transport_info[ue_id][CC_id].cntl.prach_flag, - ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_flag, - UE_transport_info[ue_id][CC_id].cntl.prach_id, - ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_id, - UE_transport_info[ue_id][CC_id].cntl.sr, - ue_cntl_delay[ue_id][CC_id][last_slot%2].sr, - UE_transport_info[ue_id][CC_id].cntl.pucch_sel, - ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_sel); -#endif - //ue_cntl_delay[subframe%2].prach_flag ; - PHY_vars_UE_g[ue_id][CC_id]->generate_prach = ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_flag;//UE_transport_info[ue_id][CC_id].cntl.prach_flag; - - if (PHY_vars_UE_g[ue_id][CC_id]->generate_prach == 1) { - // if (PHY_vars_UE_g[ue_id][CC_id]->prach_resources[enb_id] == NULL) - // PHY_vars_UE_g[ue_id][CC_id]->prach_resources[enb_id] = malloc(sizeof(PRACH_RESOURCES_t)); - //ue_cntl_delay[subframe%2].prach_id; - PHY_vars_UE_g[ue_id][CC_id]->prach_PreambleIndex = - ue_cntl_delay[ue_id][CC_id][last_slot%2].prach_id; - } - - pucch_format= ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_flag;// UE_transport_info[ue_id][CC_id].cntl.pucch_flag; - - if ((last_slot + 1) % 2 == 0) { - if (pucch_format == pucch_format1) { // UE_transport_info[ue_id][CC_id].cntl.sr; - PHY_vars_UE_g[ue_id][CC_id]->sr[subframe] = ue_cntl_delay[ue_id][CC_id][last_slot%2].sr; - } else if ((pucch_format == pucch_format1a) || - (pucch_format == pucch_format1b)) { - PHY_vars_UE_g[ue_id][CC_id]->pucch_payload[0] = ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_payload; - //UE_transport_info[ue_id][CC_id].cntl.pucch_payload; - } - - PHY_vars_UE_g[ue_id][CC_id]->pucch_sel[subframe] = - ue_cntl_delay[ue_id][CC_id][last_slot%2].pucch_sel; - } - -#ifdef DEBUG_EMU - LOG_D(EMU,"subframe %d trying to copy the payload from num eNB %d to UE %d \n", - subframe, UE_transport_info[ue_id][CC_id].num_eNB, ue_id); -#endif - - for (n_enb = 0; n_enb < UE_transport_info[ue_id][CC_id].num_eNB; n_enb++) { - - rnti = UE_transport_info[ue_id][CC_id].rnti[n_enb]; - enb_id = UE_transport_info[ue_id][CC_id].eNB_id[n_enb]; - - PHY_vars_UE_g[ue_id][CC_id]->pdcch_vars[0][enb_id]->crnti=rnti; - PHY_vars_UE_g[ue_id][CC_id]->pdcch_vars[1][enb_id]->crnti=rnti; - - harq_pid = UE_transport_info[ue_id][CC_id].harq_pid[n_enb]; - - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_RI[0] = - ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ri & 0x1; - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_RI[1] = - (ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ri>>1) & 0x1; - - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_ACK[0]= - ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ack & 0x1; - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o_ACK[1]= - (ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_ack>>1) & 0x1; - //*(uint32_t *)ulsch->o = ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_uci; - - if ((last_slot % 2) == 1) { - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->O = - ue_cntl_delay[ue_id][CC_id][last_slot%2].length_uci; - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->uci_format = - ue_cntl_delay[ue_id][CC_id][last_slot%2].uci_format; - - memcpy(PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->o, - ue_cntl_delay[ue_id][CC_id][last_slot%2].pusch_uci, - MAX_CQI_BYTES); - - ulsch = PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]; - // if (((HLC_subband_cqi_rank1_2A_5MHz *)ulsch->o)->cqi1) - LOG_D(EMU, - "[UE %d] subframe %d last slot %d copy the payload from eNB %d to UE %d with harq id %d cqi (val %d, length %d) \n", - ue_id, subframe, last_slot, enb_id, ue_id, harq_pid, - ((HLC_subband_cqi_rank1_2A_5MHz *)ulsch->o)->cqi1, - PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->O); - } - - memcpy(PHY_vars_UE_g[ue_id][CC_id]->ulsch[enb_id]->harq_processes[harq_pid]->b, - UE_transport_info[ue_id][CC_id].transport_blocks, - UE_transport_info[ue_id][CC_id].tbs[enb_id]); - - //ue_transport_info_index[enb_id]+=UE_transport_info[ue_id][CC_id].tbs[enb_id]; - - //UE_transport_info[ue_id][CC_id].transport_blocks+=ue_transport_info_index[enb_id]; - //LOG_T(EMU,"ulsch tbs is %d\n", UE_transport_info[ue_id][CC_id].tbs[enb_id]); - } -} diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index bc6990ac3e..03c834de77 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -33,34 +33,6 @@ #ifndef EMU_PROTO_H_ #define EMU_PROTO_H_ -void init_bypass (void); -void bypass_init ( unsigned int (*tx_handlerP) (unsigned char,char *, unsigned int *, unsigned int *),unsigned int (*rx_handlerP) (unsigned char,char *,unsigned int)); -int bypass_rx_data(unsigned int frame, unsigned int last_slot, - unsigned int next_slot, uint8_t is_master); -void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot, - unsigned int next_slot, uint8_t is_master); -void bypass_tx_data (emu_transport_info_t Type, unsigned int frame, unsigned int next_slot); - -void emulation_tx_rx(void); - -unsigned int emul_tx_handler(unsigned char Mode,char *Tx_buffer,unsigned int *Nbytes,unsigned int *Nb_flows); -unsigned int emul_rx_handler(unsigned char Mode,char *rx_buffer, unsigned int Nbytes); - -unsigned int emul_rx_data(void); - -void emu_transport_info(unsigned int last_slot, unsigned int next_slot); -void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot); -void fill_phy_ue_vars(unsigned int ue_id, uint8_t CC_id,unsigned int last_slot); -void emu_transport_sync(void); -void emu_transport(unsigned int frame, unsigned int last_slot,unsigned int next_slot, lte_subframe_t direction, unsigned char frame_type, int ethernet_flag ); -void emu_transport_DL(unsigned int frame, unsigned int last_slot,unsigned int next_slot); -void emu_transport_UL(unsigned int frame, unsigned int last_slot,unsigned int next_slot); -void emu_transport_release(void); - -int multicast_link_read_data_from_sock(uint8_t eNB_flag); - -void clear_eNB_transport_info(uint8_t); -void clear_UE_transport_info(uint8_t); int netlink_init(void); int netlink_init_tun(char *ifsuffix, int num_if, int id); int netlink_init_mbms_tun(char *ifsuffix, int id); From b2eb0f74b64769c252047da7a2c0d17243fe018a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 19:41:10 +0200 Subject: [PATCH 09/61] Remove unused code in openair3/UTILS: not used anywhere --- openair3/UTILS/Makefile.am | 22 ---- openair3/UTILS/mme_config.h | 178 ---------------------------- openair3/UTILS/mme_default_values.h | 127 -------------------- openair3/UTILS/mme_scanner.l | 130 -------------------- 4 files changed, 457 deletions(-) delete mode 100644 openair3/UTILS/Makefile.am delete mode 100644 openair3/UTILS/mme_config.h delete mode 100644 openair3/UTILS/mme_default_values.h delete mode 100644 openair3/UTILS/mme_scanner.l diff --git a/openair3/UTILS/Makefile.am b/openair3/UTILS/Makefile.am deleted file mode 100644 index 2e0e686086..0000000000 --- a/openair3/UTILS/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ - -SUBDIRS = . HASHTABLE - -AM_CFLAGS = @ADD_CFLAGS@ \ - -I$(top_srcdir)/COMMON \ - -I$(top_srcdir)/NAS/EURECOM-NAS/src/api/network \ - -I$(top_srcdir)/NAS/EURECOM-NAS/src/include \ - -I$(top_srcdir)/SGW-LITE \ - -I$(top_srcdir)/INTERTASK_INTERFACE - -AM_YFLAGS = -d - -noinst_LTLIBRARIES = libutils.la -libutils_la_LDFLAGS = -all-static -libutils_la_SOURCES = \ - conversions.h conversions.c \ - enum_string.h enum_string.c \ - log.c log.h \ - mme_config.c mme_config.h \ - mcc_mnc_itu.c mcc_mnc_itu.h \ - mme_default_values.h \ - queue.h tree.h diff --git a/openair3/UTILS/mme_config.h b/openair3/UTILS/mme_config.h deleted file mode 100644 index 0f6247e623..0000000000 --- a/openair3/UTILS/mme_config.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef __UTILS_MME_CONFIG__H__ -#define __UTILS_MME_CONFIG__H__ - -#include -#include - -#include "mme_default_values.h" - -#define MME_CONFIG_STRING_MME_CONFIG "MME" -#define MME_CONFIG_STRING_REALM "REALM" -#define MME_CONFIG_STRING_MAXENB "MAXENB" -#define MME_CONFIG_STRING_MAXUE "MAXUE" -#define MME_CONFIG_STRING_RELATIVE_CAPACITY "RELATIVE_CAPACITY" -#define MME_CONFIG_STRING_STATISTIC_TIMER "MME_STATISTIC_TIMER" -#define MME_CONFIG_STRING_EMERGENCY_ATTACH_SUPPORTED "EMERGENCY_ATTACH_SUPPORTED" -#define MME_CONFIG_STRING_UNAUTHENTICATED_IMSI_SUPPORTED "UNAUTHENTICATED_IMSI_SUPPORTED" - -#define MME_CONFIG_STRING_INTERTASK_INTERFACE_CONFIG "INTERTASK_INTERFACE" -#define MME_CONFIG_STRING_INTERTASK_INTERFACE_QUEUE_SIZE "ITTI_QUEUE_SIZE" - -#define MME_CONFIG_STRING_SCTP_CONFIG "SCTP" -#define MME_CONFIG_STRING_SCTP_INSTREAMS "SCTP_INSTREAMS" -#define MME_CONFIG_STRING_SCTP_OUTSTREAMS "SCTP_OUTSTREAMS" - - -#define MME_CONFIG_STRING_S1AP_CONFIG "S1AP" -#define MME_CONFIG_STRING_S1AP_OUTCOME_TIMER "S1AP_OUTCOME_TIMER" -#define MME_CONFIG_STRING_S1AP_PORT "S1AP_PORT" - -#define MME_CONFIG_STRING_GUMMEI_CONFIG "GUMMEI" -#define MME_CONFIG_STRING_MME_CODE "MME_CODE" -#define MME_CONFIG_STRING_MME_GID "MME_GID" -#define MME_CONFIG_STRING_TAI_LIST "TAI_LIST" -#define MME_CONFIG_STRING_MCC "MCC" -#define MME_CONFIG_STRING_MNC "MNC" -#define MME_CONFIG_STRING_TAC "TAC" - -#define MME_CONFIG_STRING_NETWORK_INTERFACES_CONFIG "NETWORK_INTERFACES" -#define MME_CONFIG_STRING_INTERFACE_NAME_FOR_S1_MME "MME_INTERFACE_NAME_FOR_S1_MME" -#define MME_CONFIG_STRING_IPV4_ADDRESS_FOR_S1_MME "MME_IPV4_ADDRESS_FOR_S1_MME" -#define MME_CONFIG_STRING_INTERFACE_NAME_FOR_S11_MME "MME_INTERFACE_NAME_FOR_S11_MME" -#define MME_CONFIG_STRING_IPV4_ADDRESS_FOR_S11_MME "MME_IPV4_ADDRESS_FOR_S11_MME" - -#define MME_CONFIG_STRING_ASN1_VERBOSITY "VERBOSITY" -#define MME_CONFIG_STRING_ASN1_VERBOSITY_NONE "none" -#define MME_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING "annoying" -#define MME_CONFIG_STRING_ASN1_VERBOSITY_INFO "info" - -#define MME_CONFIG_STRING_NAS_CONFIG "NAS" -#define MME_CONFIG_STRING_NAS_SUPPORTED_INTEGRITY_ALGORITHM_LIST "ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST" -#define MME_CONFIG_STRING_NAS_SUPPORTED_CIPHERING_ALGORITHM_LIST "ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST" -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA0 0b000 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA1 0b001 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA2 0b010 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA3 0b011 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA4 0b100 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA5 0b101 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA6 0b110 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EEA7 0b111 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA0 0b000 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA1 0b001 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA2 0b010 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA3 0b011 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA4 0b100 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA5 0b101 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA6 0b110 -#define NAS_CONFIG_SECURITY_ALGORITHMS_EIA7 0b111 - - - -typedef struct mme_config_s { - /* Reader/writer lock for this configuration */ - pthread_rwlock_t rw_lock; - - uint8_t verbosity_level; - - char *config_file; - char *realm; - int realm_length; - - uint32_t max_eNBs; - uint32_t max_ues; - - uint8_t relative_capacity; - - uint32_t mme_statistic_timer; - - uint8_t emergency_attach_supported; - uint8_t unauthenticated_imsi_supported; - - struct { - uint16_t nb_mme_gid; - uint16_t *mme_gid; - - uint16_t nb_mmec; - uint8_t *mmec; - - uint8_t nb_plmns; - uint16_t *plmn_mcc; - uint16_t *plmn_mnc; - uint16_t *plmn_mnc_len; - uint16_t *plmn_tac; - } gummei; - - struct { - uint16_t in_streams; - uint16_t out_streams; - } sctp_config; - struct { - uint16_t port_number; - } gtpv1u_config; - struct { - uint16_t port_number; - uint8_t outcome_drop_timer_sec; - } s1ap_config; - struct { - uint32_t sgw_ip_address_for_S1u_S12_S4_up; - - char *mme_interface_name_for_S1_MME; - uint32_t mme_ip_address_for_S1_MME; - - char *mme_interface_name_for_S11; - uint32_t mme_ip_address_for_S11; - - uint32_t sgw_ip_address_for_S11; - } ipv4; - struct { - uint32_t queue_size; - char *log_file; - } itti_config; - - struct { - uint8_t prefered_integrity_algorithm[8]; - uint8_t prefered_ciphering_algorithm[8]; - } nas_config; - - - -} mme_config_t; - -extern mme_config_t mme_config; - -int mme_config_find_mnc_length(const char mcc_digit1P, - const char mcc_digit2P, - const char mcc_digit3P, - const char mnc_digit1P, - const char mnc_digit2P, - const char mnc_digit3P); -int config_parse_opt_line(int argc, char *argv[], mme_config_t *mme_config); - -#define config_read_lock(mMEcONFIG) pthread_rwlock_rdlock(&(mMEcONFIG)->rw_lock) -#define config_write_lock(mMEcONFIG) pthread_rwlock_wrlock(&(mMEcONFIG)->rw_lock) -#define config_unlock(mMEcONFIG) pthread_rwlock_unlock(&(mMEcONFIG)->rw_lock) - -//int yyparse(struct mme_config_s *mme_config_p); - -#endif /* __UTILS_MME_CONFIG__H__ */ diff --git a/openair3/UTILS/mme_default_values.h b/openair3/UTILS/mme_default_values.h deleted file mode 100644 index de7ab6b62f..0000000000 --- a/openair3/UTILS/mme_default_values.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef MME_DEFAULT_VALUES_H_ -#define MME_DEFAULT_VALUES_H_ - -/******************************************************************************* - * Timer Constants - ******************************************************************************/ -#define MME_STATISTIC_TIMER_S (60) - -/******************************************************************************* - * GTPV1 User Plane Constants - ******************************************************************************/ -#define GTPV1_U_PORT_NUMBER (2152) - -/******************************************************************************* - * S1AP Constants - ******************************************************************************/ - -#define S1AP_PORT_NUMBER (36412) ///< S1AP SCTP IANA ASSIGNED Port Number -#define S1AP_SCTP_PPID (18) ///< S1AP SCTP Payload Protocol Identifier (PPID) - -#define S1AP_OUTCOME_TIMER_DEFAULT (5) ///< S1AP Outcome drop timer (s) - -/******************************************************************************* - * SCTP Constants - ******************************************************************************/ - -/* -#define SCTP_RECV_BUFFER_SIZE (1 << 16) -#define SCTP_OUT_STREAMS (32) -#define SCTP_IN_STREAMS (32) -#define SCTP_MAX_ATTEMPTS (5) -*/ -/******************************************************************************* - * MME global definitions - ******************************************************************************/ - -#define MAX_NUMBER_OF_ENB (2) -#define MAX_NUMBER_OF_UE (64) - -#define MMEC (0) -#define MMEGID (0) -#define PLMN_MCC (208) -#define PLMN_MNC (34) -#define PLMN_MNC_LEN (2) -#define PLMN_TAC (0) - -#define RELATIVE_CAPACITY (15) - -/******************************************************************************* - * IPv4 Constants - ******************************************************************************/ - -/* Default network card to use for IPV4 packets forwarding. - * up stands for user-plane. - * cp stands for control-plane - * - * +-----------+ +------+ +-----------+ - * | eNB +------+ | ovs | VLAN 1+------+ MME | - * | |cpenb0+------------------+cpmme0| | - * | +------+ |bridge| +------+ | - * | |upenb0+-------+ | | | - * +-----------+------+ | | | +-+------+--+ - * +---|--+ |s11mme| - * | +---+--+ - * | VLAN3 | (optional) - * | +---+--+ - * | |s11sgw| - * | +-+------+--+ - * | | S+P-GW | - * | VLAN2 +------+ +--------+ - * +----------+upsgw0| |pgwsgi0 + - * +------+ +--------+ - * | | - * +-----------+ - */ - -#define DEFAULT_SGW_INTERFACE_NAME_FOR_S11 ("s11sgw") -#define DEFAULT_SGW_IP_ADDRESS_FOR_S11 ("192.168.10.1") -#define DEFAULT_SGW_IP_NETMASK_FOR_S11 24 - -#define DEFAULT_SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ("upsgw0") -#define DEFAULT_SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP ("192.168.1.1") -#define DEFAULT_SGW_IP_NETMASK_FOR_S1U_S12_S4_UP 24 - -#define DEFAULT_SGW_INTERFACE_NAME_FOR_S5_S8_UP ("upsgw1") -#define DEFAULT_SGW_IP_ADDRESS_FOR_S5_S8_UP ("192.168.5.2") -#define DEFAULT_SGW_IP_NETMASK_FOR_S5_S8_UP 24 - -#define DEFAULT_PGW_INTERFACE_NAME_FOR_S5_S8 ("uppgw0") -#define DEFAULT_PGW_IP_ADDRESS_FOR_S5_S8 ("192.168.5.1") -#define DEFAULT_PGW_IP_NETMASK_FOR_S5_S8 24 - -#define DEFAULT_PGW_INTERFACE_NAME_FOR_SGI ("eth0") -#define DEFAULT_PGW_IP_ADDR_FOR_SGI ("192.168.14.17") -#define DEFAULT_PGW_IP_NETMASK_FOR_SGI 24 - -#define DEFAULT_MME_INTERFACE_NAME_FOR_S11 ("s11mme") ///< MME control plane interface -#define DEFAULT_MME_IP_ADDRESS_FOR_S11 ("192.168.10.2") ///< MME control plane IP address -#define DEFAULT_MME_IP_NETMASK_FOR_S11 24; - -#define DEFAULT_MME_INTERFACE_NAME_FOR_S1_MME ("cpmme0") ///< MME control plane interface -#define DEFAULT_MME_IP_ADDRESS_FOR_S1_MME ("192.168.11.1") ///< MME control plane IP address -#define DEFAULT_MME_IP_NETMASK_FOR_S1_MME 24; - - -#endif /* MME_DEFAULT_VALUES_H_ */ diff --git a/openair3/UTILS/mme_scanner.l b/openair3/UTILS/mme_scanner.l deleted file mode 100644 index 064a13f5f2..0000000000 --- a/openair3/UTILS/mme_scanner.l +++ /dev/null @@ -1,130 +0,0 @@ - -/* Lex configuration parser. - * - * This file defines the token for parsing the configuration file - * - * Note : This module is NOT thread-safe. All processing must be done from one thread only. - */ -%{ -#include - -#include "mme_config.h" -/* Include yacc tokens definitions */ -#include "mme_parser.h" - -/* Update the column information */ -#ifdef DEBUG_LEX -#define YY_USER_ACTION { \ - yylloc->first_column = yylloc->last_column + 1; \ - yylloc->last_column = yylloc->first_column + yyleng - 1; \ - TRACE_DEBUG(FULL, \ - "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \ - yylloc->first_line, yylloc->first_column, \ - yylloc->last_line, yylloc->last_column, \ - yy_act, yyleng, yytext); \ -} -#else /* DEBUG_LEX */ -#define YY_USER_ACTION { \ - yylloc->first_column = yylloc->last_column + 1; \ - yylloc->last_column = yylloc->first_column + yyleng - 1; \ -} -#endif - -#define YY_NO_INPUT -%} - -%option bison-bridge bison-locations -%option noyywrap -%option nounput - -/* Quoted string. Multilines do not match. */ -qstring \"[^\"\n]*\" - -%% - - /* List of patterns and actions */ - -<*>\n { - /* Update the line count */ - yylloc->first_line++; - yylloc->last_line++; - yylloc->last_column=0; -} - -<*>([[:space:]]{-}[\n])+ ; /* Eat all spaces, not new lines */ -<*>#.*$ ; /* Eat all comments */ - -{qstring} { - /* First copy the string without the quotes for use in the yacc parser */ - if ((yylval->string = strdup(yytext+1)) == NULL) { /* This allocates one useless tail char but... it's easier :D */ - return LEX_ERROR;/* on error, trig an error in yacc parser */ - } - yylval->string[yyleng-2] = '\0'; - - /* the yacc parser will check the string is valid */ - return QSTRING; -} - -[[:digit:]]+ { - /* Convert this to an integer value */ - int ret = sscanf(yytext, "%i", &yylval->integer); - if (ret != 1) { - /* No matching: an error occurred */ - fprintf(stderr, "Unable to convert the value '%s' to a valid number: %s\n", - yytext, strerror(errno)); - return LEX_ERROR; /* trig an error in yacc parser */ - /* Maybe we could REJECT instead of failing here? */ - } - return INTEGER; -} - - /* Full words tokens (keywords) */ -(?i:"EMERGENCY_ATTACH_SUPPORTED") { return EMERGENCY_ATTACH_SUPPORTED; } -(?i:"UNAUTHENTICATED_IMSI_SUPPORTED") { return UNAUTHENTICATED_IMSI_SUPPORTED; } -(?i:"MAXENB") { return MAX_ENB; } -(?i:"MAXUE") { return MAX_UE; } -(?i:"S6A_CONF") { return S6A_CONF; } -(?i:"ITTI_QUEUE_SIZE") { return ITTI_QUEUE_SIZE; } -(?i:"SCTP_INSTREAMS") { return SCTP_INSTREAMS; } -(?i:"SCTP_OUTSTREAMS") { return SCTP_OUTSTREAMS; } -(?i:"MME_CODE") { return MME_CODE; } -(?i:"MME_GID") { return MME_GID; } -(?i:"REALM") { return REALM; } -(?i:"PLMN") { return PLMN_Y; } -(?i:"RELATIVE_CAPACITY") { return RELATIVE_CAP; } -(?i:"S1AP_OUTCOME_TIMER") { return S1AP_OUTCOME_TIMER; } -(?i:"MME_STATISTIC_TIMER") { return MME_STATISTIC_TIMER; } -(?i:"SGW_INTERFACE_NAME_FOR_S11") { return SGW_INTERFACE_NAME_FOR_S11; } -(?i:"SGW_IP_ADDRESS_FOR_S11") { return SGW_IP_ADDRESS_FOR_S11; } -(?i:"SGW_IP_NETMASK_FOR_S11") { return SGW_IP_NETMASK_FOR_S11; } -(?i:"SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP") { return SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP; } -(?i:"SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP") { return SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP; } -(?i:"SGW_IP_NETMASK_FOR_S1U_S12_S4_UP") { return SGW_IP_NETMASK_FOR_S1U_S12_S4_UP; } -(?i:"SGW_INTERFACE_NAME_FOR_S5_S8_UP") { return SGW_INTERFACE_NAME_FOR_S5_S8_UP; } -(?i:"SGW_IP_ADDRESS_FOR_S5_S8_UP") { return SGW_IP_ADDRESS_FOR_S5_S8_UP; } -(?i:"SGW_IP_NETMASK_FOR_S5_S8_UP") { return SGW_IP_NETMASK_FOR_S5_S8_UP; } -(?i:"PGW_INTERFACE_NAME_FOR_S5_S8") { return PGW_INTERFACE_NAME_FOR_S5_S8; } -(?i:"PGW_IP_ADDRESS_FOR_S5_S8") { return PGW_IP_ADDRESS_FOR_S5_S8; } -(?i:"PGW_IP_NETMASK_FOR_S5_S8") { return PGW_IP_NETMASK_FOR_S5_S8; } -(?i:"PGW_INTERFACE_NAME_FOR_SGI") { return PGW_INTERFACE_NAME_FOR_SGI; } -(?i:"PGW_IP_ADDR_FOR_SGI") { return PGW_IP_ADDR_FOR_SGI; } -(?i:"PGW_IP_NETMASK_FOR_SGI") { return PGW_IP_NETMASK_FOR_SGI; } -(?i:"MME_INTERFACE_NAME_FOR_S1_MME") { return MME_INTERFACE_NAME_FOR_S1_MME; } -(?i:"MME_IP_ADDRESS_FOR_S1_MME") { return MME_IP_ADDRESS_FOR_S1_MME; } -(?i:"MME_IP_NETMASK_FOR_S1_MME") { return MME_IP_NETMASK_FOR_S1_MME; } -(?i:"MME_INTERFACE_NAME_FOR_S11_MME") { return MME_INTERFACE_NAME_FOR_S11_MME; } -(?i:"MME_IP_ADDRESS_FOR_S11_MME") { return MME_IP_ADDRESS_FOR_S11_MME; } -(?i:"MME_IP_NETMASK_FOR_S11_MME") { return MME_IP_NETMASK_FOR_S11_MME; } - - /* Valid single characters for yyparse */ -<*>[.=,:;{}] { return yytext[0]; } - -<*>[[:alnum:]]+ | /* This rule is only useful to print a complete token in error messages */ - /* Unrecognized character */ -<*>. { - fprintf(stderr, "Unrecognized text on line %d col %d: '%s'.\n", - yylloc->first_line, yylloc->first_column, yytext); - return LEX_ERROR; -} - -%% From 7ddba3627928da10975c19e08559fe6a3160d384 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 19:56:45 +0200 Subject: [PATCH 10/61] Remove unused code in ETH_TRANSPORT/{socket,multicast_link}.{ch} --- CMakeLists.txt | 2 - doc/Doxyfile | 4 - executables/lte-ue.c | 27 +- openair1/PHY/LTE_UE_TRANSPORT/sldch.c | 9 +- openair1/PHY/LTE_UE_TRANSPORT/slsch.c | 9 +- .../SIMULATION/ETH_TRANSPORT/multicast_link.c | 329 ------------------ .../SIMULATION/ETH_TRANSPORT/multicast_link.h | 66 ---- openair1/SIMULATION/ETH_TRANSPORT/socket.c | 109 ------ openair1/SIMULATION/ETH_TRANSPORT/socket.h | 46 --- openair1/SIMULATION/LTE_PHY/dummy_functions.c | 2 - 10 files changed, 9 insertions(+), 594 deletions(-) delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/multicast_link.h delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/socket.c delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/socket.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ae49fdecb..faaacaa9ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1887,8 +1887,6 @@ target_include_directories(SIMU PUBLIC ${OPENAIR1_DIR}/SIMULATION/TOOLS ${OPENAI add_library(SIMU_ETH STATIC ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c - ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c - ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ) target_link_libraries(SIMU_ETH PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) diff --git a/doc/Doxyfile b/doc/Doxyfile index 72c03efe96..55c2246740 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -2309,11 +2309,7 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/proto.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/multicast_link.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/socket.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/socket.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/adc.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/dac.c \ diff --git a/executables/lte-ue.c b/executables/lte-ue.c index 6c5cfd3f32..ee51346f46 100644 --- a/executables/lte-ue.c +++ b/executables/lte-ue.c @@ -80,11 +80,6 @@ void init_UE_threads_stub(int); void init_UE_single_thread_stub(int); void *UE_thread(void *arg); int init_timer_thread(void); -extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), - unsigned char _multicast_group, - char *multicast_ifname); -extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); - int tx_req_num_elems; extern uint16_t sf_ahead; @@ -364,10 +359,9 @@ void init_UE_stub_single_thread(int nb_inst, init_UE_single_thread_stub(nb_inst); printf("UE threads created \n"); - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { - LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - multicast_link_start(ue_stub_rx_handler,0,emul_iface); - } + AssertFatal(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF, + "unsupported NFAPI mode %d\n", + NFAPI_MODE); } void init_UE_standalone_thread(int ue_idx) { @@ -408,8 +402,9 @@ void init_UE_stub(int nb_inst, printf("UE threads created \n"); LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) - multicast_link_start(ue_stub_rx_handler,0,emul_iface); + AssertFatal(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF, + "unsupported NFAPI mode %d\n", + NFAPI_MODE); } @@ -2356,15 +2351,7 @@ static void *timer_thread( void *param ) { } nanosleep(&t_sleep, (struct timespec *)NULL); - UE_tport_t pdu; - pdu.header.packet_type = TTI_SYNC; - pdu.header.absSF = (timer_frame*10)+timer_subframe; - - if (NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) { - multicast_link_write_sock(0, - (char *)&pdu, - sizeof(UE_tport_header_t)); - } + AssertFatal(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF, "unsupported NFAPI mode %d\n", NFAPI_MODE); } else { wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread"); release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread"); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/sldch.c b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c index 8769d5f81b..2f7f652b5d 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/sldch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c @@ -31,8 +31,6 @@ */ #include "PHY/defs_UE.h" -extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); - void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx) { UE_tport_t pdu; @@ -54,10 +52,5 @@ void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx) sldch->payload_length, sldch_header_len+sizeof(SLDCH_t)-sizeof(uint8_t*)+sldch->payload_length); - multicast_link_write_sock(0, - (char *)&pdu, - sldch_header_len+sizeof(SLDCH_t)); - + AssertFatal(false, "multicast_link_write_sock() not implemented\n"); } - - diff --git a/openair1/PHY/LTE_UE_TRANSPORT/slsch.c b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c index e4e94a232d..8dda31fbe4 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/slsch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c @@ -31,10 +31,6 @@ */ #include "PHY/defs_UE.h" -extern int -multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); - - void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slsch,int frame_tx,int subframe_tx) { UE_tport_t pdu; @@ -58,9 +54,6 @@ void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slsch,int frame_tx,int subframe_tx) slsch->payload_length, slsch_header_len+sizeof(SLSCH_t)-sizeof(uint8_t*)+slsch->payload_length); - multicast_link_write_sock(0, - (char *)&pdu, - slsch_header_len+sizeof(SLSCH_t)-sizeof(uint8_t*)+slsch->payload_length); - + AssertFatal(false, "multicast_link_write_sock() not implemented\n"); } } diff --git a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c deleted file mode 100644 index 281d42a7a6..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file multicast_link.c - * \brief - * \author Lionel Gauthier and Navid Nikaein - * \date 2011 - * \version 1.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define MULTICAST_LINK_C - -#include "socket.h" -#include "multicast_link.h" - -#include "common/utils/LOG/log.h" - -extern unsigned short Master_id; - -const char *multicast_group_list[MULTICAST_LINK_NUM_GROUPS] = { - "239.0.0.161", - "239.0.0.162", - "239.0.0.163", - "239.0.0.164" -}; - -static multicast_group_t group_list[MULTICAST_LINK_NUM_GROUPS]; - -/* Socket file descriptors we want to wake up for, using select() */ -static fd_set socks; -/* Highest #'d file descriptor, needed for select() */ -static int highsock; -#if ! defined(ENABLE_NEW_MULTICAST) -static pthread_t main_loop_thread; -#endif -static void (*rx_handler) (unsigned int, char *); -static unsigned char multicast_group; -static char *multicast_if; - -//------------------------------------------------------------------------------ -void -multicast_link_init(void) -{ - //------------------------------------------------------------------------------ - int group; - int multicast_loop; - int reuse_addr = 1; - static struct ip_mreq command; - struct sockaddr_in sin; - // struct ifreq ifr; - - for (group = 0; group < MULTICAST_LINK_NUM_GROUPS; group++) { - //strcpy (group_list[group].host_addr, multicast_group_list[group]); - strncpy (group_list[group].host_addr, multicast_group_list[group], sizeof(group_list[group].host_addr)); - group_list[group].host_addr[sizeof(group_list[group].host_addr) - 1] = 0; // terminate string - group_list[group].port = 46014 + group; - group_list[group].socket = make_socket_inet( - SOCK_DGRAM, - &group_list[group].port, &sin); - - LOG_D(PHY, "multicast_link_init(): Created socket %d for group %d, port %d\n", - group_list[group].socket,group,group_list[group].port); - - /* Used so we can re-bind to our port while a previous connection is still - * in TIME_WAIT state. - */ - if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR, - &reuse_addr, sizeof (reuse_addr)) < 0) { - LOG_E(PHY, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ..."); - exit (EXIT_FAILURE); - } - - if (multicast_if != NULL) { - if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE, - multicast_if, strlen(multicast_if)) < 0) { - LOG_E(PHY, - "[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n", - multicast_if); - LOG_E(PHY, - "[MULTICAST] make sure that you have a root privilage or run with sudo -E \n"); - exit (EXIT_FAILURE); - } - } - -#if !defined(ENABLE_NEW_MULTICAST) - /* Make the socket blocking */ - socket_setnonblocking(group_list[group].socket); -#endif - - multicast_loop = 0; - - if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP, - &multicast_loop, sizeof (multicast_loop)) < 0) { - LOG_E(PHY, - "[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m", - __FILE__, __LINE__); - exit (EXIT_FAILURE); - } - - // Join the broadcast group: - command.imr_multiaddr.s_addr = inet_addr (group_list[group].host_addr); - command.imr_interface.s_addr = htonl (INADDR_ANY); - - if (command.imr_multiaddr.s_addr == -1) { - LOG_E(PHY, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__); - exit (EXIT_FAILURE); - } - - if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, - &command, sizeof (command)) < 0) { - LOG_E(PHY, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__, - __LINE__); - exit (EXIT_FAILURE); - } - - memset (&group_list[group].sock_remote_addr, 0, sizeof (struct sockaddr_in)); - group_list[group].sock_remote_addr.sin_family = AF_INET; - group_list[group].sock_remote_addr.sin_addr.s_addr = inet_addr (multicast_group_list[group]); - group_list[group].sock_remote_addr.sin_port = htons (group_list[group].port); - } -} - -//------------------------------------------------------------------------------ -void -multicast_link_build_select_list (void) -{ - //------------------------------------------------------------------------------ - int group; - - /* First put together fd_set for select(), which will - consist of the sock veriable in case a new connection - is coming in, plus all the sockets we have already - accepted. */ - - - /* FD_ZERO() clears out the fd_set called socks, so that - it doesn't contain any file descriptors. */ - - FD_ZERO (&socks); - - - /* Loops through all the possible connections and adds - those sockets to the fd_set */ - - for (group = 0; group < MULTICAST_LINK_NUM_GROUPS; group++) { - if (group_list[group].socket != 0) { - FD_SET (group_list[group].socket, &socks); - - if (group_list[group].socket > highsock) { - highsock = group_list[group].socket; - } - } - } -} - -void -multicast_link_read_data (int groupP) -{ - int num_bytes; - - if ((groupP < MULTICAST_LINK_NUM_GROUPS) && (groupP >= 0)) { - if ((num_bytes = recvfrom (group_list[groupP].socket, - group_list[groupP].rx_buffer, 40000, 0, 0, 0)) < 0) { - LOG_E(PHY, "[MULTICAST] recvfrom has failed (%d:%s)\n (%s:%d)\n", - errno, strerror(errno), __FILE__, __LINE__); - } else { - rx_handler(num_bytes,group_list[groupP].rx_buffer); - } - } else { - LOG_E(PHY, "[MULTICAST] ERROR: groupP out of bounds %d\n", groupP); - } -} - -//------------------------------------------------------------------------------ -void -multicast_link_read (void) -{ - //------------------------------------------------------------------------------ - int group; /* Current item in connectlist for for loops */ - - /* Now check connectlist for available data */ - - /* Run through our sockets and check to see if anything - happened with them, if so 'service' them. */ - - for (group = multicast_group; group < MULTICAST_LINK_NUM_GROUPS ; group++) { - if (FD_ISSET (group_list[group].socket, &socks)) { - multicast_link_read_data (group); - break; - } - } /* for (all entries in queue) */ -} - -//------------------------------------------------------------------------------ -int -multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP) -{ - //------------------------------------------------------------------------------ - int num; - - if ((num = sendto (group_list[groupP].socket, dataP, sizeP, 0, - (struct sockaddr *) &group_list[groupP].sock_remote_addr, - sizeof (group_list[groupP].sock_remote_addr))) < 0) { - LOG_E(PHY, "[MULTICAST] sendto has failed (%d:%s)\n (%s:%d)\n", - errno, strerror(errno), - __FILE__, __LINE__); - } - - return num; -} - -int multicast_link_read_data_from_sock(uint8_t is_master) -{ - struct timeval timeout, *timeout_p; - int readsocks; /* Number of sockets ready for reading */ - - timeout.tv_sec = 0; - timeout.tv_usec = 15000; - - if (is_master == 0) { - /* UE will block indefinetely if no data is sent from eNB - * NOTE: a NULL timeout for select will block indefinetely - */ - timeout_p = NULL; - } else { - /* In case of eNB set the timeout to 500 usecs after which we consider - * the packets as dropped. - */ - timeout_p = &timeout; - } - - highsock = -1; - - multicast_link_build_select_list (); - - LOG_D(PHY, "Stuck on select with timeout %s\n", - timeout_p == NULL ? "infinite" : "15000 usecs"); - - readsocks = select(highsock + 1, &socks, (fd_set *) 0, (fd_set *) 0, timeout_p); - - if (readsocks < 0) { - LOG_E(PHY, "Multicast select failed (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } else if (readsocks > 0) { - multicast_link_read(); - } else { - /* Timeout */ - LOG_I(PHY, "Multicast select time-out\n"); - return 1; - } - - return 0; -} - -void* multicast_link_main_loop (void *param) -{ - while (1) { - multicast_link_read_data_from_sock(0); - } - - return NULL; -} - -void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), - unsigned char _multicast_group, char *multicast_ifname) -{ - rx_handler = rx_handlerP; - multicast_group = _multicast_group; - multicast_if = multicast_ifname; - LOG_I(PHY, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n", - (multicast_if == NULL) ? "not specified" : multicast_if, multicast_group, - rx_handler); - multicast_link_init (); -#if ! defined(ENABLE_NEW_MULTICAST) - LOG_D(PHY, "[MULTICAST] multicast link start thread\n"); - - if (pthread_create (&main_loop_thread, NULL, multicast_link_main_loop, - NULL) != 0) { - LOG_E(PHY, "[MULTICAST LINK] Error in pthread_create (%d:%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } else { - pthread_detach(main_loop_thread); // disassociate from parent - LOG_I(PHY, "[MULTICAST LINK] Thread detached\n"); - } - -#endif -} diff --git a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.h b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.h deleted file mode 100644 index fdea20455b..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file multicast_link.h - * \brief - * \author Lionel Gauthier and Navid Nikaein - * \date 2011 - * \version 1.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - -#ifndef __MULTICAST_LINK_H__ -# define __MULTICAST_LINK_H__ -# ifdef MULTICAST_LINK_C -# define private_multicast_link(x) x -# define public_multicast_link(x) x -# else -# define private_multicast_link(x) -# define public_multicast_link(x) extern x -# endif -# include "stdint.h" - -private_multicast_link (typedef struct multicast_group_t { - int socket; - struct sockaddr_in sock_remote_addr; - char host_addr[16]; - uint16_t port; - char rx_buffer[40000]; -} multicast_group_t;) - -#define MULTICAST_LINK_NUM_GROUPS 4 - -extern const char *multicast_group_list[MULTICAST_LINK_NUM_GROUPS]; - -private_multicast_link(void multicast_link_init (void)); -private_multicast_link(void multicast_link_read_data (int groupP)); -private_multicast_link(void multicast_link_read (void)); -private_multicast_link(void *multicast_link_main_loop (void *param)); - -public_multicast_link(int multicast_link_write_sock (int groupP, char *dataP, uint32_t sizeP)); -public_multicast_link(void multicast_link_start ( void (*rx_handlerP) (unsigned int, char*), unsigned char multicast_group, char * multicast_ifname)); -# ifdef BYPASS_PHY -public_multicast_link(pthread_mutex_t Bypass_phy_wr_mutex); -public_multicast_link(pthread_cond_t Bypass_phy_wr_cond); -public_multicast_link(char Bypass_phy_wr); -# endif //BYPASS_PHY -#endif diff --git a/openair1/SIMULATION/ETH_TRANSPORT/socket.c b/openair1/SIMULATION/ETH_TRANSPORT/socket.c deleted file mode 100644 index 2b28a66170..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/socket.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file socket.c -* \brief -* \author Lionel Gauthier -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -*/ - -#include -#include -#include -#include -//#include -#include -#include -#include - -#define SOCKET_C -//#include "openair_defs.h" -#include "socket.h" - -#define msg printf -//------------------------------------------------------------------------------ -void -socket_setnonblocking (int sockP) -{ - //------------------------------------------------------------------------------ - - int opts; - - opts = fcntl (sockP, F_GETFL); - - if (opts < 0) { - perror ("fcntl(F_GETFL)"); - exit (EXIT_FAILURE); - } - - opts = (opts | O_NONBLOCK); - - if (fcntl (sockP, F_SETFL, opts) < 0) { - perror ("fcntl(F_SETFL)"); - exit (EXIT_FAILURE); - } - - return; -} - -//------------------------------------------------------------------------------ -int -make_socket_inet (int typeP, uint16_t * portP, struct sockaddr_in *ptr_addressP) -{ - //------------------------------------------------------------------------------ - - int sock; - unsigned int length = sizeof (struct sockaddr_in); - struct sockaddr_in name; - - - assert ((typeP == SOCK_STREAM) || (typeP == SOCK_DGRAM)); - - /* Create the socket. */ - sock = socket (PF_INET, typeP, 0); - - if (sock < 0) { - fprintf (stderr, "ERROR: %s line %d socket %m", __FILE__, __LINE__); - exit (EXIT_FAILURE); - } - - /* Give the socket a name. */ - name.sin_family = AF_INET; - name.sin_port = htons (*portP); - name.sin_addr.s_addr = htonl (INADDR_ANY); - - if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) { - close (sock); - fprintf (stderr, "ERROR: %s line %d bind port %d %m", __FILE__, __LINE__, *portP); - exit (EXIT_FAILURE); - } - - if (ptr_addressP != NULL) { - getsockname (sock, (struct sockaddr *) ptr_addressP, &length); - } - - msg("[SOCKET] bound socket port %d\n", *portP); - return sock; -} - diff --git a/openair1/SIMULATION/ETH_TRANSPORT/socket.h b/openair1/SIMULATION/ETH_TRANSPORT/socket.h deleted file mode 100644 index e9ca36bee2..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/socket.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file socket.h -* \brief -* \author Lionel Gauthier -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -*/ - -#ifndef __SIMULATION_ETH_TRANSPORT_SOCKET__H__ -#define __SIMULATION_ETH_TRANSPORT_SOCKET__H__ - -# ifdef SOCKET_C -# define private_socket(x) x -# define public_socket(x) x -# else -# define private_socket(x) -# define public_socket(x) extern x -# endif -# include "stdint.h" -public_socket (void socket_setnonblocking (int sockP); - ) -public_socket (int make_socket_inet (int typeP, uint16_t * portP, struct sockaddr_in *ptr_addressP); - ) -#endif diff --git a/openair1/SIMULATION/LTE_PHY/dummy_functions.c b/openair1/SIMULATION/LTE_PHY/dummy_functions.c index fcbab51f4b..fd682d2f78 100644 --- a/openair1/SIMULATION/LTE_PHY/dummy_functions.c +++ b/openair1/SIMULATION/LTE_PHY/dummy_functions.c @@ -47,8 +47,6 @@ SLDCH_t *ue_get_sldch(module_id_t module_idP, int CC_id,frame_t frameP, sub_fram SLSCH_t *ue_get_slsch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe) {return(NULL);} -void multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP) {} - uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, From 3d7ab0ebc6043a1b784c08e08069311285c0a831 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 12 Jul 2024 16:17:40 +0200 Subject: [PATCH 11/61] Remove unused SIMULATION/ETH_TRANSPORT/defs.h --- doc/Doxyfile | 1 - openair1/PHY/defs_nr_UE.h | 1 - openair1/SIMULATION/ETH_TRANSPORT/defs.h | 144 ---------------------- openair1/SIMULATION/ETH_TRANSPORT/proto.h | 2 - 4 files changed, 148 deletions(-) delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/defs.h diff --git a/doc/Doxyfile b/doc/Doxyfile index 55c2246740..4777455bfc 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -2310,7 +2310,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/proto.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/adc.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/dac.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/rf.h \ diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 93a4ee8b94..43209b244d 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -685,5 +685,4 @@ typedef struct LDPCDecode_ue_s { UE_nr_rxtx_proc_t proc; } ldpcDecode_ue_t; -#include "SIMULATION/ETH_TRANSPORT/defs.h" #endif diff --git a/openair1/SIMULATION/ETH_TRANSPORT/defs.h b/openair1/SIMULATION/ETH_TRANSPORT/defs.h deleted file mode 100644 index 384f25e950..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/defs.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file defs.h - * \brief specifies the data structure and variable for phy emulation - * \author Navid Nikaein, Raymomd Knopp and Hicham Anouar - * \date 2011 - * \version 1.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - -#ifndef __BYPASS_SESSION_LAYER_DEFS_H__ -# define __BYPASS_SESSION_LAYER_DEFS_H__ -//----------------------------------------------------------------------------- -//#include "openair_defs.h" -#include "common/openairinterface5g_limits.h" -#include "PHY/defs_common.h" -#include "PHY/LTE_TRANSPORT/uci_common.h" - -typedef enum emu_transport_info_e { - EMU_TRANSPORT_INFO_ERROR = 0x0, - EMU_TRANSPORT_INFO_WAIT_PM, - EMU_TRANSPORT_INFO_WAIT_SM, - EMU_TRANSPORT_INFO_SYNC, - EMU_TRANSPORT_INFO_ENB, - EMU_TRANSPORT_INFO_UE, - EMU_TRANSPORT_INFO_RELEASE -} emu_transport_info_t; - -#define WAIT_PM_TRANSPORT 1 -#define WAIT_SM_TRANSPORT 2 -#define SYNC_TRANSPORT 3 -#define ENB_TRANSPORT 4 -#define UE_TRANSPORT 5 -#define RELEASE_TRANSPORT 6 - -#define WAIT_SYNC_TRANSPORT 1 -#define SYNCED_TRANSPORT 2 -//#define WAIT_ENB_TRANSPORT 2 -//#define WAIT_UE_TRANSPORT 3 - - -#define BYPASS_RX_BUFFER_SIZE 64000 -#define BYPASS_TX_BUFFER_SIZE 64000 - -typedef unsigned int (*tx_handler_t) (unsigned char, char*, unsigned int*, unsigned int*); -typedef unsigned int (*rx_handler_t) (unsigned char, char*, unsigned int); - -/*************************************************************/ - -typedef struct eNB_cntl_s { - uint32_t pbch_flag:1; - uint32_t pmch_flag:1; - uint32_t pss:2; - uint32_t sss:8; - uint32_t cfi:2; - uint32_t phich:19; // max 200 bit - // uint32_t pbch_payload:24; - uint32_t pbch_payload; -} eNB_cntl; - -typedef struct UE_cntl_s { - uint8_t pucch_flag:3; // 0,7 = none, 1 = type 1, 2=type 1a, 3=type 1b, 4=type 2, 5=type 2a, 6=type 2b - uint8_t pucch_Ncs1:3; // physical configuration of pucch, for abstraction purposes - uint32_t pucch_payload:21; // ack/nak/cqi information - uint8_t sr:1; - uint8_t pusch_flag:1; // 0=none,1=active - uint8_t pucch_sel:1; - //uint32_t pusch_uci; // uci information on pusch - uint8_t pusch_uci[MAX_CQI_BYTES]; - uint8_t uci_format; - uint8_t length_uci; - uint8_t pusch_ri:2; // ri information on pusch - uint8_t pusch_ack:2; // ack/nak on pusch - uint8_t prach_flag:1; // 0=none,1=active - uint8_t prach_id:6; // this is the PHY preamble index for the prach -} UE_cntl; - -#define MAX_TRANSPORT_BLOCKS_BUFFER_SIZE 16384 -//#define MAX_PMCH_TRANSPORT_BLOCKS_BUFFER_SIZE 8192 // 16384 -#define MAX_NUM_DCI 5+1 // +1: for PMCH/MCH - -typedef struct eNB_transport_info_s { - eNB_cntl cntl; - uint8_t num_pmch; - uint8_t num_common_dci; - uint8_t num_ue_spec_dci; - DCI_ALLOC_t dci_alloc[MAX_NUM_DCI]; - uint8_t dlsch_type[MAX_NUM_DCI]; - uint8_t harq_pid[MAX_NUM_DCI]; - uint8_t ue_id[MAX_NUM_DCI]; - uint16_t tbs[MAX_NUM_DCI*2]; // times 2 for dual-stream MIMO formats - uint8_t transport_blocks[MAX_TRANSPORT_BLOCKS_BUFFER_SIZE]; - //uint8_t pmch_transport_blocks[MAX_PMCH_TRANSPORT_BLOCKS_BUFFER_SIZE]; -} __attribute__((__packed__)) eNB_transport_info_t ; - -typedef struct UE_transport_info_s { - UE_cntl cntl; - uint8_t num_eNB; - uint16_t rnti[NUMBER_OF_CONNECTED_eNB_MAX]; - uint8_t eNB_id[NUMBER_OF_CONNECTED_eNB_MAX]; - uint8_t harq_pid[NUMBER_OF_CONNECTED_eNB_MAX]; - uint16_t tbs[NUMBER_OF_CONNECTED_eNB_MAX]; - uint8_t transport_blocks[MAX_TRANSPORT_BLOCKS_BUFFER_SIZE];//*NUMBER_OF_CONNECTED_eNB_MAX]; -} __attribute__((__packed__)) UE_transport_info_t ; - -/*! \brief */ -typedef struct bypass_msg_header_s { - unsigned char Message_type; /*! \brief control or data*/ - //unsigned char nb_master; /*! \brief */ - unsigned char master_id; /*! \brief */ - unsigned int nb_enb; /*! \brief */ - unsigned int nb_ue; /*! \brief */ - unsigned int nb_flow; /*! \brief */ - unsigned int frame; - unsigned int subframe; - uint64_t seq_num; - unsigned int failing_master_id; -} __attribute__((__packed__)) bypass_msg_header_t; - -typedef struct bypass_proto2multicast_header_s { - unsigned int size; -} bypass_proto2multicast_header_t; - -#endif /* __BYPASS_SESSION_LAYER_DEFS_H__ */ diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 03c834de77..4c51dea523 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -28,8 +28,6 @@ * \email: navid.nikaein@eurecom.fr */ -#include "SIMULATION/ETH_TRANSPORT/defs.h" - #ifndef EMU_PROTO_H_ #define EMU_PROTO_H_ From e50978e7de554373537c41ff9f8a93129029ed9f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 12 Jul 2024 16:28:54 +0200 Subject: [PATCH 12/61] 4G RLC/PDCP interface: remove function pointers Remove function pointers that were used in the past to implement the F1(-U) interface in 4G, i.e., to have different functions to handle split/monolithic operations. As we don't have F1 in 4G anymore (see commit 9dc2282249d1ae57b4c67af4a7778ed17ca7b415), we don't need the function pointers anymore. On that occasion, rename the 5G functions by prepending nr_ to them; this allows to refactor the interface in 5G further (which is not the focus of this changeset). --- executables/lte-softmodem.c | 3 -- executables/lte-uesoftmodem.c | 2 - executables/nr-uesoftmodem.c | 2 - openair2/F1AP/f1ap_cu_rrc_message_transfer.c | 17 ++++----- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 31 +++++++-------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 40 ++++++-------------- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 28 +++++--------- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h | 16 ++++---- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 2 +- openair2/LAYER2/rlc_v2/rlc_oai_api.c | 2 +- 10 files changed, 51 insertions(+), 92 deletions(-) diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index a895b7b614..c3bc90c175 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -416,9 +416,6 @@ static void init_pdcp(void) pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_W_MBMS_BIT; pdcp_module_init(pdcp_initmask, 0); - - pdcp_set_rlc_data_req_func(rlc_data_req); - pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } static void wait_nfapi_init(char *thread_name) { diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index fa32d877f6..0754e1a239 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -498,8 +498,6 @@ static void init_pdcp(int ue_id) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; pdcp_module_init(pdcp_initmask, ue_id); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } // Stupid function addition because UE itti messages queues definition is common with eNB diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 105ffdbbaa..76d91bf800 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -340,8 +340,6 @@ static void init_pdcp(int ue_id) } nr_pdcp_layer_init(false); nr_pdcp_module_init(pdcp_initmask, ue_id); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } // Stupid function addition because UE itti messages queues definition is common with eNB diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index 224a98ebde..8ccca9f478 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -279,14 +279,13 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, sctp_assoc_t assoc_id uint8_t *mb = malloc16(ie->value.choice.RRCContainer.size); memcpy(mb, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); LOG_D(F1AP, "Calling pdcp_data_ind for UE RNTI %lx srb_id %lu with size %ld (DCCH) \n", ctxt.rntiMaybeUEid, srb_id, ie->value.choice.RRCContainer.size); - //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - // printf("%02x ", mb->data[i]); - //printf("\n"); - pdcp_data_ind (&ctxt, - 1, // srb_flag - 0, // embms_flag - srb_id, - ie->value.choice.RRCContainer.size, - mb, NULL, NULL); + nr_pdcp_data_ind(&ctxt, + 1, // srb_flag + 0, // embms_flag + srb_id, + ie->value.choice.RRCContainer.size, + mb, + NULL, + NULL); return 0; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 28cd37f3af..c45171caaa 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -113,7 +113,7 @@ struct sockaddr_in prose_ctrl_addr; struct sockaddr_in prose_pdcp_addr; struct sockaddr_in pdcp_sin; /* pdcp module parameters and related functions*/ -static pdcp_params_t pdcp_params= {0,NULL}; +static pdcp_params_t pdcp_params = {0}; rnti_t pdcp_UE_UE_module_id_to_rnti[MAX_MOBILES_PER_ENB]; rnti_t pdcp_eNB_UE_instance_to_rnti[MAX_MOBILES_PER_ENB]; // for noS1 mode unsigned int pdcp_eNB_UE_instance_to_rnti_index; @@ -298,8 +298,8 @@ bool pdcp_data_req(protocol_ctxt_t *ctxt_pP, LOG_UI(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %ld \n", srb_flagP, rb_idP); } - rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, - confirmP, sdu_buffer_sizeP, pdcp_pdu_p,NULL,NULL); + rlc_status = + rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p, NULL, NULL); } else { rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; LOG_E(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", @@ -467,9 +467,16 @@ bool pdcp_data_req(protocol_ctxt_t *ctxt_pP, if ((pdcp_pdu_p!=NULL) && (srb_flagP == 0) && (ctxt_pP->enb_flag == 1)) { LOG_D(PDCP, "pdcp data req on drb %ld, size %d, rnti %lx\n", rb_idP, pdcp_pdu_size, ctxt_pP->rntiMaybeUEid); - rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, - confirmP, pdcp_pdu_size, pdcp_pdu_p,sourceL2Id, - destinationL2Id); + rlc_status = rlc_data_req(ctxt_pP, + srb_flagP, + MBMS_FLAG_NO, + rb_idP, + muiP, + confirmP, + pdcp_pdu_size, + pdcp_pdu_p, + sourceL2Id, + destinationL2Id); ret = false; switch (rlc_status) { case RLC_OP_STATUS_OK: @@ -2279,18 +2286,6 @@ void rrc_pdcp_config_req ( } } -pdcp_data_ind_func_t get_pdcp_data_ind_func() { - return pdcp_params.pdcp_data_ind_func; -} - -void pdcp_set_rlc_data_req_func(send_rlc_data_req_func_t send_rlc_data_req) { - pdcp_params.send_rlc_data_req_func = send_rlc_data_req; -} - -void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind) { - pdcp_params.pdcp_data_ind_func = pdcp_data_ind; -} - uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { /* temporary enforce netlink when UE_NAS_USE_TUN is set, this is while switching from noS1 as build option diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 4a7f71b315..17460f824f 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -47,27 +47,6 @@ #include "openair3/SECU/secu_defs.h" -typedef rlc_op_status_t (*send_rlc_data_req_func_t)(const protocol_ctxt_t *const, - const srb_flag_t, - const MBMS_flag_t, - const rb_id_t, - const mui_t, - confirm_t, - sdu_size_t, - uint8_t *, - const uint32_t *const, - const uint32_t *const); - -typedef bool(pdcp_data_ind_t)(const protocol_ctxt_t *, - const srb_flag_t, - const MBMS_flag_t, - const rb_id_t, - const sdu_size_t, - uint8_t *, - const uint32_t *const, - const uint32_t *const); -typedef pdcp_data_ind_t* pdcp_data_ind_func_t; - #define MAX_NUMBER_NETIF 1 //16 #define ENB_NAS_USE_TUN_W_MBMS_BIT (1<< 10) #define PDCP_USE_NETLINK_BIT (1<< 11) @@ -77,8 +56,6 @@ typedef pdcp_data_ind_t* pdcp_data_ind_func_t; #define ENB_NAS_USE_TUN_BIT (1<< 16) typedef struct { uint64_t optmask; - send_rlc_data_req_func_t send_rlc_data_req_func; - pdcp_data_ind_func_t pdcp_data_ind_func; } pdcp_params_t; @@ -279,7 +256,7 @@ bool cu_f1u_data_req(protocol_ctxt_t *ctxt_pP, const uint32_t *const sourceL2Id, const uint32_t *const destinationL2Id); -/*! \fn bool pdcp_data_ind(const protocol_ctxt_t* const, srb_flag_t, MBMS_flag_t, rb_id_t, sdu_size_t, uint8_t*, bool) +/*! \fn bool pdcp_data_ind(const protocol_ctxt_t* const, srb_flag_t, MBMS_flag_t, rb_id_t, sdu_size_t, uint8_t*, uint32_t, uint32_t) * \brief This functions handles data transfer indications coming from RLC * \param[in] ctxt_pP Running context. * \param[in] Shows if rb is SRB @@ -287,12 +264,20 @@ bool cu_f1u_data_req(protocol_ctxt_t *ctxt_pP, * \param[in] rab_id Radio Bearer ID * \param[in] sdu_buffer_size Size of incoming SDU in bytes * \param[in] sdu_buffer Buffer carrying SDU - * \param[in] is_data_plane flag to indicate whether the userplane data belong to the control plane or data plane + * \param[in] srcID + * \param[in] dstID * \return TRUE on success, false otherwise * \note None * @ingroup _pdcp */ -pdcp_data_ind_t pdcp_data_ind; +bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_idP, + const sdu_size_t sdu_buffer_sizeP, + uint8_t *const sdu_buffer_pP, + const uint32_t *const srcID, + const uint32_t *const dstID); /*! \fn void rrc_pdcp_config_req(const protocol_ctxt_t* const ,uint32_t,rb_id_t,uint8_t) * \brief This functions initializes relevant PDCP entity @@ -381,9 +366,6 @@ int pdcp_fifo_flush_sdus ( const protocol_ctxt_t *const ct int pdcp_fifo_read_input_sdus_remaining_bytes ( const protocol_ctxt_t *const ctxt_pP); int pdcp_fifo_read_input_sdus ( const protocol_ctxt_t *const ctxt_pP); void pdcp_fifo_read_input_sdus_from_otg ( const protocol_ctxt_t *const ctxt_pP); -void pdcp_set_rlc_data_req_func(send_rlc_data_req_func_t send_rlc_data_req); -void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind); -pdcp_data_ind_func_t get_pdcp_data_ind_func(void); //----------------------------------------------------------------------------- int pdcp_fifo_flush_mbms_sdus ( const protocol_ctxt_t *const ctxt_pP); int pdcp_fifo_read_input_mbms_sdus_fromtun ( const protocol_ctxt_t *const ctxt_pP); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 4582a85795..910270f35d 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -367,14 +367,14 @@ static void enqueue_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, if (pthread_mutex_unlock(&pq.m) != 0) abort(); } -bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - uint8_t *const sdu_buffer, - const uint32_t *const srcID, - const uint32_t *const dstID) +bool nr_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + uint8_t *const sdu_buffer, + const uint32_t *const srcID, + const uint32_t *const dstID) { enqueue_pdcp_data_ind(ctxt_pP, srb_flagP, @@ -1313,7 +1313,7 @@ bool cu_f1u_data_req(protocol_ctxt_t *ctxt_pP, exit(1); } memcpy(memblock, sdu_buffer, sdu_buffer_size); - int ret=pdcp_data_ind(ctxt_pP,srb_flagP, false, rb_id, sdu_buffer_size, memblock, NULL, NULL); + int ret = nr_pdcp_data_ind(ctxt_pP, srb_flagP, false, rb_id, sdu_buffer_size, memblock, NULL, NULL); if (!ret) { LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__); /* what to do in case of failure? for the moment: nothing */ @@ -1337,16 +1337,6 @@ bool pdcp_data_req(protocol_ctxt_t *ctxt_pP, return false; } -void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind) -{ - /* nothing to do */ -} - -void pdcp_set_rlc_data_req_func(send_rlc_data_req_func_t send_rlc_data_req) -{ - /* nothing to do */ -} - //Dummy function needed due to LTE dependencies void pdcp_mbms_run ( const protocol_ctxt_t *const ctxt_pP){ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h index 54a5e0dcbc..101200615e 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h @@ -37,14 +37,14 @@ void du_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, sdu_size_t sdu_sizeP, uint8_t *sdu_pP); -bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - uint8_t *const sdu_buffer, - const uint32_t *const srcID, - const uint32_t *const dstID); +bool nr_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + uint8_t *const sdu_buffer, + const uint32_t *const srcID, + const uint32_t *const dstID); void nr_pdcp_add_drbs(eNB_flag_t enb_flag, ue_id_t UEid, diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 4f34a64999..46b4dad519 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -519,7 +519,7 @@ rb_found: } memcpy(memblock, buf, size); LOG_D(PDCP, "Calling PDCP layer from RLC in %s\n", __FUNCTION__); - if (!pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock, NULL, NULL)) { + if (!nr_pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock, NULL, NULL)) { LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__); /* what to do in case of failure? for the moment: nothing */ } diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index d9798f6138..e8e70aec41 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -418,7 +418,7 @@ rb_found: exit(1); } memcpy(memblock, buf, size); - if (!get_pdcp_data_ind_func()(&ctx, is_srb, is_mbms, rb_id, size, memblock, NULL, NULL)) { + if (!pdcp_data_ind(&ctx, is_srb, is_mbms, rb_id, size, memblock, NULL, NULL)) { LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed (is_srb %d rb_id %d rnti %d)\n", __FILE__, __LINE__, __FUNCTION__, is_srb, rb_id, ue->rnti); From bfaa906a1e81920266223211bcd10a9555c63e91 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 17:35:54 +0200 Subject: [PATCH 13/61] Remove rb_config functions from nas_config, remove unused functions, make static --- openair2/RRC/NAS/nas_config.h | 6 ----- openair2/RRC/NAS/rb_config.c | 45 +++-------------------------------- openair2/RRC/NAS/rb_config.h | 31 ------------------------ 3 files changed, 3 insertions(+), 79 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 97a6dd5976..21c171c56b 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -175,10 +175,4 @@ char *getBroadcastAddress(void); int bringInterfaceUp(char *interfaceName, int up); -int rb_validate_config_ipv4(int cx, int inst, int rb); -int rb_conf_ipv4(int action, int cx, int inst, int rb, int dscp, in_addr_t saddr_ipv4, in_addr_t daddr_ipv4); -void rb_ioctl_init(int inst); -int rb_stats_req(int inst); -void init_socket(void); -in_addr_t ipv4_address(int thirdOctet, int fourthOctet); #endif /*NAS_CONFIG_H_*/ diff --git a/openair2/RRC/NAS/rb_config.c b/openair2/RRC/NAS/rb_config.c index fd5c82787f..17b180131f 100644 --- a/openair2/RRC/NAS/rb_config.c +++ b/openair2/RRC/NAS/rb_config.c @@ -58,7 +58,7 @@ struct nas_ioctl gifr; static int fd; static int socket_enabled; -void init_socket(void) +static void init_socket(void) { if ((fd=socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { @@ -69,7 +69,7 @@ void init_socket(void) socket_enabled=1; } -void rb_ioctl_init(int inst) +static void rb_ioctl_init(int inst) { /* init the gifr struct for the given inst */ @@ -79,7 +79,7 @@ void rb_ioctl_init(int inst) } -int rb_validate_config_ipv4(int cx, int inst, int rb) +static int rb_validate_config_ipv4(int cx, int inst, int rb) { if (inst == -1) { @@ -229,45 +229,6 @@ int rb_conf_ipv4(int action,int cx, int inst, int rb, int dscp, in_addr_t saddr_ } - -int rb_stats_req(int inst) -{ - - if ( fd <= 0 ) { - return (1); - } /* request stats without defining the interface */ - else if (inst == -1) { - // printf("Specify an interface for statistics request \n"); - LOG_E(OIP,"Specify an interface for statistics request \n"); - return (1); - } - - struct nas_msg_statistic_reply *msgrep; - - int err; - - rb_ioctl_init(inst); - - gifr.type = NAS_MSG_STATISTIC_REQUEST; - - msgrep=(struct nas_msg_statistic_reply *)(gifr.msg); - - if ((err = ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0 ) { - perror("IOCTL error: STATS REQ FAILED\n"); - LOG_E(OIP,"IOCTL error: STATS REQ FAILED\n"); - } - - LOG_I(OIP,"ioctl :Statistics request"); - LOG_I(OIP,"tx_packets = %u, rx_packets = %u\n", msgrep->tx_packets, msgrep->rx_packets); - LOG_I(OIP,"tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes); - LOG_I(OIP,"tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors); - LOG_I(OIP,"tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped); - - return (0); - -} - - in_addr_t ipv4_address (int thirdOctet, int fourthOctet) { diff --git a/openair2/RRC/NAS/rb_config.h b/openair2/RRC/NAS/rb_config.h index 6af42bac45..f00a9573a5 100644 --- a/openair2/RRC/NAS/rb_config.h +++ b/openair2/RRC/NAS/rb_config.h @@ -28,40 +28,9 @@ #define __RB_CONFIG_H__ #include -/* -typedef struct { - int fd; // socket file descriptor - - int stats; - - int action; // add or delete - - int rb; - int cx; - int inst; - - int saddr_ipv4set; - int daddr_ipv4set; - in_addr_t saddr_ipv4; - in_addr_t daddr_ipv4; - - int saddr_ipv6set; - int daddr_ipv6set; - struct in6_addr saddr_ipv6; - struct in6_addr daddr_ipv6; - - int dscp; - - - -} rb_config; -*/ -int rb_validate_config_ipv4(int cx, int inst, int rb); int rb_conf_ipv4(int action,int cx, int inst, int rb, int dscp, in_addr_t saddr_ipv4, in_addr_t daddr_ipv4); void rb_ioctl_init(int inst); -int rb_stats_req(int inst); -void init_socket(void); in_addr_t ipv4_address (int thirdOctet, int fourthOctet); From 5223013153c4b9fdc1234ef026886dc3f43d2a63 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 31 Jul 2024 09:36:20 +0200 Subject: [PATCH 14/61] do_ra test: increase response window Tests showed that we sometimes exceed the response window. In that case, the UE cannot connect anymore, as do-ra uses contention-free RA, and prefills a RA process. Avoid this by giving more time in the CI test. --- ci-scripts/conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf b/ci-scripts/conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf index 551d860d33..f68c2e6ff0 100644 --- a/ci-scripts/conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf +++ b/ci-scripts/conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf @@ -85,7 +85,7 @@ gNBs = powerRampingStep = 1; #ra_ReponseWindow #1,2,4,8,10,20,40,80 - ra_ResponseWindow = 4; + ra_ResponseWindow = 5; #ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR #1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; From 965b7f63b0cffc52b8cef3e47edbef988282fe1f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 1 Aug 2024 08:20:31 +0200 Subject: [PATCH 15/61] Dockerfiles: correct ENV format Avoid docker warning: - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format --- docker/Dockerfile.base.rhel9 | 2 +- docker/Dockerfile.base.rocky | 2 +- docker/Dockerfile.base.ubuntu22 | 2 +- docker/Dockerfile.base.ubuntu22.cross-arm64 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile.base.rhel9 b/docker/Dockerfile.base.rhel9 index 03b4ccac91..dee50127ac 100644 --- a/docker/Dockerfile.base.rhel9 +++ b/docker/Dockerfile.base.rhel9 @@ -67,7 +67,7 @@ RUN rm -f /etc/rhsm-host && \ # Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini # it will be copied into target containers, to print exit numbers and handle signals properly -ENV TINI_VERSION v0.19.0 +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini diff --git a/docker/Dockerfile.base.rocky b/docker/Dockerfile.base.rocky index 5b5debd862..0e9d630bac 100644 --- a/docker/Dockerfile.base.rocky +++ b/docker/Dockerfile.base.rocky @@ -48,7 +48,7 @@ RUN dnf install 'dnf-command(config-manager)' -y && \ # Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini # it will be copied into target containers, to print exit numbers and handle signals properly -ENV TINI_VERSION v0.19.0 +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini diff --git a/docker/Dockerfile.base.ubuntu22 b/docker/Dockerfile.base.ubuntu22 index d1b90e2dcf..f23cf01ac0 100644 --- a/docker/Dockerfile.base.ubuntu22 +++ b/docker/Dockerfile.base.ubuntu22 @@ -57,7 +57,7 @@ RUN apt-get update && \ # Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini # it will be copied into target containers, to print exit numbers and handle signals properly -ENV TINI_VERSION v0.19.0 +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini diff --git a/docker/Dockerfile.base.ubuntu22.cross-arm64 b/docker/Dockerfile.base.ubuntu22.cross-arm64 index 2be24289f5..74af391660 100644 --- a/docker/Dockerfile.base.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.base.ubuntu22.cross-arm64 @@ -74,7 +74,7 @@ RUN apt-get update && \ # Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini # it will be copied into target containers, to print exit numbers and handle signals properly -ENV TINI_VERSION v0.19.0 +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini From 0efaec657af844fb5736596811f734b7e31b4dbd Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 26 Jul 2024 13:17:21 +0200 Subject: [PATCH 16/61] style(docker): newer versions of docker require keyword as to be of same case as from Signed-off-by: Raphael Defosseux --- docker/Dockerfile.build.fhi72.rhel9 | 4 ++-- docker/Dockerfile.build.fhi72.ubuntu22 | 4 ++-- docker/Dockerfile.build.rhel9 | 2 +- docker/Dockerfile.build.rocky | 2 +- docker/Dockerfile.build.ubuntu22 | 2 +- docker/Dockerfile.build.ubuntu22.cross-arm64 | 2 +- docker/Dockerfile.eNB.rhel9 | 2 +- docker/Dockerfile.eNB.rocky | 2 +- docker/Dockerfile.eNB.ubuntu22 | 4 ++-- docker/Dockerfile.gNB.aerial.ubuntu22 | 4 ++-- docker/Dockerfile.gNB.aerial.ubuntu22.sanitize-address | 4 ++-- docker/Dockerfile.gNB.aw2s.rhel9 | 2 +- docker/Dockerfile.gNB.aw2s.rocky | 2 +- docker/Dockerfile.gNB.fhi72.rhel9 | 6 +++--- docker/Dockerfile.gNB.fhi72.ubuntu22 | 6 +++--- docker/Dockerfile.gNB.rhel9 | 2 +- docker/Dockerfile.gNB.rocky | 2 +- docker/Dockerfile.gNB.ubuntu22 | 4 ++-- docker/Dockerfile.lteRU.rhel9 | 2 +- docker/Dockerfile.lteRU.ubuntu22 | 4 ++-- docker/Dockerfile.lteUE.rhel9 | 2 +- docker/Dockerfile.lteUE.rocky | 2 +- docker/Dockerfile.lteUE.ubuntu22 | 2 +- docker/Dockerfile.nr-cuup.rhel9 | 2 +- docker/Dockerfile.nr-cuup.rocky | 2 +- docker/Dockerfile.nr-cuup.ubuntu22 | 4 ++-- docker/Dockerfile.nrUE.rhel9 | 2 +- docker/Dockerfile.nrUE.rocky | 2 +- docker/Dockerfile.nrUE.ubuntu22 | 2 +- docker/Dockerfile.phySim.rhel9 | 2 +- 30 files changed, 42 insertions(+), 42 deletions(-) diff --git a/docker/Dockerfile.build.fhi72.rhel9 b/docker/Dockerfile.build.fhi72.rhel9 index fc5570a85c..6a70b89a51 100644 --- a/docker/Dockerfile.build.fhi72.rhel9 +++ b/docker/Dockerfile.build.fhi72.rhel9 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-base +FROM ran-base:latest AS ran-base ENV TZ=Europe RUN rm -Rf /oai-ran @@ -48,7 +48,7 @@ RUN git clone https://gerrit.o-ran-sc.org/r/o-du/phy.git /opt/phy && \ cd /opt/phy/fhi_lib/lib && \ RTE_SDK=/oai-ran/dpdk-stable-20.11.9/ XRAN_DIR=/opt/phy/fhi_lib make XRAN_LIB_SO=1 -FROM ran-base as ran-build-fhi72 +FROM ran-base AS ran-build-fhi72 ARG E2AP_VERSION=E2AP_V3 ARG KPM_VERSION=KPM_V3_00 diff --git a/docker/Dockerfile.build.fhi72.ubuntu22 b/docker/Dockerfile.build.fhi72.ubuntu22 index 774f488ed7..16ce820832 100644 --- a/docker/Dockerfile.build.fhi72.ubuntu22 +++ b/docker/Dockerfile.build.fhi72.ubuntu22 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-base +FROM ran-base:latest AS ran-base ARG E2AP_VERSION=E2AP_V3 ARG KPM_VERSION=KPM_V3_00 @@ -61,7 +61,7 @@ RUN git clone https://gerrit.o-ran-sc.org/r/o-du/phy.git /opt/phy && \ cd /opt/phy/fhi_lib/lib && \ RTE_SDK=/oai-ran/dpdk-stable-20.11.9/ XRAN_DIR=/opt/phy/fhi_lib make XRAN_LIB_SO=1 -FROM ran-base as ran-build-fhi72 +FROM ran-base AS ran-build-fhi72 ## Build and install OAI #run build_oai to build the target image RUN /bin/sh oaienv && \ diff --git a/docker/Dockerfile.build.rhel9 b/docker/Dockerfile.build.rhel9 index 6adeb62b31..464c6caf5a 100644 --- a/docker/Dockerfile.build.rhel9 +++ b/docker/Dockerfile.build.rhel9 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build RUN rm -Rf /oai-ran WORKDIR /oai-ran diff --git a/docker/Dockerfile.build.rocky b/docker/Dockerfile.build.rocky index aef75c7d2b..3fe164b10d 100644 --- a/docker/Dockerfile.build.rocky +++ b/docker/Dockerfile.build.rocky @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build RUN rm -Rf /oai-ran WORKDIR /oai-ran diff --git a/docker/Dockerfile.build.ubuntu22 b/docker/Dockerfile.build.ubuntu22 index 6a4b44c794..e4cc71fdcf 100644 --- a/docker/Dockerfile.build.ubuntu22 +++ b/docker/Dockerfile.build.ubuntu22 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build ARG BUILD_OPTION RUN rm -Rf /oai-ran diff --git a/docker/Dockerfile.build.ubuntu22.cross-arm64 b/docker/Dockerfile.build.ubuntu22.cross-arm64 index 371651e5ec..349a4f791c 100644 --- a/docker/Dockerfile.build.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.build.ubuntu22.cross-arm64 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build RUN rm -Rf /oai-ran WORKDIR /oai-ran diff --git a/docker/Dockerfile.eNB.rhel9 b/docker/Dockerfile.eNB.rhel9 index c523ac0b1f..391f2a6594 100644 --- a/docker/Dockerfile.eNB.rhel9 +++ b/docker/Dockerfile.eNB.rhel9 @@ -31,7 +31,7 @@ FROM ran-build:latest AS enb-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-enb +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-enb ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.eNB.rocky b/docker/Dockerfile.eNB.rocky index 04243dfda2..eee61a7dda 100644 --- a/docker/Dockerfile.eNB.rocky +++ b/docker/Dockerfile.eNB.rocky @@ -32,7 +32,7 @@ FROM ran-build:latest AS enb-build #start from scratch for target executable -FROM $BASE_IMAGE as oai-enb +FROM $BASE_IMAGE AS oai-enb ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.eNB.ubuntu22 b/docker/Dockerfile.eNB.ubuntu22 index af580f6258..44797cd7f5 100644 --- a/docker/Dockerfile.eNB.ubuntu22 +++ b/docker/Dockerfile.eNB.ubuntu22 @@ -25,13 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as enb-base +FROM ran-base:latest AS enb-base FROM ran-build:latest AS enb-build #start from scratch for target executable -FROM ubuntu:jammy as oai-enb +FROM ubuntu:jammy AS oai-enb ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.gNB.aerial.ubuntu22 b/docker/Dockerfile.gNB.aerial.ubuntu22 index 3259e27baa..dcfe005caa 100644 --- a/docker/Dockerfile.gNB.aerial.ubuntu22 +++ b/docker/Dockerfile.gNB.aerial.ubuntu22 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ @@ -58,7 +58,7 @@ RUN /bin/sh oaienv && \ #start from scratch for target executable -FROM ubuntu:jammy as oai-gnb-aerial +FROM ubuntu:jammy AS oai-gnb-aerial ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe diff --git a/docker/Dockerfile.gNB.aerial.ubuntu22.sanitize-address b/docker/Dockerfile.gNB.aerial.ubuntu22.sanitize-address index 919d7b788d..62c7de33d6 100644 --- a/docker/Dockerfile.gNB.aerial.ubuntu22.sanitize-address +++ b/docker/Dockerfile.gNB.aerial.ubuntu22.sanitize-address @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ran-build +FROM ran-base:latest AS ran-build RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ @@ -58,7 +58,7 @@ RUN /bin/sh oaienv && \ #start from scratch for target executable -FROM ubuntu:jammy as oai-gnb-aerial +FROM ubuntu:jammy AS oai-gnb-aerial ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe diff --git a/docker/Dockerfile.gNB.aw2s.rhel9 b/docker/Dockerfile.gNB.aw2s.rhel9 index 926e2a2e75..db4b0f60c6 100644 --- a/docker/Dockerfile.gNB.aw2s.rhel9 +++ b/docker/Dockerfile.gNB.aw2s.rhel9 @@ -38,7 +38,7 @@ RUN /bin/sh oaienv && \ ./build_oai -w AW2SORI -t Ethernet #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-gnb-aw2s +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-gnb-aw2s ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.gNB.aw2s.rocky b/docker/Dockerfile.gNB.aw2s.rocky index 269eb4be3f..bdd1eb4e38 100644 --- a/docker/Dockerfile.gNB.aw2s.rocky +++ b/docker/Dockerfile.gNB.aw2s.rocky @@ -39,7 +39,7 @@ RUN /bin/sh oaienv && \ ./build_oai -w AW2SORI -t Ethernet #start from scratch for target executable -FROM $BASE_IMAGE as oai-gnb-aw2s +FROM $BASE_IMAGE AS oai-gnb-aw2s ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.gNB.fhi72.rhel9 b/docker/Dockerfile.gNB.fhi72.rhel9 index 6bac3c71d9..0d629ac8a1 100644 --- a/docker/Dockerfile.gNB.fhi72.rhel9 +++ b/docker/Dockerfile.gNB.fhi72.rhel9 @@ -25,12 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as gnb-base +FROM ran-base:latest AS gnb-base -FROM ran-build-fhi72:latest as gnb-build +FROM ran-build-fhi72:latest AS gnb-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-gnb-fhi72 +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-gnb-fhi72 ENV TZ=Europe/Paris # Copy the entitlements diff --git a/docker/Dockerfile.gNB.fhi72.ubuntu22 b/docker/Dockerfile.gNB.fhi72.ubuntu22 index 5bb0ad5234..31f2392af7 100644 --- a/docker/Dockerfile.gNB.fhi72.ubuntu22 +++ b/docker/Dockerfile.gNB.fhi72.ubuntu22 @@ -25,13 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as gnb-base +FROM ran-base:latest AS gnb-base -FROM ran-build-fhi72:latest as gnb-build +FROM ran-build-fhi72:latest AS gnb-build #start from scratch for target executable -FROM ubuntu:jammy as oai-gnb +FROM ubuntu:jammy AS oai-gnb ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe diff --git a/docker/Dockerfile.gNB.rhel9 b/docker/Dockerfile.gNB.rhel9 index d4f20b1cd0..e8fd8a9433 100644 --- a/docker/Dockerfile.gNB.rhel9 +++ b/docker/Dockerfile.gNB.rhel9 @@ -31,7 +31,7 @@ FROM ran-build:latest AS gnb-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-gnb +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-gnb ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.gNB.rocky b/docker/Dockerfile.gNB.rocky index 2e59a0d230..c1665e5a86 100644 --- a/docker/Dockerfile.gNB.rocky +++ b/docker/Dockerfile.gNB.rocky @@ -32,7 +32,7 @@ FROM ran-build:latest AS gnb-build #start from scratch for target executable -FROM $BASE_IMAGE as oai-gnb +FROM $BASE_IMAGE AS oai-gnb ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.gNB.ubuntu22 b/docker/Dockerfile.gNB.ubuntu22 index 6ac01d7139..77a7ac0207 100644 --- a/docker/Dockerfile.gNB.ubuntu22 +++ b/docker/Dockerfile.gNB.ubuntu22 @@ -25,13 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as gnb-base +FROM ran-base:latest AS gnb-base FROM ran-build:latest AS gnb-build #start from scratch for target executable -FROM ubuntu:jammy as oai-gnb +FROM ubuntu:jammy AS oai-gnb ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.lteRU.rhel9 b/docker/Dockerfile.lteRU.rhel9 index d57c88bbf4..18ef1e8cfd 100644 --- a/docker/Dockerfile.lteRU.rhel9 +++ b/docker/Dockerfile.lteRU.rhel9 @@ -31,7 +31,7 @@ FROM ran-build:latest AS ru-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-lte-ru +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-lte-ru ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.lteRU.ubuntu22 b/docker/Dockerfile.lteRU.ubuntu22 index 83a3e950ab..0f5f68932a 100644 --- a/docker/Dockerfile.lteRU.ubuntu22 +++ b/docker/Dockerfile.lteRU.ubuntu22 @@ -25,13 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as ru-base +FROM ran-base:latest AS ru-base FROM ran-build:latest AS ru-build #start from scratch for target executable -FROM ubuntu:jammy as oai-lte-ru +FROM ubuntu:jammy AS oai-lte-ru ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.lteUE.rhel9 b/docker/Dockerfile.lteUE.rhel9 index 84854c2104..9ddf9e1f32 100644 --- a/docker/Dockerfile.lteUE.rhel9 +++ b/docker/Dockerfile.lteUE.rhel9 @@ -31,7 +31,7 @@ FROM ran-build:latest AS lte-ue-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-lte-ue +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-lte-ue ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.lteUE.rocky b/docker/Dockerfile.lteUE.rocky index 54b5dfa52a..4d98776c1d 100644 --- a/docker/Dockerfile.lteUE.rocky +++ b/docker/Dockerfile.lteUE.rocky @@ -32,7 +32,7 @@ FROM ran-build:latest AS lte-ue-build #start from scratch for target executable -FROM $BASE_IMAGE as oai-lte-ue +FROM $BASE_IMAGE AS oai-lte-ue ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.lteUE.ubuntu22 b/docker/Dockerfile.lteUE.ubuntu22 index 057b6d17dc..5174dab36a 100644 --- a/docker/Dockerfile.lteUE.ubuntu22 +++ b/docker/Dockerfile.lteUE.ubuntu22 @@ -31,7 +31,7 @@ FROM ran-build:latest AS lte-ue-build #start from scratch for target executable -FROM ubuntu:jammy as oai-lte-ue +FROM ubuntu:jammy AS oai-lte-ue ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.nr-cuup.rhel9 b/docker/Dockerfile.nr-cuup.rhel9 index c10560e13f..08ee72fa30 100644 --- a/docker/Dockerfile.nr-cuup.rhel9 +++ b/docker/Dockerfile.nr-cuup.rhel9 @@ -32,7 +32,7 @@ FROM ran-build:latest AS gnb-build RUN cp /oai-ran/docker/scripts/gnb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-nr-cuup +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-nr-cuup ENV TZ=Europe/Paris RUN yum repolist --disablerepo=* && \ diff --git a/docker/Dockerfile.nr-cuup.rocky b/docker/Dockerfile.nr-cuup.rocky index e6803bce1a..7f0e8fc2f1 100644 --- a/docker/Dockerfile.nr-cuup.rocky +++ b/docker/Dockerfile.nr-cuup.rocky @@ -33,7 +33,7 @@ FROM ran-build:latest AS gnb-build RUN cp /oai-ran/docker/scripts/gnb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable -FROM $BASE_IMAGE as oai-nr-cuup +FROM $BASE_IMAGE AS oai-nr-cuup ENV TZ=Europe/Paris RUN yum repolist --disablerepo=* && \ diff --git a/docker/Dockerfile.nr-cuup.ubuntu22 b/docker/Dockerfile.nr-cuup.ubuntu22 index b618a578be..af95cb5a9c 100644 --- a/docker/Dockerfile.nr-cuup.ubuntu22 +++ b/docker/Dockerfile.nr-cuup.ubuntu22 @@ -25,12 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-base:latest as gnb-base +FROM ran-base:latest AS gnb-base FROM ran-build:latest AS gnb-build -FROM ubuntu:jammy as oai-nr-cuup +FROM ubuntu:jammy AS oai-nr-cuup ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe diff --git a/docker/Dockerfile.nrUE.rhel9 b/docker/Dockerfile.nrUE.rhel9 index 7d5894c618..7279809fdb 100644 --- a/docker/Dockerfile.nrUE.rhel9 +++ b/docker/Dockerfile.nrUE.rhel9 @@ -31,7 +31,7 @@ FROM ran-build:latest AS nr-ue-build #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-nr-ue +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-nr-ue ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.nrUE.rocky b/docker/Dockerfile.nrUE.rocky index 88d6bd73ff..ec5ecf6a99 100644 --- a/docker/Dockerfile.nrUE.rocky +++ b/docker/Dockerfile.nrUE.rocky @@ -32,7 +32,7 @@ FROM ran-build:latest AS nr-ue-build #start from scratch for target executable -FROM $BASE_IMAGE as oai-nr-ue +FROM $BASE_IMAGE AS oai-nr-ue ENV TZ=Europe/Paris RUN dnf update -y && \ diff --git a/docker/Dockerfile.nrUE.ubuntu22 b/docker/Dockerfile.nrUE.ubuntu22 index 83aa918045..74ae9620b0 100644 --- a/docker/Dockerfile.nrUE.ubuntu22 +++ b/docker/Dockerfile.nrUE.ubuntu22 @@ -31,7 +31,7 @@ FROM ran-build:latest AS nr-ue-build #start from scratch for target executable -FROM ubuntu:jammy as oai-nr-ue +FROM ubuntu:jammy AS oai-nr-ue ARG BUILD_OPTION ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.phySim.rhel9 b/docker/Dockerfile.phySim.rhel9 index ccfe8505a8..e568c6bc00 100644 --- a/docker/Dockerfile.phySim.rhel9 +++ b/docker/Dockerfile.phySim.rhel9 @@ -41,7 +41,7 @@ RUN /bin/sh oaienv && \ ./build_oai --phy_simulators --ninja --sanitize --noavx512 -c --cmake-opt -DCMAKE_C_FLAGS=-Werror --cmake-opt -DCMAKE_CXX_FLAGS=-Werror #start from scratch for target executable -FROM registry.access.redhat.com/ubi9/ubi:latest as oai-physim +FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-physim RUN dnf update -y && \ dnf install -y \ From f6dcc19fe5a59d317d1106fcbd3429e1fcf1a57d Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 26 Jul 2024 15:00:10 +0200 Subject: [PATCH 17/61] style(docker): adding license header to dockerfiles Signed-off-by: Raphael Defosseux --- ci-scripts/docker/Dockerfile.cppcheck.xenial | 27 +++++++++++++++++++ .../docker/Dockerfile.formatting.bionic | 27 +++++++++++++++++++ .../docker/Dockerfile.unittest.ubuntu22 | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ci-scripts/docker/Dockerfile.cppcheck.xenial b/ci-scripts/docker/Dockerfile.cppcheck.xenial index f69d4a8402..0d6aa029ff 100644 --- a/ci-scripts/docker/Dockerfile.cppcheck.xenial +++ b/ci-scripts/docker/Dockerfile.cppcheck.xenial @@ -1,5 +1,32 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for Ubuntu 22.04 +# +#--------------------------------------------------------------------- FROM ubuntu:xenial AS oai-cppcheck + ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ diff --git a/ci-scripts/docker/Dockerfile.formatting.bionic b/ci-scripts/docker/Dockerfile.formatting.bionic index 47fd2a08d0..a8d58f511c 100644 --- a/ci-scripts/docker/Dockerfile.formatting.bionic +++ b/ci-scripts/docker/Dockerfile.formatting.bionic @@ -1,3 +1,30 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for Ubuntu 22.04 +# +#--------------------------------------------------------------------- + FROM ubuntu:bionic AS oai-formatting-check ARG MERGE_REQUEST diff --git a/ci-scripts/docker/Dockerfile.unittest.ubuntu22 b/ci-scripts/docker/Dockerfile.unittest.ubuntu22 index 21805560d4..4401761c02 100644 --- a/ci-scripts/docker/Dockerfile.unittest.ubuntu22 +++ b/ci-scripts/docker/Dockerfile.unittest.ubuntu22 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-base:develop as ran-tests +FROM ran-base:develop AS ran-tests RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ From 5f684d7f05a6e6d3acab0b1127e3bbeb081e8be4 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 1 Aug 2024 13:31:07 +0200 Subject: [PATCH 18/61] Improve error handling in Iperf_analyzeV3TCPJson() --- ci-scripts/cls_oaicitest.py | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index b7e61c06cd..8bfc6bc599 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -96,29 +96,26 @@ def Iperf_ComputeTime(args): return int(result.group('iperf_time')) def Iperf_analyzeV3TCPJson(filename, iperf_tcp_rate_target): - if (not os.path.isfile(filename)): - return (False, 'Iperf3 TCP: Log file not present') - if (os.path.getsize(filename)==0): - return (False, 'Iperf3 TCP: Log file is empty') - - with open(filename) as file: - filename = json.load(file) - try: - sender_bitrate = round(filename['end']['streams'][0]['sender']['bits_per_second']/1000000,2) - receiver_bitrate = round(filename['end']['streams'][0]['receiver']['bits_per_second']/1000000,2) - except Exception as e: - return (False, 'Could not compute Iperf3 bitrate!') - - snd_msg = f'Sender Bitrate : {sender_bitrate} Mbps' - rcv_msg = f'Receiver Bitrate : {receiver_bitrate} Mbps' - success = True - if (iperf_tcp_rate_target is not None): - if (int(receiver_bitrate) < int(iperf_tcp_rate_target)): - rcv_msg += f" (too low! < {iperf_tcp_rate_target} Mbps)" - success = False + try: + with open(filename) as f: + results = json.load(f) + sender_bitrate = round(results['end']['streams'][0]['sender']['bits_per_second'] / 1000000, 2) + receiver_bitrate = round(results['end']['streams'][0]['receiver']['bits_per_second'] / 1000000, 2) + snd_msg = f'Sender Bitrate : {sender_bitrate} Mbps' + rcv_msg = f'Receiver Bitrate : {receiver_bitrate} Mbps' + success = True + if (iperf_tcp_rate_target is not None): + if (int(receiver_bitrate) < int(iperf_tcp_rate_target)): + rcv_msg += f" (too low! < {iperf_tcp_rate_target} Mbps)" + success = False else: rcv_msg += f" (target : {iperf_tcp_rate_target} Mbps)" - return(success, f'{snd_msg}\n{rcv_msg}') + return(success, f'{snd_msg}\n{rcv_msg}') + except KeyError as e: + e_msg = results.get('error', f'error report not found in {filename}') + return (False, f'While parsing Iperf3 results: missing key {e}, {e_msg}') + except Exception as e: + return (False, f'While parsing Iperf3 results: generic exception: {e}') def Iperf_analyzeV3BIDIRJson(filename): if (not os.path.isfile(filename)): From 9acf60a33954e593386219479796fc08b3efa1d7 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 1 Aug 2024 13:31:51 +0200 Subject: [PATCH 19/61] Improve error handling in Iperf_analyzeV3BIDIRJson() --- ci-scripts/cls_oaicitest.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 8bfc6bc599..737b8ca580 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -118,26 +118,23 @@ def Iperf_analyzeV3TCPJson(filename, iperf_tcp_rate_target): return (False, f'While parsing Iperf3 results: generic exception: {e}') def Iperf_analyzeV3BIDIRJson(filename): - if (not os.path.isfile(filename)): - return (False, 'Iperf3 Bidir TCP: Log file not present') - if (os.path.getsize(filename)==0): - return (False, 'Iperf3 Bidir TCP: Log file is empty') - - with open(filename) as file: - filename = json.load(file) - try: - sender_bitrate_ul = round(filename['end']['streams'][0]['sender']['bits_per_second']/1000000,2) - receiver_bitrate_ul = round(filename['end']['streams'][0]['receiver']['bits_per_second']/1000000,2) - sender_bitrate_dl = round(filename['end']['streams'][1]['sender']['bits_per_second']/1000000,2) - receiver_bitrate_dl = round(filename['end']['streams'][1]['receiver']['bits_per_second']/1000000,2) - except Exception as e: - return (False, 'Could not compute BIDIR bitrate!') - - msg = f'Sender Bitrate DL : {sender_bitrate_dl} Mbps\n' - msg += f'Receiver Bitrate DL : {receiver_bitrate_dl} Mbps\n' - msg += f'Sender Bitrate UL : {sender_bitrate_ul} Mbps\n' - msg += f'Receiver Bitrate UL : {receiver_bitrate_ul} Mbps\n' - return (True, msg) + try: + with open(filename) as f: + results = json.load(f) + sender_bitrate_ul = round(results['end']['streams'][0]['sender']['bits_per_second'] / 1000000, 2) + receiver_bitrate_ul = round(results['end']['streams'][0]['receiver']['bits_per_second'] / 1000000, 2) + sender_bitrate_dl = round(results['end']['streams'][1]['sender']['bits_per_second'] / 1000000, 2) + receiver_bitrate_dl = round(results['end']['streams'][1]['receiver']['bits_per_second'] / 1000000, 2) + msg = f'Sender Bitrate DL : {sender_bitrate_dl} Mbps\n' + msg += f'Receiver Bitrate DL : {receiver_bitrate_dl} Mbps\n' + msg += f'Sender Bitrate UL : {sender_bitrate_ul} Mbps\n' + msg += f'Receiver Bitrate UL : {receiver_bitrate_ul} Mbps\n' + return (True, msg) + except KeyError as e: + e_msg = results.get('error', f'error report not found in {filename}') + return (False, f'While parsing Iperf3 results: missing key {e}, {e_msg}') + except Exception as e: + return (False, f'While parsing Iperf3 results: generic exception: {e}') def Iperf_analyzeV3UDP(filename, iperf_bitrate_threshold, iperf_packetloss_threshold, target_bitrate): if (not os.path.isfile(filename)): From 848b0f34ee290b11975c54a474aec5bf66b74987 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 1 Aug 2024 08:11:31 +0200 Subject: [PATCH 20/61] UE cmd line info: print threequarter-sampling param if used, add doc --- doc/RUNMODEM.md | 5 ++++- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index b1b5090ae7..4d181158a9 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -103,12 +103,15 @@ Command line parameters for UE in `--sa` mode: - `--ssb` : SSB start subcarrier (default value 516) **Optional parameters**: +- `-E`: use three-quarter sampling for split 8 sample rate. Required for + certain radios (e.g., 40MHz with B210). If used on the gNB, it is a good idea + to use for the UE as well (and vice versa). - `--ue-scan-carrier` : scan for cells in current bandwidth. This option can be used if the SSB position of the gNB is unknown. If multiple cells are detected, the UE will try to connect to the first cell. By default, this option is disabled and the UE attempts to only decode SSB given by `--ssb`. To simplify the configuration for the user testing OAI UE with OAI gNB, the latter prints the following LOG that guides the user to correctly set some of the UE command line parameters. ``` -[PHY] Command line parameters for the UE: -C 3319680000 -r 106 --numerology 1 --ssb 516 +[PHY] Command line parameters for OAI UE: -C 3319680000 -r 106 --numerology 1 --ssb 516 ``` You can run this, using USRPs, on two separate machines: diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 97205f28c7..aca2ad900c 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -81,19 +81,21 @@ void nr_common_signal_procedures(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_ fp->print_ue_help_cmdline_log = false; if (fp->dl_CarrierFreq != fp->ul_CarrierFreq) LOG_A(PHY, - "Command line parameters for the UE: -C %lu --CO %ld -r %d --numerology %d --ssb %d\n", + "Command line parameters for OAI UE: -C %lu --CO %ld -r %d --numerology %d --ssb %d %s\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq - fp->dl_CarrierFreq, fp->N_RB_DL, scs, - fp->ssb_start_subcarrier); + fp->ssb_start_subcarrier, + fp->threequarter_fs ? "-E" : ""); else LOG_A(PHY, - "Command line parameters for the UE: -C %lu -r %d --numerology %d --ssb %d\n", + "Command line parameters for OAI UE: -C %lu -r %d --numerology %d --ssb %d %s\n", fp->dl_CarrierFreq, fp->N_RB_DL, scs, - fp->ssb_start_subcarrier); + fp->ssb_start_subcarrier, + fp->threequarter_fs ? "-E" : ""); } LOG_D(PHY, "ssbOffsetPointA %d SSB SsbSubcarrierOffset %d prb_offset %d sc_offset %d scs %d ssb_start_subcarrier %d\n", From 70751e04d85ef5437d2f987974bd7aab7d6b9de1 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 20 Jul 2024 09:50:41 +0200 Subject: [PATCH 21/61] Added automatic scaling to PUCCH2 receiver Scaling based on incoming signal level to help with polar case. Can subsequently add PUCCH2 CQI measurement based on this. --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 83 ++++++++++++++++++--------- openair1/SIMULATION/NR_PHY/pucchsim.c | 10 ++-- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 05d7f03832..d869a4a106 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1059,6 +1059,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, c16_t rp[Prx2][2][nb_re_pucch]; memset(rp, 0, sizeof(rp)); + int64_t pucch2_lev = 0; + for (int aa=0;aanr_of_symbols;symb++) { c16_t *tmp_rp = ((c16_t *)&rxdataF[aa][soffset + (l2 + symb) * frame_parms->ofdm_symbol_size]); @@ -1072,10 +1074,23 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, memcpy(rp[aa][symb], &tmp_rp[re_offset[symb]], neg_length * sizeof(c16_t)); memcpy(&rp[aa][symb][neg_length], tmp_rp, pos_length * sizeof(c16_t)); } + pucch2_lev += signal_energy_nodc((int32_t *)rp[aa][symb], nb_re_pucch); } } + pucch2_lev /= Prx * Prx * pucch_pdu->nr_of_symbols; + int pucch2_levdB = dB_fixed(pucch2_lev); + int scaling = 0; + if (pucch2_levdB > 72) + scaling = 4; + else if (pucch2_levdB > 66) + scaling = 3; + else if (pucch2_levdB > 60) + scaling = 2; + else if (pucch2_levdB > 54) + scaling = 1; + LOG_D(PHY, - "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d\n", + "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d)\n", frame, slot, pucch_pdu->nr_of_symbols, @@ -1083,7 +1098,9 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_harq, pucch_pdu->sr_flag, pucch_pdu->bit_len_csi_part1, - pucch_pdu->bit_len_csi_part2); + pucch_pdu->bit_len_csi_part2, + pucch2_levdB, + scaling); int nc_group_size=1; // 2 PRB int ngroup = prb_size_ext/nc_group_size/2; @@ -1124,14 +1141,14 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, for (int idx = 0; idx < 4; idx++) { c16_t *rp_base = rp[aa][symb] + prb * 12 + 3 * idx; AssertFatal(prb * 12 + 3 * idx + 2 < nb_re_pucch, ""); - r_re_ext_p[idx << 1] = rp_base->r; - r_im_ext_p[idx << 1] = rp_base->i; + r_re_ext_p[idx << 1] = rp_base->r >> scaling; + r_im_ext_p[idx << 1] = rp_base->i >> scaling; rp_base++; - rd_re_ext_p[idx] = rp_base->r; - rd_im_ext_p[idx] = rp_base->i; + rd_re_ext_p[idx] = rp_base->r >> scaling; + rd_im_ext_p[idx] = rp_base->i >> scaling; rp_base++; - r_re_ext_p[1 + (idx << 1)] = rp_base->r; - r_im_ext_p[1 + (idx << 1)] = rp_base->i; + r_re_ext_p[1 + (idx << 1)] = rp_base->r >> scaling; + r_im_ext_p[1 + (idx << 1)] = rp_base->i >> scaling; } #ifdef DEBUG_NR_PUCCH_RX @@ -1524,24 +1541,38 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, corr_re = ( corr32_re[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]); corr_im = ( corr32_im[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]); corr_tmp += (corr_re*corr_re + corr_im*corr_im)>>(Prx/2); - /* - LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) - = (%d,%d) => %d\n", half_prb,cw,cw&15,cw>>4,aa, - ((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0], - ((int16_t*)&pucch2_polar_4bit[cw&15])[1],((int16_t*)&pucch2_polar_4bit[cw>>4])[1], - ((int16_t*)&pucch2_polar_4bit[cw&15])[2],((int16_t*)&pucch2_polar_4bit[cw>>4])[2], - ((int16_t*)&pucch2_polar_4bit[cw&15])[3],((int16_t*)&pucch2_polar_4bit[cw>>4])[3], - ((int16_t*)&rp_re[aa][half_prb])[0],((int16_t*)&rp_im[aa][half_prb])[0], - ((int16_t*)&rp_re[aa][half_prb])[1],((int16_t*)&rp_im[aa][half_prb])[1], - ((int16_t*)&rp_re[aa][half_prb])[2],((int16_t*)&rp_im[aa][half_prb])[2], - ((int16_t*)&rp_re[aa][half_prb])[3],((int16_t*)&rp_im[aa][half_prb])[3], - corr32_re[half_prb>>2][aa]/(2*nc_group_size*4/2),corr32_im[half_prb>>2][aa]/(2*nc_group_size*4/2), - ((int16_t*)(&prod_re[aa]))[0], - ((int16_t*)(&prod_im[aa]))[0], - corr_re, - corr_im, - corr_tmp); - */ + + LOG_D(PHY, + "pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = " + "(%d,%d) => %d\n", + half_prb, + cw, + cw & 15, + cw >> 4, + aa, + ((int16_t *)&pucch2_polar_4bit[cw & 15])[0], + ((int16_t *)&pucch2_polar_4bit[cw >> 4])[0], + ((int16_t *)&pucch2_polar_4bit[cw & 15])[1], + ((int16_t *)&pucch2_polar_4bit[cw >> 4])[1], + ((int16_t *)&pucch2_polar_4bit[cw & 15])[2], + ((int16_t *)&pucch2_polar_4bit[cw >> 4])[2], + ((int16_t *)&pucch2_polar_4bit[cw & 15])[3], + ((int16_t *)&pucch2_polar_4bit[cw >> 4])[3], + ((int16_t *)&rp_re[aa][half_prb])[0], + ((int16_t *)&rp_im[aa][half_prb])[0], + ((int16_t *)&rp_re[aa][half_prb])[1], + ((int16_t *)&rp_im[aa][half_prb])[1], + ((int16_t *)&rp_re[aa][half_prb])[2], + ((int16_t *)&rp_im[aa][half_prb])[2], + ((int16_t *)&rp_re[aa][half_prb])[3], + ((int16_t *)&rp_im[aa][half_prb])[3], + corr32_re[symb][half_prb >> 2][aa] / (2 * nc_group_size * 4 / 2), + corr32_im[symb][half_prb >> 2][aa] / (2 * nc_group_size * 4 / 2), + ((int16_t *)(&prod_re[aa]))[0], + ((int16_t *)(&prod_im[aa]))[0], + corr_re, + corr_im, + corr_tmp); } corr16 = simde_mm_set1_epi16((int16_t)(corr_tmp >> 8)); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 5291930c12..9dd9ef61a9 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -539,7 +539,7 @@ int main(int argc, char **argv) } pucch_GroupHopping_t PUCCH_GroupHopping = pucch_tx_pdu.group_hop_flag + (pucch_tx_pdu.sequence_hop_flag<<1); - + double tx_level_fp = 100.0; for(SNR=snr0;SNR<=snr1;SNR+=1){ ack_nack_errors=0; sr_errors=0; @@ -578,8 +578,8 @@ int main(int argc, char **argv) for (int aarx=0;aarx 0) printf("symb %d, re %d , aarx %d : txr %f, txi %f, chr %f, chi %f, nr %f, ni %f, rxr %f, rxi %f => %d,%d\n", symb, re, aarx, txr,txi, From 39070f6541d4f146b4afb2d40149afc861cd8007 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 1 Aug 2024 15:59:35 +0200 Subject: [PATCH 22/61] Minor fix in Iperf_analyzeV3TCPJson() --- ci-scripts/cls_oaicitest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 737b8ca580..281f8b6d48 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -108,8 +108,8 @@ def Iperf_analyzeV3TCPJson(filename, iperf_tcp_rate_target): if (int(receiver_bitrate) < int(iperf_tcp_rate_target)): rcv_msg += f" (too low! < {iperf_tcp_rate_target} Mbps)" success = False - else: - rcv_msg += f" (target : {iperf_tcp_rate_target} Mbps)" + else: + rcv_msg += f" (target : {iperf_tcp_rate_target} Mbps)" return(success, f'{snd_msg}\n{rcv_msg}') except KeyError as e: e_msg = results.get('error', f'error report not found in {filename}') From 3fa73e4bdd429ca7c0c67b7b696e8ad637d5c023 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 18 Apr 2024 17:40:50 +0200 Subject: [PATCH 23/61] implementation of MAC data inactivity timer --- openair2/COMMON/mac_messages_def.h | 1 + openair2/COMMON/mac_messages_types.h | 5 ++ openair2/LAYER2/NR_MAC_UE/config_ue.c | 71 ++++++++++++++++++++ openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 + openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 19 +++--- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 +++ openair2/RRC/NR_UE/L2_interface_ue.c | 7 ++ openair2/RRC/NR_UE/rrc_UE.c | 6 ++ openair2/RRC/NR_UE/rrc_proto.h | 1 + 10 files changed, 115 insertions(+), 9 deletions(-) diff --git a/openair2/COMMON/mac_messages_def.h b/openair2/COMMON/mac_messages_def.h index 661f219240..e3ef328017 100644 --- a/openair2/COMMON/mac_messages_def.h +++ b/openair2/COMMON/mac_messages_def.h @@ -50,6 +50,7 @@ MESSAGE_DEF(RRC_MAC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacPcchDat MESSAGE_DEF(NR_RRC_MAC_RA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacRaInd, nr_rrc_mac_ra_ind) MESSAGE_DEF(NR_RRC_MAC_MSG3_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacMsg3Ind, nr_rrc_mac_msg3_ind) +MESSAGE_DEF(NR_RRC_MAC_INAC_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacInacInd, nr_rrc_mac_inac_ind) /* RRC configures DRX context (MAC timers) of a UE */ MESSAGE_DEF(RRC_MAC_DRX_CONFIG_REQ, MESSAGE_PRIORITY_MED, rrc_mac_drx_config_req_t, rrc_mac_drx_config_req) diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index effdaacff3..bc9e8f6c8a 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -57,6 +57,7 @@ #define NR_RRC_MAC_RA_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_ra_ind #define NR_RRC_MAC_MSG3_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_msg3_ind +#define NR_RRC_MAC_INAC_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_inac_ind #define RRC_MAC_DRX_CONFIG_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_drx_config_req @@ -80,6 +81,10 @@ typedef struct NRRrcMacMsg3Ind_s { int gnb_id; } NRRrcMacMsg3Ind; +typedef struct NRRrcMacInacInd_s { + bool inactivity_timer_expired; // not to leave the struct empty +} NRRrcMacInacInd; + typedef struct RrcMacInSyncInd_s { uint32_t frame; uint8_t sub_frame; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index e28f7dce93..5272712bcb 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1814,6 +1814,64 @@ static uint32_t nr_get_sf_periodicBSRTimer(long periodicBSR) return timer; } +static uint32_t get_data_inactivity_timer(long setup) +{ + uint32_t timer_s = 0; + switch (setup) { + case NR_DataInactivityTimer_s1 : + timer_s = 1; + break; + case NR_DataInactivityTimer_s2 : + timer_s = 2; + break; + case NR_DataInactivityTimer_s3 : + timer_s = 3; + break; + case NR_DataInactivityTimer_s5 : + timer_s = 5; + break; + case NR_DataInactivityTimer_s7 : + timer_s = 7; + break; + case NR_DataInactivityTimer_s10 : + timer_s = 10; + break; + case NR_DataInactivityTimer_s15 : + timer_s = 15; + break; + case NR_DataInactivityTimer_s20 : + timer_s = 20; + break; + case NR_DataInactivityTimer_s40 : + timer_s = 40; + break; + case NR_DataInactivityTimer_s50 : + timer_s = 50; + break; + case NR_DataInactivityTimer_s60 : + timer_s = 60; + break; + case NR_DataInactivityTimer_s80 : + timer_s = 80; + break; + case NR_DataInactivityTimer_s100 : + timer_s = 100; + break; + case NR_DataInactivityTimer_s120 : + timer_s = 120; + break; + case NR_DataInactivityTimer_s150 : + timer_s = 150; + break; + case NR_DataInactivityTimer_s180 : + timer_s = 180; + break; + default : + AssertFatal(false, "Invalid data inactivity timer\n"); + } + return timer_s; +} + static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroupConfig_t *mcg) { NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info; @@ -1881,6 +1939,19 @@ static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroup if (mcg->phr_Config) { // TODO configuration when PHR is implemented } + + if (mcg->ext1 && mcg->ext1->dataInactivityTimer) { + struct NR_SetupRelease_DataInactivityTimer *setup_release = mcg->ext1->dataInactivityTimer; + if (setup_release->present == NR_SetupRelease_DataInactivityTimer_PR_release) + free(mac->data_inactivity_timer); + if (setup_release->present == NR_SetupRelease_DataInactivityTimer_PR_setup) { + if (!mac->data_inactivity_timer) + mac->data_inactivity_timer = calloc(1, sizeof(*mac->data_inactivity_timer)); + uint32_t timer_s = get_data_inactivity_timer(setup_release->choice.setup); // timer in seconds + int scs = mac->current_DL_BWP->scs; + nr_timer_setup(mac->data_inactivity_timer, (timer_s * 1000) << scs, 1); // 1 slot update rate + } + } } static void configure_csirs_resource(NR_NZP_CSI_RS_Resource_t *target, NR_NZP_CSI_RS_Resource_t *source) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 781192fbc2..d6067a3f68 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -557,8 +557,8 @@ typedef struct NR_UE_MAC_INST_s { // order lc info A_SEQUENCE_OF(nr_lcordered_info_t) lc_ordered_list; - NR_UE_SCHEDULING_INFO scheduling_info; + NR_timer_t *data_inactivity_timer; /// PHR uint8_t PHR_reporting_active; diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index b6a289cc45..fd465e6954 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -196,6 +196,8 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) nr_mac->scheduling_info.lc_sched_info[i].Bj = 0; nr_timer_stop(&nr_mac->scheduling_info.lc_sched_info[i].Bj_timer); } + if (nr_mac->data_inactivity_timer) + nr_timer_stop(nr_mac->data_inactivity_timer); nr_timer_stop(&nr_mac->ra.contention_resolution_timer); nr_timer_stop(&nr_mac->scheduling_info.sr_DelayTimer); nr_timer_stop(&nr_mac->scheduling_info.retxBSR_Timer); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c7903a9666..146429ddc7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2957,19 +2957,22 @@ void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, in // Processing MAC PDU // it parses MAC CEs subheaders, MAC CEs, SDU subheaderds and SDUs - switch (dl_info->rx_ind->rx_indication_body[pdu_id].pdu_type){ - case FAPI_NR_RX_PDU_TYPE_DLSCH: - nr_ue_process_mac_pdu(mac, dl_info, pdu_id); - break; - case FAPI_NR_RX_PDU_TYPE_RAR: + switch (dl_info->rx_ind->rx_indication_body[pdu_id].pdu_type) { + case FAPI_NR_RX_PDU_TYPE_DLSCH : + // start or restart dataInactivityTimer if any MAC entity receives a MAC SDU for DTCH logical channel, + // DCCH logical channel, or CCCH logical channel + if (mac->data_inactivity_timer) + nr_timer_start(mac->data_inactivity_timer); + nr_ue_process_mac_pdu(mac, dl_info, pdu_id); + break; + case FAPI_NR_RX_PDU_TYPE_RAR : nr_ue_process_rar(mac, dl_info, pdu_id); - break; + break; default: - break; + AssertFatal(false, "Invalid PDU type\n"); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); - } // #define EXTRACT_DCI_ITEM(val,size) val= readBits(dci_pdu, &pos, size); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 315f1ef522..5744363119 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -54,6 +54,7 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/RLC/rlc.h" +#include "RRC/NR_UE/rrc_proto.h" //#define SRS_DEBUG #define verifyMutex(a) \ @@ -147,6 +148,11 @@ static void trigger_regular_bsr(NR_UE_MAC_INST_t *mac, NR_LogicalChannelIdentity void update_mac_timers(NR_UE_MAC_INST_t *mac) { + if (mac->data_inactivity_timer) { + bool inactivity_timer_expired = nr_timer_tick(mac->data_inactivity_timer); + if (inactivity_timer_expired) + nr_mac_rrc_inactivity_timer_ind(mac->ue_id); + } nr_timer_tick(&mac->ra.contention_resolution_timer); for (int j = 0; j < NR_MAX_SR_ID; j++) nr_timer_tick(&mac->scheduling_info.sr_info[j].prohibitTimer); @@ -1426,6 +1432,10 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) ulcfg_pdu->pusch_config_pdu.tx_request_body.fapiTxPdu = ulsch_input_buffer; ulcfg_pdu->pusch_config_pdu.tx_request_body.pdu_length = TBS_bytes; number_of_pdus++; + // start or restart dataInactivityTimer if any MAC entity transmits a MAC SDU for DTCH logical channel, + // or DCCH logical channel + if (mac->data_inactivity_timer) + nr_timer_start(mac->data_inactivity_timer); } } diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index feda34be67..db26de9615 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -125,6 +125,13 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, return(0); } +void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) +{ + MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_INAC_IND); + NR_RRC_MAC_INAC_IND (message_p).inactivity_timer_expired = true; + itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p); +} + void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id) { MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MSG3_IND); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index cab08077ce..7345c06089 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1750,6 +1750,12 @@ void *rrc_nrue(void *notUsed) nr_rrc_SI_timers(SInfo); break; + case NR_RRC_MAC_INAC_IND: + LOG_D(NR_RRC, "Received data inactivity indication from lower layers\n"); + NR_Release_Cause_t release_cause = RRC_CONNECTION_FAILURE; + nr_rrc_going_to_IDLE(rrc, release_cause, NULL); + break; + case NR_RRC_MAC_MSG3_IND: nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti); break; diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 739d81cb4e..35d25ca466 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -89,6 +89,7 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, void handle_RRCRelease(NR_UE_RRC_INST_t *rrc); void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success); void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id); +void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); void set_rlf_sib1_timers_and_constants(NR_UE_Timers_Constants_t *tac, NR_SIB1_t *sib1); /**\brief RRC UE task. From a9902d883cae1ed7ca9ac6371a8de59ba0a104af Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 19 Apr 2024 18:07:30 +0200 Subject: [PATCH 24/61] creation of a separate .h file for L2_interface_ue --- executables/nr-ue.c | 1 + .../SIMULATION/NR_PHY/nr_dummy_functions.c | 2 + openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 3 +- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 11 +++++ openair2/RRC/NR_UE/L2_interface_ue.c | 30 ++++++------- openair2/RRC/NR_UE/L2_interface_ue.h | 45 +++++++++++++++++++ openair2/RRC/NR_UE/rrc_UE.c | 1 + openair2/RRC/NR_UE/rrc_proto.h | 43 ++---------------- 12 files changed, 81 insertions(+), 63 deletions(-) create mode 100644 openair2/RRC/NR_UE/L2_interface_ue.h diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 266778ebca..84c8f60142 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -27,6 +27,7 @@ #include "PHY/INIT/nr_phy_init.h" #include "NR_MAC_UE/mac_proto.h" #include "RRC/NR_UE/rrc_proto.h" +#include "RRC/NR_UE/L2_interface_ue.h" #include "SCHED_NR_UE/phy_frame_config_nr.h" #include "SCHED_NR_UE/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 8d02ee9927..2d64de91e0 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -36,6 +36,8 @@ void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti, int gnb_id) {} void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) {} +void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) {} + void rrc_data_ind(const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const sdu_size_t sdu_sizeP, diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index fd465e6954..4f2d4d316a 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -248,8 +248,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) // TODO beam failure procedure not implemented } -void release_mac_configuration(NR_UE_MAC_INST_t *mac, - NR_UE_MAC_reset_cause_t cause) +void release_mac_configuration(NR_UE_MAC_INST_t *mac, NR_UE_MAC_reset_cause_t cause) { NR_UE_ServingCell_Info_t *sc = &mac->sc_info; // if cause is Re-establishment, release spCellConfig only diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 9264e4ad16..c26e8a5629 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -31,7 +31,7 @@ */ /* RRC */ -#include "RRC/NR_UE/rrc_proto.h" +#include "RRC/NR_UE/L2_interface_ue.h" /* MAC */ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 146429ddc7..4eb0e7b9a2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -38,7 +38,7 @@ #include "executables/nr-softmodem.h" /* RRC*/ -#include "RRC/NR_UE/rrc_proto.h" +#include "RRC/NR_UE/L2_interface_ue.h" /* MAC */ #include "NR_MAC_COMMON/nr_mac.h" diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 5744363119..84bb7c6e5d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -54,7 +54,7 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/RLC/rlc.h" -#include "RRC/NR_UE/rrc_proto.h" +#include "RRC/NR_UE/L2_interface_ue.h" //#define SRS_DEBUG #define verifyMutex(a) \ diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 4044cfd9dc..6dc6172ef7 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -41,7 +41,7 @@ #include "NR_MAC_UE/mac_extern.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "executables/softmodem-common.h" -#include "openair2/RRC/NR_UE/rrc_proto.h" +#include "openair2/RRC/NR_UE/L2_interface_ue.h" #include "openair2/GNB_APP/L1_nr_paramdef.h" #include "openair2/GNB_APP/gnb_paramdef.h" #include "radio/ETHERNET/if_defs.h" diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 26502cacf1..4f85dd3a03 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -51,6 +51,17 @@ typedef enum sl_sidelink_slot_type { } sl_sidelink_slot_type_t; +extern queue_t nr_rach_ind_queue; +extern queue_t nr_rx_ind_queue; +extern queue_t nr_crc_ind_queue; +extern queue_t nr_uci_ind_queue; +extern queue_t nr_sfn_slot_queue; +extern queue_t nr_chan_param_queue; +extern queue_t nr_dl_tti_req_queue; +extern queue_t nr_tx_req_queue; +extern queue_t nr_ul_dci_req_queue; +extern queue_t nr_ul_tti_req_queue; + extern slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index db26de9615..b2b4914c22 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -31,16 +31,14 @@ */ #include "rrc_defs.h" -#include "rrc_proto.h" +#include "L2_interface_ue.h" #include "assertions.h" #include "LAYER2/NR_MAC_COMMON/nr_mac.h" #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" typedef uint32_t channel_t; -void nr_mac_rrc_sync_ind(const module_id_t module_id, - const frame_t frame, - const bool in_sync) +void nr_mac_rrc_sync_ind(const module_id_t module_id, const frame_t frame, const bool in_sync) { MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_SYNC_IND); NR_RRC_MAC_SYNC_IND (message_p).frame = frame; @@ -48,17 +46,17 @@ void nr_mac_rrc_sync_ind(const module_id_t module_id, itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p); } -int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, - const int CC_id, - const uint8_t gNB_index, - const frame_t frame, - const int slot, - const rnti_t rnti, - const uint32_t cellid, - const long arfcn, - const channel_t channel, - const uint8_t* pduP, - const sdu_size_t pdu_len) +void nr_mac_rrc_data_ind_ue(const module_id_t module_id, + const int CC_id, + const uint8_t gNB_index, + const frame_t frame, + const int slot, + const rnti_t rnti, + const uint32_t cellid, + const long arfcn, + const channel_t channel, + const uint8_t* pduP, + const sdu_size_t pdu_len) { sdu_size_t sdu_size = 0; @@ -121,8 +119,6 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, default: break; } - - return(0); } void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) diff --git a/openair2/RRC/NR_UE/L2_interface_ue.h b/openair2/RRC/NR_UE/L2_interface_ue.h new file mode 100644 index 0000000000..708633b413 --- /dev/null +++ b/openair2/RRC/NR_UE/L2_interface_ue.h @@ -0,0 +1,45 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "rrc_defs.h" +#include "common/utils/ocp_itti/intertask_interface.h" + +#ifndef _L2_INTERFACE_UE_H_ +#define _L2_INTERFACE_UE_H_ +void nr_mac_rrc_sync_ind(const module_id_t module_id, const frame_t frame, const bool in_sync); +void nr_mac_rrc_data_ind_ue(const module_id_t module_id, + const int CC_id, + const uint8_t gNB_index, + const frame_t frame, + const int slot, + const rnti_t rnti, + const uint32_t cellid, + const long arfcn, + const channel_t channel, + const uint8_t* pduP, + const sdu_size_t pdu_len); +void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); +void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id); +void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id); +void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success); +void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); +#endif + diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 7345c06089..c254a48316 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -47,6 +47,7 @@ #include "rrc_defs.h" #include "rrc_proto.h" +#include "L2_interface_ue.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" #include "intertask_interface.h" diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 35d25ca466..95685c8e2f 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -39,57 +39,22 @@ #include "NR_MeasConfig.h" #include "NR_CellGroupConfig.h" #include "NR_RadioBearerConfig.h" -#include "openair2/PHY_INTERFACE/queue_t.h" #include "common/utils/ocp_itti/intertask_interface.h" -extern queue_t nr_rach_ind_queue; -extern queue_t nr_rx_ind_queue; -extern queue_t nr_crc_ind_queue; -extern queue_t nr_uci_ind_queue; -extern queue_t nr_sfn_slot_queue; -extern queue_t nr_chan_param_queue; -extern queue_t nr_dl_tti_req_queue; -extern queue_t nr_tx_req_queue; -extern queue_t nr_ul_dci_req_queue; -extern queue_t nr_ul_tti_req_queue; - NR_UE_RRC_INST_t *nr_rrc_init_ue(char* uecap_file, int nb_inst, int num_ant_tx); + void init_nsa_message (NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file); void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len); void nr_rrc_cellgroup_configuration(NR_UE_RRC_INST_t *rrc, NR_CellGroupConfig_t *cellGroupConfig); -/**\brief interface between MAC and RRC thru SRB0 (RLC TM/no PDCP) - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param channel indicator for channel of the pdu - \param pduP pointer to pdu - \param pdu_len data length of pdu*/ -int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, - const int CC_id, - const uint8_t gNB_index, - const frame_t frame, - const int slot, - const rnti_t rnti, - const uint32_t cellid, - const long arfcn, - const channel_t channel, - const uint8_t* pduP, - const sdu_size_t pdu_len); - -void nr_mac_rrc_sync_ind(const module_id_t module_id, - const frame_t frame, - const bool in_sync); - void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, NR_Release_Cause_t release_cause, NR_RRCRelease_t *RRCRelease); + void handle_RRCRelease(NR_UE_RRC_INST_t *rrc); -void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success); -void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id); -void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); + void set_rlf_sib1_timers_and_constants(NR_UE_Timers_Constants_t *tac, NR_SIB1_t *sib1); /**\brief RRC UE task. @@ -105,8 +70,6 @@ void *recv_msgs_from_lte_ue(void *args_p); void init_connections_with_lte_ue(void); -void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); - extern void start_oai_nrue_threads(void); int get_from_lte_ue_fd(); From 12229ef50e18ebf6cf31382b9700df982466b5f3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 1 Aug 2024 17:44:21 +0200 Subject: [PATCH 25/61] Smaller except blocks, add JSONDecodeError --- ci-scripts/cls_oaicitest.py | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 281f8b6d48..037f0fdf19 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -101,21 +101,23 @@ def Iperf_analyzeV3TCPJson(filename, iperf_tcp_rate_target): results = json.load(f) sender_bitrate = round(results['end']['streams'][0]['sender']['bits_per_second'] / 1000000, 2) receiver_bitrate = round(results['end']['streams'][0]['receiver']['bits_per_second'] / 1000000, 2) - snd_msg = f'Sender Bitrate : {sender_bitrate} Mbps' - rcv_msg = f'Receiver Bitrate : {receiver_bitrate} Mbps' - success = True - if (iperf_tcp_rate_target is not None): - if (int(receiver_bitrate) < int(iperf_tcp_rate_target)): - rcv_msg += f" (too low! < {iperf_tcp_rate_target} Mbps)" - success = False - else: - rcv_msg += f" (target : {iperf_tcp_rate_target} Mbps)" - return(success, f'{snd_msg}\n{rcv_msg}') + except json.JSONDecodeError as e: + return (False, f'Could not decode JSON log file {filename}: {e}') except KeyError as e: e_msg = results.get('error', f'error report not found in {filename}') return (False, f'While parsing Iperf3 results: missing key {e}, {e_msg}') except Exception as e: - return (False, f'While parsing Iperf3 results: generic exception: {e}') + return (False, f'While parsing Iperf3 results: exception: {e}') + snd_msg = f'Sender Bitrate : {sender_bitrate} Mbps' + rcv_msg = f'Receiver Bitrate : {receiver_bitrate} Mbps' + success = True + if iperf_tcp_rate_target is not None: + success = float(receiver_bitrate) >= float(iperf_tcp_rate_target) + if success: + rcv_msg += f" (target: {iperf_tcp_rate_target})" + else: + rcv_msg += f" (too low! < {iperf_tcp_rate_target})" + return(success, f'{snd_msg}\n{rcv_msg}') def Iperf_analyzeV3BIDIRJson(filename): try: @@ -125,16 +127,19 @@ def Iperf_analyzeV3BIDIRJson(filename): receiver_bitrate_ul = round(results['end']['streams'][0]['receiver']['bits_per_second'] / 1000000, 2) sender_bitrate_dl = round(results['end']['streams'][1]['sender']['bits_per_second'] / 1000000, 2) receiver_bitrate_dl = round(results['end']['streams'][1]['receiver']['bits_per_second'] / 1000000, 2) - msg = f'Sender Bitrate DL : {sender_bitrate_dl} Mbps\n' - msg += f'Receiver Bitrate DL : {receiver_bitrate_dl} Mbps\n' - msg += f'Sender Bitrate UL : {sender_bitrate_ul} Mbps\n' - msg += f'Receiver Bitrate UL : {receiver_bitrate_ul} Mbps\n' - return (True, msg) + except json.JSONDecodeError as e: + return (False, f'Could not decode JSON log file: {e}') except KeyError as e: e_msg = results.get('error', f'error report not found in {filename}') return (False, f'While parsing Iperf3 results: missing key {e}, {e_msg}') except Exception as e: - return (False, f'While parsing Iperf3 results: generic exception: {e}') + return (False, f'While parsing Iperf3 results: exception: {e}') + + msg = f'Sender Bitrate DL : {sender_bitrate_dl} Mbps\n' + msg += f'Receiver Bitrate DL : {receiver_bitrate_dl} Mbps\n' + msg += f'Sender Bitrate UL : {sender_bitrate_ul} Mbps\n' + msg += f'Receiver Bitrate UL : {receiver_bitrate_ul} Mbps\n' + return (True, msg) def Iperf_analyzeV3UDP(filename, iperf_bitrate_threshold, iperf_packetloss_threshold, target_bitrate): if (not os.path.isfile(filename)): From cf950dfa862b62cd3137ebb554036ead0d7ac27b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 22 Jul 2024 12:41:19 +0200 Subject: [PATCH 26/61] Remove netlink/PDCP_USE_NETLINK: it's not used Remove netlink code, and the PDCP_USE_NETLINK macro, as there is no known use, it makes the code more complicated, and is simply "technical debt". In 4G PDCP, a subtle change has been introduced, in pdcp_module_init() of pdcp.c. Looking at the diff of this commit, it can be seen that there is now a new "else-if (ENB_NAS_USE_TUN_W_MBMS_BIT)" branch that is under what was the "if (PDCP_USE_NETLINK)" branch, while the code fragment was actually inside the "else" branch of PDCP_USE_NETLINK. This seems to be necessary: previously, if we did not use noS1 mode and we don't use any TUN (i.e., the eNB), the else block would set up this interface. It is important that this interface is brought up, because if we omit it, RFsim will not work. It seems to me that this interface will regularly create some traffic; without it, RFsim will be blocked, and the UE cannot connect. In short, it seems to be important to have the MBMS interface, which injects traffic in the RFsim side, which will unblock RFsim. The change in pdcp_module_init() preserves the total changes of the if-else (PDCP_USE_NETLINK). --- CMakeLists.txt | 8 --- executables/lte-softmodem.c | 3 +- executables/lte-uesoftmodem.c | 2 +- executables/nr-softmodem.c | 9 +-- executables/nr-uesoftmodem.c | 2 +- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 69 ------------------- openair1/SIMULATION/ETH_TRANSPORT/proto.h | 2 - openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 59 +++++++--------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 2 - openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 26 +++---- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 56 +++++---------- 11 files changed, 56 insertions(+), 182 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faaacaa9ed..9ed31207d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1483,10 +1483,6 @@ add_library(L2_UE_LTE_NR ) target_link_libraries(L2_UE_LTE_NR PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) -if (NOT ${NOS1}) -target_compile_definitions(L2_UE PUBLIC -DPDCP_USE_NETLINK) -endif() - target_link_libraries(L2_UE PRIVATE asn1_lte_rrc_hdrs) add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} ) @@ -2004,9 +2000,6 @@ add_executable(lte-uesoftmodem ${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c ) -if (NOT ${NOS1}) - target_compile_definitions(lte-uesoftmodem PRIVATE -DPDCP_USE_NETLINK) -endif() target_link_libraries(lte-uesoftmodem PRIVATE -Wl,--start-group lte_rrc nr_rrc s1ap x2ap m2ap m3ap @@ -2413,7 +2406,6 @@ endfunction(make_driver name dir src) # nashmesh module ################ list(APPEND nasmesh_src device.c common.c ioctl.c classifier.c tool.c mesh.c) -set(module_cc_opt "${module_cc_opt} -DNAS_NETLINK -DPDCP_USE_NETLINK") # legacy Makefile was using NAS_NETLINK flag, but other drivers the hereafter flag # so, this cmake use OAI_NW_DRIVER_USE_NETLINK everywhere if (OAI_NW_DRIVER_USE_NETLINK) diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index c3bc90c175..5e93068b06 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -407,8 +407,7 @@ extern void phy_free_RU(RU_t *); static void init_pdcp(void) { pdcp_layer_init(); - uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_IP_DRIVER_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (IS_SOFTMODEM_NOS1) pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index 0754e1a239..eae196c2ef 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -488,7 +488,7 @@ static inline void wait_nfapi_init(char *thread_name) { } static void init_pdcp(int ue_id) { - uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index b188ead832..3449af32ae 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -543,7 +543,7 @@ static void wait_nfapi_init(char *thread_name) { void init_pdcp(void) { uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT: + LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT: LINK_ENB_PDCP_TO_GTPV1U_BIT; if (!NODE_IS_DU(get_node_type())) { @@ -654,12 +654,7 @@ int main( int argc, char **argv ) { itti_init(TASK_MAX, tasks_info); // initialize mscgen log after ITTI init_opt(); - if(PDCP_USE_NETLINK && !IS_SOFTMODEM_NOS1) { - netlink_init(); - if (get_softmodem_params()->nsa) { - init_pdcp(); - } - } + #ifndef PACKAGE_VERSION #define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 76d91bf800..fd2ef4b397 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -326,7 +326,7 @@ void init_openair0() static void init_pdcp(int ue_id) { - uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); /*if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 75f5e83632..a57c7a9090 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -51,10 +51,6 @@ char nl_rx_buf[NL_MAX_PAYLOAD]; struct sockaddr_nl nas_src_addr, nas_dest_addr; -struct nlmsghdr *nas_nlh_tx = NULL; -struct nlmsghdr *nas_nlh_rx = NULL; -struct iovec nas_iov_tx; -struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; int nas_sock_fd[MAX_MOBILES_PER_ENB*2]; //Allocated for both LTE UE and NR UE. @@ -63,8 +59,6 @@ int nas_sock_mbms_fd; struct msghdr nas_msg_tx; struct msghdr nas_msg_rx; -#define GRAAL_NETLINK_ID 31 - static int tun_alloc(char *dev) { struct ifreq ifr; int fd, err; @@ -162,66 +156,3 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, . return 1; } - - -int netlink_init(void) { - int ret; - nas_sock_fd[0] = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID); - - if (nas_sock_fd[0] == -1) { - printf("[NETLINK] Error opening GRAAL_NETLINK_ID socket %d (%d:%s)\n",nas_sock_fd[0],errno, strerror(errno)); - - if (LINK_ENB_PDCP_TO_IP_DRIVER) { - exit(1); - } - } - - printf("[NETLINK] Opened socket with fd %d\n",nas_sock_fd[0]); - ret = fcntl(nas_sock_fd[0],F_SETFL,O_NONBLOCK); - - if (ret == -1) { - printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); - - if (LINK_ENB_PDCP_TO_IP_DRIVER) { - exit(1); - } - } - - memset(&nas_src_addr, 0, sizeof(nas_src_addr)); - nas_src_addr.nl_family = AF_NETLINK; - nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ - nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_fd[0], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); - memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); - nas_dest_addr.nl_family = AF_NETLINK; - nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ - nas_dest_addr.nl_groups = 0; /* unicast */ - // TX PART - free(nas_nlh_tx); - nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - /* Fill the netlink message header */ - nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ - nas_nlh_tx->nlmsg_flags = 0; - nas_iov_tx.iov_base = (void *)nas_nlh_tx; - nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; - memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); - nas_msg_tx.msg_name = (void *)&nas_dest_addr; - nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); - nas_msg_tx.msg_iov = &nas_iov_tx; - nas_msg_tx.msg_iovlen = 1; - // RX PART - memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); - nas_msg_rx.msg_name = (void *)&nas_src_addr; - nas_msg_rx.msg_namelen = sizeof(nas_src_addr); - nas_msg_rx.msg_iov = &nas_iov_rx; - nas_msg_rx.msg_iovlen = 1; - return(nas_sock_fd[0]); -} - -void netlink_cleanup(void) -{ - free(nas_nlh_tx); - nas_nlh_tx = NULL; -} diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 4c51dea523..79e97f0e72 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -31,9 +31,7 @@ #ifndef EMU_PROTO_H_ #define EMU_PROTO_H_ -int netlink_init(void); int netlink_init_tun(char *ifsuffix, int num_if, int id); int netlink_init_mbms_tun(char *ifsuffix, int id); -void netlink_cleanup(void); #endif /* EMU_PROTO_H_ */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index c45171caaa..25a31c6873 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2291,46 +2291,35 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { this is while switching from noS1 as build option to noS1 as config option */ if ( pdcp_optmask & UE_NAS_USE_TUN_BIT) { - pdcp_params.optmask = pdcp_params.optmask | PDCP_USE_NETLINK_BIT ; + pdcp_params.optmask = pdcp_params.optmask; } pdcp_params.optmask = pdcp_params.optmask | pdcp_optmask ; - LOG_I(PDCP, "pdcp init,%s %s\n", - ((LINK_ENB_PDCP_TO_GTPV1U)?"usegtp":""), - ((PDCP_USE_NETLINK)?"usenetlink":"")); - if (PDCP_USE_NETLINK) { - nas_getparams(); + nas_getparams(); - if(UE_NAS_USE_TUN) { - int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun("ue",num_if, id); - if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, 2, "ue"); - netlink_init_mbms_tun("uem", id); - nas_config_mbms(1, 2, 2, "uem"); - LOG_I(PDCP, "UE pdcp will use tun interface\n"); - } else if(ENB_NAS_USE_TUN) { - netlink_init_tun("enb", 1, 0); - nas_config(1, 1, 1, "enb"); - if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ - netlink_init_mbms_tun("enm", 0); - nas_config_mbms(1, 2, 1, "enm"); - LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); - } - LOG_I(PDCP, "ENB pdcp will use tun interface\n"); - } else { - LOG_I(PDCP, "pdcp will use kernel modules\n"); - netlink_init(); + if (UE_NAS_USE_TUN) { + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; + netlink_init_tun("ue", num_if, id); + if (IS_SOFTMODEM_NOS1) + nas_config(1, 1, 2, "ue"); + netlink_init_mbms_tun("uem", id); + nas_config_mbms(1, 2, 2, "uem"); + LOG_I(PDCP, "UE pdcp will use tun interface\n"); + } else if (ENB_NAS_USE_TUN) { + netlink_init_tun("enb", 1, 0); + nas_config(1, 1, 1, "enb"); + if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { + netlink_init_mbms_tun("enm", 0); + nas_config_mbms(1, 2, 1, "enm"); + LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } - }else{ - if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ - LOG_W(PDCP, "ENB pdcp will use tun interface for MBMS\n"); - netlink_init_mbms_tun("enm", 0); - nas_config_mbms_s1(1, 2, 1, "enm"); - }else - LOG_E(PDCP, "ENB pdcp will not use tun interface\n"); - } + LOG_I(PDCP, "ENB pdcp will use tun interface\n"); + } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { + netlink_init_mbms_tun("enm", 0); + nas_config_mbms_s1(1, 2, 1, "enm"); + LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); + } pthread_create(&pdcp_stats_thread_desc,NULL,pdcp_stats_thread,NULL); @@ -2357,7 +2346,7 @@ pdcp_free ( void pdcp_module_cleanup (void) //----------------------------------------------------------------------------- { - netlink_cleanup(); + // empty - we could free all contexts, not implemented } //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 17460f824f..04b6dba0de 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -49,7 +49,6 @@ #define MAX_NUMBER_NETIF 1 //16 #define ENB_NAS_USE_TUN_W_MBMS_BIT (1<< 10) -#define PDCP_USE_NETLINK_BIT (1<< 11) #define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13) #define LINK_ENB_PDCP_TO_GTPV1U_BIT (1<< 14) #define UE_NAS_USE_TUN_BIT (1<< 15) @@ -59,7 +58,6 @@ typedef struct { } pdcp_params_t; -#define PDCP_USE_NETLINK ( get_pdcp_optmask() & PDCP_USE_NETLINK_BIT) #define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT) #define LINK_ENB_PDCP_TO_GTPV1U ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_GTPV1U_BIT) #define UE_NAS_USE_TUN ( get_pdcp_optmask() & UE_NAS_USE_TUN_BIT) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 11ee36669b..977208ef7c 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -136,12 +136,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { log_dump(PDCP, pdcpData, pdcpHead->data_size, LOG_DUMP_CHAR,"PDCP output to be sent to TUN interface: \n"); ret = write(nas_sock_fd[0], pdcpData, pdcpHead->data_size); LOG_T(PDCP,"[NB PDCP_FIFOS] ret %d TRIED TO PUSH DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[0],pdcpHead->data_size); - } else if (PDCP_USE_NETLINK) { - int sizeToWrite= sizeof (pdcp_data_ind_header_t) + pdcpHead->data_size; - memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) pdcpHead, sizeToWrite); - nas_nlh_tx->nlmsg_len = sizeToWrite; - ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0); - } // PDCP_USE_NETLINK + } AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s), nas_sock_fd[0]: %d\n", errno, strerror(errno), nas_sock_fd[0]); @@ -422,9 +417,9 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); if (len > 0) { - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK (nas_nlh_rx, len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { + for (struct nlmsghdr *nas_nlh_rx = (struct nlmsghdr *)nl_rx_buf; + NLMSG_OK(nas_nlh_rx, len); + nas_nlh_rx = NLMSG_NEXT(nas_nlh_rx, len)) { if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); //return; @@ -807,15 +802,10 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) } /* pdcp_fifo_read_input_sdus_frompc5s */ //----------------------------------------------------------------------------- -int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { - if (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) { - return pdcp_fifo_read_input_sdus_fromtun (ctxt_pP); - } else if (PDCP_USE_NETLINK) { - pdcp_fifo_read_input_sdus_frompc5s (ctxt_pP); - return pdcp_fifo_read_input_sdus_fromnetlinksock(ctxt_pP); - } /* PDCP_USE_NETLINK */ - - return 0; +int pdcp_fifo_read_input_sdus(const protocol_ctxt_t *const ctxt_pP) +{ + DevAssert(UE_NAS_USE_TUN || ENB_NAS_USE_TUN); + return pdcp_fifo_read_input_sdus_fromtun(ctxt_pP); } //TTN for D2D (PC5S) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 910270f35d..ceab4331ea 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -608,48 +608,30 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) initialized = 1; if (pthread_mutex_unlock(&m) != 0) abort(); -#if 0 - pdcp_optmask = _pdcp_optmask; - return pdcp_optmask; -#endif - /* temporary enforce netlink when UE_NAS_USE_TUN is set, - this is while switching from noS1 as build option - to noS1 as config option */ - if ( _pdcp_optmask & UE_NAS_USE_TUN_BIT) { - pdcp_optmask = pdcp_optmask | PDCP_USE_NETLINK_BIT ; - } - pdcp_optmask = pdcp_optmask | _pdcp_optmask ; - LOG_I(PDCP, "pdcp init,%s %s\n", - ((LINK_ENB_PDCP_TO_GTPV1U)?"usegtp":""), - ((PDCP_USE_NETLINK)?"usenetlink":"")); - if (PDCP_USE_NETLINK) { - nas_getparams(); + nas_getparams(); - if(UE_NAS_USE_TUN) { - char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue"; - int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun(ifsuffix_ue, num_if, id); - //Add --nr-ip-over-lte option check for next line - if (IS_SOFTMODEM_NOS1){ - nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); - set_qfi_pduid(7, 10); - } - LOG_I(PDCP, "UE pdcp will use tun interface\n"); - start_pdcp_tun_ue(); - } else if(ENB_NAS_USE_TUN) { - char *ifsuffix_base_s = get_softmodem_params()->nsa ? "gnb" : "enb"; - netlink_init_tun(ifsuffix_base_s, 1, id); - nas_config(1, 1, 1, ifsuffix_base_s); - LOG_I(PDCP, "ENB pdcp will use tun interface\n"); - start_pdcp_tun_enb(); - } else { - LOG_I(PDCP, "pdcp will use kernel modules\n"); - abort(); - netlink_init(); + if (UE_NAS_USE_TUN) { + char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue"; + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) + ? MAX_MOBILES_PER_ENB + : 1; + netlink_init_tun(ifsuffix_ue, num_if, id); + if (IS_SOFTMODEM_NOS1) { + nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); + set_qfi_pduid(7, 10); } + LOG_I(PDCP, "UE pdcp will use tun interface\n"); + start_pdcp_tun_ue(); + } else if (ENB_NAS_USE_TUN) { + char *ifsuffix_base_s = get_softmodem_params()->nsa ? "gnb" : "enb"; + netlink_init_tun(ifsuffix_base_s, 1, id); + nas_config(1, 1, 1, ifsuffix_base_s); + LOG_I(PDCP, "ENB pdcp will use tun interface\n"); + start_pdcp_tun_enb(); } + return pdcp_optmask ; } From f680babbddd686f4365340888af70d6cb1d381eb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 16 Jul 2024 19:19:18 +0200 Subject: [PATCH 27/61] Remove unused pdcp_netlink.c file --- openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c | 269 -------------------- 1 file changed, 269 deletions(-) delete mode 100644 openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c deleted file mode 100644 index b832fee136..0000000000 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file pdcp_netlink.c - * \brief pdcp communication with linux IP interface, - * have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink. - * Read operation from netlink should be achieved in an asynchronous way to avoid - * subframe overload, netlink congestion... - * \author Sebastien ROUX - * \date 2013 - * \version 0.1 - * @ingroup pdcp - */ - -#define _GNU_SOURCE // required for pthread_setname_np() -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Bugfix for version of GCC = 4.4.3 (Ubuntu 10.04) */ -#if GCC_VERSION <= 40403 - #include -#endif - -#include - -#include "assertions.h" -#include "queue.h" -#include "liblfds611.h" - -#include "common/utils/LOG/log.h" -#include "common/utils/system.h" -#include "LAYER2/MAC/mac_extern.h" - -#include "pdcp.h" -#include "pdcp_primitives.h" - - -#define PDCP_QUEUE_NB_ELEMENTS 200 - -extern char nl_rx_buf[NL_MAX_PAYLOAD]; -extern struct nlmsghdr *nas_nlh_rx; -extern struct iovec nas_iov_rx; -extern int nas_sock_fd; -extern struct msghdr nas_msg_rx; - - -static pthread_t pdcp_netlink_thread; - -/* We use lock-free queues between the User-plane driver running in kernel-space - * and the corresponding entity in User-space. - * one queue for eNBs (index 0)/one queue for UEs (index 1) - */ -static struct lfds611_queue_state **pdcp_netlink_queue_enb = NULL; -static struct lfds611_queue_state **pdcp_netlink_queue_ue = NULL; -static uint32_t *pdcp_netlink_nb_element_enb = NULL; -static uint32_t *pdcp_netlink_nb_element_ue = NULL; - -time_stats_t ip_pdcp_stats_tmp; - -static void *pdcp_netlink_thread_fct(void *arg); - -//----------------------------------------------------------------------------- -int -pdcp_netlink_init( - void -) -//----------------------------------------------------------------------------- -{ - int i; - int nb_inst_enb; - int nb_inst_ue; - - reset_meas(&ip_pdcp_stats_tmp); - nb_inst_enb = 1; - nb_inst_ue = 1; - - if (LINK_ENB_PDCP_TO_GTPV1U) { - nb_inst_enb = 0; - LOG_I(PDCP, "[NETLINK] Creating 0 queues for eNB Netlink -> PDCP communication\n"); - } else { - /* #warning " LG: When there will be handover in, there will problems because dim is based on local nums of ues" */ - pdcp_netlink_queue_enb = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state *)); - pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t)); - LOG_I(PDCP, "[NETLINK] Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb); - - for (i = 0; i < nb_inst_enb; i++) { - pdcp_netlink_nb_element_enb[i] = 0; - - if (lfds611_queue_new(&pdcp_netlink_queue_enb[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { - LOG_E(PDCP, "Failed to create new FIFO for eNB Netlink -> PDCP communcation instance %d\n", i); - exit(EXIT_FAILURE); - } - } - } - - if (nb_inst_ue > 0) { - pdcp_netlink_queue_ue = calloc(nb_inst_ue, sizeof(struct lfds611_queue_state *)); - pdcp_netlink_nb_element_ue = malloc(nb_inst_ue * sizeof(uint32_t)); - LOG_I(PDCP, "[NETLINK] Creating %d queues for UE Netlink -> PDCP communication\n", nb_inst_ue); - - for (i = 0; i < nb_inst_ue; i++) { - pdcp_netlink_nb_element_ue[i] = 0; - - if (lfds611_queue_new(&pdcp_netlink_queue_ue[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { - LOG_E(PDCP, "Failed to create new FIFO for UE Netlink -> PDCP communcation instance %d\n", i); - exit(EXIT_FAILURE); - } - } - } - - if ((nb_inst_ue + nb_inst_enb) > 0) { - /* Create one thread that fetchs packets from the netlink. - * When the netlink fifo is full, packets are silently dropped, this behaviour - * should be avoided if we want a reliable link. - */ - threadCreate(&pdcp_netlink_thread, pdcp_netlink_thread_fct, (void*)NULL, "PDCP netlink", -1, OAI_PRIORITY_RT_LOW ); - } - - return 0; -} - -//----------------------------------------------------------------------------- -int -pdcp_netlink_dequeue_element( - const protocol_ctxt_t *const ctxt_pP, - struct pdcp_netlink_element_s **data_ppP -) -//----------------------------------------------------------------------------- -{ - int ret = 0; - - if (ctxt_pP->enb_flag) { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[ctxt_pP->module_id], (void **)data_ppP); - - if (ret != 0) { - LOG_D(PDCP,"[NETLINK]De-queueing packet for eNB instance %d\n", ctxt_pP->module_id); - } - } else { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ctxt_pP->module_id], (void **)data_ppP); - - if (ret != 0) { - LOG_D(PDCP, "[NETLINK]De-queueing packet for UE instance %d\n", ctxt_pP->module_id); - } - } - - return ret; -} - -//----------------------------------------------------------------------------- -static -void *pdcp_netlink_thread_fct(void *arg) -//----------------------------------------------------------------------------- -{ - int len = 0; - struct pdcp_netlink_element_s *new_data_p = NULL; - uint8_t pdcp_thread_read_state ; - eNB_flag_t eNB_flag = 0; - module_id_t module_id = 0; - pdcp_thread_read_state = 0; - memset(nl_rx_buf, 0, NL_MAX_PAYLOAD); - LOG_I(PDCP, "[NETLINK_THREAD] binding to fd %d\n",nas_sock_fd); - - while (1) { - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); - - if (len == 0) { - /* Other peer (kernel) has performed an orderly shutdown - */ - LOG_E(PDCP, "[NETLINK_THREAD] Kernel module has closed the netlink\n"); - exit(EXIT_FAILURE); - } else if (len < 0) { - /* There was an error */ - LOG_E(PDCP, "[NETLINK_THREAD] An error occured while reading netlink (%d:%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } else { - /* Normal read. - * NOTE: netlink messages can be assembled to form a multipart message - */ - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK(nas_nlh_rx, (unsigned int)len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { - start_meas(&ip_pdcp_stats_tmp); - - /* There is no need to check for nlmsg_type because - * the header is not set in our drivers. - */ - if (pdcp_thread_read_state == 0) { - new_data_p = malloc(sizeof(struct pdcp_netlink_element_s)); - - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_thread_read_state = 1; - memcpy((void *)&new_data_p->pdcp_read_header, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_I(PDCP, "[NETLINK_THREAD] RX pdcp_data_req_header_t inst %u, " - "rb_id %ld data_size %d\n", - new_data_p->pdcp_read_header.inst, - new_data_p->pdcp_read_header.rb_id, - new_data_p->pdcp_read_header.data_size); - } else { - LOG_E(PDCP, "[NETLINK_THREAD] WRONG size %d should be sizeof " - "%lu ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n", - nas_nlh_rx->nlmsg_len, - sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)); - } - } else { - pdcp_thread_read_state = 0; - module_id = 0; - new_data_p->data = malloc(sizeof(uint8_t) * new_data_p->pdcp_read_header.data_size); - /* Copy the data */ - memcpy(new_data_p->data, NLMSG_DATA(nas_nlh_rx), new_data_p->pdcp_read_header.data_size); - - if (eNB_flag) { - if (pdcp_netlink_nb_element_enb[module_id] - > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in eNB pdcp queue (%lu)\n", - module_id, (intptr_t)pdcp_netlink_nb_element_enb); - } - - LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for eNB module id %d\n", module_id); - /* Enqueue the element in the right queue */ - lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[module_id], new_data_p); - stop_meas(&ip_pdcp_stats_tmp); - copy_meas(&eNB_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp); - } else { - if (pdcp_netlink_nb_element_ue[module_id] - > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in UE pdcp queue (%lu)\n", - module_id, (intptr_t)pdcp_netlink_nb_element_ue); - } - - LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for UE module id %d\n", module_id); - /* Enqueue the element in the right queue */ - lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[module_id], new_data_p); - stop_meas(&ip_pdcp_stats_tmp); - copy_meas(&UE_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp); - } - } - } - } - } - - return NULL; -} - From 8f549a54338ae3b67197a4958e5c5ddec9927a8e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 22 Jul 2024 11:17:31 +0200 Subject: [PATCH 28/61] Remove rb_config: it's not used by any code currently in use --- CMakeLists.txt | 4 - doc/Doxyfile | 2 - openair2/RRC/LTE/rrc_UE.c | 9 +- openair2/RRC/LTE/rrc_eNB.c | 11 +- openair2/RRC/NAS/rb_config.c | 241 ----------------------------------- openair2/RRC/NAS/rb_config.h | 38 ------ openair2/RRC/NR/rrc_gNB.c | 1 - openair2/RRC/NR_UE/rrc_UE.c | 1 - 8 files changed, 2 insertions(+), 305 deletions(-) delete mode 100644 openair2/RRC/NAS/rb_config.c delete mode 100644 openair2/RRC/NAS/rb_config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed31207d2..78c1408ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1935,7 +1935,6 @@ add_executable(lte-softmodem ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c - ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${PHY_INTERFACE_DIR}/queue_t.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c @@ -1993,7 +1992,6 @@ add_executable(lte-uesoftmodem ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c - ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c @@ -2030,7 +2028,6 @@ add_executable(nr-softmodem ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c - ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${PHY_INTERFACE_DIR}/queue_t.c @@ -2102,7 +2099,6 @@ add_executable(nr-uesoftmodem ${OPENAIR_DIR}/radio/COMMON/record_player.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c - ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c ) diff --git a/doc/Doxyfile b/doc/Doxyfile index 4777455bfc..6e1c7828e1 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1874,8 +1874,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/L2_interface_ue.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/rb_config.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/rb_config.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_internode.c \ diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 6aa452ed99..a7a8bb8fb3 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -68,7 +68,6 @@ #include "NR_UE-CapabilityRAT-Container.h" #include "RRC/NAS/nas_config.h" -#include "RRC/NAS/rb_config.h" #if ENABLE_RAL #include "rrc_UE_ral.h" #endif @@ -776,13 +775,7 @@ rrc_ue_establish_drb( ue_mod_idP, ip_addr_offset3+ue_mod_idP, (long int)((eNB_index * LTE_maxDRB) + DRB_config->drb_Identity)); - rb_conf_ipv4(0,//add - ue_mod_idP,//cx align with the UE index - ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index - (eNB_index * LTE_maxDRB) + DRB_config->drb_Identity,//rb - 0,//dscp - ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr - ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr + AssertFatal(false, "not implemented\n"); LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); } } // !EPC_MODE_ENABLED diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index a5ad82b61e..8b086b1387 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -79,7 +79,6 @@ #include "LTE_MeasResults.h" #include "RRC/NAS/nas_config.h" -#include "RRC/NAS/rb_config.h" #include "rrc_eNB_S1AP.h" #include "rrc_eNB_GTPV1U.h" @@ -5144,7 +5143,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( { int drb_id; int oip_ifup = 0; - int dest_ip_offset = 0; uint8_t kRRCenc[32] = {0}; uint8_t kRRCint[32] = {0}; uint8_t kUPenc[32] = {0}; @@ -5264,19 +5262,12 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( if (oip_ifup == 0) { // interface is up --> send a config the DRB module_id_t ue_module_id; - dest_ip_offset = 8; LOG_I(OIP, "[eNB %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", ctxt_pP->module_id, ctxt_pP->module_id, (long int)((ue_context_pP->local_uid * LTE_maxDRB) + DRB_configList->list.array[i]->drb_Identity)); ue_module_id = 0; // Was oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[ctxt_pP->module_id][ue_context_pP->local_uid]; - rb_conf_ipv4(0, //add - ue_module_id, //cx - ctxt_pP->module_id, //inst - (ue_module_id * LTE_maxDRB) + DRB_configList->list.array[i]->drb_Identity, // RB - 0, //dscp - ipv4_address(ctxt_pP->module_id + 1, ctxt_pP->module_id + 1), //saddr - ipv4_address(ctxt_pP->module_id + 1, dest_ip_offset + ue_module_id + 1)); //daddr + AssertFatal(false, "not implemented\n"); LOG_D(RRC, "[eNB %d] State = Attached (UE rnti %x module id %u)\n", ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ue_module_id); } /* oip_ifup */ diff --git a/openair2/RRC/NAS/rb_config.c b/openair2/RRC/NAS/rb_config.c deleted file mode 100644 index 17b180131f..0000000000 --- a/openair2/RRC/NAS/rb_config.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rb_config.c -* \brief User-space utility for configuring NASMESH IOCTL interface -* \author Raymond Knopp and Navid Nikaein -* \date 2009 -* \version 1.1 -* \warning -* @ingroup driver - -*/ - -#include -#include - -#include "nas_config.h" -#include "common/utils/LOG/log.h" - -#include "NETWORK_DRIVER/MESH/rrc_nas_primitives.h" -#include "NETWORK_DRIVER/MESH/ioctl.h" -#include "NETWORK_DRIVER/MESH/constant.h" - - -#define BUF_SIZE 800 - -// Global variables -//int sd_graal; -//int fd; // moved to the struct rb_config -//char myIPAddr[16]; // local IP Address -//int meas_counter; -//struct ralu_priv ru_priv; -//struct ralu_priv *ralupriv; - -//ioctl -char dummy_buffer[BUF_SIZE]; // moved to stats req -struct nas_ioctl gifr; -//int wait_start_nas; - -static int fd; -static int socket_enabled; - -static void init_socket(void) -{ - - if ((fd=socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - LOG_E(OIP,"ERROR opening socket\n"); - socket_enabled=0; - } - - socket_enabled=1; -} - -static void rb_ioctl_init(int inst) -{ - - /* init the gifr struct for the given inst */ - sprintf(gifr.name, "oai%d",inst); - memset ((void *)dummy_buffer,0,BUF_SIZE); - gifr.msg= &(dummy_buffer[0]); -} - - -static int rb_validate_config_ipv4(int cx, int inst, int rb) -{ - - if (inst == -1) { - LOG_E(OIP,"Specify an interface\n"); - return(1); - } - - if (rb == -1) { - LOG_E(OIP,"Specify an RAB identifier \n"); - return (1); - } - - if (cx == -1) { - LOG_E(OIP,"Specify an LCR \n"); - return(1); - } - - /* - if ( inet_aton(src,&saddr_ipv4)<= 0) { - LOG_E(OIP,"Specify a source IP address\n"); - return(1); - } - if (inet_aton(src,&saddr_ipv4)<= 0 0) { - LOG_E(OIP,"Specify a destination IP address\n"); - return(1); - } - */ - return (0); - -} - -int rb_conf_ipv4(int action,int cx, int inst, int rb, int dscp, in_addr_t saddr_ipv4, in_addr_t daddr_ipv4) -{ - //int rb_conf_ipv6(int action,int cx, int inst, int qos, in6_addr src, in6_addr dst) { - //int rb_conf(rb_config *rb_cfg) { - - int err; - - struct nas_msg_rb_establishment_request *msgreq; - struct nas_msg_class_add_request *msgreq_class; - - struct nas_msg_rb_release_request *msgrel; - struct nas_msg_class_del_request *msgdel_class; - - if (socket_enabled ==0) { - init_socket(); - } - - rb_ioctl_init(inst); - - if (rb_validate_config_ipv4(cx,inst,rb) > 0) { - LOG_E(OIP, "OIP configuration failed, inputs parameters incorrect\n"); - return (1); - } - - // add an OIP - if (action == 0 ) { - - msgreq = (struct nas_msg_rb_establishment_request *)(gifr.msg); - msgreq->rab_id = (nasRadioBearerId_t) rb; - msgreq->lcr = (nasRadioBearerId_t) cx; - msgreq->qos = 0; - - gifr.type = NAS_MSG_RB_ESTABLISHMENT_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0) { - perror("IOCTL error: OIP ESTAB REQ\n"); - LOG_E(OIP,"IOCTL error: OIP ESTAB REQ"); - } - - msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = (nasRadioBearerId_t) rb; - msgreq_class->lcr = (nasRadioBearerId_t) cx; - msgreq_class->version = 4;//ipv4 - - msgreq_class->classref = 0 + (msgreq_class->lcr<<3); - msgreq_class->dir = NAS_DIRECTION_SEND; - msgreq_class->fct = NAS_FCT_QOS_SEND; - msgreq_class->saddr.ipv4 = saddr_ipv4; - msgreq_class->daddr.ipv4 = daddr_ipv4; - - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = NAS_PROTOCOL_DEFAULT; - msgreq_class->dscp=dscp; - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0 ) { - perror("IOCTL error: DIR SEND: ADD REQ"); - LOG_E(OIP,"IOCTL error: DIR SEND: ADD REQ\n"); - } - - msgreq_class->rab_id = (nasRadioBearerId_t)rb; - msgreq_class->lcr = (nasRadioBearerId_t)cx; - msgreq_class->classref = 1+(msgreq_class->lcr<<3); - msgreq_class->dir = NAS_DIRECTION_RECEIVE; - msgreq_class->daddr.ipv4 = saddr_ipv4; - msgreq_class->saddr.ipv4 = daddr_ipv4; - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0 ) { - perror("IOCTL error: DIR RECEIVE: ADD REQ"); - LOG_E(OIP,"IOCTL error: DIR RECEIVE: ADD REQ\n"); - } - - } - // OIP DEL - else if (action == 1) { - - msgrel = (struct nas_msg_rb_release_request *)(gifr.msg); - msgrel->rab_id = rb; - msgrel->lcr = cx; - - gifr.type = NAS_MSG_RB_RELEASE_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0) { - perror("IOCTL error: OIP RELEASE REQ"); - LOG_E(OIP,"IOCTL error: OIP RELEASE REQ\n"); - } - - msgdel_class = (struct nas_msg_class_del_request *)(gifr.msg); - msgdel_class->lcr = cx; - msgdel_class->dir = NAS_DIRECTION_SEND; - msgdel_class->classref = 0 + (msgdel_class->lcr<<3); - msgdel_class->dscp=dscp; - - gifr.type = NAS_MSG_CLASS_DEL_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0 ) { - perror("IOCTL error: DIR SEND : CLASS DEL REQ"); - LOG_E(OIP,"IOCTL error: DIR SEND : CLASS DEL REQ\n"); - } - - msgdel_class->lcr = cx; - msgdel_class->classref = 1+(msgdel_class->lcr<<3); - msgdel_class->dir = NAS_DIRECTION_RECEIVE; - - gifr.type = NAS_MSG_CLASS_DEL_REQUEST; - - if ((err=ioctl(fd, NAS_IOCTL_RRM, &gifr)) < 0 ) { - perror("IOCTL error: DIR RECEIVE : CLASS DEL REQ"); - LOG_E(OIP,"IOCTL erro: DIR RECEIVE : CLASS DEL REQ\n"); - } - - } - - return(0); - -} - -in_addr_t ipv4_address (int thirdOctet, int fourthOctet) -{ - - struct in_addr saddr_ipv4; - char ipAddress[20]; - sprintf(ipAddress, "10.0.%d.%d",thirdOctet,fourthOctet); - inet_aton(ipAddress,&saddr_ipv4); - return saddr_ipv4.s_addr; - -} diff --git a/openair2/RRC/NAS/rb_config.h b/openair2/RRC/NAS/rb_config.h deleted file mode 100644 index f00a9573a5..0000000000 --- a/openair2/RRC/NAS/rb_config.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/** \file rb_config.h - * \brief Openair radio bearer configuration header file - * \author Raymond Knopp and Navid Nikaein - */ - -#ifndef __RB_CONFIG_H__ -#define __RB_CONFIG_H__ - -#include - -int rb_conf_ipv4(int action,int cx, int inst, int rb, int dscp, in_addr_t saddr_ipv4, in_addr_t daddr_ipv4); -void rb_ioctl_init(int inst); -in_addr_t ipv4_address (int thirdOctet, int fourthOctet); - - - -#endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index db737823fe..08b6b334af 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -74,7 +74,6 @@ #include "T.h" #include "RRC/NAS/nas_config.h" -#include "RRC/NAS/rb_config.h" #include "openair3/SECU/secu_defs.h" diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index cab08077ce..f214c70351 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -66,7 +66,6 @@ #endif #include "RRC/NAS/nas_config.h" -#include "RRC/NAS/rb_config.h" #include "SIMULATION/TOOLS/sim.h" // for taus #include "nr_nas_msg_sim.h" From 6b21dea1eed859678a3a1df3f39d1b13c444f032 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 12 Jul 2024 17:44:46 +0200 Subject: [PATCH 29/61] Remove legacy 4G kernel modules I don't know about any user of the kernel modules. It is effectively legacy code we carry around, for no good reason. Remove it for the moment. If we ever need it, we can revert. --- CMakeLists.txt | 84 +- cmake_targets/build_oai | 5 +- cmake_targets/tools/build_helper | 4 - cmake_targets/tools/init_nas_nos1 | 54 - cmake_targets/tools/init_nas_s1 | 71 -- doc/BUILD.md | 1 - openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 6 +- openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile | 11 - .../NETWORK_DRIVER/LITE/RB_TOOL/rb_tool.c | 496 --------- openair2/NETWORK_DRIVER/LITE/classifier.c | 194 ---- openair2/NETWORK_DRIVER/LITE/common.c | 451 -------- openair2/NETWORK_DRIVER/LITE/constant.h | 174 ---- openair2/NETWORK_DRIVER/LITE/device.c | 635 ------------ openair2/NETWORK_DRIVER/LITE/ioctl.c | 129 --- openair2/NETWORK_DRIVER/LITE/ioctl.h | 256 ----- openair2/NETWORK_DRIVER/LITE/local.h | 132 --- openair2/NETWORK_DRIVER/LITE/netlink.c | 199 ---- openair2/NETWORK_DRIVER/LITE/proto_extern.h | 173 ---- openair2/NETWORK_DRIVER/LITE/sap.h | 40 - openair2/NETWORK_DRIVER/LITE/tool.c | 747 ------------- openair2/NETWORK_DRIVER/MESH/RB_TOOL/Makefile | 12 - .../NETWORK_DRIVER/MESH/RB_TOOL/rb_tool.c | 413 -------- .../NETWORK_DRIVER/MESH/TESTBENCH/testbench.c | 149 --- openair2/NETWORK_DRIVER/MESH/classifier.c | 758 -------------- openair2/NETWORK_DRIVER/MESH/common.c | 618 ----------- openair2/NETWORK_DRIVER/MESH/constant.h | 173 ---- openair2/NETWORK_DRIVER/MESH/device.c | 509 --------- openair2/NETWORK_DRIVER/MESH/ioctl.c | 860 --------------- openair2/NETWORK_DRIVER/MESH/ioctl.h | 245 ----- openair2/NETWORK_DRIVER/MESH/local.h | 181 ---- openair2/NETWORK_DRIVER/MESH/mesh.c | 980 ------------------ openair2/NETWORK_DRIVER/MESH/netlink.c | 212 ---- openair2/NETWORK_DRIVER/MESH/proto_extern.h | 304 ------ .../NETWORK_DRIVER/MESH/rrc_nas_primitives.h | 280 ----- openair2/NETWORK_DRIVER/MESH/sap.h | 65 -- openair2/NETWORK_DRIVER/MESH/tool.c | 888 ---------------- openair2/NETWORK_DRIVER/UE_IP/README | 1 - openair2/NETWORK_DRIVER/UE_IP/common.c | 359 ------- openair2/NETWORK_DRIVER/UE_IP/constant.h | 59 -- openair2/NETWORK_DRIVER/UE_IP/device.c | 442 -------- openair2/NETWORK_DRIVER/UE_IP/local.h | 107 -- openair2/NETWORK_DRIVER/UE_IP/netlink.c | 204 ---- openair2/NETWORK_DRIVER/UE_IP/proto_extern.h | 139 --- openair2/NETWORK_DRIVER/UE_IP/sap.h | 28 - targets/DOCS/nfapi-L2-emulator-setup.txt | 3 - targets/TEST/PACKET_TRACER/Makefile | 157 --- targets/TEST/PACKET_TRACER/README.txt | 35 - targets/TEST/PACKET_TRACER/messages/Msg4.txt | 1 - .../messages/rrcconnectionreconfiguration.txt | 1 - .../messages/rrcconnectionsetup.txt | 1 - targets/TEST/PACKET_TRACER/messages/sib1.txt | 1 - targets/TEST/PACKET_TRACER/messages/sib2.txt | 1 - .../PACKET_TRACER/messages/sib2_3_oai.txt | 1 - .../messages/sib2_3_oai_Rel10.txt | 1 - targets/TEST/PACKET_TRACER/messages/sib3.txt | 1 - targets/TEST/PACKET_TRACER/pt.c | 734 ------------- 56 files changed, 4 insertions(+), 12781 deletions(-) delete mode 100755 cmake_targets/tools/init_nas_nos1 delete mode 100755 cmake_targets/tools/init_nas_s1 delete mode 100644 openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile delete mode 100644 openair2/NETWORK_DRIVER/LITE/RB_TOOL/rb_tool.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/classifier.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/common.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/constant.h delete mode 100644 openair2/NETWORK_DRIVER/LITE/device.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/ioctl.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/ioctl.h delete mode 100644 openair2/NETWORK_DRIVER/LITE/local.h delete mode 100644 openair2/NETWORK_DRIVER/LITE/netlink.c delete mode 100644 openair2/NETWORK_DRIVER/LITE/proto_extern.h delete mode 100644 openair2/NETWORK_DRIVER/LITE/sap.h delete mode 100644 openair2/NETWORK_DRIVER/LITE/tool.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/RB_TOOL/Makefile delete mode 100644 openair2/NETWORK_DRIVER/MESH/RB_TOOL/rb_tool.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/TESTBENCH/testbench.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/classifier.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/common.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/constant.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/device.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/ioctl.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/ioctl.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/local.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/mesh.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/netlink.c delete mode 100644 openair2/NETWORK_DRIVER/MESH/proto_extern.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/rrc_nas_primitives.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/sap.h delete mode 100644 openair2/NETWORK_DRIVER/MESH/tool.c delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/README delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/common.c delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/constant.h delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/device.c delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/local.h delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/netlink.c delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/proto_extern.h delete mode 100644 openair2/NETWORK_DRIVER/UE_IP/sap.h delete mode 100644 targets/TEST/PACKET_TRACER/Makefile delete mode 100644 targets/TEST/PACKET_TRACER/README.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/Msg4.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/rrcconnectionreconfiguration.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/rrcconnectionsetup.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/sib1.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/sib2.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/sib2_3_oai.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/sib2_3_oai_Rel10.txt delete mode 100644 targets/TEST/PACKET_TRACER/messages/sib3.txt delete mode 100644 targets/TEST/PACKET_TRACER/pt.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 78c1408ca9..4a4cfd3e55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,9 +508,6 @@ include_directories ("${OPENAIR_DIR}/radio/COMMON") # ???!!! TO BE DOCUMENTED OPTIONS !!!??? ############################################################## -add_boolean_option(OAI_NW_DRIVER_TYPE_ETHERNET False "????" ON) -add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????" ON) - add_boolean_option(UE_EXPANSION False "enable UE_EXPANSION with max 256 UE" ON) add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION with max 256 UE" ON) add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE" ON) @@ -2331,7 +2328,7 @@ endforeach(myExe) #ensure that the T header files are generated before targets depending on them if (${T_TRACER}) foreach(i - #all "add_executable" definitions (except tests, rb_tool, updatefw) + #all "add_executable" definitions (except tests, updatefw) lte-softmodem lte-uesoftmodem nr-softmodem nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim @@ -2354,85 +2351,6 @@ if (${T_TRACER}) endforeach(i) endif (${T_TRACER}) -################################################## -# Generated specific cases is not regular code -############################################### - -################ -# Kernel modules -############### -# Set compiler options for kernel modules -# we need to get out cmake to use the regular Linux Kernel process -# this is documented as https://www.kernel.org/doc/Documentation/kbuild/modules.txt -###################################### - -# retrieve the compiler options to send it to gccxml -get_directory_property(DirDefs COMPILE_DEFINITIONS ) -foreach( d ${DirDefs} ) - set(module_cc_opt "${module_cc_opt} -D${d}") -endforeach() -get_directory_property( DirDefs INCLUDE_DIRECTORIES ) -foreach( d ${DirDefs} ) - set(module_cc_opt "${module_cc_opt} -I${d}") -endforeach() - -EXECUTE_PROCESS(COMMAND uname -r - OUTPUT_VARIABLE os_release - OUTPUT_STRIP_TRAILING_WHITESPACE) -SET(module_build_path /lib/modules/${os_release}/build) - -function(make_driver name dir) - file(MAKE_DIRECTORY ${OPENAIR_BIN_DIR}/${name}) - foreach(f IN ITEMS ${ARGN}) - list(APPEND src_path_list ${dir}/${f}) - string(REGEX REPLACE "c *$" "o" obj ${f}) - set(objs "${objs} ${obj}") - endforeach() - CONFIGURE_FILE(${OPENAIR_CMAKE}/tools/Kbuild.cmake ${OPENAIR_BIN_DIR}/${name}/Kbuild) - add_custom_command(OUTPUT ${name}.ko - COMMAND make -C ${module_build_path} M=${OPENAIR_BIN_DIR}/${name} - WORKING_DIRECTORY ${OPENAIR_BIN_DIR}/${name} - COMMENT "building ${module}.ko" - VERBATIM - SOURCES ${src_path_list} - ) - add_custom_target(${name} DEPENDS ${name}.ko) -endfunction(make_driver name dir src) - -# nashmesh module -################ -list(APPEND nasmesh_src device.c common.c ioctl.c classifier.c tool.c mesh.c) -# legacy Makefile was using NAS_NETLINK flag, but other drivers the hereafter flag -# so, this cmake use OAI_NW_DRIVER_USE_NETLINK everywhere -if (OAI_NW_DRIVER_USE_NETLINK) - list(APPEND nasmesh_src netlink.c) -endif() -make_driver(nasmesh ${OPENAIR2_DIR}/NETWORK_DRIVER/MESH ${nasmesh_src}) - -# user space tool for configuring MESH IP driver -################ -add_executable(rb_tool - ${OPENAIR2_DIR}/NETWORK_DRIVER/MESH/RB_TOOL/rb_tool.c -) -target_include_directories(rb_tool PRIVATE ${OPENAIR2_DIR}/NETWORK_DRIVER/MESH/) - -# ??? -#################### -list(APPEND oai_nw_drv_src device.c common.c ioctl.c classifier.c tool.c) -if(OAI_NW_DRIVER_USE_NETLINK) - list(APPEND oai_nw_drv_src netlink.c) -endif() -make_driver(oai_nw_drv ${OPENAIR2_DIR}/NETWORK_DRIVER/LTE ${oai_nw_drv_src}) - - -# ue_ip: purpose ??? -############### -list(APPEND ue_ip_src device.c common.c) -if(OAI_NW_DRIVER_USE_NETLINK) - list(APPEND ue_ip_src netlink.c) -endif() -make_driver(ue_ip ${OPENAIR2_DIR}/NETWORK_DRIVER/UE_IP ${ue_ip_src}) - include(${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/CMakeLists.txt) set(ENABLE_TESTS OFF CACHE STRING "Activate build of tests") diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 3e688923fb..cd7e326be8 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -85,7 +85,7 @@ Options: --RU Makes the OAI RRU --UE - Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file + Makes the UE specific parts (usim, nvram) from the given configuration file --nrUE Makes the NR UE softmodem --UE-conf-nvram [configuration file] @@ -271,9 +271,6 @@ function main() { --UE-gen-nvram) gen_nvram_path=$(readlink -f "$2") shift 2;; - --UE-ip) - TARGET_LIST="$TARGET_LIST ue_ip" - shift;; -w | --hardware) case "$2" in "USRP" | "BLADERF" | "LMSSDR" | "IRIS") diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 356229762f..ac336478df 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -171,10 +171,6 @@ clean_kernel() { $SUDO iptables -t filter -F $SUDO iptables -t raw -F echo_info "Flushed iptables" - $SUDO rmmod nasmesh > /dev/null 2>&1 - $SUDO rmmod oai_nw_drv > /dev/null 2>&1 - $SUDO rmmod ue_ip > /dev/null 2>&1 - echo_info "removed drivers from kernel" } clean_all_files() { diff --git a/cmake_targets/tools/init_nas_nos1 b/cmake_targets/tools/init_nas_nos1 deleted file mode 100755 index a94639026a..0000000000 --- a/cmake_targets/tools/init_nas_nos1 +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -# file init_nas_nos1 -# brief loads the nasmesh module and sets up the radio bearers (used to provide ip interface without S1 interface) -# author Florian Kaltenberger -# -####################################### - -load_module() { - mod_name=${1##*/} - mod_name=${mod_name%.*} - if awk "/$mod_name/ {found=1 ;exit} END {if (found!=1) exit 1}" /proc/modules - then - echo "module $mod_name already loaded: I remove it first" - sudo rmmod $mod_name - fi - echo loading $mod_name - sudo insmod $1 -} - -load_module $OPENAIR_DIR/cmake_targets/ran_build/build/nasmesh.ko - -if [ "$1" = "eNB" ]; then - echo "bring up oai0 interface for enb" - sudo ifconfig oai0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR_DIR/cmake_targets/ran_build/build/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.2 -r 1 -else - if [ "$1" = "UE" ]; then - echo "bring up oai0 interface for UE" - sudo ifconfig oai0 10.0.1.2 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR_DIR/cmake_targets/ran_build/build/rb_tool -a -c0 -i0 -z0 -s 10.0.1.2 -t 10.0.1.1 -r 1 - fi -fi diff --git a/cmake_targets/tools/init_nas_s1 b/cmake_targets/tools/init_nas_s1 deleted file mode 100755 index deee97634c..0000000000 --- a/cmake_targets/tools/init_nas_s1 +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -#WARNING: this file may not work properly, be sure to know what you -#do when using it - -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -################################################################################ -# file init_nas_s1 -# brief loads the ue_ip module and sets up IP for the UE -# you may want to edit it to fit your settings (replace oip0 by oipX for -# instance) -# author Florian Kaltenberger -# -####################################### - -LTEIF=oip1 -#OPENAIR_DIR=/home/oai/svn-oai/openair4G - -load_module() { - mod_name=${1##*/} - mod_name=${mod_name%.*} - if awk "/$mod_name/ {found=1 ;exit} END {if (found!=1) exit 1}" /proc/modules - then - echo "module $mod_name already loaded: I remove it first" - sudo rmmod $mod_name - fi - echo loading $mod_name - sudo insmod $1 -} - -load_module ../ran_build/build/ue_ip.ko - -if [ "$1" = "UE" ]; then - echo "bring up $LTEIF interface for UE" - sudo ifconfig $LTEIF up -fi - -sudo ip route flush cache -sleep 1 -sudo sysctl -w net.ipv4.conf.all.log_martians=1 -echo "Disabling reverse path filtering" -sudo sysctl -w net.ipv4.conf.all.rp_filter=0 -sudo ip route flush cache - -# Check table 200 lte in /etc/iproute2/rt_tables -fgrep lte /etc/iproute2/rt_tables > /dev/null -if [ $? -ne 0 ]; then - echo "200 lte " >> /etc/iproute2/rt_tables -fi -sudo ip rule add fwmark 1 table lte -sudo ip route add default dev $LTEIF table lte diff --git a/doc/BUILD.md b/doc/BUILD.md index e99f88fca4..3e06e79d01 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -38,7 +38,6 @@ Running the [build_oai](../cmake_targets/build_oai) script also generates some - `conf2uedata`: a binary used to build the (4G) UE data from a configuration file. The created file emulates the sim card of a 3GPP compliant phone. - `nvram`: a binary used to build (4G) UE (IMEI...) and EMM (IMSI, registered PLMN) non volatile data. -- `rb_tool`: radio bearer utility for (4G) UE - `genids` T Tracer utility, used at build time to generate `T_IDs.h` include file. This binary is located in the [T Tracer source file directory](../common/utils/T) . The build system for OAI uses [cmake](https://cmake.org/) which is a tool to generate makefiles. The `build_oai` script is a wrapper using `cmake` and `make`/`ninja` to ease the oai build and use. It logs the `cmake` and `ninja`/`make` commands it executes. The file describing how to build the executables from source files is the [CMakeLists.txt](../CMakeLists.txt), it is used as input by cmake to generate the makefiles. diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 977208ef7c..e5141b7917 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -49,7 +49,6 @@ extern int otg_enabled; #include "../MAC/mac_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "NETWORK_DRIVER/LITE/constant.h" //#include "SIMULATION/ETH_TRANSPORT/extern.h" #include "common/utils/LOG/log.h" #include "UTIL/OTG/otg_tx.h" @@ -63,7 +62,6 @@ extern int otg_enabled; #include #include -#include "NETWORK_DRIVER/UE_IP/constant.h" extern char nl_rx_buf[NL_MAX_PAYLOAD]; extern struct sockaddr_nl nas_src_addr, nas_dest_addr; @@ -521,7 +519,7 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx ctxt.rntiMaybeUEid = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { + if (rab_id == 1) { LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%lx, enb_flag=%d)\n", ctxt.module_id, ctxt.rntiMaybeUEid, ctxt.enb_flag); key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rntiMaybeUEid, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); @@ -695,7 +693,7 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) //UE if (!ctxt.enb_flag) { if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { + if (rab_id == 1) { LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%lx, enb_flag=%d)\n", ctxt.module_id, ctxt.rntiMaybeUEid, ctxt.enb_flag); key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rntiMaybeUEid, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); diff --git a/openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile b/openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile deleted file mode 100644 index a939acb7ce..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -CC = gcc - -NAS_DIR = .. - -rb_tool: rb_tool.c - $(CC) rb_tool.c -o rb_tool -I../ -g -ggdb - -all: rb_tool - -clean: - rm rb_tool diff --git a/openair2/NETWORK_DRIVER/LITE/RB_TOOL/rb_tool.c b/openair2/NETWORK_DRIVER/LITE/RB_TOOL/rb_tool.c deleted file mode 100644 index 465e134d76..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/RB_TOOL/rb_tool.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - rb_tool.c - User-space utility for driving NASMESH IOCTL interface - ------------------- - copyright : (C) 2008 by Eurecom - email : raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr -*************************************************************************** - -***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -//#include "rrc_nas_primitives.h" -#include "ioctl.h" -#include "constant.h" - - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - - - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -// Global variables - -int fd; -//ioctl -char dummy_buffer[1024]; -struct oai_nw_drv_ioctl gifr; -//int wait_start_nas; - -//--------------------------------------------------------------------------- -void IAL_NAS_ioctl_init(int inst) -//--------------------------------------------------------------------------- -{ - struct oai_nw_drv_msg_statistic_reply *msgrep; - int err,rc; - sprintf(gifr.name, "oai%d",inst); - // Get an UDP IPv6 socket ?? - fd=socket(AF_INET6, SOCK_DGRAM, 0); - - if (fd<0) { - printf("Error opening socket\n"); - exit(1); - } - - sprintf(gifr.name, "oai%d",inst); - gifr.type = OAI_NW_DRV_MSG_STATISTIC_REQUEST; - memset ((void *)dummy_buffer,0,800); - gifr.msg= &(dummy_buffer[0]); - msgrep=(struct oai_nw_drv_msg_statistic_reply *)(gifr.msg); - printf("ioctl :Statistics requested\n"); - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - rc = -1; - } - - printf("tx_packets = %u, rx_packets = %u\n", msgrep->tx_packets, msgrep->rx_packets); - printf("tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes); - printf("tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors); - printf("tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped); -} - -#define NO_ACTION_RB 0 -#define ADD_RB 1 -#define DEL_RB 2 - -//--------------------------------------------------------------------------- -int main(int argc,char **argv) -//--------------------------------------------------------------------------- -{ - int done; - int rc; - int meas_polling_counter; - fd_set readfds; - struct timeval tv; - int i; - int err; - char *buffer; - int c; - int action; - int rbset = 0; - int cxset = 0; - int classrefset = 0; - int instset = 0; - int saddr_ipv4set = 0; - int saddr_ipv6set = 0; - int daddr_ipv4set = 0; - int daddr_ipv6set = 0; - int dscpset = 0; - int dplen = 0; - int splen = 0; - int mpls_outlabelset = 0; - int mpls_inlabelset; - char rb[20]; - char cx[20]; - char classref[20]; - char dscp[20]; - char inst[20]; - char mpls_outgoinglabel[100]; - char mpls_incominglabel[100]; - int index; - struct oai_nw_drv_msg_rb_establishment_request *msgreq; - struct oai_nw_drv_msg_class_add_request *msgreq_class; - in_addr_t saddr_ipv4; - in_addr_t daddr_ipv4; - struct in6_addr saddr_ipv6; - struct in6_addr daddr_ipv6; - unsigned int mpls_outlabel; - unsigned int mpls_inlabel; - char addr_str[46]; - char mask_len_delims[] = "/"; - char *result; - // scan options - rb[0] = '\0'; - cx[0] = '\0'; - dscp[0] = '\0'; - mpls_incominglabel[0] = '\0'; - mpls_outgoinglabel[0] = '\0'; - action = NO_ACTION_RB; - - while ((c = getopt (argc, argv, "adr:i:c:f:l:m:s:t:x:y:z:")) != -1) - switch (c) { - case 'a': - action = ADD_RB; - break; - - case 'd': - action = DEL_RB; - break; - - case 'r': - strcpy(rb,optarg); - rbset = 1; - break; - - case 'i': - strcpy(inst,optarg); - instset = 1; - break; - - case 'c': - strcpy(cx,optarg); - cxset = 1; - break; - - case 'f': - strcpy(classref,optarg); - classrefset = 1; - break; - - case 'l': - strcpy(mpls_outgoinglabel,optarg); - mpls_outlabelset=1; - break; - - case 'm': - strcpy(mpls_incominglabel,optarg); - mpls_inlabelset=1; - break; - - case 's': - result = strtok( optarg, mask_len_delims ); - - if ( result != NULL ) { - inet_aton(result,&saddr_ipv4); - printf("Arg Source Addr IPv4 string: %s\n",result); - saddr_ipv4set = 1; - } else { - printf("Arg Source Addr IPv4 string: ERROR\n"); - break; - } - - result = strtok( NULL, mask_len_delims ); - - if ( result != NULL ) { - splen = atoi(result); - } else { - splen = 32; - } - - printf("Arg Source Addr IPv4 mask len: %d\n",splen); - break; - - case 't': - result = strtok( optarg, mask_len_delims ); - - if ( result != NULL ) { - inet_aton(result,&daddr_ipv4); - printf("Arg Dest Addr IPv4 string: %s\n",result); - daddr_ipv4set = 1; - } else { - printf("Arg Dest Addr IPv4 string: ERROR\n"); - break; - } - - result = strtok( NULL, mask_len_delims ); - - if ( result != NULL ) { - dplen = atoi(result); - } else { - dplen = 32; - } - - printf("Arg Dest Addr IPv4 mask len: %d\n",dplen); - break; - - case 'x': - result = strtok( optarg, mask_len_delims ); - - if ( result != NULL ) { - printf("Arg Source Addr IPv6 string: %s\n",result); - inet_pton(AF_INET6,result,(void *)&saddr_ipv6); - saddr_ipv6set = 1; - } else { - printf("Arg Source Addr IPv6 string: ERROR\n"); - break; - } - - result = strtok( NULL, mask_len_delims ); - - if ( result != NULL ) { - splen = atoi(result); - } else { - splen = 128; - } - - printf("Arg Source Addr IPv6 mask len: %d\n",splen); - break; - - case 'y': - result = strtok( optarg, mask_len_delims ); - - if ( result != NULL ) { - printf("Arg Dest Addr IPv6 string: %s\n",result); - inet_pton(AF_INET6,result,(void *)&daddr_ipv6); - daddr_ipv6set = 1; - } else { - printf("Arg Dest Addr IPv6 string: ERROR\n"); - break; - } - - result = strtok( NULL, mask_len_delims ); - - if ( result != NULL ) { - dplen = atoi(result); - } else { - dplen = 128; - } - - printf("Arg Dest Addr IPv6 mask len: %d\n",dplen); - break; - - case 'z': - dscpset=1; - strcpy(dscp,optarg); - break; - - case '?': - if (isprint (optopt)) - fprintf (stderr, "Unknown option `-%c'.\n", optopt); - else - fprintf (stderr, - "Unknown option character `\\x%x'.\n", - optopt); - - return 1; - - default: - abort (); - } - - printf ("action = %d, rb = %s,cx = %s\n", action, rb, cx); - - if (rbset==0) { - printf("ERROR: Specify a RAB id!!\n"); - exit(-1); - } - - if (cxset==0) { - printf("ERROR: Specify an LCR !!\n"); - exit(-1); - } - - if (classrefset==0) { - printf("ERROR: Specify an Class reference !!\n"); - exit(-1); - } - - if (instset==0) { - printf("ERROR: Specify an interface !!\n"); - exit(-1); - } - - if ((mpls_outlabelset == 0) && (saddr_ipv4set==0) && (saddr_ipv6set==0)) { - printf("ERROR: Specify a source IP address\n"); - exit(-1); - } - - if ((mpls_outlabelset == 0) && (daddr_ipv4set==0) && (daddr_ipv6set==0)) { - printf("ERROR: Specify a destination IP address\n"); - exit(-1); - } - - if ((mpls_outlabelset == 1) && (mpls_inlabelset == 0)) { - printf("ERROR: Specify an incoming MPLS label\n"); - exit(-1); - } - - if ((mpls_inlabelset == 1) && (mpls_outlabelset == 0)) { - printf("ERROR: Specify an outgoing MPLS label\n"); - exit(-1); - } - - IAL_NAS_ioctl_init(atoi(inst)); - msgreq = (struct oai_nw_drv_msg_rb_establishment_request *)(gifr.msg); - msgreq->rab_id = atoi(rb); - msgreq->lcr = atoi(cx); - msgreq->qos = 0; - - if (action == ADD_RB) { - gifr.type = OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST; - printf("OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST: RB %d LCR %d QOS %d\n ", msgreq->rab_id, msgreq->lcr, msgreq->qos); - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - } - - // only add classification rule - if ((action == ADD_RB ) || (action == NO_ACTION_RB)) { - if (saddr_ipv4set == 1) { - msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = 4; - msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8); - msgreq_class->dir = OAI_NW_DRV_DIRECTION_SEND; - msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND; - msgreq_class->saddr.ipv4 = saddr_ipv4; - msgreq_class->daddr.ipv4 = daddr_ipv4; - msgreq_class->dplen = dplen; - msgreq_class->splen = splen; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT; - - if (dscpset==0) { - msgreq_class->dscp=0; - } else { - msgreq_class->dscp=atoi(dscp); - } - - printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_SEND RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref); - printf("IPV4: Source = %d.%d.%d.%d/%d ", NIPADDR(msgreq_class->saddr.ipv4), msgreq_class->splen); - printf(" IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen); - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = 4; - msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8); - msgreq_class->dir = OAI_NW_DRV_DIRECTION_RECEIVE; - msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND; - msgreq_class->daddr.ipv4 = saddr_ipv4; - msgreq_class->saddr.ipv4 = daddr_ipv4; - msgreq_class->dplen = splen; - msgreq_class->splen = dplen; - printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_RECEIVE RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref); - printf("IPV4: Source = %d.%d.%d.%d/%d ", NIPADDR(msgreq_class->saddr.ipv4), msgreq_class->splen); - printf("IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen); - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - } - - if (saddr_ipv6set == 1) { - msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = 6; - msgreq_class->dplen = dplen; - msgreq_class->splen = splen; - - if (dscpset==0) - msgreq_class->dscp = 0; - else - msgreq_class->dscp = atoi(dscp); - - msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8); - msgreq_class->dir = OAI_NW_DRV_DIRECTION_SEND; - msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT; - memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16); - memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16); - printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_SEND RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref); - printf("IPV6: Source = %x:%x:%x:%x:%x:%x:%x:%x/%d ", NIP6ADDR(&msgreq_class->saddr.ipv6), msgreq_class->splen); - printf("IPV6: Dest = %x:%x:%x:%x:%x:%x:%x:%x/%d\n", NIP6ADDR(&msgreq_class->daddr.ipv6), msgreq_class->dplen); - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->dplen = splen; - msgreq_class->splen = dplen; - msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8); - msgreq_class->dir = OAI_NW_DRV_DIRECTION_RECEIVE; - memcpy(&msgreq_class->daddr.ipv6,&saddr_ipv6,16); - memcpy(&msgreq_class->saddr.ipv6,&daddr_ipv6,16); - printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_RECEIVE RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref); - printf("IPV6: Source = %x:%x:%x:%x:%x:%x:%x:%x/%d ", NIP6ADDR(&msgreq_class->saddr.ipv6), msgreq_class->splen); - printf("IPV6: Dest = %x:%x:%x:%x:%x:%x:%x:%x/%d\n", NIP6ADDR(&msgreq_class->daddr.ipv6), msgreq_class->dplen); - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - } - - if (mpls_inlabelset == 1) { - msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = OAI_NW_DRV_MPLS_VERSION_CODE; - - if (dscpset==0) - msgreq_class->dscp=0; - else - msgreq_class->dscp=atoi(dscp); - - msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8); - //msgreq_class->classref = 4 + (msgreq_class->lcr<<3); - msgreq_class->dir=OAI_NW_DRV_DIRECTION_SEND; - msgreq_class->fct=OAI_NW_DRV_FCT_QOS_SEND; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT; - mpls_outlabel = atoi(mpls_outgoinglabel); - printf("Setting MPLS outlabel %u with exp %d\n",mpls_outlabel,msgreq_class->dscp); - msgreq_class->daddr.mpls_label = mpls_outlabel; - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8); - //msgreq_class->classref = 5 + (msgreq_class->lcr<<3); - msgreq_class->dir=OAI_NW_DRV_DIRECTION_RECEIVE; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT; - mpls_inlabel = atoi(mpls_incominglabel); - printf("Setting MPLS inlabel %u with exp %d\n",mpls_inlabel,msgreq_class->dscp); - msgreq_class->daddr.mpls_label = mpls_inlabel; - gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - } - } else if (action == DEL_RB) { - gifr.type = OAI_NW_DRV_MSG_RB_RELEASE_REQUEST; - err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr); - } -} diff --git a/openair2/NETWORK_DRIVER/LITE/classifier.c b/openair2/NETWORK_DRIVER/LITE/classifier.c deleted file mode 100644 index bc6888279b..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/classifier.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file classifier.c -* \brief Classify IP packets -* \author Navid Nikaein, Lionel GAUTHIER, Raymond knopp -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr -*/ - - -#include "local.h" -#include "proto_extern.h" -#include -#include -#ifdef MPLS -#include -#endif - - -#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) -#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) -#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) -#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) -#define IN_MULTICAST(a) IN_CLASSD(a) -#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) -#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) -/* Address to accept any incoming messages. */ -#define INADDR_ANY ((unsigned long int) 0x00000000) -/* Address to send to all hosts. */ -#define INADDR_BROADCAST ((unsigned long int) 0xffffffff) -/* Address indicating an error return. */ -#define INADDR_NONE ((unsigned long int) 0xffffffff) - - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - (((__const uint32_t *) (a))[0] == 0 \ - && ((__const uint32_t *) (a))[1] == 0 \ - && ((__const uint32_t *) (a))[2] == 0 \ - && ((__const uint32_t *) (a))[3] == 0) - -#define IN6_IS_ADDR_LOOPBACK(a) \ - (((__const uint32_t *) (a))[0] == 0 \ - && ((__const uint32_t *) (a))[1] == 0 \ - && ((__const uint32_t *) (a))[2] == 0 \ - && ((__const uint32_t *) (a))[3] == htonl (1)) - -#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff) - -#define IN6_IS_ADDR_LINKLOCAL(a) \ - ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ - == htonl (0xfe800000)) - -#define IN6_IS_ADDR_SITELOCAL(a) \ - ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ - == htonl (0xfec00000)) - -#define IN6_IS_ADDR_V4MAPPED(a) \ - ((((__const uint32_t *) (a))[0] == 0) \ - && (((__const uint32_t *) (a))[1] == 0) \ - && (((__const uint32_t *) (a))[2] == htonl (0xffff))) - -#define IN6_IS_ADDR_V4COMPAT(a) \ - ((((__const uint32_t *) (a))[0] == 0) \ - && (((__const uint32_t *) (a))[1] == 0) \ - && (((__const uint32_t *) (a))[2] == 0) \ - && (ntohl (((__const uint32_t *) (a))[3]) > 1)) - -#define IN6_ARE_ADDR_EQUAL(a,b) \ - ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \ - && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \ - && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \ - && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3])) - -#define IN6_IS_ADDR_MC_NODELOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1)) - -#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2)) - -#define IN6_IS_ADDR_MC_SITELOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5)) - -#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8)) - -#define IN6_IS_ADDR_MC_GLOBAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe)) - -#define IN6_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint32_t *) (a))[0] & (((__const uint32_t *) (m))[0])) == (((__const uint32_t *) (b))[0] & (((__const uint32_t *) (m))[0]))) \ - && ((((__const uint32_t *) (a))[1] & (((__const uint32_t *) (m))[1])) == (((__const uint32_t *) (b))[1] & (((__const uint32_t *) (m))[1]))) \ - && ((((__const uint32_t *) (a))[2] & (((__const uint32_t *) (m))[2])) == (((__const uint32_t *) (b))[2] & (((__const uint32_t *) (m))[2]))) \ - && ((((__const uint32_t *) (a))[3] & (((__const uint32_t *) (m))[3])) == (((__const uint32_t *) (b))[3] & (((__const uint32_t *) (m))[3])))) - -#define IN_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint8_t *) (a))[0] & (((__const uint8_t *) (m))[0])) == (((__const uint8_t *) (b))[0] & (((__const uint8_t *) (m))[0]))) \ - && ((((__const uint8_t *) (a))[1] & (((__const uint8_t *) (m))[1])) == (((__const uint8_t *) (b))[1] & (((__const uint8_t *) (m))[1]))) \ - && ((((__const uint8_t *) (a))[2] & (((__const uint8_t *) (m))[2])) == (((__const uint8_t *) (b))[2] & (((__const uint8_t *) (m))[2]))) \ - && ((((__const uint8_t *) (a))[3] & (((__const uint8_t *) (m))[3])) == (((__const uint8_t *) (b))[3] & (((__const uint8_t *) (m))[3])))) - - -//--------------------------------------------------------------------------- -// Find the IP traffic type (UNICAST, MULTICAST, BROADCAST) -ip_traffic_type_t oai_nw_drv_find_traffic_type(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - ip_traffic_type_t traffic_type = TRAFFIC_IPVX_TYPE_UNKNOWN; - - if (skb!=NULL) { - switch (ntohs(skb->protocol)) { - case ETH_P_IPV6: - traffic_type = TRAFFIC_IPV6_TYPE_UNKNOWN; -#ifdef OAI_DRV_DEBUG_CLASS - printk("SOURCE ADDR %X:%X:%X:%X:%X:%X:%X:%X",NIP6ADDR(&(ipv6_hdr(skb)->saddr))); - printk(" DEST ADDR %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&(ipv6_hdr(skb)->daddr))); -#endif - - if (IN6_IS_ADDR_MULTICAST(&ipv6_hdr(skb)->daddr.in6_u.u6_addr32[0])) { - traffic_type = TRAFFIC_IPV6_TYPE_MULTICAST; - - } else { - traffic_type = TRAFFIC_IPV6_TYPE_UNICAST; - } - - break; - - - case ETH_P_IP: - traffic_type = TRAFFIC_IPV4_TYPE_UNKNOWN; - - //print_TOOL_pk_ipv4((struct iphdr *)skb->network_header); - if (IN_MULTICAST(htonl(ip_hdr(skb)->daddr))) { - traffic_type = TRAFFIC_IPV4_TYPE_MULTICAST; - } else { - traffic_type = TRAFFIC_IPV4_TYPE_UNICAST; - } - - // TO DO BROADCAST - - break; - - case ETH_P_ARP: - traffic_type = TRAFFIC_IPV4_TYPE_BROADCAST; - break; - - default: - ; - } - } - - return traffic_type; -} - diff --git a/openair2/NETWORK_DRIVER/LITE/common.c b/openair2/NETWORK_DRIVER/LITE/common.c deleted file mode 100644 index 2ae6f5279d..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/common.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file common.c -* \brief implementation of emultor tx and rx -* \author Navid Nikaein, Lionel GAUTHIER, and Raymomd Knopp -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ - -#include "local.h" -#include "proto_extern.h" -#ifndef OAI_NW_DRIVER_USE_NETLINK -#include "rtai_fifos.h" -#endif - - -#include -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET -#include -#endif - -#include -#include - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -//#define OAI_DRV_DEBUG_SEND -//#define OAI_DRV_DEBUG_RECEIVE -void oai_nw_drv_common_class_wireless2ip(uint16_t dlen, - void *pdcp_sdu, - int inst, - OaiNwDrvRadioBearerId_t rb_id) -{ - - //--------------------------------------------------------------------------- - struct sk_buff *skb; - struct ipversion *ipv; - struct oai_nw_drv_priv *gpriv=netdev_priv(oai_nw_drv_dev[inst]); - unsigned int hard_header_len = 0; - uint16_t *p_ether_type; - uint16_t ether_type; -#ifdef OAI_DRV_DEBUG_RECEIVE - int i; - unsigned char *addr; -#endif - unsigned char protocol; - struct iphdr *network_header; - -#ifdef NAS_ADDRESS_FIX - uint32_t odaddr,osaddr; - unsigned char *addr,*daddr,*saddr,*ifaddr; - uint16_t *cksum,check; -#endif // NAS_ADDRESS_FIX -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__, rb_id,inst,dlen); -#endif - - skb = dev_alloc_skb( dlen + 2 ); - - if(!skb) { - printk("[OAI_IP_DRV][%s] low on memory\n",__FUNCTION__); - ++gpriv->stats.rx_dropped; - return; - } - - skb_reserve(skb,2); - memcpy(skb_put(skb, dlen), pdcp_sdu,dlen); - - skb->dev = oai_nw_drv_dev[inst]; - hard_header_len = oai_nw_drv_dev[inst]->hard_header_len; - - skb_set_mac_header(skb, 0); - skb_set_network_header(skb, hard_header_len); - skb->mark = rb_id; - skb->pkt_type = PACKET_HOST; - - -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] Receiving packet @%p of size %d from PDCP \n",__FUNCTION__, skb->data, skb->len); - - for (i=0; ilen; i++) - printk("%2x ",((unsigned char *)(skb->data))[i]); - - printk("\n"); -#endif - - - - // LG TEST skb->ip_summed = CHECKSUM_NONE; - skb->ip_summed = CHECKSUM_UNNECESSARY; - - - ipv = (struct ipversion *)skb_network_header(skb); - - switch (ipv->version) { - - case 6: -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__); -#endif - skb_set_network_header(skb, hard_header_len); - - //skb->network_header = &skb->data[hard_header_len]; - if (hard_header_len == 0) { - skb->protocol = htons(ETH_P_IPV6); - } else { -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]); -#else -#endif - } - - //printk("Writing packet with protocol %x\n",ntohs(skb->protocol)); - break; - - case 4: -#ifdef NAS_ADDRESS_FIX - // Make the third byte of both the source and destination equal to the fourth of the destination - daddr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr; - odaddr = ((struct iphdr *)skb->data)->daddr; - //sn = addr[3]; - saddr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr; - osaddr = ((struct iphdr *)&skb->data[hard_header_len])->saddr; - - if (daddr[0] == saddr[0]) {// same network - daddr[2] = daddr[3]; // set third byte of destination to that of local machine so that local IP stack accepts the packet - saddr[2] = daddr[3]; // set third byte of source to that of local machine so that local IP stack accepts the packet - } else { // get the 3rd byte from device address in net_device structure - ifaddr = (unsigned char *)(&(((struct in_device *)((oai_nw_drv_dev[inst])->ip_ptr))->ifa_list->ifa_local)); - - if (saddr[0] == ifaddr[0]) { // source is in same network as local machine - daddr[0] += saddr[3]; // fix address of remote destination to undo change at source - saddr[2] = ifaddr[2]; // set third byte to that of local machine so that local IP stack accepts the packet - } else { // source is remote machine from outside network - saddr[0] -= daddr[3]; // fix address of remote source to be understood by destination - daddr[2] = daddr[3]; // fix 3rd byte of local address to be understood by IP stack of - // destination - } - } - -#endif //NAS_ADDRESS_FIX -#ifdef OAI_DRV_DEBUG_RECEIVE - //printk("NAS_TOOL_RECEIVE: receive IPv4 message\n"); - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr; - - if (addr) { - //addr[2]^=0x01; - printk("[OAI_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]); - } - - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr; - - if (addr) { - //addr[2]^=0x01; - printk("[OAI_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]); - } - - printk("[OAI_IP_DRV][%s] protocol %d\n",__FUNCTION__, ((struct iphdr *)&skb->data[hard_header_len])->protocol); -#endif - - skb_set_network_header(skb, hard_header_len); - //skb->network_header = &skb->data[hard_header_len]; - network_header = (struct iphdr *)skb_network_header(skb); - protocol = network_header->protocol; - -#ifdef OAI_DRV_DEBUG_RECEIVE - - switch (protocol) { - case IPPROTO_IP: - printk("[OAI_IP_DRV][%s] Received Raw IPv4 packet\n",__FUNCTION__); - break; - - case IPPROTO_IPV6: - printk("[OAI_IP_DRV][%s] Received Raw IPv6 packet\n",__FUNCTION__); - break; - - case IPPROTO_ICMP: - printk("[OAI_IP_DRV][%s] Received Raw ICMP packet\n",__FUNCTION__); - break; - - case IPPROTO_TCP: - printk("[OAI_IP_DRV][%s] Received TCP packet\n",__FUNCTION__); - break; - - case IPPROTO_UDP: - printk("[OAI_IP_DRV][%s] Received UDP packet\n",__FUNCTION__); - break; - - default: - break; - } - -#endif - -#ifdef NAS_ADDRESS_FIX - network_header->check = 0; - network_header->check = ip_fast_csum((unsigned char *) network_header, network_header->ihl); - //printk("[OAI_IP_DRV][COMMON][RECEIVE] IP Fast Checksum %x \n", network_header->check); - - switch(protocol) { - case IPPROTO_TCP: - - cksum = (uint16_t*)&(((struct tcphdr*)((network_header + (network_header->ihl<<2))))->check); - check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, 0,0, ~(*cksum)); - //check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum)); - //check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, dlen, IPPROTO_TCP, ~(*cksum)); - - *cksum = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check); - //*cksum = csum_tcpudp_magic(~osaddr, ~odaddr, dlen, IPPROTO_TCP, ~check); -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] Inst %d TCP packet calculated CS %x, CS = %x (before), SA (%x)%x, DA (%x)%x\n",__FUNCTION__, - inst, - network_header->check, - *cksum, - osaddr, - ((struct iphdr *)skb->data)->saddr, - odaddr, - ((struct iphdr *)skb->data)->daddr); - - printk("[OAI_IP_DRV][%s] Inst %d TCP packet NEW CS %x\n",__FUNCTION__, - inst, - *cksum); -#endif - break; - - case IPPROTO_UDP: - cksum = (uint16_t*)&(((struct udphdr*)((network_header + (network_header->ihl<<2))))->check); - check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, 0,0, ~(*cksum)); - // check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum)); - //check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, dlen, IPPROTO_UDP, ~(*cksum)); - - *cksum= csum_tcpudp_magic(~osaddr, ~odaddr,0,0, ~check); - //*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,udp_hdr(skb)->len, IPPROTO_UDP, ~check); - //*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,dlen, IPPROTO_UDP, ~check); - -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] Inst %d UDP packet CS = %x (before), SA (%x)%x, DA (%x)%x\n",__FUNCTION__, - inst,*cksum,osaddr,((struct iphdr *)&skb->data[hard_header_len])->saddr,odaddr,((struct iphdr *)&skb->data[hard_header_len])->daddr); - - printk("[OAI_IP_DRV][%s] Inst %d UDP packet NEW CS %x\n",__FUNCTION__,inst,*cksum); -#endif - //if ((check = *cksum) != 0) { - // src, dst, len, proto, sum - // } - break; - - default: - break; - } - -#endif //NAS_ADDRESS_FIX - - if (hard_header_len == 0) { - skb->protocol = htons(ETH_P_IP); - } else { -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]); -#else -#endif - } - - //printk("[OAI_IP_DRV][COMMON] Writing packet with protocol %x\n",ntohs(skb->protocol)); - break; - - default: - // fill skb->pkt_type, skb->dev - - skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]); - // minus 1(short) instead of 2(bytes) because uint16_t* - p_ether_type = (uint16_t *)(skb_network_header(skb)-2); - ether_type = ntohs(*p_ether_type); - - switch (ether_type) { - case ETH_P_ARP: -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] ether_type = ETH_P_ARP\n",__FUNCTION__); -#endif - //skb->pkt_type = PACKET_HOST; - skb->protocol = htons(ETH_P_ARP); - break; - - default: - ; - } - - printk("[OAI_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__,rb_id,inst,dlen); - printk("[OAI_IP_DRV][%s] Inst %d: receive unknown message (version=%d)\n",__FUNCTION__,inst,ipv->version); - } - - ++gpriv->stats.rx_packets; - gpriv->stats.rx_bytes += dlen; -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] sending packet of size %d to kernel\n",__FUNCTION__,skb->len); - - for (i=0; ilen; i++) - printk("%2x ",((unsigned char *)(skb->data))[i]); - - printk("\n"); -#endif //OAI_DRV_DEBUG_RECEIVE - netif_rx_ni(skb); -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] end\n",__FUNCTION__); -#endif -} - -//--------------------------------------------------------------------------- -// Delete the data -void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv=netdev_priv(oai_nw_drv_dev[inst]); - ++priv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) -void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst) -{ - //--------------------------------------------------------------------------- - struct pdcp_data_req_header_s pdcph; - struct oai_nw_drv_priv *priv=netdev_priv(oai_nw_drv_dev[inst]); -#ifdef LOOPBACK_TEST - int i; -#endif -#ifdef OAI_DRV_DEBUG_SEND - int j; -#endif - unsigned int bytes_wrote; - // Start debug information -#ifdef OAI_DRV_DEBUG_SEND - printk("[OAI_IP_DRV][%s] inst %d begin \n",__FUNCTION__,inst); -#endif - - if (skb==NULL) { -#ifdef OAI_DRV_DEBUG_SEND - printk("[OAI_IP_DRV][%s] input parameter skb is NULL \n",__FUNCTION__); -#endif - return; - } - - pdcph.data_size = skb->len; - pdcph.rb_id = skb->mark; - pdcph.inst = inst; - pdcph.traffic_type = oai_nw_drv_find_traffic_type(skb); - - - bytes_wrote = oai_nw_drv_netlink_send((char *)&pdcph,OAI_NW_DRV_PDCPH_SIZE); -#ifdef OAI_DRV_DEBUG_SEND - printk("[OAI_IP_DRV][%s] Wrote %d bytes (header for %d byte skb) to PDCP RB %d via netlink\n",__FUNCTION__, - bytes_wrote,skb->len, pdcph.rb_id); -#endif - - - if (bytes_wrote != OAI_NW_DRV_PDCPH_SIZE) { - printk("[OAI_IP_DRV][%s] problem while writing PDCP's header (bytes wrote = %d to fifo %d)\n",__FUNCTION__,bytes_wrote,IP2PDCP_FIFO); - printk("rb_id %u, Wrote %u, Header Size %lu \n", pdcph.rb_id , bytes_wrote, OAI_NW_DRV_PDCPH_SIZE); - priv->stats.tx_dropped ++; - return; - } - - bytes_wrote += oai_nw_drv_netlink_send((char *)skb->data,skb->len); - - - if (bytes_wrote != skb->len+OAI_NW_DRV_PDCPH_SIZE) { - printk("[OAI_IP_DRV][%s] Inst %d, RB_ID %u: problem while writing PDCP's data, bytes_wrote = %u, Data_len %u, PDCPH_SIZE %lu\n", - __FUNCTION__, - inst, - pdcph.rb_id, - bytes_wrote, - skb->len, - OAI_NW_DRV_PDCPH_SIZE); // congestion - - priv->stats.tx_dropped ++; - return; - } - -#ifdef OAI_DRV_DEBUG_SEND - printk("[OAI_IP_DRV][%s] Sending packet of size %d to PDCP traffic type %d\n",__FUNCTION__,skb->len, pdcph.traffic_type); - - for (j=0; jlen; j++) - printk("%2x ",((unsigned char *)(skb->data))[j]); - - printk("\n"); -#endif - - priv->stats.tx_bytes += skb->len; - priv->stats.tx_packets ++; -#ifdef OAI_DRV_DEBUG_SEND - printk("[OAI_IP_DRV][%s] end \n",__FUNCTION__); -#endif -} - - -//--------------------------------------------------------------------------- -void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh) -{ - //--------------------------------------------------------------------------- - - struct pdcp_data_ind_header_s *pdcph = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh); - struct oai_nw_drv_priv *priv; - - priv = netdev_priv(oai_nw_drv_dev[pdcph->inst]); - -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[OAI_IP_DRV][%s] QOS receive from PDCP, size %d, rab %d, inst %d\n",__FUNCTION__, - pdcph->data_size,pdcph->rb_id,pdcph->inst); -#endif //OAI_DRV_DEBUG_RECEIVE - - oai_nw_drv_common_class_wireless2ip(pdcph->data_size, - (unsigned char *)NLMSG_DATA(nlh) + OAI_NW_DRV_PDCPH_SIZE, - pdcph->inst, - pdcph->rb_id); -} - - diff --git a/openair2/NETWORK_DRIVER/LITE/constant.h b/openair2/NETWORK_DRIVER/LITE/constant.h deleted file mode 100644 index efeba0b86d..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/constant.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef _OAI_NW_DRV_CST -#define _OAI_NW_DRV_CST - -#define MAX_MEASURE_NB 5 -#define OAI_NW_DRV_MAX_LENGTH 180 - -//Debug flags -//#define OAI_NW_DRV_DEBUG_DC -#define OAI_NW_DRV_DEBUG_SEND -#define OAI_NW_DRV_DEBUG_RECEIVE -//#define OAI_NW_DRV_DEBUG_CLASS -//#define OAI_NW_DRV_DEBUG_GC -//#define OAI_NW_DRV_DEBUG_DC_MEASURE -//#define OAI_NW_DRV_DEBUG_TIMER -//#define OAI_NW_DRV_DEBUG_DEVICE -//#define OAI_NW_DRV_DEBUG_INTERRUPT -//#define OAI_NW_DRV_DEBUG_TOOL - -// Other flags -#define DEMO_3GSM - -// General Constants -#define OAI_NW_DRV_MTU 1500 -#define OAI_NW_DRV_TX_QUEUE_LEN 100 -#define OAI_NW_DRV_ADDR_LEN 8 -#define OAI_NW_DRV_INET6_ADDRSTRLEN 46 -#define OAI_NW_DRV_INET_ADDRSTRLEN 16 - -#define OAI_NW_DRV_RESET_RX_FLAGS 0 - -#define OAI_NW_DRV_CX_MAX 32 //Identical to RRC constant -//#define OAI_NW_DRV_CX_MULTICAST_ALLNODE 2 - -#define OAI_NW_DRV_RETRY_LIMIT_DEFAULT 5 - -#define OAI_NW_DRV_MESSAGE_MAXLEN 5004 - -#define OAI_NW_DRV_SIG_SRB3 3 -#define OAI_NW_DRV_SIG_SRB4 3 // not used yet - -//peer-to-peer messages between NAS entities -#define OAI_NW_DRV_CMD_OPEN_RB 1 - -//#define OAI_NW_DRV_IID1_CONTROL 0x0 -//#define OAI_NW_DRV_IID2_CONTROL __constant_htonl(0xffffffff) - -//#define OAI_NW_DRV_STATE_IDLE 0 -//#define OAI_NW_DRV_STATE_CONNECTED 1 -//#define OAI_NW_DRV_STATE_ESTABLISHMENT_REQUEST 2 -//#define OAI_NW_DRV_STATE_ESTABLISHMENT_FAILURE 3 -//#define OAI_NW_DRV_STATE_RELEASE_FAILURE 4 -#define OAI_NW_DRV_CX_RELEASE_UNDEF_CAUSE 1 - -// MT+RG NAS States -#define OAI_NW_DRV_IDLE 0x01 -// Connection -#define OAI_NW_DRV_CX_FACH 0x06 -#define OAI_NW_DRV_CX_DCH 0x0A -#define OAI_NW_DRV_CX_RECEIVED 0x10 -#define OAI_NW_DRV_CX_CONNECTING 0x04 -#define OAI_NW_DRV_CX_RELEASING 0x08 -#define OAI_NW_DRV_CX_CONNECTING_FAILURE 0x14 -#define OAI_NW_DRV_CX_RELEASING_FAILURE 0x18 -// Radio Bearers -#define OAI_NW_DRV_RB_ESTABLISHING 0x24 -#define OAI_NW_DRV_RB_RELEASING 0x28 -#define OAI_NW_DRV_RB_DCH 0x2A - - -#define OAI_NW_DRV_TIMER_ESTABLISHMENT_DEFAULT 12 -#define OAI_NW_DRV_TIMER_RELEASE_DEFAULT 2 -#define OAI_NW_DRV_TIMER_IDLE UINT_MAX -#define OAI_NW_DRV_TIMER_TICK HZ - -#define OAI_NW_DRV_PDCPH_SIZE sizeof(struct pdcp_data_req_header_s) -#define OAI_NW_DRV_IPV4_SIZE 20 -#define OAI_NW_DRV_IPV6_SIZE 40 - -#define OAI_NW_DRV_DIRECTION_SEND 0 -#define OAI_NW_DRV_DIRECTION_RECEIVE 1 -#define OAI_NW_DRV_DIRECTION_FORWARD 2 - -// function number -#define OAI_NW_DRV_FCT_DEL_SEND 1 -#define OAI_NW_DRV_FCT_QOS_SEND 2 -#define OAI_NW_DRV_FCT_DC_SEND 3 -#define OAI_NW_DRV_FCT_CTL_SEND 4 - -// type of IOCTL command -#define OAI_NW_DRV_IOCTL_RRM 0x89F0 - -// Error cause -#define OAI_NW_DRV_ERROR_ALREADYEXIST 1 -#define OAI_NW_DRV_ERROR_NOMEMORY 3 -#define OAI_NW_DRV_ERROR_NOTMT 9 -#define OAI_NW_DRV_ERROR_NOTRG 10 -#define OAI_NW_DRV_ERROR_NOTIDLE 11 -#define OAI_NW_DRV_ERROR_NOTCONNECTED 12 -#define OAI_NW_DRV_ERROR_NORB 14 -#define OAI_NW_DRV_ERROR_NOTCORRECTVALUE 32 -#define OAI_NW_DRV_ERROR_NOTCORRECTLCR 33 -#define OAI_NW_DRV_ERROR_NOTCORRECTDIR 34 -#define OAI_NW_DRV_ERROR_NOTCORRECTDSCP 35 -#define OAI_NW_DRV_ERROR_NOTCORRECTVERSION 36 -#define OAI_NW_DRV_ERROR_NOTCORRECTRABI 37 - - -/**********************************************************/ -/* Constants related with IP protocols */ -/**********************************************************/ - -//#define OAI_NW_DRV_PORT_CONTROL __constant_htons(0xc45) -//#define OAI_NW_DRV_PORT_AUTHENTICATION __constant_htons(1811) - -#define OAI_NW_DRV_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000) - -// Network control codepoint 111000 + IP version 6 -#define OAI_NW_DRV_FLOWINFO_NCONTROL __constant_htonl(0x6e000000) -// network control codepoint 111000 -#define OAI_NW_DRV_DSCP_NCONTROL 56 //0x38 -// default codepoint 1000000 -#define OAI_NW_DRV_DSCP_DEFAULT 64 -#define OAI_NW_DRV_DSCP_MAX 193 - -#define OAI_NW_DRV_PROTOCOL_DEFAULT 0 -#define OAI_NW_DRV_PROTOCOL_TCP IPPROTO_TCP -#define OAI_NW_DRV_PROTOCOL_UDP IPPROTO_UDP -#define OAI_NW_DRV_PROTOCOL_ICMP4 IPPROTO_ICMP -#define OAI_NW_DRV_PROTOCOL_ICMP6 IPPROTO_ICMPV6 -//#warning "OAI_NW_DRV_PROTOCOL_ARP value 200 may collide with new defined values in kernel" -#define OAI_NW_DRV_PROTOCOL_ARP 200 - -#define OAI_NW_DRV_PORT_DEFAULT __constant_htons(65535) -#define OAI_NW_DRV_PORT_HTTP __constant_htons(80) - -#define OAI_NW_DRV_IP_VERSION_ALL 0 -#define OAI_NW_DRV_IP_VERSION_4 4 -#define OAI_NW_DRV_IP_VERSION_6 6 - -#define OAI_NW_DRV_DEFAULT_IPV4_ADDR 0 -#define OAI_NW_DRV_DEFAULT_IPV6_ADDR0 0 -#define OAI_NW_DRV_DEFAULT_IPV6_ADDR1 0 -#define OAI_NW_DRV_DEFAULT_IPV6_ADDR2 0 -#define OAI_NW_DRV_DEFAULT_IPV6_ADDR3 0 - - -#define OAI_NW_DRV_MPLS_VERSION_CODE 99 - -#define OAI_NW_DRV_NB_INSTANCES_MAX 8 - - -#endif - diff --git a/openair2/NETWORK_DRIVER/LITE/device.c b/openair2/NETWORK_DRIVER/LITE/device.c deleted file mode 100644 index 59340784c1..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/device.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file device.c -* \brief Networking Device Driver for OpenAirInterface Ethernet -* \author navid.nikaein, Lionel Gauthier, raymond.knopp, -* \company Eurecom -* \email:navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, raymond.knopp@eurecom.fr - -*/ -/*******************************************************************************/ - -#include "constant.h" -#include "local.h" -#include "proto_extern.h" - -//#include -#include -#include -#include -#include -#include -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET -#include -#endif - - -struct net_device *oai_nw_drv_dev[OAI_NW_DRV_NB_INSTANCES_MAX]; - -#ifdef OAI_NW_DRIVER_USE_NETLINK -extern void oai_nw_drv_netlink_release(void); -extern int oai_nw_drv_netlink_init(void); -#endif - -uint8_t NULL_IMEI[14]= {0x05, 0x04, 0x03, 0x01, 0x02 ,0x00, 0x00, 0x00, 0x05, 0x04, 0x03 ,0x00, 0x01, 0x08}; - -static unsigned char oai_nw_drv_IMEI[14]; -static int m_arg=0; -static unsigned int oai_nw_drv_is_clusterhead=0; -//--------------------------------------------------------------------------- -int oai_nw_drv_find_inst(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - int i; - - for (i=0; ilock = SPIN_LOCK_UNLOCKED; - -#ifdef OAI_DRV_DEBUG_INTERRUPT - printk("INTERRUPT - begin\n"); -#endif - // spin_lock_irqsave(&priv->lock,flags); - cxi=0; - // mesh_GC_receive(); - // mesh_DC_receive(naspriv->cx+cxi); -#ifndef OAI_NW_DRIVER_USE_NETLINK - oai_nw_drv_common_wireless2ip(); -#endif - // spin_unlock_irqrestore(&priv->lock,flags); -#ifdef OAI_DRV_DEBUG_INTERRUPT - printk("INTERRUPT: end\n"); -#endif - // return 0; -} -#endif //NETLINK -//--------------------------------------------------------------------------- -void oai_nw_drv_timer(unsigned long data) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv=(struct oai_nw_drv_priv *)data; - spin_lock(&priv->lock); - (priv->timer).function=oai_nw_drv_timer; - (priv->timer).expires=jiffies+OAI_NW_DRV_TIMER_TICK; - (priv->timer).data=data; - add_timer(&priv->timer); - spin_unlock(&priv->lock); - return; - // add_timer(&gpriv->timer); - // spin_unlock(&gpriv->lock); -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is activated by ifconfig -int oai_nw_drv_open(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv=netdev_priv(dev); - - // Address has already been set at init -#ifndef OAI_NW_DRIVER_USE_NETLINK - - if (pdcp_2_oai_nw_drv_irq==-EBUSY) { - printk("[OAI_IP_DRV][%s] : irq failure\n", __FUNCTION__); - return -EBUSY; - } - -#endif //OAI_NW_DRIVER_USE_NETLINK - - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - init_timer(&priv->timer); - (priv->timer).expires = jiffies+OAI_NW_DRV_TIMER_TICK; - (priv->timer).data = (unsigned long)priv; - (priv->timer).function = oai_nw_drv_timer; - //add_timer(&priv->timer); - - printk("[OAI_IP_DRV][%s] name = %s\n", __FUNCTION__, dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is desactivated -int oai_nw_drv_stop(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv = netdev_priv(dev); - - printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__); - del_timer(&(priv->timer)); - netif_stop_queue(dev); - // MOD_DEC_USE_COUNT; - printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__); - return 0; -} - -//--------------------------------------------------------------------------- -void oai_nw_drv_teardown(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv; - int inst; - - printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__); - - if (dev) { - priv = netdev_priv(dev); - inst = oai_nw_drv_find_inst(dev); - - if ((inst<0) || (inst>=OAI_NW_DRV_NB_INSTANCES_MAX)) { - printk("[OAI_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__); - return; - } - - /*oai_nw_drv_class_flush_recv_classifier(priv); - - for (cxi=0;cxicx+cxi); - oai_nw_drv_class_flush_send_classifier(priv->cx+cxi); - }*/ - printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__); - } // check dev - else { - printk("[OAI_IP_DRV][%s] Device is null\n", __FUNCTION__); - } -} -//--------------------------------------------------------------------------- -int oai_nw_drv_set_config(struct net_device *dev, struct ifmap *map) -{ - //--------------------------------------------------------------------------- - printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__); - - if (dev->flags & IFF_UP) - return -EBUSY; - - if (map->base_addr != dev->base_addr) { - printk(KERN_WARNING "[OAI_IP_DRV][%s] Can't change I/O address\n", __FUNCTION__); - return -EOPNOTSUPP; - } - - if (map->irq != dev->irq) - dev->irq = map->irq; - - printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__); - return 0; -} - -//--------------------------------------------------------------------------- -// -int oai_nw_drv_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - //--------------------------------------------------------------------------- - int inst; - - if (dev) { - inst = oai_nw_drv_find_inst(dev); - } else { - printk("[OAI_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__); - return -1; - } - - if ((inst>=0) && (inst= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[OAI_IP_DRV][%s] step 1\n", __FUNCTION__); -#endif - oai_nw_drv_common_ip2wireless(skb,inst); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[OAI_IP_DRV][%s] step 2\n", __FUNCTION__); -#endif - dev_kfree_skb(skb); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[OAI_IP_DRV][%s] step 3\n", __FUNCTION__); -#endif - netif_wake_queue(dev); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[OAI_IP_DRV][%s] end\n", __FUNCTION__); -#endif - } else { - printk("[OAI_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__); - return(-1); - } - - return 0; -} - -//--------------------------------------------------------------------------- -struct net_device_stats *oai_nw_drv_get_stats(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // return &((struct oai_nw_drv_priv *)dev->priv)->stats; - struct oai_nw_drv_priv *priv = netdev_priv(dev); - //printk("[OAI_IP_DRV][%s]\n", __FUNCTION__); - return &priv->stats; -} -//--------------------------------------------------------------------------- -int oai_nw_drv_set_mac_address(struct net_device *dev, void *mac) -{ - //--------------------------------------------------------------------------- - struct sockaddr *addr = mac; - printk("[OAI_IP_DRV][%s] CHANGE MAC ADDRESS\n", __FUNCTION__); - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - return 0; -} -//--------------------------------------------------------------------------- -int oai_nw_drv_change_mtu(struct net_device *dev, int mtu) -{ - //--------------------------------------------------------------------------- - printk("[OAI_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtu); - - if ((mtu<50) || (mtu>1500)) - return -EINVAL; - - dev->mtu = mtu; - return 0; -} -//--------------------------------------------------------------------------- -void oai_nw_drv_change_rx_flags(struct net_device *dev, int flags) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_priv *priv = netdev_priv(dev); - printk("[OAI_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flags); - priv->rx_flags ^= flags; -} - -//--------------------------------------------------------------------------- -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) -void oai_nw_drv_tx_timeout(struct net_device *dev, unsigned int txqueue) -#else -void oai_nw_drv_tx_timeout(struct net_device *dev) -#endif -{ - //--------------------------------------------------------------------------- - // Transmitter timeout, serious problems. - struct oai_nw_drv_priv *priv = netdev_priv(dev); - - printk("[OAI_IP_DRV][%s] begin\n", __FUNCTION__); - // (struct oai_nw_drv_priv *)(dev->priv)->stats.tx_errors++; - (priv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif - netif_wake_queue(dev); - printk("[OAI_IP_DRV][%s] transmit timed out %s\n", __FUNCTION__,dev->name); -} - -static const struct net_device_ops nasmesh_netdev_ops = { - .ndo_open = oai_nw_drv_open, - .ndo_stop = oai_nw_drv_stop, - .ndo_start_xmit = oai_nw_drv_hard_start_xmit, - .ndo_validate_addr = NULL, - .ndo_get_stats = oai_nw_drv_get_stats, - .ndo_set_mac_address = oai_nw_drv_set_mac_address, - .ndo_set_config = oai_nw_drv_set_config, - .ndo_do_ioctl = oai_nw_drv_CTL_ioctl, - .ndo_change_mtu = oai_nw_drv_change_mtu, - .ndo_tx_timeout = oai_nw_drv_tx_timeout, - .ndo_change_rx_flags = oai_nw_drv_change_rx_flags, -}; -/*.ndo_set_multicast_list = NULL,*/ - -//--------------------------------------------------------------------------- -// Initialisation of the network device -void oai_nw_drv_init(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - struct oai_nw_drv_priv *priv; - int index; - - if (dev) { - - priv = netdev_priv(dev); - - memset(priv, 0, sizeof(struct oai_nw_drv_priv)); - - -#ifndef OAI_NW_DRIVER_TYPE_ETHERNET - dev->type = ARPHRD_EURECOM_LTE; - dev->features = NETIF_F_NO_CSUM; - dev->hard_header_len = 0; - dev->addr_len = ETH_ALEN; // 6 - dev->flags = IFF_BROADCAST | IFF_MULTICAST | IFF_NOARP; - dev->tx_queue_len = NAS_TX_QUEUE_LEN; - dev->mtu = NAS_MTU; -#endif - // Can be one of the following enum defined in include/linux/netdevice.h: - // enum netdev_state_t { - // __LINK_STATE_START, - // __LINK_STATE_PRESENT, - // __LINK_STATE_NOCARRIER, - // __LINK_STATE_LINKWATCH_PENDING, - // __LINK_STATE_DORMANT, - // }; - set_bit(__LINK_STATE_PRESENT, &dev->state); - - // - dev->netdev_ops = &nasmesh_netdev_ops; -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET - printk("[OAI_IP_DRV][%s] Driver type ETHERNET\n", __FUNCTION__); - // Memo: linux-source-3.2.0/net/ethernet/eth.c: - //334 void ether_setup(struct net_device *dev) - //335 { - //336 dev->header_ops = ð_header_ops; - //337 dev->type = ARPHRD_ETHER; - //338 dev->hard_header_len = ETH_HLEN; - //339 dev->mtu = ETH_DATA_LEN; - //340 dev->addr_len = ETH_ALEN; - //341 dev->tx_queue_len = 1000; /* Ethernet wants good queues */ - //342 dev->flags = IFF_BROADCAST|IFF_MULTICAST; - //343 dev->priv_flags |= IFF_TX_SKB_SHARING; - //344 - //345 memset(dev->broadcast, 0xFF, ETH_ALEN); - //346 } - ether_setup(dev); -#endif - // - // Initialize private structure - priv->rx_flags = OAI_NW_DRV_RESET_RX_FLAGS; - priv->sap[OAI_NW_DRV_RAB_INPUT_SAPI] = PDCP2IP_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; - priv->sap[OAI_NW_DRV_RAB_OUTPUT_SAPI] = IP2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; - - // priv->retry_limit=RETRY_LIMIT_DEFAULT; - // priv->timer_establishment=TIMER_ESTABLISHMENT_DEFAULT; - // priv->timer_release=TIMER_RELEASE_DEFAULT; - - /*for (dscpi=0; dscpirclassifier[dscpi]=NULL; - } - priv->nrclassifier=0;*/ - // - for (cxi=0; cxicx[cxi].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0; - // priv->cx[cxi].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0; - priv->cx[cxi].state = OAI_NW_DRV_IDLE; - priv->cx[cxi].countimer = OAI_NW_DRV_TIMER_IDLE; - priv->cx[cxi].retry = 0; - priv->cx[cxi].lcr = cxi; - /*priv->cx[cxi].rb = NULL; - priv->cx[cxi].num_rb = 0; - // initialisation of the classifier - for (dscpi=0; dscpi<65; ++dscpi) { - priv->cx[cxi].sclassifier[dscpi] = NULL; - priv->cx[cxi].fclassifier[dscpi] = NULL; - } - - priv->cx[cxi].nsclassifier=0; - priv->cx[cxi].nfclassifier=0; - */ - // initialisation of the IP address - oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[cxi].iid6, dev->addr_len); - priv->cx[cxi].iid4=0; - // - } - - spin_lock_init(&priv->lock); - //this requires kernel patch for OAI driver: typically for RF/hard realtime emu experimentation -#define ADDRCONF -#ifdef ADDRCONF - -#ifdef OAI_NW_DRIVER_USE_NETLINK - oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, dev->dev_addr, dev->addr_len);// IMEI to device address (for stateless autoconfiguration address) - - oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[0].iid6, dev->addr_len); -#else - oai_nw_drv_TOOL_imei2iid(oai_nw_drv_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) - oai_nw_drv_TOOL_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[0].iid6); -#endif - // this is more appropriate for user space soft realtime emulation -#else - - // LG: strange - for (index = 0; index < dev->addr_len; index++) { - dev->dev_addr[index] = 16*oai_nw_drv_IMEI[index]+oai_nw_drv_IMEI[index+1]); - } - - memcpy((uint8_t *)priv->cx[0].iid6,&oai_nw_drv_IMEI[0],dev->addr_len); - - printk("INIT: init IMEI to IID\n"); -#endif - printk("[OAI_IP_DRV][%s] Setting HW addr to : ", __FUNCTION__); - - for (index = 0; index < dev->addr_len; index++) { - printk("%02X", dev->dev_addr[index]); - } - - printk("\n[OAI_IP_DRV][%s] Setting priv->cx to : ", __FUNCTION__); - - for (index = 0; index < 8; index++) { - printk("%02X", ((uint8_t *)(priv->cx[0].iid6))[index]); - } - - printk("\n"); - printk("[OAI_IP_DRV][%s] INIT: end\n", __FUNCTION__); - return; - } else { - printk("[OAI_IP_DRV][%s] ERROR, Device is NULL!!\n", __FUNCTION__); - return; - } -} -//--------------------------------------------------------------------------- -int init_module (void) -{ - //--------------------------------------------------------------------------- - int err,inst, index; - struct oai_nw_drv_priv *priv; - char devicename[100]; - - - // Initialize parameters shared with RRC - printk("[OAI_IP_DRV][%s] Starting NASMESH, number of IMEI parameters %d, IMEI ", __FUNCTION__, m_arg); - - for (index = 0; index < m_arg; index++) { - printk("%02X", oai_nw_drv_IMEI[index]); - } - - printk("\n"); - -#ifndef OAI_NW_DRIVER_USE_NETLINK - - if (pdcp_2_oai_nw_drv_irq == -EBUSY || pdcp_2_oai_nw_drv_irq == -EINVAL) { - printk("[OAI_IP_DRV][%s] No interrupt resource available\n", __FUNCTION__); - return -EBUSY; - } else - printk("[OAI_IP_DRV][%s] Interrupt %d\n", __FUNCTION__, pdcp_2_oai_nw_drv_irq); - -#endif //NETLINK - - for (inst=0; inst 0x0F) { - oai_nw_drv_IMEI[8] = oai_nw_drv_IMEI[9] >> 4; - oai_nw_drv_IMEI[9] = oai_nw_drv_IMEI[9] & 0x0F; - } - } - - // linux/net/core/dev.c line 4767 - err= register_netdev(oai_nw_drv_dev[inst]); - - if (err) { - printk("[OAI_IP_DRV][%s] (inst %d): error %i registering device %s\n", __FUNCTION__, inst,err, oai_nw_drv_dev[inst]->name); - } else { - printk("[OAI_IP_DRV][%s] registering device %s, ifindex = %d\n\n", __FUNCTION__,oai_nw_drv_dev[inst]->name, oai_nw_drv_dev[inst]->ifindex); - } - } - } - -#ifdef OAI_NW_DRIVER_USE_NETLINK - printk("[OAI_IP_DRV][%s] NETLINK INIT\n", __FUNCTION__); - - if ((err=oai_nw_drv_netlink_init()) == -1) - printk("[OAI_IP_DRV][%s] NETLINK failed\n", __FUNCTION__); - -#endif //NETLINK - - return err; - -} - -//--------------------------------------------------------------------------- -void cleanup_module(void) -{ - //--------------------------------------------------------------------------- - int inst; - - printk("[OAI_IP_DRV][CLEANUP]nasmesh_cleanup_module: begin\n"); - -#ifndef OAI_NW_DRIVER_USE_NETLINK - - if (pdcp_2_oai_nw_drv_irq!=-EBUSY) { - pdcp_2_oai_nw_drv_irq=0; - // Start IRQ linux - //free_irq(priv->irq, NULL); - // End IRQ linux - } - -#else // NETLINK -#endif //NETLINK - - for (inst=0; inst"DRV_COPYRIGHT - - -module_param_array_named(oai_nw_drv_IMEI,oai_nw_drv_IMEI,byte,&m_arg,0); -//module_param_array(oai_nw_drv_IMEI,byte,&m_arg,0444); -MODULE_PARM_DESC(oai_nw_drv_IMEI,"The IMEI Hardware address (64-bit, decimal nibbles)"); - -//module_param(oai_nw_drv_is_clusterhead,uint,0444); -module_param_named(oai_nw_drv_is_clusterhead,oai_nw_drv_is_clusterhead,uint,0444); -MODULE_PARM_DESC(oai_nw_drv_is_clusterhead,"The Clusterhead Indicator"); - -//MODULE_AUTHOR(DRV_AUTHOR); -//MODULE_DESCRIPTION(DRV_DESCRIPTION); -//MODULE_LICENSE("GPL"); -//MODULE_VERSION(DRV_VERSION); - diff --git a/openair2/NETWORK_DRIVER/LITE/ioctl.c b/openair2/NETWORK_DRIVER/LITE/ioctl.c deleted file mode 100644 index 85c213c5ff..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/ioctl.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "local.h" -#include "ioctl.h" -#include "proto_extern.h" - -#include -#include -#include - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - -uint8_t g_msgrep[OAI_NW_DRV_LIST_CLASS_MAX*sizeof(struct oai_nw_drv_msg_class_list_reply)+1]; - -// Statistic -//--------------------------------------------------------------------------- -void oai_nw_drv_set_msg_statistic_reply(struct oai_nw_drv_msg_statistic_reply *msgrep, - struct oai_nw_drv_priv *priv) -{ - //--------------------------------------------------------------------------- - msgrep->rx_packets=priv->stats.rx_packets; - msgrep->tx_packets=priv->stats.tx_packets; - msgrep->rx_bytes=priv->stats.rx_bytes; - msgrep->tx_bytes=priv->stats.tx_bytes; - msgrep->rx_errors=priv->stats.rx_errors; - msgrep->tx_errors=priv->stats.tx_errors; - msgrep->rx_dropped=priv->stats.rx_dropped; - msgrep->tx_dropped=priv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -int oai_nw_drv_ioCTL_statistic_request(struct oai_nw_drv_ioctl *gifr, - struct oai_nw_drv_priv *priv) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_msg_statistic_reply msgrep; - printk("NAS_IOCTL_STATISTIC: stat requested\n"); - oai_nw_drv_set_msg_statistic_reply(&msgrep,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_STATISTIC: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - - - -/////////////////////////////////////////////////////////////////////////////// -// IMEI -// Messages for IMEI transfer - - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IOCTL command -//--------------------------------------------------------------------------- -int oai_nw_drv_CTL_ioctl(struct net_device *dev, - struct ifreq *ifr, - int cmd) -{ - //--------------------------------------------------------------------------- - struct oai_nw_drv_ioctl *gifr; - struct oai_nw_drv_priv *priv=netdev_priv(dev); - - int r; - - // printk("NAS_CTL_IOCTL: begin ioctl for instance %d\n",find_inst(dev)); - - switch(cmd) { - case OAI_NW_DRV_IOCTL_RRM: - gifr=(struct oai_nw_drv_ioctl *)ifr; - - switch(gifr->type) { - case OAI_NW_DRV_MSG_STATISTIC_REQUEST: - r=oai_nw_drv_ioCTL_statistic_request(gifr,priv); - break; - - - default: - // printk("NAS_IOCTL_RRM: unkwon request type, type=%x\n", gifr->type); - r=-EFAULT; - } - - break; - - default: - // printk("NAS_CTL_IOCTL: Unknown ioctl command, cmd=%x\n", cmd); - r=-EFAULT; - } - - // printk("NAS_CTL_IOCTL: end\n"); - return r; -} - -//--------------------------------------------------------------------------- -void oai_nw_drv_CTL_send(struct sk_buff *skb, int inst) -{ - //--------------------------------------------------------------------------- - printk("NAS_CTL_SEND - void \n"); -} diff --git a/openair2/NETWORK_DRIVER/LITE/ioctl.h b/openair2/NETWORK_DRIVER/LITE/ioctl.h deleted file mode 100644 index d5bab2038c..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/ioctl.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - ioctl.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : michelle.wetterwald@eurecom.fr - yan.moret@eurecom.fr - knopp@eurecom.fr - *************************************************************************** - - ***************************************************************************/ -#ifndef OAI_IOCTL_H -#define OAI_IOCTL_H - -#include -#include -#include -#include -#include - -#include "sap.h" - - -//#include - -#define OAI_NW_DRV_MSG_MAXLEN 1100/// change??? - -// type of CTL message -#define OAI_NW_DRV_MSG_STATISTIC_REQUEST 1 -#define OAI_NW_DRV_MSG_STATISTIC_REPLY 2 -#define OAI_NW_DRV_MSG_ECHO_REQUEST 3 -#define OAI_NW_DRV_MSG_ECHO_REPLY 4 -#define OAI_NW_DRV_MSG_CX_ESTABLISHMENT_REQUEST 5 -#define OAI_NW_DRV_MSG_CX_ESTABLISHMENT_REPLY 6 -#define OAI_NW_DRV_MSG_CX_RELEASE_REQUEST 7 -#define OAI_NW_DRV_MSG_CX_RELEASE_REPLY 8 -#define OAI_NW_DRV_MSG_CX_LIST_REQUEST 9 -#define OAI_NW_DRV_MSG_CX_LIST_REPLY 10 -#define OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST 11 -#define OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REPLY 12 -#define OAI_NW_DRV_MSG_RB_RELEASE_REQUEST 13 -#define OAI_NW_DRV_MSG_RB_RELEASE_REPLY 14 -#define OAI_NW_DRV_MSG_RB_LIST_REQUEST 15 -#define OAI_NW_DRV_MSG_RB_LIST_REPLY 16 -#define OAI_NW_DRV_MSG_CLASS_ADD_REQUEST 17 -#define OAI_NW_DRV_MSG_CLASS_ADD_REPLY 18 -#define OAI_NW_DRV_MSG_CLASS_DEL_REQUEST 19 -#define OAI_NW_DRV_MSG_CLASS_DEL_REPLY 20 -#define OAI_NW_DRV_MSG_CLASS_LIST_REQUEST 21 -#define OAI_NW_DRV_MSG_CLASS_LIST_REPLY 22 -#define OAI_NW_DRV_MSG_MEAS_REQUEST 23 -#define OAI_NW_DRV_MSG_MEAS_REPLY 24 -#define OAI_NW_DRV_MSG_IMEI_REQUEST 25 -#define OAI_NW_DRV_MSG_IMEI_REPLY 26 - -// Max number of entry of a message list -#define OAI_NW_DRV_LIST_CX_MAX 32 -#define OAI_NW_DRV_LIST_RB_MAX 32 -#define OAI_NW_DRV_LIST_CLASS_MAX 32 - -typedef unsigned short oai_nw_drv_MsgType_t; - -struct oai_nw_drv_ioctl { - char name[IFNAMSIZ]; - oai_nw_drv_MsgType_t type; - char *msg; -}; - -struct oai_nw_drv_msg_statistic_reply { - unsigned int rx_packets; - unsigned int tx_packets; - unsigned int rx_bytes; - unsigned int tx_bytes; - unsigned int rx_errors; - unsigned int tx_errors; - unsigned int rx_dropped; - unsigned int tx_dropped; -}; - -struct oai_nw_drv_msg_cx_list_reply { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - unsigned char state; - OaiNwDrvCellID_t cellid; // cell identification - unsigned int iid6[2]; // IPv6 interface identification - unsigned char iid4; // IPv4 interface identification - unsigned short num_rb; - unsigned short nsclassifier; -}; -struct oai_nw_drv_msg_cx_establishment_reply { - int status; -}; -struct oai_nw_drv_msg_cx_establishment_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - OaiNwDrvCellID_t cellid; // Cell identification -}; -struct oai_nw_drv_msg_cx_release_reply { - int status; -}; -struct oai_nw_drv_msg_cx_release_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference -}; - -struct oai_nw_drv_msg_rb_list_reply { - OaiNwDrvRadioBearerId_t rab_id; - OaiNwDrvSapId_t sapi; - OaiNwDrvQoSTrafficClass_t qos; - unsigned char state; -}; -struct oai_nw_drv_msg_rb_list_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference -}; -struct oai_nw_drv_msg_rb_establishment_reply { - int status; -}; -struct oai_nw_drv_msg_rb_establishment_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - OaiNwDrvRadioBearerId_t rab_id; - OaiNwDrvQoSTrafficClass_t qos; -}; - -struct oai_nw_drv_msg_rb_release_reply { - int status; -}; -struct oai_nw_drv_msg_rb_release_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - OaiNwDrvRadioBearerId_t rab_id; -}; -/* -struct saddr { - - struct in6_addr ipv6; - unsigned int ipv4; -}; - -struct daddr { - - struct in6_addr ipv6; - unsigned int ipv4; - unsigned int mpls_label; -}; -*/ -struct oai_nw_drv_msg_class_add_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - OaiNwDrvRadioBearerId_t rab_id; - OaiNwDrvRadioBearerId_t rab_id_rx; - unsigned char dir; // direction (send or receive, forward) - unsigned char dscp; // codepoint - unsigned char fct; - unsigned short classref; - unsigned char version; - - //struct daddr daddr; - //struct saddr saddr; - - unsigned char splen; // prefix length - - union { - struct in6_addr ipv6; - - // begin navid - //in_addr_t ipv4; - unsigned int ipv4; - //end navid - - unsigned int mpls_label; - } daddr; // IP destination address - - union { - struct in6_addr ipv6; - - // begin navid - //in_addr_t ipv4; - unsigned int ipv4; - //end navid - - } saddr; // IP source address - - - unsigned char dplen; // prefix length - - unsigned char protocol; //!< transport layer protocol type (ANY,TCP,UDP,ICMPv4,ICMPv6) - unsigned char protocol_message_type; //!< transport layer protocol message (ROUTER_ADV, ROUTER_SOLL, etc.) - unsigned short sport; //!< source port - unsigned short dport; //!< destination port -}; - -struct oai_nw_drv_msg_class_add_reply { - int status; -}; -struct oai_nw_drv_msg_class_del_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - unsigned char dir; // direction (send or receive) - unsigned char dscp; // codepoint - unsigned short classref; -}; -struct oai_nw_drv_msg_class_del_reply { - int status; -}; -#define oai_nw_drv_msg_class_list_reply oai_nw_drv_msg_class_add_request -struct oai_nw_drv_msg_class_list_request { - OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference - unsigned char dir; - unsigned char dscp; -}; - - -// Messages for Measurement transfer - MW 01/04/2005 -typedef unsigned int nioctlProviderId_t; -typedef unsigned short nioctlSignalLoss_t; -typedef struct nioctlMeasures { - OaiNwDrvCellID_t cell_id; - OaiNwDrvSigLevel_t level; - nioctlProviderId_t provider_id; -} nioctlMeasures_t; - -struct oai_nw_drv_msg_measure_request { - OaiNwDrvNumRGsMeas_t num_cells; - OaiNwDrvCellID_t cellid[OAI_NW_DRV_MAX_MEASURE_NB]; // Cell identification - unsigned short num_providers; - nioctlProviderId_t provider_id[OAI_NW_DRV_MAX_MEASURE_NB]; // Provider identification -}; -struct oai_nw_drv_msg_measure_reply { - OaiNwDrvNumRGsMeas_t num_cells; - nioctlMeasures_t measures[OAI_NW_DRV_MAX_MEASURE_NB]; - nioctlSignalLoss_t signal_lost_flag; -}; - -// Messages for Measurement transfer - MW 01/04/2005 -typedef unsigned int nioctlL2Id_t[2]; - -struct oai_nw_drv_msg_l2id_reply { - nioctlL2Id_t l2id; -}; - - -#endif diff --git a/openair2/NETWORK_DRIVER/LITE/local.h b/openair2/NETWORK_DRIVER/LITE/local.h deleted file mode 100644 index 4ceae1b929..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/local.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - local.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email :navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - knopp@eurecom.fr - *************************************************************************** - - ***************************************************************************/ - -#ifndef OAI_LOCAL_H -#define OAI_LOCAL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -#define PDCP2IP_FIFO 21 -#define IP2PDCP_FIFO 22 - -#include "constant.h" -#include "common/platform_types.h" -#include "sap.h" - -struct cx_entity { - int sap[OAI_NW_DRV_SAPI_CX_MAX]; - uint8_t state; // state of the connection - OaiNwDrvLocalConnectionRef_t lcr; // Local connection reference - OaiNwDrvCellID_t cellid; // cell identification - uint32_t countimer; // timeout's counter - uint8_t retry; // number of retransmission - - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - int lastRRCprimitive; - //measures - int req_prov_id [OAI_NW_DRV_MAX_MEASURE_NB]; - int num_measures; - int meas_cell_id[OAI_NW_DRV_MAX_MEASURE_NB]; - int meas_level [OAI_NW_DRV_MAX_MEASURE_NB]; - int provider_id [OAI_NW_DRV_MAX_MEASURE_NB]; -}; - -struct oai_nw_drv_priv { - int irq; - int rx_flags; - struct timer_list timer; - spinlock_t lock; - struct net_device_stats stats; - uint8_t retry_limit; - uint32_t timer_establishment; - uint32_t timer_release; - struct cx_entity cx[OAI_NW_DRV_CX_MAX]; - //struct classifier_entity *rclassifier[OAI_NW_DRV_DSCP_MAX]; // receive classifier - uint16_t nrclassifier; - int sap[OAI_NW_DRV_SAPI_MAX]; - struct sock *nl_sk; - uint8_t nlmsg[OAI_NW_DRV_PRIMITIVE_MAX_LENGTH+sizeof(struct nlmsghdr)]; - uint8_t xbuffer[OAI_NW_DRV_PRIMITIVE_MAX_LENGTH]; // transmition buffer - uint8_t rbuffer[OAI_NW_DRV_PRIMITIVE_MAX_LENGTH]; // reception buffer -}; - -struct ipversion { -#if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t reserved:4, - version:4; -#else - uint8_t version:4, - reserved:4; -#endif -}; - -typedef struct pdcp_data_req_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t traffic_type; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t dummy_traffic_type; -} pdcp_data_ind_header_t; - - - -extern struct net_device *oai_nw_drv_dev[OAI_NW_DRV_NB_INSTANCES_MAX]; - -extern uint8_t OAI_NW_DRV_NULL_IMEI[14]; - - - -#endif diff --git a/openair2/NETWORK_DRIVER/LITE/netlink.c b/openair2/NETWORK_DRIVER/LITE/netlink.c deleted file mode 100644 index 2ad104b421..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/netlink.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file netlink.c -* \brief establish a netlink -* \author Navid Nikaein, Lionel Gauthier, and Raymond knopp -* \company Eurecom -* \email:navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr -*/ - -#include - -//#include -#include -#include -#include -#include -#include -#include - -#include - -#include "local.h" -#include "proto_extern.h" - -//#define NETLINK_DEBUG 1 - - -#define OAI_IP_DRIVER_NETLINK_ID 31 -#define NL_DEST_PID 1 - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) -struct netlink_kernel_cfg oai_netlink_cfg; -#endif - -static struct sock *nas_nl_sk = NULL; -static int exit_netlink_thread=0; -static int nas_netlink_rx_thread(void *); - - -static DEFINE_MUTEX(nasmesh_mutex); - -static inline void nasmesh_lock(void) -{ - mutex_lock(&nasmesh_mutex); -} - -static inline void nasmesh_unlock(void) -{ - mutex_unlock(&nasmesh_mutex); -} - -// This can also be implemented using thread to get the data from PDCP without blocking. -static void nas_nl_data_ready (struct sk_buff *skb) -{ - // wake_up_interruptible(skb->sk->sk_sleep); - //nasmesh_lock(); - //netlink_rcv_skb(skb, &my_rcv_msg);// my_rcv_msg is the call back func> - //nasmesh_unlock(); - - struct nlmsghdr *nlh = NULL; - - if (skb) { -#ifdef NETLINK_DEBUG - printk("[OAI_IP_DRV][NETLINK] Received socket from PDCP\n"); -#endif //NETLINK_DEBUG - nlh = (struct nlmsghdr *)skb->data; - oai_nw_drv_common_wireless2ip(nlh); - //kfree_skb(skb); // not required, - } -} - - -int oai_nw_drv_netlink_init(void) -{ - - printk("[OAI_IP_DRV][NETLINK] Running init ...\n"); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) - oai_netlink_cfg.groups = 0; - oai_netlink_cfg.input = nas_nl_data_ready; - oai_netlink_cfg.cb_mutex = &nasmesh_mutex; - oai_netlink_cfg.bind = NULL; - - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, -# if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) - THIS_MODULE, -# endif - &oai_netlink_cfg); -#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, - 0, - nas_nl_data_ready, - &nasmesh_mutex, // NULL - THIS_MODULE); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - - if (nas_nl_sk == NULL) { - - printk("[OAI_IP_DRV][NETLINK] netlink_kernel_create failed \n"); - return(-1); - } - - - - return(0); - -} - - -void oai_nw_drv_netlink_release(void) -{ - - exit_netlink_thread=1; - printk("[OAI_IP_DRV][NETLINK] Releasing netlink socket\n"); - - if(nas_nl_sk) { - netlink_kernel_release(nas_nl_sk); //or skb->sk - - } - - // printk("[OAI_IP_DRV][NETLINK] Removing netlink_rx_thread\n"); - //kthread_stop(netlink_rx_thread); - -} - - - - -int oai_nw_drv_netlink_send(unsigned char *data,unsigned int len) -{ - - - struct sk_buff *nl_skb = alloc_skb(NLMSG_SPACE(len),GFP_ATOMIC); - struct nlmsghdr *nlh = (struct nlmsghdr *)nl_skb->data; - int status; - - - // printk("[OAI_IP_DRV][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); - skb_put(nl_skb, NLMSG_SPACE(len)); - memcpy(NLMSG_DATA(nlh),data,len); - - nlh->nlmsg_len = NLMSG_SPACE(len); - - - nlh->nlmsg_pid = 0; /* from kernel */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - NETLINK_CB(nl_skb).portid = 0; -#else - NETLINK_CB(nl_skb).pid = 0; -#endif - -#ifdef NETLINK_DEBUG - printk("[OAI_IP_DRV][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d\n",nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len); -#endif //DEBUG_NETLINK - - if (nas_nl_sk) { - - // nasmesh_lock(); - status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT); - // mutex_unlock(&nasmesh_mutex); - - if (status < 0) { - printk("[OAI_IP_DRV][NETLINK] SEND status is %d\n",status); - return(0); - } else { -#ifdef NETLINK_DEBUG - printk("[OAI_IP_DRV][NETLINK] SEND status is %d\n",status); -#endif - return len; - } - } else { - printk("[OAI_IP_DRV][SEND] socket is NULL\n"); - return(0); - } -} diff --git a/openair2/NETWORK_DRIVER/LITE/proto_extern.h b/openair2/NETWORK_DRIVER/LITE/proto_extern.h deleted file mode 100644 index d4289ca1f2..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/proto_extern.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - proto_extern.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : michelle.wetterwald@eurecom.fr - yan.moret@eurecom.fr - knopp@eurecom.fr - *************************************************************************** - -***************************************************************************/ - -#ifndef __NETWORK_DRIVER_LITE_PROTO_EXTERN__H__ -#define __NETWORK_DRIVER_LITE_PROTO_EXTERN__H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -#include "local.h" - -// device.c - - -/** @defgroup _oai_nw_drv_impl_ OAI Network Device for RRC Lite -* @ingroup _ref_implementation_ -* @{ -\fn int oai_nw_drv_find_inst(struct net_device *dev) -\brief This function determines the instance id for a particular device pointer. -@param dev Pointer to net_device structure - */ -int oai_nw_drv_find_inst(struct net_device *dev); - -// common.c -/** -\fn void oai_nw_drv_common_class_wireless2ip(unsigned short dlen, void* pdcp_sdu,int inst,OaiNwDrvRadioBearerId_t rb_id) -\brief Receive classified LTE packet, build skbuff struct with it and deliver it to the OS network layer. -@param dlen Length of SDU in bytes -@param pdcp_sdu Pointer to received SDU -@param inst Instance number -@param rb_id Radio Bearer Id - */ -void oai_nw_drv_common_class_wireless2ip(unsigned short dlen, - void *pdcp_sdu, - int inst, - OaiNwDrvRadioBearerId_t rb_id); - -/** -\fn void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst) -\brief Request the transfer of data (QoS SAP) -@param skb pointer to socket buffer -@param inst device instance - */ -void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst); - -/** -\fn void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst) -\brief Drop the IP packet comming from the OS network layer. -@param skb pointer to socket buffer -@param inst device instance - */ -void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst); - -#ifndef OAI_NW_DRIVER_USE_NETLINK -/** -\fn void oai_nw_drv_common_wireless2ip() -\brief Retrieve PDU from PDCP through RT-fifos for delivery to the IP stack. - */ -void oai_nw_drv_common_wireless2ip(void); -#else -/** -\fn void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh) -\brief Retrieve PDU from PDCP through netlink sockets for delivery to the IP stack. - */ -void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh); -#endif //OAI_NW_DRIVER_USE_NETLINK - - -#ifdef OAI_NW_DRIVER_USE_NETLINK -/** -\fn int oai_nw_drv_netlink_send(unsigned char *data,unsigned int len) -\brief Request the transfer of data by PDCP via netlink socket -@param data pointer to SDU -@param len length of SDU in bytes -@returns Numeber of bytes transfered by netlink socket - */ -int oai_nw_drv_netlink_send(unsigned char *data,unsigned int len); - -/** -\fn void oai_nw_drv_COMMON_QOS_receive(struct nlmsghdr *nlh) -\brief Request a PDU from PDCP -@param nlh pointer to netlink message header - */ -void oai_nw_drv_COMMON_QOS_receive(struct nlmsghdr *nlh); - -#endif //OAI_NW_DRIVER_USE_NETLINK - - - -// iocontrol.c -void oai_nw_drv_CTL_send(struct sk_buff *skb, int inst); -int oai_nw_drv_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - -// classifier.c - -/** - \brief Find the IP traffic type (UNICAST, MULTICAST, BROADCAST) of the IP packet attached to sk_buff. -*/ -ip_traffic_type_t oai_nw_drv_find_traffic_type(struct sk_buff *skb); - - - -// tool.c -void oai_nw_drv_TOOL_imei2iid(unsigned char *imei, unsigned char *iid); -void oai_nw_drv_TOOL_eNB_imei2iid(unsigned char *imei, unsigned char *iid, unsigned char len); -unsigned char oai_nw_drv_TOOL_get_dscp6(struct ipv6hdr *iph); -unsigned char oai_nw_drv_TOOL_get_dscp4(struct iphdr *iph); -unsigned char *oai_nw_drv_TOOL_get_protocol6(struct ipv6hdr *iph, unsigned char *protocol); -unsigned char *oai_nw_drv_TOOL_get_protocol4(struct iphdr *iph, unsigned char *protocol); -char *oai_nw_drv_TOOL_get_udpmsg(struct udphdr *udph); -unsigned short oai_nw_drv_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, unsigned char proto, unsigned int udplen, void *data); -int oai_nw_drv_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, unsigned char plen); -int oai_nw_drv_TOOL_network4(unsigned int *addr, unsigned int *prefix, unsigned char plen); -void print_TOOL_pk_icmp6(struct icmp6hdr *icmph); - -void print_TOOL_pk_all(struct sk_buff *skb); -void print_TOOL_pk_ipv6(struct ipv6hdr *iph); -void print_TOOL_state(unsigned char state); -void oai_nw_drv_tool_print_buffer(char * buffer,int length); -#ifdef OAI_NW_DRIVER_USE_NETLINK -// netlink.c - -void oai_nw_drv_netlink_release(void); -int oai_nw_drv_netlink_init(void); - -#endif - -/** @} */ -#endif diff --git a/openair2/NETWORK_DRIVER/LITE/sap.h b/openair2/NETWORK_DRIVER/LITE/sap.h deleted file mode 100644 index d72a1b10df..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/sap.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef OAI_SAP_H -#define OAI_SAP_H -typedef unsigned short OaiNwDrvRadioBearerId_t; -typedef unsigned int OaiNwDrvSapId_t; // Id of the QoS SAP to use -typedef unsigned short OaiNwDrvQoSTrafficClass_t; // QoS traffic class requested -typedef unsigned int OaiNwDrvLocalConnectionRef_t; // local identifier -typedef unsigned short OaiNwDrvCellID_t; // ID of the cell for connection -typedef unsigned short OaiNwDrvNumRGsMeas_t; // number of RGs that could be measured -typedef unsigned int OaiNwDrvSigLevel_t; // Signal level measured - -#define OAI_NW_DRV_SAPI_CX_MAX 2 -#define OAI_NW_DRV_MAX_MEASURE_NB 5 -#define OAI_NW_DRV_PRIMITIVE_MAX_LENGTH 180 // maximum length of a NAS primitive -#define OAI_NW_DRV_SAPI_MAX 4 -#define OAI_NW_DRV_RAB_INPUT_SAPI 2 -#define OAI_NW_DRV_RAB_OUTPUT_SAPI 3 -#define OAI_NW_DRV_MAX_RABS 8 * 64 //NB_RAB_MAX * MAX_MOBILES_PER_RG //27 // = MAXURAB -#define OAI_NW_DRV_LIST_RB_MAX 32 -#endif diff --git a/openair2/NETWORK_DRIVER/LITE/tool.c b/openair2/NETWORK_DRIVER/LITE/tool.c deleted file mode 100644 index d8d0030dd9..0000000000 --- a/openair2/NETWORK_DRIVER/LITE/tool.c +++ /dev/null @@ -1,747 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "local.h" -#include "proto_extern.h" - -//#include -//#include -//#include -//#include -//#include -//#include - -//#define OAI_NW_DRV_DEBUG_TOOL 1 - - - -//--------------------------------------------------------------------------- -uint8_t oai_nw_drv_TOOL_get_dscp6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_DSCP6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_DSCP6 - input parameter iph is NULL \n"); -#endif - return 0; - } - - // End debug information - return (ntohl(((*(__u32 *)iph)&OAI_NW_DRV_TRAFFICCLASS_MASK)))>>22; - //return ntohs(*(const __be16 *)iph) >> 4; // see linux/dsfield.h - -} - -//--------------------------------------------------------------------------- -uint8_t oai_nw_drv_TOOL_get_dscp4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_DSCP4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_DSCP4 - input parameter iph is NULL \n"); -#endif - return 0; - } - - // End debug information - return (iph->tos); - -} - -//--------------------------------------------------------------------------- -int oai_nw_drv_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, uint8_t plen) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK6 - begin \n"); -#endif - - if (addr==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK6 - input parameter addr is NULL \n"); -#endif - return 0; - } - - if (prefix==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK6 - input parameter prefix is NULL \n"); -#endif - return 0; - } - - // End debug information - switch(plen/32) { - case 0: - return (((addr->s6_addr32[0]>>(32-plen))<<(32-plen))==prefix->s6_addr[0]); - - case 1: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (((addr->s6_addr32[1]>>(64-plen))<<(64-plen))==prefix->s6_addr[1])); - - case 2: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (((addr->s6_addr32[2]>>(96-plen))<<(96-plen))==prefix->s6_addr[2])); - - case 3: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (addr->s6_addr32[2]==prefix->s6_addr[2])&& - (((addr->s6_addr32[3]>>(128-plen))<<(128-plen))==prefix->s6_addr[3])); - - default: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (addr->s6_addr32[2]==prefix->s6_addr[2])&& - (addr->s6_addr32[3]==prefix->s6_addr[3])); - } -} - -//--------------------------------------------------------------------------- -int oai_nw_drv_TOOL_network4(uint32_t *addr, uint32_t *prefix, uint8_t plen) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK4 - begin \n"); -#endif - - if (addr==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK4 - input parameter addr is NULL \n"); -#endif - return 0; - } - - if (prefix==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_NETWORK4 - input parameter prefix is NULL \n"); -#endif - return 0; - } - - // End debug information - if (plen>=32) - return (*addr==*prefix); - else - return (((*addr>>(32-plen))<<(32-plen))==*prefix); -} - -//--------------------------------------------------------------------------- -//struct udphdr *oai_nw_drv_TOOL_get_udp6(struct ipv6hdr *iph){ -//--------------------------------------------------------------------------- -// return (struct udphdr *)((char *)iph+OAI_NW_DRV_IPV6_SIZE); // to modify -//} - -//--------------------------------------------------------------------------- -uint8_t *oai_nw_drv_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - uint16_t size; - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - input parameter iph is NULL \n"); -#endif - return NULL; - } - - if (protocol==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - input parameter protocol is NULL \n"); -#endif - return NULL; - } - - // End debug information - *protocol=iph->nexthdr; - size=OAI_NW_DRV_IPV6_SIZE; - - while (1) { - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMPV6: - return (uint8_t *)((uint8_t *)iph+size); - - case IPPROTO_HOPOPTS: - case IPPROTO_ROUTING: - case IPPROTO_DSTOPTS: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]*8+8; - break; - - case IPPROTO_FRAGMENT: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]+8; - break; - - case IPPROTO_NONE: - case IPPROTO_AH: - case IPPROTO_ESP: - default: - return NULL; - } - } -} - -//--------------------------------------------------------------------------- -uint8_t *oai_nw_drv_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL4 - input parameter iph is NULL \n"); -#endif - return NULL; - } - - if (protocol==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_PROTOCOL4 - input parameter protocol is NULL \n"); -#endif - return NULL; - } - - // End debug information - *protocol=iph->protocol; - - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMP: - return (uint8_t *)((uint8_t *)iph+iph->tot_len); - - default: - return NULL; - } -} - -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void oai_nw_drv_TOOL_imei2iid(uint8_t *imei, uint8_t *iid) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_IMEI2IID - begin \n"); -#endif - - if (imei==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_IMEI2IID - input parameter imei is NULL \n"); -#endif - return; - } - - if (iid==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_IMEI2IID - input parameter iid is NULL \n"); -#endif - return; - } - - // End debug information - memset(iid, 0, OAI_NW_DRV_ADDR_LEN); - iid[0] = 0x03; - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 16*imei[4]+imei[5]; - iid[4] = 16*imei[6]+imei[7]; - iid[5] = 16*imei[8]+imei[9]; - iid[6] = 16*imei[10]+imei[11]; - iid[7] = 16*imei[12]+imei[13]; -} -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void oai_nw_drv_TOOL_eNB_imei2iid(unsigned char *imei, unsigned char *iid, unsigned char len) -{ - //--------------------------------------------------------------------------- - unsigned int index; - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - begin \n"); -#endif - - if (imei==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - input parameter imei is NULL \n"); -#endif - return; - } - - if (iid==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - input parameter iid is NULL \n"); -#endif - return; - } - - // End debug information - memset(iid, 0, len); - iid[0] = 0x00; // to be compatible between link local and global - - // len -1 because of insertion of 0 above - for (index = 0; index < (len-1); index++) { - iid[index+1] = 16*imei[index*2]+imei[index*2+1]; - } -} - -//struct udphdr *oai_nw_drv_TOOL_get_udp4(struct iphdr *iph) -//{ -// return (struct udphdr *)((char *)iph+OAI_NW_DRV_IPV4_SIZE); // to modify -//} - - -//--------------------------------------------------------------------------- -char *oai_nw_drv_TOOL_get_udpmsg(struct udphdr *udph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_UDPMSG - begin \n"); -#endif - - if (udph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_GET_UDPMSG - input parameter udph is NULL \n"); -#endif - return NULL; - } - - // End debug information - return ((char *)udph+sizeof(struct udphdr)); -} - -//--------------------------------------------------------------------------- -// Compute the UDP checksum (the data size must be odd) -uint16_t oai_nw_drv_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, uint8_t proto, uint32_t udplen, void *data) -{ - //--------------------------------------------------------------------------- - uint32_t i; - uint16_t *data16; - uint32_t csum=0; - - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_UDPCKSUM - begin \n"); -#endif - - if (saddr==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_UDPCKSUM - input parameter saddr is NULL \n"); -#endif - return 0; - } - - if (daddr==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_UDPCKSUM - input parameter daddr is NULL \n"); -#endif - return 0; - } - - if (data==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_UDPCKSUM - input parameter data is NULL \n"); -#endif - return 0; - } - - // End debug information - data16=data; - - for (i=0; i<8; ++i) { - csum+=ntohs(saddr->s6_addr16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - for (i=0; i<8; ++i) { - csum+=ntohs(daddr->s6_addr16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - csum+=(udplen>>16); // udplen checksum - - if (csum>0xffff) - csum -= 0xffff; - - csum+=udplen & 0xffff; - - if (csum>0xffff) - csum -= 0xffff; - - csum+=proto; // protocol checksum - - if (csum>0xffff) - csum-=0xffff; - - for (i = 0; 2*i < udplen; i++) { - csum+=ntohs(data16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - return htons((uint16_t)(~csum)&0xffff); -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_udp(struct udphdr *udph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("PRINT_TOOL_PK_UDP - begin \n"); -#endif - - if (udph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PK_UDP - input parameter udph is NULL \n"); -#endif - return; - } - - // End debug information - if (udph!=NULL) { - printk("UDP:\t source = %u, dest = %u, len = %u, check = %x\n", ntohs(udph->source), ntohs(udph->dest), ntohs(udph->len), udph->check); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_tcp(struct tcphdr *tcph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("PRINT_TOOL_PK_TDP - begin \n"); -#endif - - if (tcph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PK_TDP - input parameter tcph is NULL \n"); -#endif - return; - } - - // End debug information - if (tcph!=NULL) { - printk("TCP:\t source = %u, dest = %u\n", tcph->source, tcph->dest); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_icmp6(struct icmp6hdr *icmph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("PRINT_TOOL_PK_ICMP6 - begin \n"); -#endif - - if (icmph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PK_ICMP6 - input parameter icmph is NULL \n"); -#endif - return; - } - - // End debug information - if (icmph!=NULL) { - printk("ICMPv6:\t type= %d, code = %d\n", icmph->icmp6_type, icmph->icmp6_code); - - switch(icmph->icmp6_type) { - case ICMPV6_DEST_UNREACH: - printk("Destination unreachable\n"); - break; - - case ICMPV6_PKT_TOOBIG: - printk("Packet too big\n"); - break; - - case ICMPV6_TIME_EXCEED: - printk("Time exceeded\n"); - break; - - case ICMPV6_PARAMPROB: - printk("Parameter problem\n"); - break; - - case ICMPV6_ECHO_REQUEST: - printk("Echo request\n"); - break; - - case ICMPV6_ECHO_REPLY: - printk("Echo reply\n"); - break; - - case ICMPV6_MGM_QUERY: - printk("Multicast listener query\n"); - break; - - case ICMPV6_MGM_REPORT: - printk("Multicast listener report\n"); - break; - - case ICMPV6_MGM_REDUCTION: - printk("Multicast listener done\n"); - break; - - case NDISC_ROUTER_SOLICITATION: - printk("Router solicitation\n"); - break; - - case NDISC_ROUTER_ADVERTISEMENT: - printk("Router advertisment\n"); - break; - - case NDISC_NEIGHBOUR_SOLICITATION: - printk("Neighbour solicitation\n"); - break; - - case NDISC_NEIGHBOUR_ADVERTISEMENT: - printk("Neighbour advertisment\n"); - break; - - case NDISC_REDIRECT: - printk("redirect message\n"); - break; - } - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_ipv6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("PRINT_TOOL_PK_IPv6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PK_IPv6 - input parameter iph is NULL \n"); -#endif - return; - } - - // End debug information - - if (iph!=NULL) { - // char addr[OAI_NW_DRV_INET6_ADDRSTRLEN]; - printk("IP:\t version = %u, priority = %u, payload_len = %u\n", iph->version, iph->priority, ntohs(iph->payload_len)); - printk("\t fl0 = %u, fl1 = %u, fl2 = %u\n",iph->flow_lbl[0],iph->flow_lbl[1],iph->flow_lbl[2]); - printk("\t next header = %u, hop_limit = %u\n", iph->nexthdr, iph->hop_limit); - - // inet_ntop(AF_INET6, (void *)(&iph->saddr), addr, OAI_NW_DRV_INET6_ADDRSTRLEN); - // printk("\t saddr = %s",addr); - // inet_ntop(AF_INET6, (void *)(&iph->daddr), addr, OAI_NW_DRV_INET6_ADDRSTRLEN); - // printk(", daddr = %s\n",addr); - switch(iph->nexthdr) { - case IPPROTO_UDP: - print_TOOL_pk_udp((struct udphdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_TCP: - print_TOOL_pk_tcp((struct tcphdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_ICMPV6: - print_TOOL_pk_icmp6((struct icmp6hdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_IPV6: - print_TOOL_pk_ipv6((struct ipv6hdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - default: - printk("Unknown upper layer\n"); - } - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_ipv4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("PRINT_TOOL_PK_IPv4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PK_IPv4 - input parameter iph is NULL \n"); -#endif - return; - } - - // End debug information - - if (iph!=NULL) { - // char addr[OAI_NW_DRV_INET_ADDRSTRLEN]; - printk("IP:\t version = %u, IP length = %u\n", iph->version, iph->ihl); - // inet_ntop(AF_INET, (void *)(&iph->saddr), addr, OAI_NW_DRV_INET_ADDRSTRLEN); - // printk("\t saddr = %s", addr); - // inet_ntop(AF_INET, (void *)(&iph->saddr), addr, OAI_NW_DRV_INET_ADDRSTRLEN); - // printk("\t saddr = %s", addr); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_all(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - printk("Skb:\t %u, len = %u\n", (unsigned int)skb, skb->len); - //navid: need to calculate the current used space: fixme? - printk("Skb:\t available buf space = %u \n", skb->truesize); - - switch (ntohs(skb->protocol)) { - case ETH_P_IPV6: - print_TOOL_pk_ipv6((struct ipv6hdr *)skb->network_header); - break; - - case ETH_P_IP: - print_TOOL_pk_ipv4((struct iphdr *)skb->network_header); - break; - } -} - -//--------------------------------------------------------------------------- -/*int isdigit(char c) -{ - switch(c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return 1; - default: - return 0; - } -}*/ - -/*int oai_nw_drv_TOOL_inet_pton4(char *src, uint32_t *dst) -{ - uint32_t val; - int n; - uint8_t c; - uint32_t parts[4]; - - c = *src; - val=0; - n=0 - for (;;) - { - for (;;) - { - if (isdigit(c)) - { - val = (val * 10) + c - '0'; - c = *++src; - } - else - break; - } - if (c == '.') - { - if (n>4) - return -1; - parts[n]=val; - c = *++src; - ++n; - } - else - break; - } - if ((c != '\0')||(n!=3)) - return (0); - if ((parts[0] | parts[1] | parts[2] | val) > 256) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - if (dst) - dst = htonl(val); - return (1); -}*/ - - - -//----------------------------------------------------------------------------- -// Print the content of a buffer in hexadecimal -void oai_nw_drv_tool_print_buffer(char * buffer,int length) -{ - //----------------------------------------------------------------------------- - int i; - - // Start debug information -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PRINT_BUFFER - begin \n"); -#endif - - if (buffer==NULL) { -#ifdef OAI_NW_DRV_DEBUG_TOOL - printk("OAI_NW_DRV_TOOL_PRINT_BUFFER - input parameter buffer is NULL \n"); -#endif - return; - } - - // End debug information - printk("\nBuffer content: "); - - for (i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -// - -//#include "ral_cdma_variables.h" -//#include "ral_cdma_proto.h" - -#include "rrc_nas_primitives.h" -#include "ioctl.h" -#include "constant.h" - -//#include "nasmt_constant.h" -//#include "nasmt_iocontrol.h" - - - -// Global variables -//int sd_graal; -int fd; -//char myIPAddr[16]; // local IP Address -//int meas_counter; -//struct ralu_priv ru_priv; -//struct ralu_priv *ralupriv; -//ioctl -char dummy_buffer[1024]; -struct nas_ioctl gifr; -//int wait_start_nas; - -/* -//--------------------------------------------------------------------------- -int NAS_RALconnect(void) -//--------------------------------------------------------------------------- -{ - struct sockaddr_un remote; - int len,s; - - if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - perror("NAS_RALconnect - socket"); - exit(1); - } - // - printf("Trying to connect to NAS ...\n"); - remote.sun_family = AF_UNIX; - strcpy(remote.sun_path, SOCKET_RAL_TD_CDMA_NAME); - len = strlen(remote.sun_path) + sizeof(remote.sun_family); - - while (wait_start_graal){ - if (connect(s, (struct sockaddr *)&remote, len) == -1) { - perror("NAS_RALconnect - waiting for connection - "); - // exit(1); - wait_start_graal = 1; - sleep(5); - } else { - wait_start_graal =0; - printf("RAL connected to NAS.\n"); - } - - } - return s; -} - -*/ - -//--------------------------------------------------------------------------- -void IAL_NAS_ioctl_init(int inst) -//--------------------------------------------------------------------------- -{ - struct nas_msg_statistic_reply *msgrep; - int err; - sprintf(gifr.name, "oai%d",inst); - // Get an UDP IPv6 socket ?? - fd=socket(AF_INET6, SOCK_DGRAM, 0); - - if (fd<0) { - printf("Error opening socket\n"); - exit(1); - } - - sprintf(gifr.name, "oai%d",inst); - gifr.type = NAS_MSG_STATISTIC_REQUEST; - memset ((void *)dummy_buffer,0,800); - gifr.msg= &(dummy_buffer[0]); - msgrep=(struct nas_msg_statistic_reply *)(gifr.msg); - printf("ioctl :Statistics requested\n"); - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - } - - printf("tx_packets = %u, rx_packets = %u\n", msgrep->tx_packets, msgrep->rx_packets); - printf("tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes); - printf("tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors); - printf("tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped); -} - - -#define ADD_RB 0 -#define DEL_RB 1 - -//--------------------------------------------------------------------------- -int main(int argc,char **argv) -//--------------------------------------------------------------------------- -{ - int err = 0; - int c = 0; - int action=0,rbset=0,cxset=0,instset=0,saddr_ipv4set=0,saddr_ipv6set=0,daddr_ipv4set=0,daddr_ipv6set=0,dscpset=0,mpls_outlabelset=0,mpls_inlabelset=0; - char rb[100],cx[100],dscp[100],inst[100],mpls_outgoinglabel[100],mpls_incominglabel[100]; - struct nas_msg_rb_establishment_request *msgreq = NULL; - struct nas_msg_class_add_request *msgreq_class = NULL; - in_addr_t saddr_ipv4 = 0,daddr_ipv4 = 0; - struct in6_addr saddr_ipv6,daddr_ipv6; - unsigned int mpls_outlabel=0,mpls_inlabel=0; - char addr_str[46]; - // scan options - rb[0] = '\0'; - cx[0] = '\0'; - dscp[0] = '\0'; - mpls_incominglabel[0] = '\0'; - mpls_outgoinglabel[0] = '\0'; - - while ((c = getopt (argc, argv, "adr:i:c:l:m:s:t:x:y:z:")) != -1) - switch (c) { - case 'a': - action = ADD_RB; - break; - - case 'd': - action = DEL_RB; - break; - - case 'r': - strcpy(rb,optarg); - rbset = 1; - break; - - case 'i': - strcpy(inst,optarg); - instset = 1; - break; - - case 'c': - strcpy(cx,optarg); - cxset = 1; - break; - - case 'l': - strcpy(mpls_outgoinglabel,optarg); - mpls_outlabelset=1; - break; - - case 'm': - strcpy(mpls_incominglabel,optarg); - mpls_inlabelset=1; - break; - - case 's': { - struct in_addr a; - inet_aton(optarg,&a); - saddr_ipv4 = a.s_addr; - saddr_ipv4set = 1; - break; - } - - case 't': { - struct in_addr a; - inet_aton(optarg,&a); - daddr_ipv4 = a.s_addr; - daddr_ipv4set = 1; - break; - } - - case 'x': - printf("IPv6: %s\n",optarg); - inet_pton(AF_INET6,optarg,(void *)&saddr_ipv6); - saddr_ipv6set = 1; - break; - - case 'y': - inet_pton(AF_INET6,optarg,(void *)&daddr_ipv6); - daddr_ipv6set = 1; - break; - - case 'z': - dscpset=1; - strcpy(dscp,optarg); - break; - - case '?': - if (isprint (optopt)) - fprintf (stderr, "Unknown option `-%c'.\n", optopt); - else - fprintf (stderr, - "Unknown option character `\\x%x'.\n", - optopt); - - return 1; - - default: - abort (); - } - - printf ("action = %d, rb = %s,cx = %s\n", action, rb, cx); - - if (rbset==0) { - printf("ERROR: Specify a RAB id!!\n"); - exit(-1); - } - - if (cxset==0) { - printf("ERROR: Specify an LCR !!\n"); - exit(-1); - } - - if (instset==0) { - printf("ERROR: Specify an interface !!\n"); - exit(-1); - } - - if ((mpls_outlabelset == 0) && (saddr_ipv4set==0) && (saddr_ipv6set==0)) { - printf("ERROR: Specify a source IP address\n"); - exit(-1); - } - - if ((mpls_outlabelset == 0) && (daddr_ipv4set==0) && (daddr_ipv6set==0)) { - printf("ERROR: Specify a destination IP address\n"); - exit(-1); - } - - if ((mpls_outlabelset == 1) && (mpls_inlabelset == 0)) { - printf("ERROR: Specify an incoming MPLS label\n"); - exit(-1); - } - - if ((mpls_inlabelset == 1) && (mpls_outlabelset == 0)) { - printf("ERROR: Specify an outgoing MPLS label\n"); - exit(-1); - } - - IAL_NAS_ioctl_init(atoi(inst)); - msgreq = (struct nas_msg_rb_establishment_request *)(gifr.msg); - msgreq->rab_id = atoi(rb); - msgreq->lcr = atoi(cx); - msgreq->qos = 0; - - if (action == ADD_RB) { - gifr.type = NAS_MSG_RB_ESTABLISHMENT_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - - if (saddr_ipv4set == 1) { - msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = 4; - msgreq_class->classref = 0 + (msgreq_class->lcr<<3); - msgreq_class->dir = NAS_DIRECTION_SEND; - msgreq_class->fct = NAS_FCT_QOS_SEND; - msgreq_class->saddr.ipv4 = saddr_ipv4; - msgreq_class->daddr.ipv4 = daddr_ipv4; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = NAS_PROTOCOL_DEFAULT; - - if (dscpset==0) - msgreq_class->dscp=0; - else - msgreq_class->dscp=atoi(dscp); - - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->classref = 1+(msgreq_class->lcr<<3); - msgreq_class->dir = NAS_DIRECTION_RECEIVE; - msgreq_class->daddr.ipv4 = saddr_ipv4; - msgreq_class->saddr.ipv4 = daddr_ipv4; - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - } - - if (saddr_ipv6set == 1) { - msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = 6; - - if (dscpset==0) - msgreq_class->dscp=0; - else - msgreq_class->dscp=atoi(dscp); - - msgreq_class->classref = 2+(msgreq_class->lcr<<3); - msgreq_class->dir=NAS_DIRECTION_SEND; - msgreq_class->fct=NAS_FCT_QOS_SEND; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = NAS_PROTOCOL_DEFAULT; - memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16); - memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16); - inet_ntop(AF_INET6,(void *)&saddr_ipv6,addr_str,46); - printf("IPV6: Source %s\n",addr_str); - inet_ntop(AF_INET6,(void *)&daddr_ipv6,addr_str,46); - printf("IPV6: Dest %s\n",addr_str); - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->classref = 3+(msgreq_class->lcr<<3); - msgreq_class->dir=NAS_DIRECTION_RECEIVE; - memcpy(&msgreq_class->daddr.ipv6,&saddr_ipv6,16); - memcpy(&msgreq_class->saddr.ipv6,&daddr_ipv6,16); - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - } - - if (mpls_inlabelset == 1) { - msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg); - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->version = NAS_MPLS_VERSION_CODE; - - if (dscpset==0) - msgreq_class->dscp=0; - else - msgreq_class->dscp=atoi(dscp); - - msgreq_class->classref = 4 + (msgreq_class->lcr<<3); - msgreq_class->dir=NAS_DIRECTION_SEND; - msgreq_class->fct=NAS_FCT_QOS_SEND; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = NAS_PROTOCOL_DEFAULT; - mpls_outlabel = atoi(mpls_outgoinglabel); - printf("Setting MPLS outlabel %u with exp %d\n",mpls_outlabel,msgreq_class->dscp); - msgreq_class->daddr.mpls_label = mpls_outlabel; - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - - msgreq_class->rab_id = atoi(rb); - msgreq_class->lcr = atoi(cx); - msgreq_class->classref = 5 + (msgreq_class->lcr<<3); - msgreq_class->dir=NAS_DIRECTION_RECEIVE; - // TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule - msgreq_class->protocol = NAS_PROTOCOL_DEFAULT; - mpls_inlabel = atoi(mpls_incominglabel); - printf("Setting MPLS inlabel %u with exp %d\n",mpls_inlabel,msgreq_class->dscp); - msgreq_class->daddr.mpls_label = mpls_inlabel; - gifr.type = NAS_MSG_CLASS_ADD_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - } - } else if (action == DEL_RB) { - gifr.type = NAS_MSG_RB_RELEASE_REQUEST; - err=ioctl(fd, NAS_IOCTL_RRM, &gifr); - - if (err == -1) perror("ioctl"); - } -} diff --git a/openair2/NETWORK_DRIVER/MESH/TESTBENCH/testbench.c b/openair2/NETWORK_DRIVER/MESH/TESTBENCH/testbench.c deleted file mode 100644 index 121d3bba8b..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/TESTBENCH/testbench.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include -#include -#include -#include -#include -#include - -typedef unsigned int sdu_size_t; -typedef unsigned int rb_id_t; - -typedef struct pdcp_data_req_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_ind_header_t; - -#define MAX_PAYLOAD 1024 /* maximum payload size*/ -struct sockaddr_nl src_addr, dest_addr; -struct nlmsghdr *nlh = NULL; -struct iovec iov; -int sock_fd; -struct msghdr msg; - - -void foo( int sig ) -{ - - printf("I got cntl-C, closing socket\n"); - - - close(sock_fd); - exit(-1); -} - - -#define OAI_IP_DRIVER_NETLINK_ID 31 - -void main() -{ - - - struct sigaction newaction; - int i=0; - int ret; - int len; - - newaction.sa_handler = foo; - - if ( sigaction( SIGINT, &newaction, NULL ) == -1) - perror("Could not install the new signal handler"); - - sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); - - printf("Opened socket with fd %d\n",sock_fd); - - ret = fcntl(sock_fd,F_SETFL,O_NONBLOCK); - printf("fcntl returns %d\n",ret); - - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = 1;//getpid(); /* self pid */ - src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(sock_fd, (struct sockaddr*)&src_addr, - sizeof(src_addr)); - printf("bind returns %d\n",ret); - - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* For Linux Kernel */ - dest_addr.nl_groups = 0; /* unicast */ - - nlh=(struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD)); - /* Fill the netlink message header */ - nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD); - nlh->nlmsg_pid = 1;//getpid(); /* self pid */ - nlh->nlmsg_flags = 0; - - iov.iov_base = (void *)nlh; - iov.iov_len = nlh->nlmsg_len; - memset(&msg,0,sizeof(msg)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - - /* Read message from kernel */ - memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD)); - - while (1) { - len = recvmsg(sock_fd, &msg, 0); - - - if (len<0) { - - // exit(-1); - } else { - printf("Received socket with length %d (nlmsg_len = %d)\n",len,nlh->nlmsg_len); - } - - usleep(1000); - i=i+1; - - if ((i % 100) == 0) - printf("%d\n",i); - - /* - for (i=0;inlmsg_len - sizeof(struct nlmsghdr);i++) { - printf("%x ", - ((unsigned char *)NLMSG_DATA(nlh))[i]); - } - */ - } - - /* Close Netlink Socket */ - -} - - - - diff --git a/openair2/NETWORK_DRIVER/MESH/classifier.c b/openair2/NETWORK_DRIVER/MESH/classifier.c deleted file mode 100644 index 32d60917f6..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/classifier.c +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file classifier.c -* \brief Classify IP packets -* \author Navid Nikaein, Lionel GAUTHIER, Raymond knopp -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr -*/ - - -#include "local.h" -#include "proto_extern.h" - -#include -#include - - -//#define MPLS - -#ifdef MPLS - #include -#endif - - -//#define NAS_DEBUG_CLASS 1 -//#define NAS_DEBUG_SEND 1 - -//--------------------------------------------------------------------------- -// Add a new classifier rule (send direction) -struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) { - //--------------------------------------------------------------------------- - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_SCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_SCLASSIFIER - input parameter cx is NULL \n"); -#endif - return NULL; - } - - for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_SCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL); - - if (gc==NULL) - return NULL; - - gc->next=cx->sclassifier[dscp]; - gc->classref=classref; - cx->sclassifier[dscp]=gc; - ++cx->nsclassifier; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_SCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (receive direction) -struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp, - uint16_t classref, - struct nas_priv *gpriv) { - //--------------------------------------------------------------------------- - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_RCLASSIFIER: begin\n"); -#endif - - for (gc=gpriv->rclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_RCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL); - - if (gc==NULL) - return NULL; - - gc->next=gpriv->rclassifier[dscp]; - gc->classref=classref; - gpriv->rclassifier[dscp]=gc; - ++gpriv->nrclassifier; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_RCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (forwarding) -struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) { - //--------------------------------------------------------------------------- - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_FCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_FCLASSIFIER - input parameter cx is NULL \n"); -#endif - return NULL; - } - - for (gc=cx->fclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_SCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL); - - if (gc==NULL) - return NULL; - - gc->next=cx->fclassifier[dscp]; - gc->classref=classref; - cx->fclassifier[dscp]=gc; - ++cx->nfclassifier; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_ADD_FCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - - -//--------------------------------------------------------------------------- -void nas_CLASS_flush_sclassifier(struct cx_entity *cx) { - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_SCLASSIFIER: begin\n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_SCLASSIFIER - input parameter cx is NULL \n"); -#endif - return; - } - - // - for (dscpi=0; dscpisclassifier[dscpi]; gc!=NULL; gc=cx->sclassifier[dscpi]) { - cx->sclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - cx->nsclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_SCLASSIFIER: end\n"); -#endif -} -//--------------------------------------------------------------------------- -void nas_CLASS_flush_fclassifier(struct cx_entity *cx) { - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_FCLASSIFIER: begin\n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_FCLASSIFIER - input parameter cx is NULL \n"); -#endif - return; - } - - // - for (dscpi=0; dscpifclassifier[dscpi]; gc!=NULL; gc=cx->fclassifier[dscpi]) { - cx->fclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - cx->nfclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_FCLASSIFIER: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv) { - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_RCLASSIFIER: begin\n"); -#endif - - for (dscpi=0; dscpirclassifier[dscpi]; gc!=NULL; gc=gpriv->rclassifier[dscpi]) { - gpriv->rclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - gpriv->nrclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_FLUSH_RCLASSIFIER: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (send direction) -void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) { - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_SCLASSIFIER: begin\n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_SCLASSIFIER - input parameter cx is NULL \n"); -#endif - return; - } - - // - p=cx->sclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - cx->sclassifier[dscp]=p->next; - kfree(p); - --cx->nsclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --cx->nsclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_SCLASSIFIER: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (send direction) -void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) { - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_FCLASSIFIER: begin\n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_FCLASSIFIER - input parameter cx is NULL \n"); -#endif - return; - } - - // - p=cx->fclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - cx->fclassifier[dscp]=p->next; - kfree(p); - --cx->nfclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --cx->nfclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_FCLASSIFIER: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (receive direction) -void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv) { - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_RCLASSIFIER: begin\n"); -#endif - p=gpriv->rclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - gpriv->rclassifier[dscp]=p->next; - kfree(p); - --gpriv->nrclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --gpriv->nrclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_DEL_RCLASSIFIER: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Search the entity with the IPv6 address 'addr' -// Navid: the ipv6 classifier is not fully tested -struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb, - unsigned char dscp, - struct nas_priv *gpriv, - int inst, - unsigned char *cx_searcher) { - //--------------------------------------------------------------------------- - unsigned char cxi; - unsigned int *addr,*dst=NULL; - struct cx_entity *default_ip=NULL; - struct classifier_entity *p=NULL; - - if (skb!=NULL) { - for (cxi=*cx_searcher; cxicx[cxi].sclassifier[dscp]; - - while (p!=NULL) { - if (p->version == 6) { // verify that this is an IPv4 rule - if ((addr = (unsigned int *)(&(p->daddr.ipv6)))== NULL) { - printk("nas_CLASS_cx6: addr is null \n"); - p = p->next; - continue; - } - -#ifdef NAS_DEBUG_CLASS - printk("cx %d : %X,%X.%X,%X\n",cxi,addr[0],addr[1],addr[2],addr[3]); -#endif //NAS_DEBUG_CLASS - - - if ( (dst = &((struct iphdr *)(skb_network_header(skb)))->daddr) == NULL) { - printk("nas_CLASS_cx6: dst addr is null \n"); - p = p->next; - continue; - } - - if ((addr[0] == dst[0]) && - (addr[1] == dst[1]) && - (addr[2] == dst[2]) && - (addr[3] == dst[3])) { - //#ifdef NAS_DEBUG_CLASS - printk("nas_CLASS_cx6: found cx %d: %X.%X.%X.%X\n",cxi, - dst[0], - dst[1], - dst[2], - dst[3]); - //#endif //NAS_DEBUG_CLASS - return gpriv->cx+cxi; - } - - /* - else if ((addr[0]==NAS_DEFAULT_IPV6_ADDR0) && - (addr[1]==NAS_DEFAULT_IPV6_ADDR1) && - (addr[2]==NAS_DEFAULT_IPV6_ADDR2) && - (addr[3]==NAS_DEFAULT_IPV6_ADDR3)) - default_ip = gpriv->cx+cxi; - */ - } - - // Go to next classifier entry for connection - p = p->next; - } - } - } - - - if (dst ) { - printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n", - dst[0], - dst[1], - dst[2], - dst[3]); - } - - return default_ip; -} - -//--------------------------------------------------------------------------- -// Search the entity with the IPv4 address 'addr' -struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb, - unsigned char dscp, - struct nas_priv *gpriv, - int inst, - unsigned char *cx_searcher) { - //--------------------------------------------------------------------------- - unsigned char cxi; - unsigned char *addr; - uint32_t daddr; - struct cx_entity *default_ip=NULL; - struct classifier_entity *p=NULL; - - // if (inst >0) - // return(gpriv->cx); //dump to clusterhead - - if (skb!=NULL) { - daddr = ((struct iphdr *)(skb_network_header(skb)))->daddr; - - if (daddr!=0) { -#ifdef NAS_DEBUG_CLASS - printk("[NAS][CLASS][IPv4] Searching for %d.%d.%d.%d\n", - ((unsigned char *)&daddr)[0], - ((unsigned char *)&daddr)[1], - ((unsigned char *)&daddr)[2], - ((unsigned char *)&daddr)[3]); -#endif - - for (cxi=*cx_searcher; cxicx[cxi].sclassifier[dscp]; - - while (p!=NULL) { - if (p->version == 4) { // verify that this is an IPv4 rule -#ifdef NAS_DEBUG_CLASS - addr = (char *)(&(p->daddr.ipv4)); - printk("found classifier cx %d for destination: %d.%d.%d.%d\n",cxi,addr[0],addr[1],addr[2],addr[3]); -#endif //NAS_DEBUG_CLASS - - if ((p->daddr.ipv4)== daddr) { - addr = (char *)(&(p->daddr.ipv4)); -#ifdef NAS_DEBUG_CLASS - printk("found cx %d: %d.%d.%d.%d\n",cxi, - addr[0], - addr[1], - addr[2], - addr[3]); -#endif //NAS_DEBUG_CLASS - return gpriv->cx+cxi; - } - - /* - else if (gpriv->cx[cxi].sclassifier[dscp]->daddr.ipv4==NAS_DEFAULT_IPV4_ADDR) { - #ifdef NAS_DEBUG_CLASS - printk("found default_ip rule\n"); - #endif //NAS_DEBUG_CLASS - default_ip = gpriv->cx+cxi; - } - */ - } - - // goto to next classification rule for the connection - p = p->next; - } - } - } - } - - return default_ip; -} - -#ifdef MPLS -//--------------------------------------------------------------------------- -// Search the entity with the mpls label and given exp -struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb, - unsigned char exp, - struct nas_priv *gpriv, - int inst, - unsigned char *cx_searcher) { - //--------------------------------------------------------------------------- - unsigned char cxi; - struct cx_entity *default_label=NULL; - struct classifier_entity *p=NULL; - // if (inst >0) - // return(gpriv->cx); //dump to clusterhead -#ifdef NAS_DEBUG_CLASS - printk("[NAS][CLASS][MPLS] Searching for label %d\n",MPLSCB(skb)->label); -#endif - - for (cxi=*cx_searcher; cxicx[cxi].sclassifier[exp]; - - while (p!=NULL) { - if (p->version == NAS_MPLS_VERSION_CODE) { // verify that this is an MPLS rule -#ifdef NAS_DEBUG_CLASS - printk("cx %d : label %d\n",cxi,p->daddr.mpls_label); -#endif //NAS_DEBUG_CLASS - - if (p->daddr.mpls_label==MPLSCB(skb)->label) { -#ifdef NAS_DEBUG_CLASS - printk("found cx %d: label %d, RB %d\n",cxi, - MPLSCB(skb)->label, - p->rab_id); -#endif //NAS_DEBUG_CLASS - return gpriv->cx+cxi; - } - - /* - else if (gpriv->cx[cxi].sclassifier[dscp]->daddr.ipv4==NAS_DEFAULT_IPV4_ADDR) { - #ifdef NAS_DEBUG_CLASS - printk("found default_ip rule\n"); - #endif //NAS_DEBUG_CLASS - default_ip = gpriv->cx+cxi; - } - */ - } - - // goto to next classification rule for the connection - p = p->next; - } - } - - return default_label; -} - -#endif - -//--------------------------------------------------------------------------- -// Search the sending function -void nas_CLASS_send(struct sk_buff *skb,int inst) { - //--------------------------------------------------------------------------- - struct classifier_entity *p, *sp; - uint8_t *protocolh,version; - uint8_t protocol, dscp /*, exp,label*/ ; - uint16_t classref; - struct cx_entity *cx; - //unsigned int i; - //unsigned int router_adv = 0; - struct net_device *dev=nasdev[inst]; - struct nas_priv *gpriv=netdev_priv(dev); - unsigned char cx_searcher,no_connection=1; -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: begin - inst %d\n",inst); -#endif - - if (skb==NULL) { -#ifdef NAS_DEBUG_SEND - printk("NAS_CLASS_SEND - input parameter skb is NULL \n"); -#endif - return; - } - -#ifdef NAS_DEBUG_SEND - printk("[NAS][CLASS][SEND] Got packet from kernel:\n"); - - for (int i=0; i<256; i++) - printk("%2x ",((unsigned char *)skb->data)[i]); - - printk("\n"); -#endif - // find all connections related to socket - cx_searcher = 0; - no_connection = 1; - //while (cx_searcherprotocol)) { - case ETH_P_IPV6: - version = 6; - protocolh=nas_TOOL_get_protocol6( - (struct ipv6hdr *)(skb_network_header(skb)), - &protocol); - dscp=nas_TOOL_get_dscp6( - (struct ipv6hdr *)(skb_network_header(skb)) - ); -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher); -#endif - cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher); -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp); -#endif - break; - - case ETH_P_IP: - dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb))); - cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher); - protocolh=nas_TOOL_get_protocol4( - (struct iphdr *)(skb_network_header(skb)), - &protocol); -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx); -#endif - version = 4; - break; -#ifdef MPLS - - case ETH_P_MPLS_UC: - cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher); -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx); -#endif - dscp = MPLSCB(skb)->exp; - version = NAS_MPLS_VERSION_CODE; - protocol = version; - break; -#endif - - default: - printk("NAS_CLASS_SEND: Unknown protocol\n"); - version = 0; - return; - } - - // If a valid connection for the DSCP/EXP with destination address - // is found scan all protocol-based classification rules - - if (cx) { - classref=0; - sp=NULL; -#ifdef NAS_DEBUG_CLASS - printk("[NAS][CLASSIFIER] DSCP/EXP %d : looking for classifier entry\n",dscp); -#endif - - for (p=cx->sclassifier[dscp]; p!=NULL; p=p->next) { -#ifdef NAS_DEBUG_CLASS - printk("[NAS][CLASSIFIER] DSCP %d p->classref=%d,p->protocol=%d,p->version=%d\n",dscp,p->classref,p->protocol,p->version); -#endif - // Check if transport protocol/message match - /* - if ((p->protocol == protocol)) - if ((protocol == NAS_PROTOCOL_ICMP6) && (version == 6)) - if (p->protocol_message_type == (p->protocol_message_type )) { - printk("[GRAAL][CLASSIFIER] Router advertisement\n"); - } - */ - // normal rule checks that network protocol version matches - - if (p->version == version) { - sp=p; - classref=sp->classref; - break; - } - } - - if (sp!=NULL) { -#ifdef NAS_DEBUG_CLASS - char sfct[10], sprotocol[10]; - - if (sp->fct==nas_COMMON_QOS_send) - strcpy(sfct, "qos"); - - if (sp->fct==nas_CTL_send) - strcpy(sfct, "ctl"); - - if (sp->fct==nas_COMMON_del_send) - strcpy(sfct, "del"); - - if (sp->fct==nas_mesh_DC_send_sig_data_request) - strcpy(sfct, "dc"); - - switch(protocol) { - case NAS_PROTOCOL_UDP: - strcpy(sprotocol, "udp"); - printk("udp packet\n"); - break; - - case NAS_PROTOCOL_TCP: - strcpy(sprotocol, "tcp"); - printk("tcp packet\n"); - break; - - case NAS_PROTOCOL_ICMP4: - strcpy(sprotocol, "icmp4"); - printk("icmp4 packet\n"); - break; - - case NAS_PROTOCOL_ICMP6: - strcpy(sprotocol, "icmp6"); - print_TOOL_pk_icmp6((struct icmp6hdr *)protocolh); - break; -#ifdef MPLS - - case NAS_MPLS_VERSION_CODE: - strcpy(sprotocol,"mpls"); - break; -#endif - } - - printk("NAS_CLASS_SEND: (dscp %u, %s) received, (classref %u, fct %s, rab_id %u) classifier rule\n", - dscp, sprotocol, sp->classref, sfct, sp->rab_id); -#endif - sp->fct(skb, cx, sp,inst, NULL); - } // if classifier entry match found - else { - printk("NAS_CLASS_SEND: no corresponding item in the classifier, so the message is dropped\n"); - // nas_COMMON_del_send(skb, cx, NULL,inst); - } - - no_connection = 0; - } // if connection found - -#ifdef NAS_DEBUG_CLASS - - if (no_connection == 1) - printk("NAS_CLASS_SEND: no corresponding connection, so the message is dropped\n"); - -#endif /* NAS_DEBUG_CLASS */ - // } // while loop over connections -#ifdef NAS_DEBUG_CLASS - printk("NAS_CLASS_SEND: end\n"); -#endif -} diff --git a/openair2/NETWORK_DRIVER/MESH/common.c b/openair2/NETWORK_DRIVER/MESH/common.c deleted file mode 100644 index c04acded3e..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/common.c +++ /dev/null @@ -1,618 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file common.c -* \brief implementation of emultor tx and rx -* \author Navid Nikaein, Lionel GAUTHIER, and Raymomd Knopp -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ - -#include "local.h" -#include "proto_extern.h" - -//#define NAS_DEBUG_RECEIVE 1 -//#define NAS_DEBUG_SEND 1 -//#define NAS_DEBUG_CLASS 1 -//#define NAS_ADDRESS_FIX 1 - -#include - -#include -#include - - -void nas_COMMON_receive(uint16_t dlen, - void *pdcp_sdu, - int inst, - struct classifier_entity *rclass, - nasRadioBearerId_t rb_id) -{ - - //--------------------------------------------------------------------------- - struct sk_buff *skb; - struct ipversion *ipv; - struct nas_priv *gpriv=netdev_priv(nasdev[inst]); - - //int i; - - unsigned char protocol; - - - //struct udphdr *uh; - //struct tcphdr *th; - - struct iphdr *network_header; - -#ifdef NAS_DEBUG_RECEIVE - - printk("NAS_COMMON_RECEIVE: begin RB %d Inst %d Length %d bytes\n",rb_id,inst,dlen); -#endif - skb = dev_alloc_skb( dlen + 2 ); - - if(!skb) { - printk("NAS_COMMON_RECEIVE: low on memory\n"); - ++gpriv->stats.rx_dropped; - return; - } - - skb_reserve(skb,2); - memcpy(skb_put(skb, dlen), pdcp_sdu,dlen); - - skb->dev = nasdev[inst]; - - skb_reset_mac_header(skb); - //printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb->pkt_type,PACKET_HOST,PACKET_BROADCAST); - skb->pkt_type = PACKET_HOST; - - if (rclass->version != NAS_MPLS_VERSION_CODE) { // This is an IP packet - - skb->ip_summed = CHECKSUM_NONE; - - - ipv = (struct ipversion *)skb->data; - - switch (ipv->version) { - case 6: -#ifdef NAS_DEBUG_RECEIVE - printk("NAS_COMMON_RECEIVE: receive IPv6 message\n"); -#endif - - - skb_reset_network_header(skb); - - skb->protocol = htons(ETH_P_IPV6); - // printk("Writing packet with protocol %x\n",ntohs(skb->protocol)); - - break; - - case 4: -#ifdef NAS_ADDRESS_FIX - // Make the third byte of both the source and destination equal to the fourth of the destination - - unsigned char * ifaddr, *saddr, daddr; - uint32_t odaddr = 0, osaddr; - daddr = (unsigned char *)&((struct iphdr *)skb->data)->daddr; - odaddr = ((struct iphdr *)skb->data)->daddr; - //sn = addr[3]; - saddr = (unsigned char *)&((struct iphdr *)skb->data)->saddr; - osaddr = ((struct iphdr *)skb->data)->saddr; - - if (daddr[0] == saddr[0]) {// same network - daddr[2] = daddr[3]; // set third byte of destination to that of local machine so that local IP stack accepts the packet - saddr[2] = daddr[3]; // set third byte of source to that of local machine so that local IP stack accepts the packet - } else { // get the 3rd byte from device address in net_device structure - ifaddr = (unsigned char *)(&(((struct in_device *)((nasdev[inst])->ip_ptr))->ifa_list->ifa_local)); - - if (saddr[0] == ifaddr[0]) { // source is in same network as local machine - daddr[0] += saddr[3]; // fix address of remote destination to undo change at source - saddr[2] = ifaddr[2]; // set third byte to that of local machine so that local IP stack accepts the packet - } else { // source is remote machine from outside network - saddr[0] -= daddr[3]; // fix address of remote source to be understood by destination - daddr[2] = daddr[3]; // fix 3rd byte of local address to be understood by IP stack of - // destination - } - } - -#endif //NAS_ADDRESS_FIX -#ifdef NAS_DEBUG_RECEIVE - // printk("NAS_TOOL_RECEIVE: receive IPv4 message\n"); - addr = (unsigned char *)&((struct iphdr *)skb->data)->saddr; - - if (addr) { - // addr[2]^=0x01; - printk("[NAS][COMMON][RECEIVE] Source %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - addr = (unsigned char *)&((struct iphdr *)skb->data)->daddr; - - if (addr) { - // addr[2]^=0x01; - printk("[NAS][COMMON][RECEIVE] Dest %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - printk("[NAS][COMMON][RECEIVE] protocol %d\n",((struct iphdr *)skb->data)->protocol); - -#endif - - skb_reset_network_header(skb); - network_header = (struct iphdr *)skb_network_header(skb); - protocol = network_header->protocol; - -#ifdef NAS_DEBUG_RECEIVE - - switch (protocol) { - case IPPROTO_IP: - printk("[NAS][COMMON][RECEIVE] Received Raw IPv4 packet\n"); - break; - - case IPPROTO_IPV6: - printk("[NAS][COMMON][RECEIVE] Received Raw IPv6 packet\n"); - break; - - case IPPROTO_ICMP: - printk("[NAS][COMMON][RECEIVE] Received Raw ICMP packet\n"); - break; - - case IPPROTO_TCP: - printk("[NAS][COMMON][RECEIVE] Received TCP packet\n"); - break; - - case IPPROTO_UDP: - printk("[NAS][COMMON][RECEIVE] Received UDP packet\n"); - break; - - default: - break; - } - -#endif - -#ifdef NAS_ADDRESS_FIX - -#ifdef NAS_DEBUG_RECEIVE - printk("NAS_COMMON_RECEIVE: dumping the packet before the csum recalculation (len %d)\n",skb->len); - - for (i=0; ilen; i++) - printk("%2x ",((unsigned char *)(skb->data))[i]); - - printk("\n"); -#endif //NAS_DEBUG_RECEIVE - - - network_header->check = 0; - network_header->check = ip_fast_csum((unsigned char *) network_header, - network_header->ihl); -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON][RECEIVE] IP Fast Checksum %x \n", network_header->check); -#endif - - // if (!(skb->nh.iph->frag_off & htons(IP_OFFSET))) { - - - - - switch(protocol) { - - case IPPROTO_TCP: - - uint16_t *cksum,check; - cksum = (uint16_t*)&(((struct tcphdr*)(((char *)network_header + (network_header->ihl<<2))))->check); - //check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum)); - -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON] Inst %d TCP packet calculated CS %x, CS = %x (before), SA (%x)%x, DA (%x)%x\n", - inst, - network_header->check, - *cksum, - osaddr, - ((struct iphdr *)skb->data)->saddr, - odaddr, - ((struct iphdr *)skb->data)->daddr); -#endif - check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr,0,0, ~(*cksum)); - *cksum = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check); - -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON] Inst %d TCP packet NEW CS %x\n", - inst, - *cksum); -#endif - break; - - case IPPROTO_UDP: - - cksum = (uint16_t*)&(((struct udphdr*)(((char *)network_header + (network_header->ihl<<2))))->check); - // check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum)); -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON] Inst %d UDP packet CS = %x (before), SA (%x)%x, DA (%x)%x\n", - inst, - *cksum, - osaddr, - ((struct iphdr *)skb->data)->saddr, - odaddr, - ((struct iphdr *)skb->data)->daddr); -#endif - check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr, 0,0, ~(*cksum)); - *cksum= csum_tcpudp_magic(~osaddr, ~odaddr,0,0, ~check); - //*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,udp_hdr(skb)->len, IPPROTO_UDP, ~check); - -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON] Inst %d UDP packet NEW CS %x\n", - inst, - *cksum); -#endif - // if ((check = *cksum) != 0) { - // src, dst, len, proto, sum - - - // } - - break; - - default: - break; - } - - // } - -#endif //NAS_ADDRESS_FIX - - skb->protocol = htons(ETH_P_IP); - // printk("[NAS][COMMON] Writing packet with protocol %x\n",ntohs(skb->protocol)); - break; - - default: - printk("NAS_COMMON_RECEIVE: begin RB %d Inst %d Length %d bytes\n",rb_id,inst,dlen); - - printk("[NAS][COMMON] Inst %d: receive unknown message (version=%d)\n",inst,ipv->version); - - } - } else { // This is an MPLS packet - -#ifdef NAS_DEBUG_RECEIVE - printk("NAS_COMMON_RECEIVE: Received an MPLS packet on RB %d\n",rb_id); -#endif - skb->protocol = htons(ETH_P_MPLS_UC); - - } - - ++gpriv->stats.rx_packets; - gpriv->stats.rx_bytes += dlen; -#ifdef NAS_DEBUG_RECEIVE - printk("NAS_COMMON_RECEIVE: sending packet of size %d to kernel\n",skb->len); - - for (i=0; ilen; i++) - printk("%2x ",((unsigned char *)(skb->data))[i]); - - printk("\n"); -#endif //NAS_DEBUG_RECEIVE - netif_rx_ni(skb); -#ifdef NAS_DEBUG_RECEIVE - printk("NAS_COMMON_RECEIVE: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete the data -void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *sp,int inst,struct nas_priv *gpriv) -{ - struct nas_priv *priv=netdev_priv(nasdev[inst]); - //--------------------------------------------------------------------------- - ++priv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) - -void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst, struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct pdcp_data_req_header_s pdcph; - struct nas_priv *priv=netdev_priv(nasdev[inst]); -#ifdef LOOPBACK_TEST - int i; -#endif - unsigned int bytes_wrote; - //unsigned char j; - // Start debug information -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND - inst %d begin \n",inst); -#endif - - // if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR - // { - // priv->stats.tx_dropped ++; - // printk("NAS_QOS_SEND: No connected, so message are dropped \n"); - // return; - // } - if (skb==NULL) { -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND - input parameter skb is NULL \n"); -#endif - return; - } - - if (gc==NULL) { -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND - input parameter gc is NULL \n"); -#endif - return; - } - - if (cx==NULL) { -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND - input parameter cx is NULL \n"); -#endif - return; - } - - // End debug information - if (gc->rb==NULL) { - gc->rb=nas_COMMON_search_rb(cx, gc->rab_id); - - if (gc->rb==NULL) { - ++priv->stats.tx_dropped; - printk("NAS_COMMON_QOS_SEND: No corresponding Radio Bearer, so message are dropped, rab_id=%u \n", gc->rab_id); - return; - } - } - -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND #1 :"); - printk("lcr %u, rab_id %u, rab_id %u, skb_len %d\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id,skb->len); - nas_print_classifier(gc); -#endif - pdcph.data_size = skb->len; - pdcph.rb_id = (gc->rb)->rab_id; - pdcph.inst = inst; - pdcph.sourceL2Id = 0; - pdcph.destinationL2Id = 0; - - bytes_wrote = nas_netlink_send((char *)&pdcph,NAS_PDCPH_SIZE); -#ifdef NAS_DEBUG_SEND - printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", - bytes_wrote,skb->len); -#endif - - if (bytes_wrote != NAS_PDCPH_SIZE) { - printk("NAS_COMMON_QOS_SEND: problem while writing PDCP's header (bytes wrote = %d )\n",bytes_wrote); - printk("rb_id %ld, Wrote %d, Header Size %lu\n", pdcph.rb_id , bytes_wrote, NAS_PDCPH_SIZE); - return; - } - - bytes_wrote += nas_netlink_send((char *)skb->data,skb->len); - - if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { - printk("NAS_COMMON_QOS_SEND: Inst %d, RB_ID %ld: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %lu\n", - inst, - pdcph.rb_id, - bytes_wrote, - skb->len, - NAS_PDCPH_SIZE); // congestion - return; - } - -#ifdef NAS_DEBUG_SEND - printk("NAS_SEND: Sending packet of size %d to PDCP \n",skb->len); - - for (j=0; jlen; j++) - printk("%2x ",((unsigned char *)(skb->data))[j]); - - printk("\n"); -#endif - - priv->stats.tx_bytes += skb->len; - priv->stats.tx_packets ++; -#ifdef NAS_DEBUG_SEND - printk("NAS_COMMON_QOS_SEND - end \n"); -#endif -} - -void nas_COMMON_QOS_receive(struct nlmsghdr *nlh) -{ - - struct pdcp_data_ind_header_s *pdcph = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh); - struct classifier_entity *rclass; - struct nas_priv *priv; - - priv = netdev_priv(nasdev[pdcph->inst]); - - -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON][NETLINK] QOS receive from PDCP, size %d, rab %d, inst %d\n", - pdcph->data_size,pdcph->rb_id,pdcph->inst); -#endif //NAS_DEBUG_RECEIVE - - rclass = nas_COMMON_search_class_for_rb(pdcph->rb_id,priv); - - if (rclass) { -#ifdef NAS_DEBUG_RECEIVE - printk("[NAS][COMMON][NETLINK] Found corresponding connection in classifier for RAB\n"); -#endif //NAS_DEBUG_RECEIVE - - nas_COMMON_receive(pdcph->data_size, - (unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE, - pdcph->inst, - rclass, - pdcph->rb_id); - } - -} - -//--------------------------------------------------------------------------- -struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_SEARCH_CX - lcr %d\n",lcr); -#endif - - if (lcrcx+lcr; - else - return NULL; -} - -//--------------------------------------------------------------------------- -// Search a Radio Bearer -struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_SEARCH_RB - rab_id %d\n", rab_id); -#endif - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { -#ifdef NAS_DEBUG_CLASS - printk("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\n"); - printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.rab_id %u \n", rb->rab_id, rab_id); - //printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.sapi %u \n", rb->sapi); - //printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.qos %u \n", rb->qos); - //printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.state %u \n", rb->state); - //printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.retry %u \n", rb->retry); - //printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.countimer %u \n\n", rb->countimer); -#endif - - if (rb->rab_id==rab_id) - return rb; - } - - return NULL; -} - - // - // Search for a classifier with corresponding radio bearer - - struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv) -{ - - //struct rb_entity *rb; - int dscp; - struct classifier_entity *rclass; - -#ifdef NAS_DEBUG_CLASS - printk("[NAS][COMMON] NAS_COMMON_SEARCH_CLASS_FOR_RB - rab_id %d\n", rab_id); -#endif - - for (dscp=0; dscprclassifier[%d] = %p\n",dscp,priv->rclassifier[dscp]); - for (rclass=priv->rclassifier[dscp]; rclass!=NULL; rclass=rclass->next) { -#ifdef NAS_DEBUG_CLASS - printk("[NAS][COMMON] NAS_COMMON_SEARCH_CLASS_FOR_RB - dscp %d, rb %d\n", dscp,rclass->rab_id); -#endif - - if (rclass->rab_id==rab_id) - return rclass; - } - } - - return NULL; - -} - -//--------------------------------------------------------------------------- -struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasQoSTrafficClass_t qos) -{ - //-------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_ADD_RB - begin for rab_id %d , qos %d\n", rab_id, qos ); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_ADD_RB - input parameter cx is NULL \n"); -#endif - return NULL; - } - - rb=nas_COMMON_search_rb(cx, rab_id); - - if (rb==NULL) { - rb=(struct rb_entity *)kmalloc(sizeof(struct rb_entity), GFP_KERNEL); - - if (rb!=NULL) { - rb->retry=0; - rb->countimer=NAS_TIMER_IDLE; - rb->rab_id=rab_id; - // rb->rab_id=rab_id+(32*cx->lcr); -#ifdef NAS_DEBUG_DC - printk("NAS_COMMON_ADD_RB: rab_id=%u, mt_id=%u\n",rb->rab_id, cx->lcr); -#endif - rb->qos=qos; - rb->sapi=NAS_RAB_INPUT_SAPI; - rb->state=NAS_IDLE; - rb->next=cx->rb; - cx->rb=rb; - ++cx->num_rb; - } else - printk("NAS_ADD_CTL_RB: no memory\n"); - } - -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_ADD_RB - end \n" ); -#endif - return rb; -} - -//--------------------------------------------------------------------------- -void nas_COMMON_flush_rb(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - struct classifier_entity *gc; - uint8_t dscp; - // End debug information -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_FLUSH_RB - begin\n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_FLUSH_RB - input parameter cx is NULL \n"); -#endif - return; - } - - // End debug information - for (rb=cx->rb; rb!=NULL; rb=cx->rb) { - printk("NAS_COMMON_FLUSH_RB: del rab_id %u\n", rb->rab_id); - cx->rb=rb->next; - kfree(rb); - } - - cx->num_rb=0; - cx->rb=NULL; - - for(dscp=0; dscpsclassifier[dscp]; gc!=NULL; gc=gc->next) - gc->rb=NULL; - } - -#ifdef NAS_DEBUG_CLASS - printk("NAS_COMMON_FLUSH_RB - end\n"); -#endif -} diff --git a/openair2/NETWORK_DRIVER/MESH/constant.h b/openair2/NETWORK_DRIVER/MESH/constant.h deleted file mode 100644 index 5347c5a784..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/constant.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef _NAS_CST -#define _NAS_CST - -#define MAX_MEASURE_NB 5 -#define NAS_MAX_LENGTH 180 - -//Debug flags -//#define NAS_DEBUG_DC -//#define NAS_DEBUG_SEND -//#define NAS_DEBUG_RECEIVE -//#define NAS_DEBUG_CLASS -//#define NAS_DEBUG_GC -//#define NAS_DEBUG_DC_MEASURE -//#define NAS_DEBUG_TIMER -//#define NAS_DEBUG_DEVICE -//#define NAS_DEBUG_INTERRUPT -//#define NAS_DEBUG_TOOL - -// Other flags -#define DEMO_3GSM - -// General Constants -#define NAS_MTU 1500 -#define NAS_TX_QUEUE_LEN 100 -#define NAS_ADDR_LEN 8 -#define NAS_INET6_ADDRSTRLEN 46 -#define NAS_INET_ADDRSTRLEN 16 - -#define NAS_CX_MAX 32 //128 //Identical to RRC constant: no you cannot -/* increase to 128 without risking stack problems: KEEP ATTENTION TO COMPILATION WARNINGS */ -//#define NAS_CX_MULTICAST_ALLNODE 2 - -#define NAS_RETRY_LIMIT_DEFAULT 5 - -#define NAS_MESSAGE_MAXLEN 5004 - -#define NAS_SIG_SRB3 3 -#define NAS_SIG_SRB4 3 // not used yet - -//peer-to-peer messages between NAS entities -#define NAS_CMD_OPEN_RB 1 - -//#define NAS_IID1_CONTROL 0x0 -//#define NAS_IID2_CONTROL __constant_htonl(0xffffffff) - -//#define NAS_STATE_IDLE 0 -//#define NAS_STATE_CONNECTED 1 -//#define NAS_STATE_ESTABLISHMENT_REQUEST 2 -//#define NAS_STATE_ESTABLISHMENT_FAILURE 3 -//#define NAS_STATE_RELEASE_FAILURE 4 -#define NAS_CX_RELEASE_UNDEF_CAUSE 1 - -// MT+RG NAS States -#define NAS_IDLE 0x01 -// Connection -#define NAS_CX_FACH 0x06 -#define NAS_CX_DCH 0x0A -#define NAS_CX_RECEIVED 0x10 -#define NAS_CX_CONNECTING 0x04 -#define NAS_CX_RELEASING 0x08 -#define NAS_CX_CONNECTING_FAILURE 0x14 -#define NAS_CX_RELEASING_FAILURE 0x18 -// Radio Bearers -#define NAS_RB_ESTABLISHING 0x24 -#define NAS_RB_RELEASING 0x28 -#define NAS_RB_DCH 0x2A - - -#define NAS_TIMER_ESTABLISHMENT_DEFAULT 12 -#define NAS_TIMER_RELEASE_DEFAULT 2 -#define NAS_TIMER_IDLE UINT_MAX -#define NAS_TIMER_TICK HZ - -#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_s) -#define NAS_IPV4_SIZE 20 -#define NAS_IPV6_SIZE 40 - -#define NAS_DIRECTION_SEND 0 -#define NAS_DIRECTION_RECEIVE 1 -#define NAS_DIRECTION_FORWARD 2 - -// function number -#define NAS_FCT_DEL_SEND 1 -#define NAS_FCT_QOS_SEND 2 -#define NAS_FCT_DC_SEND 3 -#define NAS_FCT_CTL_SEND 4 - -// type of IOCTL command -#define NAS_IOCTL_RRM 0x89F0 - -// Error cause -#define NAS_ERROR_ALREADYEXIST 1 -#define NAS_ERROR_NOMEMORY 3 -#define NAS_ERROR_NOTMT 9 -#define NAS_ERROR_NOTRG 10 -#define NAS_ERROR_NOTIDLE 11 -#define NAS_ERROR_NOTCONNECTED 12 -#define NAS_ERROR_NORB 14 -#define NAS_ERROR_NOTCORRECTVALUE 32 -#define NAS_ERROR_NOTCORRECTLCR 33 -#define NAS_ERROR_NOTCORRECTDIR 34 -#define NAS_ERROR_NOTCORRECTDSCP 35 -#define NAS_ERROR_NOTCORRECTVERSION 36 -#define NAS_ERROR_NOTCORRECTRABI 37 - - -/**********************************************************/ -/* Constants related with IP protocols */ -/**********************************************************/ - -//#define NAS_PORT_CONTROL __constant_htons(0xc45) -//#define NAS_PORT_AUTHENTICATION __constant_htons(1811) - -#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000) - -// Network control codepoint 111000 + IP version 6 -#define NAS_FLOWINFO_NCONTROL __constant_htonl(0x6e000000) -// network control codepoint 111000 -#define NAS_DSCP_NCONTROL 56 //0x38 -// default codepoint 1000000 -#define NAS_DSCP_DEFAULT 64 -#define NAS_DSCP_MAX 193 - -#define NAS_PROTOCOL_DEFAULT 0 -#define NAS_PROTOCOL_TCP IPPROTO_TCP -#define NAS_PROTOCOL_UDP IPPROTO_UDP -#define NAS_PROTOCOL_ICMP4 IPPROTO_ICMP -#define NAS_PROTOCOL_ICMP6 IPPROTO_ICMPV6 - -#define NAS_PORT_DEFAULT __constant_htons(65535) -#define NAS_PORT_HTTP __constant_htons(80) - -#define NAS_VERSION_DEFAULT 0 -#define NAS_VERSION_4 4 -#define NAS_VERSION_6 0 //?MW - -#define NAS_DEFAULT_IPV4_ADDR 0 -#define NAS_DEFAULT_IPV6_ADDR0 0 -#define NAS_DEFAULT_IPV6_ADDR1 0 -#define NAS_DEFAULT_IPV6_ADDR2 0 -#define NAS_DEFAULT_IPV6_ADDR3 0 - - -#define NAS_MPLS_VERSION_CODE 99 - -#define NB_INSTANCES_MAX 64 //16 - - -#endif - - - diff --git a/openair2/NETWORK_DRIVER/MESH/device.c b/openair2/NETWORK_DRIVER/MESH/device.c deleted file mode 100644 index d86e32e561..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/device.c +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file device.c -* \brief Networking Device Driver for OpenAirInterface MESH -* \author navid.nikaein, yan.moret(no longer valid), michelle.wetterwald, raymond.knopp -* \company Eurecom -* \email: raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, michelle.wetterwald@eurecom.fr, - -*/ -/*******************************************************************************/ - -#include "constant.h" -#include "local.h" -#include "proto_extern.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -//#define DEBUG_DEVICE 1 -//#define DEBUG_INTERRUPT 1 - -struct net_device *nasdev[NB_INSTANCES_MAX]; - -extern void nas_netlink_release(void); -extern int nas_netlink_init(void); - -//int bytes_wrote; -//int bytes_read; -uint8_t NULL_IMEI[14]= {0x05, 0x04, 0x03, 0x01, 0x02 ,0x00, 0x00, 0x00, 0x05, 0x04, 0x03 ,0x00, 0x01, 0x08}; - - -static unsigned int nas_IMEI[6]= {0x03, 0x01, 0x02 ,0x00, 0x00, 0x00}; // may change to char -static int m_arg=0; -static unsigned int nas_is_clusterhead=0; - - -int find_inst(struct net_device *dev) -{ - - int i; - - for (i=0; itimer); - (priv->timer).expires=jiffies+NAS_TIMER_TICK; - (priv->timer).data=0L; - (priv->timer).function=nas_mesh_timer; - // add_timer(&priv->timer); - // - */ - printk("OPEN: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is desactivated -int nas_stop(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct nas_priv *priv = netdev_priv(dev); - printk("STOP: begin\n"); - del_timer(&(priv->timer)); - netif_stop_queue(dev); - // MOD_DEC_USE_COUNT; - printk("STOP: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -void nas_teardown(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - int cxi; - - struct nas_priv *priv; - int inst; - - if (dev) { - priv = netdev_priv(dev); - inst = find_inst(dev); - - if (inst<0) { - printk("nas_teardown: ERROR, couldn't find instance\n"); - } - - printk("nas_teardown instance %d: begin\n",inst); - - - - nas_CLASS_flush_rclassifier(priv); - - for (cxi=0; cxicx+cxi); - nas_CLASS_flush_sclassifier(priv->cx+cxi); - } - - printk("nas_teardown: end\n"); - } // check dev - else { - printk("nas_teardown: Device is null\n"); - } -} - -//--------------------------------------------------------------------------- -int nas_set_config(struct net_device *dev, struct ifmap *map) -{ - //--------------------------------------------------------------------------- - printk("SET_CONFIG: begin\n"); - - if (dev->flags & IFF_UP) - return -EBUSY; - - if (map->base_addr != dev->base_addr) { - printk(KERN_WARNING "SET_CONFIG: Can't change I/O address\n"); - return -EOPNOTSUPP; - } - - if (map->irq != dev->irq) - dev->irq = map->irq; - - return 0; -} - -//--------------------------------------------------------------------------- -// -int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // Start debug information - - int inst; - - if (dev) - inst = find_inst(dev); - else { - printk("nas_hard_start_xmit: ERROR, device is null\n"); - return -1; - } - - if (inst>=0) { -#ifdef DEBUG_DEVICE - printk("HARD_START_XMIT: inst %d, begin\n",inst); -#endif - - if (!skb) { - printk("HARD_START_XMIT - input parameter skb is NULL \n"); - return -1; - } - - // End debug information - netif_stop_queue(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif -#ifdef DEBUG_DEVICE - printk("HARD_START_XMIT: step 1\n"); -#endif - nas_CLASS_send(skb,inst); -#ifdef DEBUG_DEVICE - printk("HARD_START_XMIT: step 2\n"); -#endif - // if (skb==NULL){ - // printk("HARD_START_XMIT - parameter skb is NULL \n"); - // return -1; - // }else - dev_kfree_skb(skb); -#ifdef DEBUG_DEVICE - printk("HARD_START_XMIT: step 3\n"); -#endif - netif_wake_queue(dev); -#ifdef DEBUG_DEVICE - printk("HARD_START_XMIT: end\n"); -#endif - } else { - printk("nas_hard_start_xmit: ERROR, couldn't find instnace\n"); - return(-1); - } - - return 0; -} - -//--------------------------------------------------------------------------- -struct net_device_stats *nas_get_stats(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // return &((struct nas_priv *)dev->priv)->stats; - struct nas_priv *priv = netdev_priv(dev); - return &priv->stats; -} - -//--------------------------------------------------------------------------- -int nas_change_mtu(struct net_device *dev, int mtu) -{ - //--------------------------------------------------------------------------- - - printk("CHANGE_MTU: begin\n"); - - if ((mtu<50) || (mtu>1500)) - return -EINVAL; - - dev->mtu = mtu; - return 0; -} - -//--------------------------------------------------------------------------- -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) -void nas_tx_timeout(struct net_device *dev, unsigned int txqueue) -#else -void nas_tx_timeout(struct net_device *dev) -#endif -{ - //--------------------------------------------------------------------------- - // Transmitter timeout, serious problems. - struct nas_priv *priv = netdev_priv(dev); - - printk("TX_TIMEOUT: begin\n"); - // (struct nas_priv *)(dev->priv)->stats.tx_errors++; - (priv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif - netif_wake_queue(dev); - printk("TX_TIMEOUT: transmit timed out %s\n",dev->name); -} - -static const struct net_device_ops nasmesh_netdev_ops = { - - .ndo_open = nas_open, - .ndo_stop = nas_stop, - .ndo_start_xmit = nas_hard_start_xmit, - .ndo_validate_addr = NULL, - .ndo_set_mac_address = NULL, - .ndo_set_config = nas_set_config, - .ndo_do_ioctl = nas_CTL_ioctl, -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1797 && RHEL_RELEASE_CODE != 2403) - .extended.ndo_change_mtu = nas_change_mtu, -#else - .ndo_change_mtu = nas_change_mtu, -#endif - .ndo_tx_timeout = nas_tx_timeout, -}; - -//--------------------------------------------------------------------------- -// Initialisation of the network device -void nas_init(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - uint8_t cxi, dscpi; - struct nas_priv *priv; - // int inst; - - if (dev) { - priv = netdev_priv(dev); - //memset(dev->priv, 0, sizeof(struct nas_priv)); - memset(priv, 0, sizeof(struct nas_priv)); - // priv=(struct nas_priv *)(dev->priv); - priv=netdev_priv(dev); - // - dev->netdev_ops = &nasmesh_netdev_ops; - // dev->type = ARPHRD_EUROPENAIRMESH; - //dev->type = ARPHRD_ETHER; - // dev->features = NETIF_F_NO_CSUM; - dev->hard_header_len = 0; - dev->addr_len = NAS_ADDR_LEN; - dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; - dev->tx_queue_len = NAS_TX_QUEUE_LEN; - dev->mtu = NAS_MTU; - // - // Initialize private structure - // priv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC; - // priv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT; - priv->sap[NAS_RAB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; - priv->sap[NAS_RAB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; - - // priv->retry_limit=RETRY_LIMIT_DEFAULT; - // priv->timer_establishment=TIMER_ESTABLISHMENT_DEFAULT; - // priv->timer_release=TIMER_RELEASE_DEFAULT; - - for (dscpi=0; dscpi<65; ++dscpi) - priv->rclassifier[dscpi]=NULL; - - priv->nrclassifier=0; - - // - for (cxi=0; cxicx[cxi].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0; - // priv->cx[cxi].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0; - priv->cx[cxi].state=NAS_IDLE; - priv->cx[cxi].countimer=NAS_TIMER_IDLE; - priv->cx[cxi].retry=0; - priv->cx[cxi].lcr=cxi; - priv->cx[cxi].rb=NULL; - priv->cx[cxi].num_rb=0; - - // initialisation of the classifier - for (dscpi=0; dscpi<65; ++dscpi) { - priv->cx[cxi].sclassifier[dscpi]=NULL; - priv->cx[cxi].fclassifier[dscpi]=NULL; - } - - priv->cx[cxi].nsclassifier=0; - priv->cx[cxi].nfclassifier=0; - // initialisation of the IP address - // TOOL_imei2iid(IMEI, (uint8_t *)priv->cx[cxi].iid6); - priv->cx[cxi].iid4=0; - // - } - - spin_lock_init(&priv->lock); - //this requires kernel patch for OAI driver: typically for RF/hard realtime emu experimentation -#ifdef ADDRCONF -#ifdef NETLINK - nas_TOOL_imei2iid(IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) - nas_TOOL_imei2iid(IMEI, (uint8_t *)priv->cx[0].iid6); -#else - nas_TOOL_imei2iid((uint8_t *)nas_IMEI, dev->dev_addr); // IMEI to device address (for stateless autoconfiguration address) - nas_TOOL_imei2iid((uint8_t *)nas_IMEI, (uint8_t *)priv->cx[0].iid6); -#endif - // this is more appropriate for user space soft realtime emulation -#else - memcpy(dev->dev_addr,&nas_IMEI[0],8); - printk("Setting HW addr to : %X%X\n",*((unsigned int *)&dev->dev_addr[0]),*((unsigned int *)&dev->dev_addr[4])); - - ((unsigned char*)dev->dev_addr)[7] = (unsigned char)find_inst(dev); - - memcpy((uint8_t *)priv->cx[0].iid6,&nas_IMEI[0],8); - - printk("INIT: init IMEI to IID\n"); -#endif - - printk("INIT: end\n"); - return; - } // instance value check - else { - printk("nas_init(): ERROR, Device is NULL!!\n"); - return; - } -} -//--------------------------------------------------------------------------- -int init_module (void) -{ - //--------------------------------------------------------------------------- - int err,inst; - struct nas_priv *priv; - char devicename[100]; - - - // Initialize parameters shared with RRC - - printk("Starting NASMESH, number of IMEI paramters %d, IMEI %X%X\n",m_arg,nas_IMEI[0],nas_IMEI[1]); - - for (inst=0; instdev_addr,&nas_IMEI[0],8); - nas_TOOL_imei2iid((uint8_t *)nas_IMEI, nasdev[inst]->dev_addr);// IMEI to device address (for stateless autoconfiguration address) - nas_TOOL_imei2iid((uint8_t *)nas_IMEI, (uint8_t *)priv->cx[0].iid6); - // TO HAVE DIFFERENT HW @ - ((unsigned char*)nasdev[inst]->dev_addr)[7] = ((unsigned char*)nasdev[inst]->dev_addr)[7] + (unsigned char)inst + 1; - printk("Setting HW addr for INST %d to : %X%X\n",inst,*((unsigned int *)&nasdev[inst]->dev_addr[0]),*((unsigned int *)&nasdev[inst]->dev_addr[4])); - - } - - - - err= register_netdev(nasdev[inst]); - - if (err) { - printk("[NAS][INIT] nasmesh_init_module (inst %d): error %i registering device %s\n", inst,err, nasdev[inst]->name); - } else { - printk("nasmesh_init_module: registering device %s, ifindex = %d\n\n",nasdev[inst]->name, nasdev[inst]->ifindex); - } - } - - if ((err=nas_netlink_init()) == -1) - printk("[NAS][INIT] NETLINK failed\n"); - - printk("[NAS][INIT] NETLINK INIT\n"); - - return err; - -} - -//--------------------------------------------------------------------------- -void cleanup_module(void) -{ - //--------------------------------------------------------------------------- - - int inst; - - - printk("[NAS][CLEANUP]nasmesh_cleanup_module: begin\n"); - - for (inst=0; inst= KERNEL_VERSION(3,2,0) - -#define DRV_NAME "NASMESH" -#define DRV_VERSION "3.0.2"DRV_NAME -#define DRV_DESCRIPTION "OPENAIR MESH Device Driver" -#define DRV_COPYRIGHT "-Copyright(c) GNU GPL Eurecom 2009" -#define DRV_AUTHOR "Raymond Knopp, and Navid Nikaein: "DRV_COPYRIGHT - -module_param_array(nas_IMEI,uint,&m_arg,0444); -MODULE_PARM_DESC(nas_IMEI,"The IMEI Hardware address (64-bit, decimal nibbles)"); - -module_param(nas_is_clusterhead,uint,0444); -MODULE_PARM_DESC(nas_is_clusterhead,"The Clusterhead Indicator"); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,1) -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_AUTHOR(DRV_AUTHOR); -#endif -#endif - - - -/* -//--------------------------------------------------------------------------- -//module_init(init_nasmesh); -//module_exit(exit_nasmesh); -//--------------------------------------------------------------------------- - -*/ diff --git a/openair2/NETWORK_DRIVER/MESH/ioctl.c b/openair2/NETWORK_DRIVER/MESH/ioctl.c deleted file mode 100644 index 56dfb1cfe8..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/ioctl.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "local.h" -#include "ioctl.h" -#include "proto_extern.h" - -//#include -#include -#include -#include - - -// Statistic -//--------------------------------------------------------------------------- -void nas_set_msg_statistic_reply(struct nas_msg_statistic_reply *msgrep, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - msgrep->rx_packets=priv->stats.rx_packets; - msgrep->tx_packets=priv->stats.tx_packets; - msgrep->rx_bytes=priv->stats.rx_bytes; - msgrep->tx_bytes=priv->stats.tx_bytes; - msgrep->rx_errors=priv->stats.rx_errors; - msgrep->tx_errors=priv->stats.tx_errors; - msgrep->rx_dropped=priv->stats.rx_dropped; - msgrep->tx_dropped=priv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_statistic_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_statistic_reply msgrep; - printk("NAS_IOCTL_STATISTIC: stat requested\n"); - nas_set_msg_statistic_reply(&msgrep,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_STATISTIC: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connections List -//--------------------------------------------------------------------------- -void nas_set_msg_cx_list_reply(uint8_t *msgrep, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - nasLocalConnectionRef_t lcr; - struct nas_msg_cx_list_reply *list; - msgrep[0]=NAS_CX_MAX; - list=(struct nas_msg_cx_list_reply *)(msgrep+1); - - for(lcr=0; lcrstate; - list[lcr].cellid=cx->cellid; - list[lcr].iid4=cx->iid4; - list[lcr].iid6[0]=cx->iid6[0]; - list[lcr].iid6[1]=cx->iid6[1]; - list[lcr].num_rb=cx->num_rb; - list[lcr].nsclassifier=cx->nsclassifier; - printk("NAS_SET_MSG_CX_LIST_REPLY: nsc=%u\n",cx->nsclassifier); - } -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_cx_list_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1]; - printk("NAS_IOCTL_CX_LIST: connection list requested\n"); - nas_set_msg_cx_list_reply(msgrep,priv); - - if (copy_to_user(gifr->msg, msgrep, NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1)) { - printk("NAS_IOCTL_CX_LIST: copy_to_user failure\n"); - return -EFAULT; - } - - printk("NAS_IOCTL_CX_LIST: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Establishment -//--------------------------------------------------------------------------- -void nas_set_msg_cx_establishment_reply(struct nas_msg_cx_establishment_reply *msgrep, - struct nas_msg_cx_establishment_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx!=NULL) { - cx->cellid=msgreq->cellid; - msgrep->status=nas_mesh_DC_send_cx_establish_request(cx,priv); - } else - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - -} -//--------------------------------------------------------------------------- -int nas_ioCTL_cx_establishment_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_establishment_request msgreq; - struct nas_msg_cx_establishment_reply msgrep; - printk("NAS_IOCTL_ESTABLISHMENT: connection establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_CX_ESTABLISHMENT: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_cx_establishment_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_CX_ESTABLISHMENT: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Release -//--------------------------------------------------------------------------- -void nas_set_msg_cx_release_reply(struct nas_msg_cx_release_reply *msgrep, - struct nas_msg_cx_release_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx!=NULL) - msgrep->status=nas_mesh_DC_send_cx_release_request(cx,priv); - else - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; -} - -//--------------------------------------------------------------------------- -// Request the release of a connection -int nas_ioCTL_cx_release_request(struct nas_ioctl *gifr,struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_release_request msgreq; - struct nas_msg_cx_release_reply msgrep; - - printk("NAS_IOCTL_CX_RELEASE: connection release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_CX_RELEASE: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_cx_release_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_CX_RELEASE: copy_to_user failure\n"); - return -EFAULT; - } - - printk("NAS_IOCTL_CX_RELEASE: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer List -//--------------------------------------------------------------------------- -void nas_set_msg_rb_list_reply(uint8_t *msgrep, - struct nas_msg_rb_list_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx!=NULL) { - uint8_t rbi; - struct rb_entity *rb; - struct nas_msg_rb_list_reply *list; - - if (cx->num_rb > NAS_LIST_RB_MAX) - msgrep[0] = NAS_LIST_RB_MAX; - else - msgrep[0] = cx->num_rb; - - list=(struct nas_msg_rb_list_reply *)(msgrep+1); - - for (rb=cx->rb, rbi=0; (rb!=NULL)&&(rbinext, ++rbi) { - list[rbi].state=rb->state; - list[rbi].rab_id=rb->rab_id; - list[rbi].sapi=rb->sapi; - list[rbi].qos=rb->qos; - } - } else - msgrep[0]=0; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_rb_list_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1]; - struct nas_msg_rb_list_request msgreq; - printk("NAS_IOCTL_RB_LIST: Radio Bearer list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_RB_LIST: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_rb_list_reply(msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1)) { - printk("NAS_IOCTL_RB_LIST: copy_to_user failure\n"); - return -EFAULT; - } - - printk("NAS_IOCTL_CX_LIST: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Establishment -//--------------------------------------------------------------------------- -void nas_set_msg_rb_establishment_reply(struct nas_msg_rb_establishment_reply *msgrep, - struct nas_msg_rb_establishment_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - // if ((msgreq->rab_id<3)||(msgreq->rab_id>127)) - if ((msgreq->rab_id<1)||(msgreq->rab_id>MAX_RABS)) // navid : increase the number - msgrep->status=-NAS_ERROR_NOTCORRECTRABI; - else { - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx==NULL) - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - else { - struct rb_entity *rb; - rb=nas_COMMON_add_rb(cx, msgreq->rab_id, msgreq->qos); - - if (rb!=NULL) { - // rb->cnxid = msgreq->cnxid; - // msgrep->status=nas_rg_DC_send_rb_establish_request(cx, rb); - } else - msgrep->status=-NAS_ERROR_NOMEMORY; - - // msgrep->cnxid = msgreq->cnxid; - } - } -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_rb_establishment_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_establishment_request msgreq; - struct nas_msg_rb_establishment_reply msgrep; - printk("NAS_IOCTL_RB_ESTABLISHMENT: Radio bearer establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_RB_ESTABLISHMENT: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_rb_establishment_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_RB_ESTABLISHMENT: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Release -//--------------------------------------------------------------------------- -void nas_set_msg_rb_release_reply(struct nas_msg_rb_release_reply *msgrep, - struct nas_msg_rb_release_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - if (msgreq->lcrlcr,priv); - rb=nas_COMMON_search_rb(cx, msgreq->rab_id); - - if (rb!=NULL) { - //msgrep->status=nas_rg_DC_send_rb_release_request(cx, rb); - } else - msgrep->status=-NAS_ERROR_NOTCONNECTED; - - // msgrep->cnxid = msgreq->cnxid; - } else - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_rb_release_request( - struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_release_request msgreq; - struct nas_msg_rb_release_reply msgrep; - printk("NAS_IOCTL_RB_RELEASE: Radio bearer release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_RB_RELEASE: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_rb_release_reply(&msgrep, &msgreq, priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_RB_RELEASE: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Classifier List -//--------------------------------------------------------------------------- -void nas_set_msg_class_list_reply( - uint8_t *msgrep, - struct nas_msg_class_list_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - struct classifier_entity *gc; - struct nas_msg_class_list_reply *list; - uint8_t cli; - list=(struct nas_msg_class_list_reply *)(msgrep+1); - - switch(msgreq->dir) { - case NAS_DIRECTION_SEND: - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx==NULL) { - msgrep[0]=0; - return; - } - - gc=cx->sclassifier[msgreq->dscp]; - break; - - case NAS_DIRECTION_RECEIVE: - cx=NULL; - gc=priv->rclassifier[msgreq->dscp]; - break; - - default: - cx=NULL; - msgrep[0]=0; - return; - } - - for (cli=0; (gc!=NULL)&&(clinext, ++cli) { - list[cli].classref=gc->classref; - list[cli].lcr=msgreq->lcr; - list[cli].dir=msgreq->dir; - list[cli].dscp=msgreq->dscp; - list[cli].rab_id=gc->rab_id; - list[cli].version=gc->version; - - switch(gc->version) { - case 4: - list[cli].saddr.ipv4 = gc->saddr.ipv4; - list[cli].daddr.ipv4 = gc->daddr.ipv4; - break; - - case 6: - list[cli].saddr.ipv6 = gc->saddr.ipv6; - list[cli].daddr.ipv6 = gc->daddr.ipv6; - break; - } - - list[cli].protocol=gc->protocol; - list[cli].sport=ntohs(gc->sport); - list[cli].dport=ntohs(gc->dport); - list[cli].splen=gc->splen; - list[cli].dplen=gc->dplen; - list[cli].fct=nas_TOOL_invfct(gc); - } - - msgrep[0]=cli; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_class_list_request( - struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1]; - struct nas_msg_class_list_request msgreq; - printk("NAS_IOCTL_CLASS_LIST: classifier list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_CLASS_LIST: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_class_list_reply(msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1)) { - printk("NAS_IOCTL_CLASS_LIST: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the addition of a classifier rule -//--------------------------------------------------------------------------- -void nas_set_msg_class_add_reply( - struct nas_msg_class_add_reply *msgrep, - struct nas_msg_class_add_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc,*gc2; - unsigned char *saddr,*daddr; - unsigned int *saddr32,*daddr32; - - printk("[NAS][CLASS] nas_set_msg_class_add_reply\n"); - - - if (msgreq->dscp>NAS_DSCP_MAX) { - printk("NAS_SET_MSG_CLASS_ADD_REPLY: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - - - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx!=NULL) { - printk("NAS_SET_MSG_CLASS_ADD_REPLY: DSCP/EXP %d, Classref %d, RB %u\n", msgreq->dscp, msgreq->classref,msgreq->rab_id ); - gc=nas_CLASS_add_sclassifier(cx, msgreq->dscp, msgreq->classref); - - printk("NAS_SET_MSG_CLASS_ADD_REPLY: %p %p\n" , msgreq, gc); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - - gc->rab_id=msgreq->rab_id; - - gc->rb=nas_COMMON_search_rb(cx, gc->rab_id); - printk("NAS_SET_MSG_CLASS_ADD_REPLY: gc_rb %p %u \n", gc->rb, gc->rab_id); - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) { - gc=nas_CLASS_add_rclassifier(msgreq->dscp, - msgreq->classref, - priv); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - - gc->rab_id=msgreq->rab_id; - - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - - for (gc2 = priv->rclassifier[msgreq->dscp]; gc2!=NULL ; gc2 = gc2->next) - printk("[NAS][CLASS] Add Receive Classifier dscp %d: rab_id %d (%p,next %p)\n",msgreq->dscp,gc2->rab_id,gc2,gc2->next); - } - - printk("[NAS][CLASS] Getting addresses ...\n"); - - nas_TOOL_fct(gc, msgreq->fct); - gc->version=msgreq->version; - - switch(gc->version) { - case 4: - gc->saddr.ipv4=msgreq->saddr.ipv4; - gc->daddr.ipv4=msgreq->daddr.ipv4; - - - - // #ifdef NAS_CLASS_DEBUG - saddr = (unsigned char *)&gc->saddr.ipv4; - daddr = (unsigned char *)&gc->daddr.ipv4; - - printk("[NAS][CLASS] Adding IPv4 %d.%d.%d.%d -> %d.%d.%d.%d\n", - saddr[0],saddr[1],saddr[2],saddr[3], - daddr[0],daddr[1],daddr[2],daddr[3]); - - - - //#endif - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case 6: - memcpy(&gc->saddr.ipv6,&msgreq->saddr.ipv6,16); - memcpy(&gc->daddr.ipv6,&msgreq->daddr.ipv6,16); - - saddr32 = (unsigned int *)&gc->saddr.ipv6; - daddr32 = (unsigned int *)&gc->daddr.ipv6; - - printk("[NAS][CLASS] Adding IPv6 %X:%X:%X:%X -> %X.%X.%X.%X\n", - saddr32[0],saddr32[1],saddr32[2],saddr32[3], - daddr32[0],daddr32[1],daddr32[2],daddr32[3]); - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case NAS_MPLS_VERSION_CODE: - - printk("[NAS][CLASS] Adding MPLS label %d with exp %d\n", - msgreq->daddr.mpls_label,msgreq->dscp); - gc->daddr.mpls_label = msgreq->daddr.mpls_label; - - break; - - case 0: - gc->saddr.ipv6.s6_addr32[0]=0; - gc->daddr.ipv6.s6_addr32[1]=0; - gc->saddr.ipv6.s6_addr32[2]=0; - gc->daddr.ipv6.s6_addr32[3]=0; - gc->splen=0; - gc->dplen=0; - break; - - default: - msgrep->status=-NAS_ERROR_NOTCORRECTVERSION; - kfree(gc); - return; - } - - gc->protocol=msgreq->protocol; - gc->protocol_message_type=msgreq->protocol_message_type; - gc->sport=htons(msgreq->sport); - gc->dport=htons(msgreq->dport); - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_class_add_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_add_request msgreq; - struct nas_msg_class_add_reply msgrep; - - - printk("NAS_IOCTL_CLASS_ADD: Add classifier components requested\n"); - printk("NAS_IOCTL_CLASS_ADD: size of gifr msg %zd\n", sizeof(gifr->msg)); - - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_CLASS_ADD: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_class_add_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_CLASS_ADD: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the deletion of a classifier rule -//--------------------------------------------------------------------------- -void nas_set_msg_class_del_reply(struct nas_msg_class_del_reply *msgrep, - struct nas_msg_class_del_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - if (msgreq->dscp>NAS_DSCP_DEFAULT) { - printk("NAS_SET_MSG_CLASS_DEL_REPLY: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - struct cx_entity *cx; - cx=nas_COMMON_search_cx(msgreq->lcr,priv); - - if (cx!=NULL) - nas_CLASS_del_sclassifier(cx, msgreq->dscp, msgreq->classref); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) - nas_CLASS_del_rclassifier(msgreq->dscp, msgreq->classref,priv); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - } - - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nas_ioCTL_class_del_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_del_request msgreq; - struct nas_msg_class_del_reply msgrep; - printk("NAS_IOCTL_CLASS_DEL: Del classifier components requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_CLASS_DEL: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_class_del_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_CLASS_DEL: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Measurement -// Messages for Measurement transfer - -//--------------------------------------------------------------------------- -void nas_set_msg_measure_reply(struct nas_msg_measure_reply *msgrep, struct nas_msg_measure_request *msgreq, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - int lcr=0; // Temp lcr->mt =0 - int i; - - cx=nas_COMMON_search_cx(lcr,priv); - - if (cx!=NULL) { - msgrep->num_cells = cx->num_measures; - - for (i=0; inum_measures; i++) { - msgrep-> measures[i].cell_id = cx->meas_cell_id[i]; - msgrep-> measures[i].level = cx->meas_level[i]; - msgrep-> measures[i].provider_id = cx->provider_id[i]; - } - - msgrep->signal_lost_flag = 0; - } -} -//--------------------------------------------------------------------------- -int nas_ioCTL_measure_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_measure_request msgreq; - struct nas_msg_measure_reply msgrep; - printk("NAS_IOCTL_MEASURE: Measurement requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("NAS_IOCTL_MEASURE: copy_from_user failure\n"); - return -EFAULT; - } - - nas_set_msg_measure_reply(&msgrep, &msgreq,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_MEASURE: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// IMEI -// Messages for IMEI transfer -//--------------------------------------------------------------------------- -void nas_set_msg_imei_reply(struct nas_msg_l2id_reply *msgrep, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - int lcr=0; // Temp lcr->mt =0 - - cx=nas_COMMON_search_cx(lcr,priv); - - if (cx!=NULL) { - msgrep->l2id[0] = cx->iid6[0]; - msgrep->l2id[1] = cx->iid6[1]; - } -} -//--------------------------------------------------------------------------- -int nas_ioCTL_imei_request(struct nas_ioctl *gifr, - struct nas_priv *priv) -{ - //--------------------------------------------------------------------------- - struct nas_msg_l2id_reply msgrep; - printk("NAS_IOCTL_IMEI: IMEI requested\n"); - nas_set_msg_imei_reply(&msgrep,priv); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("NAS_IOCTL_IMEI: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IOCTL command -//--------------------------------------------------------------------------- -int nas_CTL_ioctl(struct net_device *dev, - struct ifreq *ifr, - int cmd) -{ - //--------------------------------------------------------------------------- - struct nas_ioctl *gifr; - struct nas_priv *priv=netdev_priv(dev); - - int r; - - // printk("NAS_CTL_IOCTL: begin ioctl for instance %d\n",find_inst(dev)); - - switch(cmd) { - case NAS_IOCTL_RRM: - gifr=(struct nas_ioctl *)ifr; - - switch(gifr->type) { - case NAS_MSG_STATISTIC_REQUEST: - r=nas_ioCTL_statistic_request(gifr,priv); - break; - - case NAS_MSG_CX_ESTABLISHMENT_REQUEST: - r=nas_ioCTL_cx_establishment_request(gifr,priv); - break; - - case NAS_MSG_CX_RELEASE_REQUEST: - r=nas_ioCTL_cx_release_request(gifr,priv); - break; - - case NAS_MSG_CX_LIST_REQUEST: - r=nas_ioCTL_cx_list_request(gifr,priv); - break; - - case NAS_MSG_RB_ESTABLISHMENT_REQUEST: - r=nas_ioCTL_rb_establishment_request(gifr,priv); - break; - - case NAS_MSG_RB_RELEASE_REQUEST: - r= nas_ioCTL_rb_release_request(gifr,priv); - break; - - case NAS_MSG_RB_LIST_REQUEST: - r=nas_ioCTL_rb_list_request(gifr,priv); - break; - - case NAS_MSG_CLASS_ADD_REQUEST: - r=nas_ioCTL_class_add_request(gifr,priv); - break; - - case NAS_MSG_CLASS_LIST_REQUEST: - r=nas_ioCTL_class_list_request(gifr,priv); - break; - - case NAS_MSG_CLASS_DEL_REQUEST: - r=nas_ioCTL_class_del_request(gifr,priv); - break; - - case NAS_MSG_MEAS_REQUEST: - r=nas_ioCTL_measure_request(gifr,priv); - break; - - case NAS_MSG_IMEI_REQUEST: - r=nas_ioCTL_imei_request(gifr,priv); - break; - - default: - // printk("NAS_IOCTL_RRM: unkwon request type, type=%x\n", gifr->type); - r=-EFAULT; - } - - break; - - default: - // printk("NAS_CTL_IOCTL: Unknown ioctl command, cmd=%x\n", cmd); - r=-EFAULT; - } - - // printk("NAS_CTL_IOCTL: end\n"); - return r; -} - -//--------------------------------------------------------------------------- -void nas_CTL_send(struct sk_buff *skb, - struct cx_entity *cx, - struct classifier_entity *gc, int inst, struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - printk("NAS_CTL_SEND - void \n"); -} - diff --git a/openair2/NETWORK_DRIVER/MESH/ioctl.h b/openair2/NETWORK_DRIVER/MESH/ioctl.h deleted file mode 100644 index 904105b1d1..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/ioctl.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef NAS_CTL_H -#define NAS_CTL_H - -#include -#include -#include -#include -#include - - -//#include - -#define NAS_MSG_MAXLEN 1100/// change??? - -// type of CTL message -#define NAS_MSG_STATISTIC_REQUEST 1 -#define NAS_MSG_STATISTIC_REPLY 2 -#define NAS_MSG_ECHO_REQUEST 3 -#define NAS_MSG_ECHO_REPLY 4 -#define NAS_MSG_CX_ESTABLISHMENT_REQUEST 5 -#define NAS_MSG_CX_ESTABLISHMENT_REPLY 6 -#define NAS_MSG_CX_RELEASE_REQUEST 7 -#define NAS_MSG_CX_RELEASE_REPLY 8 -#define NAS_MSG_CX_LIST_REQUEST 9 -#define NAS_MSG_CX_LIST_REPLY 10 -#define NAS_MSG_RB_ESTABLISHMENT_REQUEST 11 -#define NAS_MSG_RB_ESTABLISHMENT_REPLY 12 -#define NAS_MSG_RB_RELEASE_REQUEST 13 -#define NAS_MSG_RB_RELEASE_REPLY 14 -#define NAS_MSG_RB_LIST_REQUEST 15 -#define NAS_MSG_RB_LIST_REPLY 16 -#define NAS_MSG_CLASS_ADD_REQUEST 17 -#define NAS_MSG_CLASS_ADD_REPLY 18 -#define NAS_MSG_CLASS_DEL_REQUEST 19 -#define NAS_MSG_CLASS_DEL_REPLY 20 -#define NAS_MSG_CLASS_LIST_REQUEST 21 -#define NAS_MSG_CLASS_LIST_REPLY 22 -#define NAS_MSG_MEAS_REQUEST 23 -#define NAS_MSG_MEAS_REPLY 24 -#define NAS_MSG_IMEI_REQUEST 25 -#define NAS_MSG_IMEI_REPLY 26 - -// Max number of entry of a message list -#define NAS_LIST_CX_MAX 32 -#define NAS_LIST_RB_MAX 32 -#define NAS_LIST_CLASS_MAX 16 // 32 is too high!!: -/* risk of stack problems: KEEP ATTENTION TO COMPILATION WARNINGS */ - -typedef unsigned short nasMsgType_t; - -struct nas_ioctl { - char name[IFNAMSIZ]; - nasMsgType_t type; - char *msg; -}; - -struct nas_msg_statistic_reply { - unsigned int rx_packets; - unsigned int tx_packets; - unsigned int rx_bytes; - unsigned int tx_bytes; - unsigned int rx_errors; - unsigned int tx_errors; - unsigned int rx_dropped; - unsigned int tx_dropped; -}; - -struct nas_msg_cx_list_reply { - nasLocalConnectionRef_t lcr; // Local Connection reference - unsigned char state; - nasCellID_t cellid; // cell identification - unsigned int iid6[2]; // IPv6 interface identification - unsigned char iid4; // IPv4 interface identification - unsigned short num_rb; - unsigned short nsclassifier; -}; -struct nas_msg_cx_establishment_reply { - int status; -}; -struct nas_msg_cx_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasCellID_t cellid; // Cell identification -}; -struct nas_msg_cx_release_reply { - int status; -}; -struct nas_msg_cx_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; - -struct nas_msg_rb_list_reply { - nasRadioBearerId_t rab_id; - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - unsigned char state; -}; -struct nas_msg_rb_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; -struct nas_msg_rb_establishment_reply { - int status; -}; -struct nas_msg_rb_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - nasQoSTrafficClass_t qos; -}; - -struct nas_msg_rb_release_reply { - int status; -}; -struct nas_msg_rb_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; -}; -/* -struct saddr { - - struct in6_addr ipv6; - unsigned int ipv4; -}; - -struct daddr { - - struct in6_addr ipv6; - unsigned int ipv4; - unsigned int mpls_label; -}; -*/ -struct nas_msg_class_add_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - nasRadioBearerId_t rab_id_rx; - unsigned char dir; // direction (send or receive, forward) - unsigned char dscp; // codepoint - unsigned char fct; - unsigned short classref; - unsigned char version; - - //struct daddr daddr; - //struct saddr saddr; - - unsigned char splen; // prefix length - - union { - struct in6_addr ipv6; - - // begin navid - //in_addr_t ipv4; - unsigned int ipv4; - //end navid - - unsigned int mpls_label; - } daddr; // IP destination address - - union { - struct in6_addr ipv6; - - // begin navid - //in_addr_t ipv4; - unsigned int ipv4; - //end navid - - } saddr; // IP source address - - - unsigned char dplen; // prefix length - - unsigned char protocol; //!< transport layer protocol type (ANY,TCP,UDP,ICMPv4,ICMPv6) - unsigned char protocol_message_type; //!< transport layer protocol message (ROUTER_ADV, ROUTER_SOLL, etc.) - unsigned short sport; //!< source port - unsigned short dport; //!< destination port -}; - -struct nas_msg_class_add_reply { - int status; -}; -struct nas_msg_class_del_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - unsigned char dir; // direction (send or receive) - unsigned char dscp; // codepoint - unsigned short classref; -}; -struct nas_msg_class_del_reply { - int status; -}; -#define nas_msg_class_list_reply nas_msg_class_add_request -struct nas_msg_class_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - unsigned char dir; - unsigned char dscp; -}; - - -// Messages for Measurement transfer - MW 01/04/2005 -typedef unsigned int nioctlProviderId_t; -typedef unsigned short nioctlSignalLoss_t; -typedef struct nioctlMeasures { - nasCellID_t cell_id; - nasSigLevel_t level; - nioctlProviderId_t provider_id; -} nioctlMeasures_t; - -struct nas_msg_measure_request { - nasNumRGsMeas_t num_cells; - nasCellID_t cellid[MAX_MEASURE_NB]; // Cell identification - unsigned short num_providers; - nioctlProviderId_t provider_id[MAX_MEASURE_NB]; // Provider identification -}; -struct nas_msg_measure_reply { - nasNumRGsMeas_t num_cells; - nioctlMeasures_t measures[MAX_MEASURE_NB]; - nioctlSignalLoss_t signal_lost_flag; -}; - -// Messages for Measurement transfer - MW 01/04/2005 -typedef unsigned int nioctlL2Id_t[2]; - -struct nas_msg_l2id_reply { - nioctlL2Id_t l2id; -}; - - -#endif diff --git a/openair2/NETWORK_DRIVER/MESH/local.h b/openair2/NETWORK_DRIVER/MESH/local.h deleted file mode 100644 index ef4cfde8ac..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/local.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - local.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - knopp@eurecom.fr - *************************************************************************** - - ***************************************************************************/ - -#ifndef LOCAL_H -#define LOCAL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - - -//#include "rrc_nas_primitives.h" -//#include "rrc_sap.h" - -#define PDCP2PDCP_USE_RT_FIFO 21 -#define NAS2PDCP_FIFO 22 - -#include "constant.h" -#include "sap.h" -#include "rrc_nas_primitives.h" -#include "common/platform_types.h" - -struct rb_entity { - nasRadioBearerId_t rab_id; - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - uint8_t state; - uint8_t retry; - uint32_t countimer; - struct rb_entity *next; -}; - -struct cx_entity { - int sap[NAS_SAPI_CX_MAX]; - uint8_t state; // state of the connection - nasLocalConnectionRef_t lcr; // Local connection reference - nasCellID_t cellid; // cell identification - uint32_t countimer; // timeout's counter - uint8_t retry; // number of retransmission - struct classifier_entity *sclassifier[NAS_DSCP_MAX]; // send classifier; - struct classifier_entity *fclassifier[NAS_DSCP_MAX]; // send classifier; - uint16_t nsclassifier; - uint16_t nfclassifier; - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - struct rb_entity *rb; - uint16_t num_rb; - int lastRRCprimitive; - //measures - int req_prov_id[MAX_MEASURE_NB]; - int num_measures; - int meas_cell_id[MAX_MEASURE_NB]; - int meas_level[MAX_MEASURE_NB]; - int provider_id[MAX_MEASURE_NB]; - -}; -//#define NAS_RETRY_LIMIT_DEFAULT 5 - -struct nas_priv { - int irq; - struct timer_list timer; - spinlock_t lock; - struct net_device_stats stats; - uint8_t retry_limit; - uint32_t timer_establishment; - uint32_t timer_release; - struct cx_entity cx[NAS_CX_MAX]; - struct classifier_entity *rclassifier[NAS_DSCP_MAX]; // receive classifier - uint16_t nrclassifier; - int sap[NAS_SAPI_MAX]; - struct sock *nl_sk; - uint8_t nlmsg[NAS_MAX_LENGTH+sizeof(struct nlmsghdr)]; - uint8_t xbuffer[NAS_MAX_LENGTH]; // transmition buffer - uint8_t rbuffer[NAS_MAX_LENGTH]; // reception buffer -}; - - -struct classifier_entity { - uint32_t classref; - struct classifier_entity *next; - uint8_t version; - union { - struct in6_addr ipv6; - uint32_t ipv4; - } saddr; // IP source address - uint8_t splen; // prefix length - union { - struct in6_addr ipv6; - uint32_t ipv4; - unsigned int mpls_label; - } daddr; // IP destination address - uint8_t dplen; // prefix length - uint8_t protocol; // high layer protocol type - unsigned char protocol_message_type; - uint16_t sport; // source port - uint16_t dport; // destination port - struct rb_entity *rb; //pointer to rb_entity for sending function or receiving in case of forwarding rule - struct rb_entity *rb_rx; //pointer to rb_entity for receiving (in case of forwarding rule) - nasRadioBearerId_t rab_id; // RAB identification for sending - nasRadioBearerId_t rab_id_rx; // RAB identification for receiving (in case of forwarding rule) - void (*fct)(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst, struct nas_priv *gpriv); -}; - -struct ipversion { -#if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t reserved:4, - version:4; -#else - uint8_t version:4, - reserved:4; -#endif -}; - -typedef struct pdcp_data_req_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t dummy_traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; -} pdcp_data_ind_header_t; - -extern struct net_device *nasdev[NB_INSTANCES_MAX]; - - -extern uint8_t NAS_NULL_IMEI[14]; - -#endif diff --git a/openair2/NETWORK_DRIVER/MESH/mesh.c b/openair2/NETWORK_DRIVER/MESH/mesh.c deleted file mode 100644 index 00cfc35bc8..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/mesh.c +++ /dev/null @@ -1,980 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - nas_mesh.c - description - ------------------- - copyright : (C) 2003-2008 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - raymond.knopp@eurecom.fr - - -***************************************************************************/ - -#include -#include "local.h" -#include "proto_extern.h" - -//--------------------------------------------------------------------------- -void nas_mesh_init(int inst) -{ - //--------------------------------------------------------------------------- - // struct cx_entity *cx; - printk("NAS_MESH_INIT Complete\n"); - - // Request the establishment of a connexion - // cx=nas_COMMON_search_cx(0); - // if (cx==NULL) - // { - // printk("NAS_MESH_INIT: connexion failure\n"); - // return; - // } - // cx->countimer=5; - // cx->state=NAS_CX_CONNECTING; - // cx->retry=0; - // cx->cellid=25; -} - -//--------------------------------------------------------------------------- -//For demo, add automatically a classifier -//Equivalent to class add send 0 -f qos -cr 0 -void nas_mesh_start_broadcast_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - - struct classifier_entity *gc; - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_BROADCAST_SCLASS - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - input parameter cx is NULL \n"); -#endif - return; - } - - if (rb==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - input parameter rb is NULL \n"); -#endif - return; - } - - // End debug information - gc=nas_CLASS_add_sclassifier(cx, NAS_DSCP_DEFAULT, 6); - - // gc=nas_CLASS_add_sclassifier(cx, 5, 0); - if (gc==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - Classifier not added \n"); -#endif - return; - } - - gc->fct = nas_COMMON_QOS_send; - gc->rab_id =rb->rab_id; //5 - gc->rb= rb; - gc->version = NAS_VERSION_DEFAULT; - gc->protocol= NAS_PROTOCOL_ICMP6; - // gc->sport = NAS_PORT_DEFAULT; - // gc->dport = NAS_PORT_DEFAULT; -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - end \n"); - nas_print_classifier(gc); -#endif - -} -void nas_mesh_start_default_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- -#ifdef DEMO_3GSM - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - input parameter cx is NULL \n"); -#endif - return; - } - - if (rb==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - input parameter rb is NULL \n"); -#endif - return; - } - - // End debug information - gc=nas_CLASS_add_sclassifier(cx, NAS_DSCP_DEFAULT, 5); - - // gc=nas_CLASS_add_sclassifier(cx, 5, 0); - if (gc==NULL) { -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - Classifier not added \n"); -#endif - return; - } - - gc->fct = nas_COMMON_QOS_send; - gc->rab_id =rb->rab_id; //5 - gc->rb= rb; - gc->version = NAS_VERSION_DEFAULT; - gc->protocol= NAS_PROTOCOL_DEFAULT; - // gc->sport = NAS_PORT_DEFAULT; - // gc->dport = NAS_PORT_DEFAULT; -#ifdef NAS_DEBUG_CLASS - printk("NAS_MESH_START_DEFAULT_SCLASS - end \n"); - nas_print_classifier(gc); -#endif -#endif -} - -//--------------------------------------------------------------------------- -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) -void nas_mesh_timer(struct timer_list *t) -#else -void nas_mesh_timer(unsigned long data) -#endif -{ - //--------------------------------------------------------------------------- -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) - struct nas_priv *gpriv=from_timer(gpriv, t, timer); - #else - struct nas_priv *gpriv=(struct nas_priv *) data; - #endif - uint8_t cxi; - struct cx_entity *cx; - struct rb_entity *rb; - // spin_lock(&gpriv->lock); -#ifdef NAS_DEBUG_TIMER - printk("NAS_MESH_TIMER - begin \n"); -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) -timer_setup(&gpriv->timer, nas_mesh_timer, 0); - mod_timer(&gpriv->timer, jiffies+NAS_TIMER_TICK); - #else - (gpriv->timer).function=nas_mesh_timer; - (gpriv->timer).expires=jiffies+NAS_TIMER_TICK; - (gpriv->timer).data=data; - #endif - - return; - - - for (cxi=0; cxicx+cxi; - - if (cx==NULL) { -#ifdef NAS_DEBUG_TIMER - printk("NAS_MESH_TIMER - No pointer for connection %d \n", cxi); -#endif - continue; - } - - if (cx->countimer!=NAS_TIMER_IDLE) { -#ifdef NAS_DEBUG_TIMER - printk("NAS_MESH_TIMER: lcr %u, countimer %u\n", cx->lcr, cx->countimer); -#endif - - if (cx->countimer==0) { - switch (cx->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: - if (cx->retryretry_limit) - nas_mesh_DC_send_cx_establish_request(cx,gpriv); - else { - printk("NAS_MESH_TIMER: Establishment failure\n"); - cx->state=NAS_IDLE; - cx->retry=0; - cx->countimer=NAS_TIMER_IDLE; - } - - break; - - case NAS_CX_RELEASING_FAILURE: - nas_mesh_DC_send_cx_release_request(cx,gpriv); - break; - - default: - printk("NAS_MESH_TIMER: default value\n"); - cx->countimer=NAS_TIMER_IDLE; - } - } else - --cx->countimer; - } - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->countimer!=NAS_TIMER_IDLE) { -#ifdef NAS_DEBUG_TIMER - printk("NAS_MESH_TIMER : rb countimer %d, rb state %d\n", rb->countimer, rb->state); -#endif - - if (rb->countimer==0) { - switch (rb->state) { - case NAS_RB_DCH: - nas_mesh_start_default_sclassifier(cx, rb); - rb->countimer=NAS_TIMER_IDLE; - break; - - default: - rb->countimer=NAS_TIMER_IDLE; - } - } else { - --rb->countimer; - printk("NAS_MESH_TIMER : rb countimer-- %d, rb state %d\n", rb->countimer, rb->state); - } - } - } - } - - // add_timer(&gpriv->timer); - // spin_unlock(&gpriv->lock); -} - - -//--------------------------------------------------------------------------- -// Request the establishment of a connexion (DC channel) -int nas_mesh_DC_send_cx_establish_request(struct cx_entity *cx,struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - int bytes_wrote=0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_ESTABLISH - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_ESTABLISH - input parameter cx is NULL \n"); -#endif - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - - switch (cx->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: - case NAS_IDLE: - p= (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = CONN_ESTABLISH_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASConnEstablishReq); - p->nasUEDCPrimitive.conn_establish_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.conn_establish_req.cellId = cx->cellid; -#ifdef NAS_DEBUG_DC - printk ("\nCONN_ESTABLISH_REQ Buffer to Xmit: "); - nas_tool_print_buffer((char *)p,p->length); -#endif - ++cx->retry; - cx->countimer=gpriv->timer_establishment; - - if (bytes_wrote==p->length) { - cx->state=NAS_CX_CONNECTING; -#ifdef NAS_DEBUG_DC - printk("nas_mesh_DC_send_cx_establish_req: Message sent successfully in DC-FIFO\n"); - printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_establish_req.localConnectionRef); - printk(" Cell Identification %u\n", p->nasUEDCPrimitive.conn_establish_req.cellId); - print_TOOL_state(cx->state); -#endif - } else { - cx->state=NAS_CX_CONNECTING_FAILURE; - printk("NAS_MESH_DC_SEND_CX_ESTABLISHMENT_REQUEST: Message sent failure in DC-FIFO\n"); - print_TOOL_state(cx->state); - } - - return bytes_wrote; - - default: - return -NAS_ERROR_NOTIDLE; -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_ESTABLISH - NAS_ERROR_NOTIDLE \n"); -#endif - } -} - -//--------------------------------------------------------------------------- -// Request the release of a connexion (DC channel) -int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx, - struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - int bytes_wrote=0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_RELEASE - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_RELEASE - input parameter cx is NULL \n"); -#endif - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - switch (cx->state) { - case NAS_CX_RELEASING_FAILURE: - case NAS_CX_DCH: - p= (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = CONN_RELEASE_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASConnReleaseReq); - p->nasUEDCPrimitive.conn_release_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.conn_release_req.releaseCause = NAS_CX_RELEASE_UNDEF_CAUSE; - - if (bytes_wrote==p->length) { - cx->state=NAS_IDLE; - cx->iid4=0; - // nas_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nas_COMMON_flush_rb(cx); - -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST: Message sent successfully in DC-FIFO\n"); - printk(" Local Connection Reference %u\n", p->nasUEDCPrimitive.conn_release_req.localConnectionRef); - printk(" Release Cause %u\n", p->nasUEDCPrimitive.conn_release_req.releaseCause); - print_TOOL_state(cx->state); -#endif - } else { - ++cx->retry; - cx->countimer=gpriv->timer_release; - cx->state=NAS_CX_RELEASING_FAILURE; - printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST: Message sent failure in DC-FIFO\n"); - print_TOOL_state(cx->state); - } - - return bytes_wrote; - - default: - return -NAS_ERROR_NOTCONNECTED; -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST - NAS_ERROR_NOTCONNECTED \n"); -#endif - } -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (DC SAP) -void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, - struct cx_entity *cx, - struct classifier_entity *gc, - int inst, - struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - //char data_type = 'A'; - int bytes_wrote=0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_SIG - begin \n"); -#endif - - if (skb==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_SIG - input parameter skb is NULL \n"); -#endif - return; - } - - if (gc==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_SIG - input parameter gc is NULL \n"); -#endif - return; - } - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_SIG - input parameter cx is NULL \n"); -#endif - return; - } - - // End debug information - if (cx->state!=NAS_CX_DCH) { - printk("NAS_MESH_DC_SEND_SIG: Not connected, so the message is dropped\n"); - ++gpriv->stats.tx_dropped; - return; - } - - p = (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = DATA_TRANSFER_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASDataReq); - p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD - p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (skb->len)+1; //adds category character - - if (bytes_wrote!=p->length) { - printk("NAS_MESH_DC_SEND_SIG: Header sent failure in DC-FIFO\n"); - return; - } - - if (bytes_wrote != p->length + skb->len + 1) { - printk("NAS_MESH_DC_SEND_SIG: Data sent failure in DC-FIFO\n"); - return; - } - - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_SEND_SIG - end \n"); -#endif -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (DC SAP) -void nas_mesh_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig_category, - struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - uint8_t nas_data[10]; - unsigned int nas_length; - //char data_type = 'Z'; - int bytes_wrote=0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_PEER_SEND_SIG - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_PEER_SEND_SIG - input parameter cx is NULL \n"); -#endif - return; - } - - // End debug information - - if (cx->state!=NAS_CX_DCH) { - printk("NAS_MESH_DC_PEER_SEND_SIG: Not connected, so the message is dropped\n"); - return; - } - - // Initialize peer message - nas_length = 10; - memset (nas_data, 0, nas_length); - nas_data[0]= sig_category; - // - p = (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = DATA_TRANSFER_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASDataReq); - p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD - p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (nas_length)+1; //adds category character - - if (bytes_wrote!=p->length) { - printk("NAS_MESH_DC_PEER_SEND_SIG: Header sent failure in DC-FIFO\n"); - return; - } - - if (bytes_wrote != p->length + nas_length + 1) { - printk("NAS_MESH_DC_PEER_SEND_SIG: Data sent failure in DC-FIFO\n"); - return; - } - -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_PEER_SEND_SIG - end \n"); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_ESTABLISH_RESP message from RRC -void nas_mesh_DC_decode_cx_establish_resp(struct cx_entity *cx, struct nas_ue_dc_element *p,struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - uint8_t sig_category; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information - cx->retry=0; - - if (p->nasUEDCPrimitive.conn_establish_resp.status == TERMINATED) { - cx->state=NAS_CX_DCH; //to be changed to NAS_CX_FACH - cx->iid4=1; - //nas_TOOL_imei2iid(NAS_RG_IMEI, (uint8_t *)cx->iid6); - sig_category = NAS_CMD_OPEN_RB; - //For demo, add automatically a radio bearer -#ifdef DEMO_3GSM - printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - sig_category %u \n", sig_category); - nas_mesh_DC_send_peer_sig_data_request(cx, sig_category,gpriv); -#endif - } else { - cx->state=NAS_IDLE; - } - -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE: CONN_ESTABLISH_RESP\n"); - printk("Local Connection reference %u\n",p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef); - printk("Connection Establishment status %u\n",p->nasUEDCPrimitive.conn_establish_resp.status); - print_TOOL_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_LOSS_IND message from RRC -void nas_mesh_DC_decode_cx_loss_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_LOSS - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_LOSS - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_CX_LOSS - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information - cx->state=NAS_IDLE; - cx->iid4=0; - //nas_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nas_COMMON_flush_rb(cx); -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE: CONN_LOSS_IND reception\n"); - printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - print_TOOL_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_RELEASE_IND message from RRC -//void nas_mesh_DC_decode_cx_release_ind(struct cx_entity *cx, struct nas_ue_dc_element *p){ -//--------------------------------------------------------------------------- -// printk("\t\tCONN_RELEASE_IND\n"); -// printk("\t\tLocal Connection reference %u\n", p->nasUEDCPrimitive.conn_release_ind.localConnectionRef); -// printk("\t\tRelease cause %u\n", p->nasRGDCPrimitive.conn_release_ind.releaseCause); -// if (gpriv->cx[cxi].state==NAS_CX_DCH) -// { -// gpriv->cx[cxi].state=NAS_IDLE; -// printk("\t\tMobile no more connected\n"); -// return bytes_read; -// } -// printk("\t\tIncoherent state %u\n", gpriv->cx[cxi].state); -// return bytes_read; -//} - -//--------------------------------------------------------------------------- -// Decode DATA_TRANSFER_IND message from RRC -void nas_mesh_DC_decode_sig_data_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_SIG_DATA_IND - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_SIG_DATA_IND - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_SIG_DATA_IND - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE: DATA_TRANSFER_IND reception\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.data_transfer_ind.localConnectionRef); - printk(" Signaling Priority %u\n",p->nasUEDCPrimitive.data_transfer_ind.priority); - printk(" NAS Data length %u\n",p->nasUEDCPrimitive.data_transfer_ind.nasDataLength); - printk(" NAS Data string %s\n", (uint8_t *)p+p->length); -#endif - -} -//--------------------------------------------------------------------------- -// Decode RB_ESTABLISH_IND message from RRC -void nas_mesh_DC_decode_rb_establish_ind(struct cx_entity *cx, struct nas_ue_dc_element *p,struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information - rb=nas_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId); - - if (rb==NULL) { - rb=nas_COMMON_add_rb(cx, p->nasUEDCPrimitive.rb_establish_ind.rbId, p->nasUEDCPrimitive.rb_establish_ind.QoSclass); - rb->state=NAS_RB_DCH; - cx->state=NAS_CX_DCH; - //For demo, add automatically a classifier -#ifdef DEMO_3GSM - rb->countimer=gpriv->timer_establishment+10; -#endif -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND: RB_ESTABLISH_IND reception\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef); - printk(" Radio Bearer Identity %u \n",p->nasUEDCPrimitive.rb_establish_ind.rbId); - printk(" QoS Traffic Class %u\n",p->nasUEDCPrimitive.rb_establish_ind.QoSclass); - printk(" DSCP Code %u\n",p->nasUEDCPrimitive.rb_establish_ind.dscp); - printk(" SAP Id %u\n",p->nasUEDCPrimitive.rb_establish_ind.sapId); - print_TOOL_state(cx->state); - nas_print_rb_entity(rb); -#endif - } else - printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND: RB_ESTABLISH_IND reception, Radio bearer already opened\n"); -} - -//--------------------------------------------------------------------------- -// Decode RB_RELEASE_IND message from RRC -void nas_mesh_DC_decode_rb_release_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information - rb=nas_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId); - - if (rb!=NULL) { - rb->state=NAS_IDLE; - //needs also to flush corresponding control block to be coherent with add_rb -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND: RB_RELEASE_IND reception\n"); - printk("Local Connection reference %u\n",p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); - printk("Radio Bearer Identity %u\n",p->nasUEDCPrimitive.rb_release_ind.rbId); - print_TOOL_state(cx->state); -#endif - } else - printk("NAS_DC_RG_RECEIVE: RB_RELEASE_IND reception, No corresponding radio bearer\n"); - -} -//--------------------------------------------------------------------------- -// Decode MEASUREMENT_IND message from RRC -void nas_mesh_DC_decode_measurement_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - uint8_t i; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - input parameter cx is NULL \n"); -#endif - return; - } - - if (p==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - input parameter p is NULL \n"); -#endif - return; - } - - // End debug information -#ifdef NAS_DEBUG_DC_MEASURE - printk("NAS_MESH_DC_RECEIVE: MEASUREMENT_IND reception\n"); - printk(" Local Connection reference: %u\n", p->nasUEDCPrimitive.measurement_ind.localConnectionRef); - printk(" Number of RGs: %u\n", p->nasUEDCPrimitive.measurement_ind.nb_rg); - print_TOOL_state(cx->state); - - for (i=0; inasUEDCPrimitive.measurement_ind.nb_rg; ++i) { - printk(" RG[%u]: Cell_Id %u, Level: %u\n", i, - p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id, - p->nasUEDCPrimitive.measurement_ind.measures[i].level); - } - -#endif //NAS_DEBUG_DC_MEASURE - cx->num_measures = p->nasUEDCPrimitive.measurement_ind.nb_rg; - - for (i=0; inum_measures; i++) { - cx->meas_cell_id[i]= (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id); - cx->meas_level[i] = (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].level); - //npriv->provider_id[i]=; - } - - cx->provider_id[0]=25; - cx->provider_id[1]=1; - cx->provider_id[2]=25; - -} - -//--------------------------------------------------------------------------- -// Check if anything in DC FIFO and decode it (MESH) -int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - // Start debug information - int bytes_read=0; - -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE - begin \n"); -#endif - - if (cx==NULL) { -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE - input parameter cx is NULL \n"); -#endif - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - - if (bytes_read>0) { - struct nas_ue_dc_element *p; - - p= (struct nas_ue_dc_element *)(gpriv->rbuffer); - //get the rest of the primitive - - if (bytes_read!=p->length) { - printk("NAS_MESH_DC_RECEIVE: Problem while reading primitive header\n"); - return bytes_read; - } - - switch (p->type) { - case CONN_ESTABLISH_RESP : - if (p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef!=cx->lcr) - printk("NAS_MESH_DC_RECEIVE: CONN_ESTABLISH_RESP, Local connection reference not correct %u\n",p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_CONNECTING: - nas_mesh_DC_decode_cx_establish_resp(cx,p,gpriv); // process message - break; - - default: - printk("NAS_MESH_DC_RECEIVE: CONN_ESTABLISH_RESP reception, Invalid state %u\n", cx->state); - } - } - - break; - - case CONN_LOSS_IND : - if (p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef!=cx->lcr) - printk("NAS_MESH_DC_RECEIVE: CONN_LOSS_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_RELEASING_FAILURE: - cx->retry=0; - /* fallthrough */ - - case NAS_CX_DCH: - nas_mesh_DC_decode_cx_loss_ind(cx,p); // process message - break; - - default: - printk("NAS_MESH_DC_RECEIVE: CONN_LOSS_IND reception, Invalid state %u", cx->state); - } - } - - break; - - // case CONN_RELEASE_IND : - // break; - case DATA_TRANSFER_IND : - if (p->nasUEDCPrimitive.data_transfer_ind.localConnectionRef!=cx->lcr) - printk("NAS_MESH_DC_RECEIVE: DATA_TRANSFER_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_FACH: - case NAS_CX_DCH: - nas_mesh_DC_decode_sig_data_ind(cx,p); // process message - break; - - default: - printk("NAS_MESH_DC_RECEIVE: DATA_TRANSFER_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case RB_ESTABLISH_IND : - if (p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef!=cx->lcr) - printk("NAS_MESH_DC_RECEIVE: RB_ESTABLISH_IND reception, Local connexion reference not correct %u\n", p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_FACH: - case NAS_CX_DCH: - nas_mesh_DC_decode_rb_establish_ind(cx,p,gpriv); // process message - break; - - default: - printk("NAS_MESH_DC_RECEIVE: RB_ESTABLISH_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case RB_RELEASE_IND : - if (p->nasUEDCPrimitive.rb_release_ind.localConnectionRef!=cx->lcr) - printk("NAS_DC_MESH_RECEIVE: RB_RELEASE_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_DCH: - nas_mesh_DC_decode_rb_release_ind(cx,p); // process message - break; - - default: - printk("NAS_MESH_DC_RECEIVE: RB_RELEASE_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case MEASUREMENT_IND : - if (p->nasUEDCPrimitive.measurement_ind.localConnectionRef!=cx->lcr) - printk("NAS_MESH_DC_RECEIVE: MEASUREMENT_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.measurement_ind.localConnectionRef); - else { - nas_mesh_DC_decode_measurement_ind(cx,p); - } - - break; - - default : - printk("NAS_MESH_DC_RECEIVE: Invalid message received\n"); - } - } - -#ifdef NAS_DEBUG_DC - printk("NAS_MESH_DC_RECEIVE - end \n"); -#endif - return bytes_read; -} - -//--------------------------------------------------------------------------- -// Check if anything in GC FIFO and decode it (MESH) -int nas_mesh_GC_receive(struct nas_priv *gpriv) -{ - //--------------------------------------------------------------------------- - - int bytes_read=0; - -#ifdef NAS_DEBUG_GC - printk("NAS_MESH_GC_RECEIVE - begin \n"); -#endif - - if (bytes_read>0) { - struct nas_ue_gc_element *p; - p= (struct nas_ue_gc_element *)(gpriv->rbuffer); - //get the rest of the primitive - - if (bytes_read!=p->length) { - printk("NAS_MESH_GC_RECEIVE: Problem while reading primitive's header\n"); - return bytes_read; - } - - // start decoding message - switch (p->type) { - case INFO_BROADCAST_IND : - if (bytes_read!=p->length+p->nasUEGCPrimitive.broadcast_ind.nasDataLength) { - printk("NAS_MESH_GC_RECEIVE: INFO_BROADCAST_IND reception, Problem while reading primitive's data\n"); - return bytes_read; - } - -#ifdef NAS_DEBUG_GC - printk("NAS_MESH_GC_RECEIVE: INFO_BROADCAST_IND reception\n"); - printk(" Primitive length %d \n", (int)(p->type)); - printk(" Data length %u\n", p->nasUEGCPrimitive.broadcast_ind.nasDataLength); - printk(" Data string %s\n", (uint8_t *)p+p->length); -#endif //NAS_DEBUG_GC - return bytes_read; - - default : - printk("NAS_MESH_GC_RECEIVE: Invalid message received\n"); - return -1; - } - } else - return -1; -} - - diff --git a/openair2/NETWORK_DRIVER/MESH/netlink.c b/openair2/NETWORK_DRIVER/MESH/netlink.c deleted file mode 100644 index 7c4223e4e8..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/netlink.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file netlink.c -* \brief establish a netlink -* \author Navid Nikaein, Lionel Gauthier, and Raymond knopp -* \company Eurecom -* \email:navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr -*/ - -//#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "local.h" -#include "proto_extern.h" -//#include "common/platform_constants.h" - -//#define NETLINK_DEBUG 1 - - -#define OAI_IP_DRIVER_NETLINK_ID 31 -#define NL_DEST_PID 1 - - -static struct sock *nas_nl_sk = NULL; -static int exit_netlink_thread=0; -//static int nas_netlink_rx_thread(void *); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) -struct netlink_kernel_cfg oai_netlink_cfg; -#endif - -static DEFINE_MUTEX(nasmesh_mutex); - -static inline void nasmesh_lock(void) -{ - mutex_lock(&nasmesh_mutex); -} - -static inline void nasmesh_unlock(void) -{ - mutex_unlock(&nasmesh_mutex); -} - -// This can also be implemented using thread to get the data from PDCP without blocking. -static void nas_nl_data_ready (struct sk_buff *skb) -{ - // wake_up_interruptible(skb->sk->sk_sleep); - //nasmesh_lock(); - //netlink_rcv_skb(skb, &my_rcv_msg);// my_rcv_msg is the call back func> - //nasmesh_unlock(); - - struct nlmsghdr *nlh = NULL; - //int j; - - if (skb) { - -#ifdef NETLINK_DEBUG - printk("[NAS][NETLINK] Received socket from PDCP\n"); -#endif //NETLINK_DEBUG - nlh = (struct nlmsghdr *)skb->data; - - nas_COMMON_QOS_receive(nlh); - - //kfree_skb(skb); // not required, - } - -} - -int nas_netlink_init() -{ - - printk("[NAS][NETLINK] Running init ...\n"); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) - oai_netlink_cfg.groups = 0; - oai_netlink_cfg.input = nas_nl_data_ready; - oai_netlink_cfg.cb_mutex = &nasmesh_mutex; - oai_netlink_cfg.bind = NULL; - - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, -# if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) - THIS_MODULE, -# endif - &oai_netlink_cfg); -#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, - 0, - nas_nl_data_ready, - &nasmesh_mutex, // NULL - THIS_MODULE); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - - if (nas_nl_sk == NULL) { - - printk("[NAS][NETLINK] netlink_kernel_create failed \n"); - return(-1); - } - - - - return(0); - -} - - -void nas_netlink_release(void) -{ - - exit_netlink_thread=1; - printk("[NAS][NETLINK] Releasing netlink socket\n"); - - if(nas_nl_sk) { - netlink_kernel_release(nas_nl_sk); //or skb->sk - - } - - // printk("[NAS][NETLINK] Removing netlink_rx_thread\n"); - //kthread_stop(netlink_rx_thread); - -} - - - - -int nas_netlink_send(unsigned char *data,unsigned int len) -{ - - - struct sk_buff *nl_skb = alloc_skb(NLMSG_SPACE(len),GFP_ATOMIC); - struct nlmsghdr *nlh = (struct nlmsghdr *)nl_skb->data; - int status; - - - //printk("[NAS][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); - skb_put(nl_skb, NLMSG_SPACE(len)); - memcpy(NLMSG_DATA(nlh),data,len); - - nlh->nlmsg_len = NLMSG_SPACE(len); - - - nlh->nlmsg_pid = 0; /* from kernel */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - NETLINK_CB(nl_skb).portid = 0; -#else - NETLINK_CB(nl_skb).pid = 0; -#endif - -#ifdef NETLINK_DEBUG - printk("[NAS][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d (OAI_IP_DRIVER_NETLINK_ID %d)\n", - nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len, - OAI_IP_DRIVER_NETLINK_ID); -#endif //DEBUG_NETLINK - - if (nas_nl_sk) { - - // nasmesh_lock(); - - status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT); - // mutex_unlock(&nasmesh_mutex); - - if (status < 0) { - printk("[NAS][NETLINK] SEND status is %d\n",status); - return(0); - } else { -#ifdef NETLINK_DEBUG - printk("[NAS][NETLINK] SEND status is %d\n",status); -#endif - return len; - } - } else { - printk("[NAS][SEND] socket is NULL\n"); - return(0); - } - - /* - nlmsg_failure: // Used by NLMSG_PUT - if (nl_skb) - kfree_skb(nl_skb); - */ - -} diff --git a/openair2/NETWORK_DRIVER/MESH/proto_extern.h b/openair2/NETWORK_DRIVER/MESH/proto_extern.h deleted file mode 100644 index 332540f3b7..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/proto_extern.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - nas_proto_extern.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - knopp@eurecom.fr - -***************************************************************************/ - -#ifndef __NETWORK_DRIVER_MESH_PROTO_EXTERN__H__ -#define __NETWORK_DRIVER_MESH_PROTO_EXTERN__H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -//#include "rrc_nas_primitives.h" -//#include "protocol_vars_extern.h" -//#include "as_sap.h" -//#include "rrc_qos.h" -//#include "rrc_sap.h" - -#include "local.h" - -// device.c - - -/** @defgroup _nas_mesh_impl_ NAS Mesh Network Device -* @ingroup _ref_implementation_ -* @{ -\fn int find_inst(struct net_device *dev) -\brief This function determines the instance id for a particular device pointer. -@param dev Pointer to net_device structure - */ -int find_inst(struct net_device *dev); - -// nas_common.c -/** -\fn void nas_COMMON_receive(unsigned short dlen, void* pdcp_sdu,int inst,struct classifier_entity *rclass,nasRadioBearerId_t rb_id) -\brief Receive data from FIFO (QOS) -@param dlen Length of SDU in bytes -@param pdcp_sdu Pointer to received SDU -@param inst Instance number -@param rclass RX Classifier entity -@param rb_id Radio Bearer Id - */ -void nas_COMMON_receive(unsigned short dlen, - void *pdcp_sdu, - int inst, - struct classifier_entity *rclass, - nasRadioBearerId_t rb_id); - -/** -\fn void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst) -\brief Request the transfer of data (QoS SAP) -@param skb pointer to socket buffer -@param cx pointer to connection entity for SDU -@param gc pointer to classifier entity for SDU -@param inst device instance - */ -void nas_COMMON_QOS_send(struct sk_buff *skb, - struct cx_entity *cx, - struct classifier_entity *gc,int inst, struct nas_priv *gpriv); - -/** -\fn void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst) -\brief Delete the data -@param skb pointer to socket buffer -@param cx pointer to connection entity for SDU -@param gc pointer to classifier entity for SDU -@param inst device instance - */ -void nas_COMMON_del_send(struct sk_buff *skb, - struct cx_entity *cx, - struct classifier_entity *gc,int inst, struct nas_priv *gpriv); - -/** -\fn struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos) -\brief Add a radio-bearer descriptor -@param cx pointer to connection entity -@param rabi radio-bearer index -@param qos NAS QOS traffic class - */ -struct rb_entity *nas_COMMON_add_rb( - struct cx_entity *cx, nasRadioBearerId_t rabi, - nasQoSTrafficClass_t qos); - -/** -\fn struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi) -\brief Search for a radio-bearer entity for a particular connection and radio-bearer index -@param cx pointer to connection entity -@param rabi radio-bearer index -@returns A pointer to the radio-bearer entity - */ -struct rb_entity *nas_COMMON_search_rb( - struct cx_entity *cx, nasRadioBearerId_t rabi); - -/** -\fn struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *gpriv) -\brief Search for a connection entity based on its index and pointer to nas_priv -@param lcr index of local connection -@param gpriv pointer to nas_priv for device -@returns A pointer to the connection entity - */ -struct cx_entity *nas_COMMON_search_cx( - nasLocalConnectionRef_t lcr, - struct nas_priv *gpriv); - -/** -\fn struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv) -\brief Search for an RX classifier entity based on a RB id and pointer to nas_priv -@param rab_id Index of RAB for search -@param priv pointer to nas_priv for device -@returns A pointer to the corresponding RX classifier entity - */ -struct classifier_entity -*nas_COMMON_search_class_for_rb(nasRadioBearerId_t - rab_id,struct nas_priv *priv); - -/** -\fn void nas_COMMON_flush_rb(struct cx_entity *cx) -\brief Clear all RB's for a particular connection -@param cx pointer to connection entity - */ -void nas_COMMON_flush_rb(struct cx_entity *cx); - -/** -\fn int nas_netlink_send(unsigned char *data,unsigned int len) -\brief Request the transfer of data by PDCP via netlink socket -@param data pointer to SDU -@param len length of SDU in bytes -@returns Numeber of bytes transfered by netlink socket - */ -int nas_netlink_send(unsigned char *data,unsigned int len); - -/** -\fn void nas_COMMON_QOS_receive(struct nlmsghdr *nlh) -\brief Request a PDU from PDCP -@param nlh pointer to netlink message header - */ -void nas_COMMON_QOS_receive(struct nlmsghdr *nlh); - -//nasmesh.c - -/** - \brief Initialize an interface for a particular instance ID. -*/ -void nas_mesh_init(int inst //!< Instance ID - - ); - - -int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv); -int nas_mesh_GC_receive(struct nas_priv *gpriv); -int nas_mesh_DC_send_cx_establish_request(struct cx_entity *cx,struct nas_priv *gpriv); -int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx,struct nas_priv *gpriv); -void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst, struct nas_priv *gpriv); - -// iocontrol.c -void nas_CTL_send(struct sk_buff *skb, - struct cx_entity *cx, - struct classifier_entity *gc,int inst, struct nas_priv *gpriv); -//int nas_CTL_receive_authentication(struct ipv6hdr *iph, struct cx-entity *cx, unsigned char sapi); -int nas_CTL_ioctl(struct net_device *dev, - struct ifreq *ifr, int cmd); - -// classifier.c - -/** - \brief Send a socket received from IP to classifier for a particular instance ID. -*/ -void nas_CLASS_send(struct sk_buff *skb, //!< Pointer to socket buffer - int inst //!< Instance ID - ); -/** - \brief -*/ -struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, unsigned char dscp, unsigned short classref); - -/** - \brief Send a socket received from IP to classifier for a particular instance ID. -*/ -struct classifier_entity -*nas_CLASS_add_fclassifier(struct cx_entity *cx, - unsigned char dscp, - unsigned short classref - ); - -/** - \brief Send a socket received from IP to classifier for a particular instance ID. -*/ -struct classifier_entity -*nas_CLASS_add_rclassifier(unsigned char dscp, - unsigned short classref, - struct nas_priv* - ); - -/** - \brief -*/ -void nas_CLASS_del_sclassifier(struct cx_entity *cx, - unsigned char dscp, - unsigned short classref - ); - -/** - \brief -*/ -void nas_CLASS_del_fclassifier(struct cx_entity *cx, - unsigned char dscp, - unsigned short classref - ); - -/** - \brief -*/ -void nas_CLASS_del_rclassifier(unsigned char dscp, - unsigned short classref, - struct nas_priv* - ); - -/** - \brief -*/ -void nas_CLASS_flush_sclassifier(struct cx_entity *cx - ); - -/** - \brief -*/ -void nas_CLASS_flush_fclassifier(struct cx_entity *cx - ); - -/** - \brief -*/ -void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv - ); - - -// nas_tool.c -unsigned char nas_TOOL_invfct(struct classifier_entity *gc); -void nas_TOOL_fct(struct classifier_entity *gc, unsigned char fct); -void nas_TOOL_imei2iid(unsigned char *imei, unsigned char *iid); -unsigned char nas_TOOL_get_dscp6(struct ipv6hdr *iph); -unsigned char nas_TOOL_get_dscp4(struct iphdr *iph); -unsigned char *nas_TOOL_get_protocol6(struct ipv6hdr *iph, unsigned char *protocol); -unsigned char *nas_TOOL_get_protocol4(struct iphdr *iph, unsigned char *protocol); -char *nas_TOOL_get_udpmsg(struct udphdr *udph); -unsigned short nas_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, unsigned char proto, unsigned int udplen, void *data); -int nas_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, unsigned char plen); -int nas_TOOL_network4(unsigned int *addr, unsigned int *prefix, unsigned char plen); -void print_TOOL_pk_icmp6(struct icmp6hdr *icmph); - -void print_TOOL_pk_all(struct sk_buff *skb); -void print_TOOL_pk_ipv6(struct ipv6hdr *iph); -void print_TOOL_state(unsigned char state); -void nas_tool_print_buffer(char * buffer,int length); -void nas_print_rb_entity(struct rb_entity *rb); -void nas_print_classifier(struct classifier_entity *gc); - -// nas_netlink.c - -void nas_netlink_release(void); -int nas_netlink_init(void); - -/** @} */ -#endif diff --git a/openair2/NETWORK_DRIVER/MESH/rrc_nas_primitives.h b/openair2/NETWORK_DRIVER/MESH/rrc_nas_primitives.h deleted file mode 100644 index 193ce286cb..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/rrc_nas_primitives.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/********************************************************************* - rrc_nas_primitives.h - description - ------------------- - begin : Jan 11, 2002 - copyright : (C) 2001 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - knopp@eurecom.fr - ********************************************************************* - Define RRC external interface primitives - ********************************************************************/ -#ifndef __RRC_NASPRIM_H__ -# define __RRC_NASPRIM_H__ - -//---------------------------------------------------------- -// Primitives -//---------------------------------------------------------- -# define INFO_BROADCAST_REQ 1 -# define INFO_BROADCAST_IND 2 -# define CONN_ESTABLISH_REQ 3 -# define CONN_ESTABLISH_IND 4 -# define CONN_ESTABLISH_RESP 5 -# define CONN_ESTABLISH_CNF 6 -# define CONN_RELEASE_REQ 7 -# define CONN_RELEASE_IND 8 -# define DATA_TRANSFER_REQ 9 -# define DATA_TRANSFER_IND 10 -# define RB_ESTABLISH_REQ 11 -# define RB_ESTABLISH_IND 12 -# define RB_ESTABLISH_CNF 14 -# define RB_RELEASE_REQ 15 -# define RB_RELEASE_IND 16 -# define MEASUREMENT_IND 17 -# define CONN_LOSS_IND 18 -# define PAGING_REQ 19 -# define NOTIFICATION_IND 20 - -//---------------------------------------------------------- -// Constants -//---------------------------------------------------------- -// Define max length authorized (to be updated later) -# define NAS_MAX_LENGTH 180 // maximum length of a NAS primitive -# define NAS_TL_SIZE 4 // size of the Type+Length fields of the primitive -# define NAS_DATA_MAX_LENGTH NAS_MAX_LENGTH - NAS_TL_SIZE //remaining bytes for the message -# define MAX_RABS 8 * 64 //NB_RAB_MAX * MAX_MOBILES_PER_RG //27 // = MAXURAB -# define MAX_MEASURE_NB 5 - -//Connection Establishment status -// UE -# define TERMINATED 0 -# define ABORTED 1 -# define ALREADY_CONNECTED 2 -// RG + RB Establishment Confirm -# define ACCEPTED 0 -# define FAILURE 1 -//---------------------------------------------------------- - -// Parameter types -//---------------------------------------------------------- -typedef unsigned int nasPeriod_t; // Broadcast repetition period -typedef unsigned short nasBroadcastCategory_t; // identifies the type of data to broadcast (IP signalling/ List of neighbors) -typedef unsigned char nasIMEI_t[14]; // 14 digits of IMEI -typedef unsigned short nasDataLength_t; // Length of the data in the primitive -typedef unsigned short nasCellID_t; // ID of the cell for connection -typedef unsigned int nasLocalConnectionRef_t; // local identifier -typedef unsigned short nasConnectionStatus_t; // connection establishment status -typedef unsigned short nasReleaseCause_t; // connection release cause -typedef unsigned short nasSignalingPriority_t; // priority to use srb3 or srb4 -typedef unsigned short nasRadioBearerId_t; -typedef unsigned short nasQoSTrafficClass_t; //QoS traffic class requested -typedef unsigned short nasIPdscp_t; // DSCP code transported to service NAS -typedef struct nasRBDef { - nasRadioBearerId_t rbId; - nasQoSTrafficClass_t QoSclass; - nasIPdscp_t dscp; -} nasrbParms_t; -typedef unsigned int nasSapId_t; // Id of the QoS SAP to use -typedef unsigned short nasRBEstablishStatus_t; // radio bearer establishment status -typedef unsigned short nasNumRBsInList_t; // number of RBs defined in the list -typedef nasrbParms_t nasRBList_t[MAX_RABS]; // List of Rbs for handover -typedef unsigned short nasNumRGsMeas_t; // number of RGs that could be measured -typedef unsigned int nasPagingUEId_t; // Cell_Id of the mobile, = Local Conn Ref -typedef unsigned int nasSigLevel_t; // Signal level measured -typedef struct nasMeasures { - nasCellID_t cell_id; - nasSigLevel_t level; -} nasMeasures_t; - -//---------------------------------------------------------- -// Primitive definitions -//---------------------------------------------------------- -// -- SAP-GC -struct NASInfoBroadcastReq { - nasPeriod_t period; // 0 = one-shot, otherwise in x 10 ms - nasBroadcastCategory_t category; - nasDataLength_t nasDataLength; -}; -struct NASInfoBroadcastInd { - nasDataLength_t nasDataLength; -}; -struct nas_ue_gc_element { - unsigned short type; - unsigned short length; - union { - struct NASInfoBroadcastInd broadcast_ind; - } nasUEGCPrimitive; -}; -struct nas_rg_gc_element { - unsigned short type; - unsigned short length; - union { - struct NASInfoBroadcastReq broadcast_req; - } nasRGGCPrimitive; -}; - -// -- SAP-DC -struct NASConnEstablishReq { - nasLocalConnectionRef_t localConnectionRef; //provided by NAS - nasCellID_t cellId; -}; -struct NASConnEstablishInd { - nasLocalConnectionRef_t localConnectionRef; - nasIMEI_t InterfaceIMEI; -}; -struct NASConnEstablishConf { - nasLocalConnectionRef_t localConnectionRef; - nasConnectionStatus_t status; // can be : Accepted, Failure - nasNumRBsInList_t num_RBs; // actual number of RBs in the list - nasRBList_t RB_List; -}; -struct NASConnEstablishResp { - nasLocalConnectionRef_t localConnectionRef; - nasIMEI_t InterfaceIMEI; - nasConnectionStatus_t status; // can be : Terminated, Aborted , Already_Connected -}; -struct NASConnReleaseReq { - nasLocalConnectionRef_t localConnectionRef; - nasReleaseCause_t releaseCause; -}; -struct NASConnReleaseInd { - nasLocalConnectionRef_t localConnectionRef; - nasReleaseCause_t releaseCause; -}; -struct NASConnLossInd { - nasLocalConnectionRef_t localConnectionRef; -}; -struct NASDataReq { - nasLocalConnectionRef_t localConnectionRef; - nasSignalingPriority_t priority; - nasDataLength_t nasDataLength; -}; -struct NASDataInd { - nasLocalConnectionRef_t localConnectionRef; - nasSignalingPriority_t priority; - nasDataLength_t nasDataLength; -}; -struct NASrbEstablishReq { - nasLocalConnectionRef_t localConnectionRef; - nasRadioBearerId_t rbId; - nasQoSTrafficClass_t QoSclass; - nasIPdscp_t dscp; -}; -struct NASrbEstablishInd { - nasLocalConnectionRef_t localConnectionRef; - nasRadioBearerId_t rbId; - nasQoSTrafficClass_t QoSclass; - nasIPdscp_t dscp; - nasSapId_t sapId; -}; -struct NASrbEstablishConf { - nasLocalConnectionRef_t localConnectionRef; - nasRadioBearerId_t rbId; - nasSapId_t sapId; - nasRBEstablishStatus_t status; // can be : Accepted, Failure -}; -struct NASrbReleaseReq { - nasLocalConnectionRef_t localConnectionRef; - nasRadioBearerId_t rbId; -}; -struct NASrbReleaseInd { - nasLocalConnectionRef_t localConnectionRef; - nasRadioBearerId_t rbId; -}; -struct NASMeasureReq { - nasLocalConnectionRef_t localConnectionRef; -}; -struct NASMeasureInd { - nasLocalConnectionRef_t localConnectionRef; - nasNumRGsMeas_t nb_rg; - nasMeasures_t measures[MAX_MEASURE_NB]; -}; - -/***** - * UE Primitives - *****/ -struct nas_ue_dc_element { - unsigned short type; - unsigned short length; - union { - struct NASConnEstablishReq conn_establish_req; - struct NASConnEstablishResp conn_establish_resp; - - // struct NASConnReleaseInd conn_release_ind; - struct NASConnReleaseReq conn_release_req; - struct NASConnLossInd conn_loss_ind; - struct NASDataReq data_transfer_req; - struct NASDataInd data_transfer_ind; - struct NASrbEstablishInd rb_establish_ind; - struct NASrbReleaseInd rb_release_ind; - struct NASMeasureInd measurement_ind; - struct NASMeasureReq measurement_req; - } nasUEDCPrimitive; -}; - -/***** - * RG Primitives - *****/ -struct nas_rg_dc_element { - unsigned short type; - unsigned short length; - union { - struct NASConnEstablishInd conn_establish_ind; - struct NASConnEstablishConf conn_establish_conf; - struct NASConnReleaseInd conn_release_ind; - - // struct NASConnReleaseReq conn_release_req; - struct NASConnLossInd conn_loss_ind; - struct NASDataReq data_transfer_req; - struct NASDataInd data_transfer_ind; - struct NASrbEstablishReq rb_establish_req; - struct NASrbEstablishConf rb_establish_conf; - struct NASrbReleaseReq rb_release_req; - } nasRGDCPrimitive; -}; - -// -- SAP-NT -struct NASPagingReq { - nasPagingUEId_t UeId; - nasDataLength_t nasDataLength; -}; -struct NASNotificationInd { - nasDataLength_t nasDataLength; -}; -struct nas_ue_nt_element { - unsigned short type; - unsigned short length; - union { - struct NASNotificationInd notification_ind; - } nasUENTPrimitive; -}; -struct nas_rg_nt_element { - unsigned short type; - unsigned short length; - union { - struct NASPagingReq paging_req; - } nasRGNTPrimitive; -}; - -#endif diff --git a/openair2/NETWORK_DRIVER/MESH/sap.h b/openair2/NETWORK_DRIVER/MESH/sap.h deleted file mode 100644 index 60b8fa11fb..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/sap.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - graal_sap.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : michelle.wetterwald@eurecom.fr - yan.moret@eurecom.fr - *************************************************************************** - - ***************************************************************************/ - -#ifndef _NAS_SAP_H -#define _NAS_SAP_H - - -// RT-FIFO identifiers ** must be identical to Access Stratum as_sap.h and rrc_sap.h - -#define RRC_DEVICE_GC RRC_SAPI_GCSAP -#define RRC_DEVICE_NT RRC_SAPI_NTSAP -#define RRC_DEVICE_DC_INPUT0 RRC_SAPI_DCSAP_IN -#define RRC_DEVICE_DC_OUTPUT0 RRC_SAPI_DCSAP_OUT - - -//FIFO indexes in control blocks - -#define NAS_DC_INPUT_SAPI 0 -#define NAS_DC_OUTPUT_SAPI 1 -#define NAS_SAPI_CX_MAX 2 - -#define NAS_GC_SAPI 0 -#define NAS_NT_SAPI 1 - -#define NAS_RAB_INPUT_SAPI 2 -#define NAS_RAB_OUTPUT_SAPI 3 - - -#define NAS_SAPI_MAX 4 - - - - -#endif - - - diff --git a/openair2/NETWORK_DRIVER/MESH/tool.c b/openair2/NETWORK_DRIVER/MESH/tool.c deleted file mode 100644 index a8d359f9ff..0000000000 --- a/openair2/NETWORK_DRIVER/MESH/tool.c +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "local.h" -#include "proto_extern.h" - -//#include -//#include -//#include -//#include -//#include -//#include - -//#define NAS_DEBUG_TOOL 1 - -//--------------------------------------------------------------------------- -// -void nas_TOOL_fct(struct classifier_entity *gc, uint8_t fct) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_FCT - begin \n"); -#endif - - if (gc==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_FCT - input parameter gc is NULL \n"); -#endif - return; - } - - // End debug information - switch(fct) { - case NAS_FCT_QOS_SEND: - gc->fct=nas_COMMON_QOS_send; - break; - - case NAS_FCT_CTL_SEND: - gc->fct=nas_CTL_send; - break; - - case NAS_FCT_DC_SEND: - gc->fct=nas_mesh_DC_send_sig_data_request; - break; - - case NAS_FCT_DEL_SEND: - gc->fct=nas_COMMON_del_send; - break; - - default: - gc->fct=nas_COMMON_del_send; - } -} - -//--------------------------------------------------------------------------- -uint8_t nas_TOOL_invfct(struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_INVFCT - begin \n"); -#endif - - if (gc==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_INVFCT - input parameter gc is NULL \n"); -#endif - return 0; - } - - // End debug information - if (gc->fct==nas_COMMON_QOS_send) - return NAS_FCT_QOS_SEND; - - if (gc->fct==nas_CTL_send) - return NAS_FCT_CTL_SEND; - - if (gc->fct==nas_COMMON_del_send) - return NAS_FCT_DEL_SEND; - - if (gc->fct==nas_mesh_DC_send_sig_data_request) - - return NAS_FCT_DC_SEND; - - return 0; -} - -//--------------------------------------------------------------------------- -uint8_t nas_TOOL_get_dscp6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_DSCP6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_DSCP6 - input parameter iph is NULL \n"); -#endif - return 0; - } - - // End debug information - return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>22; - //return ntohs(*(const __be16 *)iph) >> 4; // see linux/dsfield.h - -} - -//--------------------------------------------------------------------------- -uint8_t nas_TOOL_get_dscp4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_DSCP4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_DSCP4 - input parameter iph is NULL \n"); -#endif - return 0; - } - - // End debug information - return (iph->tos); - -} - -//--------------------------------------------------------------------------- -int nas_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, uint8_t plen) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK6 - begin \n"); -#endif - - if (addr==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK6 - input parameter addr is NULL \n"); -#endif - return 0; - } - - if (prefix==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK6 - input parameter prefix is NULL \n"); -#endif - return 0; - } - - // End debug information - switch(plen/32) { - case 0: - return (((addr->s6_addr32[0]>>(32-plen))<<(32-plen))==prefix->s6_addr[0]); - - case 1: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (((addr->s6_addr32[1]>>(64-plen))<<(64-plen))==prefix->s6_addr[1])); - - case 2: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (((addr->s6_addr32[2]>>(96-plen))<<(96-plen))==prefix->s6_addr[2])); - - case 3: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (addr->s6_addr32[2]==prefix->s6_addr[2])&& - (((addr->s6_addr32[3]>>(128-plen))<<(128-plen))==prefix->s6_addr[3])); - - default: - return ((addr->s6_addr32[0]==prefix->s6_addr[0])&& - (addr->s6_addr32[1]==prefix->s6_addr[1])&& - (addr->s6_addr32[2]==prefix->s6_addr[2])&& - (addr->s6_addr32[3]==prefix->s6_addr[3])); - } -} - -//--------------------------------------------------------------------------- -int nas_TOOL_network4(uint32_t *addr, uint32_t *prefix, uint8_t plen) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK4 - begin \n"); -#endif - - if (addr==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK4 - input parameter addr is NULL \n"); -#endif - return 0; - } - - if (prefix==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_NETWORK4 - input parameter prefix is NULL \n"); -#endif - return 0; - } - - // End debug information - if (plen>=32) - return (*addr==*prefix); - else - return (((*addr>>(32-plen))<<(32-plen))==*prefix); -} - -//--------------------------------------------------------------------------- -//struct udphdr *nas_TOOL_get_udp6(struct ipv6hdr *iph){ -//--------------------------------------------------------------------------- -// return (struct udphdr *)((char *)iph+NAS_IPV6_SIZE); // to modify -//} - -//--------------------------------------------------------------------------- -uint8_t *nas_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - uint16_t size; - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL6 - input parameter iph is NULL \n"); -#endif - return NULL; - } - - if (protocol==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL6 - input parameter protocol is NULL \n"); -#endif - return NULL; - } - - // End debug information - *protocol=iph->nexthdr; - size=NAS_IPV6_SIZE; - - while (1) { - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMPV6: - return (uint8_t *)((uint8_t *)iph+size); - - case IPPROTO_HOPOPTS: - case IPPROTO_ROUTING: - case IPPROTO_DSTOPTS: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]*8+8; - break; - - case IPPROTO_FRAGMENT: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]+8; - break; - - case IPPROTO_NONE: - case IPPROTO_AH: - case IPPROTO_ESP: - default: - return NULL; - } - } -} - -//--------------------------------------------------------------------------- -uint8_t *nas_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL4 - input parameter iph is NULL \n"); -#endif - return NULL; - } - - if (protocol==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_PROTOCOL4 - input parameter protocol is NULL \n"); -#endif - return NULL; - } - - // End debug information - *protocol=iph->protocol; - - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMP: - return (uint8_t *)((uint8_t *)iph+iph->tot_len); - - default: - return NULL; - } -} - -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void nas_TOOL_imei2iid(uint8_t *imei, uint8_t *iid) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_IMEI2IID - begin \n"); -#endif - - if (imei==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_IMEI2IID - input parameter imei is NULL \n"); -#endif - return; - } - - if (iid==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_IMEI2IID - input parameter iid is NULL \n"); -#endif - return; - } - - // End debug information - memset(iid, 0, NAS_ADDR_LEN); - iid[0] = 0x03; - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 16*imei[4]+imei[5]; - iid[4] = 16*imei[6]+imei[7]; - iid[5] = 16*imei[8]+imei[9]; - iid[6] = 16*imei[10]+imei[11]; - iid[7] = 16*imei[12]+imei[13]; -} - -//struct udphdr *nas_TOOL_get_udp4(struct iphdr *iph) -//{ -// return (struct udphdr *)((char *)iph+NAS_IPV4_SIZE); // to modify -//} - - -//--------------------------------------------------------------------------- -char *nas_TOOL_get_udpmsg(struct udphdr *udph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_UDPMSG - begin \n"); -#endif - - if (udph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_GET_UDPMSG - input parameter udph is NULL \n"); -#endif - return NULL; - } - - // End debug information - return ((char *)udph+sizeof(struct udphdr)); -} - -//--------------------------------------------------------------------------- -// Compute the UDP checksum (the data size must be odd) -uint16_t nas_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, uint8_t proto, uint32_t udplen, void *data) -{ - //--------------------------------------------------------------------------- - uint32_t i; - uint16_t *data16; - uint32_t csum=0; - - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_UDPCKSUM - begin \n"); -#endif - - if (saddr==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_UDPCKSUM - input parameter saddr is NULL \n"); -#endif - return 0; - } - - if (daddr==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_UDPCKSUM - input parameter daddr is NULL \n"); -#endif - return 0; - } - - if (data==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_UDPCKSUM - input parameter data is NULL \n"); -#endif - return 0; - } - - // End debug information - data16=data; - - for (i=0; i<8; ++i) { - csum+=ntohs(saddr->s6_addr16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - for (i=0; i<8; ++i) { - csum+=ntohs(daddr->s6_addr16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - csum+=(udplen>>16); // udplen checksum - - if (csum>0xffff) - csum -= 0xffff; - - csum+=udplen & 0xffff; - - if (csum>0xffff) - csum -= 0xffff; - - csum+=proto; // protocol checksum - - if (csum>0xffff) - csum-=0xffff; - - for (i = 0; 2*i < udplen; i++) { - csum+=ntohs(data16[i]); - - if (csum>0xffff) - csum-=0xffff; - } - - return htons((uint16_t)(~csum)&0xffff); -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_udp(struct udphdr *udph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("PRINT_TOOL_PK_UDP - begin \n"); -#endif - - if (udph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PK_UDP - input parameter udph is NULL \n"); -#endif - return; - } - - // End debug information - if (udph!=NULL) { - printk("UDP:\t source = %u, dest = %u, len = %u, check = %x\n", ntohs(udph->source), ntohs(udph->dest), ntohs(udph->len), udph->check); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_tcp(struct tcphdr *tcph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("PRINT_TOOL_PK_TDP - begin \n"); -#endif - - if (tcph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PK_TDP - input parameter tcph is NULL \n"); -#endif - return; - } - - // End debug information - if (tcph!=NULL) { - printk("TCP:\t source = %u, dest = %u\n", tcph->source, tcph->dest); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_icmp6(struct icmp6hdr *icmph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("PRINT_TOOL_PK_ICMP6 - begin \n"); -#endif - - if (icmph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PK_ICMP6 - input parameter icmph is NULL \n"); -#endif - return; - } - - // End debug information - if (icmph!=NULL) { - printk("ICMPv6:\t type= %d, code = %d\n", icmph->icmp6_type, icmph->icmp6_code); - - switch(icmph->icmp6_type) { - case ICMPV6_DEST_UNREACH: - printk("Destination unreachable\n"); - break; - - case ICMPV6_PKT_TOOBIG: - printk("Packet too big\n"); - break; - - case ICMPV6_TIME_EXCEED: - printk("Time exceeded\n"); - break; - - case ICMPV6_PARAMPROB: - printk("Parameter problem\n"); - break; - - case ICMPV6_ECHO_REQUEST: - printk("Echo request\n"); - break; - - case ICMPV6_ECHO_REPLY: - printk("Echo reply\n"); - break; - - case ICMPV6_MGM_QUERY: - printk("Multicast listener query\n"); - break; - - case ICMPV6_MGM_REPORT: - printk("Multicast listener report\n"); - break; - - case ICMPV6_MGM_REDUCTION: - printk("Multicast listener done\n"); - break; - - case NDISC_ROUTER_SOLICITATION: - printk("Router solicitation\n"); - break; - - case NDISC_ROUTER_ADVERTISEMENT: - printk("Router advertisment\n"); - break; - - case NDISC_NEIGHBOUR_SOLICITATION: - printk("Neighbour solicitation\n"); - break; - - case NDISC_NEIGHBOUR_ADVERTISEMENT: - printk("Neighbour advertisment\n"); - break; - - case NDISC_REDIRECT: - printk("redirect message\n"); - break; - } - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_ipv6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("PRINT_TOOL_PK_IPv6 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PK_IPv6 - input parameter iph is NULL \n"); -#endif - return; - } - - // End debug information - - if (iph!=NULL) { - // char addr[NAS_INET6_ADDRSTRLEN]; - printk("IP:\t version = %u, priority = %u, payload_len = %u\n", iph->version, iph->priority, ntohs(iph->payload_len)); - printk("\t fl0 = %u, fl1 = %u, fl2 = %u\n",iph->flow_lbl[0],iph->flow_lbl[1],iph->flow_lbl[2]); - printk("\t next header = %u, hop_limit = %u\n", iph->nexthdr, iph->hop_limit); - - // inet_ntop(AF_INET6, (void *)(&iph->saddr), addr, NAS_INET6_ADDRSTRLEN); - // printk("\t saddr = %s",addr); - // inet_ntop(AF_INET6, (void *)(&iph->daddr), addr, NAS_INET6_ADDRSTRLEN); - // printk(", daddr = %s\n",addr); - switch(iph->nexthdr) { - case IPPROTO_UDP: - print_TOOL_pk_udp((struct udphdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_TCP: - print_TOOL_pk_tcp((struct tcphdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_ICMPV6: - print_TOOL_pk_icmp6((struct icmp6hdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - case IPPROTO_IPV6: - print_TOOL_pk_ipv6((struct ipv6hdr *)((char *)iph+sizeof(struct ipv6hdr))); - break; - - default: - printk("Unknown upper layer\n"); - } - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_ipv4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("PRINT_TOOL_PK_IPv4 - begin \n"); -#endif - - if (iph==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PK_IPv4 - input parameter iph is NULL \n"); -#endif - return; - } - - // End debug information - - if (iph!=NULL) { - // char addr[NAS_INET_ADDRSTRLEN]; - printk("IP:\t version = %u, IP length = %u\n", iph->version, iph->ihl); - // inet_ntop(AF_INET, (void *)(&iph->saddr), addr, NAS_INET_ADDRSTRLEN); - // printk("\t saddr = %s", addr); - // inet_ntop(AF_INET, (void *)(&iph->saddr), addr, NAS_INET_ADDRSTRLEN); - // printk("\t saddr = %s", addr); - } -} - -//--------------------------------------------------------------------------- -void print_TOOL_pk_all(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - printk("Skb:\t %p, len = %u\n", skb, skb->len); - //navid: need to calculate the current used space: fixme? - printk("Skb:\t available buf space = %u \n", skb->truesize); - - switch (ntohs(skb->protocol)) { - case ETH_P_IPV6: - print_TOOL_pk_ipv6((struct ipv6hdr *)skb_network_header(skb)); - break; - - case ETH_P_IP: - print_TOOL_pk_ipv4((struct iphdr *)skb_network_header(skb)); - break; - } -} - -//--------------------------------------------------------------------------- -/*int isdigit(char c) -{ - switch(c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return 1; - default: - return 0; - } -}*/ - -/*int nas_TOOL_inet_pton4(char *src, uint32_t *dst) -{ - uint32_t val; - int n; - uint8_t c; - uint32_t parts[4]; - - c = *src; - val=0; - n=0 - for (;;) - { - for (;;) - { - if (isdigit(c)) - { - val = (val * 10) + c - '0'; - c = *++src; - } - else - break; - } - if (c == '.') - { - if (n>4) - return -1; - parts[n]=val; - c = *++src; - ++n; - } - else - break; - } - if ((c != '\0')||(n!=3)) - return (0); - if ((parts[0] | parts[1] | parts[2] | val) > 256) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - if (dst) - dst = htonl(val); - return (1); -}*/ - -//--------------------------------------------------------------------------- -void print_TOOL_state(uint8_t state) -{ - //--------------------------------------------------------------------------- - // case NAS_STATE_IDLE:printk(" State NAS_STATE_IDLE\n");return; - // case NAS_STATE_CONNECTED:printk(" State NAS_STATE_CONNECTED\n");return; - // case NAS_STATE_ESTABLISHMENT_REQUEST:printk(" State NAS_STATE_ESTABLISHMENT_REQUEST\n");return; - // case NAS_STATE_ESTABLISHMENT_FAILURE:printk(" State NAS_STATE_ESTABLISHMENT_FAILURE\n");return; - // case NAS_STATE_RELEASE_FAILURE:printk(" State NAS_STATE_RELEASE_FAILURE\n");return; - - switch(state) { - case NAS_IDLE: - printk("NAS_IDLE\n"); - return; - - case NAS_CX_FACH: - printk("NAS_CX_FACH\n"); - return; - - case NAS_CX_DCH: - printk("NAS_CX_DCH\n"); - return; - - case NAS_CX_RECEIVED: - printk("NAS_CX_RECEIVED\n"); - return; - - case NAS_CX_CONNECTING: - printk("NAS_CX_CONNECTING\n"); - return; - - case NAS_CX_RELEASING: - printk("NAS_CX_RELEASING\n"); - return; - - case NAS_CX_CONNECTING_FAILURE: - printk("NAS_CX_CONNECTING_FAILURE\n"); - return; - - case NAS_CX_RELEASING_FAILURE: - printk("NAS_CX_RELEASING_FAILURE\n"); - return; - - case NAS_RB_ESTABLISHING: - printk("NAS_RB_ESTABLISHING\n"); - return; - - case NAS_RB_RELEASING: - printk("NAS_RB_RELEASING\n"); - return; - - case NAS_RB_DCH: - printk("NAS_RB_DCH\n"); - return; - - default: - printk(" Unknown state\n"); - } -} - -//----------------------------------------------------------------------------- -// Print the content of a buffer in hexadecimal -void nas_tool_print_buffer(char * buffer,int length) -{ - //----------------------------------------------------------------------------- - int i; - - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PRINT_BUFFER - begin \n"); -#endif - - if (buffer==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_TOOL_PRINT_BUFFER - input parameter buffer is NULL \n"); -#endif - return; - } - - // End debug information - printk("\nBuffer content: "); - - for (i=0; irab_id, rb->sapi, rb->qos); - printk("state %d, retry %d, countimer %d\n",rb->state, rb->retry, rb->countimer); -}; - -//----------------------------------------------------------------------------- -void nas_print_classifier(struct classifier_entity *gc) -{ - //----------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("NAS_PRINT_GC_ENTITY - begin \n"); -#endif - - if (gc==NULL) { -#ifdef NAS_DEBUG_TOOL - printk("NAS_PRINT_GC_ENTITY - input parameter gc is NULL \n"); -#endif - return; - } - - // End debug information - printk("\nClassifier content: classref %d, version %d, splen %d, dplen %d,\n", gc->classref, gc->version, gc->splen, gc->dplen); - printk("protocol %d, sport %d, dport %d, rab_id %d\n", gc->protocol, gc->sport, gc->dport, gc->rab_id); - - if (gc->rb != NULL) { - nas_print_rb_entity(gc->rb); - } -}; - - diff --git a/openair2/NETWORK_DRIVER/UE_IP/README b/openair2/NETWORK_DRIVER/UE_IP/README deleted file mode 100644 index e889a08102..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/README +++ /dev/null @@ -1 +0,0 @@ -This the driver for the UE when NAS layer is running in the UE (EPC setting). \ No newline at end of file diff --git a/openair2/NETWORK_DRIVER/UE_IP/common.c b/openair2/NETWORK_DRIVER/UE_IP/common.c deleted file mode 100644 index 05118a5f6b..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/common.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file common.c -* \brief -* \author Navid Nikaein and Raymond Knopp, Lionel GAUTHIER -* \date 2013 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ - -#include "local.h" -#include "proto_extern.h" -#ifndef OAI_NW_DRIVER_USE_NETLINK - #include "rtai_fifos.h" -#endif - - -#include - -#include -#include - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -//#define OAI_DRV_DEBUG_SEND -//#define OAI_DRV_DEBUG_RECEIVE - -void -ue_ip_common_class_wireless2ip( - sdu_size_t data_lenP, - void *pdcp_sdu_pP, - int instP, - rb_id_t rb_idP) { - //--------------------------------------------------------------------------- - struct sk_buff *skb_p = NULL; - ipversion_t *ipv_p = NULL; - ue_ip_priv_t *gpriv_p = netdev_priv(ue_ip_dev[instP]); - unsigned int hard_header_len = 0; -#ifdef OAI_DRV_DEBUG_RECEIVE - int i; - unsigned char *addr_p = 0; -#endif - unsigned char protocol; - struct iphdr *network_header_p = NULL; -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__, rb_idP,instP,data_lenP); -#endif - skb_p = dev_alloc_skb( data_lenP + 2 ); - - if(!skb_p) { - printk("[UE_IP_DRV][%s] low on memory\n",__FUNCTION__); - ++gpriv_p->stats.rx_dropped; - return; - } - - skb_reserve(skb_p,2); - memcpy(skb_put(skb_p, data_lenP), pdcp_sdu_pP,data_lenP); - skb_p->dev = ue_ip_dev[instP]; - hard_header_len = ue_ip_dev[instP]->hard_header_len; - skb_set_mac_header(skb_p, 0); - skb_set_network_header(skb_p, hard_header_len); - skb_p->mark = rb_idP; - //printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb_p->pkt_type,PACKET_HOST,PACKET_BROADCAST); - skb_p->pkt_type = PACKET_HOST; -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] Receiving packet of size %d from PDCP \n",__FUNCTION__, skb_p->len); - - for (i=0; ilen; i++) { - printk("%2x ",((unsigned char *)(skb_p->data))[i]); - } - - printk("\n"); -#endif -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] skb_p->data @ %p\n",__FUNCTION__, skb_p->data); - printk("[UE_IP_DRV][%s] skb_p->mac_header @ %p\n",__FUNCTION__, skb_p->mac_header); -#endif - // LG TEST skb_p->ip_summed = CHECKSUM_NONE; - skb_p->ip_summed = CHECKSUM_UNNECESSARY; - ipv_p = (ipversion_t *)((void *)&(skb_p->data[hard_header_len])); - - switch (ipv_p->version) { - case 6: -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__); -#endif - skb_set_network_header(skb_p, hard_header_len); - - //skb_p->network_header_p = &skb_p->data[hard_header_len]; - - if (hard_header_len == 0) { - skb_p->protocol = htons(ETH_P_IPV6); - } else { -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET - skb_p->protocol = eth_type_trans(skb_p, ue_ip_dev[instP]); -#else -#endif - } - - //printk("Writing packet with protocol %x\n",ntohs(skb_p->protocol)); - break; - - case 4: -#ifdef OAI_DRV_DEBUG_RECEIVE - //printk("NAS_TOOL_RECEIVE: receive IPv4 message\n"); - addr_p = (unsigned char *)&((struct iphdr *)&skb_p->data[hard_header_len])->saddr; - - if (addr_p) { - printk("[UE_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, addr_p[0],addr_p[1],addr_p[2],addr_p[3]); - } - - addr_p = (unsigned char *)&((struct iphdr *)&skb_p->data[hard_header_len])->daddr; - - if (addr_p) { - printk("[UE_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, addr_p[0],addr_p[1],addr_p[2],addr_p[3]); - } - - printk("[UE_IP_DRV][%s] protocol %d\n",__FUNCTION__, ((struct iphdr *)&skb_p->data[hard_header_len])->protocol); -#endif - skb_set_network_header(skb_p, hard_header_len); - //network_header_p = (struct iphdr *)skb_network_header(skb_p); - network_header_p = (struct iphdr *)skb_network_header(skb_p); - protocol = network_header_p->protocol; -#ifdef OAI_DRV_DEBUG_RECEIVE - - switch (protocol) { - case IPPROTO_IP: - printk("[UE_IP_DRV][%s] Received Raw IPv4 packet\n",__FUNCTION__); - break; - - case IPPROTO_IPV6: - printk("[UE_IP_DRV][%s] Received Raw IPv6 packet\n",__FUNCTION__); - break; - - case IPPROTO_ICMP: - printk("[UE_IP_DRV][%s] Received Raw ICMP packet\n",__FUNCTION__); - break; - - case IPPROTO_TCP: - printk("[UE_IP_DRV][%s] Received TCP packet\n",__FUNCTION__); - break; - - case IPPROTO_UDP: - printk("[UE_IP_DRV][%s] Received UDP packet\n",__FUNCTION__); - break; - - default: - break; - } - -#endif - - if (hard_header_len == 0) { - skb_p->protocol = htons(ETH_P_IP); - } - - //printk("[UE_IP_DRV][COMMON] Writing packet with protocol %x\n",ntohs(skb_p->protocol)); - break; - - default: - printk("[UE_IP_DRV][%s] begin RB %ld Inst %d Length %d bytes\n",__FUNCTION__,rb_idP,instP,data_lenP); - printk("[UE_IP_DRV][%s] Inst %d: receive unknown message (version=%d)\n",__FUNCTION__,instP,ipv_p->version); - } - - ++gpriv_p->stats.rx_packets; - gpriv_p->stats.rx_bytes += data_lenP; -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] sending packet of size %d to kernel\n",__FUNCTION__,skb_p->len); - - for (i=0; ilen; i++) { - printk("%2x ",((unsigned char *)(skb_p->data))[i]); - } - - printk("\n"); -#endif //OAI_DRV_DEBUG_RECEIVE - netif_rx_ni(skb_p); -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] end\n",__FUNCTION__); -#endif -} - -//--------------------------------------------------------------------------- -// Delete the data -void ue_ip_common_ip2wireless_drop(struct sk_buff *skb_pP, int instP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p=netdev_priv(ue_ip_dev[instP]); - ++priv_p->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) -void -ue_ip_common_ip2wireless( - struct sk_buff *skb_pP, - int instP -) { - //--------------------------------------------------------------------------- - struct pdcp_data_req_header_s pdcph; - ue_ip_priv_t *priv_p=netdev_priv(ue_ip_dev[instP]); - ipversion_t *ipv_p = NULL; - unsigned int hard_header_len = 0; - unsigned char *src_addr = 0; - unsigned char *dst_addr = 0; -#ifdef LOOPBACK_TEST - int i; -#endif -#ifdef OAI_DRV_DEBUG_SEND - int j; -#endif - unsigned int bytes_wrote; - // Start debug information -#ifdef OAI_DRV_DEBUG_SEND - printk("[UE_IP_DRV][%s] inst %d begin \n",__FUNCTION__,instP); -#endif - - if (skb_pP==NULL) { -#ifdef OAI_DRV_DEBUG_SEND - printk("[UE_IP_DRV][%s] input parameter skb is NULL \n",__FUNCTION__); -#endif - return; - } - - pdcph.data_size = skb_pP->len; - - if (skb_pP->mark) { - pdcph.rb_id = skb_pP->mark; - } else { - pdcph.rb_id = UE_IP_DEFAULT_RAB_ID; - } - - pdcph.inst = instP; - //pass source/destination IP addresses to PDCP header - hard_header_len = ue_ip_dev[instP]->hard_header_len; - ipv_p = (ipversion_t *)((void *)&(skb_pP->data[hard_header_len])); - - switch (ipv_p->version) { - case 6: - printk("[UE_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__); - //TODO - break; - - case 4: - src_addr = (unsigned char *)&((struct iphdr *)&skb_pP->data[hard_header_len])->saddr; - - if (src_addr) { - printk("[UE_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, src_addr[0],src_addr[1],src_addr[2],src_addr[3]); - } - - dst_addr = (unsigned char *)&((struct iphdr *)&skb_pP->data[hard_header_len])->daddr; - - if (dst_addr) { - printk("[UE_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, dst_addr[0],dst_addr[1],dst_addr[2],dst_addr[3]); - } - - //get Ipv4 address and pass to PCDP header - printk("[UE_IP_DRV] source Id: 0x%08x\n",pdcph.sourceL2Id ); - printk("[UE_IP_DRV] destinationL2Id Id: 0x%08x\n",pdcph.destinationL2Id ); - pdcph.sourceL2Id = ntohl( ((struct iphdr *)&skb_pP->data[hard_header_len])->saddr) & 0x00FFFFFF; - pdcph.destinationL2Id = ntohl( ((struct iphdr *)&skb_pP->data[hard_header_len])->daddr) & 0x00FFFFFF; - break; - - default: - break; - } - - bytes_wrote = ue_ip_netlink_send((char *)&pdcph,UE_IP_PDCPH_SIZE); -#ifdef OAI_DRV_DEBUG_SEND - printk("[UE_IP_DRV][%s] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n",__FUNCTION__, - bytes_wrote,skb_pP->len); -#endif - - if (bytes_wrote != UE_IP_PDCPH_SIZE) { - printk("[UE_IP_DRV][%s] problem while writing PDCP's header (bytes wrote = %d)\n",__FUNCTION__,bytes_wrote); - printk("rb_id %ld, Wrote %d, Header Size %d \n", pdcph.rb_id, bytes_wrote, UE_IP_PDCPH_SIZE); - priv_p->stats.tx_dropped ++; - return; - } - - bytes_wrote += ue_ip_netlink_send((char *)skb_pP->data,skb_pP->len); - - if (bytes_wrote != skb_pP->len+UE_IP_PDCPH_SIZE) { - printk("[UE_IP_DRV][%s] Inst %d, RB_ID %ld: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %d\n", - __FUNCTION__, - instP, - pdcph.rb_id, - bytes_wrote, - skb_pP->len, - UE_IP_PDCPH_SIZE); // congestion - priv_p->stats.tx_dropped ++; - return; - } - -#ifdef OAI_DRV_DEBUG_SEND - printk("[UE_IP_DRV][%s] Sending packet of size %d to PDCP \n",__FUNCTION__,skb_pP->len); - - for (j=0; jlen; j++) { - printk("%2x ",((unsigned char *)(skb_pP->data))[j]); - } - - printk("\n"); -#endif - priv_p->stats.tx_bytes += skb_pP->len; - priv_p->stats.tx_packets ++; -#ifdef OAI_DRV_DEBUG_SEND - printk("[UE_IP_DRV][%s] end \n",__FUNCTION__); -#endif -} - -//--------------------------------------------------------------------------- -void ue_ip_common_wireless2ip(struct nlmsghdr *nlh_pP) { - //--------------------------------------------------------------------------- - struct pdcp_data_ind_header_s *pdcph_p = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh_pP); - ue_ip_priv_t *priv_p; - priv_p = netdev_priv(ue_ip_dev[pdcph_p->inst]); -#ifdef OAI_DRV_DEBUG_RECEIVE - printk("[UE_IP_DRV][%s] QOS receive from PDCP, size %d, rab %d, inst %d\n",__FUNCTION__, - pdcph_p->data_size,pdcph_p->rb_id,pdcph_p->inst); -#endif - ue_ip_common_class_wireless2ip(pdcph_p->data_size, - (unsigned char *)NLMSG_DATA(nlh_pP) + UE_IP_PDCPH_SIZE, - pdcph_p->inst, - pdcph_p->rb_id); -} - diff --git a/openair2/NETWORK_DRIVER/UE_IP/constant.h b/openair2/NETWORK_DRIVER/UE_IP/constant.h deleted file mode 100644 index 9df54d74d5..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/constant.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "common/openairinterface5g_limits.h" -#ifndef _UE_IP_CST -#define _UE_IP_CST - -#define UE_IP_MAX_LENGTH 180 - -// General Constants -#define UE_IP_MTU 1500 -#define UE_IP_TX_QUEUE_LEN 100 -#define UE_IP_ADDR_LEN 8 -#define UE_IP_INET6_ADDRSTRLEN 46 -#define UE_IP_INET_ADDRSTRLEN 16 -#define UE_IP_DEFAULT_RAB_ID 1 - -#define UE_IP_RESET_RX_FLAGS 0 - - -#define UE_IP_RETRY_LIMIT_DEFAULT (int)5 - -#define UE_IP_MESSAGE_MAXLEN (int)5004 - -#define UE_IP_TIMER_ESTABLISHMENT_DEFAULT (int)12 -#define UE_IP_TIMER_RELEASE_DEFAULT (int)2 -#define UE_IP_TIMER_IDLE UINT_MAX -#define UE_IP_TIMER_TICK HZ - -#define UE_IP_PDCPH_SIZE (int)sizeof(struct pdcp_data_req_header_s) -#define UE_IP_IPV4_SIZE (int)20 -#define UE_IP_IPV6_SIZE (int)40 - - - - -#define UE_IP_NB_INSTANCES_MAX NUMBER_OF_UE_MAX /*MAX_MOBILES_PER_ENB*/ - - -#endif - diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c deleted file mode 100644 index 911514683c..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file device.c -* \brief Networking Device Driver for OpenAirInterface -* \author navid nikaein, Lionel Gauthier, raymond knopp -* \company Eurecom -* \email: raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr - -*/ -/*******************************************************************************/ - -#include "constant.h" -#include "local.h" -#include "proto_extern.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX]; - -#ifdef OAI_NW_DRIVER_USE_NETLINK - extern void ue_ip_netlink_release(void); - extern int ue_ip_netlink_init(void); -#endif - -//--------------------------------------------------------------------------- -int ue_ip_find_inst(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - int i; - - for (i=0; ilock = SPIN_LOCK_UNLOCKED; -#ifdef OAI_DRV_DEBUG_INTERRUPT - printk("INTERRUPT - begin\n"); -#endif - // spin_lock_irqsave(&priv_p->lock,flags); - cxi=0; - // mesh_GC_receive(); - // mesh_DC_receive(naspriv->cx+cxi); -#ifndef OAI_NW_DRIVER_USE_NETLINK - ue_ip_common_wireless2ip(); -#endif - // spin_unlock_irqrestore(&priv_p->lock,flags); -#ifdef OAI_DRV_DEBUG_INTERRUPT - printk("INTERRUPT: end\n"); -#endif - // return 0; -} -#endif //NETLINK -//--------------------------------------------------------------------------- -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) - void ue_ip_timer(struct timer_list *t) -#else - void ue_ip_timer(unsigned long dataP) -#endif -{ - //--------------------------------------------------------------------------- -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) - ue_ip_priv_t *priv_p = from_timer(priv_p, t, timer); -#else - ue_ip_priv_t *priv_p = (ue_ip_priv_t *)dataP; -#endif - spin_lock(&priv_p->lock); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) - mod_timer(&priv_p->timer, jiffies + UE_IP_TIMER_TICK); -#else - (priv_p->timer).function = ue_ip_timer; - (priv_p->timer).expires = jiffies + UE_IP_TIMER_TICK; - (priv_p->timer).data = dataP; - add_timer(&priv_p->timer); -#endif - spin_unlock(&priv_p->lock); - return; - // add_timer(&gpriv->timer); - // spin_unlock(&gpriv->lock); -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is activated by ifconfig -int ue_ip_open(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p=netdev_priv(dev_pP); - // Address has already been set at init -#ifndef OAI_NW_DRIVER_USE_NETLINK - - if (pdcp_2_ue_ip_irq==-EBUSY) { - printk("[UE_IP_DRV][%s] : irq failure\n", __FUNCTION__); - return -EBUSY; - } - -#endif //OAI_NW_DRIVER_USE_NETLINK - - if(!netif_queue_stopped(dev_pP)) { - netif_start_queue(dev_pP); - } else { - netif_wake_queue(dev_pP); - } - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) - timer_setup(&(priv_p->timer), ue_ip_timer, 0); - (priv_p->timer).expires = jiffies+UE_IP_TIMER_TICK; -#else - init_timer(&priv_p->timer); - (priv_p->timer).expires = jiffies+UE_IP_TIMER_TICK; - (priv_p->timer).data = (unsigned long)priv_p; - (priv_p->timer).function = ue_ip_timer; -#endif - //add_timer(&priv_p->timer); - printk("[UE_IP_DRV][%s] name = %s\n", __FUNCTION__, dev_pP->name); - return 0; -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is desactivated -int ue_ip_stop(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p = netdev_priv(dev_pP); - printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__); - del_timer(&(priv_p->timer)); - netif_stop_queue(dev_pP); - // MOD_DEC_USE_COUNT; - printk("[UE_IP_DRV][%s] End\n", __FUNCTION__); - return 0; -} - -//--------------------------------------------------------------------------- -void ue_ip_teardown(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p; - int inst; - printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__); - - if (dev_pP) { - priv_p = netdev_priv(dev_pP); - inst = ue_ip_find_inst(dev_pP); - - if ((inst<0) || (inst>=UE_IP_NB_INSTANCES_MAX)) { - printk("[UE_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__); - return; - } - - printk("[UE_IP_DRV][%s] End\n", __FUNCTION__); - } // check dev_pP - else { - printk("[UE_IP_DRV][%s] Device is null\n", __FUNCTION__); - } -} -//--------------------------------------------------------------------------- -int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP) { - //--------------------------------------------------------------------------- - printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__); - - if (dev_pP->flags & IFF_UP) { - return -EBUSY; - } - - if (map_pP->base_addr != dev_pP->base_addr) { - printk(KERN_WARNING "[UE_IP_DRV][%s] Can't change I/O address\n", __FUNCTION__); - return -EOPNOTSUPP; - } - - if (map_pP->irq != dev_pP->irq) { - dev_pP->irq = map_pP->irq; - } - - printk("[UE_IP_DRV][%s] End\n", __FUNCTION__); - return 0; -} - -//--------------------------------------------------------------------------- -// -int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - int inst; - - if (dev_pP) { - inst = ue_ip_find_inst(dev_pP); - } else { - printk("[UE_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__); - return -1; - } - - if ((inst>=0) && (inst= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) - netif_trans_update(dev_pP); -#else - dev_pP->trans_start = jiffies; -#endif -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[UE_IP_DRV][%s] step 1\n", __FUNCTION__); -#endif - ue_ip_common_ip2wireless(skb_pP,inst); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[UE_IP_DRV][%s] step 2\n", __FUNCTION__); -#endif - dev_kfree_skb(skb_pP); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[UE_IP_DRV][%s] step 3\n", __FUNCTION__); -#endif - netif_wake_queue(dev_pP); -#ifdef OAI_DRV_DEBUG_DEVICE - printk("[UE_IP_DRV][%s] end\n", __FUNCTION__); -#endif - } else { - printk("[UE_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__); - return(-1); - } - - return 0; -} - -//--------------------------------------------------------------------------- -struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p = netdev_priv(dev_pP); - return &priv_p->stats; -} -//--------------------------------------------------------------------------- -int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP) { - //--------------------------------------------------------------------------- - //struct sockaddr *addr = mac_pP; - printk("[UE_IP_DRV][%s] CHANGE MAC ADDRESS UNSUPPORTED\n", __FUNCTION__); - //memcpy(dev_pP->dev_addr, addr->sa_data, dev_pP->addr_len); - return 0; -} -//--------------------------------------------------------------------------- -int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP) { - //--------------------------------------------------------------------------- - printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtuP); - - if ((mtuP<50) || (mtuP>1500)) { - return -EINVAL; - } - - dev_pP->mtu = mtuP; - return 0; -} -//--------------------------------------------------------------------------- -void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p = netdev_priv(dev_pP); - printk("[UE_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flagsP); - priv_p->rx_flags ^= flagsP; -} - -//--------------------------------------------------------------------------- - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE == 2055) -void ue_ip_tx_timeout(struct net_device *dev_pP, unsigned int txqueue) -#else -void ue_ip_tx_timeout(struct net_device *dev_pP) -#endif -{ - //--------------------------------------------------------------------------- - // Transmitter timeout, serious problems. - ue_ip_priv_t *priv_p = netdev_priv(dev_pP); - printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__); - // (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++; - (priv_p->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) \ - || (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1796 && RHEL_RELEASE_CODE != 2403) - netif_trans_update(dev_pP); -#else - dev_pP->trans_start = jiffies; -#endif - netif_wake_queue(dev_pP); - printk("[UE_IP_DRV][%s] transmit timed out %s\n", __FUNCTION__,dev_pP->name); -} - -static const struct net_device_ops ue_ip_netdev_ops = { - .ndo_open = ue_ip_open, - .ndo_stop = ue_ip_stop, - .ndo_start_xmit = ue_ip_hard_start_xmit, - .ndo_validate_addr = NULL, - .ndo_get_stats = ue_ip_get_stats, - .ndo_set_mac_address = ue_ip_set_mac_address, - .ndo_set_config = ue_ip_set_config, - .ndo_do_ioctl = NULL, -#if defined(RHEL_RELEASE_CODE) - #if (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 5)) && (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0)) - .extended.ndo_change_mtu = ue_ip_change_mtu, - #else - .ndo_change_mtu = ue_ip_change_mtu, - #endif -#else - .ndo_change_mtu = ue_ip_change_mtu, -#endif - .ndo_tx_timeout = ue_ip_tx_timeout, - .ndo_change_rx_flags = ue_ip_change_rx_flags, -}; -/*.ndo_set_multicast_list = NULL,*/ - -//--------------------------------------------------------------------------- -// Initialisation of the network device -void ue_ip_init(struct net_device *dev_pP) { - //--------------------------------------------------------------------------- - ue_ip_priv_t *priv_p = NULL; - - if (dev_pP) { - priv_p = netdev_priv(dev_pP); - memset(priv_p, 0, sizeof(ue_ip_priv_t)); - spin_lock_init(&priv_p->lock); - dev_pP->netdev_ops = &ue_ip_netdev_ops; - dev_pP->hard_header_len = 0; - dev_pP->addr_len = UE_IP_ADDR_LEN; - dev_pP->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; - dev_pP->tx_queue_len = UE_IP_TX_QUEUE_LEN; - dev_pP->mtu = UE_IP_MTU; - } else { - printk("[UE_IP_DRV][%s] ERROR, Device is NULL!!\n", __FUNCTION__); - return; - } -} -//--------------------------------------------------------------------------- -int init_module (void) { - //--------------------------------------------------------------------------- - int err,inst; - char devicename[100]; - // Initialize parameters shared with RRC - printk("[UE_IP_DRV][%s] Starting OAI IP driver", __FUNCTION__); - - for (inst=0; instname); - } else { - printk("[UE_IP_DRV][%s] registering device %s, ifindex = %d\n\n", __FUNCTION__,ue_ip_dev[inst]->name, ue_ip_dev[inst]->ifindex); - } - } - } - - printk("[UE_IP_DRV][%s] NETLINK INIT\n", __FUNCTION__); - - if ((err=ue_ip_netlink_init()) == -1) { - printk("[UE_IP_DRV][%s] NETLINK failed\n", __FUNCTION__); - } - - return err; -} - -//--------------------------------------------------------------------------- -void cleanup_module(void) { - //--------------------------------------------------------------------------- - int inst; - printk("[UE_IP_DRV][CLEANUP] begin\n"); - - for (inst=0; inst"DRV_COPYRIGHT - - diff --git a/openair2/NETWORK_DRIVER/UE_IP/local.h b/openair2/NETWORK_DRIVER/UE_IP/local.h deleted file mode 100644 index 8a89d7a9de..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/local.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - local.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr, - knopp@eurecom.fr - - ***************************************************************************/ - -#ifndef UE_IP_LOCAL_H -#define UE_IP_LOCAL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -#include "constant.h" -#include "common/platform_types.h" -#include "sap.h" - -typedef struct ue_ip_priv_s { - int irq; - int rx_flags; - struct timer_list timer; - spinlock_t lock; - struct net_device_stats stats; - uint8_t retry_limit; - uint32_t timer_establishment; - uint32_t timer_release; - struct sock *nl_sk; - uint8_t nlmsg[UE_IP_PRIMITIVE_MAX_LENGTH+sizeof(struct nlmsghdr)]; - uint8_t xbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // transmission buffer - uint8_t rbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // reception buffer -} ue_ip_priv_t; - -typedef struct ipversion_s { -#if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t reserved:4, - version:4; -#else - uint8_t version:4, - reserved:4; -#endif -} ipversion_t; - - -typedef struct pdcp_data_req_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_s { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t dummy_traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; -} pdcp_data_ind_header_t; - - - -extern struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX]; - - -#endif diff --git a/openair2/NETWORK_DRIVER/UE_IP/netlink.c b/openair2/NETWORK_DRIVER/UE_IP/netlink.c deleted file mode 100644 index b3829c51d1..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/netlink.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file netlink.c -* \brief establish a netlink -* \author Navid Nikaein, Lionel Gauthier, Raymond knopp -* \company Eurecom -* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr -*/ - -//#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "local.h" -#include "proto_extern.h" - -MODULE_LICENSE("OAI"); - -#define OAI_IP_DRIVER_NETLINK_ID 31 -#define NL_DEST_PID 1 - -/******************************************************************************* -Prototypes -*******************************************************************************/ -static inline void nasmesh_lock(void); -static inline void nasmesh_unlock(void); -static void nas_nl_data_ready (struct sk_buff *skb); -int ue_ip_netlink_init(void); - -static struct sock *nas_nl_sk = NULL; -static int exit_netlink_thread=0; - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) -struct netlink_kernel_cfg cfg = { - .input = nas_nl_data_ready, -}; -#endif - -static DEFINE_MUTEX(nasmesh_mutex); - - -static inline void nasmesh_lock(void) -{ - mutex_lock(&nasmesh_mutex); -} - -static inline void nasmesh_unlock(void) -{ - mutex_unlock(&nasmesh_mutex); -} - -// This can also be implemented using thread to get the data from PDCP without blocking. -static void nas_nl_data_ready (struct sk_buff *skb) -{ - // wake_up_interruptible(skb->sk->sk_sleep); - //nasmesh_lock(); - //netlink_rcv_skb(skb, &my_rcv_msg);// my_rcv_msg is the call back func> - //nasmesh_unlock(); - - struct nlmsghdr *nlh = NULL; - - if (skb) { -#ifdef NETLINK_DEBUG - printk("[UE_IP_DRV][NETLINK] Received socket from PDCP\n"); -#endif //NETLINK_DEBUG - nlh = (struct nlmsghdr *)skb->data; - ue_ip_common_wireless2ip(nlh); - //kfree_skb(skb); // not required, - } -} - - -int ue_ip_netlink_init(void) -{ - - printk("[UE_IP_DRV][NETLINK] Running init ...\n"); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) - cfg.groups = 0; - cfg.input = nas_nl_data_ready; - cfg.cb_mutex = &nasmesh_mutex; - cfg.bind = NULL; - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, -# if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) - THIS_MODULE, -# endif - &cfg); -#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - nas_nl_sk = netlink_kernel_create( - &init_net, - OAI_IP_DRIVER_NETLINK_ID, - 0, - nas_nl_data_ready, - &nasmesh_mutex, // NULL - THIS_MODULE); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */ - - - - if (nas_nl_sk == NULL) { - - printk("[UE_IP_DRV][NETLINK] netlink_kernel_create failed \n"); - return(-1); - } - - - - return(0); - -} - - -void ue_ip_netlink_release(void) -{ - - exit_netlink_thread=1; - printk("[UE_IP_DRV][NETLINK] Releasing netlink socket\n"); - - if(nas_nl_sk) { - netlink_kernel_release(nas_nl_sk); //or skb->sk - - } - - // printk("[UE_IP_DRV][NETLINK] Removing netlink_rx_thread\n"); - //kthread_stop(netlink_rx_thread); - -} - - - - -int ue_ip_netlink_send(unsigned char *data,unsigned int len) -{ - - - struct sk_buff *nl_skb = alloc_skb(NLMSG_SPACE(len),GFP_ATOMIC); - struct nlmsghdr *nlh = (struct nlmsghdr *)nl_skb->data; - int status; - - - // printk("[UE_IP_DRV][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); - skb_put(nl_skb, NLMSG_SPACE(len)); - memcpy(NLMSG_DATA(nlh),data,len); - - nlh->nlmsg_len = NLMSG_SPACE(len); - - - nlh->nlmsg_pid = 0; /* from kernel */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) - NETLINK_CB(nl_skb).pid = 0; -#endif - -#ifdef NETLINK_DEBUG - printk("[UE_IP_DRV][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d\n",nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len); -#endif //DEBUG_NETLINK - - if (nas_nl_sk) { - - // nasmesh_lock(); - status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT); - // mutex_unlock(&nasmesh_mutex); - - if (status < 0) { - printk("[UE_IP_DRV][NETLINK] SEND status is %d\n",status); - return(0); - } else { -#ifdef NETLINK_DEBUG - printk("[UE_IP_DRV][NETLINK] SEND status is %d\n",status); -#endif - return len; - } - } else { - printk("[UE_IP_DRV][SEND] socket is NULL\n"); - return(0); - } -} diff --git a/openair2/NETWORK_DRIVER/UE_IP/proto_extern.h b/openair2/NETWORK_DRIVER/UE_IP/proto_extern.h deleted file mode 100644 index b335b019c1..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/proto_extern.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - proto_extern.h - description - ------------------- - copyright : (C) 2002 by Eurecom - email : navid.nikaein@eurecom.fr - lionel.gauthier@eurecom.fr - knopp@eurecom.fr - -***************************************************************************/ - -#ifndef _UE_IP_PROTO_H -#define _UE_IP_PROTO_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -#include "local.h" - -// device.c - - -/** @defgroup _ue_ip_impl_ OAI Network Device for RRC Lite -* @ingroup _ref_implementation_ -* @{ -\fn int ue_ip_find_inst(struct net_device *dev) -\brief This function determines the instance id for a particular device pointer. -@param dev Pointer to net_device structure - */ -int ue_ip_find_inst(struct net_device *dev); - -// common.c -/** -\fn void ue_ip_common_class_wireless2ip(unsigned short dlen, void* pdcp_sdu,int inst,struct classifier_entity *rclass,OaiNwDrvRadioBearerId_t rb_id) -\brief Receive classified LTE packet, build skbuff struct with it and deliver it to the OS network layer. -@param dlen Length of SDU in bytes -@param pdcp_sdu Pointer to received SDU -@param inst Instance number -@param rb_id Radio Bearer Id - */ -void ue_ip_common_class_wireless2ip(sdu_size_t dlen, - void *pdcp_sdu, - int inst, - rb_id_t rb_id); - -/** -\fn void ue_ip_common_ip2wireless(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst) -\brief Request the transfer of data (QoS SAP) -@param skb pointer to socket buffer -@param inst device instance - */ -void ue_ip_common_ip2wireless(struct sk_buff *skb, int inst); - -/** -\fn void ue_ip_common_ip2wireless_drop(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst) -\brief Drop the IP packet comming from the OS network layer. -@param skb pointer to socket buffer -@param inst device instance - */ -void ue_ip_common_ip2wireless_drop(struct sk_buff *skb, int inst); - -#ifndef OAI_NW_DRIVER_USE_NETLINK -/** -\fn void ue_ip_common_wireless2ip() -\brief Retrieve PDU from PDCP through RT-fifos for delivery to the IP stack. - */ -void ue_ip_common_wireless2ip(void); -#else -/** -\fn void ue_ip_common_wireless2ip(struct nlmsghdr *nlh) -\brief Retrieve PDU from PDCP through netlink sockets for delivery to the IP stack. - */ -void ue_ip_common_wireless2ip(struct nlmsghdr *nlh); -#endif //OAI_NW_DRIVER_USE_NETLINK - - -#ifdef OAI_NW_DRIVER_USE_NETLINK -/** -\fn int ue_ip_netlink_send(unsigned char *data,unsigned int len) -\brief Request the transfer of data by PDCP via netlink socket -@param data pointer to SDU -@param len length of SDU in bytes -@returns Numeber of bytes transfered by netlink socket - */ -int ue_ip_netlink_send(unsigned char *data,unsigned int len); - -/** -\fn void ue_ip_COMMON_QOS_receive(struct nlmsghdr *nlh) -\brief Request a PDU from PDCP -@param nlh pointer to netlink message header - */ -void ue_ip_COMMON_QOS_receive(struct nlmsghdr *nlh); - -#endif //OAI_NW_DRIVER_USE_NETLINK - - -// netlink.c - -void ue_ip_netlink_release(void); -int ue_ip_netlink_init(void); - - -/** @} */ -#endif diff --git a/openair2/NETWORK_DRIVER/UE_IP/sap.h b/openair2/NETWORK_DRIVER/UE_IP/sap.h deleted file mode 100644 index ad70386ed7..0000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/sap.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef UE_IP_SAP_H -#define UE_IP_SAP_H -typedef unsigned short OaiNwDrvRadioBearerId_t; - -#define UE_IP_PRIMITIVE_MAX_LENGTH 180 // maximum length of a NAS primitive - -#endif diff --git a/targets/DOCS/nfapi-L2-emulator-setup.txt b/targets/DOCS/nfapi-L2-emulator-setup.txt index 3e502e2137..daf2ac6395 100644 --- a/targets/DOCS/nfapi-L2-emulator-setup.txt +++ b/targets/DOCS/nfapi-L2-emulator-setup.txt @@ -13,9 +13,6 @@ cd cmake_targets #Execution instuctions (Currently running eNB (VNF) and UE side (PNF) on the same machine using the loopback interface) cd cmake_targets/tools -# Loading nasmesh -source init_nas_nos1 - # Add a new loopback interface address sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up diff --git a/targets/TEST/PACKET_TRACER/Makefile b/targets/TEST/PACKET_TRACER/Makefile deleted file mode 100644 index f49fefe454..0000000000 --- a/targets/TEST/PACKET_TRACER/Makefile +++ /dev/null @@ -1,157 +0,0 @@ -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -TOP_DIR = $(OPENAIR1_DIR) -OPENAIR1_TOP = $(OPENAIR1_DIR) -OPENAIR2_TOP = $(OPENAIR2_DIR) -OPENAIR3_TOP = $(OPENAIR3_DIR) -OPENAIR3 = $(OPENAIR3_DIR) - -CFLAGS += -m32 -DPHYSIM -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 - -ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES - -CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -CFLAGS += -DEMIT_ASN_DEBUG=1 -ifndef OPENAIR2 -OPENAIR2=1 -endif - -# activate OCG and libxml only under linux -ifeq ($(linux),1) -CFLAGS += -I/usr/include/libxml2 -L/usr/local/lib -I/usr/include/atlas -L/usr/X11R6/lib -CFLAGS += -DLINUX -endif - - -ifndef rrc_cellular -rrc_cellular = 0 -rrc_cellular_eNB = 0 -rrc_cellular_UE = 0 -else - ifeq ($(eNB_flag),1) - rrc_cellular_eNB=1 - endif - ifeq ($(UE_flag),1) - rrc_cellular_UE=1 - endif -endif - -ifdef DEBUG_PHY -CFLAGS += -DDEBUG_PHY -endif - -#CFLAGS += -DPDCP_USE_NETLINK -DLINUX -#NAS_FLAG=1 - -#require kernel patch for oai driver to enable address autoconfiguration (IPv6 only) -ifdef ADDCONF -CFLAGS+=-DADDRCONF -endif - - -ifdef TRAFFIC_TM5 -CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 -DFULL_BUFFER=1 -endif - -include $(OPENAIR1_DIR)/PHY/Makefile.inc -include $(OPENAIR1_DIR)/SCHED/Makefile.inc -include $(OPENAIR2_DIR)/LAYER2/Makefile.inc -include $(OPENAIR1_DIR)/SIMULATION/ETH_TRANSPORT/Makefile.inc -include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc -include $(OPENAIR2_DIR)/RRC/NAS/Makefile.inc -include $(OPENAIR2_DIR)/UTIL/Makefile.inc - -ASN1_MSG_OBJS1=$(addprefix $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/, $(ASN1_MSG_OBJS)) -#L2_OBJS = -#EXTRA_CFLAGS = - -export IS_REL10=$(shell if [ -f .lock-rel10 ] ; then echo "1" ; else echo "0" ; fi) -export IS_REL8=$(shell if [ -f .lock-rel8 ] ; then echo "1" ; else echo "0" ; fi) - -ifdef Rel10 -CFLAGS += -DRel10 -ifeq ($(IS_REL10), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-a20.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR_TARGETS)/TEST/PACKET_TRACER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS) ; touch .lock-rel10 ; rm .lock-rel8 ;) -endif -else # default is rel 8 -ifeq ($(IS_REL8), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-86.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR_TARGETS)/TEST/PACKET_TRACER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS); rm -f *.o ; rm -f oaisim ; touch .lock-rel8 ; rm .lock-rel10 ; ) -endif -endif -export IS_REL10=$(shell if [ -f .lock-rel10 ] ; then echo "1" ; else echo "0" ; fi) -export IS_REL8=$(shell if [ -f .lock-rel8 ] ; then echo "1" ; else echo "0" ; fi) - -PT_OBJS = pt.o - -SIMULATION_OBJS += $(TOP_DIR)/SIMULATION/TOOLS/taus.o -SIMULATION_OBJS += $(TOP_DIR)/SIMULATION/TOOLS/rangen_double.o - -OBJ = $(PHY_OBJS) $(SIMULATION_OBJS) $(SCHED_OBJS) $(L2_OBJS) $(TOOLS_OBJS) $(STATS_OBJS) $(ASN1_MSG_OBJS1) $(NAS_OBJS) $(INT_OBJS) $(UTIL_OBJ) - -OBJ += $(OPENAIR_TARGETS)/SIMU/USER/init_lte.o - -all: pt - -printvars: - @echo LINUX variable is $(linux) - @echo rrc_cellular variable is $(rrc_cellular) - @echo EXTRA_CFLAGS = $(EXTRA_CFLAGS) - @echo OAI NETLINK FLAG is $(NAS_FLAG) - @echo SSE3 proc is $(SSE3PROC) - @echo IS_REL_8 is $(IS_REL_8) - @echo IS_REL_10 is $(IS_REL_10) - -$(OBJ): %.o : %.c - @echo Compiling $< - $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DPHY_CONTEXT=1 -I$(TOP_DIR) $(L2_incl) $(UTIL_incl) -I$(ASN1_MSG_INC) -o $@ $< - -pt: $(OBJ) pt.c - @echo "Compiling pt.c ..." - @$(CC) pt.c -I$(TOP_DIR) $(L2_incl) $(UTIL_incl) -I$(ASN1_MSG_INC) -o pt $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) -lm -lblas -lpthread -lxml2 -lX11 -lXpm -lrt -lforms -llapack_atlas - -ifeq ($(rrc_cellular_eNB),1) - mv oaisim oaisim_eNB -endif -ifeq ($(rrc_cellular_UE),1) - mv oaisim oaisim_UE -endif - -nasmesh_fix: - (cd $(OPENAIR2_DIR) && make nasmesh_netlink_address_fix.ko) - (sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko) -nasmesh_nl: - (cd $(OPENAIR2_DIR) && make nasmesh_netlink.ko) - (sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko) -rb_tool: - (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && make) - -nasmesh_install: - (sudo rmmod nasmesh) - (sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko) -clean: - rm -f oaisim - rm -f $(OBJ) - rm -f *.o - rm -f *.exe* - -cleanl1: - rm -f oaisim - rm -f $(PHY_OBJS) $(SCHED_OBJS) - rm -f *.o - rm -f *.exe - -cleanl2: - rm -f $(L2_OBJS) - -cleanasn1: - rm -f $(ASN1_MSG_OBJS1) - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated - -print: - @echo $(CFLAGS) - @echo $(EXTRA_CFLAGS) - @echo $(OBJ) - -showcflags: - @echo $(CFLAGS) diff --git a/targets/TEST/PACKET_TRACER/README.txt b/targets/TEST/PACKET_TRACER/README.txt deleted file mode 100644 index bfd505651f..0000000000 --- a/targets/TEST/PACKET_TRACER/README.txt +++ /dev/null @@ -1,35 +0,0 @@ -This utility allows you to inject packets into the Openair4G stack (UE for the moment) or generate packets -from different parts of the stack. - -To compile: - - make pt - -To get help - - ./pt --help - -Some pregenerated messages (RRC and MAC) can be found in the PACKET_TRACER/messages directory. Here are some -usage examples: - -To generate RRC messages (e.g. SIBx) - -./pt --eNB_RRC --RRCSIB2_3 - -./pt --eNB_RRC --RRCConnectionReconfiguration - -./pt --UE_RRC --RRCConnectionRequest - - -To inject packets into the OpenAir4G stack (This works for UE receiver only for now, with control-plane messasges) - -./pt --eNB_MAC -I messages/Msg4.txt - -./pt -I messages/rrcconnectionsetup.txt -J messages/rrcconnectionreconfiguration.txt --eNB_RRC --RRCConnectionReconfiguration - -./pt -I messages/rrcconnectionsetup.txt --eNB_RRC --RRCConnectionSetup - - -To be done: - - - user-plane tests, in particular out-of-order segments to (MAC->RLC) diff --git a/targets/TEST/PACKET_TRACER/messages/Msg4.txt b/targets/TEST/PACKET_TRACER/messages/Msg4.txt deleted file mode 100644 index 760d141f5e..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/Msg4.txt +++ /dev/null @@ -1 +0,0 @@ -1C5AF0FA9E3966 diff --git a/targets/TEST/PACKET_TRACER/messages/rrcconnectionreconfiguration.txt b/targets/TEST/PACKET_TRACER/messages/rrcconnectionreconfiguration.txt deleted file mode 100644 index e4b976c840..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/rrcconnectionreconfiguration.txt +++ /dev/null @@ -1 +0,0 @@ -21591FA00404200602013D2C3FAC50083A101700300007888000080102900E08484A0202020000000000605A0AA1A3BB4B932B632B9B982808A0A0A322805FB007888000080891A2B3C353E0FA897844866E926E0D80100021F756A900 diff --git a/targets/TEST/PACKET_TRACER/messages/rrcconnectionsetup.txt b/targets/TEST/PACKET_TRACER/messages/rrcconnectionsetup.txt deleted file mode 100644 index 3f72682b08..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/rrcconnectionsetup.txt +++ /dev/null @@ -1 +0,0 @@ -3F0060129B26E0D9E1C952C860C0827030 diff --git a/targets/TEST/PACKET_TRACER/messages/sib1.txt b/targets/TEST/PACKET_TRACER/messages/sib1.txt deleted file mode 100644 index d8f6f01684..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/sib1.txt +++ /dev/null @@ -1 +0,0 @@ -5040040300010000001C1650902080850000 diff --git a/targets/TEST/PACKET_TRACER/messages/sib2.txt b/targets/TEST/PACKET_TRACER/messages/sib2.txt deleted file mode 100644 index 5b16de5778..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/sib2.txt +++ /dev/null @@ -1 +0,0 @@ -00000C60FD6C8160C002A00200141000029AA55696D0C72944C1C000 diff --git a/targets/TEST/PACKET_TRACER/messages/sib2_3_oai.txt b/targets/TEST/PACKET_TRACER/messages/sib2_3_oai.txt deleted file mode 100644 index db929dcd4f..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/sib2_3_oai.txt +++ /dev/null @@ -1 +0,0 @@ -00800f5995648000020a580020000804012f395796dec00a111fe807c1 diff --git a/targets/TEST/PACKET_TRACER/messages/sib2_3_oai_Rel10.txt b/targets/TEST/PACKET_TRACER/messages/sib2_3_oai_Rel10.txt deleted file mode 100644 index 3fed9fc532..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/sib2_3_oai_Rel10.txt +++ /dev/null @@ -1 +0,0 @@ -010101eb32ac900000414b00040001008025e72af2dbd800115542023fd00f83020c000802200000 diff --git a/targets/TEST/PACKET_TRACER/messages/sib3.txt b/targets/TEST/PACKET_TRACER/messages/sib3.txt deleted file mode 100644 index d77c0df378..0000000000 --- a/targets/TEST/PACKET_TRACER/messages/sib3.txt +++ /dev/null @@ -1 +0,0 @@ -00043020384000 diff --git a/targets/TEST/PACKET_TRACER/pt.c b/targets/TEST/PACKET_TRACER/pt.c deleted file mode 100644 index 24c1fe495a..0000000000 --- a/targets/TEST/PACKET_TRACER/pt.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include -#include -#include -#include -#include - -//#include "SIMULATION/TOOLS/defs.h" -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" -#include "MAC_INTERFACE/vars.h" - -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "RRC/LTE/vars.h" -#include "PHY_INTERFACE/vars.h" -#include "UTIL/LOG/log.h" -#include "UTIL/OTG/otg_tx.h" -#include "UTIL/OTG/otg.h" -#include "UTIL/OTG/otg_vars.h" - - -char binary_table[16][5] = {{"0000\0"},{"0001\0"},{"0010\0"},{"0011\0"},{"0100\0"},{"0101\0"},{"0110\0"},{"0111\0"},{"1000\0"},{"1001\0"},{"1010\0"},{"1011\0"},{"1100\0"},{"1101\0"},{"1110\0"},{"1111\0"}}; - -typedef enum { - RRCConnectionRequest=0, - RRCConnectionSetup, - RRCConnectionSetupComplete, - RRCConnectionReconfiguration, - RRCConnectionReconfigurationComplete, - RRCSIB1, - RRCSIB2_3 -} RRC_MESSAGES_t; - -typedef enum { - eNB_RRC=0, - eNB_S1U, - eNB_PDCP, - eNB_RLC_UM, - eNB_RLC_AM, - eNB_RLC_TM, - eNB_MAC, - UE_RRC, - UE_S1U, - UE_PDCP, - UE_RLC_UM, - UE_RLC_AM, - UE_RLC_TM, - eNB_SI -} SDUsource_t; - - -typedef struct { - int verbose; - int RRCmessage; - int lcid; - int rbid; - int SDUsize; - int TBsize; - SDUsource_t SDUsource; - char input1_file[128]; - char input2_file[128]; - char output_file[128]; - unsigned char input1_sdu[1024]; - unsigned char input2_sdu[1024]; - int input1_sdu_flag; - unsigned short input1_sdu_len; - int input2_sdu_flag; - unsigned short input2_sdu_len; - int frame; - int input_sib; - int input_eNB_MAC; -} args_t; - -int input_text(char *file,char *sdu) -{ - - FILE *fd; - int i,b_ind=0; - char c,c0,c1; - unsigned char byte; - - fd = fopen(file,"r"); - - while (!feof(fd)) { - c0 = fgetc(fd); - - if (!feof(fd)) - c1 = fgetc(fd); - else - return(-1); - - byte = 0; - - for (i=0,c=c0; i<2; i++,c=c1) - switch(c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - byte += (c-'0')<<(4*(1-i)); - break; - - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - byte += (10+c-'A')<<(4*(1-i)); - break; - - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - byte += (10+c-'a')<<(4*(1-i)); - break; - - case '\n': - case '\0': - return(b_ind); - break; - - default: - printf("Unknown hex character %c in file\n",c); - return(-1); - break; - } - - sdu[b_ind]=byte; - printf("byte %d: %x (%s%s)\n",b_ind,byte,binary_table[byte>>4],binary_table[byte&0xf]); - b_ind++; - } - if (fd) - fclose(fd); - return(b_ind); -} - - -int parse_args(int argc, char** argv, args_t* args) -{ - int c; - int k; - const struct option long_options[] = { - {"lcid", required_argument, NULL, 256}, - {"rbid", required_argument, NULL, 257}, - {"TBsize", required_argument, NULL, 258}, - {"SDUsize", required_argument, NULL, 259}, - {"eNB_RRC", no_argument, NULL, 260}, - {"eNB_S1U", no_argument, NULL, 261}, - {"eNB_PDCP", no_argument, NULL, 262}, - {"eNB_RLC_UM", no_argument, NULL, 263}, - {"eNB_RLC_AM", no_argument, NULL, 264}, - {"eNB_RLC_TM", no_argument, NULL, 265}, - {"eNB_MAC" , no_argument, NULL, 266}, - {"UE_RRC", no_argument, NULL, 267}, - {"UE_S1U", no_argument, NULL, 268}, - {"UE_PDCP", no_argument, NULL, 269}, - {"UE_RLC_UM", no_argument, NULL, 270}, - {"UE_RLC_AM", no_argument, NULL, 271}, - {"UE_RLC_TM", no_argument, NULL, 272}, - {"RRCConnectionRequest", no_argument, NULL, 273}, - {"RRCConnectionSetup", no_argument, NULL, 274}, - {"RRCConnectionSetupComplete", no_argument, NULL, 275}, - {"RRCConnectionReconfiguration", no_argument, NULL, 276}, - {"RRCConnectionReconfigurationComplete", no_argument, NULL, 277}, - {"RRCSIB1", no_argument, NULL, 278}, - {"RRCSIB2_3", no_argument, NULL, 279}, - {NULL, 0, NULL, 0} - }; - args->frame = 0; - - while((c = getopt_long(argc, argv, "ho:I:J:v", long_options, NULL)) != -1) { - switch(c) { - case 'h': - return 1; - - case 'o': - strcpy(args->output_file,optarg); - break; - - case 'f': - args->frame = atoi(optarg); - break; - - case 'I': - strcpy(args->input1_file,optarg); - args->input1_sdu_len = input_text(args->input1_file,args->input1_sdu); - printf("Got sdu1 of length %u bytes\n",args->input1_sdu_len); - args->input1_sdu_flag=1; - break; - - case 'J': - strcpy(args->input2_file,optarg); - args->input2_sdu_len = input_text(args->input2_file,args->input2_sdu); - printf("Got sdu2 of length %u bytes\n",args->input2_sdu_len); - args->input2_sdu_flag=1; - break; - - case 'v': - args->verbose++; - break; - - case 256: // lchan - args->lcid = atoi(optarg); - break; - - case 257: // - args->rbid = atoi(optarg); - break; - - case 258: - args->TBsize = atoi(optarg); - break; - - case 259: - args->SDUsize = atoi(optarg); - break; - - case 260: //eNB_RRC - case 261: //eNB_S1U - case 262: //eNB_PDCP - case 263: //eNB_RLC_UM - case 264: //eNB_RLC_AM - case 265: //eNB_RLC_TM - case 266: //eNB_MAC - case 267: //UE_RRC - case 268: //UE_S1U - case 269: //UE_PDCP - case 270: //UE_RLC_UM - case 271: //UE_RLC_AM - case 272: //UE_RLC_TM - args->SDUsource = c-260; - break; - - case 273: //RRCConnectionRequest - case 274: //RRCConnectionSetup - case 275: //RRCConnectionSetupComplete - case 276: //RRCConnectionReconfiguration - case 277: //RRCConnectionReconfigurationComplete - case 278: //RRCSIB1 - case 279: //RRCSIB2_3 - args->RRCmessage = c-273; - break; - - default: - return 1; - } - } - - return 0; -} - -void print_usage(const char* prog) -{ - printf("Usage: %s [options]\n", prog); - printf("\n"); - printf(" General options:\n"); - printf(" -h : print usage\n"); - printf(" -v : increase verbosity level [0]\n"); - printf(" -o : output .dat file (binary packet data)\n"); - printf(" -i : input .dat file (binary packet data)\n"); - printf(" -I : input .txt file (ASCII packet data)\n"); - printf("\n"); - printf(" Packet options:\n"); - printf(" --eNB_RRC : set source of packet to eNB_RRC\n"); - printf(" --eNB_S1U : set source of packet to eNB_S1U (e.g. IP)\n"); - printf(" --eNB_PDCP : set source of packet to eNB_PDCP\n"); - printf(" --eNB_RLC_UM : set source of packet to eNB_RLC_UM\n"); - printf(" --eNB_RLC_AM : set source of packet to eNB_RLC_AM\n"); - printf(" --eNB_RLC_TM : set source of packet to eNB_RLC_TM\n"); - printf(" --eNB_MAC : set source of packet to eNB_MAC\n"); - printf(" --UE_RRC : set source of packet to UE_RRC\n"); - printf(" --UE_S1U : set source of packet to UE_S1U (e.g. IP)\n"); - printf(" --UE_PDCP : set source of packet to UE_PDCP\n"); - printf(" --UE_RLC_UM : set source of packet to UE_RLC_UM\n"); - printf(" --UE_RLC_AM : set source of packet to UE RLC_AM\n"); - printf(" --UE_RLC_TM : set source of packet to UE RLC_TM\n"); - printf(" --lchan : set logical channel id\n"); - printf(" --rbid : set radio bearer id\n"); - printf(" --TBsize : set Transport Block Size at MAC layer\n"); - printf(" --SDUsize : set the SDU size used by the originating entity (except RRC)\n"); - printf(" --RRCConnectionSetup : set the SDU to be an RRCConnectionSetup\n"); - printf(" --RRCConnectionSetupComplete : set the SDU to be an RRCConnectionSetupComplete\n"); - printf(" --RRCConnectionRequest : set the SDU to be an RRCConnectionRequest\n"); - printf(" --RRCConnectionReconfiguration : set the SDU to be an RRCConnectionReconfiguration\n"); - printf(" --RRCConnectionReconfigurationComplete : set the SDU to be an RRCConnectionReconfigurationComplete\n"); - printf(" --RRCSIB1 : set the SDU to be an RRCSIB1\n"); - printf(" --RRCSIB2_3 : set the SDU to be an RRCSIB2_3\n"); -} - -u8 attach_ue0(char *sdu) -{ - u8 Size; - u16 Size16; - u8 lcid=0; - - UE_rrc_inst[0].Info[0].State = RRC_SI_RECEIVED; - rrc_ue_generate_RRCConnectionRequest(0,131,0); - - Size = mac_rrc_data_req(0, - 131, - CCCH,1, - &sdu[sizeof(SCH_SUBHEADER_FIXED)],0, - 0); - Size16 = (u16)Size; - - generate_ulsch_header((u8 *)sdu, // mac header - 1, // num sdus - 0, // short padding - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - NULL, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, - 0); // post padding - - return(Size+sizeof(SCH_SUBHEADER_FIXED)); -} - -// This retrieves the RRCConnectionSetup RRC SDU -u8 attach_ue1(char *sdu) -{ - // simulate reception of CCCH at eNB(RRCConnectionRequest) - mac_rrc_lite_data_ind(0,131,0,UE_rrc_inst[0].Srb0[0].Tx_buffer.Payload, - UE_rrc_inst[0].Srb0[0].Tx_buffer.payload_size,1,0); - - return(mac_rrc_data_req(0, - 132, - 0,1, - sdu, - 1, - 0)); -} - -// This retrieves the RRCConnectionSetupComplete RRC SDU -u16 attach_ue2(char *dcch_sdu_eNB, char dcch_sdu_eNB_len, char *dcch_sdu) -{ - - mac_rlc_status_resp_t rlc_status; - u16 sdu_len; - - printf("************* attach_ue2 (CCCH payload %d)\n", - eNB_rrc_inst[0].Srb0.Tx_buffer.payload_size); - // simulate reception of CCCH at UE (RRCConnectionSetup) - mac_rrc_lite_data_ind(0,132,0,dcch_sdu_eNB,dcch_sdu_eNB_len,0,0); - - // simulate transmission of RRCConnectionSetupComplete - rlc_status = mac_rlc_status_ind(1,134,0, - DCCH, - 100); - sdu_len = mac_rlc_data_req(1,133, - DCCH, - dcch_sdu); - - return(sdu_len); -} - -// This retrieves the RRCConnectionReconfiguration RRC SDU -u16 attach_ue3(char *dcch_sdu_ue, char dcch_sdu_ue_len, char *dcch_sdu_eNB) -{ - - mac_rlc_status_resp_t rlc_status; - u16 sdu_len; - - // simulation reception of RRCConnectionSetupComplete - - mac_rlc_data_ind(0,134,1, - DCCH, - dcch_sdu_ue, - dcch_sdu_ue_len, - 1, - NULL); - - /// ... and generation of RRCConnectionReconfiguration - /// First RLC-AM Control SDU (ACK) - rlc_status = mac_rlc_status_ind(0,135,1, - DCCH, - 100); - - sdu_len = mac_rlc_data_req(0,135, - DCCH, - dcch_sdu_eNB); - - mac_rlc_data_ind(1,135,1, - DCCH, - dcch_sdu_eNB, - sdu_len, - 1, - NULL); - - // now RRC message - rlc_status = mac_rlc_status_ind(0,136,1, - DCCH, - 100); - - sdu_len = mac_rlc_data_req(0,136, - DCCH, - dcch_sdu_eNB); - - return(sdu_len); -} - -// This retrieves the RRCConnectionReconfigurationComplete RRC SDU -u16 attach_ue4(char *dcch_sdu_eNB, char dcch_sdu_eNB_len, char *dcch_sdu_ue) -{ - - mac_rlc_status_resp_t rlc_status; - u16 sdu_len; - - // simulation UE reception of RRCConnectionReconfiguration .... - - mac_rlc_data_ind(1,135,0, - DCCH, - dcch_sdu_eNB, - dcch_sdu_eNB_len, - 1, - NULL); - - // ... and generation of RRCConnectionReconfigurationComplete - - - rlc_status = mac_rlc_status_ind(1,135,0, - DCCH, - 100); - - sdu_len = mac_rlc_data_req(1,135, - DCCH, - dcch_sdu_ue); - - rlc_status = mac_rlc_status_ind(1,136,0, - DCCH, - 100); - - sdu_len = mac_rlc_data_req(1,136, - DCCH, - dcch_sdu_ue); - - return(sdu_len); -} - -//u8 NB_INST=2; -const int NB_UE_INST = 1; - -int main (int argc, char **argv) -{ - - args_t args; - LTE_DL_FRAME_PARMS frame_parms0; - LTE_DL_FRAME_PARMS *frame_parms=&frame_parms; - char sdu0[16],sdu1[64],sdu2[1024],sdu3[1024],sdu4[1024]; - unsigned short sdu_len0,sdu_len1,sdu_len2,sdu_len3,sdu_len4; - char ulsch_buffer[1024],dlsch_buffer[1024]; - u8 lcid; - u8 payload_offset; - int i,comp; - - logInit(); - - // Parse arguments - if(parse_args(argc, argv, &args) > 0) { - print_usage(argv[0]); - exit(1); - } - - set_taus_seed(0); - logInit(); - set_glog(LOG_TRACE, 1); - - for (comp = PHY; comp < MAX_LOG_COMPONENTS ; comp++) - set_comp_log(comp, - LOG_TRACE, - LOG_NONE, - 1); - - /* - set_log(OMG, LOG_INFO, 20); - set_log(EMU, LOG_INFO, 10); - set_log(MAC, LOG_TRACE, 1); - set_log(RLC, LOG_TRACE, 1); - set_log(PHY, LOG_DEBUG, 1); - set_log(PDCP, LOG_TRACE, 1); - set_log(RRC, LOG_TRACE, 1); - */ - mac_xface = (MAC_xface *)malloc(sizeof(MAC_xface)); - init_lte_vars (&frame_parms, 0, 1, 0, 0, 25, 0, 0, 1, 1); - l2_init(frame_parms); - - // Generate eNB SI - if (args.input_sib == 0) { - openair_rrc_lite_eNB_init(0); - } else { - printf("Got SI from files (%d,%d,%d)\n", - args.input_sib,args.input1_sdu_flag,args.input2_sdu_flag); - } - - openair_rrc_on(0,0); - openair_rrc_lite_ue_init(0,0); - - switch (args.SDUsource) { - case eNB_RRC: - if (args.RRCmessage == RRCSIB1) { - if (args.input1_sdu_flag == 1) { - for (i=0; i Date: Mon, 15 Jul 2024 19:08:31 +0200 Subject: [PATCH 30/61] Remove --nokrnmod option, as we never use the kernel anyway --- common/config/DOC/config/rtusage.md | 1 - doc/L1SIM.md | 4 ++-- doc/iqrecordplayer_usage.md | 4 ++-- executables/lte-softmodem.c | 2 +- executables/lte-uesoftmodem.c | 9 +++++++-- executables/nr-softmodem-common.h | 2 +- executables/nr-softmodem.c | 2 +- executables/nr-uesoftmodem.c | 11 ++++++++--- executables/softmodem-common.c | 6 +----- executables/softmodem-common.h | 5 ----- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common/config/DOC/config/rtusage.md b/common/config/DOC/config/rtusage.md index 42ef93bffc..3b51e1afd2 100644 --- a/common/config/DOC/config/rtusage.md +++ b/common/config/DOC/config/rtusage.md @@ -68,7 +68,6 @@ To get help on supported parameters you can use specific options: --worker-config: two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE' --nbiot-disable: disable nb-iot, even if defined in config --noS1: Disable s1 interface - --nokrnmod: (noS1 only): Use tun instead of namesh module -------------------------------------------------------------------- [LIBCONFIG] (root): 4/4 parameters successfully set, (4 to default value) diff --git a/doc/L1SIM.md b/doc/L1SIM.md index 56be7f93b6..a78d3c328a 100644 --- a/doc/L1SIM.md +++ b/doc/L1SIM.md @@ -45,7 +45,7 @@ $ source oaienv $ cd cmake_targets/tools $ sudo -E ./init_nas_nos1 eNB $ cd ../ran_build/build -$ sudo -E ./lte-softmodem -O YYY.conf --noS1 --nokrnmod 0 +$ sudo -E ./lte-softmodem -O YYY.conf --noS1 ``` # How to run a UE with the noS1 option @@ -59,7 +59,7 @@ $ source oaienv $ cd cmake_targets/tools $ sudo -E ./init_nas_nos1 UE $ cd ../ran_build/build -$ sudo ./lte-uesoftmodem -O XXX.conf -r 25 --siml1 --noS1 --nokrnmod 0 +$ sudo ./lte-uesoftmodem -O XXX.conf -r 25 --siml1 --noS1 ``` That should give you equivalent functionality to what you had with oaisim including noise and RF channel emulation (path loss / fading, etc.). You should also be able to run multiple UEs. diff --git a/doc/iqrecordplayer_usage.md b/doc/iqrecordplayer_usage.md index 603a74f4b5..69c675c996 100644 --- a/doc/iqrecordplayer_usage.md +++ b/doc/iqrecordplayer_usage.md @@ -33,7 +33,7 @@ than the value of `--subframes-max` parameter. >Recording session example: ```bash -./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --nokrnmod 1 --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-record 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-max 30000 +./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-record 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-max 30000 ............................................ ............................................ ............................................ @@ -54,7 +54,7 @@ options for replay mode are: >Replay mode session example: ```bash -./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --nokrnmod 1 --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-replay 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-loops 1 +./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-replay 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-loops 1 .................................. .................................. [HW] Replay iqs from USRP B200 device, bandwidth 4.000000e+07 diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 5e93068b06..59a58f30dc 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -410,7 +410,7 @@ static void init_pdcp(void) uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_IP_DRIVER_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (IS_SOFTMODEM_NOS1) - pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT; pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_W_MBMS_BIT; diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index eae196c2ef..2373670015 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -494,8 +494,13 @@ static void init_pdcp(int ue_id) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; } - if (IS_SOFTMODEM_NOKRNMOD) - pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + // previous code was: + // if (IS_SOFTMODEM_NOKRNMOD) + // pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + // The kernel module (KRNMOD) has been removed from the project, so the 'if' + // was removed but the flag 'pdcp_initmask' was kept, as "no kernel module" + // was always set. further refactoring could take it out + pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; pdcp_module_init(pdcp_initmask, ue_id); } diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 589bc537f5..c168a1ac0b 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -103,8 +103,8 @@ #define CONFIG_HLP_TELN "Start embedded telnet server \n" #define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" #define CONFIG_HLP_NOS1 "Disable s1 interface\n" -#define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" #define CONFIG_HLP_AGC "Rx Gain control used for UE" + /*--------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters for LOG utility */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 3449af32ae..b196a10970 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -543,7 +543,7 @@ static void wait_nfapi_init(char *thread_name) { void init_pdcp(void) { uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT: + LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (!NODE_IS_DU(get_node_type())) { diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index fd2ef4b397..d64be3125a 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -332,9 +332,14 @@ static void init_pdcp(int ue_id) pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; }*/ - if (IS_SOFTMODEM_NOKRNMOD) { - pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; - } + // previous code was: + // if (IS_SOFTMODEM_NOKRNMOD) + // pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + // The kernel module (KRNMOD) has been removed from the project, so the 'if' + // was removed but the flag 'pdcp_initmask' was kept, as "no kernel module" + // was always set. further refactoring could take it out + pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) { LOG_I(RLC, "Problem at RLC initiation \n"); } diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index 6f5cabdede..be2a79eb64 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -97,7 +97,7 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) uint32_t glog_level=0 ; uint32_t start_telnetsrv = 0, start_telnetclt = 0; uint32_t start_websrv = 0; - uint32_t noS1 = 0, nokrnmod = 1, nonbiot = 0; + uint32_t noS1 = 0, nonbiot = 0; uint32_t rfsim = 0, do_forms = 0; int nfapi_index = 0; char *logmem_filename = NULL; @@ -146,10 +146,6 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) set_softmodem_optmask(SOFTMODEM_NOS1_BIT); } - if (nokrnmod) { - set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT); - } - if (nonbiot) { set_softmodem_optmask(SOFTMODEM_NONBIOT_BIT); } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index a696c064a4..110a5c60a7 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -99,7 +99,6 @@ extern "C" #define CONFIG_HLP_NOS1 "Disable s1 interface\n" #define CONFIG_HLP_RFSIM "Run in rf simulator mode\n" -#define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_NFAPI "Change the nFAPI mode for NR 'MONOLITHIC', 'PNF', 'VNF', 'AERIAL','UE_STUB_PNF','UE_STUB_OFFNET','STANDALONE_PNF'\n" @@ -173,7 +172,6 @@ extern int usrp_tx_thread; {"worker-config", CONFIG_HLP_WORKER_CMD, 0, .strptr=&worker_config, .defstrval=NULL, TYPE_STRING, 0}, \ {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, .uptr=&noS1, .defintval=0, TYPE_UINT, 0}, \ {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, .uptr=&rfsim, .defintval=0, TYPE_UINT, 0}, \ - {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, .uptr=&nokrnmod, .defintval=1, TYPE_UINT, 0}, \ {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, .uptr=&nonbiot, .defuintval=0, TYPE_UINT, 0}, \ {"chest-freq", CONFIG_HLP_CHESTFREQ, 0, .iptr=&CHEST_FREQ, .defintval=0, TYPE_INT, 0}, \ {"chest-time", CONFIG_HLP_CHESTTIME, 0, .iptr=&CHEST_TIME, .defintval=0, TYPE_INT, 0}, \ @@ -224,7 +222,6 @@ extern int usrp_tx_thread; { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ - { .s5 = { NULL } }, \ { .s3a = { config_checkstr_assign_integer, \ {"MONOLITHIC", "PNF", "VNF", "AERIAL","UE_STUB_PNF","UE_STUB_OFFNET","STANDALONE_PNF"}, \ {NFAPI_MONOLITHIC, NFAPI_MODE_PNF, NFAPI_MODE_VNF, NFAPI_MODE_AERIAL,NFAPI_UE_STUB_PNF,NFAPI_UE_STUB_OFFNET,NFAPI_MODE_STANDALONE_PNF}, \ @@ -278,7 +275,6 @@ extern int usrp_tx_thread; /***************************************************************************************************************************************/ #define SOFTMODEM_NOS1_BIT (1<<0) -#define SOFTMODEM_NOKRNMOD_BIT (1<<1) #define SOFTMODEM_NONBIOT_BIT (1<<2) #define SOFTMODEM_RFSIM_BIT (1<<10) #define SOFTMODEM_SIML1_BIT (1<<12) @@ -298,7 +294,6 @@ extern int usrp_tx_thread; #define IS_SOFTMODEM_NOS1 ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT) -#define IS_SOFTMODEM_NOKRNMOD ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT) #define IS_SOFTMODEM_NONBIOT ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT) #define IS_SOFTMODEM_RFSIM ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT) #define IS_SOFTMODEM_SIML1 ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT) From 44a0a454604d61d55fdb9e6bb2ef71e281f138e2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Jul 2024 08:46:09 +0200 Subject: [PATCH 31/61] Remove unneeded header includes --- openair2/RRC/NR/rrc_gNB.c | 2 -- openair2/RRC/NR_UE/rrc_UE.c | 1 - 2 files changed, 3 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 08b6b334af..f9646468e0 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -73,8 +73,6 @@ #include "T.h" -#include "RRC/NAS/nas_config.h" - #include "openair3/SECU/secu_defs.h" #include "rrc_gNB_NGAP.h" diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index f214c70351..61bbabbecb 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -65,7 +65,6 @@ #include "RRC/NR/MESSAGES/asn1_msg.h" #endif -#include "RRC/NAS/nas_config.h" #include "SIMULATION/TOOLS/sim.h" // for taus #include "nr_nas_msg_sim.h" From 7782f4aef009cb835303e42688fb22c6ad18559d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 17:00:42 +0200 Subject: [PATCH 32/61] Remove functions from nas_config that are not used, mark static - Remove unused NAS_config(): It does most of what the highly similar nas_config() does. - Remove unused set_gateway() - Remove unused blocking_NAS_config() - Remove unused functions getNetMask() - Remove unused broadcast functionality: functions setBroadcastAddress() and getBroadcastAddress(), as well as global variable broadcastAddr are not used in consumers. Remove it. - Make functions static --- openair2/RRC/NAS/nas_config.c | 121 ++++------------------------------ openair2/RRC/NAS/nas_config.h | 82 ----------------------- 2 files changed, 11 insertions(+), 192 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index ce8f53fe29..5470a19bff 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -52,10 +52,8 @@ char *baseNetAddress ; char *netMask ; -char *broadcastAddr ; #define NASHLP_NETPREFIX "\n" #define NASHLP_NETMASK "\n" -#define NASHLP_BROADCASTADDR "\n" void nas_getparams(void) { // this datamodel require this static because we partially keep data like baseNetAddress (malloc on a global) // but we loose the opther attributes in nasoptions between two calls if is is not static ! @@ -67,7 +65,6 @@ void nas_getparams(void) { /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ {"NetworkPrefix", NASHLP_NETPREFIX, 0, .strptr=&baseNetAddress, .defstrval="10.0", TYPE_STRING, 0 }, {"NetworkMask", NASHLP_NETMASK, 0, .strptr=&netMask, .defstrval="255.255.255.0", TYPE_STRING, 0 }, - {"BroadcastAddr", NASHLP_BROADCASTADDR, 0, .strptr=&broadcastAddr, .defstrval="10.0.255.255", TYPE_STRING, 0 }, }; // clang-format on config_get(config_get_if(), nasoptions, sizeofArray(nasoptions), "nas.noS1"); @@ -77,77 +74,14 @@ void setBaseNetAddress (char *baseAddr) { strcpy(baseNetAddress,baseAddr); } -char *getBaseNetAddress (void) { - return baseNetAddress; -} - void setNetMask (char *baseAddr) { strcpy(netMask,baseAddr); } -char *getNetMask (void) { - return netMask; -} - -void setBroadcastAddress (char *baseAddr) { - strcpy(broadcastAddr, baseAddr); -} - -char *getBroadcastAddress (void) { - return broadcastAddr; -} - -//Add Gateway to the interface -int set_gateway(char *interfaceName, char *gateway) { - int sock_fd; - struct rtentry rt; - struct sockaddr_in addr; - - if((sock_fd = socket(AF_INET,SOCK_DGRAM,0)) < 0) { - perror("socket failed"); - return 1; - } - - memset (&rt, 0, sizeof (rt)); - addr.sin_family = AF_INET; - /*set Destination addr*/ - inet_aton("0.0.0.0",&addr.sin_addr); - memcpy(&rt.rt_dst, &addr, sizeof(struct sockaddr_in)); - /*set gateway addr*/ - inet_aton(gateway,&addr.sin_addr); - memcpy(&rt.rt_gateway, &addr, sizeof(struct sockaddr_in)); - /*set genmask addr*/ - inet_aton("0.0.0.0",&addr.sin_addr); - memcpy(&rt.rt_genmask, &addr, sizeof(struct sockaddr_in)); - rt.rt_dev = interfaceName; - //rt.rt_flags = RTF_UP|RTF_GATEWAY|RTF_DEFAULT; - /* SR: rt_flags on 16 bits but RTF_DEFAULT = 0x00010000 - * therefore doesn't lie in container -> disable it - */ - //rt.rt_flags = RTF_GATEWAY|RTF_DEFAULT; - rt.rt_flags = RTF_GATEWAY; - - if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { - close(sock_fd); - - if(strstr(strerror(errno),"File exists") == NULL) { - LOG_E(OIP,"ioctl SIOCADDRT failed : %s\n",strerror(errno)); - return 2; - } else { /*if SIOCADDRT error is route exist, retrun success*/ - LOG_I(OIP,"File Exist ...\n"); - LOG_I(OIP,"set_gateway OK!\n"); - return 0; - } - } - - close(sock_fd); - LOG_D(OIP,"Set Gateway OK!\n"); - return 0; -} - // sets a genneric interface parameter // (SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) -int setInterfaceParameter(char *interfaceName, char *settingAddress, int operation) { +static int setInterfaceParameter(const char *interfaceName, const char *settingAddress, int operation) +{ int sock_fd; struct ifreq ifr; struct sockaddr_in addr; @@ -178,7 +112,8 @@ int setInterfaceParameter(char *interfaceName, char *settingAddress, int operati // sets a genneric interface parameter // (SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) -int bringInterfaceUp(char *interfaceName, int up) { +static int bringInterfaceUp(char *interfaceName, int up) +{ int sock_fd; struct ifreq ifr; @@ -213,27 +148,6 @@ int bringInterfaceUp(char *interfaceName, int up) { close( sock_fd ); return 0; } -// non blocking full configuration of the interface (address, net mask, and broadcast mask) -int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *broadcastAddress) { - bringInterfaceUp(interfaceName, 0); - // sets the machine address - int returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); - - // sets the machine network mask - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, networkMask,SIOCSIFNETMASK); - - // sets the machine broadcast address - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR); - - // if(!returnValue) - // returnValue=set_gateway(interfaceName, broadcastAddress); - if(!returnValue) - returnValue = bringInterfaceUp(interfaceName, 1); - - return returnValue; -} int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { //char buf[5]; @@ -370,25 +284,11 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) return returnValue; } -// Blocking full configuration of the interface (address, net mask, and broadcast mask) -int blocking_NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *broadcastAddress) { - char command[200]; - command[0]='\0'; - strcat(command, "ifconfig "); - strncat(command, interfaceName, sizeof(command) - strlen(command) - 1); - strncat(command, " ", sizeof(command) - strlen(command) - 1); - strncat(command, ipAddress, sizeof(command) - strlen(command) - 1); - strncat(command, " networkMask ", sizeof(command) - strlen(command) - 1); - strncat(command, networkMask, sizeof(command) - strlen(command) - 1); - strncat(command, " broadcast ", sizeof(command) - strlen(command) - 1); - strncat(command, broadcastAddress, sizeof(command) - strlen(command) - 1); - // ifconfig nasmesh0 10.0.1.1 networkMask 255.255.255.0 broadcast 10.0.1.255 - int i = system (command); - return i; -} +#ifdef STANDALONE // program help -void helpOptions(char **argv) { +static void helpOptions(char **argv) +{ printf("Help for %s\n", argv[0]); printf(" -i \n"); printf(" -a \n"); @@ -404,7 +304,8 @@ void helpOptions(char **argv) { } // creates the broadcast address if it wasn't set before -void createBroadcast(char *broadcastAddress) { +static void createBroadcast(char *broadcastAddress) +{ int pos=strlen(broadcastAddress)-1; while(broadcastAddress[pos]!='.') @@ -415,7 +316,7 @@ void createBroadcast(char *broadcastAddress) { broadcastAddress[++pos]='5'; broadcastAddress[++pos]='\0'; } -#ifdef STANDALONE + // main function //--------------------------------------------------------------------------- int main(int argc,char **argv) @@ -473,7 +374,7 @@ int main(int argc,char **argv) } printf("Command: ifconfig %s %s networkMask %s broadcast %s\n", interfaceName, ipAddress, networkMask, broadcastAddress); - NAS_config(interfaceName, ipAddress, networkMask, broadcastAddress); + //test // setBaseNetAddress("11.11"); // nas_config(interfaceName, 33, 44); diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 21c171c56b..d599be05e3 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -38,18 +38,6 @@ */ void nas_getparams(void); -/*! \fn int NAS_config(char*, char*, char*, char*) - * \brief This function initializes the nasmesh interface - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] ipAddress, the address of the interface, e.g. 10.0.1.1 - * \param[in] networkMask, the network mask to be used, e.g. 255.255.255.0 - * \param[in] broadcastAddress, the broadcast address for the subnet, e.g. 10.0.1.255 - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails - * \note - * @ingroup _nas - */ -int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *broadcastAddress); - /*! \fn int nas_config(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, * basic address, network mask and broadcast address, as the default configured @@ -89,42 +77,6 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifs */ int nas_config_mbms_s1(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); -/*! \fn int blocking_NAS_config(char*, char*, char*, char*) - * \brief This function initializes the nasmesh interface, in a blocking way, - * the system calls are interrupted - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] ipAddress, the address of the interface, e.g. 10.0.1.1 - * \param[in] networkMask, the network mask to be used, e.g. 255.255.255.0 - * \param[in] broadcastAddress, the broadcast address for the subnet, e.g. 10.0.1.255 - * \return 0 on success, otherwise 1 - * \note - * @ingroup _nas - */ -int blocking_NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *broadcastAddress); - -/*! \fn int setInterfaceParameter(char*, char*, int) - * \brief This function sets an genneric interface parameter (SIOCSIFADDR, - * SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] address, the value of the parameter to set, e.g. 10.0.1.255 - * \param[in] operation, the operation to perform, (SIOCSIFADDR, SIOCSIFNETMASK, - * SIOCSIFBRDADDR, SIOCSIFFLAGS), e.g. SIOCSIFBRDADDR - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails - * \note - * @ingroup _nas - */ -int setInterfaceParameter(char *interfaceName, char *settingAddress, int operation); - -/*! \fn int set_gateway(char*, char*) - * \brief This function sets the interface gateway - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] address, the address of the gateway, e.g. 10.0.1.2 - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails - * \note - * @ingroup _nas - */ -int set_gateway(char *interfaceName, char *gateway); - /*! \fn void setBaseNetAddress(char*) * \brief This function sets the basic network address used * \param[in] baseAddr, the new basic address e.g.for 10.0.1.2, would be 10.0 @@ -133,14 +85,6 @@ int set_gateway(char *interfaceName, char *gateway); */ void setBaseNetAddress(char *baseAddr); -/*! \fn char* getBaseNetAddress() - * \brief This function returns the basic network address used - * \return the basic network address in use - * \note - * @ingroup _nas - */ -char *getBaseNetAddress(void); - /*! \fn void setNetMask(char*) * \brief This function sets the new default network mask used * \param[in] newNetworkMask, the new network mask e.g.for 255.255.0.0 @@ -149,30 +93,4 @@ char *getBaseNetAddress(void); */ void setNetMask(char *baseAddr); -/*! \fn char* getNetMask() - * \brief This function returns the network mask address in use - * \return the network mask in use - * \note - * @ingroup _nas - */ -char *getNetMask(void); - -/*! \fn coid setBroadcastAddress(char*) - * \brief This function sets the new broadcast address used - * \param[in] newNetworkMask, the new broadcast address e.g.for 10.0.255.255 - * \note - * @ingroup _nas - */ -void setBroadcastAddress(char *baseAddr); - -/*! \fn char* getBroadcastAddress() - * \brief This function returns the broadcast address in use - * \return the broadcast address in use - * \note - * @ingroup _nas - */ -char *getBroadcastAddress(void); - -int bringInterfaceUp(char *interfaceName, int up); - #endif /*NAS_CONFIG_H_*/ From 31b2428db86d525194b391557c1ab9a980c10090 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Tue, 16 Jul 2024 23:29:50 +0200 Subject: [PATCH 33/61] CI: Add configuration file for gNB fhi7.2 with Benetel550 and VVDN --- .../gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf | 297 ++++++++++++++++++ ...sa.band78.273prb.fhi72.4x4-benetel550.conf | 296 +++++++++++++++++ 2 files changed, 593 insertions(+) create mode 100644 ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf create mode 100644 ci-scripts/conf_files/gnb.sa.band78.273prb.fhi72.4x4-benetel550.conf diff --git a/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf new file mode 100644 index 0000000000..b98ed5d31c --- /dev/null +++ b/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf @@ -0,0 +1,297 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ( { sst = 1; }); }); + + //nr_cellid = 12345678L; + nr_cellid = 1; + + ////////// Physical parameters: + + pdsch_AntennaPorts_XP = 2; + pdsch_AntennaPorts_N1 = 1; + maxMIMO_layers = 2; + pusch_AntennaPorts = 4; + do_CSIRS = 1; + do_SRS = 0 ; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + physCellId = 0; +# downlinkConfigCommon + #frequencyInfoDL + # this is 3450.72 MHz (center frequency) + absoluteFrequencySSB = 666624; + dl_frequencyBand = 77; + # this is 3401.58 MHz + dl_absoluteFrequencyPointA = 663348; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 273; + #initialDownlinkBWP + #genericParameters + initialDLBWPlocationAndBandwidth = 1099; #38.101-1 Table 5.3.2-1 + # +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 77; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 273; + pMax = 23; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 1099; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 159; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 0; + preambleReceivedTargetPower = -100; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 7; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 2; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 5; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + +# this is the offset between the last PRACH preamble power and the Msg3 PUSCH, 2 times the field value in dB + msg3_DeltaPreamble = 2; + p0_NominalWithGrant = -100; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 0; + p0_nominal = -96; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 0x1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 5; + nrofDownlinkSlots = 3; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 1; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = 0; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ({ ipv4 = "172.21.6.103"; }); + + NETWORK_INTERFACES : + { + GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.21.18.20"; + GNB_IPV4_ADDRESS_FOR_NGU = "172.21.18.20"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 180; + pucch_TargetSNRx10 = 230; + ul_bler_target_upper=.35; + ul_bler_target_lower=.15; + pusch_FailureThres = 100; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 130 + pucch0_dtx_threshold = 80; + pusch_dtx_threshold = -100; + tx_amp_backoff_dB = 3; + L1_rx_thread_core = 3; + L1_tx_thread_core = 4; + phase_compensation = 0; # needs to match O-RU configuration +} +); + +RUs = ( +{ + local_rf = "no"; + nb_tx = 4; + nb_rx = 4; + att_tx = 0 + att_rx = 0; + bands = [77]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + sf_extension = 0; + eNB_instances = [0]; + ru_thread_core = 5; + sl_ahead = 5; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000,0x00007fff, 0x0000]; + clock_src = "internal"; + tr_preference = "raw_if4p5"; # important: activate FHI7.2 + do_precoding = 0; # needs to match O-RU configuration +} +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : { + global_log_level = "info"; + hw_log_level = "info"; + phy_log_level = "info"; + mac_log_level = "info"; + rlc_log_level = "info"; + pdcp_log_level = "info"; + rrc_log_level = "info"; + ngap_log_level = "info"; + f1ap_log_level = "info"; +}; + +fhi_72 = { + dpdk_devices = ("0000:c3:11.0", "0000:c3:11.1"); + system_core = 0; + io_core = 1; + worker_cores = (2); + du_addr = ("76:76:64:6e:00:01", "76:76:64:6e:00:01"); + ru_addr = ("98:ae:71:01:c5:eb", "98:ae:71:01:c5:eb"); + mtu = 9216; # check if xran uses this properly + fh_config = ({ + Tadv_cp_dl = 125; + T2a_cp_dl = (285, 429); # (min, max) + T2a_cp_ul = (285, 429); # (min, max) + T2a_up = (125, 428); # (min, max) + Ta3 = (130, 170); # (min, max) + T1a_cp_dl = (285, 470); # (min, max) + T1a_cp_ul = (285, 429); # (min, max) + T1a_up = (125, 350); # (min, max) + Ta4 = (110, 180); # (min, max) + ru_config = { + iq_width = 9; + iq_width_prach = 9; + }; + prach_config = { + eAxC_offset = 4; + }; + }); +}; diff --git a/ci-scripts/conf_files/gnb.sa.band78.273prb.fhi72.4x4-benetel550.conf b/ci-scripts/conf_files/gnb.sa.band78.273prb.fhi72.4x4-benetel550.conf new file mode 100644 index 0000000000..f8586437fa --- /dev/null +++ b/ci-scripts/conf_files/gnb.sa.band78.273prb.fhi72.4x4-benetel550.conf @@ -0,0 +1,296 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ( { sst = 1; }); }); + + nr_cellid = 1; + + ////////// Physical parameters: + + pdsch_AntennaPorts_XP = 2; + pdsch_AntennaPorts_N1 = 1; + maxMIMO_layers = 2; + pusch_AntennaPorts = 4; + do_CSIRS = 1; + do_SRS = 0 ; + sib1_tda = 15; +# force_UL256qam_off = 1; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + # n_TimingAdvanceOffset = 0; +# downlinkConfigCommon + #frequencyInfoDL + # this is 3450.72 MHz (center frequency) + absoluteFrequencySSB = 623328; + dl_frequencyBand = 78; + # this is 3401.58 MHz + dl_absoluteFrequencyPointA = 620052; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 273; + #initialDownlinkBWP + #genericParameters + initialDLBWPlocationAndBandwidth = 1099; #38.101-1 Table 5.3.2-1 + # +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 273; + pMax = 23; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 1099; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 151; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 0; + preambleReceivedTargetPower = -100; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 8; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 5; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + +# this is the offset between the last PRACH preamble power and the Msg3 PUSCH, 2 times the field value in dB + msg3_DeltaPreamble = 2; + p0_NominalWithGrant = -96; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 0; + p0_nominal = -96; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 0x1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -15; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ({ ipv4 = "172.21.6.103"; }); + + NETWORK_INTERFACES : + { + GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.21.18.20"; + GNB_IPV4_ADDRESS_FOR_NGU = "172.21.18.20"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 100; + pucch_TargetSNRx10 = 200; + dl_bler_target_upper=.35; + dl_bler_target_lower=.15; + ul_bler_target_upper=.35; + ul_bler_target_lower=.15; + pusch_FailureThres = 1000; + ul_max_mcs = 28; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 90; + pucch0_dtx_threshold = 80; + pusch_dtx_threshold = 10; + max_ldpc_iterations = 15; + tx_amp_backoff_dB = 12; # needs to match O-RU configuration + L1_rx_thread_core = 3; + L1_tx_thread_core = 4; + phase_compensation = 0; # needs to match O-RU configuration +} +); + +RUs = ( +{ + local_rf = "no"; + nb_tx = 4; + nb_rx = 4; + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + sf_extension = 0; + eNB_instances = [0]; + ru_thread_core = 5; + sl_ahead = 10; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000,0x00007fff, 0x0000]; + tr_preference = "raw_if4p5"; # important: activate FHI7.2 + do_precoding = 0; # needs to match O-RU configuration +} +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + ngap_log_level ="info"; + f1ap_log_level ="info"; +}; + +fhi_72 = { + dpdk_devices = ("0000:c3:11.0", "0000:c3:11.1"); + system_core = 0; + io_core = 1; + worker_cores = (2); + du_addr = ("00:11:22:33:44:66", "00:11:22:33:44:67"); + ru_addr = ("70:b3:d5:e1:5b:81", "70:b3:d5:e1:5b:81"); + mtu = 9216; + file_prefix = "fhi_72"; + fh_config = ({ + Tadv_cp_dl = 125; + T2a_cp_dl = (259, 500); + T2a_cp_ul = (25, 500); + T2a_up = (134, 375); + Ta3 = (152, 160); + T1a_cp_dl = (419, 470); + T1a_cp_ul = (285, 336); + T1a_up = (294, 345); + Ta4 = (0, 200); + ru_config = { + iq_width = 9; + iq_width_prach = 9; + }; + prach_config = { + eAxC_offset = 4; + }; + }); +}; From c7c1cb2dbf2a9b249cdc4c8b1bea15730fe9531f Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Wed, 26 Jun 2024 16:54:16 +0200 Subject: [PATCH 34/61] Enable PHR reporting for NR UE --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 16 ++- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 41 ++++-- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 6 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 9 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 18 ++- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 128 ++++++++++++++++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 12 +- 7 files changed, 184 insertions(+), 46 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index e28f7dce93..50244f2d2b 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1879,7 +1879,21 @@ static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroup } } if (mcg->phr_Config) { - // TODO configuration when PHR is implemented + nr_phr_info_t *phr_info = &si->phr_info; + phr_info->is_configured = mcg->phr_Config->choice.setup != NULL; + if (phr_info->is_configured) { + int slots_per_subframe = nr_slots_per_frame[scs] / 10; + struct NR_PHR_Config *config = mcg->phr_Config->choice.setup; + AssertFatal(config->multiplePHR == 0, "mulitplePHR not supported"); + phr_info->PathlossChange_db = config->phr_Tx_PowerFactorChange; + const int periodic_timer_sf_enum_to_sf[] = {10, 20, 50, 100, 200, 500, 1000, UINT_MAX}; + int periodic_timer_sf = periodic_timer_sf_enum_to_sf[config->phr_PeriodicTimer]; + nr_timer_setup(&phr_info->periodicPHR_Timer, periodic_timer_sf * slots_per_subframe, 1); + const int prohibit_timer_sf_enum_to_sf[] = {0, 10, 20, 50, 100, 200, 500, 1000}; + int prohibit_timer_sf = prohibit_timer_sf_enum_to_sf[config->phr_ProhibitTimer]; + nr_timer_setup(&phr_info->prohibitPHR_Timer, prohibit_timer_sf * slots_per_subframe, 1); + phr_info->phr_reporting = (1 << phr_cause_phr_config); + } } } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 781192fbc2..bec9d84dca 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -172,6 +172,12 @@ UE_STATE(UE_CONNECTED) \ UE_STATE(UE_DETACHING) +typedef enum { + phr_cause_prohibit_timer = 0, + phr_cause_periodic_timer, + phr_cause_phr_config, +} NR_UE_PHR_Reporting_cause_t; + /*!\brief UE layer 2 status */ typedef enum { #define UE_STATE(state) state, @@ -222,6 +228,24 @@ typedef struct { uint32_t maxTransmissions; } nr_sr_info_t; +typedef struct { + bool is_configured; + ///timer before triggering a periodic PHR + NR_timer_t periodicPHR_Timer; + ///timer before triggering a prohibit PHR + NR_timer_t prohibitPHR_Timer; + ///DL Pathloss change value + uint16_t PathlossLastValue; + ///number of subframe before triggering a periodic PHR + int16_t periodicPHR_SF; + ///number of subframe before triggering a prohibit PHR + int16_t prohibitPHR_SF; + ///DL Pathloss Change in db + uint16_t PathlossChange_db; + int phr_reporting; + bool was_mac_reset; +} nr_phr_info_t; + // LTE structure, might need to be adapted for NR typedef struct { // lcs scheduling info @@ -240,18 +264,8 @@ typedef struct { NR_timer_t retxBSR_Timer; /// periodicBSR-Timer NR_timer_t periodicBSR_Timer; - ///timer before triggering a periodic PHR - uint16_t periodicPHR_Timer; - ///timer before triggering a prohibit PHR - uint16_t prohibitPHR_Timer; - ///DL Pathloss change value - uint16_t PathlossChange; - ///number of subframe before triggering a periodic PHR - int16_t periodicPHR_SF; - ///number of subframe before triggering a prohibit PHR - int16_t prohibitPHR_SF; - ///DL Pathloss Change in db - uint16_t PathlossChange_db; + + nr_phr_info_t phr_info; } NR_UE_SCHEDULING_INFO; typedef enum { @@ -560,9 +574,6 @@ typedef struct NR_UE_MAC_INST_s { NR_UE_SCHEDULING_INFO scheduling_info; - /// PHR - uint8_t PHR_reporting_active; - int dmrs_TypeA_Position; int p_Max; int p_Max_alt; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 396294fc97..9a0bc8e911 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -173,7 +173,7 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac,nr_downlink_indication_t *dl_in int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, NR_UE_MAC_INST_t *mac, - uint8_t power_headroom, // todo: NR_POWER_HEADROOM_CMD *power_headroom, + NR_SINGLE_ENTRY_PHR_MAC_CE *power_headroom, uint16_t *crnti, NR_BSR_SHORT *truncated_bsr, NR_BSR_SHORT *short_bsr, @@ -193,7 +193,9 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, sub_frame_t subframe, uint8_t gNB_index, uint8_t *ulsch_buffer, - uint32_t buflen); + uint32_t buflen, + int16_t tx_power, + int16_t P_CMAX); void set_harq_status(NR_UE_MAC_INST_t *mac, uint8_t pucch_id, diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index b6a289cc45..73f85c9535 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -118,8 +118,10 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) nr_timer_setup(&mac->scheduling_info.retxBSR_Timer, 80 * subframes_per_slot, 1); // 1 slot update rate nr_timer_setup(&mac->scheduling_info.periodicBSR_Timer, 10 * subframes_per_slot, 1); // 1 slot update rate - mac->scheduling_info.periodicPHR_Timer = NR_PHR_Config__phr_PeriodicTimer_sf10; - mac->scheduling_info.prohibitPHR_Timer = NR_PHR_Config__phr_ProhibitTimer_sf10; + mac->scheduling_info.phr_info.is_configured = true; + mac->scheduling_info.phr_info.PathlossChange_db = 1; + nr_timer_setup(&mac->scheduling_info.phr_info.periodicPHR_Timer, 10 * subframes_per_slot, 1); + nr_timer_setup(&mac->scheduling_info.phr_info.prohibitPHR_Timer, 10 * subframes_per_slot, 1); } void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req) @@ -229,7 +231,8 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) nr_mac->scheduling_info.BSR_reporting_active = NR_BSR_TRIGGER_NONE; // cancel any triggered Power Headroom Reporting procedure - // TODO PHR not implemented yet + nr_mac->scheduling_info.phr_info.phr_reporting = 0; + nr_mac->scheduling_info.phr_info.was_mac_reset = true; // flush the soft buffers for all DL HARQ processes for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c7903a9666..59495bd2c3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3668,30 +3668,28 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i */ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, NR_UE_MAC_INST_t *mac, - uint8_t power_headroom, // todo: NR_POWER_HEADROOM_CMD *power_headroom, + NR_SINGLE_ENTRY_PHR_MAC_CE *power_headroom, uint16_t *crnti, NR_BSR_SHORT *truncated_bsr, NR_BSR_SHORT *short_bsr, NR_BSR_LONG *long_bsr) { int mac_ce_len = 0; - uint8_t mac_ce_size = 0; uint8_t *pdu = mac_ce; if (power_headroom) { - // MAC CE fixed subheader ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) mac_ce)->LCID = UL_SCH_LCID_SINGLE_ENTRY_PHR; mac_ce++; // PHR MAC CE (1 octet) - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = power_headroom; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = power_headroom->PH; ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R1 = 0; - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = 0; // todo + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = power_headroom->PCMAX; ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R2 = 0; // update pointer and length - mac_ce_size = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); + int mac_ce_size = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : power_headroom pdu %p mac_ce %p b\n", @@ -3710,7 +3708,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, memcpy(mac_ce, crnti, sizeof(*crnti)); // update pointer and length - mac_ce_size = sizeof(uint16_t); + int mac_ce_size = sizeof(uint16_t); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); } @@ -3727,7 +3725,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> LcgID = truncated_bsr->LcgID;; // update pointer and length - mac_ce_size = sizeof(NR_BSR_SHORT_TRUNCATED); + int mac_ce_size = sizeof(NR_BSR_SHORT_TRUNCATED); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : truncated_bsr Buffer_size %d LcgID %d pdu %p mac_ce %p\n", @@ -3745,7 +3743,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ((NR_BSR_SHORT *) mac_ce)->LcgID = short_bsr->LcgID; // update pointer and length - mac_ce_size = sizeof(NR_BSR_SHORT); + int mac_ce_size = sizeof(NR_BSR_SHORT); mac_ce += mac_ce_size; mac_ce_len += mac_ce_size + sizeof(NR_MAC_SUBHEADER_FIXED); LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : short_bsr Buffer_size %d LcgID %d pdu %p mac_ce %p\n", @@ -3812,7 +3810,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ((NR_BSR_LONG *) mac_ce)->LcgID7 = 1; *Buffer_size_ptr++ = long_bsr->Buffer_size7; } - ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_subheader_ptr)->L = mac_ce_size = (uint8_t*) Buffer_size_ptr - (uint8_t*) mac_ce; + int mac_ce_size = ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_subheader_ptr)->L = (uint8_t*) Buffer_size_ptr - (uint8_t*) mac_ce; LOG_D(NR_MAC, "[UE] Generating ULSCH PDU : long_bsr size %d Lcgbit 0x%02x Buffer_size %d %d %d %d %d %d %d %d\n", mac_ce_size, *((uint8_t*) mac_ce), ((NR_BSR_LONG *) mac_ce)->Buffer_size0, ((NR_BSR_LONG *) mac_ce)->Buffer_size1, ((NR_BSR_LONG *) mac_ce)->Buffer_size2, ((NR_BSR_LONG *) mac_ce)->Buffer_size3, ((NR_BSR_LONG *) mac_ce)->Buffer_size4, ((NR_BSR_LONG *) mac_ce)->Buffer_size5, ((NR_BSR_LONG *) mac_ce)->Buffer_size6, ((NR_BSR_LONG *) mac_ce)->Buffer_size7); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 315f1ef522..b3f9ff5ffc 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -64,6 +64,12 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP); static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment); +static void nr_ue_fill_phr(NR_UE_MAC_INST_t *mac, + NR_SINGLE_ENTRY_PHR_MAC_CE *phr, + float P_CMAX, + float tx_power, + frame_t frameP, + sub_frame_t subframe); void clear_ul_config_request(NR_UE_MAC_INST_t *mac, int scs) { @@ -176,6 +182,21 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac) AssertFatal(!nr_timer_tick(&mac->scheduling_info.lc_sched_info[i].Bj_timer), "Bj timer for LCID %d expired! That should never happen\n", i); + + nr_phr_info_t *phr_info = &mac->scheduling_info.phr_info; + if (phr_info->is_configured) { + bool prohibit_expired = nr_timer_tick(&phr_info->prohibitPHR_Timer); + if (prohibit_expired) { + int16_t pathloss = compute_nr_SSB_PL(mac, mac->ssb_measurements.ssb_rsrp_dBm); + if (abs(pathloss - phr_info->PathlossLastValue) > phr_info->PathlossChange_db) { + phr_info->phr_reporting |= (1 << phr_cause_prohibit_timer); + } + } + bool periodic_expired = nr_timer_tick(&phr_info->periodicPHR_Timer); + if (periodic_expired) { + phr_info->phr_reporting |= (1 << phr_cause_periodic_timer); + } + } } void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu) @@ -942,6 +963,16 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, return -1; } + // 38.321 5.4.6 + // if it is the first UL resource allocated for a new transmission since the last MAC reset: + // 2> start phr-PeriodicTimer; + if (mac->scheduling_info.phr_info.is_configured) { + if (mac->scheduling_info.phr_info.was_mac_reset && pusch_config_pdu->pusch_data.new_data_indicator) { + mac->scheduling_info.phr_info.was_mac_reset = false; + nr_timer_start(&mac->scheduling_info.phr_info.periodicPHR_Timer); + } + } + return 0; } @@ -1185,7 +1216,6 @@ static bool nr_ue_periodic_srs_scheduling(NR_UE_MAC_INST_t *mac, frame_t frame, // Performs : // 1. TODO: Call RRC for link status return to PHY // 2. TODO: Perform SR/BSR procedures for scheduling feedback -// 3. TODO: Perform PHR procedures void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info) { frame_t rx_frame = dl_info->frame; @@ -1422,10 +1452,24 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator && (mac->state == UE_CONNECTED || (ra->ra_state == nrRA_WAIT_RAR && ra->cfra))) { // Getting IP traffic to be transmitted - nr_ue_get_sdu(mac, cc_id, frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes); - ulcfg_pdu->pusch_config_pdu.tx_request_body.fapiTxPdu = ulsch_input_buffer; - ulcfg_pdu->pusch_config_pdu.tx_request_body.pdu_length = TBS_bytes; - number_of_pdus++; + int tx_power = ulcfg_pdu->pusch_config_pdu.tx_power; + int P_CMAX = nr_get_Pcmax(mac->p_Max, + mac->nr_band, + mac->frame_type, + mac->frequency_range, + mac->current_UL_BWP->channel_bandwidth, + ulcfg_pdu->pusch_config_pdu.qam_mod_order, + false, + mac->current_UL_BWP->scs, + mac->current_UL_BWP->BWPSize, + ulcfg_pdu->pusch_config_pdu.transform_precoding, + ulcfg_pdu->pusch_config_pdu.rb_size, + ulcfg_pdu->pusch_config_pdu.rb_start); + + nr_ue_get_sdu(mac, cc_id, frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes, tx_power, P_CMAX); + ulcfg_pdu->pusch_config_pdu.tx_request_body.fapiTxPdu = ulsch_input_buffer; + ulcfg_pdu->pusch_config_pdu.tx_request_body.pdu_length = TBS_bytes; + number_of_pdus++; } } @@ -2735,6 +2779,7 @@ typedef struct { NR_BSR_SHORT *bsr_s; NR_BSR_LONG *bsr_l; NR_BSR_SHORT *bsr_t; + NR_SINGLE_ENTRY_PHR_MAC_CE* phr; //NR_POWER_HEADROOM_CMD *phr_pr; int tot_mac_ce_len; uint8_t total_mac_pdu_header_len; @@ -2758,12 +2803,13 @@ static int nr_ue_get_sdu_mac_ce_pre(NR_UE_MAC_INST_t *mac, uint8_t gNB_index, uint8_t *ulsch_buffer, uint32_t buflen, + int16_t tx_power, + int16_t P_CMAX, NR_UE_MAC_CE_INFO *mac_ce_p) { int num_lcg_id_with_data = 0; // Preparing the MAC CEs sub-PDUs and get the total size mac_ce_p->bsr_header_len = 0; - mac_ce_p->phr_header_len = 0; //sizeof(SCH_SUBHEADER_FIXED); int lcg_id = 0; while (lcg_id != NR_INVALID_LCGID) { if (mac->scheduling_info.lcg_sched_info[lcg_id].BSR_bytes) { @@ -2794,8 +2840,23 @@ static int nr_ue_get_sdu_mac_ce_pre(NR_UE_MAC_INST_t *mac, } } } - mac_ce_p->bsr_len = mac_ce_p->bsr_ce_len + mac_ce_p->bsr_header_len; + + + nr_phr_info_t *phr_info = &mac->scheduling_info.phr_info; + mac_ce_p->phr_header_len = 0; + mac_ce_p->phr_ce_len = 0; + if (phr_info->is_configured && phr_info->phr_reporting > 0) { + if (buflen >= (mac_ce_p->bsr_len + sizeof(NR_MAC_SUBHEADER_FIXED) + sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE))) { + if (mac->scheduling_info.phr_info.phr_reporting) { + mac_ce_p->phr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED); + mac_ce_p->phr_ce_len = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); + nr_ue_fill_phr(mac, mac_ce_p->phr, P_CMAX, tx_power, frameP, subframe); + } + } + } + mac_ce_p->phr_len = mac_ce_p->phr_header_len + mac_ce_p->phr_ce_len; + return (mac_ce_p->bsr_len + mac_ce_p->phr_len); } @@ -3234,7 +3295,9 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, slot_t slot, uint8_t gNB_index, uint8_t *ulsch_buffer, - uint32_t buflen) + uint32_t buflen, + int16_t tx_power, + int16_t P_CMAX) { NR_UE_MAC_CE_INFO mac_ce_info; NR_UE_MAC_CE_INFO *mac_ce_p=&mac_ce_info; @@ -3253,8 +3316,9 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, mac_ce_p->bsr_s = &bsr_short; mac_ce_p->bsr_l = &bsr_long; mac_ce_p->bsr_t = &bsr_truncated; - //NR_POWER_HEADROOM_CMD phr; - //mac_ce_p->phr_p = &phr; + + NR_SINGLE_ENTRY_PHR_MAC_CE phr; + mac_ce_p->phr = &phr; //int highest_priority = 16; const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_LONG); @@ -3273,7 +3337,7 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, // because as per standard(TS38.321), all equal priority channels should be served equally // nr_ue_get_sdu_mac_ce_pre updates all mac_ce related header field related to length - mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(mac, CC_id, frame, slot, gNB_index, ulsch_buffer, buflen, mac_ce_p); + mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(mac, CC_id, frame, slot, gNB_index, ulsch_buffer, buflen, tx_power, P_CMAX, mac_ce_p); mac_ce_p->total_mac_pdu_header_len = mac_ce_p->tot_mac_ce_len; LOG_D(NR_MAC, "[UE %d] [%d.%d] process UL transport block at with size TBS = %d bytes \n", mac->ue_id, frame, slot, buflen); @@ -3373,9 +3437,8 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, nr_ue_get_sdu_mac_ce_post(mac, frame, slot, ulsch_buffer, buflen, mac_ce_p); if (mac_ce_p->tot_mac_ce_len > 0) { - LOG_D(NR_MAC, "In %s copying %d bytes of MAC CEs to the UL PDU \n", __FUNCTION__, mac_ce_p->tot_mac_ce_len); - int size = nr_write_ce_ulsch_pdu(pdu, mac, 0, NULL, mac_ce_p->bsr_t, mac_ce_p->bsr_s, mac_ce_p->bsr_l); + int size = nr_write_ce_ulsch_pdu(pdu, mac, mac_ce_p->phr_ce_len ? mac_ce_p->phr : NULL, 0, mac_ce_p->bsr_t, mac_ce_p->bsr_s, mac_ce_p->bsr_l); if (size != mac_ce_p->tot_mac_ce_len) LOG_E(NR_MAC, "MAC CE size computed by nr_write_ce_ulsch_pdu is %d while the one assumed before is %d\n", size, mac_ce_p->tot_mac_ce_len); pdu += (unsigned char) mac_ce_p->tot_mac_ce_len; @@ -3436,3 +3499,42 @@ static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TI dl_config->number_pdus += 1; ul_time_alignment->ta_apply = no_ta; } + +static void nr_ue_fill_phr(NR_UE_MAC_INST_t *mac, + NR_SINGLE_ENTRY_PHR_MAC_CE *phr, + float P_CMAX, + float tx_power, + frame_t frameP, + sub_frame_t subframe) +{ + nr_phr_info_t *phr_info = &mac->scheduling_info.phr_info; + // Value mapping according to 38.133 10.1.18.1 + const int PC_MAX_00 = -29; + phr->PCMAX = max(0, (int)P_CMAX - PC_MAX_00) & 0x3f; + // Value mapping according to 38.133 10.1.17.1.1 + const int POWER_HEADROOM_55 = 22; + int headroom = P_CMAX - tx_power; + if (headroom < POWER_HEADROOM_55) { + const int POWER_HEADROOM_0 = -32; + phr->PH = max(0, headroom - POWER_HEADROOM_0); + } else { + phr->PH = min(0x3f, 55 + (headroom - POWER_HEADROOM_55) / 2); + } + + LOG_D(NR_MAC, + "PHR Reporting sfn.subframe %d.%d reason = %d, P_CMAX = %d (%5.2f dBm), headrom = %d (%d dB) tx_power = %5.2f dBm\n", + frameP, + subframe, + phr_info->phr_reporting, + phr->PCMAX, + P_CMAX, + phr->PH, + headroom, + tx_power); + + phr_info->PathlossLastValue = compute_nr_SSB_PL(mac, mac->ssb_measurements.ssb_rsrp_dBm); + // Restart both timers according to 38.321 + nr_timer_start(&phr_info->periodicPHR_Timer); + nr_timer_start(&phr_info->prohibitPHR_Timer); + phr_info->phr_reporting = 0; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 772b9bf582..dce6d3b71b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -331,8 +331,16 @@ static int nr_process_mac_pdu(instance_t module_idP, sched_ctrl->ph0 = PH; /* 38.133 Table10.1.18.1-1 */ sched_ctrl->pcmax = PCMAX - 29; - LOG_D(NR_MAC, "SINGLE ENTRY PHR R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n", - phr->R1, PH, sched_ctrl->ph, phr->R2, PCMAX, sched_ctrl->pcmax); + LOG_D(NR_MAC, + "SINGLE ENTRY PHR %d.%d R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n", + frameP, + slot, + phr->R1, + PH, + sched_ctrl->ph, + phr->R2, + PCMAX, + sched_ctrl->pcmax); break; case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT: From f23c1dff00b5008f71eef715d7b57547ba7b2cdd Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Wed, 3 Jul 2024 16:24:12 +0200 Subject: [PATCH 35/61] Correct gNB received PHR to headroom calculation according to 38.133. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index dce6d3b71b..b8f370be16 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -313,10 +313,13 @@ static int nr_process_mac_pdu(instance_t module_idP, int PH; const int PCMAX = phr->PCMAX; /* 38.133 Table10.1.17.1-1 */ - if (phr->PH < 55) + if (phr->PH < 55) { PH = phr->PH - 32; - else - PH = phr->PH - 32 + (phr->PH - 54); + } else if (phr->PH < 63) { + PH = 28 + (phr->PH - 55) * 2; + } else { + PH = 42; + } // in sched_ctrl we set normalized PH wrt MCS and PRBs long *deltaMCS = ul_bwp->pusch_Config ? ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS : NULL; sched_ctrl->ph = PH From 983ee2794d9bbf9bcae62538001a829ab3bb4d6e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 19:11:49 +0200 Subject: [PATCH 36/61] Replace nas_config_mbms_s1() call with nas_config_mbms() Comparing both functions, it seems that nas_config_mbms_s1() sets the same parameters, assuming that in nas_config_mbms(), we set - (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) yielding true -> should yield the same interface name - netmask is hardcoded to 255.255.255.0 - baseNetAddress is hardcoded 10.0 So replace the call with nas_config_mbms() by setting parameters accordingly. --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- openair2/RRC/NAS/nas_config.c | 42 ----------------------------- openair2/RRC/NAS/nas_config.h | 13 --------- 3 files changed, 1 insertion(+), 56 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 25a31c6873..57a7a5a20f 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2317,7 +2317,7 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("enm", 0); - nas_config_mbms_s1(1, 2, 1, "enm"); + nas_config_mbms(1, 2, 1, "enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 5470a19bff..9df9e25014 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -188,48 +188,6 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifn return returnValue; } -int nas_config_mbms_s1(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { - //char buf[5]; - char ipAddress[20]; - char broadcastAddress[20]; - char interfaceName[20]; - int returnValue; - //if(strcmp(ifname,"ue") == 0) - //sprintf(ipAddress, "%s.%d.%d", "20.0",thirdOctet,fourthOctet); - ////else - sprintf(ipAddress, "%s.%d.%d","10.0",thirdOctet,fourthOctet); - - sprintf(broadcastAddress, "%s.%d.255","10.0", thirdOctet); - sprintf(interfaceName, "%s%s%d", "oaitun_",ifname,interface_id); - bringInterfaceUp(interfaceName, 0); - // sets the machine address - returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); - - // sets the machine network mask - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, "255.255.255.0",SIOCSIFNETMASK); - printf("returnValue %d\n",returnValue); - - // sets the machine broadcast address - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR); - printf("returnValue %d\n",returnValue); - - if(!returnValue) - bringInterfaceUp(interfaceName, 1); - printf("returnValue %d\n",returnValue); - - if(!returnValue) - LOG_I(OIP,"Interface %s successfully configured, ip address %s, mask %s broadcast address %s\n", - interfaceName, ipAddress, "255.255.255.0", broadcastAddress); - else - LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n", - interfaceName, ipAddress, "255.255.255.0", broadcastAddress); - - return returnValue; -} - - // non blocking full configuration of the interface (address, and the two lest octets of the address) int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { //char buf[5]; diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index d599be05e3..3188a73beb 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -64,19 +64,6 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix */ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); -/*! \fn int nas_config_mbms_s1(char*, int, int) - * \brief This function initializes the nasmesh interface using the basic values, - * basic address, network mask and broadcast address, as the default configured - * ones - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] third octet of the ip address e.g. for the 10.1.2.3 address would be 2 - * \param[in] fourth octet of the ip address e.g. for the 10.1.2.3 address would be 3 - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails - * \note - * @ingroup _nas - */ -int nas_config_mbms_s1(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); - /*! \fn void setBaseNetAddress(char*) * \brief This function sets the basic network address used * \param[in] baseAddr, the new basic address e.g.for 10.0.1.2, would be 10.0 From 5acfa47325e039c6f7c3a541a85a731f2b151516 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 22 Jul 2024 13:33:34 +0200 Subject: [PATCH 37/61] nas_config()/netlink_init_tun(): use entire interface name (prefix) Instead of implicitly using a hardcoded prefix "oaitun_" interface name, move that out to the callers of these functions to make it clear. The ID still remains outside. The "sister functions" nas_config_mbms()/netlink_init_tun_mbms() will do the same change in the next commit. --- openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c | 5 +++-- openair1/SIMULATION/ETH_TRANSPORT/proto.h | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 8 ++++---- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 12 ++++++------ openair2/RRC/LTE/rrc_UE.c | 8 ++++---- openair2/RRC/LTE/rrc_eNB.c | 8 ++++---- openair2/RRC/NAS/nas_config.c | 6 +++--- openair2/RRC/NAS/nas_config.h | 2 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 2 +- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index a57c7a9090..919edbb834 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -126,14 +126,15 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., return 1; } -int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ..., +int netlink_init_tun(const char *ifprefix, int num_if, int id) +{ int ret; char ifname[64]; int begx = (id == 0) ? 0 : id - 1; int endx = (id == 0) ? num_if : id; for (int i = begx; i < endx; i++) { - sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1); + sprintf(ifname, "%s%d", ifprefix, i + 1); nas_sock_fd[i] = tun_alloc(ifname); if (nas_sock_fd[i] == -1) { diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 79e97f0e72..647824cf05 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -31,7 +31,7 @@ #ifndef EMU_PROTO_H_ #define EMU_PROTO_H_ -int netlink_init_tun(char *ifsuffix, int num_if, int id); +int netlink_init_tun(const char *ifprefix, int num_if, int id); int netlink_init_mbms_tun(char *ifsuffix, int id); #endif /* EMU_PROTO_H_ */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 57a7a5a20f..33ecfe0c0c 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2300,15 +2300,15 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { if (UE_NAS_USE_TUN) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun("ue", num_if, id); + netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, 2, "ue"); + nas_config(1, 1, 2, "oaitun_ue"); netlink_init_mbms_tun("uem", id); nas_config_mbms(1, 2, 2, "uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { - netlink_init_tun("enb", 1, 0); - nas_config(1, 1, 1, "enb"); + netlink_init_tun("oaitun_enb", 1, 0); + nas_config(1, 1, 1, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("enm", 0); nas_config_mbms(1, 2, 1, "enm"); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index ceab4331ea..51feb0d955 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -613,21 +613,21 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) nas_getparams(); if (UE_NAS_USE_TUN) { - char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue"; + char *ifprefix = get_softmodem_params()->nsa ? "oaitun_nrue" : "oaitun_ue"; int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun(ifsuffix_ue, num_if, id); + netlink_init_tun(ifprefix, num_if, id); if (IS_SOFTMODEM_NOS1) { - nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); + nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifprefix); set_qfi_pduid(7, 10); } LOG_I(PDCP, "UE pdcp will use tun interface\n"); start_pdcp_tun_ue(); } else if (ENB_NAS_USE_TUN) { - char *ifsuffix_base_s = get_softmodem_params()->nsa ? "gnb" : "enb"; - netlink_init_tun(ifsuffix_base_s, 1, id); - nas_config(1, 1, 1, ifsuffix_base_s); + char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb"; + netlink_init_tun(ifprefix, 1, id); + nas_config(1, 1, 1, ifprefix); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); } diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index a7a8bb8fb3..9de1e52527 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -765,10 +765,10 @@ rrc_ue_establish_drb( ip_addr_offset4 = 1; LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); - oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id - UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet - ip_addr_offset4+ue_mod_idP+1, // fourth_octet - "oip"); // interface suffix (when using kernel module) + oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, // interface_id + UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), // third_octet + ip_addr_offset4 + ue_mod_idP + 1, // fourth_octet + "oaitun_oip"); if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 8b086b1387..3828df4cb7 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -5255,10 +5255,10 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", ctxt_pP->module_id, ctxt_pP->module_id); - oip_ifup = nas_config(ctxt_pP->module_id, // interface index - ctxt_pP->module_id + 1, // third octet - ctxt_pP->module_id + 1, // fourth octet - "oai"); + oip_ifup = nas_config(ctxt_pP->module_id, // interface index + ctxt_pP->module_id + 1, // third octet + ctxt_pP->module_id + 1, // fourth octet + "oaitun_oai"); if (oip_ifup == 0) { // interface is up --> send a config the DRB module_id_t ue_module_id; diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 9df9e25014..d3618483ba 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -189,7 +189,8 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifn } // non blocking full configuration of the interface (address, and the two lest octets of the address) -int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { +int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifpref) +{ //char buf[5]; char ipAddress[20]; char broadcastAddress[20]; @@ -197,8 +198,7 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) int returnValue; sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); - sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname, - UE_NAS_USE_TUN?"ue": (ENB_NAS_USE_TUN?"enb":""),interface_id); + sprintf(interfaceName, "%s%d", ifpref, interface_id); bringInterfaceUp(interfaceName, 0); // sets the machine address returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 3188a73beb..72a3bc6887 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -49,7 +49,7 @@ void nas_getparams(void); * \note * @ingroup _nas */ -int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); +int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifprefix); /*! \fn int nas_config_mbms(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 1d25258821..8f81684437 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -846,7 +846,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff int third_octet = *(pdu_buffer + 41); int fourth_octet = *(pdu_buffer + 42); LOG_A(NAS, "Received PDU Session Establishment Accept\n"); - nas_config(1,third_octet,fourth_octet,"ue"); + nas_config(1, third_octet, fourth_octet, "oaitun_ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); } From a12460e88242841c6449b713942828635c6a7fb1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 20:08:35 +0200 Subject: [PATCH 38/61] nas_config_mbms/netlink_init_mbms_tun(): use entire interface prefix Does the same change in the _mbms() functions as in the previous commit. Also, simplify logic in netlink_init_mbms_tun(): directly use the id in the interface. This requires a slight ID change in the users, which is also done in this commit. --- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 17 ++++++----------- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 12 ++++++------ openair2/RRC/NAS/nas_config.c | 6 +++--- openair2/RRC/NAS/nas_config.h | 2 +- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 919edbb834..e32cb81b00 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -93,24 +93,19 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., int ret; char ifname[64]; - if (id > 0) { - sprintf(ifname, "oaitun_%.3s%d", ifprefix, id-1); - } - else { - sprintf(ifname, "oaitun_%.3s1", ifprefix); // added "1": for historical reasons - } - nas_sock_mbms_fd = tun_alloc(ifname); + sprintf(ifname, "%s%d", ifprefix, id); + nas_sock_mbms_fd = tun_alloc(ifname); - if (nas_sock_mbms_fd == -1) { - printf("[NETLINK] Error opening mbms socket %s (%d:%s)\n",ifname,errno, strerror(errno)); - exit(1); + if (nas_sock_mbms_fd == -1) { + LOG_E(PDCP, "[NETLINK] Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); + exit(1); } printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd); ret = fcntl(nas_sock_mbms_fd,F_SETFL,O_NONBLOCK); if (ret == -1) { - printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); + LOG_E(PDCP, "[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); if (LINK_ENB_PDCP_TO_IP_DRIVER) { exit(1); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 33ecfe0c0c..15dc9a2403 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2303,21 +2303,21 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) nas_config(1, 1, 2, "oaitun_ue"); - netlink_init_mbms_tun("uem", id); - nas_config_mbms(1, 2, 2, "uem"); + netlink_init_mbms_tun("oaitun_uem", id + 1); + nas_config_mbms(1, 2, 2, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); nas_config(1, 1, 1, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("enm", 0); - nas_config_mbms(1, 2, 1, "enm"); + netlink_init_mbms_tun("oaitun_enm", 1); + nas_config_mbms(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("enm", 0); - nas_config_mbms(1, 2, 1, "enm"); + netlink_init_mbms_tun("oaitun_enm", 0); + nas_config_mbms(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index d3618483ba..087d3c81a0 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -149,7 +149,8 @@ static int bringInterfaceUp(char *interfaceName, int up) return 0; } -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { +int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname) +{ //char buf[5]; char ipAddress[20]; char broadcastAddress[20]; @@ -161,8 +162,7 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifn sprintf(ipAddress, "%s.%d.%d",baseNetAddress,thirdOctet,fourthOctet); sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); - sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname, - UE_NAS_USE_TUN?ifname/*"ue"*/: (ENB_NAS_USE_TUN?ifname/*"enb"*/:""),interface_id); + sprintf(interfaceName, "%s%d", ifname, interface_id); bringInterfaceUp(interfaceName, 0); // sets the machine address returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 72a3bc6887..017bf57133 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -62,7 +62,7 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if * \note * @ingroup _nas */ -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); +int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname); /*! \fn void setBaseNetAddress(char*) * \brief This function sets the basic network address used From 380cf5c603d7366630498d902d6268ca1f6b146b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 20:12:20 +0200 Subject: [PATCH 39/61] Remove routing table init in nas_config() The routing table is temporarily removed in this commit and introduced in one of the next commits. --- openair2/RRC/NAS/nas_config.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 087d3c81a0..461ed51ef4 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -221,24 +221,6 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n", interfaceName, ipAddress, netMask, broadcastAddress); - int res; - char command_line[500]; - res = sprintf(command_line, - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev %s%d table %d", - ipAddress, interface_id - 1 + 10000, - ipAddress, interface_id - 1 + 10000, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", - interface_id, interface_id - 1 + 10000); - - if (res < 0) { - LOG_E(OIP,"Could not create ip rule/route commands string\n"); - return res; - } - - background_system(command_line); - return returnValue; } From 9fedbf31dd433111624bc86822a06bb14b13d734 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 6 Jun 2024 20:15:09 +0200 Subject: [PATCH 40/61] Remove nas_config_mbms() Remove nas_config_mbms() since nas_config_mbms() and nas_config() do the same --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 6 ++--- openair2/RRC/NAS/nas_config.c | 39 ----------------------------- openair2/RRC/NAS/nas_config.h | 13 ---------- 3 files changed, 3 insertions(+), 55 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 15dc9a2403..992357e8e7 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2304,20 +2304,20 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { if (IS_SOFTMODEM_NOS1) nas_config(1, 1, 2, "oaitun_ue"); netlink_init_mbms_tun("oaitun_uem", id + 1); - nas_config_mbms(1, 2, 2, "oaitun_uem"); + nas_config(1, 2, 2, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); nas_config(1, 1, 1, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 1); - nas_config_mbms(1, 2, 1, "oaitun_enm"); + nas_config(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 0); - nas_config_mbms(1, 2, 1, "oaitun_enm"); + nas_config(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 461ed51ef4..e35281dec8 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -149,45 +149,6 @@ static int bringInterfaceUp(char *interfaceName, int up) return 0; } -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname) -{ - //char buf[5]; - char ipAddress[20]; - char broadcastAddress[20]; - char interfaceName[20]; - int returnValue; - //if(strcmp(ifname,"ue") == 0) - //sprintf(ipAddress, "%s.%d.%d", "20.0",thirdOctet,fourthOctet); - ////else - sprintf(ipAddress, "%s.%d.%d",baseNetAddress,thirdOctet,fourthOctet); - - sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); - sprintf(interfaceName, "%s%d", ifname, interface_id); - bringInterfaceUp(interfaceName, 0); - // sets the machine address - returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); - - // sets the machine network mask - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, netMask,SIOCSIFNETMASK); - - // sets the machine broadcast address - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR); - - if(!returnValue) - bringInterfaceUp(interfaceName, 1); - - if(!returnValue) - LOG_I(OIP,"Interface %s successfully configured, ip address %s, mask %s broadcast address %s\n", - interfaceName, ipAddress, netMask, broadcastAddress); - else - LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n", - interfaceName, ipAddress, netMask, broadcastAddress); - - return returnValue; -} - // non blocking full configuration of the interface (address, and the two lest octets of the address) int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifpref) { diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 017bf57133..fc6dda11dd 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -51,19 +51,6 @@ void nas_getparams(void); */ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifprefix); -/*! \fn int nas_config_mbms(char*, int, int) - * \brief This function initializes the nasmesh interface using the basic values, - * basic address, network mask and broadcast address, as the default configured - * ones - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] third octet of the ip address e.g. for the 10.1.2.3 address would be 2 - * \param[in] fourth octet of the ip address e.g. for the 10.1.2.3 address would be 3 - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails - * \note - * @ingroup _nas - */ -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname); - /*! \fn void setBaseNetAddress(char*) * \brief This function sets the basic network address used * \param[in] baseAddr, the new basic address e.g.for 10.0.1.2, would be 10.0 From 4810efdcfdcd4c47fe9f5acbdaf520ef9cd37ed8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Jul 2024 16:15:34 +0200 Subject: [PATCH 41/61] Remove unused code from nas_config.c Remove unused header includes, as well as the test program (which does not do much, and certainly does not test in the way we use the interfaces). --- openair2/RRC/NAS/nas_config.c | 116 ---------------------------------- 1 file changed, 116 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index e35281dec8..8d3944a2eb 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -19,34 +19,16 @@ * contact@openairinterface.org */ -/*! \file nas_config.c -* \brief Configures the nasmesh interface -* \author Daniel Camara and Navid Nikaein -* \date 2006-2011 -* \version 0.1 -* \email:navid.nikaein@eurecom.fr -* \company Eurecom -*/ - #include #include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include #include "nas_config.h" #include "common/utils/LOG/log.h" -#include "executables/lte-softmodem.h" #include "common/config/config_userapi.h" -#include "pdcp.h" //default values according to the examples, @@ -184,101 +166,3 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if return returnValue; } - -#ifdef STANDALONE - -// program help -static void helpOptions(char **argv) -{ - printf("Help for %s\n", argv[0]); - printf(" -i \n"); - printf(" -a \n"); - printf(" -n \n"); - printf(" -b \n"); - printf(" -h Shows this help\n"); - printf("If no option is passed as parameter the default values are: \n"); - printf(" Interface Name: nasmesh0\n"); - printf(" IP Address: 10.0.1.1\n"); - printf(" Net mask: 255.255.255.0\n"); - printf(" Broadcast address: [Beginning of the IP address].255\n"); - exit(1); -} - -// creates the broadcast address if it wasn't set before -static void createBroadcast(char *broadcastAddress) -{ - int pos=strlen(broadcastAddress)-1; - - while(broadcastAddress[pos]!='.') - pos--; - - broadcastAddress[++pos]='2'; - broadcastAddress[++pos]='2'; - broadcastAddress[++pos]='5'; - broadcastAddress[++pos]='\0'; -} - -// main function -//--------------------------------------------------------------------------- -int main(int argc,char **argv) -//--------------------------------------------------------------------------- -{ - int c; - char interfaceName[100]; - char ipAddress[100]; - char networkMask[100]; - char broadcastAddress[100]; - strcpy(interfaceName, "oai0"); - strcpy(ipAddress, "10.0.1.1"); - strcpy(networkMask, "255.255.255.0"); - broadcastAddress[0]='\0'; - - while ((c = getopt (argc, argv, "i:a:n:b:h")) != -1) - switch (c) { - case 'h': - helpOptions(argv); - break; - - case 'i': - strcpy(interfaceName,optarg); - break; - - case 'a': - strcpy(ipAddress,optarg); - break; - - case 'n': - strcpy(networkMask,optarg); - break; - - case 'b': - strcpy(broadcastAddress,optarg); - break; - - case '?': - if (isprint (optopt)) - fprintf (stderr, "Unknown option `-%c'.\n", optopt); - else - fprintf (stderr, - "Unknown option character `\\x%x'.\n", - optopt); - - return 1; - - default: - abort (); - } - - if(strlen(broadcastAddress)==0) { - strcpy(broadcastAddress,ipAddress); - createBroadcast(broadcastAddress); - } - - printf("Command: ifconfig %s %s networkMask %s broadcast %s\n", interfaceName, ipAddress, networkMask, broadcastAddress); - - //test - // setBaseNetAddress("11.11"); - // nas_config(interfaceName, 33, 44); -} - -#endif From 5bf498fca4b6cdac05f273189353d8ea4a010cf5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Jul 2024 16:53:16 +0200 Subject: [PATCH 42/61] nas_config(): remove broadcast parameter Remove the broadcast address from the UE, as logically, a UE has nothing to broadcast: it can only directly talk to the core. Additionally, at least as of now, the UE interface is shown as "POINTOPOINT", so broadcasting is not possible. --- openair2/RRC/NAS/nas_config.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 8d3944a2eb..19811ed1d3 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -136,11 +136,9 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if { //char buf[5]; char ipAddress[20]; - char broadcastAddress[20]; char interfaceName[20]; int returnValue; sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); - sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); sprintf(interfaceName, "%s%d", ifpref, interface_id); bringInterfaceUp(interfaceName, 0); // sets the machine address @@ -150,19 +148,13 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if if(!returnValue) returnValue= setInterfaceParameter(interfaceName, netMask,SIOCSIFNETMASK); - // sets the machine broadcast address - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR); - if(!returnValue) returnValue=bringInterfaceUp(interfaceName, 1); if(!returnValue) - LOG_I(OIP,"Interface %s successfully configured, ip address %s, mask %s broadcast address %s\n", - interfaceName, ipAddress, netMask, broadcastAddress); + LOG_I(OIP, "Interface %s successfully configured, ip address %s, mask %s\n", interfaceName, ipAddress, netMask); else - LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n", - interfaceName, ipAddress, netMask, broadcastAddress); + LOG_E(OIP, "Interface %s couldn't be configured (ip address %s, mask %s)\n", interfaceName, ipAddress, netMask); return returnValue; } From e2163ba312d7ff9d0bec7691ceac0ee4619d89b9 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Jul 2024 17:44:31 +0200 Subject: [PATCH 43/61] Remove netmask configuration and hardcode instead I initially planned to entirely remove the netmask configuration. However, in specific configurations, e.g. in 4G Rfsim with feMBMS, routing does not seem to work anymore using these commands: iperf -B 10.0.2.2 -s -u -i1 iperf -c 10.0.2.2 -B 10.0.2.1 -u -t 30 -b 2.00M -i1 Therefore, we simplify by hardcoding the netmask to /24, which allows the above to work. --- openair2/RRC/NAS/nas_config.c | 14 ++++---------- openair2/RRC/NAS/nas_config.h | 8 -------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 19811ed1d3..de48117e2f 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -33,9 +33,7 @@ //default values according to the examples, char *baseNetAddress ; -char *netMask ; #define NASHLP_NETPREFIX "\n" -#define NASHLP_NETMASK "\n" void nas_getparams(void) { // this datamodel require this static because we partially keep data like baseNetAddress (malloc on a global) // but we loose the opther attributes in nasoptions between two calls if is is not static ! @@ -46,7 +44,6 @@ void nas_getparams(void) { /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ {"NetworkPrefix", NASHLP_NETPREFIX, 0, .strptr=&baseNetAddress, .defstrval="10.0", TYPE_STRING, 0 }, - {"NetworkMask", NASHLP_NETMASK, 0, .strptr=&netMask, .defstrval="255.255.255.0", TYPE_STRING, 0 }, }; // clang-format on config_get(config_get_if(), nasoptions, sizeofArray(nasoptions), "nas.noS1"); @@ -56,9 +53,6 @@ void setBaseNetAddress (char *baseAddr) { strcpy(baseNetAddress,baseAddr); } -void setNetMask (char *baseAddr) { - strcpy(netMask,baseAddr); -} // sets a genneric interface parameter // (SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) @@ -145,16 +139,16 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); // sets the machine network mask - if(!returnValue) - returnValue= setInterfaceParameter(interfaceName, netMask,SIOCSIFNETMASK); + if (!returnValue) + returnValue = setInterfaceParameter(interfaceName, "255.255.255.0", SIOCSIFNETMASK); if(!returnValue) returnValue=bringInterfaceUp(interfaceName, 1); if(!returnValue) - LOG_I(OIP, "Interface %s successfully configured, ip address %s, mask %s\n", interfaceName, ipAddress, netMask); + LOG_I(OIP, "Interface %s successfully configured, ip address %s\n", interfaceName, ipAddress); else - LOG_E(OIP, "Interface %s couldn't be configured (ip address %s, mask %s)\n", interfaceName, ipAddress, netMask); + LOG_E(OIP, "Interface %s couldn't be configured (ip address %s)\n", interfaceName, ipAddress); return returnValue; } diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index fc6dda11dd..fefb12f937 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -59,12 +59,4 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if */ void setBaseNetAddress(char *baseAddr); -/*! \fn void setNetMask(char*) - * \brief This function sets the new default network mask used - * \param[in] newNetworkMask, the new network mask e.g.for 255.255.0.0 - * \note - * @ingroup _nas - */ -void setNetMask(char *baseAddr); - #endif /*NAS_CONFIG_H_*/ From 2c878c10ec7aeea29a757b89f9258d67f1325ef2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Jul 2024 17:01:54 +0200 Subject: [PATCH 44/61] Refactor setInterfaceParameter() and bringInterfaceUp() - refactor functions to make them shorter - provide doxygen strings - open socket for operation once instead of in each function - use named constant (from enum) to differentiate interface UP/DOWN - Linux kernel defines name length as IFNAM_SIZE, so use that for interface name length. Also, it seems no null-byte is needed. --- openair2/RRC/NAS/nas_config.c | 122 +++++++++++++++------------------- 1 file changed, 52 insertions(+), 70 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index de48117e2f..f9e349bccf 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -54,101 +55,82 @@ void setBaseNetAddress (char *baseAddr) { } -// sets a genneric interface parameter -// (SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) -static int setInterfaceParameter(const char *interfaceName, const char *settingAddress, int operation) +/* + * \brief set a genneric interface parameter + * \param ifn the name of the interface to modify + * \param if_addr the address that needs to be modified + * \param operation one of SIOCSIFADDR (set interface address), SIOCSIFNETMASK + * (set network mask), SIOCSIFBRDADDR (set broadcast address), SIOCSIFFLAGS + * (set flags) + * \return true on success, false otherwise + */ +static bool setInterfaceParameter(int sock_fd, const char *ifn, const char *if_addr, int operation) { - int sock_fd; - struct ifreq ifr; - struct sockaddr_in addr; + struct ifreq ifr = {0}; + strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); - if((sock_fd = socket(AF_INET,SOCK_DGRAM,0)) < 0) { - LOG_E(OIP,"Setting operation %d, for %s, address, %s : socket failed\n", - operation, interfaceName, settingAddress); - return 1; - } - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)-1); - memset(&addr, 0, sizeof(struct sockaddr_in)); - addr.sin_family = AF_INET; - inet_aton(settingAddress,&addr.sin_addr); + struct sockaddr_in addr = {.sin_family = AF_INET}; + inet_aton(if_addr, &addr.sin_addr); + //inet_pton(AF_INET6 or AF_INET) memcpy(&ifr.ifr_ifru.ifru_addr,&addr,sizeof(struct sockaddr_in)); - if(ioctl(sock_fd,operation,&ifr) < 0) { - close(sock_fd); - LOG_E(OIP,"Setting operation %d, for %s, address, %s : ioctl call failed\n", - operation, interfaceName, settingAddress); - return 2; - } - - close(sock_fd); - return 0; + bool success = ioctl(sock_fd,operation,&ifr) == 0; + if (!success) + LOG_E(OIP, "Setting operation %d for %s: ioctl call failed: %d, %s\n", operation, ifn, errno, strerror(errno)); + return success; } -// sets a genneric interface parameter -// (SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFFLAGS) -static int bringInterfaceUp(char *interfaceName, int up) +/* + * \brief bring interface up (up != 0) or down (up == 0) + */ +typedef enum { INTERFACE_DOWN, INTERFACE_UP } if_action_t; +static bool change_interface_state(int sock_fd, const char *ifn, if_action_t if_action) { - int sock_fd; - struct ifreq ifr; + struct ifreq ifr = {0}; + strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); - if((sock_fd = socket(AF_INET,SOCK_DGRAM,0)) < 0) { - LOG_E(OIP,"Bringing interface UP, for %s, failed creating socket\n", interfaceName); - return 1; - } - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)-1); - - if(up) { + if (if_action == INTERFACE_UP) { ifr.ifr_flags |= IFF_UP | IFF_NOARP | IFF_MULTICAST; - - if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) { - close(sock_fd); - LOG_E(OIP,"Bringing interface UP, for %s, failed UP ioctl\n", interfaceName); - return 2; - } } else { - // printf("desactivation de %s\n", interfaceName); ifr.ifr_flags &= (~IFF_UP); - - if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) { - close(sock_fd); - LOG_E(OIP,"Bringing interface down, for %s, failed UP ioctl\n", interfaceName); - return 2; - } } - // printf("UP/DOWN OK!\n"); - close( sock_fd ); - return 0; + bool success = ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t)&ifr) == 0; + if (!success) { + const char* action = if_action == INTERFACE_DOWN ? "DOWN" : "UP"; + LOG_E(OIP, "Bringing interface %s for %s: ioctl call failed: %d, %s\n", action, ifn, errno, strerror(errno)); + } + return success; } // non blocking full configuration of the interface (address, and the two lest octets of the address) int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifpref) { - //char buf[5]; char ipAddress[20]; - char interfaceName[20]; - int returnValue; + char interfaceName[IFNAMSIZ]; sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); - sprintf(interfaceName, "%s%d", ifpref, interface_id); - bringInterfaceUp(interfaceName, 0); - // sets the machine address - returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); + snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id); - // sets the machine network mask - if (!returnValue) - returnValue = setInterfaceParameter(interfaceName, "255.255.255.0", SIOCSIFNETMASK); + int sock_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (sock_fd < 0) { + LOG_E(UTIL, "Failed creating socket for interface management: %d, %s\n", errno, strerror(errno)); + return 1; + } - if(!returnValue) - returnValue=bringInterfaceUp(interfaceName, 1); + change_interface_state(sock_fd, interfaceName, INTERFACE_DOWN); + bool success = setInterfaceParameter(sock_fd, interfaceName, ipAddress, SIOCSIFADDR); + // set the machine network mask + if (success) + success = setInterfaceParameter(sock_fd, interfaceName, "255.255.255.0", SIOCSIFNETMASK); - if(!returnValue) + if (success) + success = change_interface_state(sock_fd, interfaceName, INTERFACE_UP); + + if (success) LOG_I(OIP, "Interface %s successfully configured, ip address %s\n", interfaceName, ipAddress); else LOG_E(OIP, "Interface %s couldn't be configured (ip address %s)\n", interfaceName, ipAddress); - return returnValue; + close(sock_fd); + return success; } From 2da09aba806a4ac29b9f979cf923c4725213973c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 9 Jul 2024 09:57:59 +0200 Subject: [PATCH 45/61] nas_config(): provide entire IP address to configure Prior to this commit, there was a global variable baseNetAddress that could be set independently through a setter and also through the configuration module. This baseNetAddress (16 bits IPv4) would then be complemented with two more bytes in nas_config(). However, this is counter-productive, as not only we have a global variable that is avoidable (we can give the entire address to nas_config() directly), but it also would not work with IPv6. Hence, modify to give nas_config() the entire address. A follow-up commit will add IPv6 support. --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 12 +++--- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 7 ++-- openair2/RRC/LTE/rrc_UE.c | 11 ++++-- openair2/RRC/LTE/rrc_eNB.c | 7 ++-- openair2/RRC/NAS/nas_config.c | 37 +++---------------- openair2/RRC/NAS/nas_config.h | 35 ++++-------------- .../ESM/MSG/PduSessionEstablishmentAccept.c | 30 ++++++++------- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 25 +++++-------- 8 files changed, 56 insertions(+), 108 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 992357e8e7..3a64bbf68e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2296,28 +2296,26 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { pdcp_params.optmask = pdcp_params.optmask | pdcp_optmask ; - nas_getparams(); - if (UE_NAS_USE_TUN) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, 2, "oaitun_ue"); + nas_config(1, "10.0.1.2", "oaitun_ue"); netlink_init_mbms_tun("oaitun_uem", id + 1); - nas_config(1, 2, 2, "oaitun_uem"); + nas_config(1, "10.0.2.2", "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); - nas_config(1, 1, 1, "oaitun_enb"); + nas_config(1, "10.0.1.1", "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 1); - nas_config(1, 2, 1, "oaitun_enm"); + nas_config(1, "10.0.2.1", "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 0); - nas_config(1, 2, 1, "oaitun_enm"); + nas_config(1, "10.0.2.1", "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 51feb0d955..5146cf3cee 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -610,8 +610,6 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) pdcp_optmask = pdcp_optmask | _pdcp_optmask ; - nas_getparams(); - if (UE_NAS_USE_TUN) { char *ifprefix = get_softmodem_params()->nsa ? "oaitun_nrue" : "oaitun_ue"; int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) @@ -619,7 +617,8 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) : 1; netlink_init_tun(ifprefix, num_if, id); if (IS_SOFTMODEM_NOS1) { - nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifprefix); + const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3"; + nas_config(1, ip, ifprefix); set_qfi_pduid(7, 10); } LOG_I(PDCP, "UE pdcp will use tun interface\n"); @@ -627,7 +626,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) } else if (ENB_NAS_USE_TUN) { char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb"; netlink_init_tun(ifprefix, 1, id); - nas_config(1, 1, 1, ifprefix); + nas_config(1, "10.0.1.1", ifprefix); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); } diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 9de1e52527..d125892d83 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -765,10 +765,13 @@ rrc_ue_establish_drb( ip_addr_offset4 = 1; LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); - oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, // interface_id - UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), // third_octet - ip_addr_offset4 + ue_mod_idP + 1, // fourth_octet - "oaitun_oip"); + char ip[20]; + snprintf(ip, + sizeof(ip), + "10.0.%d.%d", + UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), + ip_addr_offset4 + ue_mod_idP + 1); + oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, ip, "oaitun_oip"); if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 3828df4cb7..cda6ac2013 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -5255,10 +5255,9 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", ctxt_pP->module_id, ctxt_pP->module_id); - oip_ifup = nas_config(ctxt_pP->module_id, // interface index - ctxt_pP->module_id + 1, // third octet - ctxt_pP->module_id + 1, // fourth octet - "oaitun_oai"); + char ip[20]; + snprintf(ip, sizeof(ip), "10.0.%d.%d", ctxt_pP->module_id + 1, ctxt_pP->module_id + 1); + oip_ifup = nas_config(ctxt_pP->module_id, ip, "oaitun_oai"); if (oip_ifup == 0) { // interface is up --> send a config the DRB module_id_t ue_module_id; diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index f9e349bccf..4606ade6ba 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -29,31 +29,6 @@ #include "nas_config.h" #include "common/utils/LOG/log.h" -#include "common/config/config_userapi.h" - -//default values according to the examples, - -char *baseNetAddress ; -#define NASHLP_NETPREFIX "\n" -void nas_getparams(void) { - // this datamodel require this static because we partially keep data like baseNetAddress (malloc on a global) - // but we loose the opther attributes in nasoptions between two calls if is is not static ! - // clang-format off - paramdef_t nasoptions[] = { - /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - /* configuration parameters for netlink, includes network parameters when running in noS1 mode */ - /* optname helpstr paramflags XXXptr defXXXval type numelt */ - /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - {"NetworkPrefix", NASHLP_NETPREFIX, 0, .strptr=&baseNetAddress, .defstrval="10.0", TYPE_STRING, 0 }, - }; - // clang-format on - config_get(config_get_if(), nasoptions, sizeofArray(nasoptions), "nas.noS1"); -} - -void setBaseNetAddress (char *baseAddr) { - strcpy(baseNetAddress,baseAddr); -} - /* * \brief set a genneric interface parameter @@ -104,21 +79,19 @@ static bool change_interface_state(int sock_fd, const char *ifn, if_action_t if_ } // non blocking full configuration of the interface (address, and the two lest octets of the address) -int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifpref) +bool nas_config(int interface_id, const char *ip, const char *ifpref) { - char ipAddress[20]; char interfaceName[IFNAMSIZ]; - sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id); int sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (sock_fd < 0) { LOG_E(UTIL, "Failed creating socket for interface management: %d, %s\n", errno, strerror(errno)); - return 1; + return false; } change_interface_state(sock_fd, interfaceName, INTERFACE_DOWN); - bool success = setInterfaceParameter(sock_fd, interfaceName, ipAddress, SIOCSIFADDR); + bool success = setInterfaceParameter(sock_fd, interfaceName, ip, SIOCSIFADDR); // set the machine network mask if (success) success = setInterfaceParameter(sock_fd, interfaceName, "255.255.255.0", SIOCSIFNETMASK); @@ -127,9 +100,9 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if success = change_interface_state(sock_fd, interfaceName, INTERFACE_UP); if (success) - LOG_I(OIP, "Interface %s successfully configured, ip address %s\n", interfaceName, ipAddress); + LOG_I(OIP, "Interface %s successfully configured, ip address %s\n", interfaceName, ip); else - LOG_E(OIP, "Interface %s couldn't be configured (ip address %s)\n", interfaceName, ipAddress); + LOG_E(OIP, "Interface %s couldn't be configured (ip address %s)\n", interfaceName, ip); close(sock_fd); return success; diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index fefb12f937..265e7b5760 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -19,44 +19,25 @@ * contact@openairinterface.org */ -/*! \file nas_config.h - * \brief Configures the nasmesh interface - * \author Daniel Camara and navid nikaein - * \date 2006-2011 - * \version 0.1 - * \company Eurecom - */ #ifndef NAS_CONFIG_H_ #define NAS_CONFIG_H_ +#include #include -/*! \fn void void nas_getparams(void)(void) - * \brief This function get parameters used to configure network interface when running in noS1 mode - * \note - * @ingroup _nas - */ -void nas_getparams(void); - /*! \fn int nas_config(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, * basic address, network mask and broadcast address, as the default configured * ones - * \param[in] interfaceName, the name of the interface, e.g. nasmesh0 or nasmesh1 - * \param[in] third octet of the ip address e.g. for the 10.1.2.3 address would be 2 - * \param[in] fourth octet of the ip address e.g. for the 10.1.2.3 address would be 3 - * \return 0 on success, otherwise 1, if couldn't open a socket and 2 if the ioctl fails + * \param[in] interface_id number of this interface, prepended after interface + * name + * \param[in] ip IPv4 address of this interface as a string + * \param[in] ifprefix interface name prefix to which an interface number will + * be appended + * \return true on success, otherwise false * \note * @ingroup _nas */ -int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifprefix); - -/*! \fn void setBaseNetAddress(char*) - * \brief This function sets the basic network address used - * \param[in] baseAddr, the new basic address e.g.for 10.0.1.2, would be 10.0 - * \note - * @ingroup _nas - */ -void setBaseNetAddress(char *baseAddr); +bool nas_config(int interface_id, const char *ip, const char *ifprefix); #endif /*NAS_CONFIG_H_*/ diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 99ea466e2e..b83dd100dd 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -25,8 +25,6 @@ #include "openair2/RRC/NAS/nas_config.h" #include "openair2/SDAP/nr_sdap/nr_sdap.h" -extern char *baseNetAddress; - static uint16_t getShort(uint8_t *input) { uint16_t tmp16; @@ -105,19 +103,23 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ psea_msg.pdu_addr_ie.pdu_length = *curPtr++; psea_msg.pdu_addr_ie.pdu_type = *curPtr++; + DevAssert(psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4); if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4) { - psea_msg.pdu_addr_ie.pdu_addr_oct1 = *curPtr++; - psea_msg.pdu_addr_ie.pdu_addr_oct2 = *curPtr++; - psea_msg.pdu_addr_ie.pdu_addr_oct3 = *curPtr++; - psea_msg.pdu_addr_ie.pdu_addr_oct4 = *curPtr++; - nas_getparams(); - sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); - nas_config(1, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); - LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", - psea_msg.pdu_addr_ie.pdu_addr_oct1, - psea_msg.pdu_addr_ie.pdu_addr_oct2, - psea_msg.pdu_addr_ie.pdu_addr_oct3, - psea_msg.pdu_addr_ie.pdu_addr_oct4); + pdu_address_t *addr = &psea_msg.pdu_addr_ie; + addr->pdu_addr_oct1 = *curPtr++; + addr->pdu_addr_oct2 = *curPtr++; + addr->pdu_addr_oct3 = *curPtr++; + addr->pdu_addr_oct4 = *curPtr++; + char ip[20]; + snprintf(ip, + sizeof(ip), + "%d.%d.%d.%d", + addr->pdu_addr_oct1, + addr->pdu_addr_oct2, + addr->pdu_addr_oct3, + addr->pdu_addr_oct4); + nas_config(1, ip, "oaitun_ue"); + LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %s\n", ip); } else { curPtr += psea_msg.pdu_addr_ie.pdu_length; } diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 8f81684437..fd4088aab8 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -53,7 +53,6 @@ #include "openair3/SECU/nas_stream_eia2.h" #include "openair3/UTILS/conversions.h" -extern char *baseNetAddress; extern uint16_t NB_UE_INST; static nr_ue_nas_t nr_ue_nas = {0}; static nr_nas_msg_snssai_t nas_allowed_nssai[8]; @@ -842,11 +841,11 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buffer){ uint8_t msg_type = *(pdu_buffer + 16); if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ - sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); - int third_octet = *(pdu_buffer + 41); - int fourth_octet = *(pdu_buffer + 42); + uint8_t *ip_p = pdu_buffer + 39; + char ip[20]; + sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_A(NAS, "Received PDU Session Establishment Accept\n"); - nas_config(1, third_octet, fourth_octet, "oaitun_ue"); + nas_config(1, ip, "oaitun_ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); } @@ -1428,17 +1427,11 @@ void *nas_nrue(void *args_p) while (offset < payload_container_length) { if (*(payload_container + offset) == 0x29) { // PDU address IEI if ((*(payload_container + offset + 1) == 0x05) && (*(payload_container + offset + 2) == 0x01)) { // IPV4 - nas_getparams(); - sprintf(baseNetAddress, "%d.%d", *(payload_container + offset + 3), *(payload_container + offset + 4)); - int third_octet = *(payload_container + offset + 5); - int fourth_octet = *(payload_container + offset + 6); - LOG_I(NAS, - "Received PDU Session Establishment Accept, UE IP: %d.%d.%d.%d\n", - *(payload_container + offset + 3), - *(payload_container + offset + 4), - *(payload_container + offset + 5), - *(payload_container + offset + 6)); - nas_config(1, third_octet, fourth_octet, "oaitun_ue"); + uint8_t *ip_p = payload_container + offset + 3; + char ip[20]; + snprintf(ip, sizeof(ip), "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); + LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %s\n", ip); + nas_config(1, ip, "oaitun_ue"); break; } } From ffcf53fc757a217a8fd8fcfc12d2a572cc43ca76 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 17 Jul 2024 07:53:36 +0200 Subject: [PATCH 46/61] Reintroduce the IP rule&route for OAI UE through setup_ue_ipv4_route() These rules & route are necessary to properly send packets on oaitun_ue1 interface: 1. This forces the packets coming from a subnet different than the UE's subnet to go back through oaitun_ue1 rather than via what the default route defined on the system (e.g., important if ping from the internet arrives). 2. On machines setting net.ipv4.conf.oaitun_ue1.rp_filter=1 (e.g. RHEL), this prevents that source filtering for packets coming back is applied and those packets be dropped. By default, many hosts have rp_filter=2, so no strict source filtering is applied, and it would work; on others, this rule prevents source filter dropping. --- openair2/RRC/NAS/nas_config.c | 27 +++++++++++++++++++ openair2/RRC/NAS/nas_config.h | 14 ++++++++++ .../ESM/MSG/PduSessionEstablishmentAccept.c | 1 + openair3/NAS/NR_UE/nr_nas_msg_sim.c | 2 ++ 4 files changed, 44 insertions(+) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 4606ade6ba..5a437febf1 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -29,6 +29,7 @@ #include "nas_config.h" #include "common/utils/LOG/log.h" +#include "common/utils/system.h" /* * \brief set a genneric interface parameter @@ -107,3 +108,29 @@ bool nas_config(int interface_id, const char *ip, const char *ifpref) close(sock_fd); return success; } + +void setup_ue_ipv4_route(int interface_id, const char *ipv4, const char *ifpref) +{ + int table_id = interface_id - 1 + 10000; + char interfaceName[IFNAMSIZ]; + snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id); + + char command_line[500]; + int res = sprintf(command_line, + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s table %d", + ipv4, + table_id, + ipv4, + table_id, + interfaceName, + table_id); + + if (res < 0) { + LOG_E(UTIL, "Could not create ip rule/route commands string\n"); + return; + } + background_system(command_line); +} + diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 265e7b5760..0db23c2946 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -40,4 +40,18 @@ */ bool nas_config(int interface_id, const char *ip, const char *ifprefix); +/*! + * \brief Setup a IPv4 rule in table (interface_id - 1 + 10000) and route to + * force packets coming into interface back through it, and workaround + * net.ipv4.conf.all.rp_filter=2 (strict source filtering would filter out + * responses of packets going out through interface to another IP address not + * in same subnet). + * \param[in] interface_id number of this interface, prepended after interface + * name + * \param[in] ipv4 IPv4 address of the UE + * \param[in] ifprefix interface name prefix to which an interface number will + * be appended + */ +void setup_ue_ipv4_route(int interface_id, const char *ipv4, const char *ifpref); + #endif /*NAS_CONFIG_H_*/ diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index b83dd100dd..46b77efcb1 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -119,6 +119,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ addr->pdu_addr_oct3, addr->pdu_addr_oct4); nas_config(1, ip, "oaitun_ue"); + setup_ue_ipv4_route(1, ip, "oaitun_ue"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %s\n", ip); } else { curPtr += psea_msg.pdu_addr_ie.pdu_length; diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index fd4088aab8..b40229ef0d 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -846,6 +846,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_A(NAS, "Received PDU Session Establishment Accept\n"); nas_config(1, ip, "oaitun_ue"); + setup_ue_ipv4_route(1, ip, "oaitun_ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); } @@ -1432,6 +1433,7 @@ void *nas_nrue(void *args_p) snprintf(ip, sizeof(ip), "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %s\n", ip); nas_config(1, ip, "oaitun_ue"); + setup_ue_ipv4_route(1, ip, "oaitun_ue"); break; } } From ae5702d014c2f26f0d7e6f6f77393b25475d3831 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 15 Jul 2024 15:49:21 +0200 Subject: [PATCH 47/61] nas_config(): change API to handle both IPv4 and IPv6 Implement handling of IPv4 and IPv6 (on the same interface) in nas_config(). --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 10 +-- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 4 +- openair2/RRC/LTE/rrc_UE.c | 2 +- openair2/RRC/LTE/rrc_eNB.c | 2 +- openair2/RRC/NAS/nas_config.c | 69 +++++++++++++++---- openair2/RRC/NAS/nas_config.h | 6 +- .../ESM/MSG/PduSessionEstablishmentAccept.c | 2 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 4 +- 8 files changed, 71 insertions(+), 28 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 3a64bbf68e..122bd14794 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2300,22 +2300,22 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) - nas_config(1, "10.0.1.2", "oaitun_ue"); + nas_config(1, "10.0.1.2", NULL, "oaitun_ue"); netlink_init_mbms_tun("oaitun_uem", id + 1); - nas_config(1, "10.0.2.2", "oaitun_uem"); + nas_config(1, "10.0.2.2", NULL, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); - nas_config(1, "10.0.1.1", "oaitun_enb"); + nas_config(1, "10.0.1.1", NULL, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 1); - nas_config(1, "10.0.2.1", "oaitun_enm"); + nas_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 0); - nas_config(1, "10.0.2.1", "oaitun_enm"); + nas_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 5146cf3cee..051999ad9d 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -618,7 +618,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) netlink_init_tun(ifprefix, num_if, id); if (IS_SOFTMODEM_NOS1) { const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3"; - nas_config(1, ip, ifprefix); + nas_config(1, ip, NULL, ifprefix); set_qfi_pduid(7, 10); } LOG_I(PDCP, "UE pdcp will use tun interface\n"); @@ -626,7 +626,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) } else if (ENB_NAS_USE_TUN) { char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb"; netlink_init_tun(ifprefix, 1, id); - nas_config(1, "10.0.1.1", ifprefix); + nas_config(1, "10.0.1.1", NULL, ifprefix); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); } diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index d125892d83..1d1de490bb 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -771,7 +771,7 @@ rrc_ue_establish_drb( "10.0.%d.%d", UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), ip_addr_offset4 + ue_mod_idP + 1); - oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, ip, "oaitun_oip"); + oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, ip, NULL, "oaitun_oip"); if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index cda6ac2013..1b42985bde 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -5257,7 +5257,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id); char ip[20]; snprintf(ip, sizeof(ip), "10.0.%d.%d", ctxt_pP->module_id + 1, ctxt_pP->module_id + 1); - oip_ifup = nas_config(ctxt_pP->module_id, ip, "oaitun_oai"); + oip_ifup = nas_config(ctxt_pP->module_id, ip, NULL, "oaitun_oai"); if (oip_ifup == 0) { // interface is up --> send a config the DRB module_id_t ue_module_id; diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 5a437febf1..f744c065c5 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "nas_config.h" #include "common/utils/LOG/log.h" @@ -40,17 +41,42 @@ * (set flags) * \return true on success, false otherwise */ -static bool setInterfaceParameter(int sock_fd, const char *ifn, const char *if_addr, int operation) +static bool setInterfaceParameter(int sock_fd, const char *ifn, int af, const char *if_addr, int operation) { + DevAssert(af == AF_INET || af == AF_INET6); struct ifreq ifr = {0}; strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); + struct in6_ifreq ifr6 = {0}; - struct sockaddr_in addr = {.sin_family = AF_INET}; - inet_aton(if_addr, &addr.sin_addr); - //inet_pton(AF_INET6 or AF_INET) - memcpy(&ifr.ifr_ifru.ifru_addr,&addr,sizeof(struct sockaddr_in)); + void *ioctl_opt = NULL; + if (af == AF_INET) { + struct sockaddr_in addr = {.sin_family = AF_INET}; + int ret = inet_pton(af, if_addr, &addr.sin_addr); + if (ret != 1) { + LOG_E(OIP, "inet_pton(): cannot convert %s to IPv4 network address\n", if_addr); + return false; + } + memcpy(&ifr.ifr_ifru.ifru_addr,&addr,sizeof(struct sockaddr_in)); + ioctl_opt = 𝔦 + } else { + struct sockaddr_in6 addr6 = {.sin6_family = AF_INET6}; + int ret = inet_pton(af, if_addr, &addr6.sin6_addr); + if (ret != 1) { + LOG_E(OIP, "inet_pton(): cannot convert %s to IPv6 network address\n", if_addr); + return false; + } + memcpy(&ifr6.ifr6_addr, &addr6.sin6_addr, sizeof(struct in6_addr)); + // we need to get the if index to put it into ifr6 + if (ioctl(sock_fd, SIOGIFINDEX, &ifr) < 0) { + LOG_E(OIP, "ioctl() failed: errno %d, %s\n", errno, strerror(errno)); + return false; + } + ifr6.ifr6_ifindex = ifr.ifr_ifindex; + ifr6.ifr6_prefixlen = 64; + ioctl_opt = &ifr6; + } - bool success = ioctl(sock_fd,operation,&ifr) == 0; + bool success = ioctl(sock_fd, operation, ioctl_opt) == 0; if (!success) LOG_E(OIP, "Setting operation %d for %s: ioctl call failed: %d, %s\n", operation, ifn, errno, strerror(errno)); return success; @@ -80,11 +106,13 @@ static bool change_interface_state(int sock_fd, const char *ifn, if_action_t if_ } // non blocking full configuration of the interface (address, and the two lest octets of the address) -bool nas_config(int interface_id, const char *ip, const char *ifpref) +bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifpref) { char interfaceName[IFNAMSIZ]; snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id); + AssertFatal(ipv4 != NULL || ipv6 != NULL, "need to have IP address, but none given\n"); + int sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (sock_fd < 0) { LOG_E(UTIL, "Failed creating socket for interface management: %d, %s\n", errno, strerror(errno)); @@ -92,18 +120,33 @@ bool nas_config(int interface_id, const char *ip, const char *ifpref) } change_interface_state(sock_fd, interfaceName, INTERFACE_DOWN); - bool success = setInterfaceParameter(sock_fd, interfaceName, ip, SIOCSIFADDR); - // set the machine network mask - if (success) - success = setInterfaceParameter(sock_fd, interfaceName, "255.255.255.0", SIOCSIFNETMASK); + bool success = true; + if (ipv4 != NULL) + success = setInterfaceParameter(sock_fd, interfaceName, AF_INET, ipv4, SIOCSIFADDR); + // set the machine network mask for IPv4 + if (success && ipv4 != NULL) + success = setInterfaceParameter(sock_fd, interfaceName, AF_INET, "255.255.255.0", SIOCSIFNETMASK); + + if (ipv6 != NULL) { + // for setting the IPv6 address, we need an IPv6 socket. For setting IPv4, + // we need an IPv4 socket. So do all operations using IPv4 socket, except + // for setting the IPv6 + int sock_fd = socket(AF_INET6, SOCK_DGRAM, 0); + if (sock_fd < 0) { + LOG_E(UTIL, "Failed creating socket for interface management: %d, %s\n", errno, strerror(errno)); + success = false; + } + success = success && setInterfaceParameter(sock_fd, interfaceName, AF_INET6, ipv6, SIOCSIFADDR); + close(sock_fd); + } if (success) success = change_interface_state(sock_fd, interfaceName, INTERFACE_UP); if (success) - LOG_I(OIP, "Interface %s successfully configured, ip address %s\n", interfaceName, ip); + LOG_I(OIP, "Interface %s successfully configured, IPv4 %s, IPv6 %s\n", interfaceName, ipv4, ipv6); else - LOG_E(OIP, "Interface %s couldn't be configured (ip address %s)\n", interfaceName, ip); + LOG_E(OIP, "Interface %s couldn't be configured (IPv4 %s, IPv6 %s)\n", interfaceName, ipv4, ipv6); close(sock_fd); return success; diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 0db23c2946..f937b6ccf5 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -23,7 +23,6 @@ #define NAS_CONFIG_H_ #include -#include /*! \fn int nas_config(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, @@ -31,14 +30,15 @@ * ones * \param[in] interface_id number of this interface, prepended after interface * name - * \param[in] ip IPv4 address of this interface as a string + * \param[in] ipv4 IPv4 address of this interface as a string + * \param[in] ipv6 IPv6 address of this interface as a string * \param[in] ifprefix interface name prefix to which an interface number will * be appended * \return true on success, otherwise false * \note * @ingroup _nas */ -bool nas_config(int interface_id, const char *ip, const char *ifprefix); +bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifprefix); /*! * \brief Setup a IPv4 rule in table (interface_id - 1 + 10000) and route to diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 46b77efcb1..4a307039c9 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -118,7 +118,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ addr->pdu_addr_oct2, addr->pdu_addr_oct3, addr->pdu_addr_oct4); - nas_config(1, ip, "oaitun_ue"); + nas_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %s\n", ip); } else { diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index b40229ef0d..53575244fd 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -845,7 +845,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff char ip[20]; sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_A(NAS, "Received PDU Session Establishment Accept\n"); - nas_config(1, ip, "oaitun_ue"); + nas_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); @@ -1432,7 +1432,7 @@ void *nas_nrue(void *args_p) char ip[20]; snprintf(ip, sizeof(ip), "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %s\n", ip); - nas_config(1, ip, "oaitun_ue"); + nas_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); break; } From d0f32d8aad72ff433a6b33016d8137858584890e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 1 Aug 2024 18:46:07 +0200 Subject: [PATCH 48/61] Refactor change_interface_state() - Read interface flags before setting status to not inadvertently overwrite existing flags - Set interface flag point-to-point, remove multicast (I think a UE is not supposed to send anywhere else than to the UPF, so it seems to not make sense to declare the interface as multicast) --- openair2/RRC/NAS/nas_config.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index f744c065c5..c1e85a3360 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -88,21 +88,30 @@ static bool setInterfaceParameter(int sock_fd, const char *ifn, int af, const ch typedef enum { INTERFACE_DOWN, INTERFACE_UP } if_action_t; static bool change_interface_state(int sock_fd, const char *ifn, if_action_t if_action) { + const char* action = if_action == INTERFACE_DOWN ? "DOWN" : "UP"; + struct ifreq ifr = {0}; strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); + /* get flags of this interface: see netdevice(7) */ + bool success = ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t)&ifr) == 0; + if (!success) + goto fail_interface_state; if (if_action == INTERFACE_UP) { - ifr.ifr_flags |= IFF_UP | IFF_NOARP | IFF_MULTICAST; + ifr.ifr_flags |= IFF_UP | IFF_NOARP | IFF_POINTOPOINT; + ifr.ifr_flags &= ~IFF_MULTICAST; } else { - ifr.ifr_flags &= (~IFF_UP); + ifr.ifr_flags &= ~IFF_UP; } - bool success = ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t)&ifr) == 0; - if (!success) { - const char* action = if_action == INTERFACE_DOWN ? "DOWN" : "UP"; - LOG_E(OIP, "Bringing interface %s for %s: ioctl call failed: %d, %s\n", action, ifn, errno, strerror(errno)); - } - return success; + success = ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t)&ifr) == 0; + if (!success) + goto fail_interface_state; + return true; + +fail_interface_state: + LOG_E(OIP, "Bringing interface %s for %s: ioctl call failed: %d, %s\n", action, ifn, errno, strerror(errno)); + return false; } // non blocking full configuration of the interface (address, and the two lest octets of the address) From 659a81997bc1f6fe03a3ca977196c8cf8e648100 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 31 Jul 2024 15:01:12 +0200 Subject: [PATCH 49/61] Handle IPv6/IPv4v6 PDU sessions Handle IPv6 (and IPv4v6) PDU sessions by correctly instructing nas_config() to set up the interface with provided IP addresses. Note that as of now, IPv6 PDU sessions have not been fully tested. Remove a useless assert at the gNB; to my understanding the gNB does not care about the IP session type (at least for IP), as it just transparently tunnels the IP packets from/to GTP. I added a comment in the code where to change to request a PDU session different from IPv4. Currently it is hardcoded to IPv4, and it seems that a default OAI 5GC config would reject a PDU session type different from IPv4. --- openair2/RRC/NR/rrc_gNB_NGAP.c | 1 - .../ESM/MSG/PduSessionEstablishmentAccept.c | 61 ++++++++++++++----- .../ESM/MSG/PduSessionEstablishmentAccept.h | 5 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index e8050f2e5d..a98853af28 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -310,7 +310,6 @@ static int decodePDUSessionResourceSetup(pdusession_t *session) /* mandatory PDUSessionType */ case NGAP_ProtocolIE_ID_id_PDUSessionType: session->pdu_session_type = (uint8_t)pdusessionTransfer_ies->value.choice.PDUSessionType; - AssertFatal(session->pdu_session_type == PDUSessionType_ipv4 || session->pdu_session_type == PDUSessionType_ipv4v6, "To be developped: support not IPv4 sessions\n"); break; /* optional SecurityIndication */ diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index 4a307039c9..decb80d7e3 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -32,6 +32,29 @@ static uint16_t getShort(uint8_t *input) return htons(tmp16); } +static int capture_ipv4_addr(const uint8_t *addr, char *ip, size_t len) +{ + return snprintf(ip, len, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); +} + +static int capture_ipv6_addr(const uint8_t *addr, char *ip, size_t len) +{ + // 24.501 Sec 9.11.4.10: "an interface identifier for the IPv6 link local + // address": link local starts with fe80::, and only the last 64bits are + // given (middle is zero) + return snprintf(ip, + len, + "fe80::%02x%02x:%02x%02x:%02x%02x:%02x%02x", + addr[0], + addr[1], + addr[2], + addr[3], + addr[4], + addr[5], + addr[6], + addr[7]); +} + void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length) { security_protected_nas_5gs_msg_t sec_nas_hdr; @@ -103,25 +126,35 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ psea_msg.pdu_addr_ie.pdu_length = *curPtr++; psea_msg.pdu_addr_ie.pdu_type = *curPtr++; - DevAssert(psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4); + uint8_t *addr = psea_msg.pdu_addr_ie.pdu_addr_oct; if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4) { - pdu_address_t *addr = &psea_msg.pdu_addr_ie; - addr->pdu_addr_oct1 = *curPtr++; - addr->pdu_addr_oct2 = *curPtr++; - addr->pdu_addr_oct3 = *curPtr++; - addr->pdu_addr_oct4 = *curPtr++; + for (int i = 0; i < 4; ++i) + addr[i] = *curPtr++; char ip[20]; - snprintf(ip, - sizeof(ip), - "%d.%d.%d.%d", - addr->pdu_addr_oct1, - addr->pdu_addr_oct2, - addr->pdu_addr_oct3, - addr->pdu_addr_oct4); + capture_ipv4_addr(&addr[0], ip, sizeof(ip)); nas_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); - LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %s\n", ip); + } else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV6) { + for (int i = 0; i < 8; ++i) + addr[i] = *curPtr++; + char ipv6[40]; + capture_ipv6_addr(addr, ipv6, sizeof(ipv6)); + nas_config(1, NULL, ipv6, "oaitun_ue"); + } else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4V6) { + // 24.501 Sec 9.11.4.10: "If the PDU session type value indicates + // IPv4v6, the PDU address information in octet 4 to octet 11 + // contains an interface identifier for the IPv6 link local address + // and in octet 12 to octet 15 contains an IPv4 address." + for (int i = 0; i < 12; ++i) + addr[i] = *curPtr++; + char ipv6[40]; + capture_ipv6_addr(addr, ipv6, sizeof(ipv6)); + char ipv4[20]; + capture_ipv4_addr(&addr[8], ipv4, sizeof(ipv4)); + nas_config(1, ipv4, ipv6, "oaitun_ue"); + setup_ue_ipv4_route(1, ipv4, "oaitun_ue"); } else { + LOG_E(NAS, "unknown/unhandled PDU session establishment accept PDU type %d\n", psea_msg.pdu_addr_ie.pdu_type); curPtr += psea_msg.pdu_addr_ie.pdu_length; } break; diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h index 95ca942339..a254debfbe 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.h @@ -114,10 +114,7 @@ typedef struct pdu_address_s { uint8_t pdu_iei; /* PDU Address IEI (0x29) */ uint8_t pdu_length; /* Length of PDU address contents */ uint8_t pdu_type; /* PDU session type value */ - uint8_t pdu_addr_oct1; /* PDU address information (1st Octet)*/ - uint8_t pdu_addr_oct2; /* PDU address information (2nd Octet)*/ - uint8_t pdu_addr_oct3; /* PDU address information (3rd Octet)*/ - uint8_t pdu_addr_oct4; /* PDU address information (4th Octet)*/ + uint8_t pdu_addr_oct[12]; /* PDU address information (depending on type, up to 12 bytes)*/ } pdu_address_t; /* TS 24.501 9.11.4.10 */ typedef struct dnn_s { diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 53575244fd..5b8edeab7e 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -1176,7 +1176,7 @@ static void request_default_pdusession(int instance, int nssai_idx) { MessageDef *message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_PDU_SESSION_REQ); NAS_PDU_SESSION_REQ(message_p).pdusession_id = 10; /* first or default pdu session */ - NAS_PDU_SESSION_REQ(message_p).pdusession_type = 0x91; + NAS_PDU_SESSION_REQ(message_p).pdusession_type = 0x91; // 0x91 = IPv4, 0x92 = IPv6, 0x93 = IPv4v6 NAS_PDU_SESSION_REQ(message_p).sst = nas_allowed_nssai[nssai_idx].sst; NAS_PDU_SESSION_REQ(message_p).sd = nas_allowed_nssai[nssai_idx].sd; itti_send_msg_to_task(TASK_NAS_NRUE, instance, message_p); From 2e804f53c0c4e04e19564446705a446281033e6a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 20 Jul 2024 08:45:56 +0200 Subject: [PATCH 50/61] Remove useless LINK_ENB_PDCP_TO_IP_DRIVER option --- executables/lte-softmodem.c | 2 +- executables/lte-uesoftmodem.c | 2 +- executables/nr-softmodem.c | 6 ++---- executables/nr-uesoftmodem.c | 2 +- openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c | 9 ++------- openair2/LAYER2/PDCP_v10.1.0/pdcp.h | 2 -- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 59a58f30dc..99f98d4f83 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -407,7 +407,7 @@ extern void phy_free_RU(RU_t *); static void init_pdcp(void) { pdcp_layer_init(); - uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_IP_DRIVER_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? 0 : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (IS_SOFTMODEM_NOS1) pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT; diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index 2373670015..a75a22fba4 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -488,7 +488,7 @@ static inline void wait_nfapi_init(char *thread_name) { } static void init_pdcp(int ue_id) { - uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + uint32_t pdcp_initmask = !IS_SOFTMODEM_NOS1 ? LINK_ENB_PDCP_TO_GTPV1U_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index b196a10970..3d3544dfc6 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -542,10 +542,8 @@ static void wait_nfapi_init(char *thread_name) { } void init_pdcp(void) { - uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? - LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT : - LINK_ENB_PDCP_TO_GTPV1U_BIT; - + uint32_t pdcp_initmask = IS_SOFTMODEM_NOS1 ? ENB_NAS_USE_TUN_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; + if (!NODE_IS_DU(get_node_type())) { nr_pdcp_layer_init(get_node_type() == ngran_gNB_CUCP); nr_pdcp_module_init(pdcp_initmask, 0); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index d64be3125a..0e679a1bbb 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -326,7 +326,7 @@ void init_openair0() static void init_pdcp(int ue_id) { - uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : LINK_ENB_PDCP_TO_GTPV1U_BIT; /*if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index e32cb81b00..26f639eeea 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -106,10 +106,7 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., if (ret == -1) { LOG_E(PDCP, "[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); - - if (LINK_ENB_PDCP_TO_IP_DRIVER) { - exit(1); - } + return 0; } memset(&nas_src_addr, 0, sizeof(nas_src_addr)); @@ -144,9 +141,7 @@ int netlink_init_tun(const char *ifprefix, int num_if, int id) if (ret == -1) { LOG_E(PDCP, "TUN: Error fcntl (%d:%s)\n",errno, strerror(errno)); - if (LINK_ENB_PDCP_TO_IP_DRIVER) { - exit(1); - } + return 0; } } /* for */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 04b6dba0de..7a2ce5b84c 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -49,7 +49,6 @@ #define MAX_NUMBER_NETIF 1 //16 #define ENB_NAS_USE_TUN_W_MBMS_BIT (1<< 10) -#define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13) #define LINK_ENB_PDCP_TO_GTPV1U_BIT (1<< 14) #define UE_NAS_USE_TUN_BIT (1<< 15) #define ENB_NAS_USE_TUN_BIT (1<< 16) @@ -58,7 +57,6 @@ typedef struct { } pdcp_params_t; -#define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT) #define LINK_ENB_PDCP_TO_GTPV1U ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_GTPV1U_BIT) #define UE_NAS_USE_TUN ( get_pdcp_optmask() & UE_NAS_USE_TUN_BIT) #define ENB_NAS_USE_TUN ( get_pdcp_optmask() & ENB_NAS_USE_TUN_BIT) From 3a99fb829377c617208a939c30c0449f7c94dcef Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jul 2024 11:52:25 +0200 Subject: [PATCH 51/61] Set up 4G UE addr via nas_config() --- openair3/NAS/UE/ESM/esm_ebr_context.c | 147 ++------------------------ 1 file changed, 9 insertions(+), 138 deletions(-) diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index ca69687abe..02278ddf1a 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -45,6 +45,7 @@ Description Defines functions used to handle EPS bearer contexts. #include "esm_ebr.h" #include "esm_ebr_context.h" +#include "openair2/RRC/NAS/nas_config.h" #include "emm_sap.h" #include "system.h" @@ -194,15 +195,6 @@ int esm_ebr_context_create( // LG ADD TEMP { - char *tmp = NULL; - char ipv4_addr[INET_ADDRSTRLEN]; - //char ipv6_addr[INET6_ADDRSTRLEN]; - int netmask = 32; - char broadcast[INET_ADDRSTRLEN]; - struct in_addr in_addr; - char command_line[500]; - int res = -1; - switch (pdn->type) { case NET_PDN_TYPE_IPV4V6: @@ -210,135 +202,14 @@ int esm_ebr_context_create( /* TODO? */ // etc - case NET_PDN_TYPE_IPV4: - // in_addr is in network byte order - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((pdn->ip_addr[1] << 16) & 0x00FF0000) | - ((pdn->ip_addr[2] << 8) & 0x0000FF00) | - ( pdn->ip_addr[3] & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - //AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(ipv4_addr, tmp); - - if (IN_CLASSA(ntohl(in_addr.s_addr))) { - netmask = 8; - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((255 << 16) & 0x00FF0000) | - ((255 << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else if (IN_CLASSB(ntohl(in_addr.s_addr))) { - netmask = 16; - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((pdn->ip_addr[1] << 16) & 0x00FF0000) | - ((255 << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else if (IN_CLASSC(ntohl(in_addr.s_addr))) { - netmask = 24; - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((pdn->ip_addr[1] << 16) & 0x00FF0000) | - ((pdn->ip_addr[2] << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else { - netmask = 32; - strcpy(broadcast, ipv4_addr); - } - LOG_D(NAS, "setting commandline string: " - "ip address add %s/%d broadcast %s dev %s%d && " - "ip link set %s%d up && " - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev %s%d table %d", - ipv4_addr, netmask, broadcast, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, - ipv4_addr, ueid + 10000, - ipv4_addr, ueid + 10000, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", - ueid + 1, ueid + 10000); - if (!get_softmodem_params()->nsa) - { - res = sprintf(command_line, - "ip address add %s/%d broadcast %s dev %s%d && " - "ip link set %s%d up && " - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev %s%d table %d", - ipv4_addr, netmask, broadcast, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, - ipv4_addr, ueid + 10000, - ipv4_addr, ueid + 10000, - UE_NAS_USE_TUN ? "oaitun_ue" : "oip", - ueid + 1, ueid + 10000); - - if ( res<0 ) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); - } - - /* Calling system() here disrupts UE's realtime processing in some cases. - * This may be because of the call to fork(), which, for some - * unidentified reason, interacts badly with other (realtime) threads. - * background_system() is a replacement mechanism relying on a - * background process that does the system() and reports result to - * the parent process (lte-softmodem, oaisim, ...). The background - * process is created very early in the life of the parent process. - * The processes interact through standard pipes. See - * common/utils/system.c for details. - */ - - LOG_TRACE(INFO, "ESM-PROC - executing %s ", - command_line); - if (background_system(command_line) != 0) - { - LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); - } - } - else if (get_softmodem_params()->nsa) { - res = sprintf(command_line, - "ip address add %s/%d broadcast %s dev %s%d && " - "ip link set %s%d up && " - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev %s%d table %d", - ipv4_addr, netmask, broadcast, - UE_NAS_USE_TUN ? "oaitun_nru" : "oip", ueid + 1, - UE_NAS_USE_TUN ? "oaitun_nru" : "oip", ueid + 1, - ipv4_addr, ueid + 10000, - ipv4_addr, ueid + 10000, - UE_NAS_USE_TUN ? "oaitun_nru" : "oip", - ueid + 1, ueid + 10000); - - if ( res<0 ) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); - } - LOG_D(NAS, "Sending NAS_OAI_TUN_NSA msg to LTE UE via itti\n"); - MessageDef *msg_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_OAI_TUN_NSA); - memcpy(NAS_OAI_TUN_NSA(msg_p).buffer, command_line, sizeof(NAS_OAI_TUN_NSA(msg_p).buffer)); - itti_send_msg_to_task(TASK_RRC_UE, 0, msg_p); - } - - break; + case NET_PDN_TYPE_IPV4: { + char ip[20]; + char *ip_addr = pdn->ip_addr; + snprintf(ip, sizeof(ip), "%d.%d.%d.%d", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); + const char *ifn = get_softmodem_params()->nsa ? "oaitun_nru" : "oaitun_ue"; + nas_config(1, ip, NULL, ifn); + setup_ue_ipv4_route(1, ip, ifn); + } break; case NET_PDN_TYPE_IPV6: break; From 39e7839f196d8aee653e02a6c5c1d54ae28609ca Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 30 Jul 2024 08:29:50 +0200 Subject: [PATCH 52/61] Cleanup netlink_init.c and pdcp_fifo.c - Remove globals, declare where they are used - Cleanup pdcp_fifo.c - Remove unnecessary headers from netlink_init.c - Reformat netlink_init.c --- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 88 +++++++------------ openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 15 +--- 2 files changed, 32 insertions(+), 71 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 26f639eeea..19c0fd8a19 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -19,52 +19,25 @@ * contact@openairinterface.org */ -/*! \file netlink_init.c -* \brief initiate the netlink socket for communication with nas dirver -* \author Navid Nikaein and Raymomd Knopp -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -*/ - -#include #include -#include -#include -#include -#include -#include -#include -#include #include -#include "common/platform_constants.h" - #include -#include #include #include -#include "common/openairinterface5g_limits.h" -#include "pdcp.h" - -char nl_rx_buf[NL_MAX_PAYLOAD]; - -struct sockaddr_nl nas_src_addr, nas_dest_addr; - -int nas_sock_fd[MAX_MOBILES_PER_ENB*2]; //Allocated for both LTE UE and NR UE. +#include "common/platform_constants.h" +#include "common/utils/LOG/log.h" +int nas_sock_fd[MAX_MOBILES_PER_ENB * 2]; // Allocated for both LTE UE and NR UE. int nas_sock_mbms_fd; -struct msghdr nas_msg_tx; -struct msghdr nas_msg_rx; - -static int tun_alloc(char *dev) { +static int tun_alloc(char *dev) +{ struct ifreq ifr; int fd, err; - if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { - LOG_E(PDCP, "[TUN] failed to open /dev/net/tun\n"); + if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { + LOG_E(UTIL, "failed to open /dev/net/tun\n"); return -1; } @@ -76,10 +49,10 @@ static int tun_alloc(char *dev) { */ ifr.ifr_flags = IFF_TUN | IFF_NO_PI; - if( *dev ) - strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)-1); + if (*dev) + strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1); - if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { + if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { close(fd); return err; } @@ -88,8 +61,8 @@ static int tun_alloc(char *dev) { return fd; } - -int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., +int netlink_init_mbms_tun(char *ifprefix, int id) +{ int ret; char ifname[64]; @@ -97,23 +70,23 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., nas_sock_mbms_fd = tun_alloc(ifname); if (nas_sock_mbms_fd == -1) { - LOG_E(PDCP, "[NETLINK] Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); + LOG_E(UTIL, "Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); exit(1); - } + } - printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd); - ret = fcntl(nas_sock_mbms_fd,F_SETFL,O_NONBLOCK); + LOG_D(UTIL, "Opened socket %s with fd %d\n", ifname, nas_sock_mbms_fd); + ret = fcntl(nas_sock_mbms_fd, F_SETFL, O_NONBLOCK); - if (ret == -1) { - LOG_E(PDCP, "[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); - return 0; - } + if (ret == -1) { + LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); + return 0; + } - memset(&nas_src_addr, 0, sizeof(nas_src_addr)); - nas_src_addr.nl_family = AF_NETLINK; - nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ - nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); + struct sockaddr_nl nas_src_addr = {0}; + nas_src_addr.nl_family = AF_NETLINK; + nas_src_addr.nl_pid = 1; + nas_src_addr.nl_groups = 0; /* not in mcast groups */ + ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); return 1; } @@ -130,20 +103,19 @@ int netlink_init_tun(const char *ifprefix, int num_if, int id) nas_sock_fd[i] = tun_alloc(ifname); if (nas_sock_fd[i] == -1) { - LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); + LOG_E(UTIL, "Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno)); return 0; } - LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n", - ifname, i, nas_sock_fd[i]); - ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); + LOG_I(UTIL, "Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]); + ret = fcntl(nas_sock_fd[i], F_SETFL, O_NONBLOCK); if (ret == -1) { - LOG_E(PDCP, "TUN: Error fcntl (%d:%s)\n",errno, strerror(errno)); + LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); return 0; } - } /* for */ + } return 1; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index e5141b7917..5f54bf6f04 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -31,8 +31,6 @@ #define PDCP_FIFO_C - - extern int otg_enabled; #include "pdcp.h" @@ -63,21 +61,11 @@ extern int otg_enabled; #include #include -extern char nl_rx_buf[NL_MAX_PAYLOAD]; -extern struct sockaddr_nl nas_src_addr, nas_dest_addr; -extern struct nlmsghdr *nas_nlh_tx; -extern struct nlmsghdr *nas_nlh_rx; -extern struct iovec nas_iov_tx; -extern struct iovec nas_iov_rx; - extern int nas_sock_fd[MAX_MOBILES_PER_ENB]; extern int nas_sock_mbms_fd; -extern struct msghdr nas_msg_tx; -extern struct msghdr nas_msg_rx; - - +static char nl_rx_buf[NL_MAX_PAYLOAD]; # include "openair3/ocp-gtpu/gtp_itf.h" @@ -411,6 +399,7 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx rb_id_t rab_id = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + struct msghdr nas_msg_rx; len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); From 89d89a75648d173bd82eda571d17bb1bc2a39bb8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Jul 2024 11:39:18 +0200 Subject: [PATCH 53/61] Create tun_if module for TUN interface handling Move openair3/RRC/NAS/nas_config.c to common/utils/tun_if.c, and remove the former from all targets. --- CMakeLists.txt | 8 -------- common/utils/CMakeLists.txt | 2 +- .../RRC/NAS/nas_config.c => common/utils/tun_if.c | 4 ++-- .../RRC/NAS/nas_config.h => common/utils/tun_if.h | 10 +++++----- doc/Doxyfile | 4 ++-- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 12 ++++++------ openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 6 +++--- openair2/RRC/LTE/rrc_UE.c | 4 ++-- openair2/RRC/LTE/rrc_eNB.c | 4 ++-- .../COMMON/ESM/MSG/PduSessionEstablishmentAccept.c | 8 ++++---- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 6 +++--- openair3/NAS/UE/ESM/esm_ebr_context.c | 4 ++-- 12 files changed, 32 insertions(+), 40 deletions(-) rename openair2/RRC/NAS/nas_config.c => common/utils/tun_if.c (98%) rename openair2/RRC/NAS/nas_config.h => common/utils/tun_if.h (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a4cfd3e55..b19e884592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1931,7 +1931,6 @@ add_executable(lte-softmodem ${OPENAIR_DIR}/executables/create_tasks_mbms.c ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${PHY_INTERFACE_DIR}/queue_t.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c @@ -1988,7 +1987,6 @@ add_executable(lte-uesoftmodem ${OPENAIR_DIR}/executables/create_tasks_ue.c ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c @@ -2024,7 +2022,6 @@ add_executable(nr-softmodem ${OPENAIR_DIR}/executables/softmodem-common.c ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${PHY_INTERFACE_DIR}/queue_t.c @@ -2066,7 +2063,6 @@ target_link_libraries(nr-softmodem PRIVATE add_executable(nr-cuup executables/nr-cuup.c executables/softmodem-common.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${NR_RRC_DIR}/rrc_gNB_UE_context.c ${OPENAIR2_DIR}/E1AP/e1ap_setup.c ${NR_PDCP_SRC} @@ -2094,7 +2090,6 @@ add_executable(nr-uesoftmodem ${OPENAIR_DIR}/executables/softmodem-common.c ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c @@ -2205,7 +2200,6 @@ add_executable(nr_psbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/psbchsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c @@ -2232,7 +2226,6 @@ add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c @@ -2268,7 +2261,6 @@ add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c diff --git a/common/utils/CMakeLists.txt b/common/utils/CMakeLists.txt index 932f458a77..025091249b 100644 --- a/common/utils/CMakeLists.txt +++ b/common/utils/CMakeLists.txt @@ -13,6 +13,6 @@ add_subdirectory(T) add_subdirectory(nr) add_subdirectory(LOG) add_subdirectory(threadPool) -add_library(utils utils.c system.c time_meas.c time_stat.c) +add_library(utils utils.c system.c time_meas.c time_stat.c tun_if.c) target_include_directories(utils PUBLIC .) target_link_libraries(utils PRIVATE ${T_LIB}) diff --git a/openair2/RRC/NAS/nas_config.c b/common/utils/tun_if.c similarity index 98% rename from openair2/RRC/NAS/nas_config.c rename to common/utils/tun_if.c index c1e85a3360..4d6308c02d 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/common/utils/tun_if.c @@ -28,7 +28,7 @@ #include #include -#include "nas_config.h" +#include "tun_if.h" #include "common/utils/LOG/log.h" #include "common/utils/system.h" @@ -115,7 +115,7 @@ fail_interface_state: } // non blocking full configuration of the interface (address, and the two lest octets of the address) -bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifpref) +bool tun_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifpref) { char interfaceName[IFNAMSIZ]; snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id); diff --git a/openair2/RRC/NAS/nas_config.h b/common/utils/tun_if.h similarity index 92% rename from openair2/RRC/NAS/nas_config.h rename to common/utils/tun_if.h index f937b6ccf5..779d5e8102 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/common/utils/tun_if.h @@ -19,12 +19,12 @@ * contact@openairinterface.org */ -#ifndef NAS_CONFIG_H_ -#define NAS_CONFIG_H_ +#ifndef TUN_IF_H_ +#define TUN_IF_H_ #include -/*! \fn int nas_config(char*, int, int) +/*! \fn int tun_config(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, * basic address, network mask and broadcast address, as the default configured * ones @@ -38,7 +38,7 @@ * \note * @ingroup _nas */ -bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifprefix); +bool tun_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifprefix); /*! * \brief Setup a IPv4 rule in table (interface_id - 1 + 10000) and route to @@ -54,4 +54,4 @@ bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char */ void setup_ue_ipv4_route(int interface_id, const char *ipv4, const char *ifpref); -#endif /*NAS_CONFIG_H_*/ +#endif /*TUN_IF_H_*/ diff --git a/doc/Doxyfile b/doc/Doxyfile index 6e1c7828e1..0ea84a8d0f 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -866,6 +866,8 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../common/config/config_cmdline.c \ @CMAKE_CURRENT_SOURCE_DIR@/../common/utils/time_meas.c \ @CMAKE_CURRENT_SOURCE_DIR@/../common/utils/time_meas.h \ +@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/tun_if.h \ +@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/tun_if.c \ @CMAKE_CURRENT_SOURCE_DIR@/../common/utils/utils.c \ @CMAKE_CURRENT_SOURCE_DIR@/../common/utils/oai_asn1.h \ @CMAKE_CURRENT_SOURCE_DIR@/../common/utils/system.h \ @@ -1874,8 +1876,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/L2_interface_ue.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_internode.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/cucp_cuup_if.h \ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 122bd14794..62f103add0 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -50,7 +50,7 @@ #include "common/openairinterface5g_limits.h" #include "executables/lte-softmodem.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" -#include "openair2/RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #include "intertask_interface.h" #include "openair3/S1AP/s1ap_eNB.h" #include @@ -2300,22 +2300,22 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) - nas_config(1, "10.0.1.2", NULL, "oaitun_ue"); + tun_config(1, "10.0.1.2", NULL, "oaitun_ue"); netlink_init_mbms_tun("oaitun_uem", id + 1); - nas_config(1, "10.0.2.2", NULL, "oaitun_uem"); + tun_config(1, "10.0.2.2", NULL, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); - nas_config(1, "10.0.1.1", NULL, "oaitun_enb"); + tun_config(1, "10.0.1.1", NULL, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 1); - nas_config(1, "10.0.2.1", NULL, "oaitun_enm"); + tun_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { netlink_init_mbms_tun("oaitun_enm", 0); - nas_config(1, "10.0.2.1", NULL, "oaitun_enm"); + tun_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 051999ad9d..71409833d3 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -594,7 +594,7 @@ void nr_pdcp_layer_init(bool uses_e1) #include "nfapi/oai_integration/vendor_ext.h" #include "executables/lte-softmodem.h" -#include "openair2/RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) { @@ -618,7 +618,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) netlink_init_tun(ifprefix, num_if, id); if (IS_SOFTMODEM_NOS1) { const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3"; - nas_config(1, ip, NULL, ifprefix); + tun_config(1, ip, NULL, ifprefix); set_qfi_pduid(7, 10); } LOG_I(PDCP, "UE pdcp will use tun interface\n"); @@ -626,7 +626,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) } else if (ENB_NAS_USE_TUN) { char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb"; netlink_init_tun(ifprefix, 1, id); - nas_config(1, "10.0.1.1", NULL, ifprefix); + tun_config(1, "10.0.1.1", NULL, ifprefix); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); } diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 1d1de490bb..13787f2334 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -67,7 +67,7 @@ #include "NR_RAT-Type.h" #include "NR_UE-CapabilityRAT-Container.h" -#include "RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #if ENABLE_RAL #include "rrc_UE_ral.h" #endif @@ -771,7 +771,7 @@ rrc_ue_establish_drb( "10.0.%d.%d", UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), ip_addr_offset4 + ue_mod_idP + 1); - oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, ip, NULL, "oaitun_oip"); + oip_ifup = tun_config(ip_addr_offset3 + ue_mod_idP + 1, ip, NULL, "oaitun_oip"); if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 1b42985bde..9217350891 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -78,7 +78,7 @@ #include "T.h" #include "LTE_MeasResults.h" -#include "RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #include "rrc_eNB_S1AP.h" #include "rrc_eNB_GTPV1U.h" @@ -5257,7 +5257,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id); char ip[20]; snprintf(ip, sizeof(ip), "10.0.%d.%d", ctxt_pP->module_id + 1, ctxt_pP->module_id + 1); - oip_ifup = nas_config(ctxt_pP->module_id, ip, NULL, "oaitun_oai"); + oip_ifup = tun_config(ctxt_pP->module_id, ip, NULL, "oaitun_oai"); if (oip_ifup == 0) { // interface is up --> send a config the DRB module_id_t ue_module_id; diff --git a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c index decb80d7e3..f5d053ae58 100644 --- a/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c +++ b/openair3/NAS/COMMON/ESM/MSG/PduSessionEstablishmentAccept.c @@ -22,7 +22,7 @@ #include "PduSessionEstablishmentAccept.h" #include "common/utils/LOG/log.h" #include "nr_nas_msg_sim.h" -#include "openair2/RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #include "openair2/SDAP/nr_sdap/nr_sdap.h" static uint16_t getShort(uint8_t *input) @@ -132,14 +132,14 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ addr[i] = *curPtr++; char ip[20]; capture_ipv4_addr(&addr[0], ip, sizeof(ip)); - nas_config(1, ip, NULL, "oaitun_ue"); + tun_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); } else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV6) { for (int i = 0; i < 8; ++i) addr[i] = *curPtr++; char ipv6[40]; capture_ipv6_addr(addr, ipv6, sizeof(ipv6)); - nas_config(1, NULL, ipv6, "oaitun_ue"); + tun_config(1, NULL, ipv6, "oaitun_ue"); } else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4V6) { // 24.501 Sec 9.11.4.10: "If the PDU session type value indicates // IPv4v6, the PDU address information in octet 4 to octet 11 @@ -151,7 +151,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ capture_ipv6_addr(addr, ipv6, sizeof(ipv6)); char ipv4[20]; capture_ipv4_addr(&addr[8], ipv4, sizeof(ipv4)); - nas_config(1, ipv4, ipv6, "oaitun_ue"); + tun_config(1, ipv4, ipv6, "oaitun_ue"); setup_ue_ipv4_route(1, ipv4, "oaitun_ue"); } else { LOG_E(NAS, "unknown/unhandled PDU session establishment accept PDU type %d\n", psea_msg.pdu_addr_ie.pdu_type); diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 5b8edeab7e..722a1ba1ec 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -46,7 +46,7 @@ #include "RegistrationAccept.h" #include "FGSDeregistrationRequestUEOriginating.h" #include "intertask_interface.h" -#include "openair2/RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #include #include #include "openair2/SDAP/nr_sdap/nr_sdap.h" @@ -845,7 +845,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff char ip[20]; sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_A(NAS, "Received PDU Session Establishment Accept\n"); - nas_config(1, ip, NULL, "oaitun_ue"); + tun_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); @@ -1432,7 +1432,7 @@ void *nas_nrue(void *args_p) char ip[20]; snprintf(ip, sizeof(ip), "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3)); LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %s\n", ip); - nas_config(1, ip, NULL, "oaitun_ue"); + tun_config(1, ip, NULL, "oaitun_ue"); setup_ue_ipv4_route(1, ip, "oaitun_ue"); break; } diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index 02278ddf1a..72b5d240e0 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -45,7 +45,7 @@ Description Defines functions used to handle EPS bearer contexts. #include "esm_ebr.h" #include "esm_ebr_context.h" -#include "openair2/RRC/NAS/nas_config.h" +#include "common/utils/tun_if.h" #include "emm_sap.h" #include "system.h" @@ -207,7 +207,7 @@ int esm_ebr_context_create( char *ip_addr = pdn->ip_addr; snprintf(ip, sizeof(ip), "%d.%d.%d.%d", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); const char *ifn = get_softmodem_params()->nsa ? "oaitun_nru" : "oaitun_ue"; - nas_config(1, ip, NULL, ifn); + tun_config(1, ip, NULL, ifn); setup_ue_ipv4_route(1, ip, ifn); } break; From 168582b5a18499081e6cddb1897165c429336780 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 31 Jul 2024 15:43:59 +0200 Subject: [PATCH 54/61] Remove netlink_init.c, and move remaining functionality to tun_if.c Remove openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c, and move TUN interface creation functionality to tun_if.c. Remove SIMU_ETH target. --- CMakeLists.txt | 23 ++-- common/utils/tun_if.c | 95 ++++++++++++++ common/utils/tun_if.h | 6 + doc/Doxyfile | 2 - executables/lte-enb.c | 1 - executables/lte-ru.c | 2 - executables/lte-softmodem.h | 1 - executables/nr-gnb.c | 1 - executables/nr-ru.c | 1 - executables/nr-softmodem-common.h | 2 - executables/nr-softmodem.c | 2 - executables/nr-uesoftmodem.h | 3 - openair1/SIMULATION/ETH_TRANSPORT/README.txt | 25 ---- openair1/SIMULATION/ETH_TRANSPORT/extern.h | 60 --------- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 121 ------------------ openair1/SIMULATION/ETH_TRANSPORT/proto.h | 37 ------ openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 11 +- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 4 +- openair3/NAS/NR_UE/nr_nas_msg_sim.c | 1 - 19 files changed, 117 insertions(+), 281 deletions(-) delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/README.txt delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/extern.h delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c delete mode 100644 openair1/SIMULATION/ETH_TRANSPORT/proto.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b19e884592..88233b943e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1878,11 +1878,6 @@ set (SIMUSRC add_library(SIMU STATIC ${SIMUSRC} ) target_include_directories(SIMU PUBLIC ${OPENAIR1_DIR}/SIMULATION/TOOLS ${OPENAIR1_DIR}/SIMULATION/RF) -add_library(SIMU_ETH STATIC - ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c -) -target_link_libraries(SIMU_ETH PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) - include_directories("${NFAPI_DIR}/nfapi/public_inc") include_directories("${NFAPI_DIR}/common/public_inc") include_directories("${NFAPI_DIR}/pnf/public_inc") @@ -1943,7 +1938,7 @@ target_link_libraries(lte-softmodem PRIVATE -Wl,--start-group lte_rrc nr_rrc s1ap m2ap x2ap m3ap GTPV1U SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB - ${NAS_UE_LIB} ITTI SIMU SIMU_ETH shlib_loader + ${NAS_UE_LIB} ITTI SIMU shlib_loader -Wl,--end-group z dl) target_link_libraries(lte-softmodem PRIVATE pthread m CONFIG_LIB rt sctp) @@ -1997,7 +1992,7 @@ target_link_libraries(lte-uesoftmodem PRIVATE -Wl,--start-group lte_rrc nr_rrc s1ap x2ap m2ap m3ap SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON - PHY_UE PHY_RU L2_UE L2_LTE SIMU SIMU_ETH NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB + PHY_UE PHY_RU L2_UE L2_LTE SIMU NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB ${NAS_UE_LIB} ITTI shlib_loader -Wl,--end-group z dl) @@ -2032,7 +2027,7 @@ target_link_libraries(nr-softmodem PRIVATE -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECURITY ITTI ${NAS_UE_LIB} lte_rrc nr_rrc - ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU SIMU_ETH + ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU x2ap f1ap m2ap m3ap e1ap shlib_loader -Wl,--end-group z dl) @@ -2071,7 +2066,7 @@ add_executable(nr-cuup target_link_libraries(nr-cuup PRIVATE CONFIG_LIB ITTI SCTP_CLIENT - GTPV1U e1ap f1ap SIMU_ETH + GTPV1U e1ap f1ap z sctp dl pthread shlib_loader ${T_LIB}) target_link_libraries(nr-cuup PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) if(E2_AGENT) @@ -2100,7 +2095,7 @@ target_link_libraries(nr-uesoftmodem PRIVATE nr_rrc SECURITY UTIL HASHTABLE SCHED_RU_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_COMMON PHY_NR_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_NR_LIB - ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU SIMU_ETH shlib_loader + ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU shlib_loader -Wl,--end-group z dl) target_link_libraries(nr-uesoftmodem PRIVATE pthread m CONFIG_LIB rt) @@ -2206,7 +2201,7 @@ add_executable(nr_psbchsim ${PHY_INTERFACE_DIR}/queue_t.c ) target_link_libraries(nr_psbchsim PRIVATE - -Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON CONFIG_LIB L2_NR -lz -Wl,--end-group + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON CONFIG_LIB L2_NR -lz -Wl,--end-group m pthread ${T_LIB} ITTI dl shlib_loader ) target_link_libraries(nr_psbchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -2232,7 +2227,7 @@ add_executable(nr_dlsim ${PHY_INTERFACE_DIR}/queue_t.c ) target_link_libraries(nr_dlsim PRIVATE - -Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group m pthread ${T_LIB} ITTI dl shlib_loader ) target_link_libraries(nr_dlsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -2272,7 +2267,7 @@ if (ENABLE_LDPC_T2) endif() target_link_libraries(nr_ulsim PRIVATE - -Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group m pthread ${T_LIB} ITTI dl shlib_loader ) target_link_libraries(nr_ulsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -2335,7 +2330,7 @@ if (${T_TRACER}) MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_UE_NR ngap - CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU SIMU_ETH OPENAIR0_LIB + CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc_t2 ldpc_cl ldpc_cuda ldpc dfts config_internals nr_common) if (TARGET ${i}) add_dependencies(${i} generate_T) diff --git a/common/utils/tun_if.c b/common/utils/tun_if.c index 4d6308c02d..4d04325998 100644 --- a/common/utils/tun_if.c +++ b/common/utils/tun_if.c @@ -27,11 +27,106 @@ #include #include #include +#include +#include #include "tun_if.h" +#include "common/platform_constants.h" #include "common/utils/LOG/log.h" #include "common/utils/system.h" +int nas_sock_fd[MAX_MOBILES_PER_ENB * 2]; // Allocated for both LTE UE and NR UE. +int nas_sock_mbms_fd; + +static int tun_alloc(char *dev) +{ + struct ifreq ifr; + int fd, err; + + if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { + LOG_E(UTIL, "failed to open /dev/net/tun\n"); + return -1; + } + + memset(&ifr, 0, sizeof(ifr)); + /* Flags: IFF_TUN - TUN device (no Ethernet headers) + * IFF_TAP - TAP device + * + * IFF_NO_PI - Do not provide packet information + */ + ifr.ifr_flags = IFF_TUN | IFF_NO_PI; + + if (*dev) + strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1); + + if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { + close(fd); + return err; + } + + strcpy(dev, ifr.ifr_name); + return fd; +} + +int tun_init_mbms(char *ifprefix, int id) +{ + int ret; + char ifname[64]; + + sprintf(ifname, "%s%d", ifprefix, id); + nas_sock_mbms_fd = tun_alloc(ifname); + + if (nas_sock_mbms_fd == -1) { + LOG_E(UTIL, "Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); + exit(1); + } + + LOG_D(UTIL, "Opened socket %s with fd %d\n", ifname, nas_sock_mbms_fd); + ret = fcntl(nas_sock_mbms_fd, F_SETFL, O_NONBLOCK); + + if (ret == -1) { + LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); + return 0; + } + + struct sockaddr_nl nas_src_addr = {0}; + nas_src_addr.nl_family = AF_NETLINK; + nas_src_addr.nl_pid = 1; + nas_src_addr.nl_groups = 0; /* not in mcast groups */ + ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); + + return 1; +} + +int tun_init(const char *ifprefix, int num_if, int id) +{ + int ret; + char ifname[64]; + + int begx = (id == 0) ? 0 : id - 1; + int endx = (id == 0) ? num_if : id; + for (int i = begx; i < endx; i++) { + sprintf(ifname, "%s%d", ifprefix, i + 1); + nas_sock_fd[i] = tun_alloc(ifname); + + if (nas_sock_fd[i] == -1) { + LOG_E(UTIL, "Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno)); + return 0; + } + + LOG_I(UTIL, "Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]); + ret = fcntl(nas_sock_fd[i], F_SETFL, O_NONBLOCK); + + if (ret == -1) { + LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); + + return 0; + } + } + + return 1; +} + /* * \brief set a genneric interface parameter * \param ifn the name of the interface to modify diff --git a/common/utils/tun_if.h b/common/utils/tun_if.h index 779d5e8102..45ae34983f 100644 --- a/common/utils/tun_if.h +++ b/common/utils/tun_if.h @@ -24,6 +24,12 @@ #include +/* TODO: doc */ +int tun_init(const char *ifprefix, int num_if, int id); + +/* TODO: doc */ +int tun_init_mbms(char *ifsuffix, int id); + /*! \fn int tun_config(char*, int, int) * \brief This function initializes the nasmesh interface using the basic values, * basic address, network mask and broadcast address, as the default configured diff --git a/doc/Doxyfile b/doc/Doxyfile index 0ea84a8d0f..5ae52a3c3a 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -2306,8 +2306,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_freq_equalization.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/proto.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/adc.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/dac.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/rf.h \ diff --git a/executables/lte-enb.c b/executables/lte-enb.c index 8f50dfc63d..1a26644a43 100644 --- a/executables/lte-enb.c +++ b/executables/lte-enb.c @@ -85,7 +85,6 @@ #include "executables/lte-softmodem.h" #include "s1ap_eNB.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" #include "T.h" diff --git a/executables/lte-ru.c b/executables/lte-ru.c index 54747a9578..0ae8b86216 100644 --- a/executables/lte-ru.c +++ b/executables/lte-ru.c @@ -72,8 +72,6 @@ static int DEFRUTPCORES[] = {2,4,6,8}; #include "ENB_APP/enb_paramdef.h" #include "common/config/config_userapi.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" - #include "T.h" #include "executables/softmodem-common.h" diff --git a/executables/lte-softmodem.h b/executables/lte-softmodem.h index 6bc6d27f21..0f5559c7d3 100644 --- a/executables/lte-softmodem.h +++ b/executables/lte-softmodem.h @@ -26,7 +26,6 @@ #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" #include "s1ap_eNB.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" #include "executables/softmodem-common.h" diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 1f5fca077c..6efd26dfd7 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -75,7 +75,6 @@ #include "UTIL/OPT/opt.h" #include "gnb_paramdef.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" #include #include "T.h" diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 24a1ecd719..aff3b5b8c2 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -65,7 +65,6 @@ static int DEFRUTPCORES[] = {-1,-1,-1,-1}; #include "GNB_APP/gnb_paramdef.h" #include "common/config/config_userapi.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" #include diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index c168a1ac0b..b50389e7d0 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -30,8 +30,6 @@ #include "PHY/types.h" #include -#include "SIMULATION/ETH_TRANSPORT/proto.h" - /* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ #define CONFIG_HLP_RFCFGF "Configuration file for front-end (e.g. LMS7002M)\n" #define CONFIG_HLP_ULMAXE "set the eNodeB max ULSCH erros\n" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 3d3544dfc6..ac8a6c13ef 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -140,8 +140,6 @@ uint8_t nb_antenna_rx = 1; int otg_enabled; -#include - extern void reset_opp_meas(void); extern void print_opp_meas(void); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 779f0049d8..204b16b109 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -3,9 +3,6 @@ #include #include #include "PHY/defs_nr_UE.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" - - #define CONFIG_HLP_IF_FREQ "IF frequency for RF, if needed\n" #define CONFIG_HLP_IF_FREQ_OFF "UL IF frequency offset for RF, if needed\n" diff --git a/openair1/SIMULATION/ETH_TRANSPORT/README.txt b/openair1/SIMULATION/ETH_TRANSPORT/README.txt deleted file mode 100644 index a1c1ed9562..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -For reliable UDP multicast, the libpgm-dev should be installed on the machines, -otherwise the old multicast method using simply UDP will be used, resulting in -packet loss and unexpected behaviour of oaisim. - -To compile OAI with PGM: - -For Ubuntu 12.04 and earliers: - sudo apt-get install libpgm-dev - is sufficient - -For Ubuntu older than 12.04: - -wget http://openpgm.googlecode.com/files/libpgm-5.1.118.tar.gz -tar xvf libpgm-5.1.118.tar.gz -cd libpgm-5.1.118/openpgm/pgm -./configure --prefix=/usr -make -sudo make install - -We have to clean oaisim compilation and re-compile - - -When running OAI, the -D should be used to provide the NIC to bind. -Parameter can be either an interface name or an ip address (refer to this link -for more informations: http://code.google.com/p/openpgm/wiki/OpenPgmConceptsTransport) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/extern.h b/openair1/SIMULATION/ETH_TRANSPORT/extern.h deleted file mode 100644 index ecd0d301d6..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/extern.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file extern.h - * \brief specifies the extern variables for phy emulation - * \author Navid Nikaein and Raymomd Knopp and Hicham Anouar - * \date 2011 - * \version 1.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - -#ifndef __BYPASS_SESSION_LAYER_EXTERN_H__ -# define __BYPASS_SESSION_LAYER_EXTERN_H__ - -#include - - -extern unsigned char Emulation_status; -extern unsigned char emu_tx_status; -extern unsigned char emu_rx_status; -//extern unsigned int Master_list; -//extern unsigned short Master_id; -//extern unsigned int Is_primary_master; - -#if !defined(ENABLE_NEW_MULTICAST) -extern pthread_mutex_t Tx_mutex; -extern pthread_cond_t Tx_cond; -extern char Tx_mutex_var; -#endif - -extern rx_handler_t rx_handler; -extern tx_handler_t tx_handler; - -extern eNB_transport_info_t eNB_transport_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs]; -extern uint16_t eNB_transport_info_TB_index[NUMBER_OF_eNB_MAX][MAX_NUM_CCs]; - -extern UE_transport_info_t UE_transport_info[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - -extern UE_cntl ue_cntl_delay[NUMBER_OF_UE_MAX][MAX_NUM_CCs][2]; - -#endif diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c deleted file mode 100644 index 19c0fd8a19..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include -#include -#include -#include - -#include "common/platform_constants.h" -#include "common/utils/LOG/log.h" - -int nas_sock_fd[MAX_MOBILES_PER_ENB * 2]; // Allocated for both LTE UE and NR UE. -int nas_sock_mbms_fd; - -static int tun_alloc(char *dev) -{ - struct ifreq ifr; - int fd, err; - - if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { - LOG_E(UTIL, "failed to open /dev/net/tun\n"); - return -1; - } - - memset(&ifr, 0, sizeof(ifr)); - /* Flags: IFF_TUN - TUN device (no Ethernet headers) - * IFF_TAP - TAP device - * - * IFF_NO_PI - Do not provide packet information - */ - ifr.ifr_flags = IFF_TUN | IFF_NO_PI; - - if (*dev) - strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1); - - if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { - close(fd); - return err; - } - - strcpy(dev, ifr.ifr_name); - return fd; -} - -int netlink_init_mbms_tun(char *ifprefix, int id) -{ - int ret; - char ifname[64]; - - sprintf(ifname, "%s%d", ifprefix, id); - nas_sock_mbms_fd = tun_alloc(ifname); - - if (nas_sock_mbms_fd == -1) { - LOG_E(UTIL, "Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); - exit(1); - } - - LOG_D(UTIL, "Opened socket %s with fd %d\n", ifname, nas_sock_mbms_fd); - ret = fcntl(nas_sock_mbms_fd, F_SETFL, O_NONBLOCK); - - if (ret == -1) { - LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); - return 0; - } - - struct sockaddr_nl nas_src_addr = {0}; - nas_src_addr.nl_family = AF_NETLINK; - nas_src_addr.nl_pid = 1; - nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); - - return 1; -} - -int netlink_init_tun(const char *ifprefix, int num_if, int id) -{ - int ret; - char ifname[64]; - - int begx = (id == 0) ? 0 : id - 1; - int endx = (id == 0) ? num_if : id; - for (int i = begx; i < endx; i++) { - sprintf(ifname, "%s%d", ifprefix, i + 1); - nas_sock_fd[i] = tun_alloc(ifname); - - if (nas_sock_fd[i] == -1) { - LOG_E(UTIL, "Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno)); - return 0; - } - - LOG_I(UTIL, "Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]); - ret = fcntl(nas_sock_fd[i], F_SETFL, O_NONBLOCK); - - if (ret == -1) { - LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno)); - - return 0; - } - } - - return 1; -} diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h deleted file mode 100644 index 647824cf05..0000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file proto.h -* \brief -* \author Navid Nikaein -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -*/ - -#ifndef EMU_PROTO_H_ -#define EMU_PROTO_H_ - -int netlink_init_tun(const char *ifprefix, int num_if, int id); -int netlink_init_mbms_tun(char *ifsuffix, int id); - -#endif /* EMU_PROTO_H_ */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 62f103add0..c63487e1ce 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -49,7 +49,6 @@ #include "common/ngran_types.h" #include "common/openairinterface5g_limits.h" #include "executables/lte-softmodem.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" #include "common/utils/tun_if.h" #include "intertask_interface.h" #include "openair3/S1AP/s1ap_eNB.h" @@ -2298,23 +2297,23 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { if (UE_NAS_USE_TUN) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun("oaitun_ue", num_if, id); + tun_init("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) tun_config(1, "10.0.1.2", NULL, "oaitun_ue"); - netlink_init_mbms_tun("oaitun_uem", id + 1); + tun_init_mbms("oaitun_uem", id + 1); tun_config(1, "10.0.2.2", NULL, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { - netlink_init_tun("oaitun_enb", 1, 0); + tun_init("oaitun_enb", 1, 0); tun_config(1, "10.0.1.1", NULL, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("oaitun_enm", 1); + tun_init_mbms("oaitun_enm", 1); tun_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("oaitun_enm", 0); + tun_init_mbms("oaitun_enm", 0); tun_config(1, "10.0.2.1", NULL, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 71409833d3..d9efb52776 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -615,7 +615,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun(ifprefix, num_if, id); + tun_init(ifprefix, num_if, id); if (IS_SOFTMODEM_NOS1) { const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3"; tun_config(1, ip, NULL, ifprefix); @@ -625,7 +625,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) start_pdcp_tun_ue(); } else if (ENB_NAS_USE_TUN) { char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb"; - netlink_init_tun(ifprefix, 1, id); + tun_init(ifprefix, 1, id); tun_config(1, "10.0.1.1", NULL, ifprefix); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 722a1ba1ec..ed0078b610 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -48,7 +48,6 @@ #include "intertask_interface.h" #include "common/utils/tun_if.h" #include -#include #include "openair2/SDAP/nr_sdap/nr_sdap.h" #include "openair3/SECU/nas_stream_eia2.h" #include "openair3/UTILS/conversions.h" From 7dffdcd797b114a5c4906c6a17aa8d6a5865e91a Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Fri, 2 Aug 2024 14:28:41 +0200 Subject: [PATCH 55/61] CI: Add YAML files and deployment scripts for FHI7.2 pipeline Create directories for gNB deployment with VVDN and Benetel550 RUs. Each directory includes scripts for setting up and cleaning up the host machine running the gNB. --- .../sa_fhi_7.2_benetel550_gnb/README.md | 15 ++++ .../docker-compose.yml | 40 +++++++++ .../setup_cleanup.sh | 5 ++ .../setup_sriov_benetel.sh | 22 +++++ .../yaml_files/sa_fhi_7.2_vvdn_gnb/README.md | 87 +++++++++++++++++++ .../sa_fhi_7.2_vvdn_gnb/docker-compose.yml | 40 +++++++++ .../sa_fhi_7.2_vvdn_gnb/setup_cleanup.sh | 5 ++ .../sa_fhi_7.2_vvdn_gnb/setup_sriov_vvdn.sh | 21 +++++ 8 files changed, 235 insertions(+) create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/README.md create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_cleanup.sh create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_sriov_benetel.sh create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/README.md create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_cleanup.sh create mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_sriov_vvdn.sh diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/README.md b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/README.md new file mode 100644 index 0000000000..c9cf235bb2 --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/README.md @@ -0,0 +1,15 @@ + + + + + +
+ + + + + + OAI O-RAN 7.2 Front-haul Docker Compose +
+ +For instructions on OAI gNB Docker deployment with FH 7.2 RU, please refer to the [README](../sa_fhi_7.2_vvdn_gnb/README.md). diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml new file mode 100644 index 0000000000..5783964bbe --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml @@ -0,0 +1,40 @@ +services: + oai-gnb: + image: oai-gnb-fhi72:latest + cap_add: + - SYS_ADMIN + - IPC_LOCK + - SYS_NICE + cap_drop: + - ALL + container_name: oai-gnb + environment: + TZ: Europe/Paris + USE_ADDITIONAL_OPTIONS: --sa --thread-pool 6,7,8,9 + devices: + - /dev/vfio:/dev/vfio/ + volumes: + - ../../conf_files/gnb.sa.band78.273prb.fhi72.4x4-benetel550.conf:/opt/oai-gnb/etc/gnb.conf + - /dev/hugepages:/dev/hugepages + # Please change these values based on your system + cpuset: "0,1,2,3,4,5,6,7,8,9" + networks: + oai-net: + ipv4_address: 172.21.18.20 + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 +networks: + oai-net: + driver: macvlan + name: oai-net + ipam: + config: + - subnet: "172.21.16.0/22" + ip_range: "172.21.18.20/32" + gateway: "172.21.19.254" + driver_opts: + com.docker.network.bridge.name: "oai-net" + parent: ens7f0 diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_cleanup.sh b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_cleanup.sh new file mode 100644 index 0000000000..9a06336acc --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_cleanup.sh @@ -0,0 +1,5 @@ +set -e +sudo cpupower idle-set -E > /dev/null +sudo sysctl kernel.sched_rt_runtime_us=950000 +sudo sysctl kernel.timer_migration=1 +exit 0 diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_sriov_benetel.sh b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_sriov_benetel.sh new file mode 100644 index 0000000000..1bcf941ae0 --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/setup_sriov_benetel.sh @@ -0,0 +1,22 @@ +set -e +sudo cpupower idle-set -D 0 > /dev/null +sudo sysctl kernel.sched_rt_runtime_us=-1 +sudo sysctl kernel.timer_migration=0 +sudo ethtool -G ens7f1 rx 8160 +sudo ethtool -G ens7f1 tx 8160 +sudo ifconfig ens7f1 mtu 9216 +sudo sh -c 'echo 0 > /sys/class/net/ens7f1/device/sriov_numvfs' +sudo sh -c 'echo 2 > /sys/class/net/ens7f1/device/sriov_numvfs' +sudo modprobe -r iavf +sudo modprobe iavf +# this next 2 lines is for C/U planes +sudo ip link set ens7f1 vf 0 mac 00:11:22:33:44:66 vlan 3 qos 0 spoofchk off mtu 9216 +sudo ip link set ens7f1 vf 1 mac 00:11:22:33:44:67 vlan 3 qos 0 spoofchk off mtu 9216 +sleep 1 +# These are the DPDK bindings for C/U-planes on vlan 3 +sudo /usr/local/bin/dpdk-devbind.py --unbind c3:11.0 +sudo /usr/local/bin/dpdk-devbind.py --unbind c3:11.1 +sudo modprobe vfio-pci +sudo /usr/local/bin/dpdk-devbind.py --bind vfio-pci c3:11.0 +sudo /usr/local/bin/dpdk-devbind.py --bind vfio-pci c3:11.1 +exit 0 diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/README.md b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/README.md new file mode 100644 index 0000000000..2fcf39ad2c --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/README.md @@ -0,0 +1,87 @@ + + + + + +
+ + + + + + OAI O-RAN 7.2 Front-haul Docker Compose +
+ +![Docker deploy 7.2](../../../doc/images/docker-deploy-oai-7-2.png) + +This docker-compose is designed to use `OAI-gNB` with a 7.2 compatible Radio Unit. Before using this docker compose you have to configure +the host machine as per the [ORAN_FHI7.2_Tutorial](../../../doc/ORAN_FHI7.2_Tutorial.md). The container image used by the docker compose file is tested only on `Ubuntu 22.04` and `RHEL 9.4` docker host. + +## Build Image (Optional) + +Refer to [OAI Docker/Podman Build and Usage Procedures](../../../docker/README.md) + +## Configure Networking + +### SR-IOV Virtual Functions (VFs) + +In docker-compose environment there is no automated method +to configure the VFs on the fly. The user will have to manually configure +C/U plane VFs before starting the container `OAI-gNB`. + +You can follow the step +[configure-network-interfaces-and-dpdk-vfs](../../../doc/ORAN_FHI7.2_Tutorial.md#configure-network-interfaces-and-dpdk-vfs). + +### Interface towards AMF (N2) + +For `N2` interface we are using `macvlan` driver of docker. + +You can use the `bridge` driver, in situation + +- When the core network is running on the same machine +- or different machine but you have configured +needed `ip route` and forwarding to access the core network from RAN host. + +To configure docker `macvlan` network +you need to choose `ipam.config` and `driver_opts.parent` are per your environment + +``` + oai-net: + driver: macvlan + name: oai-net + ipam: + config: + - subnet: "172.21.16.0/22" + ip_range: "172.21.18.20/32" + gateway: "172.21.19.254" + driver_opts: + com.docker.network.bridge.name: "oai-net" + parent: enp193s0f0 +``` + +To configure `bridge` network you need to choose `ipam.config.subnet` as per your environment. + +``` + oai-net: + driver: bridge + name: oai-net + ipam: + config: + - subnet: 192.168.72.128/26 + driver_opts: + com.docker.network.bridge.name: "oai-net" +``` + +## Deploy OAI-gNB Container + +The [configuration file](../../conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf) used by docker compose is configured for VVDN RU. + +```bash +docker-compose up -d +``` + +To check the logs + +```bash +docker logs oai-gnb -f +``` diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml new file mode 100644 index 0000000000..2798a8e8fc --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml @@ -0,0 +1,40 @@ +services: + oai-gnb: + image: oai-gnb-fhi72:latest + cap_add: + - SYS_ADMIN + - IPC_LOCK + - SYS_NICE + cap_drop: + - ALL + container_name: oai-gnb + environment: + TZ: Europe/Paris + USE_ADDITIONAL_OPTIONS: --sa --thread-pool 6,7,8,9 + devices: + - /dev/vfio:/dev/vfio/ + volumes: + - ../../conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf:/opt/oai-gnb/etc/gnb.conf + - /dev/hugepages:/dev/hugepages + # Please change these values based on your system + cpuset: "0,1,2,3,4,5,6,7,8,9" + networks: + oai-net: + ipv4_address: 172.21.18.20 + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 +networks: + oai-net: + driver: macvlan + name: oai-net + ipam: + config: + - subnet: "172.21.16.0/22" + ip_range: "172.21.18.20/32" + gateway: "172.21.19.254" + driver_opts: + com.docker.network.bridge.name: "oai-net" + parent: ens7f0 diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_cleanup.sh b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_cleanup.sh new file mode 100644 index 0000000000..9a06336acc --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_cleanup.sh @@ -0,0 +1,5 @@ +set -e +sudo cpupower idle-set -E > /dev/null +sudo sysctl kernel.sched_rt_runtime_us=950000 +sudo sysctl kernel.timer_migration=1 +exit 0 diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_sriov_vvdn.sh b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_sriov_vvdn.sh new file mode 100644 index 0000000000..2b7a512f83 --- /dev/null +++ b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/setup_sriov_vvdn.sh @@ -0,0 +1,21 @@ +set -e +sudo cpupower idle-set -D 0 > /dev/null +sudo sysctl kernel.sched_rt_runtime_us=-1 +sudo sysctl kernel.timer_migration=0 +sudo ethtool -G ens7f1 rx 8160 +sudo ethtool -G ens7f1 tx 8160 +sudo sh -c 'echo 0 > /sys/class/net/ens7f1/device/sriov_numvfs' +sudo sh -c 'echo 2 > /sys/class/net/ens7f1/device/sriov_numvfs' +sudo modprobe -r iavf +sudo modprobe iavf +# this next 2 lines is for C/U planes +sudo ip link set ens7f1 vf 0 mac 76:76:64:6e:00:01 vlan 4 spoofchk off mtu 9216 +sudo ip link set ens7f1 vf 1 mac 76:76:64:6e:00:00 vlan 4 spoofchk off mtu 9216 +sleep 1 +# These are the DPDK bindings for C/U-planes on vlan 4 +sudo /usr/local/bin/dpdk-devbind.py --unbind c3:11.0 +sudo /usr/local/bin/dpdk-devbind.py --unbind c3:11.1 +sudo modprobe vfio-pci +sudo /usr/local/bin/dpdk-devbind.py --bind vfio-pci c3:11.0 +sudo /usr/local/bin/dpdk-devbind.py --bind vfio-pci c3:11.1 +exit 0 From 9c602a7790417da85af8defd9f7b170496ddd7d5 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Fri, 2 Aug 2024 14:30:07 +0200 Subject: [PATCH 56/61] CI: Remove unused directory for FHI 7.2 deployments --- .../yaml_files/sa_fhi_7.2_gnb/README.md | 87 ------------------- .../sa_fhi_7.2_gnb/docker-compose.yml | 34 -------- 2 files changed, 121 deletions(-) delete mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_gnb/README.md delete mode 100644 ci-scripts/yaml_files/sa_fhi_7.2_gnb/docker-compose.yml diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_gnb/README.md b/ci-scripts/yaml_files/sa_fhi_7.2_gnb/README.md deleted file mode 100644 index 1acbe7fb86..0000000000 --- a/ci-scripts/yaml_files/sa_fhi_7.2_gnb/README.md +++ /dev/null @@ -1,87 +0,0 @@ - - - - - -
- - - - - - OAI O-RAN 7.2 Front-haul Docker Compose -
- -![Docker deploy 7.2](../../../doc/images/docker-deploy-oai-7-2.png) - -This docker-compose is designed to use `OAI-gNB` with a 7.2 compatible Radio Unit. Before using this docker compose you have to configure -the host machine as per the [ORAN_FHI7.2_Tutorial](../../../doc/ORAN_FHI7.2_Tutorial.md). The container image used by the docker compose file is tested only on `Ubuntu 22.04` docker host. - -## Build Image (Optional) - -Refer to [OAI Docker/Podman Build and Usage Procedures](../../../docker/README.md) - -## Configure Networking - -### SR-IOV Virtual Functions (VFs) - -In docker-compose environment there is no automated method -to configure the VFs on the fly. The user will have to manually configure -C/U plane VFs before starting the container `OAI-gNB`. - -You can follow the step -[configure-network-interfaces-and-dpdk-vfs](../../../doc/ORAN_FHI7.2_Tutorial.md#configure-network-interfaces-and-dpdk-vfs). - -### Interface towards AMF (N2) - -For `N2` interface we are using `macvlan` driver of docker. - -You can use the `bridge` driver, in situation - -- When the core network is running on the same machine -- or different machine but you have configured -needed `ip route` and forwarding to access the core network from RAN host. - -To configure docker `macvlan` network -you need to choose `ipam.config` and `driver_opts.parent` are per your environment - -``` - oai-net: - driver: macvlan - name: oai-net - ipam: - config: - - subnet: "172.21.16.0/22" - ip_range: "172.21.18.20/32" - gateway: "172.21.19.254" - driver_opts: - com.docker.network.bridge.name: "oai-net" - parent: enp193s0f0 -``` - -To configure `bridge` network you need to choose `ipam.config.subnet` as per your environment. - -``` - oai-net: - driver: bridge - name: oai-net - ipam: - config: - - subnet: 192.168.72.128/26 - driver_opts: - com.docker.network.bridge.name: "oai-net" -``` - -## Deploy OAI-gNB Container - -The [configuration file](../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-benetel650.conf) used by docker compose is configured for Benetel 650 RU (RAN650-1v1.0.4-dda1bf5). - -```bash -docker-compose up -d -``` - -To check the logs - -```bash -docker logs oai-gnb -f -``` diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_fhi_7.2_gnb/docker-compose.yml deleted file mode 100644 index e3e93b3b74..0000000000 --- a/ci-scripts/yaml_files/sa_fhi_7.2_gnb/docker-compose.yml +++ /dev/null @@ -1,34 +0,0 @@ -services: - oai-gnb: - image: oai-gnb-fhi72:latest - privileged: true - container_name: oai-gnb - environment: - TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa --thread-pool 13,14,15,16,17,18 - devices: - - /dev/vfio:/dev/vfio/ - volumes: - - ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-benetel650.conf:/opt/oai-gnb/etc/gnb.conf - - /dev/hugepages:/dev/hugepages - cpuset: "0,1,2,8,9,10,13,14,15,16,17,18" - networks: - oai-net: - ipv4_address: 172.21.18.20 - healthcheck: - test: /bin/bash -c "pgrep nr-softmodem" - interval: 10s - timeout: 5s - retries: 5 -networks: - oai-net: - driver: macvlan - name: oai-net - ipam: - config: - - subnet: "172.21.16.0/22" - ip_range: "172.21.18.20/32" - gateway: "172.21.19.254" - driver_opts: - com.docker.network.bridge.name: "oai-net" - parent: enp193s0f0 From 3cdb0d795e19fb614d2130052ef07e388f82311f Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Tue, 30 Jul 2024 15:06:40 +0200 Subject: [PATCH 57/61] CI: Add path and namespace configuration for OC CNs - Modify CN deployment and termination functions to include namespace and path parameters. - Update `Module_UE` class with new attributes for namespace and CN path. - Integrate `cnID` for OC CN deployment and termination in `epc.py`. - Extract `cn_id` from XML configurations for CN operations. - Update XML files to include `cn_id` tag for 5G Core initialization and termination. (Used in OAIUE and AW2S pipeline, for OC CN deployment. This change will not affect other CN deployments.) --- ci-scripts/ci_infra.yaml | 2 ++ ci-scripts/cls_cluster.py | 15 ++++++--------- ci-scripts/cls_module.py | 8 ++++++++ ci-scripts/epc.py | 8 ++++++-- ci-scripts/main.py | 2 ++ ci-scripts/xml_files/sa_cn5g_closure.xml | 1 + ci-scripts/xml_files/sa_cn5g_start.xml | 1 + 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ci-scripts/ci_infra.yaml b/ci-scripts/ci_infra.yaml index 8cbb5936e2..d562593e1a 100644 --- a/ci-scripts/ci_infra.yaml +++ b/ci-scripts/ci_infra.yaml @@ -58,6 +58,8 @@ adb_ue_2: oc-cn5g: Host: avra + Namespace: "oaicicd-core-for-ci-ran" + CNPath: "/opt/oai-cn5g-fed-develop-2024-april-00102" NetworkScript: echo "inet 172.21.6.102" RunIperf3Server: False diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py index 80d6d95daa..3f11fad7fb 100644 --- a/ci-scripts/cls_cluster.py +++ b/ci-scripts/cls_cluster.py @@ -43,7 +43,6 @@ NAMESPACE = "oaicicd-ran" OCUrl = "https://api.oai.cs.eurecom.fr:6443" OCRegistry = "default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/" CI_OC_RAN_NAMESPACE = "oaicicd-ran" -CI_OC_CORE_NAMESPACE = "oaicicd-core-for-ci-ran" CN_IMAGES = ["mysql", "oai-nrf", "oai-amf", "oai-smf", "oai-upf", "oai-ausf", "oai-udm", "oai-udr", "oai-traffic-server"] CN_CONTAINERS = ["", "-c nrf", "-c amf", "-c smf", "-c upf", "-c ausf", "-c udm", "-c udr", ""] @@ -68,10 +67,9 @@ def OC_login(cmd, ocUserName, ocPassword, ocProjectName): def OC_logout(cmd): cmd.run(f'oc logout') -def OC_deploy_CN(cmd, ocUserName, ocPassword): - logging.debug('OC OAI CN5G: Deploying OAI CN5G on Openshift Cluster') - path = "/opt/oai-cn5g-fed-develop-2024-april-00102" - succeeded = OC_login(cmd, ocUserName, ocPassword, CI_OC_CORE_NAMESPACE) +def OC_deploy_CN(cmd, ocUserName, ocPassword, ocNamespace, path): + logging.debug(f'OC OAI CN5G: Deploying OAI CN5G on Openshift Cluster: {ocNamespace}') + succeeded = OC_login(cmd, ocUserName, ocPassword, ocNamespace) if not succeeded: return False, CONST.OC_LOGIN_FAIL cmd.run('helm uninstall oai5gcn --wait --timeout 60s') @@ -84,10 +82,9 @@ def OC_deploy_CN(cmd, ocUserName, ocPassword): OC_logout(cmd) return True, report -def OC_undeploy_CN(cmd, ocUserName, ocPassword): - logging.debug('OC OAI CN5G: Terminating CN on Openshift Cluster') - path = "/opt/oai-cn5g-fed-develop-2024-april-00102" - succeeded = OC_login(cmd, ocUserName, ocPassword, CI_OC_CORE_NAMESPACE) +def OC_undeploy_CN(cmd, ocUserName, ocPassword, ocNamespace, path): + logging.debug(f'OC OAI CN5G: Terminating CN on Openshift Cluster: {ocNamespace}') + succeeded = OC_login(cmd, ocUserName, ocPassword, ocNamespace) if not succeeded: return False, CONST.OC_LOGIN_FAIL cmd.run(f'rm -Rf {path}/logs') diff --git a/ci-scripts/cls_module.py b/ci-scripts/cls_module.py index d0cfba0299..ef758a2933 100644 --- a/ci-scripts/cls_module.py +++ b/ci-scripts/cls_module.py @@ -65,6 +65,8 @@ class Module_UE: self.logStore = m.get('LogStore') self.cmd_prefix = m.get('CmdPrefix') self.runIperf3Server = m.get('RunIperf3Server', True) + self.namespace = m.get('Namespace') + self.cnPath = m.get('CNPath') logging.info(f'initialized {self.module_name}@{self.host} from {filename}') def __str__(self): @@ -190,6 +192,12 @@ class Module_UE: def getHost(self): return self.host + def getNamespace(self): + return self.namespace + + def getCNPath(self): + return self.cnPath + def getRunIperf3Server(self): return self.runIperf3Server diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index fb5aa8cde6..7c0eb51853 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -48,6 +48,7 @@ import helpreadme as HELP import constants as CONST import cls_cluster as OC import cls_cmd +import cls_module #----------------------------------------------------------- # Class Declaration #----------------------------------------------------------- @@ -75,6 +76,7 @@ class EPCManagement(): self.OCRegistry = "default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/" self.OCUserName = '' self.OCPassword = '' + self.cnID = '' self.imageToPull = '' self.eNBSourceCodePath = '' @@ -298,7 +300,8 @@ class EPCManagement(): html_cell += '(' + res4.group('date') + ')' html_cell += '\n' elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): - succeeded, report = OC.OC_deploy_CN(mySSH, self.OCUserName, self.OCPassword) + cn = cls_module.Module_UE(self.cnID) + succeeded, report = OC.OC_deploy_CN(mySSH, self.OCUserName, self.OCPassword, cn.getNamespace(), cn.getCNPath()) if not succeeded: HTML.CreateHtmlTestRow('N/A', 'KO', report) HTML.CreateHtmlTabFooter(False) @@ -575,7 +578,8 @@ class EPCManagement(): mySSH.copyin(f'{self.SourceCodePath}/logs/test_logs_CN.zip','test_logs_CN.zip') logging.debug(message) elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): - succeeded, report = OC.OC_undeploy_CN(mySSH, self.OCUserName, self.OCPassword) + cn = cls_module.Module_UE(self.cnID) + succeeded, report = OC.OC_undeploy_CN(mySSH, self.OCUserName, self.OCPassword, cn.getNamespace(), cn.getCNPath()) if not succeeded: HTML.CreateHtmlTestRow('N/A', 'KO', report) HTML.CreateHtmlTabFooter(False) diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 03c99d9741..14466a1594 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -329,11 +329,13 @@ def GetParametersFromXML(action): string_field = test.findtext('args') if (string_field is not None): EPC.cfgDeploy = string_field + EPC.cnID = test.findtext('cn_id') elif action == 'Terminate_5GCN': string_field = test.findtext('args') if (string_field is not None): EPC.cfgUnDeploy = string_field + EPC.cnID = test.findtext('cn_id') elif action == 'Deploy_Object' or action == 'Undeploy_Object': eNB_instance=test.findtext('eNB_instance') diff --git a/ci-scripts/xml_files/sa_cn5g_closure.xml b/ci-scripts/xml_files/sa_cn5g_closure.xml index 7174da3b7b..727e208d4c 100644 --- a/ci-scripts/xml_files/sa_cn5g_closure.xml +++ b/ci-scripts/xml_files/sa_cn5g_closure.xml @@ -32,6 +32,7 @@ Terminate_5GCN Terminate 5G Core + oc-cn5g diff --git a/ci-scripts/xml_files/sa_cn5g_start.xml b/ci-scripts/xml_files/sa_cn5g_start.xml index 6499d60700..3de615330a 100644 --- a/ci-scripts/xml_files/sa_cn5g_start.xml +++ b/ci-scripts/xml_files/sa_cn5g_start.xml @@ -33,5 +33,6 @@ Initialize_5GCN Initialize 5G Core + oc-cn5g From ca2d9ec2a1ef9482e12a183953f5988dedd4ef18 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Fri, 2 Aug 2024 15:29:49 +0200 Subject: [PATCH 58/61] CI: Update ci_infra for FHI7.2 pipeline --- ci-scripts/ci_infra.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ci-scripts/ci_infra.yaml b/ci-scripts/ci_infra.yaml index d562593e1a..8ffb1c2083 100644 --- a/ci-scripts/ci_infra.yaml +++ b/ci-scripts/ci_infra.yaml @@ -18,6 +18,14 @@ up2: IF: wwan0 MTU: 1500 +up2-fhi72: + Host: up2 + AttachScript: sudo /opt/mbim-fhi72/start_quectel_mbim.sh + DetachScript: sudo /opt/mbim-fhi72/stop_quectel_mbim.sh + NetworkScript: ip a show dev wwan0 + IF: wwan0 + MTU: 1500 + sphex_quectel: Host: sphex InitScript: sudo stdbuf -oL /home/oaicicd/quectel-CM/quectel-CM -4 -s oai.ipv4 &> /tmp/quecel-cm.log & @@ -63,6 +71,13 @@ oc-cn5g: NetworkScript: echo "inet 172.21.6.102" RunIperf3Server: False +oc-cn5g-20897: + Host: cacofonix + Namespace: "oaicicd-core-for-fhi72" + CNPath: "/opt/oai-cn5g-fed-develop-2024-april-20897" + NetworkScript: echo "inet 172.21.6.105" + RunIperf3Server: False + matix-cn5g: Host: matix NetworkScript: docker exec prod-trf-gen ip a show dev eth0 @@ -101,6 +116,10 @@ amarisoft_ue: Host: amariue InitScript: /root/lteue-linux-2023-10-27/ue/lteue /root/oaicicd/ran_sa_aw2s_asue_2x2/aw2s-multi-00102-2x2.cfg & TermScript: /root/2023-10-27/libs/ws.js -t 10 127.0.0.1:9002 '{"message":"quit"}' || killall -KILL lteue-avx2 +amarisoft_ue_fhi72: + Host: amariue + InitScript: /root/lteue-linux-2023-10-27/ue/lteue /root/oaicicd/ran_sa_fhi72_asue_2x2_benetel550/fhi72-multi-20897-2x2.cfg & + TermScript: /root/2023-10-27/libs/ws.js -t 10 127.0.0.1:9002 '{"message":"quit"}' || killall -KILL lteue-avx2 amarisoft_ue_1: Host: amariue AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":1}' From 9a4d1e920d16a59d1aea3e853b3352d30a19465d Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Mon, 5 Aug 2024 14:15:29 +0200 Subject: [PATCH 59/61] CI: Add XML files for FHI72 pipeline --- .../xml_files/container_sa_fhi72_vvdn_up2.xml | 143 ++++++++++++++++++ .../container_sa_fhi72_vvdn_up2_cleanup.xml | 63 ++++++++ .../xml_files/sa_cn5g_20897_closure.xml | 38 +++++ ci-scripts/xml_files/sa_cn5g_20897_start.xml | 38 +++++ 4 files changed, 282 insertions(+) create mode 100644 ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml create mode 100644 ci-scripts/xml_files/container_sa_fhi72_vvdn_up2_cleanup.xml create mode 100644 ci-scripts/xml_files/sa_cn5g_20897_closure.xml create mode 100644 ci-scripts/xml_files/sa_cn5g_20897_start.xml diff --git a/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml new file mode 100644 index 0000000000..bac2ec38a0 --- /dev/null +++ b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml @@ -0,0 +1,143 @@ + + + test-5g-fhi72-vvdn + 100 MHz TDD SA VVDN + tasks + 1 + + 200000 + 110000 + 120000 + 102000 + 102001 + 100100 + 100010 + 100020 + 100030 + 100040 + 103000 + 100002 + 130000 + + + + + Custom_Command + Setup sriov and network interfaces VVDN + cacofonix + /opt/FHI7.2/setup_sriov_vvdn.sh + yes + + + + Pull_Cluster_Image + Pull Images from Cluster + oaicicd-ran + oai-gnb-fhi72 + + + + Deploy_Object + Deploy gNB (TDD/Band78/100MHz/VVDN) in a container + ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb + 0 + 0 + + + + Attach_UE + Attach UE + up2-fhi72 + + + + Ping + Ping: 100 pings in 10 sec + up2-fhi72 + -c 100 -i 0.1 172.21.6.104 + 1 + 15 + + + + Iperf + iperf (DL/300Mbps/UDP)(30 sec)(multi-ue profile) + -u -b 300M -t 30 -R + up2-fhi72 + 20 + 80 + balanced + oc-cn5g-20897 + + + + Iperf + iperf (DL/TCP)(30 sec)(multi-ue profile) + -t 30 -R + up2-fhi72 + 40 + oc-cn5g-20897 + + + + Iperf + iperf (UL/70Mbps/UDP)(30 sec)(multi-ue profile) + -u -b 70M -t 30 + up2-fhi72 + 20 + 80 + balanced + oc-cn5g-20897 + + + + Iperf + iperf (UL/TCP)(30 sec)(multi-ue profile) + -t 30 + up2-fhi72 + 40 + oc-cn5g-20897 + + + + Detach_UE + Detach UE + up2-fhi72 + + + + IdleSleep + Sleep + 5 + + + + Undeploy_Object + Undeploy gNB + ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb + 0 + 0 + + + diff --git a/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2_cleanup.xml b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2_cleanup.xml new file mode 100644 index 0000000000..1a9aecfc8a --- /dev/null +++ b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2_cleanup.xml @@ -0,0 +1,63 @@ + + + cleanup-fhi72-vvdn + Cleanup VVDN + trash + + 555555 + 666666 + 777777 + 888888 + + + + + Detach_UE + Detach UE + up2-fhi72 + + + + Undeploy_Object + Undeploy gNB + ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb + 0 + 0 + + + + Clean_Test_Server_Images + Clean Test Images on Test Server + 0 + + + + Custom_Command + Set CPU to idle state, set kernel parameters to default values + cacofonix + /opt/FHI7.2/setup_cleanup.sh + yes + + + diff --git a/ci-scripts/xml_files/sa_cn5g_20897_closure.xml b/ci-scripts/xml_files/sa_cn5g_20897_closure.xml new file mode 100644 index 0000000000..685775c1a4 --- /dev/null +++ b/ci-scripts/xml_files/sa_cn5g_20897_closure.xml @@ -0,0 +1,38 @@ + + + cn5g-closure + CN5G-Closure + log-out + + 060000 + + + + + Terminate_5GCN + Terminate 5G Core + oc-cn5g-20897 + + + diff --git a/ci-scripts/xml_files/sa_cn5g_20897_start.xml b/ci-scripts/xml_files/sa_cn5g_20897_start.xml new file mode 100644 index 0000000000..2d60baedc1 --- /dev/null +++ b/ci-scripts/xml_files/sa_cn5g_20897_start.xml @@ -0,0 +1,38 @@ + + + cn5g-start-tab + CN5G-Start + log-in + + 000100 + + + + + + Initialize_5GCN + Initialize 5G Core + oc-cn5g-20897 + + From a57098ec02e3b8047178c84225725ca691549764 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 18 Jul 2024 09:05:13 +0200 Subject: [PATCH 60/61] CI: Add FHI72 pipeline to CI doc --- doc/TESTBenches.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 17c869d55e..00537b8469 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -199,6 +199,12 @@ information on how the images are built. ~5G-NR - matix + N310 (gNB), up2 + COTS UE (Quectel RM520N), OAI 5GC deployed in docker on matix - NR performance tests: 2x2 configuration, 60 MHz and 100 MHz bandwidth +- [RAN-SA-FHI72-CN5G](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-FHI72-CN5G/) + ~5G-NR + - cacofonix + FHI72 + Benetel550 (gNB), AmariUE, OAI CN5G + - cacofonix + FHI72 + VVDN (gNB), up2 (Quectel RM520N UE), OAI CN5G + - OpenShift cluster for CN deployment + - FHI 7.2 testing with 100 MHz bandwidth, 2 layers in DL ### RAN-CI-NSA-Trigger From d8696f703c947cece876a6d11b3ca708cbbef3b2 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 18 Jul 2024 16:32:26 +0200 Subject: [PATCH 61/61] CI: Add FHI72 pipeline to the parent pipeline --- ci-scripts/Jenkinsfile-GitLab-Container | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index b1bf895111..f5b83ec071 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -585,6 +585,29 @@ pipeline { } } } + stage ("SA-FHI72-CN5G") { + when { expression {do5Gtest} } + steps { + script { + triggerSlaveJob ('RAN-SA-FHI72-CN5G', 'SA-FHI72-CN5G') + } + } + post { + always { + script { + // Using a unique variable name for each test stage to avoid overwriting on a global variable + // due to parallel-time concurrency + saFHI72Status = finalizeSlaveJob('RAN-SA-FHI72-CN5G') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + failingStages += saFHI72Status + } + } + } + } stage ("SA-OAIUE-CN5G") { when { expression {do5Gtest} } steps {