Commit d06d2852 authored by thomasl's avatar thomasl

remove legacy conditional compilation with kernel version



git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6078 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 6df7aaaa
......@@ -2,79 +2,13 @@
#
NAS_UPDIR := $(shell /bin/pwd)
KERNEL_NAME=$(shell echo `uname -r`)
KERNEL_MAIN_TYPE=$(shell echo `uname -r | cut -d. -f-2 | tr "." "_"`)
export KERNEL_MAIN_TYPE
KERNEL_MAIN_VERSION=$(shell echo `uname -r | cut -d. -f-1`)
KERNEL_ARCH=$(shell echo `uname -m`)
#SET_REGPARM=$(shell if [ $(KERNEL_ARCH) = 'i686' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
ifeq ($(KERNEL_MAIN_VERSION),2)
ifeq ($(IS_LINUX), 1)
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
else
ifeq ($(IS_KERNEL_OPENAIRINTERFACE), 1)
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
else
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux-headers-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
endif
endif
SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_20=$(shell if [ $(SUBVERSION) -ge 20 ] ; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_22=$(shell if [ $(SUBVERSION) -ge 22 ] ; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_29=$(shell if [ $(SUBVERSION) -ge 29 ] ; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_30=$(shell if [ $(SUBVERSION) -ge 30 ] ; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_32=$(shell if [ $(SUBVERSION) -ge 32 ] ; then echo true ; fi)
IS_KERNEL_MAIN_VERSION_IS_2 = "true"
endif
# Add global rule for V3 kernels
ifeq ($(KERNEL_MAIN_VERSION),3)
ifeq ($(IS_LINUX), 1)
PATCHLEVEL=$(shell echo `grep '^PATCHLEVEL =' /usr/src/linux/Makefile | sed -e 's, ,,g' | sed -e 's/PATCHLEVEL=//'`)
else
ifeq ($(IS_KERNEL_OPENAIRINTERFACE), 1)
PATCHLEVEL=$(shell echo `grep '^PATCHLEVEL =' /usr/src/linux-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/PATCHLEVEL=//'`)
else
PATCHLEVEL=$(shell echo `grep '^PATCHLEVEL =' /usr/src/linux-headers-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/PATCHLEVEL=//'`)
endif
endif
SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi)
IS_KERNEL2_SUBVERSION_GREATER_THAN_22 = "true"
IS_KERNEL2_SUBVERSION_GREATER_THAN_29 = "true"
IS_KERNEL2_SUBVERSION_GREATER_THAN_30 = "true"
IS_KERNEL2_SUBVERSION_GREATER_THAN_32 = "true"
IS_KERNEL3_PATCHLEVEL_GREATER_THAN_2=$(shell if [ $(PATCHLEVEL) -ge 2 ] ; then echo true ; fi)
IS_KERNEL3_PATCHLEVEL_GREATER_THAN_5=$(shell if [ $(PATCHLEVEL) -ge 5 ] ; then echo true ; fi)
IS_KERNEL3_PATCHLEVEL_GREATER_THAN_8=$(shell if [ $(PATCHLEVEL) -ge 8 ] ; then echo true ; fi)
IS_KERNEL3_PATCHLEVEL_GREATER_THAN_9=$(shell if [ $(PATCHLEVEL) -ge 9 ] ; then echo true ; fi)
IS_KERNEL_MAIN_VERSION_IS_3 = "true"
endif
GT2620= $(if $(IS_KERNEL2_SUBVERSION_GREATER_THAN_20),-DKERNEL_VERSION_GREATER_THAN_2622=1)
GT2622= $(if $(IS_KERNEL2_SUBVERSION_GREATER_THAN_22),-DKERNEL_VERSION_GREATER_THAN_2622=1)
GT2629= $(if $(IS_KERNEL2_SUBVERSION_GREATER_THAN_29),-DKERNEL_VERSION_GREATER_THAN_2629=1)
GT2632= $(if $(IS_KERNEL2_SUBVERSION_GREATER_THAN_32),-DKERNEL_VERSION_GREATER_THAN_2632=1)
V3= $(if $(IS_KERNEL_MAIN_VERSION_IS_3),-DKERNEL_MAIN_VERSION_IS_3=1)
GT32= $(if $(IS_KERNEL3_PATCHLEVEL_GREATER_THAN_2),-DKERNEL_VERSION_GREATER_THAN_3200=1)
GT35= $(if $(IS_KERNEL3_PATCHLEVEL_GREATER_THAN_5),-DKERNEL_VERSION_GREATER_THAN_3500=1)
GT38= $(if $(IS_KERNEL3_PATCHLEVEL_GREATER_THAN_8),-DKERNEL_VERSION_GREATER_THAN_3800=1)
GT39= $(if $(IS_KERNEL3_PATCHLEVEL_GREATER_THAN_9),-DKERNEL_VERSION_GREATER_THAN_3900=1)
####################################################
# D E B U G F L A G S
####################################################
SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi)
####################################################
# EXTRA COMPILER FLAGS
####################################################
EXTRA_CFLAGS = -I$(OPENAIR2_DIR)/COMMON -fno-common $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_20),-mregparm=3 -fno-stack-protector -mpreferred-stack-boundary=4) $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) $(GT2622) $(GT2629) $(GT2632) $(V3) $(GT32) $(GT35) $(GT38) $(GT39)
EXTRA_CFLAGS = -I$(OPENAIR2_DIR)/COMMON -fno-common -mregparm=3 -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,)
......@@ -101,19 +35,7 @@ endif
print:
@echo KERNEL_NAME : $(KERNEL_NAME)
@echo KERNEL_MAIN_VERSION : $(KERNEL_MAIN_VERSION)
@echo KERNEL_SUB_VERSION : $(SUBVERSION)
@echo KERNEL_PATCHLEVEL : $(PATCHLEVEL)
@echo SET_X64 : $(SET_X64)
@echo flag gt2620 : $(GT2620)
@echo flag gt2622 : $(GT2622)
@echo flag gt2629 : $(GT2629)
@echo flag gt2632 : $(GT2632)
@echo flag gt32 : $(GT32)
@echo flag gt35 : $(GT35)
@echo flag gt38 : $(GT38)
@echo flag gt39 : $(GT39)
clean:
rm -f *.ko
......
......@@ -41,6 +41,7 @@
#include <net/sock.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
#include <linux/version.h>
#include "local.h"
#include "proto_extern.h"
......@@ -54,18 +55,13 @@ Prototypes
*******************************************************************************/
static inline void nasmesh_lock(void);
static inline void nasmesh_unlock(void);
#ifdef KERNEL_VERSION_GREATER_THAN_2629
static void nas_nl_data_ready (struct sk_buff *skb);
#else
static int nas_netlink_rx_thread(void *data);
static void nas_nl_data_ready (struct sock *sk,int len);
#endif
int ue_ip_netlink_init(void);
static struct sock *nas_nl_sk = NULL;
static int exit_netlink_thread=0;
#ifdef KERNEL_VERSION_GREATER_THAN_3800
#ifdef LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
struct netlink_kernel_cfg cfg = {
.input = nas_nl_data_ready,
};
......@@ -84,7 +80,6 @@ static inline void nasmesh_unlock(void)
mutex_unlock(&nasmesh_mutex);
}
#ifdef KERNEL_VERSION_GREATER_THAN_2629
// 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)
{
......@@ -103,60 +98,6 @@ static void nas_nl_data_ready (struct sk_buff *skb)
//kfree_skb(skb); // not required,
}
}
#else
static struct task_struct *netlink_rx_thread;
// this thread is used to avoid blocking other system calls from entering the kernel
static int nas_netlink_rx_thread(void *data) {
int err;
struct sk_buff *skb = NULL;
struct nlmsghdr *nlh = NULL;
printk("[UE_IP_DRV][NETLINK] Starting RX Thread \n");
while (!kthread_should_stop()) {
if (nas_nl_sk) {
skb = skb_recv_datagram(nas_nl_sk, 0, 0, &err);
if (skb) {
#ifdef NETLINK_DEBUG
printk("[UE_IP_DRV][NETLINK] Received socket from PDCP\n");
#endif //NETLINK_DEBUG
nlh = (struct nlmsghdr *)skb->data;
nas_COMMON_QOS_receive(nlh);
skb_free_datagram(nas_nl_sk,skb);
}
}
else {
if (exit_netlink_thread == 1) {
printk("[UE_IP_DRV][NETLINK] exit_netlink_thread\n");
break;
}
}
} // while
printk("[UE_IP_DRV][NETLINK] Exiting RX thread\n");
return(0);
}
static
void nas_nl_data_ready (
struct sock *sk,
int len)
{
wake_up_interruptible(sk->sk_sleep);
}
#endif
int ue_ip_netlink_init(void)
......@@ -165,19 +106,15 @@ int ue_ip_netlink_init(void)
printk("[UE_IP_DRV][NETLINK] Running init ...\n");
nas_nl_sk = netlink_kernel_create(
#ifdef KERNEL_VERSION_GREATER_THAN_2622
&init_net,
#endif
#ifdef KERNEL_VERSION_GREATER_THAN_3800
#ifdef LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
NAS_NETLINK_ID,
&cfg
#else
NAS_NETLINK_ID,
0,
nas_nl_data_ready,
#ifdef KERNEL_VERSION_GREATER_THAN_2622
&nasmesh_mutex, // NULL
#endif
THIS_MODULE
#endif
);
......@@ -189,12 +126,7 @@ int ue_ip_netlink_init(void)
return(-1);
}
#ifdef KERNEL_VERSION_GREATER_THAN_2629
#else
// Create receive thread
netlink_rx_thread = kthread_run(nas_netlink_rx_thread, NULL, "NAS_NETLINK_RX_THREAD");
#endif
return(0);
......@@ -207,11 +139,7 @@ void ue_ip_netlink_release(void) {
printk("[UE_IP_DRV][NETLINK] Releasing netlink socket\n");
if(nas_nl_sk){
#ifdef KERNEL_VERSION_GREATER_THAN_2629
netlink_kernel_release(nas_nl_sk); //or skb->sk
#else
sock_release(nas_nl_sk->sk_socket);
#endif
}
......@@ -240,7 +168,7 @@ int ue_ip_netlink_send(unsigned char *data,unsigned int len) {
nlh->nlmsg_pid = 0; /* from kernel */
#if !defined(KERNEL_VERSION_GREATER_THAN_3800)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
NETLINK_CB(nl_skb).pid = 0;
#endif
......
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