Commit cf950dfa authored by Robert Schmidt's avatar Robert Schmidt

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).
parent bfaa906a
......@@ -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)
......
......@@ -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 ;
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
}
......@@ -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_ */
......@@ -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();
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();
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");
}
}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
}
//-----------------------------------------------------------------------------
......
......@@ -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)
......
......@@ -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)
......
......@@ -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();
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();
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);
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 ;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment