Commit 7ece26ee authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] remove a pile of 2.0 and 2.2 support

parent e49392aa
......@@ -812,13 +812,8 @@ static int munich_probe(void)
printk("munich_probe: munich chip found, IRQ %d\n", pci->irq);
#if (LINUX_VERSION_CODE < 0x02030d)
bar1 = ioremap_nocache(pci->base_address[0], 0x100);
lbi = ioremap_nocache(pci->base_address[1], 0x100);
#else
bar1 = ioremap_nocache(pci->resource[0].start, 0x100);
lbi = ioremap_nocache(pci->resource[1].start, 0x100);
#endif
if (bar1 && lbi)
{
......
......@@ -198,12 +198,6 @@ void cpc_tty_init(pc300dev_t *pc300dev)
int port, aux;
st_cpc_tty_area * cpc_tty;
if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) {
printk("%s-tty: Error: TTY driver is supported on 2.4.X kernel!\n",
((struct net_device*)(pc300dev->hdlc))->name);
return;
}
/* hdlcX - X=interface number */
port = ((struct net_device*)(pc300dev->hdlc))->name[4] - '0';
if (port >= CPC_TTY_NPORTS) {
......
......@@ -60,14 +60,9 @@
#include <linux/if_arp.h> /* ARPHRD_* defines */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
#include <asm/uaccess.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#else
#include <asm/segment.h>
#include <net/route.h> /* Adding new route entries : 2.0.X kernels */
#endif
#include <asm/uaccess.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#include <linux/in.h> /* sockaddr_in */
#include <linux/inet.h>
......@@ -153,13 +148,11 @@ typedef struct chdlc_private_area
unsigned short timer_int_enabled;
char update_comms_stats; /* updating comms stats */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
bh_data_t *bh_head; /* Circular buffer for chdlc_bh */
unsigned long tq_working;
volatile int bh_write;
volatile int bh_read;
atomic_t bh_buff_used;
#endif
unsigned char interface_down;
......@@ -204,15 +197,8 @@ static int if_close (netdevice_t* dev);
static int if_header (struct sk_buff* skb, netdevice_t* dev,
unsigned short type, void* daddr, void* saddr, unsigned len);
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr (struct sk_buff *skb);
static struct net_device_stats* if_stats (netdevice_t* dev);
#else
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb);
static struct enet_statistics* if_stats (netdevice_t* dev);
#endif
static int if_rebuild_hdr (struct sk_buff *skb);
static struct net_device_stats* if_stats (netdevice_t* dev);
static int if_send (struct sk_buff* skb, netdevice_t* dev);
......@@ -228,9 +214,7 @@ static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb);
static int chdlc_disable_comm_shutdown (sdla_t *card);
#ifdef LINUX_2_4
static void if_tx_timeout (netdevice_t *dev);
#endif
static void if_tx_timeout (netdevice_t *dev);
/* Miscellaneous CHDLC Functions */
static int set_chdlc_config (sdla_t* card);
......@@ -260,12 +244,10 @@ static void wpc_isr (sdla_t* card);
static void rx_intr (sdla_t* card);
static void timer_intr(sdla_t *);
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Bottom half handlers */
static void chdlc_work (netdevice_t *);
static int chdlc_work_cleanup (netdevice_t *);
static int bh_enqueue (netdevice_t *, struct sk_buff *);
#endif
/* Bottom half handlers */
static void chdlc_work (netdevice_t *);
static int chdlc_work_cleanup (netdevice_t *);
static int bh_enqueue (netdevice_t *, struct sk_buff *);
/* Miscellaneous functions */
static int chk_bcast_mcast_addr(sdla_t* card, netdevice_t* dev,
......@@ -287,8 +269,6 @@ static int Intr_test_counter;
/* TTY Global Definitions */
#if defined(LINUX_2_4) || defined(LINUX_2_1)
#define NR_PORTS 4
#define WAN_TTY_MAJOR 226
#define WAN_TTY_MINOR 0
......@@ -321,8 +301,6 @@ static char *p_decode[] = {"NONE","ODD","EVEN"};
static void* tty_card_map[NR_PORTS] = {NULL,NULL,NULL,NULL};
#endif
/****** Public Functions ****************************************************/
......@@ -569,7 +547,6 @@ int wpc_init (sdla_t* card, wandev_conf_t* conf)
}
if ((card->tty_opt=conf->tty) == WANOPT_YES){
#if defined(LINUX_2_4) || defined(LINUX_2_1)
int err;
card->tty_minor = conf->tty_minor;
......@@ -582,11 +559,6 @@ int wpc_init (sdla_t* card, wandev_conf_t* conf)
if (err){
return err;
}
#else
printk(KERN_INFO "%s: Error: TTY driver is not supported on 2.0.X kernels!\n",
card->devname);
return -EINVAL;
#endif
}else{
......@@ -851,18 +823,6 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
min_t(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
DEFAULT_SLARP_REQ_TIMER;
#ifdef LINUX_2_0
if (card->u.c.slarp_timer){
printk(KERN_INFO
"%s: Error: Dynamic IP support not available for 2.0.X kernels\n",
card->devname);
printk(KERN_INFO "%s: Defaulting to Static IP addressing\n",
card->devname);
}
card->u.c.slarp_timer=0;
#endif
if (conf->hdlc_streaming == WANOPT_YES) {
printk(KERN_INFO "%s: Enabling HDLC STREAMING Mode\n",
wandev->name);
......@@ -892,40 +852,24 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
}
} else if( strcmp(conf->usedby, "API") == 0) {
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->u.c.usedby = API;
printk(KERN_INFO "%s: Running in API mode !\n",
wandev->name);
#else
printk(KERN_INFO "%s: API Mode is not supported for kernels lower than 2.2.X!\n",
wandev->name);
printk(KERN_INFO "%s: Please upgrade to a 2.2.X kernel fro the API support\n",
wandev->name);
kfree(chdlc_priv_area);
return -EINVAL;
#endif
}
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Tells us that if this interface is a
* gateway or not */
if ((chdlc_priv_area->gateway = conf->gateway) == WANOPT_YES){
printk(KERN_INFO "%s: Interface %s is set as a gateway.\n",
card->devname,card->u.c.if_name);
}
#endif
/* Get Multicast Information */
chdlc_priv_area->mc = conf->mc;
/* prepare network device data space for registration */
#ifdef LINUX_2_4
strcpy(dev->name,card->u.c.if_name);
#else
dev->name = (char *)kmalloc(strlen(card->u.c.if_name) + 2, GFP_KERNEL);
sprintf(dev->name, "%s", card->u.c.if_name);
#endif
dev->init = &if_init;
dev->priv = chdlc_priv_area;
......@@ -958,9 +902,6 @@ static int if_init (netdevice_t* dev)
chdlc_private_area_t* chdlc_priv_area = dev->priv;
sdla_t* card = chdlc_priv_area->card;
wan_device_t* wandev = &card->wandev;
#ifdef LINUX_2_0
int i;
#endif
/* Initialize device driver entry points */
dev->open = &if_open;
......@@ -969,10 +910,8 @@ static int if_init (netdevice_t* dev)
dev->rebuild_header = &if_rebuild_hdr;
dev->hard_start_xmit = &if_send;
dev->get_stats = &if_stats;
#ifdef LINUX_2_4
dev->tx_timeout = &if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
/* Initialize media-specific parameters */
......@@ -984,16 +923,8 @@ static int if_init (netdevice_t* dev)
dev->flags |= IFF_MULTICAST;
}
#ifdef LINUX_2_0
dev->family = AF_INET;
#endif
if (chdlc_priv_area->true_if_encoding){
#if defined(LINUX_2_1) || defined(LINUX_2_4)
dev->type = ARPHRD_HDLC; /* This breaks the tcpdump */
#else
dev->type = ARPHRD_PPP;
#endif
}else{
dev->type = ARPHRD_PPP;
}
......@@ -1019,11 +950,6 @@ static int if_init (netdevice_t* dev)
*/
dev->tx_queue_len = 100;
/* Initialize socket buffers */
#if !defined(LINUX_2_1) && !defined(LINUX_2_4)
for (i = 0; i < DEV_NUMBUFFS; ++i)
skb_queue_head_init(&dev->buffs[i]);
#endif
return 0;
}
......@@ -1043,10 +969,9 @@ static int if_open (netdevice_t* dev)
/* Only one open per interface is allowed */
if (is_dev_running(dev))
if (netif_running(dev))
return -EBUSY;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Initialize the work queue entry */
chdlc_priv_area->tq_working=0;
......@@ -1058,18 +983,11 @@ static int if_open (netdevice_t* dev)
chdlc_priv_area->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
memset(chdlc_priv_area->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1)));
atomic_set(&chdlc_priv_area->bh_buff_used, 0);
#endif
do_gettimeofday(&tv);
chdlc_priv_area->router_start_time = tv.tv_sec;
#ifdef LINUX_2_4
netif_start_queue(dev);
#else
dev->interrupt = 0;
dev->tbusy = 0;
dev->start = 1;
#endif
wanpipe_open(card);
......@@ -1100,8 +1018,6 @@ static int if_close (netdevice_t* dev)
chdlc_private_area_t* chdlc_priv_area = dev->priv;
sdla_t* card = chdlc_priv_area->card;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if (chdlc_priv_area->bh_head){
int i;
struct sk_buff *skb;
......@@ -1109,18 +1025,14 @@ static int if_close (netdevice_t* dev)
for (i=0; i<(MAX_BH_BUFF+1); i++){
skb = ((bh_data_t *)&chdlc_priv_area->bh_head[i])->skb;
if (skb != NULL){
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
}
kfree(chdlc_priv_area->bh_head);
chdlc_priv_area->bh_head=NULL;
}
#endif
stop_net_queue(dev);
#ifndef LINUX_2_4
dev->start=0;
#endif
netif_stop_queue(dev);
wanpipe_close(card);
del_timer(&chdlc_priv_area->poll_delay_timer);
return 0;
......@@ -1136,7 +1048,6 @@ static void disable_comm (sdla_t *card)
flags->interrupt_info_struct.interrupt_permission = 0;
}
#if defined(LINUX_2_4) || defined(LINUX_2_1)
if (!tty_init_cnt)
return;
......@@ -1160,7 +1071,6 @@ static void disable_comm (sdla_t *card)
state = &rs_table[card->tty_minor];
memset(state,0,sizeof(state));
}
#endif
return;
}
......@@ -1183,7 +1093,6 @@ static int if_header (struct sk_buff* skb, netdevice_t* dev,
}
#ifdef LINUX_2_4
/*============================================================================
* Handle transmit timeout event from netif watchdog
*/
......@@ -1203,7 +1112,6 @@ static void if_tx_timeout (netdevice_t *dev)
printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name);
netif_wake_queue (dev);
}
#endif
......@@ -1213,18 +1121,11 @@ static void if_tx_timeout (netdevice_t *dev)
* Return: 1 physical address resolved.
* 0 physical address not resolved
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr (struct sk_buff *skb)
{
return 1;
}
#else
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb)
{
return 1;
}
#endif
/*============================================================================
* Send a packet on a network interface.
......@@ -1253,9 +1154,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
unsigned long smp_flags;
int err=0;
#ifdef LINUX_2_4
netif_stop_queue(dev);
#endif
if (skb == NULL){
/* If we get here, some higher layer thinks we've missed an
......@@ -1264,31 +1163,10 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
printk(KERN_INFO "%s: interface %s got kicked!\n",
card->devname, dev->name);
wake_net_dev(dev);
netif_wake_queue(dev);
return 0;
}
#ifndef LINUX_2_4
if (dev->tbusy){
/* If our device stays busy for at least 5 seconds then we will
* kick start the device by making dev->tbusy = 0. We expect
* that our device never stays busy more than 5 seconds. So this
* is only used as a last resort.
*/
++card->wandev.stats.collisions;
if((jiffies - chdlc_priv_area->tick_counter) < (5 * HZ)) {
return 1;
}
printk (KERN_INFO "%s: Transmit timeout !\n",
card->devname);
/* unbusy the interface */
clear_bit(0,&dev->tbusy);
}
#endif
if (ntohs(skb->protocol) != htons(PVC_PROT)){
/* check the udp packet type */
......@@ -1301,7 +1179,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
chdlc_int->interrupt_permission |=
APP_INT_ON_TIMER;
}
start_net_queue(dev);
netif_start_queue(dev);
return 0;
}
......@@ -1309,8 +1187,8 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
/* multicast IP address */
if(chk_bcast_mcast_addr(card, dev, skb)){
++card->wandev.stats.tx_dropped;
wan_dev_kfree_skb(skb,FREE_WRITE);
start_net_queue(dev);
dev_kfree_skb_any(skb);
netif_start_queue(dev);
return 0;
}
}
......@@ -1325,17 +1203,17 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
printk(KERN_INFO "%s: Critical in if_send: %lx\n",
card->wandev.name,card->wandev.critical);
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_exit_crit;
}
if(card->u.c.state != WAN_CONNECTED){
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
}else if(!skb->protocol){
++card->wandev.stats.tx_errors;
start_net_queue(dev);
netif_start_queue(dev);
}else {
void* data = skb->data;
......@@ -1355,7 +1233,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
(len <= sizeof(api_tx_hdr_t))) {
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_exit_crit;
}
......@@ -1366,25 +1244,21 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
}
if(chdlc_send(card, data, len)) {
stop_net_queue(dev);
netif_stop_queue(dev);
}else{
++card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.tx_bytes += len;
#endif
start_net_queue(dev);
netif_start_queue(dev);
#ifdef LINUX_2_4
dev->trans_start = jiffies;
#endif
}
}
if_send_exit_crit:
if (!(err=is_queue_stopped(dev))) {
wan_dev_kfree_skb(skb, FREE_WRITE);
if (!(err=netif_queue_stopped(dev))) {
dev_kfree_skb_any(skb);
}else{
chdlc_priv_area->tick_counter = jiffies;
chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME;
......@@ -1409,14 +1283,12 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
{
u32 src_ip_addr;
u32 broadcast_ip_addr = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev;
#endif
/* read the IP source address from the outgoing packet */
src_ip_addr = *(u32 *)(skb->data + 12);
/* read the IP broadcast address for the device */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
in_dev = dev->ip_ptr;
if(in_dev != NULL) {
struct in_ifaddr *ifa= in_dev->ifa_list;
......@@ -1425,9 +1297,6 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
else
return 0;
}
#else
broadcast_ip_addr = dev->pa_brdaddr;
#endif
/* check if the IP Source Address is a Broadcast address */
if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
......@@ -1552,7 +1421,6 @@ unsigned short calc_checksum (char *data, int len)
* Get ethernet-style interface statistics.
* Return a pointer to struct enet_statistics.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats* if_stats (netdevice_t* dev)
{
sdla_t *my_card;
......@@ -1564,19 +1432,7 @@ static struct net_device_stats* if_stats (netdevice_t* dev)
my_card = chdlc_priv_area->card;
return &my_card->wandev.stats;
}
#else
static struct enet_statistics* if_stats (netdevice_t* dev)
{
sdla_t *my_card;
chdlc_private_area_t* chdlc_priv_area = dev->priv;
if ((chdlc_priv_area=dev->priv) == NULL)
return NULL;
my_card = chdlc_priv_area->card;
return &my_card->wandev.stats;
}
#endif
/****** Cisco HDLC Firmware Interface Functions *******************************/
......@@ -1846,7 +1702,7 @@ static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb)
return 0;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/********** Bottom Half Handlers ********************************************/
/* NOTE: There is no API, BH support for Kernels lower than 2.2.X.
......@@ -1873,7 +1729,7 @@ static void chdlc_work (netdevice_t * dev)
if (chan->common.sk == NULL || chan->common.func == NULL){
++card->wandev.stats.rx_dropped;
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
chdlc_work_cleanup(dev);
continue;
}
......@@ -1921,7 +1777,7 @@ static int bh_enqueue (netdevice_t *dev, struct sk_buff *skb)
if (atomic_read(&chan->bh_buff_used) == (MAX_BH_BUFF+1)){
++card->wandev.stats.rx_dropped;
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
return 1;
}
......@@ -1940,7 +1796,6 @@ static int bh_enqueue (netdevice_t *dev, struct sk_buff *skb)
/* END OF API BH Support */
#endif
/****** Interrupt Handlers **************************************************/
......@@ -2017,24 +1872,19 @@ static void wpc_isr (sdla_t* card)
flags->interrupt_info_struct.interrupt_permission &=
~APP_INT_ON_TX_FRAME;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if (card->tty_opt){
wanpipe_tty_trigger_poll(card);
break;
}
if (dev && is_queue_stopped(dev)){
if (dev && netif_queue_stopped(dev)){
if (card->u.c.usedby == API){
start_net_queue(dev);
netif_start_queue(dev);
wakeup_sk_bh(dev);
}else{
wake_net_dev(dev);
netif_wake_queue(dev);
}
}
#else
wake_net_dev(dev);
#endif
break;
case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */
......@@ -2120,7 +1970,6 @@ static void rx_intr (sdla_t* card)
len = rxbuf->frame_length;
#if defined(LINUX_2_4) || defined(LINUX_2_1)
if (card->tty_opt){
if (rxbuf->error_flag){
......@@ -2138,7 +1987,6 @@ static void rx_intr (sdla_t* card)
wanpipe_tty_receive(card,addr,len);
goto rx_exit;
}
#endif
dev = card->wandev.dev;
......@@ -2146,7 +1994,7 @@ static void rx_intr (sdla_t* card)
goto rx_exit;
}
if (!is_dev_running(dev))
if (!netif_running(dev))
goto rx_exit;
chdlc_priv_area = dev->priv;
......@@ -2177,9 +2025,7 @@ static void rx_intr (sdla_t* card)
skb->protocol = htons(ETH_P_IP);
card->wandev.stats.rx_packets ++;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.rx_bytes += skb->len;
#endif
udp_type = udp_pkt_type( skb, card );
if(udp_type == UDP_CPIPE_TYPE) {
......@@ -2189,7 +2035,6 @@ static void rx_intr (sdla_t* card)
interrupt_permission |=
APP_INT_ON_TIMER;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
} else if(card->u.c.usedby == API) {
api_rx_hdr_t* api_rx_hdr;
......@@ -2207,7 +2052,6 @@ static void rx_intr (sdla_t* card)
if (!test_and_set_bit(0,&chdlc_priv_area->tq_working))
wanpipe_queue_work(&chdlc_priv_area->common.wanpipe_work);
#endif
}else{
/* FIXME: we should check to see if the received packet is a
multicast packet so that we can increment the multicast
......@@ -2331,7 +2175,6 @@ static int set_chdlc_config(sdla_t* card)
netdevice_t * dev = card->wandev.dev;
chdlc_private_area_t *chdlc_priv_area = dev->priv;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev = dev->ip_ptr;
if(in_dev != NULL) {
......@@ -2344,12 +2187,6 @@ static int set_chdlc_config(sdla_t* card)
chdlc_priv_area->IP_netmask = ntohl(ifa->ifa_mask);
}
}
#else
cfg.IP_address = ntohl(dev->pa_addr);
cfg.IP_netmask = ntohl(dev->pa_mask);
chdlc_priv_area->IP_address = ntohl(dev->pa_addr);
chdlc_priv_area->IP_netmask = ntohl(dev->pa_mask);
#endif
/* FIXME: We must re-think this message in next release
if((cfg.IP_address & 0x000000FF) > 2) {
......@@ -2647,15 +2484,10 @@ static void process_route (sdla_t *card)
u32 remote_IP_addr = 0;
u32 IP_netmask, IP_addr;
int err = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev;
mm_segment_t fs;
struct ifreq if_info;
struct sockaddr_in *if_data1, *if_data2;
#else
unsigned long fs = 0;
struct rtentry route;
#endif
chdlc_priv_area = dev->priv;
port_num = card->u.c.comm_port;
......@@ -2705,7 +2537,6 @@ static void process_route (sdla_t *card)
return;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
in_dev = dev->ip_ptr;
if(in_dev != NULL) {
......@@ -2715,11 +2546,6 @@ static void process_route (sdla_t *card)
IP_netmask = ifa->ifa_mask;
}
}
#else
local_IP_addr = dev->pa_addr;
remote_IP_addr = dev->pa_dstaddr;
IP_netmask = dev->pa_mask;
#endif
}else{
/* According to Cisco HDLC, if the point-to-point address is
A.B.C.1, then we are the opposite (A.B.C.2), and vice-versa.
......@@ -2749,44 +2575,20 @@ static void process_route (sdla_t *card)
fs = get_fs(); /* Save file system */
set_fs(get_ds()); /* Get user space block */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Setup a structure for adding/removing routes */
memset(&if_info, 0, sizeof(if_info));
strcpy(if_info.ifr_name, dev->name);
#else
/* Setup a structure for adding/removing routes */
dev->pa_mask = IP_netmask;
dev->pa_dstaddr = remote_IP_addr;
dev->pa_addr = local_IP_addr;
memset(&route, 0, sizeof(route));
route.rt_dev = dev->name;
route.rt_flags = 0;
((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr =
dev->pa_dstaddr;
((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET;
((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr =
0xFFFFFFFF;
((struct sockaddr_in *)&(route.rt_genmask))->sin_family =
AF_INET;
#endif
switch (chdlc_priv_area->route_status) {
case ADD_ROUTE:
if(!card->u.c.slarp_timer) {
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr;
if_data2->sin_addr.s_addr = remote_IP_addr;
if_data2->sin_family = AF_INET;
err = devinet_ioctl(SIOCSIFDSTADDR, &if_info);
#else
err = ip_rt_new(&route);
#endif
} else {
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if_data1 = (struct sockaddr_in *)&if_info.ifr_addr;
if_data1->sin_addr.s_addr = local_IP_addr;
if_data1->sin_family = AF_INET;
......@@ -2796,9 +2598,6 @@ static void process_route (sdla_t *card)
if_data2->sin_family = AF_INET;
err = devinet_ioctl(SIOCSIFDSTADDR, &if_info);
}
#else
err = ip_rt_new(&route);
#endif
}
if(err) {
......@@ -2819,7 +2618,6 @@ static void process_route (sdla_t *card)
case REMOVE_ROUTE:
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Change the local ip address of the interface to 0.
* This will also delete the destination route.
*/
......@@ -2835,11 +2633,6 @@ static void process_route (sdla_t *card)
err = devinet_ioctl(SIOCSIFADDR,&if_info);
}
#else
/* set the point-to-point IP address to 0.0.0.0 */
dev->pa_dstaddr = 0;
err = ip_rt_kill(&route);
#endif
if(err) {
printk(KERN_INFO
"%s: Remove route %u.%u.%u.%u failed, (err %d)\n",
......@@ -2880,9 +2673,9 @@ static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
}
if(udp_pkt_src == UDP_PKT_FRM_STACK){
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
}else{
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
return(udp_pkt_stored);
......@@ -3256,9 +3049,7 @@ static int process_udp_mgmt_pkt(sdla_t* card, netdevice_t* dev,
if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) {
++ card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.tx_bytes += len;
#endif
}
}
} else {
......@@ -3808,30 +3599,21 @@ static void chdlc_poll_delay (unsigned long dev_ptr)
void s508_lock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_lock_irqsave(&card->wandev.lock, *smp_flags);
if (card->next){
spin_lock(&card->next->wandev.lock);
}
#else
disable_irq(card->hw.irq);
#endif
}
void s508_unlock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
if (card->next){
spin_unlock(&card->next->wandev.lock);
}
spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
#else
enable_irq(card->hw.irq);
#endif
}
//*********** TTY SECTION ****************
#if defined(LINUX_2_4) || defined(LINUX_2_1)
static void wanpipe_tty_trigger_tx_irq(sdla_t *card)
{
......@@ -3858,8 +3640,7 @@ static void tty_poll_work (void* data)
(tty->ldisc.write_wakeup)(tty);
}
wake_up_interruptible(&tty->write_wait);
#if defined(SERIAL_HAVE_POLL_WAIT) || \
(defined LINUX_2_1 && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15))
#if defined(SERIAL_HAVE_POLL_WAIT)
wake_up_interruptible(&tty->poll_wait);
#endif
return;
......@@ -4479,8 +4260,7 @@ static void wanpipe_tty_flush_buffer(struct tty_struct *tty)
return;
wake_up_interruptible(&tty->write_wait);
#if defined(SERIAL_HAVE_POLL_WAIT) || \
(defined LINUX_2_1 && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15))
#if defined(SERIAL_HAVE_POLL_WAIT)
wake_up_interruptible(&tty->poll_wait);
#endif
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
......@@ -4722,8 +4502,6 @@ int wanpipe_tty_init(sdla_t *card)
return 0;
}
#endif
MODULE_LICENSE("GPL");
......
......@@ -229,11 +229,7 @@ typedef struct fr_channel
int inarp_interval; /* Time between InArp Requests */
unsigned long inarp_tick; /* InArp jiffies tick counter */
long interface_down; /* Bring interface down on disconnect */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct net_device_stats ifstats; /* interface statistics */
#else
struct enet_statistics ifstats;
#endif
if_send_stat_t drvstats_if_send;
rx_intr_stat_t drvstats_rx_intr;
pipe_mgmt_stat_t drvstats_gen;
......@@ -242,14 +238,11 @@ typedef struct fr_channel
unsigned short transmit_length;
struct sk_buff *delay_skb;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
bh_data_t *bh_head; /* Circular buffer for chdlc_bh */
unsigned long tq_working;
volatile int bh_write;
volatile int bh_read;
atomic_t bh_buff_used;
#endif
/* Polling task queue. Each interface
* has its own task queue, which is used
......@@ -343,26 +336,14 @@ static int if_init(netdevice_t *dev);
static int if_open(netdevice_t *dev);
static int if_close(netdevice_t *dev);
#ifdef LINUX_2_4
static void if_tx_timeout (netdevice_t *dev);
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr (struct sk_buff *skb);
#else
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb);
#endif
static int if_send(struct sk_buff *skb, netdevice_t *dev);
static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
struct sk_buff *skb);
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats *if_stats(netdevice_t *dev);
#else
static struct enet_statistics* if_stats (netdevice_t* dev);
#endif
/* Interrupt handlers */
static void fr_isr(sdla_t *card);
......@@ -417,13 +398,11 @@ static int setup_for_delayed_transmit(netdevice_t* dev, struct sk_buff *skb);
netdevice_t * move_dev_to_next (sdla_t *, netdevice_t *);
static int check_tx_status(sdla_t *, netdevice_t *);
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Frame Relay Socket API */
static void trigger_fr_bh (fr_channel_t *);
static void fr_bh (netdevice_t *);
static int fr_bh_cleanup (netdevice_t *);
static int bh_enqueue (netdevice_t *, struct sk_buff *);
#endif
static void trigger_fr_poll (netdevice_t *);
static void fr_poll (netdevice_t *);
......@@ -886,26 +865,14 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
chan->common.usedby = BRIDGE;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE) mode.\n",
card->devname);
#else
printk(KERN_INFO "%s: WANPIPE Bridging mode not supported in 2.0.X kernels.\n",
card->devname);
err = -EPROTONOSUPPORT;
#endif
}else if( strcmp(conf->usedby, "BRIDGE_N") == 0 ){
chan->common.usedby = BRIDGE_NODE;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE_NODE) mode.\n",
card->devname);
#else
printk(KERN_INFO "%s: WANPIPE Bridging mode not supported in 2.0.X kernels.\n",
card->devname);
err = -EPROTONOSUPPORT;
#endif
}
if (!err){
......@@ -922,18 +889,9 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
} else if(strcmp(conf->usedby, "API") == 0){
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->common.usedby = API;
printk(KERN_INFO "%s: Running in API mode.\n",
wandev->name);
#else
printk(KERN_INFO "%s: The API Mode is not supported for"
"kernels lower than 2.2.X !\n",
wandev->name);
printk(KERN_INFO "%s: Please upgrade to a 2.2.X kernel for the API support\n",
wandev->name);
err = -EINVAL;
#endif
}
if (err) {
......@@ -980,16 +938,9 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
chan->mc = conf->mc;
if (conf->inarp == WANOPT_YES){
#if defined(LINUX_2_1) || defined(LINUX_2_4)
printk(KERN_INFO "%s: Inverse ARP Support Enabled\n",card->devname);
chan->inarp = conf->inarp ? INARP_REQUEST : INARP_NONE;
chan->inarp_interval = conf->inarp_interval ? conf->inarp_interval : 10;
#else
printk(KERN_INFO "%s: Warning, Inverse ARP Support not available for 2.0.X kernels!\n",
card->devname);
chan->inarp = INARP_NONE;
chan->inarp_interval = 10;
#endif
}else{
printk(KERN_INFO "%s: Inverse ARP Support Disabled\n",card->devname);
chan->inarp = INARP_NONE;
......@@ -1023,17 +974,7 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
chan->transmit_length = 0;
/* prepare network device data space for registration */
#ifdef LINUX_2_4
strcpy(dev->name,chan->name);
#else
dev->name = (char *)kmalloc(strlen(chan->name) + 2, GFP_KERNEL);
if(dev->name == NULL)
{
kfree(chan);
return -ENOMEM;
}
sprintf(dev->name, "%s", chan->name);
#endif
dev->init = &if_init;
dev->priv = chan;
......@@ -1042,9 +983,6 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
* We need a poll routine for each network
* interface.
*/
#ifndef LINUX_2_4
chan->fr_poll_task.next = NULL;
#endif
chan->fr_poll_task.sync = 0;
chan->fr_poll_task.routine = (void *)(void *)fr_poll;
chan->fr_poll_task.data = dev;
......@@ -1138,8 +1076,6 @@ static int wpf_exec (struct sdla* card, void* u_cmd, void* u_data)
int err, len;
fr_cmd_t cmd;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(copy_from_user((void*)&cmd, u_cmd, sizeof(cmd)))
return -EFAULT;
......@@ -1169,44 +1105,6 @@ static int wpf_exec (struct sdla* card, void* u_cmd, void* u_data)
if (len && u_data && !copy_to_user(u_data, (void*)&mbox->data, len))
return -EFAULT;
return 0;
#else
if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(fr_cmd_t)))
return -EFAULT;
memcpy_fromfs((void*)&cmd, u_cmd, sizeof(cmd));
if (cmd.length) {
if (!u_data || verify_area(VERIFY_READ, u_data, cmd.length))
return -EFAULT;
}
/* execute command */
do
{
memcpy(&mbox->cmd, &cmd, sizeof(cmd));
if (cmd.length)
memcpy_fromfs((void*)&mbox->data, u_data, cmd.length);
if (sdla_exec(mbox))
err = mbox->cmd.result;
else return -EIO;
} while (err && retry-- && fr_event(card, err, mbox));
/* return result */
memcpy_tofs(u_cmd, (void*)&mbox->cmd, sizeof(fr_cmd_t));
len = mbox->cmd.length;
if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len))
memcpy_tofs(u_data, (void*)&mbox->data, len);
return 0;
#endif
}
/****** Network Device Interface ********************************************/
......@@ -1223,9 +1121,6 @@ static int if_init (netdevice_t* dev)
fr_channel_t* chan = dev->priv;
sdla_t* card = chan->card;
wan_device_t* wandev = &card->wandev;
#ifdef LINUX_2_0
int i;
#endif
/* Initialize device driver entry points */
dev->open = &if_open;
......@@ -1234,15 +1129,11 @@ static int if_init (netdevice_t* dev)
dev->rebuild_header = &if_rebuild_hdr;
dev->hard_start_xmit = &if_send;
dev->get_stats = &if_stats;
#ifdef LINUX_2_4
dev->tx_timeout = &if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
if (chan->common.usedby == WANPIPE || chan->common.usedby == API){
#ifdef LINUX_2_0
dev->family = AF_INET;
#endif
/* Initialize media-specific parameters */
if (chan->true_if_encoding){
dev->type = ARPHRD_DLCI; /* This breaks tcpdump */
......@@ -1274,11 +1165,6 @@ static int if_init (netdevice_t* dev)
/* Set transmit buffer queue length */
dev->tx_queue_len = 100;
/* Initialize socket buffers */
#if !defined(LINUX_2_1) && !defined(LINUX_2_4)
for (i = 0; i < DEV_NUMBUFFS; ++i)
skb_queue_head_init(&dev->buffs[i]);
#endif
}else{
/* Setup the interface for Bridging */
......@@ -1315,16 +1201,12 @@ static int if_open (netdevice_t* dev)
int err = 0;
struct timeval tv;
if (is_dev_running(dev))
if (netif_running(dev))
return -EBUSY;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Initialize the task queue */
chan->tq_working=0;
#ifndef LINUX_2_4
chan->common.wanpipe_task.next = NULL;
#endif
chan->common.wanpipe_task.sync = 0;
chan->common.wanpipe_task.routine = (void *)(void *)fr_bh;
chan->common.wanpipe_task.data = dev;
......@@ -1333,15 +1215,8 @@ static int if_open (netdevice_t* dev)
chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF));
atomic_set(&chan->bh_buff_used, 0);
#endif
#ifdef LINUX_2_4
netif_start_queue(dev);
#else
dev->interrupt = 0;
dev->tbusy = 0;
dev->start = 1;
#endif
wanpipe_open(card);
do_gettimeofday( &tv );
......@@ -1370,10 +1245,7 @@ static int if_close (netdevice_t* dev)
chan->inarp = INARP_REQUEST;
}
stop_net_queue(dev);
#ifndef LINUX_2_4
dev->start=0;
#endif
netif_stop_queue(dev);
wanpipe_close(card);
return 0;
......@@ -1385,18 +1257,10 @@ static int if_close (netdevice_t* dev)
* Return: 1 physical address resolved.
* 0 physical address not resolved
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr (struct sk_buff* skb)
{
#else
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb)
{
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
netdevice_t *dev = skb->dev;
#endif
fr_channel_t* chan = dev->priv;
sdla_t* card = chan->card;
......@@ -1405,7 +1269,6 @@ static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
return 1;
}
#ifdef LINUX_2_4
/*============================================================================
* Handle transmit timeout event from netif watchdog
*/
......@@ -1429,7 +1292,7 @@ static void if_tx_timeout (netdevice_t *dev)
netif_wake_queue (dev);
}
#endif
/*============================================================================
* Send a packet on a network interface.
......@@ -1448,7 +1311,7 @@ static void if_tx_timeout (netdevice_t *dev)
* 1. This routine is called either by the protocol stack or by the "net
* bottom half" (with interrupts enabled).
*
* 2. Using the start_net_queue() and stop_net_queue() MACROS
* 2. Using netif_start_queue() and netif_stop_queue()
* will inhibit further transmit requests from the protocol stack
* and can be used for flow control with protocol layer.
*/
......@@ -1466,9 +1329,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
chan->drvstats_if_send.if_send_entry++;
#ifdef LINUX_2_4
netif_stop_queue(dev);
#endif
if (skb == NULL) {
/* if we get here, some higher layer thinks we've missed an
......@@ -1478,7 +1339,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
card->devname, dev->name);
chan->drvstats_if_send.if_send_skb_null ++;
wake_net_dev(dev);
netif_wake_queue(dev);
return 0;
}
......@@ -1488,8 +1349,8 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
printk(KERN_INFO "%s: Critical in if_send(): Peripheral running!\n",
card->devname);
wan_dev_kfree_skb(skb,FREE_WRITE);
start_net_queue(dev);
dev_kfree_skb_any(skb);
netif_start_queue(dev);
return 0;
}
......@@ -1500,37 +1361,13 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
*/
set_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
if(chan->transmit_length) {
stop_net_queue(dev);
netif_stop_queue(dev);
chan->tick_counter = jiffies;
clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
return 1;
}
clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
#ifndef LINUX_2_4
if (dev->tbusy) {
/* If our device stays busy for at least 5 seconds then we will
* kick start the device by making dev->tbusy = 0. We expect
* that our device never stays busy more than 5 seconds. So this
* is only used as a last resort.
*/
chan->drvstats_if_send.if_send_tbusy++;
++chan->ifstats.collisions;
if ((jiffies - chan->tick_counter) < (5 * HZ)) {
return 1;
}
printk(KERN_INFO "%s: Transmit timed out on %s\n",
card->devname, chan->name);
chan->drvstats_if_send.if_send_tbusy_timeout ++;
dev->tbusy = 0;
}
#endif
/* Move the if_header() code to here. By inserting frame
* relay header in if_header() we would break the
* tcpdump and other packet sniffers */
......@@ -1539,8 +1376,8 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
++chan->ifstats.tx_dropped;
++card->wandev.stats.tx_dropped;
wan_dev_kfree_skb(skb,FREE_WRITE);
start_net_queue(dev);
dev_kfree_skb_any(skb);
netif_start_queue(dev);
return 0;
}
......@@ -1557,7 +1394,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
if_send_PIPE_request ++;
}
}
start_net_queue(dev);
netif_start_queue(dev);
return 0;
}
......@@ -1569,8 +1406,8 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
if(chk_bcast_mcast_addr(card, dev, skb)){
++chan->ifstats.tx_dropped;
++card->wandev.stats.tx_dropped;
wan_dev_kfree_skb(skb, FREE_WRITE);
start_net_queue(dev);
dev_kfree_skb_any(skb);
netif_start_queue(dev);
return 0;
}
}
......@@ -1691,26 +1528,22 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
++chan->ifstats.tx_packets;
++card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.tx_bytes += skb->len;
card->wandev.stats.tx_bytes += skb->len;
#endif
#ifdef LINUX_2_4
dev->trans_start = jiffies;
#endif
}
}
}
if_send_start_and_exit:
start_net_queue(dev);
netif_start_queue(dev);
/* If we queued the packet for transmission, we must not
* deallocate it. The packet is unlinked from the IP stack
* not copied. Therefore, we must keep the original packet */
if (!test_bit(1,&delay_tx_queued)) {
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
}else{
adptr_flags->imask |= FR_INTR_TXRDY;
card->u.f.tx_interrupts_pending ++;
......@@ -1786,16 +1619,13 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
{
u32 src_ip_addr;
u32 broadcast_ip_addr = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev;
#endif
fr_channel_t* chan = dev->priv;
/* read the IP source address from the outgoing packet */
src_ip_addr = *(u32 *)(skb->data + 14);
/* read the IP broadcast address for the device */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
in_dev = dev->ip_ptr;
if(in_dev != NULL) {
struct in_ifaddr *ifa= in_dev->ifa_list;
......@@ -1804,9 +1634,6 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
else
return 0;
}
#else
broadcast_ip_addr = dev->pa_brdaddr;
#endif
/* check if the IP Source Address is a Broadcast address */
if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
......@@ -1999,11 +1826,7 @@ static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_
* Get ethernet-style interface statistics.
* Return a pointer to struct enet_statistics.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats *if_stats(netdevice_t *dev)
#else
static struct enet_statistics* if_stats (netdevice_t* dev)
#endif
{
fr_channel_t* chan = dev->priv;
......@@ -2193,7 +2016,7 @@ static void rx_intr (sdla_t* card)
skb = dev_alloc_skb(len);
if (!is_dev_running(dev) || (skb == NULL)){
if (!netif_running(dev) || (skb == NULL)){
++chan->ifstats.rx_dropped;
......@@ -2206,11 +2029,11 @@ static void rx_intr (sdla_t* card)
chan->drvstats_rx_intr.rx_intr_no_socket ++;
}
if (!is_dev_running(dev)){
if (!netif_running(dev)){
chan->drvstats_rx_intr.
rx_intr_dev_not_started ++;
if (skb){
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
}
goto rx_done;
......@@ -2252,7 +2075,6 @@ static void rx_intr (sdla_t* card)
}
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
}else if (chan->common.usedby == API) {
/* We are in API mode.
......@@ -2281,7 +2103,6 @@ static void rx_intr (sdla_t* card)
bh_enqueue(dev, skb);
trigger_fr_bh(chan);
#endif
}else if (handle_IPXWAN(skb->data,chan->name,chan->enable_IPX, chan->network_number)){
......@@ -2289,7 +2110,7 @@ static void rx_intr (sdla_t* card)
//if (chan->enable_IPX) {
// fr_send(card, dlci, 0, skb->len,skb->data);
//}
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
} else if (is_arp(skb->data)) {
......@@ -2304,7 +2125,7 @@ static void rx_intr (sdla_t* card)
card->devname);
}
}
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
} else if (skb->data[0] != 0x03) {
......@@ -2312,7 +2133,7 @@ static void rx_intr (sdla_t* card)
printk(KERN_INFO "%s: Non IETF packet discarded.\n",
card->devname);
}
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
} else {
......@@ -2341,7 +2162,7 @@ static void rx_intr (sdla_t* card)
if (!wanrouter_type_trans(skb, dev)) {
/* can't decapsulate packet */
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
++chan->drvstats_rx_intr.rx_intr_bfr_not_passed_to_stack;
++chan->ifstats.rx_errors;
......@@ -2359,10 +2180,8 @@ static void rx_intr (sdla_t* card)
++chan->ifstats.rx_packets;
++card->wandev.stats.rx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.rx_bytes += len_incl_hdr;
card->wandev.stats.rx_bytes += len_incl_hdr;
#endif
}
rx_done:
......@@ -2454,36 +2273,28 @@ static void tx_intr(sdla_t *card)
++chan->ifstats.tx_packets;
++card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.tx_bytes += chan->transmit_length;
card->wandev.stats.tx_bytes += chan->transmit_length;
#endif
/* We must free an sk buffer, which we used
* for delayed transmission; Otherwise, the sock
* will run out of memory */
wan_dev_kfree_skb(chan->delay_skb, FREE_WRITE);
dev_kfree_skb_any(chan->delay_skb);
chan->delay_skb = NULL;
chan->transmit_length = 0;
#ifdef LINUX_2_4
dev->trans_start = jiffies;
#endif
#ifdef LINUX_2_0
wake_net_dev(dev);
#else
if (is_queue_stopped(dev)){
if (netif_queue_stopped(dev)){
/* If using API, than wakeup socket BH handler */
if (chan->common.usedby == API){
start_net_queue(dev);
netif_start_queue(dev);
wakeup_sk_bh(dev);
}else{
wake_net_dev(dev);
netif_wake_queue(dev);
}
}
#endif
}
end_of_tx_intr:
......@@ -2778,8 +2589,6 @@ static void process_route (netdevice_t *dev)
fr_channel_t *chan = dev->priv;
sdla_t *card = chan->card;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct ifreq if_info;
struct sockaddr_in *if_data;
mm_segment_t fs = get_fs();
......@@ -2851,66 +2660,6 @@ static void process_route (netdevice_t *dev)
} /* Case Statement */
#else
/* Dynamic Route adding/removing */
struct rtentry route;
int err = 0;
unsigned long fs = get_fs();
memset(&route, 0, sizeof(route));
route.rt_dev = dev->name;
route.rt_flags = 0;
((struct sockaddr_in *) &(route.rt_dst)) ->
sin_addr.s_addr=dev->pa_dstaddr;
((struct sockaddr_in *) &(route.rt_dst)) ->
sin_family = AF_INET;
((struct sockaddr_in *) &(route.rt_genmask)) ->
sin_addr.s_addr = 0xFFFFFFFF;
((struct sockaddr_in *) &(route.rt_genmask)) ->
sin_family = AF_INET;
switch(chan->route_flag) {
case ADD_ROUTE:
set_fs(get_ds()); /* get user space block */
err = ip_rt_new(&route);
set_fs(fs); /* restore old block */
if (err) {
printk(KERN_INFO "%s: Adding of route failed. Error: %d\n",
card->devname,err);
printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n",
chan->name, NIPQUAD(dev->pa_dstaddr) );
}
else {
chan->route_flag = ROUTE_ADDED;
}
break;
case REMOVE_ROUTE:
set_fs(get_ds()); /* get user space block */
err = ip_rt_kill(&route);
set_fs(fs); /* restore old block */
if (err) {
printk(KERN_INFO "%s: Deleting of route failed. Error: %d\n",
card->devname,err);
printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n",
dev->name,NIPQUAD(dev->pa_dstaddr) );
} else {
printk(KERN_INFO "%s: Removed route.\n",
((fr_channel_t*)dev->priv)->name);
chan->route_flag = NO_ROUTE;
}
break;
}
#endif
}
......@@ -3468,7 +3217,7 @@ static int fr_dlci_change (sdla_t *card, fr_mbox_t* mbox)
"%s: DLCI %u is inactive!\n",
card->devname, dlci);
if (dev && is_dev_running(dev))
if (dev && netif_running(dev))
set_chan_state(dev, WAN_DISCONNECTED);
}
......@@ -3478,7 +3227,7 @@ static int fr_dlci_change (sdla_t *card, fr_mbox_t* mbox)
"%s: DLCI %u has been deleted!\n",
card->devname, dlci);
if (dev && is_dev_running(dev)){
if (dev && netif_running(dev)){
fr_channel_t *chan = dev->priv;
......@@ -3743,9 +3492,9 @@ static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t* card,
}
if(udp_pkt_src == UDP_PKT_FRM_STACK){
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
}else{
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
return(udp_pkt_stored);
......@@ -4173,8 +3922,6 @@ int send_inarp_request(sdla_t *card, netdevice_t *dev)
{
int err=0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
arphdr_1490_t *ArpPacket;
arphdr_fr_t *arphdr;
fr_channel_t *chan = dev->priv;
......@@ -4225,47 +3972,6 @@ int send_inarp_request(sdla_t *card, netdevice_t *dev)
return 1;
}
#else
arphdr_1490_t *ArpPacket;
arphdr_fr_t *arphdr;
fr_channel_t *chan = dev->priv;
ArpPacket = kmalloc(sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t), GFP_ATOMIC);
/* SNAP Header indicating ARP */
ArpPacket->control = 0x03;
ArpPacket->pad = 0x00;
ArpPacket->NLPID = 0x80;
ArpPacket->OUI[0] = 0;
ArpPacket->OUI[1] = 0;
ArpPacket->OUI[2] = 0;
ArpPacket->PID = 0x0608;
arphdr = (arphdr_fr_t *)(ArpPacket + 1); // Go to ARP Packet
/* InARP request */
arphdr->ar_hrd = 0x0F00; /* Frame Relay HW type */
arphdr->ar_pro = 0x0008; /* IP Protocol */
arphdr->ar_hln = 2; /* HW addr length */
arphdr->ar_pln = 4; /* IP addr length */
arphdr->ar_op = htons(0x08); /* InARP Request */
arphdr->ar_sha = 0; /* src HW DLCI - Doesn't matter */
arphdr->ar_sip = dev->pa_addr; /* Local Address */
arphdr->ar_tha = 0; /* dst HW DLCI - Doesn't matter */
arphdr->ar_tip = 0; /* Remote Address -- what we want */
printk(KERN_INFO "%s: Sending InARP request on DLCI %d.\n", card->devname, chan->dlci);
err = fr_send(card, chan->dlci, 0,
sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t),
(void *)ArpPacket);
if (!err){
printk(KERN_INFO "\n%s: Sending InARP request on DLCI %d.\n",
card->devname, chan->dlci);
clear_bit(ARP_CRIT,&card->wandev.critical);
}
kfree(ArpPacket);
#endif
return 0;
}
......@@ -4293,15 +3999,10 @@ int process_ARP(arphdr_1490_t *ArpPacket, sdla_t *card, netdevice_t* dev)
{
#if defined(LINUX_2_1) || defined(LINUX_2_4)
arphdr_fr_t *arphdr = (arphdr_fr_t *)(ArpPacket + 1); /* Skip header */
fr_rx_buf_ctl_t* frbuf = card->rxmb;
struct in_device *in_dev;
fr_channel_t *chan = dev->priv;
#else
arphdr_fr_t *arphdr = (arphdr_fr_t *)(ArpPacket + 1); /* Skip header */
fr_rx_buf_ctl_t* frbuf = card->rxmb;
#endif
/* Before we transmit ARP packet, we must check
* to see that we are not currently transmitting a
......@@ -4316,8 +4017,6 @@ int process_ARP(arphdr_1490_t *ArpPacket, sdla_t *card, netdevice_t* dev)
return 0;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
in_dev = dev->ip_ptr;
/* Check that IP addresses exist for our network address */
......@@ -4434,87 +4133,6 @@ int process_ARP(arphdr_1490_t *ArpPacket, sdla_t *card, netdevice_t* dev)
}
return 0;
#else
switch (ntohs(arphdr->ar_op)) {
case 0x08: // Inverse ARP request -- Send Reply, add route.
/* Check for valid Address */
printk(KERN_INFO "%s: Recvd PtP addr %u.%u.%u.%u -InArp Req\n",
((fr_channel_t *)dev->priv)->name, NIPQUAD(arphdr->ar_sip));
if (dev->pa_mask != 0xFFFFFFFF){
if ((dev->pa_mask & arphdr->ar_sip) != (dev->pa_mask & dev->pa_addr)) {
printk(KERN_INFO "%s: Invalid PtP address. InARP ignored.\n",
card->devname);
return -1;
}
}
if (dev->pa_addr == arphdr->ar_sip) {
printk(KERN_INFO "%s: Local addr = PtP addr. InARP ignored.\n",
card->devname);
return -1;
}
arphdr->ar_op = htons(0x09); /* InARP Reply */
/* Set addresses */
arphdr->ar_tip = arphdr->ar_sip;
arphdr->ar_sip = dev->pa_addr;
fr_send(card, frbuf->dlci, 0, frbuf->length, (void *)ArpPacket);
clear_bit(ARP_CRIT,&card->wandev.critical);
/* Modify Point-to-Point Address */
dev->pa_dstaddr = arphdr->ar_tip;
/* Add Route Flag */
/* The route will be added in the polling routine so
that it is not interrupt context. */
((fr_channel_t *) dev->priv)->route_flag = ADD_ROUTE;
trigger_fr_poll(dev);
break;
case 0x09: // Inverse ARP reply
/* Check for valid Address */
printk(KERN_INFO "%s: Recvd PtP addr %u.%u.%u.%u -InArp Reply\n",
((fr_channel_t *)dev->priv)->name, NIPQUAD(arphdr->ar_sip));
if ((dev->pa_mask & arphdr->ar_sip) != (dev->pa_mask & dev->pa_addr)) {
printk(KERN_INFO "%s: Invalid PtP address. InARP ignored.\n",
card->devname);
return -1;
}
if (dev->pa_addr == arphdr->ar_sip) {
printk(KERN_INFO "%s: Local addr = PtP addr. InARP ignored.\n",
card->devname);
return -1;
}
/* Modify Point-to-Point Address */
dev->pa_dstaddr = arphdr->ar_sip;
/* Add Route Flag */
/* The route will be added in the polling routine so
that it is not interrupt context. */
((fr_channel_t *) dev->priv)->route_flag = ADD_ROUTE;
((fr_channel_t *) dev->priv)->inarp = INARP_CONFIGURED;
trigger_fr_poll(dev);
break;
default: // ARP's and RARP's -- Shouldn't happen.
}
return 0;
#endif
}
......@@ -4706,15 +4324,9 @@ void s508_s514_lock(sdla_t *card, unsigned long *smp_flags)
{
if (card->hw.type != SDLA_S514){
#if defined(__SMP__) || defined(LINUX_2_4)
spin_lock_irqsave(&card->wandev.lock, *smp_flags);
#else
disable_irq(card->hw.irq);
#endif
}else{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_lock(&card->u.f.if_send_lock);
#endif
}
return;
}
......@@ -4724,23 +4336,15 @@ void s508_s514_unlock(sdla_t *card, unsigned long *smp_flags)
{
if (card->hw.type != SDLA_S514){
#if defined(__SMP__) || defined(LINUX_2_4)
spin_unlock_irqrestore (&card->wandev.lock, *smp_flags);
#else
enable_irq(card->hw.irq);
#endif
}else{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_unlock(&card->u.f.if_send_lock);
#endif
}
return;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/*----------------------------------------------------------------------
RECEIVE INTERRUPT: BOTTOM HALF HANDLERS
----------------------------------------------------------------------*/
......@@ -4770,7 +4374,7 @@ static int bh_enqueue (netdevice_t *dev, struct sk_buff *skb)
if (atomic_read(&chan->bh_buff_used) == MAX_BH_BUFF){
++card->wandev.stats.rx_dropped;
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
return 1;
}
......@@ -4859,7 +4463,7 @@ static void fr_bh (netdevice_t * dev)
if (chan->common.sk == NULL || chan->common.func == NULL){
++card->wandev.stats.rx_dropped;
++chan->ifstats.rx_dropped;
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
fr_bh_cleanup(dev);
continue;
}
......@@ -4896,7 +4500,6 @@ static int fr_bh_cleanup (netdevice_t *dev)
atomic_dec(&chan->bh_buff_used);
return 0;
}
#endif
/*----------------------------------------------------------------------
......@@ -4919,11 +4522,7 @@ static int fr_bh_cleanup (netdevice_t *dev)
static void trigger_fr_poll (netdevice_t *dev)
{
fr_channel_t* chan = dev->priv;
#ifdef LINUX_2_4
schedule_task(&chan->fr_poll_task);
#else
queue_task(&chan->fr_poll_task, &tq_scheduler);
#endif
return;
}
......@@ -5047,7 +4646,7 @@ static int check_tx_status(sdla_t *card, netdevice_t *dev)
}
}
if (is_queue_stopped(dev) || (card->u.f.tx_interrupts_pending))
if (netif_queue_stopped(dev) || (card->u.f.tx_interrupts_pending))
return 1;
return 0;
......@@ -5295,7 +4894,6 @@ static int setup_fr_header(struct sk_buff ** skb_orig, netdevice_t* dev, char op
* an Ethernet header */
if (op_mode == BRIDGE || op_mode == BRIDGE_NODE){
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Encapsulate the packet as a bridged Ethernet frame. */
#ifdef DEBUG
......@@ -5316,12 +4914,6 @@ static int setup_fr_header(struct sk_buff ** skb_orig, netdevice_t* dev, char op
skb->protocol = ETH_P_802_3;
return 8;
#else
/* BRIDGING is not supported in 2.0.X */
return -EINVAL;
#endif
}
return 0;
......
......@@ -252,8 +252,6 @@ static int wpft1_exec(sdla_t *card, void *u_cmd, void *u_data)
CHDLC_MAILBOX_STRUCT* mbox = card->mbox;
int len;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if (copy_from_user((void*)&mbox->command, u_cmd, sizeof(ft1_exec_cmd_t))){
return -EFAULT;
}
......@@ -282,36 +280,6 @@ static int wpft1_exec(sdla_t *card, void *u_cmd, void *u_data)
return -EFAULT;
}
#else
if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(ft1_exec_cmd_t))){
return -EFAULT;
}
memcpy_fromfs((void*)&mbox->command, u_cmd, sizeof(ft1_exec_cmd_t));
len = mbox->buffer_length;
if (len) {
if (!u_data || verify_area(VERIFY_READ, u_data, len))
return -EFAULT;
memcpy_fromfs((void*)&mbox->data, u_data, len);
}
/* execute command */
if (!sdla_exec(mbox))
return -EIO;
/* return result */
memcpy_tofs(u_cmd, (void*)&mbox->command, sizeof(ft1_exec_cmd_t));
len = mbox->buffer_length;
if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len)){
memcpy_tofs(u_data, (void*)&mbox->data, len);
}
#endif
return 0;
}
......
......@@ -104,15 +104,9 @@
#include <linux/in.h> /* sockaddr_in */
/* ---- 2.4.X KERNEL SUPPORT -----------------------*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
#include <asm/uaccess.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#else
#include <asm/segment.h>
#include <net/route.h> /* Adding new route entries : 2.0.X kernels */
#endif
#include <asm/uaccess.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#include <linux/if.h>
#include <linux/sdla_ppp.h> /* PPP firmware API definitions */
......@@ -163,10 +157,6 @@
#define NUM_AUTH_REQ_WITHOUT_REPLY 10
#define END_OFFSET 0x1F0
#if LINUX_VERSION_CODE < 0x020125
#define test_and_set_bit set_bit
#define net_ratelimit() 1
#endif
/******Data Structures*****************************************************/
......@@ -255,18 +245,10 @@ static int if_close(netdevice_t *dev);
static int if_header(struct sk_buff *skb, netdevice_t *dev, unsigned short type,
void *daddr, void *saddr, unsigned len);
#ifdef LINUX_2_4
static void if_tx_timeout (netdevice_t *dev);
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr(struct sk_buff *skb);
static struct net_device_stats *if_stats(netdevice_t *dev);
#else
static struct enet_statistics *if_stats(netdevice_t *dev);
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb);
#endif
static int if_send(struct sk_buff *skb, netdevice_t *dev);
......@@ -615,17 +597,7 @@ static int new_if(wan_device_t *wandev, netdevice_t *dev, wanif_conf_t *conf)
}
/* prepare network device data space for registration */
#ifdef LINUX_2_4
strcpy(dev->name,card->u.p.if_name);
#else
dev->name = (char *)kmalloc(strlen(card->u.p.if_name) + 2, GFP_KERNEL);
if(dev->name == NULL)
{
kfree(ppp_priv_area);
return -ENOMEM;
}
sprintf(dev->name, "%s", card->u.p.if_name);
#endif
dev->init = &if_init;
dev->priv = ppp_priv_area;
......@@ -673,7 +645,6 @@ static int wpp_exec(struct sdla *card, void *u_cmd, void *u_data)
ppp_mbox_t *mbox = card->mbox;
int len;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if (copy_from_user((void*)&mbox->cmd, u_cmd, sizeof(ppp_cmd_t)))
return -EFAULT;
......@@ -698,35 +669,6 @@ static int wpp_exec(struct sdla *card, void *u_cmd, void *u_data)
if (len && u_data && copy_to_user(u_data, (void*)&mbox->data, len))
return -EFAULT;
#else
if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(ppp_cmd_t)))
return -EFAULT;
memcpy_fromfs((void*)&mbox->cmd, u_cmd, sizeof(ppp_cmd_t));
len = mbox->cmd.length;
if (len) {
if (!u_data || verify_area(VERIFY_READ, u_data, len))
return -EFAULT;
}
/* execute command */
if (!sdla_exec(mbox))
return -EIO;
/* return result */
memcpy_tofs(u_cmd, (void*)&mbox->cmd, sizeof(ppp_cmd_t));
len = mbox->cmd.length;
if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len))
memcpy_tofs(u_data, (void*)&mbox->data, len);
#endif
return 0;
}
......@@ -744,9 +686,6 @@ static int if_init(netdevice_t *dev)
ppp_private_area_t *ppp_priv_area = dev->priv;
sdla_t *card = ppp_priv_area->card;
wan_device_t *wandev = &card->wandev;
#ifdef LINUX_2_0
int i;
#endif
/* Initialize device driver entry points */
dev->open = &if_open;
......@@ -755,10 +694,8 @@ static int if_init(netdevice_t *dev)
dev->rebuild_header = &if_rebuild_hdr;
dev->hard_start_xmit = &if_send;
dev->get_stats = &if_stats;
#ifdef LINUX_2_4
dev->tx_timeout = &if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
/* Initialize media-specific parameters */
dev->type = ARPHRD_PPP; /* ARP h/w type */
......@@ -770,9 +707,6 @@ static int if_init(netdevice_t *dev)
dev->flags |= IFF_MULTICAST;
}
#ifdef LINUX_2_0
dev->family = AF_INET;
#endif
dev->mtu = wandev->mtu;
dev->hard_header_len = PPP_HDR_LEN; /* media header length */
......@@ -786,12 +720,6 @@ static int if_init(netdevice_t *dev)
/* Set transmit buffer queue length */
dev->tx_queue_len = 100;
/* Initialize socket buffers */
#if !defined(LINUX_2_1) && !defined(LINUX_2_4)
for (i = 0; i < DEV_NUMBUFFS; ++i)
skb_queue_head_init(&dev->buffs[i]);
#endif
return 0;
}
......@@ -809,18 +737,12 @@ static int if_open (netdevice_t *dev)
struct timeval tv;
//unsigned long smp_flags;
if (is_dev_running(dev))
if (netif_running(dev))
return -EBUSY;
wanpipe_open(card);
#ifdef LINUX_2_4
netif_start_queue(dev);
#else
dev->interrupt = 0;
dev->tbusy = 0;
dev->start = 1;
#endif
do_gettimeofday( &tv );
ppp_priv_area->router_start_time = tv.tv_sec;
......@@ -852,10 +774,7 @@ static int if_close(netdevice_t *dev)
ppp_private_area_t *ppp_priv_area = dev->priv;
sdla_t *card = ppp_priv_area->card;
stop_net_queue(dev);
#ifndef LINUX_2_4
dev->start=0;
#endif
netif_stop_queue(dev);
wanpipe_close(card);
del_timer (&ppp_priv_area->poll_delay_timer);
......@@ -894,7 +813,6 @@ static int if_header(struct sk_buff *skb, netdevice_t *dev,
* Return: 1 physical address resolved.
* 0 physical address not resolved
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static int if_rebuild_hdr (struct sk_buff *skb)
{
netdevice_t *dev = skb->dev;
......@@ -906,16 +824,6 @@ static int if_rebuild_hdr (struct sk_buff *skb)
return 1;
}
#else
static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr,
struct sk_buff* skb)
{
return 1;
}
#endif
#ifdef LINUX_2_4
/*============================================================================
* Handle transmit timeout event from netif watchdog
*/
......@@ -937,7 +845,6 @@ static void if_tx_timeout (netdevice_t *dev)
++chan->if_send_stat.if_send_tbusy_timeout;
netif_wake_queue (dev);
}
#endif
......@@ -970,9 +877,7 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
++ppp_priv_area->if_send_stat.if_send_entry;
#ifdef LINUX_2_4
netif_stop_queue(dev);
#endif
if (skb == NULL) {
......@@ -984,36 +889,10 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
++ppp_priv_area->if_send_stat.if_send_skb_null;
wake_net_dev(dev);
netif_wake_queue(dev);
return 0;
}
#ifndef LINUX_2_4
if (dev->tbusy) {
/* If our device stays busy for at least 5 seconds then we will
* kick start the device by making dev->tbusy = 0. We expect
* that our device never stays busy more than 5 seconds. So this
* is only used as a last resort.
*/
++ppp_priv_area->if_send_stat.if_send_tbusy;
++card->wandev.stats.collisions;
if ((jiffies - ppp_priv_area->tick_counter) < (5*HZ)) {
return 1;
}
printk (KERN_INFO "%s: Transmit times out on %s\n",card->devname,dev->name);
++ppp_priv_area->if_send_stat.if_send_tbusy_timeout;
++card->wandev.stats.collisions;
/* unbusy the card (because only one interface per card)*/
dev->tbusy = 0;
}
#endif
sendpacket = skb->data;
udp_type = udp_pkt_type( skb, card );
......@@ -1025,7 +904,7 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
flags->imask |= PPP_INTR_TIMER;
}
++ppp_priv_area->if_send_stat.if_send_PIPE_request;
start_net_queue(dev);
netif_start_queue(dev);
return 0;
}
......@@ -1034,8 +913,8 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
*/
if(chk_bcast_mcast_addr(card, dev, skb)){
++card->wandev.stats.tx_dropped;
wan_dev_kfree_skb(skb,FREE_WRITE);
start_net_queue(dev);
dev_kfree_skb_any(skb);
netif_start_queue(dev);
return 0;
}
......@@ -1051,7 +930,7 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
++card->wandev.stats.tx_dropped;
++ppp_priv_area->if_send_stat.if_send_critical_non_ISR;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_exit_crit;
}
......@@ -1059,12 +938,12 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
++ppp_priv_area->if_send_stat.if_send_wan_disconnected;
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
} else if (!skb->protocol) {
++ppp_priv_area->if_send_stat.if_send_protocol_error;
++card->wandev.stats.tx_errors;
start_net_queue(dev);
netif_start_queue(dev);
} else {
......@@ -1075,32 +954,28 @@ static int if_send (struct sk_buff *skb, netdevice_t *dev)
ppp_priv_area->network_number, 0);
} else {
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_exit_crit;
}
}
if (ppp_send(card, skb->data, skb->len, skb->protocol)) {
stop_net_queue(dev);
netif_stop_queue(dev);
++ppp_priv_area->if_send_stat.if_send_adptr_bfrs_full;
++ppp_priv_area->if_send_stat.if_send_tx_int_enabled;
} else {
++ppp_priv_area->if_send_stat.if_send_bfr_passed_to_adptr;
++card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.tx_bytes += skb->len;
#endif
start_net_queue(dev);
#ifdef LINUX_2_4
netif_start_queue(dev);
dev->trans_start = jiffies;
#endif
}
}
if_send_exit_crit:
if (!(err=is_queue_stopped(dev))){
wan_dev_kfree_skb(skb, FREE_WRITE);
if (!(err=netif_queue_stopped(dev))){
dev_kfree_skb_any(skb);
}else{
ppp_priv_area->tick_counter = jiffies;
flags->imask |= PPP_INTR_TXRDY; /* unmask Tx interrupts */
......@@ -1134,13 +1009,8 @@ static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
udp_pkt_stored = 1;
}else{
if (skb->len > MAX_LGTH_UDP_MGNT_PKT){
#if defined(LINUX_2_1) || defined(LINUX_2_4)
printk(KERN_INFO "%s: PIPEMON UDP request too long : %i\n",
card->devname, skb->len);
#else
printk(KERN_INFO "%s: PIPEMON UDP request too long : %li\n",
card->devname, skb->len);
#endif
}else{
printk(KERN_INFO "%s: PIPEMON UPD request already pending\n",
card->devname);
......@@ -1149,9 +1019,9 @@ static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
}
if(udp_pkt_src == UDP_PKT_FRM_STACK){
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
}else{
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
return(udp_pkt_stored);
......@@ -1319,11 +1189,7 @@ static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_
* Get ethernet-style interface statistics.
* Return a pointer to struct net_device_stats.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats *if_stats(netdevice_t *dev)
#else
static struct enet_statistics *if_stats(netdevice_t *dev)
#endif
{
ppp_private_area_t *ppp_priv_area = dev->priv;
......@@ -1743,7 +1609,7 @@ static void wpp_isr (sdla_t *card)
case PPP_INTR_TXRDY: /* transmit interrupt 0x02 (bit 1)*/
++card->statistics.isr_tx;
flags->imask &= ~PPP_INTR_TXRDY;
wake_net_dev(dev);
netif_wake_queue(dev);
break;
case PPP_INTR_CMD: /* interface command completed */
......@@ -1821,7 +1687,7 @@ static void rx_intr(sdla_t *card)
return;
}
if (dev && is_dev_running(dev) && dev->priv){
if (dev && netif_running(dev) && dev->priv){
len = rxbuf->length;
ppp_priv_area = dev->priv;
......@@ -1881,7 +1747,7 @@ static void rx_intr(sdla_t *card)
if (!test_bit(SEND_CRIT, &card->wandev.critical)){
ppp_send(card, skb->data, skb->len, htons(ETH_P_IPX));
}
wan_dev_kfree_skb(skb,FREE_READ);
dev_kfree_skb_any(skb);
} else {
++card->wandev.stats.rx_dropped;
......@@ -1892,9 +1758,7 @@ static void rx_intr(sdla_t *card)
skb->mac.raw = skb->data;
++card->wandev.stats.rx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.rx_bytes += skb->len;
#endif
++ppp_priv_area->rx_intr_stat.rx_intr_bfr_passed_to_stack;
netif_rx(skb);
dev->last_rx = jiffies;
......@@ -2244,8 +2108,6 @@ static void process_route (sdla_t *card)
netdevice_t *dev = card->wandev.dev;
ppp_private_area_t *ppp_priv_area = dev->priv;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if ((card->u.p.ip_mode == WANOPT_PPP_PEER) &&
(flags->ip_state == 0x09)){
......@@ -2276,29 +2138,6 @@ static void process_route (sdla_t *card)
}
}
}
#else
if ((card->u.p.ip_mode == WANOPT_PPP_PEER) &&
(flags->ip_state == 0x09)){
if (ppp_priv_area->ip_local == 0)
return;
printk(KERN_INFO "%s: IPCP State Opened.\n", card->devname);
if (read_info( card )) {
printk(KERN_INFO
"%s: An error occurred in IP assignment.\n",
card->devname);
} else {
printk(KERN_INFO "%s: Assigned Lcl. Addr: %u.%u.%u.%u\n",
card->devname, NIPQUAD(dev->pa_addr));
printk(KERN_INFO "%s: Assigned Rmt. Addr: %u.%u.%u.%U\n",
card->devname, NIPQUAD(dev->pa_dstaddr));
}
}
#endif
}
/*============================================================================
......@@ -2328,9 +2167,7 @@ static void retrigger_comm(sdla_t *card)
static int config508(netdevice_t *dev, sdla_t *card)
{
ppp508_conf_t cfg;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev = dev->ip_ptr;
#endif
ppp_private_area_t *ppp_priv_area = dev->priv;
/* Prepare PPP configuration structure */
......@@ -2393,14 +2230,8 @@ static int config508(netdevice_t *dev, sdla_t *card)
printk(KERN_INFO "%s: PPP IP Mode: STATIC\n",card->devname);
cfg.ip_options = L_AND_R_IP_NO_ASSIG |
ENABLE_IP;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
cfg.ip_local = in_dev->ifa_list->ifa_local;
cfg.ip_remote = in_dev->ifa_list->ifa_address;
#else
cfg.ip_local = dev->pa_addr;
cfg.ip_remote = dev->pa_dstaddr;
#endif
/* Debugging code used to check that IP addresses
* obtained from the kernel are correct */
......@@ -2414,14 +2245,8 @@ static int config508(netdevice_t *dev, sdla_t *card)
cfg.ip_options = L_IP_LOCAL_ASSIG |
R_IP_LOCAL_ASSIG |
ENABLE_IP;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
cfg.ip_local = in_dev->ifa_list->ifa_local;
cfg.ip_remote = in_dev->ifa_list->ifa_address;
#else
cfg.ip_local = dev->pa_addr;
cfg.ip_remote = dev->pa_dstaddr;
#endif
/* Debugging code used to check that IP addresses
* obtained from the kernel are correct */
NEX_PRINTK (KERN_INFO "Local %u.%u.%u.%u Remote %u.%u.%u.%u Name %s\n",
......@@ -2431,8 +2256,6 @@ static int config508(netdevice_t *dev, sdla_t *card)
case WANOPT_PPP_PEER:
#if defined(LINUX_2_1) || defined(LINUX_2_4)
printk(KERN_INFO "%s: PPP IP Mode: PEER\n",card->devname);
cfg.ip_options = L_IP_REMOTE_ASSIG |
R_IP_REMOTE_ASSIG |
......@@ -2441,16 +2264,6 @@ static int config508(netdevice_t *dev, sdla_t *card)
cfg.ip_remote = 0x00;
break;
#else
/* No PEER support for 2.0.X kernels, drop down to default
* condition */
printk(KERN_INFO "%s: ERROR, PEER mode is not supported in 2.0.X kernels\n",
card->devname);
#endif
default:
printk(KERN_INFO "%s: ERROR: Unsupported PPP Mode Selected\n",
card->devname);
......@@ -3038,19 +2851,9 @@ static int read_info( sdla_t *card )
ppp_private_area_t *ppp_priv_area = dev->priv;
int err;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct ifreq if_info;
struct sockaddr_in *if_data1, *if_data2;
mm_segment_t fs;
#else
#ifdef _DYNAMIC_ROUTE_20X_SUPPORT_
struct rtentry route;
#endif
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Set Local and remote addresses */
memset(&if_info, 0, sizeof(if_info));
......@@ -3074,39 +2877,6 @@ static int read_info( sdla_t *card )
set_fs(fs); /* restore old block */
#else
/* FIXME: Dynamic Routing in 2.0.X kernels is not
* supported. Sorry ! I'll come back to it when I get
* a chance. */
printk(KERN_INFO "%s: ERROR, Dynamic routing is not supported in 2.0.X kernels\n",
card->devname);
printk(KERN_INFO "%s: Please use the STATIC IP mode!\n",
card->devname);
err = 0;
#ifdef _DYNAMIC_ROUTE_20X_SUPPORT_
dev->pa_dstaddr = ppp_priv_area->ip_remote;
dev->pa_addr = ppp_priv_area->ip_local;
memset(&route, 0, sizeof(route));
route.rt_dev = dev->name;
route.rt_flags = 0;
((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr =
dev->pa_dstaddr;
((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET;
((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr =
0xFFFFFFFF;
((struct sockaddr_in *)&(route.rt_genmask))->sin_family =
AF_INET;
err = ip_rt_new(&route);
#endif
#endif
if (err) {
printk (KERN_INFO "%s: Adding of route failed: %i\n",
card->devname,err);
......@@ -3130,32 +2900,21 @@ static void remove_route( sdla_t *card )
long ip_addr;
int err;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
mm_segment_t fs;
struct ifreq if_info;
struct sockaddr_in *if_data1;
struct in_device *in_dev = dev->ip_ptr;
struct in_ifaddr *ifa = in_dev->ifa_list;
#else
unsigned long fs = 0;
struct rtentry route;
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
ip_addr = ifa->ifa_local;
/* Set Local and remote addresses */
memset(&if_info, 0, sizeof(if_info));
strcpy(if_info.ifr_name, dev->name);
#endif
fs = get_fs();
set_fs(get_ds()); /* get user space block */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* Change the local ip address of the interface to 0.
* This will also delete the destination route.
*/
......@@ -3163,26 +2922,6 @@ static void remove_route( sdla_t *card )
if_data1->sin_addr.s_addr = 0;
if_data1->sin_family = AF_INET;
err = devinet_ioctl( SIOCSIFADDR, &if_info );
#else
ip_addr = dev->pa_addr;
dev->pa_dstaddr = 0;
memset(&route, 0, sizeof(route));
route.rt_dev = dev->name;
route.rt_flags = 0;
((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr =
dev->pa_dstaddr;
((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET;
((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr =
0xFFFFFFFF;
((struct sockaddr_in *)&(route.rt_genmask))->sin_family =
AF_INET;
err = ip_rt_kill(&route);
#endif
set_fs(fs); /* restore old block */
......@@ -3288,14 +3027,12 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
{
u32 src_ip_addr;
u32 broadcast_ip_addr = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct in_device *in_dev;
#endif
/* read the IP source address from the outgoing packet */
src_ip_addr = *(u32 *)(skb->data + 12);
/* read the IP broadcast address for the device */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
in_dev = dev->ip_ptr;
if(in_dev != NULL) {
struct in_ifaddr *ifa= in_dev->ifa_list;
......@@ -3304,9 +3041,6 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
else
return 0;
}
#else
broadcast_ip_addr = dev->pa_brdaddr;
#endif
/* check if the IP Source Address is a Broadcast address */
if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
......@@ -3328,20 +3062,12 @@ static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev,
void s508_lock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_lock_irqsave(&card->wandev.lock, *smp_flags);
#else
disable_irq(card->hw.irq);
#endif
}
void s508_unlock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
#else
enable_irq(card->hw.irq);
#endif
}
static int read_connection_info (sdla_t *card)
......
......@@ -95,12 +95,7 @@
#include <asm/atomic.h>
#include <linux/delay.h> /* Experimental delay */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
#include <asm/uaccess.h>
#else
#include <asm/segment.h>
#include <net/route.h>
#endif
#include <asm/uaccess.h>
#include <linux/if.h>
#include <linux/if_arp.h>
......@@ -281,11 +276,7 @@ typedef struct x25_channel
int ch_idx;
unsigned char enable_IPX;
unsigned long network_number;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct net_device_stats ifstats; /* interface statistics */
#else
struct enet_statistics ifstats;
#endif
unsigned short transmit_length;
unsigned short tx_offset;
char transmit_buffer[X25_CHAN_MTU+sizeof(x25api_hdr_t)];
......@@ -369,9 +360,7 @@ static int if_rebuild_hdr (struct sk_buff* skb);
static int if_send (struct sk_buff* skb, netdevice_t* dev);
static struct net_device_stats *if_stats (netdevice_t* dev);
#ifdef LINUX_2_4
static void if_tx_timeout (netdevice_t *dev);
#endif
/*=================================================
* Interrupt handlers
......@@ -792,9 +781,6 @@ int wpx_init (sdla_t* card, wandev_conf_t* conf)
init_global_statistics(card);
#ifndef LINUX_2_4
card->u.x.x25_poll_task.next = NULL;
#endif
card->u.x.x25_poll_task.sync=0;
card->u.x.x25_poll_task.routine = (void*)(void*)wpx_poll;
card->u.x.x25_poll_task.data = card;
......@@ -1011,18 +997,8 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
chan->network_number = 0xDEADBEEF;
/* prepare network device data space for registration */
#ifdef LINUX_2_4
strcpy(dev->name,chan->name);
#else
dev->name = (char *)kmalloc(strlen(chan->name) + 2, GFP_KERNEL);
if(dev->name == NULL)
{
kfree(chan);
dev->priv = NULL;
return -ENOMEM;
}
sprintf(dev->name, "%s", chan->name);
#endif
dev->init = &if_init;
init_x25_channel_struct(chan);
......@@ -1124,9 +1100,6 @@ static int if_init (netdevice_t* dev)
x25_channel_t* chan = dev->priv;
sdla_t* card = chan->card;
wan_device_t* wandev = &card->wandev;
#ifdef LINUX_2_0
int i;
#endif
/* Initialize device driver entry points */
dev->open = &if_open;
......@@ -1135,19 +1108,11 @@ static int if_init (netdevice_t* dev)
dev->rebuild_header = &if_rebuild_hdr;
dev->hard_start_xmit = &if_send;
dev->get_stats = &if_stats;
#ifdef LINUX_2_4
dev->tx_timeout = &if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
/* Initialize media-specific parameters */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
dev->type = ARPHRD_PPP; /* ARP h/w type */
#else
dev->family = AF_INET; /* address family */
dev->type = ARPHRD_PPP; /* no x25 type */
#endif
dev->flags |= IFF_POINTOPOINT;
dev->flags |= IFF_NOARP;
......@@ -1174,11 +1139,6 @@ static int if_init (netdevice_t* dev)
/* Set transmit buffer queue length */
dev->tx_queue_len = 100;
/* Initialize socket buffers */
#if !defined(LINUX_2_1) && !defined(LINUX_2_4)
for (i = 0; i < DEV_NUMBUFFS; ++i)
skb_queue_head_init(&dev->buffs[i]);
#endif
/* FIXME Why are we doing this */
set_chan_state(dev, WAN_DISCONNECTED);
return 0;
......@@ -1214,15 +1174,12 @@ static int if_open (netdevice_t* dev)
struct timeval tv;
unsigned long smp_flags;
if (is_dev_running(dev))
if (netif_running(dev))
return -EBUSY;
chan->tq_working = 0;
/* Initialize the task queue */
#ifndef LINUX_2_4
chan->common.wanpipe_task.next = NULL;
#endif
chan->common.wanpipe_task.sync = 0;
chan->common.wanpipe_task.routine = (void *)(void *)x25api_bh;
chan->common.wanpipe_task.data = dev;
......@@ -1276,13 +1233,8 @@ static int if_open (netdevice_t* dev)
do_gettimeofday( &tv );
chan->router_start_time = tv.tv_sec;
#ifdef LINUX_2_4
netif_start_queue(dev);
#else
dev->interrupt = 0;
dev->tbusy = 0;
dev->start = 1;
#endif
return 0;
}
......@@ -1314,10 +1266,7 @@ static int if_close (netdevice_t* dev)
sdla_t* card = chan->card;
unsigned long smp_flags;
stop_net_queue(dev);
#ifndef LINUX_2_4
dev->start=0;
#endif
netif_stop_queue(dev);
if ((chan->common.state == WAN_CONNECTED) ||
(chan->common.state == WAN_CONNECTING)){
......@@ -1336,7 +1285,7 @@ static int if_close (netdevice_t* dev)
for (i=0; i<(MAX_BH_BUFF+1); i++){
skb = ((bh_data_t *)&chan->bh_head[i])->skb;
if (skb != NULL){
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
}
kfree(chan->bh_head);
......@@ -1405,7 +1354,6 @@ static int if_rebuild_hdr (struct sk_buff* skb)
}
#ifdef LINUX_2_4
/*============================================================================
* Handle transmit timeout event from netif watchdog
*/
......@@ -1425,7 +1373,6 @@ static void if_tx_timeout (netdevice_t *dev)
card->devname, dev->name);
netif_wake_queue (dev);
}
#endif
/*=========================================================================
......@@ -1457,33 +1404,11 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
++chan->if_send_stat.if_send_entry;
#ifdef LINUX_2_4
netif_stop_queue(dev);
#endif
/* No need to check frame length, since socket code
* will perform the check for us */
#ifndef LINUX_2_4
if (dev->tbusy){
netdevice_t *dev2;
++chan->if_send_stat.if_send_tbusy;
if ((jiffies - chan->tick_counter) < (5*HZ)){
return 1;
}
printk(KERN_INFO "%s: Transmit time out %s!\n",
card->devname, dev->name);
for( dev2 = card->wandev.dev; dev2;
dev2 = *((netdevice_t**)dev2->priv)){
dev2->tbusy = 0;
}
++chan->if_send_stat.if_send_tbusy_timeout;
}
#endif
chan->tick_counter = jiffies;
/* Critical region starts here */
......@@ -1506,7 +1431,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
chan->if_send_stat.if_send_PIPE_request++;
}
}
start_net_queue(dev);
netif_start_queue(dev);
clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
S508_S514_unlock(card, &smp_flags);
return 0;
......@@ -1518,7 +1443,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
chan->transmit_length=0;
atomic_set(&chan->common.driver_busy,0);
}else{
stop_net_queue(dev);
netif_stop_queue(dev);
++card->u.x.tx_interrupts_pending;
status->imask |= INTR_ON_TX_FRAME;
clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
......@@ -1589,9 +1514,9 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
if_send_crit_exit:
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
start_net_queue(dev);
netif_start_queue(dev);
clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
S508_S514_unlock(card, &smp_flags);
return 0;
......@@ -1787,14 +1712,12 @@ static void rx_intr (sdla_t* card)
++chan->ifstats.rx_dropped;
++card->wandev.stats.rx_dropped;
++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
return;
}
++chan->ifstats.rx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.rx_bytes += skb->len;
#endif
chan->rx_skb = NULL;
......@@ -1814,7 +1737,7 @@ static void rx_intr (sdla_t* card)
/* Decapsulate packet, if necessary */
if (!skb->protocol && !wanrouter_type_trans(skb, dev)){
/* can't decapsulate packet */
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
++chan->ifstats.rx_errors;
++chan->ifstats.rx_dropped;
++card->wandev.stats.rx_dropped;
......@@ -1829,7 +1752,7 @@ static void rx_intr (sdla_t* card)
if(chan_send(dev, skb->data, skb->len,0)){
chan->tx_skb = skb;
}else{
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
}
}else{
......@@ -1839,9 +1762,7 @@ static void rx_intr (sdla_t* card)
}
}else{
skb->mac.raw = skb->data;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.rx_bytes += skb->len;
#endif
++chan->ifstats.rx_packets;
++chan->rx_intr_stat.rx_intr_bfr_passed_to_stack;
netif_rx(skb);
......@@ -1898,7 +1819,7 @@ static int wanpipe_pull_data_in_skb (sdla_t *card, netdevice_t *dev, struct sk_b
if (skb_tailroom(new_skb) < len){
/* No room for the packet. Call off the whole thing! */
wan_dev_kfree_skb(new_skb, FREE_READ);
dev_kfree_skb_any(new_skb);
if (chan->common.usedby == WANPIPE){
chan->rx_skb = NULL;
if (qdm & 0x01){
......@@ -1985,12 +1906,12 @@ static void tx_intr (sdla_t* card)
chan->transmit_length = 0;
atomic_set(&chan->common.driver_busy,0);
chan->tx_offset=0;
if (is_queue_stopped(dev)){
if (netif_queue_stopped(dev)){
if (chan->common.usedby == API){
start_net_queue(dev);
netif_start_queue(dev);
wakeup_sk_bh(dev);
}else{
wake_net_dev(dev);
netif_wake_queue(dev);
}
}
dev = move_dev_to_next(card,dev);
......@@ -2092,12 +2013,12 @@ static int tx_intr_send(sdla_t *card, netdevice_t *dev)
/* If we are in API mode, wakeup the
* sock BH handler, not the NET_BH */
if (is_queue_stopped(dev)){
if (netif_queue_stopped(dev)){
if (chan->common.usedby == API){
start_net_queue(dev);
netif_start_queue(dev);
wakeup_sk_bh(dev);
}else{
wake_net_dev(dev);
netif_wake_queue(dev);
}
}
return 0;
......@@ -2342,11 +2263,7 @@ static void wpx_poll (sdla_t *card)
static void trigger_x25_poll(sdla_t *card)
{
#ifdef LINUX_2_4
schedule_task(&card->u.x.x25_poll_task);
#else
queue_task(&card->u.x.x25_poll_task, &tq_scheduler);
#endif
}
/*====================================================================
......@@ -3658,8 +3575,8 @@ static void set_chan_state (netdevice_t* dev, int state)
chan->transmit_length=0;
atomic_set(&chan->common.driver_busy,0);
chan->tx_offset=0;
if (is_queue_stopped(dev)){
wake_net_dev(dev);
if (netif_queue_stopped(dev)){
netif_wake_queue(dev);
}
}
atomic_set(&chan->common.command,0);
......@@ -3766,9 +3683,7 @@ static int chan_send (netdevice_t* dev, void* buff, unsigned data_len, unsigned
case 0x00: /* success */
chan->i_timeout_sofar = jiffies;
#ifdef LINUX_2_4
dev->trans_start=jiffies;
#endif
if ((qdm & M_BIT) && !card->u.x.LAPB_hdlc){
if (!tx_intr){
......@@ -3780,9 +3695,7 @@ static int chan_send (netdevice_t* dev, void* buff, unsigned data_len, unsigned
chan->tx_offset += len;
++chan->ifstats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.tx_bytes += len;
#endif
if (chan->tx_offset < orig_len){
setup_for_delayed_transmit (dev, buff, data_len);
......@@ -3795,9 +3708,7 @@ static int chan_send (netdevice_t* dev, void* buff, unsigned data_len, unsigned
* be X number of times larger than max data size.
*/
++chan->ifstats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.tx_bytes += len;
#endif
++chan->if_send_stat.if_send_bfr_passed_to_adptr;
chan->tx_offset += len;
......@@ -3817,9 +3728,7 @@ static int chan_send (netdevice_t* dev, void* buff, unsigned data_len, unsigned
}
}else{
++chan->ifstats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
chan->ifstats.tx_bytes += len;
#endif
++chan->if_send_stat.if_send_bfr_passed_to_adptr;
res=0;
}
......@@ -4288,7 +4197,7 @@ static void x25api_bh (netdevice_t * dev)
if (chan->common.sk == NULL || chan->common.func == NULL){
printk(KERN_INFO "%s: BH: Socket disconnected, dropping\n",
card->devname);
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
x25api_bh_cleanup(dev);
++chan->ifstats.rx_dropped;
++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
......@@ -4745,7 +4654,7 @@ static int api_incoming_call (sdla_t* card, TX25Mbox *mbox, int lcn)
if (card->func(skb,card->sk) < 0){
printk(KERN_INFO "%s: MAJOR ERROR: Failed to send up place call \n",card->devname);
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
return 1;
}
......@@ -4912,7 +4821,7 @@ static void send_oob_msg (sdla_t *card, netdevice_t *dev, TX25Mbox *mbox)
if (chan->common.func(skb,dev,chan->common.sk) < 0){
if (bh_enqueue(dev,skb)){
printk(KERN_INFO "%s: Dropping OOB MSG\n",card->devname);
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
}
......@@ -4940,7 +4849,7 @@ static int alloc_and_init_skb_buf (sdla_t *card, struct sk_buff **skb, int len)
if (skb_tailroom(new_skb) < len){
/* No room for the packet. Call off the whole thing! */
wan_dev_kfree_skb(new_skb, FREE_READ);
dev_kfree_skb_any(new_skb);
printk(KERN_INFO "%s: Listen: unexpectedly long packet sequence\n"
,card->devname);
*skb = NULL;
......@@ -5448,9 +5357,9 @@ static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t* card,
}
if(udp_pkt_src == UDP_PKT_FRM_STACK){
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
}else{
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
}
return(udp_pkt_stored);
......
......@@ -108,16 +108,8 @@
#define _OUTB(port, byte) (outb((byte),(port)))
#define SYSTEM_TICK jiffies
#include <linux/init.h>
#if defined(LINUX_2_1) || defined(LINUX_2_4)
#include <linux/init.h>
#else
#include <linux/bios32.h>/* BIOS32, PCI BIOS functions and definitions */
#define ioremap vremap
#define iounmap vfree
extern void * vremap (unsigned long offset, unsigned long size);
extern void vfree (void *addr);
#endif
#elif defined(_SCO_UNIX_) /****** SCO Unix ****************************/
......@@ -381,9 +373,7 @@ void cleanup_module (void)
* < 0 error
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_setup);
#endif
int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len)
{
......@@ -528,9 +518,7 @@ int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len)
* Shut down SDLA: disable shared memory access and interrupts, stop CPU, etc.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_down);
#endif
int sdla_down (sdlahw_t* hw)
{
......@@ -572,7 +560,6 @@ int sdla_down (sdlahw_t* hw)
*(char *)hw->vector = S514_CPU_HALT;
CPU_no = hw->S514_cpu_no[0];
#if defined(LINUX_2_1) || defined(LINUX_2_4)
/* disable the PCI IRQ and disable memory access */
pci_read_config_dword(hw->pci_dev, PCI_INT_CONFIG, &int_config);
int_config &= (CPU_no == S514_CPU_A) ? ~PCI_DISABLE_IRQ_CPU_A : ~PCI_DISABLE_IRQ_CPU_B;
......@@ -585,22 +572,6 @@ int sdla_down (sdlahw_t* hw)
else
pci_write_config_dword(hw->pci_dev, PCI_MAP1_DWORD,
PCI_CPU_B_MEM_DISABLE);
#else
/* disable the PCI IRQ and disable memory access */
pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func,
PCI_INT_CONFIG, &int_config);
int_config &= (CPU_no == S514_CPU_A) ? ~PCI_DISABLE_IRQ_CPU_A : ~PCI_DISABLE_IRQ_CPU_B;
pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func,
PCI_INT_CONFIG, int_config);
read_S514_int_stat(hw, &int_status);
S514_intack(hw, int_status);
// disable PCI memory access
if(CPU_no == S514_CPU_A)
pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func,
PCI_MAP0_DWORD, PCI_CPU_A_MEM_DISABLE);
else
pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func, PCI_MAP1_DWORD, PCI_CPU_B_MEM_DISABLE);
#endif
/* free up the allocated virtual memory */
iounmap((void *)hw->dpmbase);
......@@ -618,9 +589,7 @@ int sdla_down (sdlahw_t* hw)
* Map shared memory window into SDLA address space.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_mapmem);
#endif
int sdla_mapmem (sdlahw_t* hw, unsigned long addr)
{
......@@ -681,9 +650,7 @@ int sdla_mapmem (sdlahw_t* hw, unsigned long addr)
* Enable interrupt generation.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_inten);
#endif
int sdla_inten (sdlahw_t* hw)
{
......@@ -739,9 +706,7 @@ int sdla_inten (sdlahw_t* hw)
* Disable interrupt generation.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_intde);
#endif
int sdla_intde (sdlahw_t* hw)
{
......@@ -796,9 +761,7 @@ int sdla_intde (sdlahw_t* hw)
* Acknowledge SDLA hardware interrupt.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_intack);
#endif
int sdla_intack (sdlahw_t* hw)
{
......@@ -848,18 +811,11 @@ int sdla_intack (sdlahw_t* hw)
* Acknowledge S514 hardware interrupt.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(S514_intack);
#endif
void S514_intack (sdlahw_t* hw, u32 int_status)
{
#if defined(LINUX_2_1) || defined(LINUX_2_4)
pci_write_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status);
#else
pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func,
PCI_INT_STATUS, int_status);
#endif
}
......@@ -867,18 +823,11 @@ void S514_intack (sdlahw_t* hw, u32 int_status)
* Read the S514 hardware interrupt status.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(read_S514_int_stat);
#endif
void read_S514_int_stat (sdlahw_t* hw, u32* int_status)
{
#if defined(LINUX_2_1) || defined(LINUX_2_4)
pci_read_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status);
#else
pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_STATUS,
int_status);
#endif
}
......@@ -886,9 +835,7 @@ void read_S514_int_stat (sdlahw_t* hw, u32* int_status)
* Generate an interrupt to adapter's CPU.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_intr);
#endif
int sdla_intr (sdlahw_t* hw)
{
......@@ -932,9 +879,7 @@ int sdla_intr (sdlahw_t* hw)
* o Return number of loops made, or 0 if command timed out.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_exec);
#endif
int sdla_exec (void* opflag)
{
......@@ -970,9 +915,7 @@ int sdla_exec (void* opflag)
* interrupt routines are accessing adapter shared memory.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_peek);
#endif
int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len)
{
......@@ -1054,9 +997,7 @@ static void peek_by_4 (unsigned long src, void* buf, unsigned len)
* interrupt routines are accessing adapter shared memory.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(sdla_poke);
#endif
int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len)
{
......@@ -1961,20 +1902,11 @@ static int detect_s514 (sdlahw_t* hw)
int number_S514_cards = 0;
u32 S514_mem_base_addr = 0;
u32 ut_u32;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct pci_dev *pci_dev;
#else
u8 ut_u8;
#endif
#ifdef CONFIG_PCI
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(!pci_present())
#else
if(!pcibios_present())
#endif
{
printk(KERN_INFO "%s: PCI BIOS not present!\n", modname);
return 0;
......@@ -2029,26 +1961,12 @@ static int detect_s514 (sdlahw_t* hw)
}
}
#if defined(LINUX_2_4)
pci_dev = hw->pci_dev;
/* read the physical memory base address */
S514_mem_base_addr = (CPU_no == S514_CPU_A) ?
(pci_dev->resource[1].start) :
(pci_dev->resource[2].start);
#elif defined (LINUX_2_1)
pci_dev = hw->pci_dev;
/* read the physical memory base address */
S514_mem_base_addr = (CPU_no == S514_CPU_A) ?
(pci_dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK) :
(pci_dev->base_address[2] & PCI_BASE_ADDRESS_MEM_MASK);
#else
pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func,
(CPU_no == S514_CPU_A) ? PCI_MEM_BASE0_DWORD :
PCI_MEM_BASE1_DWORD, &S514_mem_base_addr);
#endif
printk(KERN_INFO "%s: S514 PCI memory at 0x%X\n",
modname, S514_mem_base_addr);
if(!S514_mem_base_addr) {
......@@ -2060,24 +1978,14 @@ static int detect_s514 (sdlahw_t* hw)
}
/* enable the PCI memory */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
pci_read_config_dword(pci_dev,
(CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
&ut_u32);
pci_write_config_dword(pci_dev,
(CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
(ut_u32 | PCI_MEMORY_ENABLE));
#else
pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func,
(CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
&ut_u32);
pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func,
(CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
(ut_u32 | PCI_MEMORY_ENABLE));
#endif
/* check the IRQ allocated and enable IRQ usage */
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(!(hw->irq = pci_dev->irq)) {
printk(KERN_INFO "%s: IRQ not allocated to S514 adapter\n",
modname);
......@@ -2099,29 +2007,6 @@ static int detect_s514 (sdlahw_t* hw)
ut_u32 |= (CPU_no == S514_CPU_A) ?
PCI_ENABLE_IRQ_CPU_A : PCI_ENABLE_IRQ_CPU_B;
pci_write_config_dword(pci_dev, PCI_INT_CONFIG, ut_u32);
#else
/* the INTPIN must not be 0 - if it is, then the S514 adapter is not */
/* configured for IRQ usage */
pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func,
PCI_INT_PIN_BYTE, &ut_u8);
if(!ut_u8) {
printk(KERN_INFO "%s: invalid setting for INTPIN on S514 card\n", modname);
printk(KERN_INFO "Please contact your Sangoma representative\n");
return 0;
}
pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func,
PCI_INT_LINE_BYTE, (unsigned char *)&hw->irq);
if(hw->irq == PCI_IRQ_NOT_ALLOCATED) {
printk(KERN_INFO "%s: IRQ not allocated to S514 adapter\n",
modname);
return 0;
}
pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_CONFIG, &ut_u32);
ut_u32 |= (CPU_no == S514_CPU_A) ?
PCI_ENABLE_IRQ_CPU_A : PCI_ENABLE_IRQ_CPU_B;
pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func,
PCI_INT_CONFIG, ut_u32);
#endif
printk(KERN_INFO "%s: IRQ %d allocated to the S514 card\n",
modname, hw->irq);
......@@ -2157,15 +2042,10 @@ static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card)
char S514_found_in_slot = 0;
u16 PCI_subsys_vendor;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct pci_dev *pci_dev = NULL;
#else
int pci_index;
#endif
slot_no = hw->S514_slot_no;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev))
!= NULL) {
......@@ -2197,40 +2077,6 @@ static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card)
}
}
#else
//LINUX VERSION 2.0.X
for (pci_index = 0; pci_index < MAX_S514_CARDS; pci_index ++) {
if (pcibios_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_index,
&hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) {
break;
}
pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func,
PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor);
if (PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR)
continue;
if (find_first_S514_card)
return(1);
number_S514_cards ++;
printk(KERN_INFO "%s: S514 card found, bus #%d, slot #%d\n",
modname, hw->pci_bus,
((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK));
if (hw->auto_pci_cfg){
hw->S514_slot_no = ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK)
slot_no = hw->S514_slot_no;
}else if (((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK) == slot_no) {
S514_found_in_slot = 1;
break;
}
}
#endif
/* if no S514 adapter has been found, then exit */
if (!number_S514_cards) {
printk(KERN_INFO "%s: Error, no S514 adapters found\n", modname);
......@@ -2408,17 +2254,11 @@ static int pci_probe(sdlahw_t *hw)
u16 PCI_subsys_vendor;
u16 PCI_card_type;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
struct pci_dev *pci_dev = NULL;
struct pci_bus *bus = NULL;
#else
int pci_index;
u8 irq;
#endif
slot_no = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev))
!= NULL) {
......@@ -2453,52 +2293,13 @@ static int pci_probe(sdlahw_t *hw)
}
}
#else
for (pci_index = 0; pci_index < MAX_S514_CARDS; pci_index ++) {
if(pcibios_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_index,
&hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) {
break;
}
pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func,
PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor);
if(PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR)
continue;
pcibios_read_config_word(hw->pci_bus,hw->pci_dev_func,PCI_CARD_TYPE,
&PCI_card_type);
pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func,
PCI_INT_LINE_BYTE, &irq);
/* A dual cpu card can support up to 4 physical connections,
* where a single cpu card can support up to 2 physical
* connections. The FT1 card can only support a single
* connection, however we cannot distinguish between a Single
* CPU card and an FT1 card. */
if (PCI_card_type == S514_DUAL_CPU){
number_S514_cards += 4;
printk(KERN_INFO "%s: S514-PCI card found, cpu(s) 2, bus #%d, slot #%d, irq #%d\n",
modname, hw->pci_bus,
((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq);
}else{
printk(KERN_INFO "%s: S514-PCI card found, cpu(s) 1, bus #%d, slot #%d, irq #%d\n",
modname, hw->pci_bus,
((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq);
number_S514_cards += 2;
}
}
#endif
return number_S514_cards;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
EXPORT_SYMBOL(wanpipe_hw_probe);
#endif
unsigned wanpipe_hw_probe(void)
{
......
......@@ -64,26 +64,10 @@
#include <linux/sdlapci.h>
#include <linux/if_wanpipe_common.h>
#if defined(LINUX_2_4)
#define netdevice_t struct net_device
#include <asm/uaccess.h> /* kernel <-> user copy */
#include <linux/inetdevice.h>
#define netdevice_t struct net_device
#elif defined(LINUX_2_1)
#include <asm/uaccess.h> /* kernel <-> user copy */
#include <linux/inetdevice.h>
#define netdevice_t struct device
#else
#include <asm/segment.h>
#define devinet_ioctl(x,y) dev_ioctl(x,y)
#define netdevice_t struct device
#define test_and_set_bit set_bit
typedef unsigned long mm_segment_t;
#endif
#include <asm/uaccess.h> /* kernel <-> user copy */
#include <linux/inetdevice.h>
#include <linux/ip.h>
#include <net/route.h>
......@@ -240,23 +224,12 @@ static sdla_t* card_array = NULL; /* adapter data space */
* function, which will execute all pending,
* tasks in wanpipe_tq_custom queue */
#ifdef LINUX_2_4
DECLARE_TASK_QUEUE(wanpipe_tq_custom);
static struct tq_struct wanpipe_tq_task =
{
.routine = (void (*)(void *)) run_wanpipe_tq,
.data = &wanpipe_tq_custom
};
#else
static struct tq_struct *wanpipe_tq_custom = NULL;
static struct tq_struct wanpipe_tq_task =
{
NULL,
0,
(void *)(void *) run_wanpipe_tq,
&wanpipe_tq_custom
};
#endif
static int wanpipe_bh_critical=0;
......@@ -511,9 +484,7 @@ static int setup (wan_device_t* wandev, wandev_conf_t* conf)
if (!card->configured){
/* Initialize the Spin lock */
#if defined(__SMP__) || defined(LINUX_2_4)
printk(KERN_INFO "%s: Initializing for SMP\n",wandev->name);
#endif
/* Piggyback spin lock has already been initialized,
* in check_s514/s508_conflicts() */
......@@ -974,26 +945,13 @@ static int ioctl_dump (sdla_t* card, sdla_dump_t* u_dump)
unsigned long smp_flags;
int err = 0;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(copy_from_user((void*)&dump, (void*)u_dump, sizeof(sdla_dump_t)))
return -EFAULT;
#else
if ((u_dump == NULL) ||
verify_area(VERIFY_READ, u_dump, sizeof(sdla_dump_t)))
return -EFAULT;
memcpy_fromfs((void*)&dump, (void*)u_dump, sizeof(sdla_dump_t));
#endif
if ((dump.magic != WANPIPE_MAGIC) ||
(dump.offset + dump.length > card->hw.memory))
return -EINVAL;
#ifdef LINUX_2_0
if ((dump.ptr == NULL) ||
verify_area(VERIFY_WRITE, dump.ptr, dump.length))
return -EFAULT;
#endif
winsize = card->hw.dpmsize;
if(card->hw.type != SDLA_S514) {
......@@ -1014,17 +972,13 @@ static int ioctl_dump (sdla_t* card, sdla_dump_t* u_dump)
break;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(copy_to_user((void *)dump.ptr,
(u8 *)card->hw.dpmbase + pos, len)){
unlock_adapter_irq(&card->wandev.lock, &smp_flags);
return -EFAULT;
}
#else
memcpy_tofs((void*)(dump.ptr),
(void*)(card->hw.dpmbase + pos), len);
#endif
dump.length -= len;
dump.offset += len;
(char*)dump.ptr += len;
......@@ -1035,15 +989,10 @@ static int ioctl_dump (sdla_t* card, sdla_dump_t* u_dump)
}else {
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(copy_to_user((void *)dump.ptr,
(u8 *)card->hw.dpmbase + dump.offset, dump.length)){
return -EFAULT;
}
#else
memcpy_tofs((void*)(dump.ptr),
(void*)(card->hw.dpmbase + dump.offset), dump.length);
#endif
}
return err;
......@@ -1064,15 +1013,8 @@ static int ioctl_exec (sdla_t* card, sdla_exec_t* u_exec, int cmd)
return -ENODEV;
}
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if(copy_from_user((void*)&exec, (void*)u_exec, sizeof(sdla_exec_t)))
return -EFAULT;
#else
if ((u_exec == NULL) ||
verify_area(VERIFY_READ, u_exec, sizeof(sdla_exec_t)))
return -EFAULT;
memcpy_fromfs((void*)&exec, (void*)u_exec, sizeof(sdla_exec_t));
#endif
if ((exec.magic != WANPIPE_MAGIC) || (exec.cmd == NULL))
return -EINVAL;
......@@ -1345,60 +1287,33 @@ int change_dev_flags (netdevice_t *dev, unsigned flags)
unsigned long get_ip_address (netdevice_t *dev, int option)
{
#ifdef LINUX_2_4
struct in_ifaddr *ifaddr;
struct in_device *in_dev;
if ((in_dev = __in_dev_get(dev)) == NULL){
return 0;
}
#elif defined(LINUX_2_1)
struct in_ifaddr *ifaddr;
struct in_device *in_dev;
if ((in_dev = dev->ip_ptr) == NULL){
return 0;
}
#endif
#if defined(LINUX_2_1) || defined(LINUX_2_4)
if ((ifaddr = in_dev->ifa_list)== NULL ){
return 0;
}
#endif
switch (option){
case WAN_LOCAL_IP:
#ifdef LINUX_2_0
return dev->pa_addr;
#else
return ifaddr->ifa_local;
#endif
break;
case WAN_POINTOPOINT_IP:
#ifdef LINUX_2_0
return dev->pa_dstaddr;
#else
return ifaddr->ifa_address;
#endif
break;
case WAN_NETMASK_IP:
#ifdef LINUX_2_0
return dev->pa_mask;
#else
return ifaddr->ifa_mask;
#endif
break;
case WAN_BROADCAST_IP:
#ifdef LINUX_2_0
return dev->pa_brdaddr;
#else
return ifaddr->ifa_broadcast;
#endif
break;
default:
return 0;
......@@ -1431,11 +1346,7 @@ void add_gateway(sdla_t *card, netdevice_t *dev)
oldfs = get_fs();
set_fs(get_ds());
#if defined(LINUX_2_1) || defined(LINUX_2_4)
res = ip_rt_ioctl(SIOCADDRT,&route);
#else
res = ip_rt_new(&route);
#endif
set_fs(oldfs);
if (res == 0){
......
......@@ -42,19 +42,11 @@
#include <linux/if_wanpipe.h>
#if defined(LINUX_2_1) || defined(LINUX_2_4)
#include <linux/inetdevice.h>
#include <asm/uaccess.h>
#include <linux/inetdevice.h>
#include <asm/uaccess.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
#include <net/syncppp.h>
#else
#include "syncppp.h"
#endif
#include <net/syncppp.h>
#else
#include <net/route.h> /* Adding new route entries */
#endif
/****** Defines & Macros ****************************************************/
......@@ -148,15 +140,9 @@ static int if_init (netdevice_t* dev);
static int if_open (netdevice_t* dev);
static int if_close (netdevice_t* dev);
static int if_send (struct sk_buff* skb, netdevice_t* dev);
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats* if_stats (netdevice_t* dev);
#else
static struct enet_statistics* if_stats (netdevice_t* dev);
#endif
#ifdef LINUX_2_4
static void if_tx_timeout (netdevice_t *dev);
#endif
/* CHDLC Firmware interface functions */
static int chdlc_configure (sdla_t* card, void* data);
......@@ -601,17 +587,7 @@ static int new_if (wan_device_t* wandev, netdevice_t* pdev, wanif_conf_t* conf)
/* prepare network device data space for registration */
#ifdef LINUX_2_4
strcpy(dev->name,card->u.c.if_name);
#else
dev->name = (char *)kmalloc(strlen(card->u.c.if_name) + 2, GFP_KERNEL);
if(dev->name == NULL)
{
kfree(chdlc_priv_area);
return -ENOMEM;
}
sprintf(dev->name, "%s", card->u.c.if_name);
#endif
/* Attach PPP protocol layer to pppdev
* The sppp_attach() will initilize the dev structure
......@@ -620,11 +596,7 @@ static int new_if (wan_device_t* wandev, netdevice_t* pdev, wanif_conf_t* conf)
* if_open(), if_close(), if_send() and get_stats() functions.
*/
sppp_attach(pppdev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,16)
dev = pppdev->dev;
#else
dev = &pppdev->dev;
#endif
sp = &pppdev->sppp;
/* Enable PPP Debugging */
......@@ -684,9 +656,6 @@ static int if_init (netdevice_t* dev)
chdlc_private_area_t* chdlc_priv_area = dev->priv;
sdla_t* card = chdlc_priv_area->card;
wan_device_t* wandev = &card->wandev;
#ifdef LINUX_2_0
int i;
#endif
/* NOTE: Most of the dev initialization was
* done in sppp_attach(), called by new_if()
......@@ -699,16 +668,10 @@ static int if_init (netdevice_t* dev)
dev->stop = &if_close;
dev->hard_start_xmit = &if_send;
dev->get_stats = &if_stats;
#ifdef LINUX_2_4
dev->tx_timeout = &if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#endif
#ifdef LINUX_2_0
dev->family = AF_INET;
#endif
/* Initialize hardware parameters */
dev->irq = wandev->irq;
dev->dma = wandev->dma;
......@@ -724,17 +687,10 @@ static int if_init (netdevice_t* dev)
*/
dev->tx_queue_len = 100;
/* Initialize socket buffers */
#if !defined(LINUX_2_1) && !defined(LINUX_2_4)
for (i = 0; i < DEV_NUMBUFFS; ++i)
skb_queue_head_init(&dev->buffs[i]);
#endif
return 0;
}
#ifdef LINUX_2_4
/*============================================================================
* Handle transmit timeout event from netif watchdog
*/
......@@ -754,8 +710,6 @@ static void if_tx_timeout (netdevice_t *dev)
printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name);
netif_wake_queue (dev);
}
#endif
/*============================================================================
......@@ -773,14 +727,8 @@ static int if_open (netdevice_t* dev)
SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
/* Only one open per interface is allowed */
#ifdef LINUX_2_4
if (netif_running(dev))
return -EBUSY;
#else
if (dev->start)
return -EBUSY; /* only one open is allowed */
#endif
/* Start PPP Layer */
if (sppp_open(dev)){
......@@ -790,13 +738,7 @@ static int if_open (netdevice_t* dev)
do_gettimeofday(&tv);
chdlc_priv_area->router_start_time = tv.tv_sec;
#ifdef LINUX_2_4
netif_start_queue(dev);
#else
dev->interrupt = 0;
dev->tbusy = 0;
dev->start = 1;
#endif
wanpipe_open(card);
......@@ -817,11 +759,7 @@ static int if_close (netdevice_t* dev)
/* Stop the PPP Layer */
sppp_close(dev);
stop_net_queue(dev);
#ifndef LINUX_2_4
dev->start=0;
#endif
netif_stop_queue(dev);
wanpipe_close(card);
......@@ -855,9 +793,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
unsigned long smp_flags;
int err=0;
#ifdef LINUX_2_4
netif_stop_queue(dev);
#endif
if (skb == NULL){
......@@ -867,32 +803,10 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
printk(KERN_INFO "%s: Received NULL skb buffer! interface %s got kicked!\n",
card->devname, dev->name);
wake_net_dev(dev);
netif_wake_queue(dev);
return 0;
}
#ifndef LINUX_2_4
if (dev->tbusy){
/* If our device stays busy for at least 5 seconds then we will
* kick start the device by making dev->tbusy = 0. We expect
* that our device never stays busy more than 5 seconds. So this
* is only used as a last resort.
*/
++card->wandev.stats.collisions;
if((jiffies - chdlc_priv_area->tick_counter) < (5 * HZ)) {
return 1;
}
printk (KERN_INFO "%s: Transmit (tbusy) timeout !\n",
card->devname);
/* unbusy the interface */
dev->tbusy = 0;
}
#endif
if (ntohs(skb->protocol) != htons(PVC_PROT)){
/* check the udp packet type */
......@@ -903,7 +817,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
chdlc_int->interrupt_permission |=
APP_INT_ON_TIMER;
}
start_net_queue(dev);
netif_start_queue(dev);
return 0;
}
}
......@@ -918,33 +832,29 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev)
printk(KERN_INFO "%s: Critical in if_send: %lx\n",
card->wandev.name,card->wandev.critical);
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_crit_exit;
}
if (card->wandev.state != WAN_CONNECTED){
++card->wandev.stats.tx_dropped;
start_net_queue(dev);
netif_start_queue(dev);
goto if_send_crit_exit;
}
if (chdlc_send(card, skb->data, skb->len)){
stop_net_queue(dev);
netif_stop_queue(dev);
}else{
++card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.tx_bytes += skb->len;
#endif
#ifdef LINUX_2_4
dev->trans_start = jiffies;
#endif
start_net_queue(dev);
netif_start_queue(dev);
}
if_send_crit_exit:
if (!(err=is_queue_stopped(dev))){
wan_dev_kfree_skb(skb, FREE_WRITE);
if (!(err=netif_queue_stopped(dev))){
dev_kfree_skb_any(skb);
}else{
chdlc_priv_area->tick_counter = jiffies;
chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME;
......@@ -1063,7 +973,6 @@ unsigned short calc_checksum (char *data, int len)
* Get ethernet-style interface statistics.
* Return a pointer to struct enet_statistics.
*/
#if defined(LINUX_2_1) || defined(LINUX_2_4)
static struct net_device_stats* if_stats (netdevice_t* dev)
{
sdla_t *my_card;
......@@ -1079,23 +988,7 @@ static struct net_device_stats* if_stats (netdevice_t* dev)
my_card = chdlc_priv_area->card;
return &my_card->wandev.stats;
}
#else
static struct enet_statistics* if_stats (netdevice_t* dev)
{
sdla_t *my_card;
chdlc_private_area_t* chdlc_priv_area = dev->priv;
/* Shutdown bug fix. In del_if() we kill
* dev->priv pointer. This function, gets
* called after del_if(), thus check
* if pointer has been deleted */
if ((chdlc_priv_area=dev->priv) == NULL)
return NULL;
my_card = chdlc_priv_area->card;
return &my_card->wandev.stats;
}
#endif
/****** Cisco HDLC Firmware Interface Functions *******************************/
......@@ -1417,7 +1310,7 @@ STATIC void wsppp_isr (sdla_t* card)
flags->interrupt_info_struct.interrupt_permission &=
~APP_INT_ON_TX_FRAME;
wake_net_dev(dev);
netif_wake_queue(dev);
break;
case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */
......@@ -1505,15 +1398,9 @@ static void rx_intr (sdla_t* card)
goto rx_exit;
}
#ifdef LINUX_2_4
if (!netif_running(dev)){
goto rx_exit;
}
#else
if (!dev->start){
goto rx_exit;
}
#endif
chdlc_priv_area = dev->priv;
......@@ -1555,9 +1442,7 @@ static void rx_intr (sdla_t* card)
skb->protocol = htons(ETH_P_WAN_PPP);
card->wandev.stats.rx_packets ++;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.rx_bytes += skb->len;
#endif
udp_type = udp_pkt_type( skb, card );
if(udp_type == UDP_CPIPE_TYPE) {
......@@ -1795,9 +1680,9 @@ static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
}
if(udp_pkt_src == UDP_PKT_FRM_STACK)
wan_dev_kfree_skb(skb, FREE_WRITE);
dev_kfree_skb_any(skb);
else
wan_dev_kfree_skb(skb, FREE_READ);
dev_kfree_skb_any(skb);
return(udp_pkt_stored);
}
......@@ -2156,9 +2041,7 @@ static int process_udp_mgmt_pkt(sdla_t* card, netdevice_t* dev,
if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) {
if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) {
++ card->wandev.stats.tx_packets;
#if defined(LINUX_2_1) || defined(LINUX_2_4)
card->wandev.stats.tx_bytes += len;
#endif
}
} else {
......@@ -2360,28 +2243,20 @@ static void port_set_state (sdla_t *card, int state)
void s508_lock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
spin_lock_irqsave(&card->wandev.lock, *smp_flags);
if (card->next){
/* It is ok to use spin_lock here, since we
* already turned off interrupts */
spin_lock(&card->next->wandev.lock);
}
#else
disable_irq(card->hw.irq);
#endif
}
void s508_unlock (sdla_t *card, unsigned long *smp_flags)
{
#if defined(__SMP__) || defined(LINUX_2_4)
if (card->next){
spin_unlock(&card->next->wandev.lock);
}
spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
#else
enable_irq(card->hw.irq);
#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