remove kernel 2.6 conditional compilation and replace other by native linux macros
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6069 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -2,49 +2,6 @@
|
||||
#
|
||||
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`)
|
||||
|
||||
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
|
||||
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_20=$(shell if [ $(SUBVERSION) -ge 20 ] ; then echo true ; fi)
|
||||
KERNEL_ARCH=$(shell echo `uname -m`)
|
||||
#SET_REGPARM=$(shell if [ $(KERNEL_ARCH) = 'i686' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
|
||||
SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
|
||||
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_22=$(shell if [ $(SUBVERSION) -ge 22 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_29=$(shell if [ $(SUBVERSION) -ge 29 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_30=$(shell if [ $(SUBVERSION) -ge 30 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_32=$(shell if [ $(SUBVERSION) -ge 32 ] ; then echo true ; fi)
|
||||
# Add global rule for V3 kernels
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_301= "false"
|
||||
|
||||
ifeq ($(KERNEL_MAIN_VERSION),3)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_22 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_29 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_30 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_32 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_301=$(shell if [ $(SUBVERSION) -ge 1 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_307=$(shell if [ $(SUBVERSION) -ge 7 ] ; then echo true ; fi)
|
||||
endif
|
||||
|
||||
GT2622 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_22),-DKERNEL_VERSION_GREATER_THAN_2622=1)
|
||||
GT2629 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_29),-DKERNEL_VERSION_GREATER_THAN_2629=1)
|
||||
GT32 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_32),-DKERNEL_VERSION_GREATER_THAN_32=1)
|
||||
GT301 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_301),-DKERNEL_VERSION_GREATER_THAN_301=1)
|
||||
|
||||
####################################################
|
||||
# NASMESH compilation flags
|
||||
####################################################
|
||||
@@ -54,12 +11,10 @@ GT301 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_301),-DKERNEL_VERSION_GREATER_
|
||||
# D E B U G F L A G S
|
||||
####################################################
|
||||
|
||||
|
||||
|
||||
####################################################
|
||||
# EXTRA COMPILER FLAGS
|
||||
####################################################
|
||||
EXTRA_CFLAGS = -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) $(V3) $(GT32) $(GT301)
|
||||
EXTRA_CFLAGS = -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,)
|
||||
EXTRA_CFLAGS += -I$(OPENAIR2_DIR)
|
||||
ifdef NAS_NETLINK
|
||||
EXTRA_CFLAGS += -DNAS_NETLINK
|
||||
@@ -99,16 +54,6 @@ endif
|
||||
#nasmesh.ko:
|
||||
# make V=1 -C /usr/src/linux-$(shell echo `uname -r`) M=`pwd` modules
|
||||
|
||||
print:
|
||||
@echo linux kernel ge 22: $(IS_KERNEL_SUBVERSION_GREATER_THAN_22)
|
||||
@echo kernel name : $(KERNEL_NAME)
|
||||
@echo subversion : $(SUBVERSION)
|
||||
@echo flag gt2622: $(GT2622)
|
||||
@echo linux kernel ge 29: $(IS_KERNEL_SUBVERSION_GREATER_THAN_29)
|
||||
@echo flag gt2629: $(GT2629)
|
||||
@echo linux kernel ge 30: $(IS_KERNEL_SUBVERSION_GREATER_THAN_30)
|
||||
@echo flag KERNEL_MAIN_VERSION $(KERNEL_MAIN_VERSION)
|
||||
|
||||
clean:
|
||||
rm -f $(nasmesh-objs) $(obj-m)
|
||||
# make -C /usr/src/linux-$(shell echo `uname -r`) M=`pwd` modules
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
#include <net/route.h>
|
||||
|
||||
|
||||
//#define KERNEL_VERSION_GREATER_THAN_2622 1
|
||||
//#define KERNEL_VERSION_GREATER_THAN_2630 1
|
||||
//#define MPLS
|
||||
|
||||
#ifdef MPLS
|
||||
@@ -613,18 +611,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst){
|
||||
version = 6;
|
||||
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
#else
|
||||
skb->nh.ipv6h,
|
||||
#endif
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
#else
|
||||
skb->nh.ipv6h
|
||||
#endif
|
||||
);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
@@ -639,18 +629,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst){
|
||||
case ETH_P_IP:
|
||||
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
#else
|
||||
dscp=nas_TOOL_get_dscp4(skb->nh.iph);
|
||||
#endif
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
#else
|
||||
skb->nh.iph,
|
||||
#endif
|
||||
&protocol);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
|
||||
@@ -93,11 +93,7 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
|
||||
skb->dev = nasdev[inst];
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
skb_reset_mac_header(skb);
|
||||
#else
|
||||
skb->mac.raw = skb->data;
|
||||
#endif
|
||||
//printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb->pkt_type,PACKET_HOST,PACKET_BROADCAST);
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
@@ -115,11 +111,7 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
skb_reset_network_header(skb);
|
||||
#else
|
||||
skb->nh.ipv6h = (struct ipv6hdr *)skb->data;
|
||||
#endif
|
||||
|
||||
skb->protocol = htons(ETH_P_IPV6);
|
||||
// printk("Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
@@ -171,14 +163,9 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
skb_reset_network_header(skb);
|
||||
network_header = (struct iphdr *)skb_network_header(skb);
|
||||
protocol = network_header->protocol;
|
||||
#else
|
||||
skb->nh.iph = (struct iphdr *)skb->data;
|
||||
protocol=skb->nh.iph->protocol;
|
||||
#endif
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
switch (protocol) {
|
||||
@@ -213,7 +200,6 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
network_header->check = 0;
|
||||
network_header->check = ip_fast_csum((unsigned char *) network_header,
|
||||
network_header->ihl);
|
||||
@@ -221,16 +207,6 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
printk("[NAS][COMMON][RECEIVE] IP Fast Checksum %x \n", network_header->check);
|
||||
#endif
|
||||
|
||||
#else
|
||||
skb->nh.iph->check = 0;
|
||||
skb->nh.iph->check = ip_fast_csum((unsigned char *)skb->data,
|
||||
skb->nh.iph->ihl);
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON][RECEIVE] IP Fast Checksum %x \n", skb->nh.iph->check);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// if (!(skb->nh.iph->frag_off & htons(IP_OFFSET))) {
|
||||
|
||||
|
||||
@@ -241,13 +217,8 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
|
||||
case IPPROTO_TCP:
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
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, tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum));
|
||||
#else
|
||||
cksum = (uint16_t*)&(((struct tcphdr*)((skb->data + (skb->nh.iph->ihl<<2))))->check);
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr,tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum));
|
||||
#endif
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d TCP packet calculated CS %x, CS = %x (before), SA (%x)%x, DA (%x)%x\n",
|
||||
@@ -271,13 +242,8 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
|
||||
case IPPROTO_UDP:
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
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, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum));
|
||||
#else
|
||||
cksum = (uint16_t*)&(((struct udphdr*)((skb->data + (skb->nh.iph->ihl<<2))))->check);
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum));
|
||||
#endif
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d UDP packet CS = %x (before), SA (%x)%x, DA (%x)%x\n",
|
||||
inst,
|
||||
@@ -309,7 +275,6 @@ void nas_COMMON_receive(uint16_t dlen,
|
||||
}
|
||||
// }
|
||||
|
||||
//#endif // KERNEL VERSION > 22
|
||||
#endif //NAS_ADDRESS_FIX
|
||||
|
||||
skb->protocol = htons(ETH_P_IP);
|
||||
|
||||
@@ -302,25 +302,18 @@ void nas_tx_timeout(struct net_device *dev){
|
||||
printk("TX_TIMEOUT: transmit timed out %s\n",dev->name);
|
||||
}
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
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,
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_32
|
||||
#ifndef KERNEL_VERSION_GREATER_THAN_301
|
||||
.ndo_set_multicast_list = NULL,
|
||||
#endif
|
||||
#endif
|
||||
.ndo_set_mac_address = NULL,
|
||||
.ndo_set_config = nas_set_config,
|
||||
.ndo_do_ioctl = nas_CTL_ioctl,
|
||||
.ndo_change_mtu = nas_change_mtu,
|
||||
.ndo_tx_timeout = nas_tx_timeout,
|
||||
};
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Initialisation of the network device
|
||||
@@ -337,23 +330,7 @@ void nas_init(struct net_device *dev){
|
||||
// priv=(struct nas_priv *)(dev->priv);
|
||||
priv=netdev_priv(dev);
|
||||
//
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
dev->netdev_ops = &nasmesh_netdev_ops;
|
||||
#else
|
||||
dev->open = nas_open;
|
||||
dev->stop = nas_stop;
|
||||
dev->set_config = nas_set_config;
|
||||
dev->hard_start_xmit = nas_hard_start_xmit;
|
||||
dev->do_ioctl = nas_CTL_ioctl;
|
||||
dev->get_stats = nas_get_stats;
|
||||
// dev->rebuild_header = NULL;
|
||||
// dev->hard_header = NULL;
|
||||
dev->change_mtu = nas_change_mtu;
|
||||
// dev->hard_header_cache = NULL;
|
||||
// dev->header_cache_update = NULL;
|
||||
dev->tx_timeout = nas_tx_timeout;
|
||||
//
|
||||
#endif
|
||||
// dev->type = ARPHRD_EUROPENAIRMESH;
|
||||
//dev->type = ARPHRD_ETHER;
|
||||
// dev->features = NETIF_F_NO_CSUM;
|
||||
@@ -557,7 +534,7 @@ void cleanup_module(void){
|
||||
|
||||
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_32
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
|
||||
|
||||
#define DRV_NAME "NASMESH"
|
||||
#define DRV_VERSION "3.0.2"DRV_NAME
|
||||
@@ -571,7 +548,7 @@ 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");
|
||||
|
||||
#ifndef KERNEL_VERSION_GREATER_THAN_301
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,1)
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
||||
MODULE_AUTHOR(DRV_AUTHOR);
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
//#include <linux/udp.h>
|
||||
//#include <linux/tcp.h>
|
||||
|
||||
//#define KERNEL_VERSION_GREATER_THAN_2622 1
|
||||
//#define KERNEL_VERSION_GREATER_THAN_2630 1
|
||||
|
||||
//#define NAS_DEBUG_TOOL 1
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -565,27 +562,15 @@ void print_TOOL_pk_ipv4(struct iphdr *iph){
|
||||
void print_TOOL_pk_all(struct sk_buff *skb){
|
||||
//---------------------------------------------------------------------------
|
||||
printk("Skb:\t %p, len = %u\n", skb, skb->len);
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
//navid: need to calculate the current used space: fixme?
|
||||
printk("Skb:\t available buf space = %u \n", skb->truesize);
|
||||
#else
|
||||
printk("Skb:\t available buf space = %u, cur used space = %u \n", skb->end-skb->head, skb->tail-skb->data);
|
||||
#endif
|
||||
switch (ntohs(skb->protocol))
|
||||
{
|
||||
case ETH_P_IPV6:
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
print_TOOL_pk_ipv6((struct ipv6hdr *)skb->network_header);
|
||||
#else
|
||||
print_TOOL_pk_ipv6(skb->nh.ipv6h);
|
||||
#endif
|
||||
break;
|
||||
case ETH_P_IP:
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
print_TOOL_pk_ipv4((struct iphdr *)skb->network_header);
|
||||
#else
|
||||
print_TOOL_pk_ipv4(skb->nh.iph);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user