Coding rules
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5126 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -70,12 +70,12 @@ extern int ue_ip_netlink_init(void);
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_find_inst(struct net_device *dev) {
|
||||
int ue_ip_find_inst(struct net_device *dev_pP) {
|
||||
//---------------------------------------------------------------------------
|
||||
int i;
|
||||
|
||||
for (i=0;i<UE_IP_NB_INSTANCES_MAX;i++)
|
||||
if (ue_ip_dev[i] == dev)
|
||||
if (ue_ip_dev[i] == dev_pP)
|
||||
return(i);
|
||||
return(-1);
|
||||
}
|
||||
@@ -85,23 +85,23 @@ int ue_ip_find_inst(struct net_device *dev) {
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
void *ue_ip_interrupt(void){
|
||||
//---------------------------------------------------------------------------
|
||||
u8 cxi;
|
||||
uint8_t cxi;
|
||||
|
||||
// struct ue_ip_priv *priv=netdev_priv(dev_id);
|
||||
// ue_ip_priv_t *priv_p=netdev_priv(dev_id);
|
||||
// unsigned int flags;
|
||||
// priv->lock = SPIN_LOCK_UNLOCKED;
|
||||
// priv_p->lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT - begin\n");
|
||||
#endif
|
||||
// spin_lock_irqsave(&priv->lock,flags);
|
||||
// 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->lock,flags);
|
||||
// spin_unlock_irqrestore(&priv_p->lock,flags);
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT: end\n");
|
||||
#endif
|
||||
@@ -109,15 +109,15 @@ void *ue_ip_interrupt(void){
|
||||
}
|
||||
#endif //NETLINK
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_timer(unsigned long data){
|
||||
void ue_ip_timer(unsigned long dataP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv=(struct ue_ip_priv *)data;
|
||||
spin_lock(&priv->lock);
|
||||
(priv->timer).function=ue_ip_timer;
|
||||
(priv->timer).expires=jiffies+UE_IP_TIMER_TICK;
|
||||
(priv->timer).data=data;
|
||||
add_timer(&priv->timer);
|
||||
spin_unlock(&priv->lock);
|
||||
ue_ip_priv_t *priv_p=(ue_ip_priv_t *)dataP;
|
||||
spin_lock(&priv_p->lock);
|
||||
(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);
|
||||
spin_unlock(&priv_p->lock);
|
||||
return;
|
||||
// add_timer(&gpriv->timer);
|
||||
// spin_unlock(&gpriv->lock);
|
||||
@@ -125,9 +125,9 @@ void ue_ip_timer(unsigned long data){
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is activated by ifconfig
|
||||
int ue_ip_open(struct net_device *dev){
|
||||
int ue_ip_open(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv=netdev_priv(dev);
|
||||
ue_ip_priv_t *priv_p=netdev_priv(dev_pP);
|
||||
|
||||
// Address has already been set at init
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
@@ -137,45 +137,45 @@ int ue_ip_open(struct net_device *dev){
|
||||
}
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
if(!netif_queue_stopped(dev))
|
||||
netif_start_queue(dev);
|
||||
if(!netif_queue_stopped(dev_pP))
|
||||
netif_start_queue(dev_pP);
|
||||
else
|
||||
netif_wake_queue(dev);
|
||||
netif_wake_queue(dev_pP);
|
||||
|
||||
init_timer(&priv->timer);
|
||||
(priv->timer).expires = jiffies+UE_IP_TIMER_TICK;
|
||||
(priv->timer).data = (unsigned long)priv;
|
||||
(priv->timer).function = ue_ip_timer;
|
||||
//add_timer(&priv->timer);
|
||||
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;
|
||||
//add_timer(&priv_p->timer);
|
||||
|
||||
printk("[UE_IP_DRV][%s] name = %s\n", __FUNCTION__, dev->name);
|
||||
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){
|
||||
int ue_ip_stop(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
|
||||
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
del_timer(&(priv->timer));
|
||||
netif_stop_queue(dev);
|
||||
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){
|
||||
void ue_ip_teardown(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv;
|
||||
ue_ip_priv_t *priv_p;
|
||||
int inst;
|
||||
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
inst = ue_ip_find_inst(dev);
|
||||
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;
|
||||
@@ -183,38 +183,38 @@ void ue_ip_teardown(struct net_device *dev){
|
||||
|
||||
|
||||
printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
} // check dev
|
||||
} // check dev_pP
|
||||
else {
|
||||
printk("[UE_IP_DRV][%s] Device is null\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_set_config(struct net_device *dev, struct ifmap *map){
|
||||
int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
if (dev->flags & IFF_UP)
|
||||
if (dev_pP->flags & IFF_UP)
|
||||
return -EBUSY;
|
||||
if (map->base_addr != dev->base_addr) {
|
||||
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->irq != dev->irq)
|
||||
dev->irq = map->irq;
|
||||
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, struct net_device *dev){
|
||||
int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
int inst;
|
||||
|
||||
if (dev) {
|
||||
inst = ue_ip_find_inst(dev);
|
||||
if (dev_pP) {
|
||||
inst = ue_ip_find_inst(dev_pP);
|
||||
} else {
|
||||
printk("[UE_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__);
|
||||
return -1;
|
||||
printk("[UE_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((inst>=0) && (inst<UE_IP_NB_INSTANCES_MAX)) {
|
||||
@@ -222,25 +222,25 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb, struct net_device *dev){
|
||||
printk("[UE_IP_DRV][%s] inst %d, begin\n", __FUNCTION__,inst);
|
||||
#endif
|
||||
|
||||
if (!skb){
|
||||
if (!skb_pP){
|
||||
printk("[UE_IP_DRV][%s] input parameter skb is NULL\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
// End debug information
|
||||
netif_stop_queue(dev);
|
||||
dev->trans_start = jiffies;
|
||||
netif_stop_queue(dev_pP);
|
||||
dev_pP->trans_start = jiffies;
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] step 1\n", __FUNCTION__);
|
||||
#endif
|
||||
ue_ip_common_ip2wireless(skb,inst);
|
||||
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);
|
||||
dev_kfree_skb(skb_pP);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] step 3\n", __FUNCTION__);
|
||||
#endif
|
||||
netif_wake_queue(dev);
|
||||
netif_wake_queue(dev_pP);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] end\n", __FUNCTION__);
|
||||
#endif
|
||||
@@ -252,50 +252,48 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb, struct net_device *dev){
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct net_device_stats *ue_ip_get_stats(struct net_device *dev){
|
||||
struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
// return &((struct ue_ip_priv *)dev->priv)->stats;
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
//printk("[UE_IP_DRV][%s]\n", __FUNCTION__);
|
||||
return &priv->stats;
|
||||
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
|
||||
return &priv_p->stats;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_set_mac_address(struct net_device *dev, void *mac) {
|
||||
int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP) {
|
||||
//---------------------------------------------------------------------------
|
||||
//struct sockaddr *addr = mac;
|
||||
//struct sockaddr *addr = mac_pP;
|
||||
printk("[UE_IP_DRV][%s] CHANGE MAC ADDRESS UNSUPPORTED\n", __FUNCTION__);
|
||||
//memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
|
||||
//memcpy(dev_pP->dev_addr, addr->sa_data, dev_pP->addr_len);
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_change_mtu(struct net_device *dev, int mtu){
|
||||
int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP){
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtu);
|
||||
if ((mtu<50) || (mtu>1500))
|
||||
printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtuP);
|
||||
if ((mtuP<50) || (mtuP>1500))
|
||||
return -EINVAL;
|
||||
dev->mtu = mtu;
|
||||
dev_pP->mtu = mtuP;
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_change_rx_flags(struct net_device *dev, int flags){
|
||||
void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
printk("[UE_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flags);
|
||||
priv->rx_flags ^= flags;
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_tx_timeout(struct net_device *dev){
|
||||
void ue_ip_tx_timeout(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
// Transmitter timeout, serious problems.
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
|
||||
|
||||
printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__);
|
||||
// (struct ue_ip_priv *)(dev->priv)->stats.tx_errors++;
|
||||
(priv->stats).tx_errors++;
|
||||
dev->trans_start = jiffies;
|
||||
netif_wake_queue(dev);
|
||||
printk("[UE_IP_DRV][%s] transmit timed out %s\n", __FUNCTION__,dev->name);
|
||||
// (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++;
|
||||
(priv_p->stats).tx_errors++;
|
||||
dev_pP->trans_start = jiffies;
|
||||
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 = {
|
||||
@@ -315,23 +313,23 @@ static const struct net_device_ops ue_ip_netdev_ops = {
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Initialisation of the network device
|
||||
void ue_ip_init(struct net_device *dev){
|
||||
void ue_ip_init(struct net_device *dev_pP){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv;
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
memset(priv, 0, sizeof(struct ue_ip_priv));
|
||||
spin_lock_init(&priv->lock);
|
||||
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);
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
dev->netdev_ops = &ue_ip_netdev_ops;
|
||||
dev_pP->netdev_ops = &ue_ip_netdev_ops;
|
||||
#else
|
||||
#error "KERNEL VERSION MUST BE NEWER THAN 2.6.29"
|
||||
#endif
|
||||
dev->hard_header_len = 0;
|
||||
dev->addr_len = UE_IP_ADDR_LEN;
|
||||
dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
|
||||
dev->tx_queue_len = UE_IP_TX_QUEUE_LEN;
|
||||
dev->mtu = UE_IP_MTU;
|
||||
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;
|
||||
@@ -350,7 +348,7 @@ int init_module (void) {
|
||||
for (inst=0;inst<UE_IP_NB_INSTANCES_MAX;inst++) {
|
||||
printk("[UE_IP_DRV][%s] begin init instance %d\n", __FUNCTION__,inst);
|
||||
sprintf(devicename,"oip%d",inst);
|
||||
ue_ip_dev[inst] = alloc_netdev(sizeof(struct ue_ip_priv),devicename, ue_ip_init);
|
||||
ue_ip_dev[inst] = alloc_netdev(sizeof(ue_ip_priv_t),devicename, ue_ip_init);
|
||||
//netif_stop_queue(ue_ip_dev[inst]);
|
||||
if (ue_ip_dev[inst] == NULL) {
|
||||
printk("[UE_IP_DRV][%s][INST %02d] alloc_netdev FAILED\n", __FUNCTION__,inst);
|
||||
|
||||
Reference in New Issue
Block a user