/****************************************************************************
* sdlamain.c WANPIPE(tm) Multiprotocol WAN Link Driver. Main module.
*
* Author: Nenad Corbic <ncorbic@sangoma.com>
* Gideon Hack
*
* Copyright: (c) 1995-2000 Sangoma Technologies Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
* ============================================================================
* Dec 22, 2000 Nenad Corbic Updated for 2.4.X kernels.
* Removed the polling routine.
* Nov 13, 2000 Nenad Corbic Added hw probing on module load and dynamic
* device allocation.
* Nov 7, 2000 Nenad Corbic Fixed the Multi-Port PPP for kernels
* 2.2.16 and above.
* Aug 2, 2000 Nenad Corbic Block the Multi-Port PPP from running on
* kernels 2.2.16 or greater. The SyncPPP
* has changed.
* Jul 25, 2000 Nenad Corbic Updated the Piggiback support for MultPPPP.
* Jul 13, 2000 Nenad Corbic Added Multi-PPP support.
* Feb 02, 2000 Nenad Corbic Fixed up piggyback probing and selection.
* Sep 23, 1999 Nenad Corbic Added support for SMP
* Sep 13, 1999 Nenad Corbic Each port is treated as a separate device.
* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
* Updates for Linux 2.2.X kernels.
* Sep 17, 1998 Jaspreet Singh Updated for 2.1.121+ kernel
* Nov 28, 1997 Jaspreet Singh Changed DRV_RELEASE to 1
* Nov 10, 1997 Jaspreet Singh Changed sti() to restore_flags();
* Nov 06, 1997 Jaspreet Singh Changed DRV_VERSION to 4 and DRV_RELEASE to 0
* Oct 20, 1997 Jaspreet Singh Modified sdla_isr routine so that card->in_isr
* assignments are taken out and placed in the
* sdla_ppp.c, sdla_fr.c and sdla_x25.c isr
* routines. Took out 'wandev->tx_int_enabled' and
* replaced it with 'wandev->enable_tx_int'.
* May 29, 1997 Jaspreet Singh Flow Control Problem
* added "wandev->tx_int_enabled=1" line in the
* init module. This line initializes the flag for
* preventing Interrupt disabled with device set to
* busy
* Jan 15, 1997 Gene Kozin Version 3.1.0
* o added UDP management stuff
* Jan 02, 1997 Gene Kozin Initial version.
*****************************************************************************/
#include <linux/config.h> /* OS configuration options */
#include <linux/stddef.h> /* offsetof(), etc. */
#include <linux/errno.h> /* return codes */
#include <linux/string.h> /* inline memset(), etc. */
#include <linux/init.h>
#include <linux/slab.h> /* kmalloc(), kfree() */
#include <linux/kernel.h> /* printk(), and other useful stuff */
#include <linux/module.h> /* support for loadable modules */
#include <linux/ioport.h> /* request_region(), release_region() */
#include <linux/wanrouter.h> /* WAN router definitions */
#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
#include <linux/rcupdate.h>
#include <linux/in.h>
#include <asm/io.h> /* phys_to_virt() */
#include <linux/pci.h>
#include <linux/sdlapci.h>
#include <linux/if_wanpipe_common.h>
#include <asm/uaccess.h> /* kernel <-> user copy */
#include <linux/inetdevice.h>
#include <linux/ip.h>
#include <net/route.h>
#define KMEM_SAFETYZONE 8
#ifndef CONFIG_WANPIPE_FR
#define wpf_init(a,b) (-EPROTONOSUPPORT)
#endif
#ifndef CONFIG_WANPIPE_CHDLC
#define wpc_init(a,b) (-EPROTONOSUPPORT)
#endif
#ifndef CONFIG_WANPIPE_X25
#define wpx_init(a,b) (-EPROTONOSUPPORT)
#endif
#ifndef CONFIG_WANPIPE_PPP
#define wpp_init(a,b) (-EPROTONOSUPPORT)
#endif
#ifndef CONFIG_WANPIPE_MULTPPP
#define wsppp_init(a,b) (-EPROTONOSUPPORT)
#endif
/***********FOR DEBUGGING PURPOSES*********************************************
static void * dbg_kmalloc(unsigned int size, int prio, int line) {
int i = 0;
void * v = kmalloc(size+sizeof(unsigned int)+2*KMEM_SAFETYZONE*8,prio);
char * c1 = v;
c1 += sizeof(unsigned int);
*((unsigned int *)v) = size;
for (i = 0; i < KMEM_SAFETYZONE; i++) {
c1[0] = 'D'; c1[1] = 'E'; c1[2] = 'A'; c1[3] = 'D';
c1[4] = 'B'; c1[5] = 'E'; c1[6] = 'E'; c1[7] = 'F';
c1 += 8;
}
c1 += size;
for (i = 0; i < KMEM_SAFETYZONE; i++) {
c1[0] = 'M'; c1[1] = 'U'; c1[2] = 'N'; c1[3] = 'G';
c1[4] = 'W'; c1[5] = 'A'; c1[6] = 'L'; c1[7] = 'L';
c1 += 8;
}
v = ((char *)v) + sizeof(unsigned int) + KMEM_SAFETYZONE*8;
printk(KERN_INFO "line %d kmalloc(%d,%d) = %p\n",line,size,prio,v);
return v;
}
static void dbg_kfree(void * v, int line) {
unsigned int * sp = (unsigned int *)(((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8));
unsigned int size = *sp;
char * c1 = ((char *)v) - KMEM_SAFETYZONE*8;
int i = 0;
for (i = 0; i < KMEM_SAFETYZONE; i++) {
if ( c1[0] != 'D' || c1[1] != 'E' || c1[2] != 'A' || c1[3] != 'D'
|| c1[4] != 'B' || c1[5] != 'E' || c1[6] != 'E' || c1[7] != 'F') {
printk(KERN_INFO "kmalloced block at %p has been corrupted (underrun)!\n",v);
printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
}
c1 += 8;
}
c1 += size;
for (i = 0; i < KMEM_SAFETYZONE; i++) {
if ( c1[0] != 'M' || c1[1] != 'U' || c1[2] != 'N' || c1[3] != 'G'
|| c1[4] !=