mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-17 14:30:00 +00:00
Merge branch 'delete-wanrouter' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
Paul Gortmaker says: ==================== The removal of wanrouter code was originally listed in the (now gone) feature removal file since May 2012, and an RFC of the deletion was posted[1] in late 2012. The overall concept was given an OK, but defconfig contamination, build failures, etc. meant that it didn't quite make it into mainline for 3.8. Since that time, Dan discovered (via code audit) a runtime bug that proves nobody has been using this for over four years[2]. With that new information, I think it makes sense for someone to follow through on Joe's original RFC and get this done for the 3.9 release. In addition to resolving the build failures of the RFC by keeping stub headers, this also splits the change into two parts, just like the token ring removal did. Part #1 decouples the mainline kernel from the expired subsystem, and part #2 does the large scale deletion of the subsystem content. The advantage of the above, is that a "git blame" will never lead you to a 4000+ line deletion commit. The large scale deletion will never show up in a "git blame" and hence the same advantages that we get from the "--irreversible-delete" in the review stage of "git format-patch" are also embedded into the git history itself. This may seem like a moot point to some, but for those who spend a considerable amount of time data mining in the git history, this is probably worth doing. I have done build tests of all[mod/yes]config for both the stage 1 (Makefile and Kconfig) and stage 2 (full driver delete) as a sanity check, and the issues with the previously posted RFC should be gone. Speaking of "--irreversible-delete" -- these patches were created with that option, so if you want to use them locally, you are going to have to pull (location below) the content instead of doing a "git am" of the mailed out content. [1] http://patchwork.ozlabs.org/patch/198794/ [2] http://www.spinics.net/lists/netdev/msg218670.html ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
33397a7121
@ -179,7 +179,7 @@ Code Seq#(hex) Include File Comments
|
||||
'V' C0 media/davinci/vpfe_capture.h conflict!
|
||||
'V' C0 media/si4713.h conflict!
|
||||
'W' 00-1F linux/watchdog.h conflict!
|
||||
'W' 00-1F linux/wanrouter.h conflict!
|
||||
'W' 00-1F linux/wanrouter.h conflict! (pre 3.9)
|
||||
'W' 00-3F sound/asound.h conflict!
|
||||
'X' all fs/xfs/xfs_fs.h conflict!
|
||||
and fs/xfs/linux-2.6/xfs_ioctl32.h
|
||||
|
@ -122,7 +122,7 @@ SLAB_C_MAGIC 0x4f17a36d kmem_cache mm/slab.c
|
||||
COW_MAGIC 0x4f4f4f4d cow_header_v1 arch/um/drivers/ubd_user.c
|
||||
I810_CARD_MAGIC 0x5072696E i810_card sound/oss/i810_audio.c
|
||||
TRIDENT_CARD_MAGIC 0x5072696E trident_card sound/oss/trident.c
|
||||
ROUTER_MAGIC 0x524d4157 wan_device include/linux/wanrouter.h
|
||||
ROUTER_MAGIC 0x524d4157 wan_device [in wanrouter.h pre 3.9]
|
||||
SCC_MAGIC 0x52696368 gs_port drivers/char/scc.h
|
||||
SAVEKMSG_MAGIC1 0x53415645 savekmsg arch/*/amiga/config.c
|
||||
GDA_MAGIC 0x58464552 gda arch/mips/include/asm/sn/gda.h
|
||||
|
@ -122,7 +122,7 @@ SLAB_C_MAGIC 0x4f17a36d kmem_cache mm/slab.c
|
||||
COW_MAGIC 0x4f4f4f4d cow_header_v1 arch/um/drivers/ubd_user.c
|
||||
I810_CARD_MAGIC 0x5072696E i810_card sound/oss/i810_audio.c
|
||||
TRIDENT_CARD_MAGIC 0x5072696E trident_card sound/oss/trident.c
|
||||
ROUTER_MAGIC 0x524d4157 wan_device include/linux/wanrouter.h
|
||||
ROUTER_MAGIC 0x524d4157 wan_device [in wanrouter.h pre 3.9]
|
||||
SCC_MAGIC 0x52696368 gs_port drivers/char/scc.h
|
||||
SAVEKMSG_MAGIC1 0x53415645 savekmsg arch/*/amiga/config.c
|
||||
GDA_MAGIC 0x58464552 gda arch/mips/include/asm/sn/gda.h
|
||||
|
@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/wanrouter.h>
|
||||
#include <linux/isdn.h>
|
||||
#include <linux/concap.h>
|
||||
|
||||
|
@ -356,60 +356,6 @@ config SDLA
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called sdla.
|
||||
|
||||
# Wan router core.
|
||||
config WAN_ROUTER_DRIVERS
|
||||
tristate "WAN router drivers"
|
||||
depends on WAN_ROUTER
|
||||
---help---
|
||||
Connect LAN to WAN via Linux box.
|
||||
|
||||
Select driver your card and remember to say Y to "Wan Router."
|
||||
You will need the wan-tools package which is available from
|
||||
<ftp://ftp.sangoma.com/>.
|
||||
|
||||
Note that the answer to this question won't directly affect the
|
||||
kernel except for how subordinate drivers may be built:
|
||||
saying N will just cause the configurator to skip all
|
||||
the questions about WAN router drivers.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config CYCLADES_SYNC
|
||||
tristate "Cyclom 2X(tm) cards (EXPERIMENTAL)"
|
||||
depends on WAN_ROUTER_DRIVERS && (PCI || ISA)
|
||||
---help---
|
||||
Cyclom 2X from Cyclades Corporation <http://www.avocent.com/> is an
|
||||
intelligent multiprotocol WAN adapter with data transfer rates up to
|
||||
512 Kbps. These cards support the X.25 and SNA related protocols.
|
||||
|
||||
While no documentation is available at this time please grab the
|
||||
wanconfig tarball in
|
||||
<http://www.conectiva.com.br/~acme/cycsyn-devel/> (with minor changes
|
||||
to make it compile with the current wanrouter include files; efforts
|
||||
are being made to use the original package available at
|
||||
<ftp://ftp.sangoma.com/>).
|
||||
|
||||
Feel free to contact me or the cycsyn-devel mailing list at
|
||||
<acme@conectiva.com.br> and <cycsyn-devel@bazar.conectiva.com.br> for
|
||||
additional details, I hope to have documentation available as soon as
|
||||
possible. (Cyclades Brazil is writing the Documentation).
|
||||
|
||||
The next questions will ask you about the protocols you want the
|
||||
driver to support (for now only X.25 is supported).
|
||||
|
||||
If you have one or more of these cards, say Y to this option.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called cyclomx.
|
||||
|
||||
config CYCLOMX_X25
|
||||
bool "Cyclom 2X X.25 support (EXPERIMENTAL)"
|
||||
depends on CYCLADES_SYNC
|
||||
help
|
||||
Connect a Cyclom 2X card to an X.25 network.
|
||||
|
||||
Enabling X.25 support will enlarge your kernel by about 11 kB.
|
||||
|
||||
# X.25 network drivers
|
||||
config LAPBETHER
|
||||
tristate "LAPB over Ethernet driver (EXPERIMENTAL)"
|
||||
|
@ -5,10 +5,6 @@
|
||||
# Rewritten to use lists instead of if-statements.
|
||||
#
|
||||
|
||||
cyclomx-y := cycx_main.o
|
||||
cyclomx-$(CONFIG_CYCLOMX_X25) += cycx_x25.o
|
||||
cyclomx-objs := $(cyclomx-y)
|
||||
|
||||
obj-$(CONFIG_HDLC) += hdlc.o
|
||||
obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o
|
||||
obj-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o
|
||||
@ -28,7 +24,6 @@ obj-$(CONFIG_LANMEDIA) += lmc/
|
||||
|
||||
obj-$(CONFIG_DLCI) += dlci.o
|
||||
obj-$(CONFIG_SDLA) += sdla.o
|
||||
obj-$(CONFIG_CYCLADES_SYNC) += cycx_drv.o cyclomx.o
|
||||
obj-$(CONFIG_LAPBETHER) += lapbether.o
|
||||
obj-$(CONFIG_SBNI) += sbni.o
|
||||
obj-$(CONFIG_N2) += n2.o
|
||||
|
@ -1,569 +0,0 @@
|
||||
/*
|
||||
* cycx_drv.c Cyclom 2X Support Module.
|
||||
*
|
||||
* This module is a library of common hardware specific
|
||||
* functions used by the Cyclades Cyclom 2X sync card.
|
||||
*
|
||||
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
||||
*
|
||||
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
|
||||
*
|
||||
* Based on sdladrv.c by Gene Kozin <genek@compuserve.com>
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* 1999/11/11 acme set_current_state(TASK_INTERRUPTIBLE), code
|
||||
* cleanup
|
||||
* 1999/11/08 acme init_cyc2x deleted, doing nothing
|
||||
* 1999/11/06 acme back to read[bw], write[bw] and memcpy_to and
|
||||
* fromio to use dpmbase ioremaped
|
||||
* 1999/10/26 acme use isa_read[bw], isa_write[bw] & isa_memcpy_to
|
||||
* & fromio
|
||||
* 1999/10/23 acme cleanup to only supports cyclom2x: all the other
|
||||
* boards are no longer manufactured by cyclades,
|
||||
* if someone wants to support them... be my guest!
|
||||
* 1999/05/28 acme cycx_intack & cycx_intde gone for good
|
||||
* 1999/05/18 acme lots of unlogged work, submitting to Linus...
|
||||
* 1999/01/03 acme more judicious use of data types
|
||||
* 1999/01/03 acme judicious use of data types :>
|
||||
* cycx_inten trying to reset pending interrupts
|
||||
* from cyclom 2x - I think this isn't the way to
|
||||
* go, but for now...
|
||||
* 1999/01/02 acme cycx_intack ok, I think there's nothing to do
|
||||
* to ack an int in cycx_drv.c, only handle it in
|
||||
* cyx_isr (or in the other protocols: cyp_isr,
|
||||
* cyf_isr, when they get implemented.
|
||||
* Dec 31, 1998 acme cycx_data_boot & cycx_code_boot fixed, crossing
|
||||
* fingers to see x25_configure in cycx_x25.c
|
||||
* work... :)
|
||||
* Dec 26, 1998 acme load implementation fixed, seems to work! :)
|
||||
* cycx_2x_dpmbase_options with all the possible
|
||||
* DPM addresses (20).
|
||||
* cycx_intr implemented (test this!)
|
||||
* general code cleanup
|
||||
* Dec 8, 1998 Ivan Passos Cyclom-2X firmware load implementation.
|
||||
* Aug 8, 1998 acme Initial version.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/init.h> /* __init */
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h> /* printk(), and other useful stuff */
|
||||
#include <linux/stddef.h> /* offsetof(), etc. */
|
||||
#include <linux/errno.h> /* return codes */
|
||||
#include <linux/cycx_drv.h> /* API definitions */
|
||||
#include <linux/cycx_cfm.h> /* CYCX firmware module definitions */
|
||||
#include <linux/delay.h> /* udelay, msleep_interruptible */
|
||||
#include <asm/io.h> /* read[wl], write[wl], ioremap, iounmap */
|
||||
|
||||
#define MOD_VERSION 0
|
||||
#define MOD_RELEASE 6
|
||||
|
||||
MODULE_AUTHOR("Arnaldo Carvalho de Melo");
|
||||
MODULE_DESCRIPTION("Cyclom 2x Sync Card Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
/* Hardware-specific functions */
|
||||
static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len);
|
||||
static void cycx_bootcfg(struct cycx_hw *hw);
|
||||
|
||||
static int reset_cyc2x(void __iomem *addr);
|
||||
static int detect_cyc2x(void __iomem *addr);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
static int get_option_index(const long *optlist, long optval);
|
||||
static u16 checksum(u8 *buf, u32 len);
|
||||
|
||||
#define wait_cyc(addr) cycx_exec(addr + CMD_OFFSET)
|
||||
|
||||
/* Global Data */
|
||||
|
||||
/* private data */
|
||||
static const char fullname[] = "Cyclom 2X Support Module";
|
||||
static const char copyright[] =
|
||||
"(c) 1998-2003 Arnaldo Carvalho de Melo <acme@conectiva.com.br>";
|
||||
|
||||
/* Hardware configuration options.
|
||||
* These are arrays of configuration options used by verification routines.
|
||||
* The first element of each array is its size (i.e. number of options).
|
||||
*/
|
||||
static const long cyc2x_dpmbase_options[] = {
|
||||
20,
|
||||
0xA0000, 0xA4000, 0xA8000, 0xAC000, 0xB0000, 0xB4000, 0xB8000,
|
||||
0xBC000, 0xC0000, 0xC4000, 0xC8000, 0xCC000, 0xD0000, 0xD4000,
|
||||
0xD8000, 0xDC000, 0xE0000, 0xE4000, 0xE8000, 0xEC000
|
||||
};
|
||||
|
||||
static const long cycx_2x_irq_options[] = { 7, 3, 5, 9, 10, 11, 12, 15 };
|
||||
|
||||
/* Kernel Loadable Module Entry Points */
|
||||
/* Module 'insert' entry point.
|
||||
* o print announcement
|
||||
* o initialize static data
|
||||
*
|
||||
* Return: 0 Ok
|
||||
* < 0 error.
|
||||
* Context: process */
|
||||
|
||||
static int __init cycx_drv_init(void)
|
||||
{
|
||||
pr_info("%s v%u.%u %s\n",
|
||||
fullname, MOD_VERSION, MOD_RELEASE, copyright);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Module 'remove' entry point.
|
||||
* o release all remaining system resources */
|
||||
static void cycx_drv_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Kernel APIs */
|
||||
/* Set up adapter.
|
||||
* o detect adapter type
|
||||
* o verify hardware configuration options
|
||||
* o check for hardware conflicts
|
||||
* o set up adapter shared memory
|
||||
* o test adapter memory
|
||||
* o load firmware
|
||||
* Return: 0 ok.
|
||||
* < 0 error */
|
||||
EXPORT_SYMBOL(cycx_setup);
|
||||
int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Verify IRQ configuration options */
|
||||
if (!get_option_index(cycx_2x_irq_options, hw->irq)) {
|
||||
pr_err("IRQ %d is invalid!\n", hw->irq);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Setup adapter dual-port memory window and test memory */
|
||||
if (!dpmbase) {
|
||||
pr_err("you must specify the dpm address!\n");
|
||||
return -EINVAL;
|
||||
} else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) {
|
||||
pr_err("memory address 0x%lX is invalid!\n", dpmbase);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hw->dpmbase = ioremap(dpmbase, CYCX_WINDOWSIZE);
|
||||
hw->dpmsize = CYCX_WINDOWSIZE;
|
||||
|
||||
if (!detect_cyc2x(hw->dpmbase)) {
|
||||
pr_err("adapter Cyclom 2X not found at address 0x%lX!\n",
|
||||
dpmbase);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pr_info("found Cyclom 2X card at address 0x%lX\n", dpmbase);
|
||||
|
||||
/* Load firmware. If loader fails then shut down adapter */
|
||||
err = load_cyc2x(hw, cfm, len);
|
||||
|
||||
if (err)
|
||||
cycx_down(hw); /* shutdown adapter */
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(cycx_down);
|
||||
int cycx_down(struct cycx_hw *hw)
|
||||
{
|
||||
iounmap(hw->dpmbase);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Enable interrupt generation. */
|
||||
static void cycx_inten(struct cycx_hw *hw)
|
||||
{
|
||||
writeb(0, hw->dpmbase);
|
||||
}
|
||||
|
||||
/* Generate an interrupt to adapter's CPU. */
|
||||
EXPORT_SYMBOL(cycx_intr);
|
||||
void cycx_intr(struct cycx_hw *hw)
|
||||
{
|
||||
writew(0, hw->dpmbase + GEN_CYCX_INTR);
|
||||
}
|
||||
|
||||
/* Execute Adapter Command.
|
||||
* o Set exec flag.
|
||||
* o Busy-wait until flag is reset. */
|
||||
EXPORT_SYMBOL(cycx_exec);
|
||||
int cycx_exec(void __iomem *addr)
|
||||
{
|
||||
u16 i = 0;
|
||||
/* wait till addr content is zeroed */
|
||||
|
||||
while (readw(addr)) {
|
||||
udelay(1000);
|
||||
|
||||
if (++i > 50)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read absolute adapter memory.
|
||||
* Transfer data from adapter's memory to data buffer. */
|
||||
EXPORT_SYMBOL(cycx_peek);
|
||||
int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len)
|
||||
{
|
||||
if (len == 1)
|
||||
*(u8*)buf = readb(hw->dpmbase + addr);
|
||||
else
|
||||
memcpy_fromio(buf, hw->dpmbase + addr, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write Absolute Adapter Memory.
|
||||
* Transfer data from data buffer to adapter's memory. */
|
||||
EXPORT_SYMBOL(cycx_poke);
|
||||
int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len)
|
||||
{
|
||||
if (len == 1)
|
||||
writeb(*(u8*)buf, hw->dpmbase + addr);
|
||||
else
|
||||
memcpy_toio(hw->dpmbase + addr, buf, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Hardware-Specific Functions */
|
||||
|
||||
/* Load Aux Routines */
|
||||
/* Reset board hardware.
|
||||
return 1 if memory exists at addr and 0 if not. */
|
||||
static int memory_exists(void __iomem *addr)
|
||||
{
|
||||
int tries = 0;
|
||||
|
||||
for (; tries < 3 ; tries++) {
|
||||
writew(TEST_PATTERN, addr + 0x10);
|
||||
|
||||
if (readw(addr + 0x10) == TEST_PATTERN)
|
||||
if (readw(addr + 0x10) == TEST_PATTERN)
|
||||
return 1;
|
||||
|
||||
msleep_interruptible(1 * 1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load reset code. */
|
||||
static void reset_load(void __iomem *addr, u8 *buffer, u32 cnt)
|
||||
{
|
||||
void __iomem *pt_code = addr + RESET_OFFSET;
|
||||
u16 i; /*, j; */
|
||||
|
||||
for (i = 0 ; i < cnt ; i++) {
|
||||
/* for (j = 0 ; j < 50 ; j++); Delay - FIXME busy waiting... */
|
||||
writeb(*buffer++, pt_code++);
|
||||
}
|
||||
}
|
||||
|
||||
/* Load buffer using boot interface.
|
||||
* o copy data from buffer to Cyclom-X memory
|
||||
* o wait for reset code to copy it to right portion of memory */
|
||||
static int buffer_load(void __iomem *addr, u8 *buffer, u32 cnt)
|
||||
{
|
||||
memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
|
||||
writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
|
||||
|
||||
return wait_cyc(addr);
|
||||
}
|
||||
|
||||
/* Set up entry point and kick start Cyclom-X CPU. */
|
||||
static void cycx_start(void __iomem *addr)
|
||||
{
|
||||
/* put in 0x30 offset the jump instruction to the code entry point */
|
||||
writeb(0xea, addr + 0x30);
|
||||
writeb(0x00, addr + 0x31);
|
||||
writeb(0xc4, addr + 0x32);
|
||||
writeb(0x00, addr + 0x33);
|
||||
writeb(0x00, addr + 0x34);
|
||||
|
||||
/* cmd to start executing code */
|
||||
writew(GEN_START, addr + CMD_OFFSET);
|
||||
}
|
||||
|
||||
/* Load and boot reset code. */
|
||||
static void cycx_reset_boot(void __iomem *addr, u8 *code, u32 len)
|
||||
{
|
||||
void __iomem *pt_start = addr + START_OFFSET;
|
||||
|
||||
writeb(0xea, pt_start++); /* jmp to f000:3f00 */
|
||||
writeb(0x00, pt_start++);
|
||||
writeb(0xfc, pt_start++);
|
||||
writeb(0x00, pt_start++);
|
||||
writeb(0xf0, pt_start);
|
||||
reset_load(addr, code, len);
|
||||
|
||||
/* 80186 was in hold, go */
|
||||
writeb(0, addr + START_CPU);
|
||||
msleep_interruptible(1 * 1000);
|
||||
}
|
||||
|
||||
/* Load data.bin file through boot (reset) interface. */
|
||||
static int cycx_data_boot(void __iomem *addr, u8 *code, u32 len)
|
||||
{
|
||||
void __iomem *pt_boot_cmd = addr + CMD_OFFSET;
|
||||
u32 i;
|
||||
|
||||
/* boot buffer length */
|
||||
writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
|
||||
writew(GEN_DEFPAR, pt_boot_cmd);
|
||||
|
||||
if (wait_cyc(addr) < 0)
|
||||
return -1;
|
||||
|
||||
writew(0, pt_boot_cmd + sizeof(u16));
|
||||
writew(0x4000, pt_boot_cmd + 2 * sizeof(u16));
|
||||
writew(GEN_SET_SEG, pt_boot_cmd);
|
||||
|
||||
if (wait_cyc(addr) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ)
|
||||
if (buffer_load(addr, code + i,
|
||||
min_t(u32, CFM_LOAD_BUFSZ, (len - i))) < 0) {
|
||||
pr_err("Error !!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Load code.bin file through boot (reset) interface. */
|
||||
static int cycx_code_boot(void __iomem *addr, u8 *code, u32 len)
|
||||
{
|
||||
void __iomem *pt_boot_cmd = addr + CMD_OFFSET;
|
||||
u32 i;
|
||||
|
||||
/* boot buffer length */
|
||||
writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
|
||||
writew(GEN_DEFPAR, pt_boot_cmd);
|
||||
|
||||
if (wait_cyc(addr) < 0)
|
||||
return -1;
|
||||
|
||||
writew(0x0000, pt_boot_cmd + sizeof(u16));
|
||||
writew(0xc400, pt_boot_cmd + 2 * sizeof(u16));
|
||||
writew(GEN_SET_SEG, pt_boot_cmd);
|
||||
|
||||
if (wait_cyc(addr) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ)
|
||||
if (buffer_load(addr, code + i,
|
||||
min_t(u32, CFM_LOAD_BUFSZ, (len - i)))) {
|
||||
pr_err("Error !!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load adapter from the memory image of the CYCX firmware module.
|
||||
* o verify firmware integrity and compatibility
|
||||
* o start adapter up */
|
||||
static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len)
|
||||
{
|
||||
int i, j;
|
||||
struct cycx_fw_header *img_hdr;
|
||||
u8 *reset_image,
|
||||
*data_image,
|
||||
*code_image;
|
||||
void __iomem *pt_cycld = hw->dpmbase + 0x400;
|
||||
u16 cksum;
|
||||
|
||||
/* Announce */
|
||||
pr_info("firmware signature=\"%s\"\n", cfm->signature);
|
||||
|
||||
/* Verify firmware signature */
|
||||
if (strcmp(cfm->signature, CFM_SIGNATURE)) {
|
||||
pr_err("load_cyc2x: not Cyclom-2X firmware!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pr_info("firmware version=%u\n", cfm->version);
|
||||
|
||||
/* Verify firmware module format version */
|
||||
if (cfm->version != CFM_VERSION) {
|
||||
pr_err("%s: firmware format %u rejected! Expecting %u.\n",
|
||||
__func__, cfm->version, CFM_VERSION);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Verify firmware module length and checksum */
|
||||
cksum = checksum((u8*)&cfm->info, sizeof(struct cycx_fw_info) +
|
||||
cfm->info.codesize);
|
||||
/*
|
||||
FIXME cfm->info.codesize is off by 2
|
||||
if (((len - sizeof(struct cycx_firmware) - 1) != cfm->info.codesize) ||
|
||||
*/
|
||||
if (cksum != cfm->checksum) {
|
||||
pr_err("%s: firmware corrupted!\n", __func__);
|
||||
pr_err(" cdsize = 0x%x (expected 0x%lx)\n",
|
||||
len - (int)sizeof(struct cycx_firmware) - 1,
|
||||
cfm->info.codesize);
|
||||
pr_err(" chksum = 0x%x (expected 0x%x)\n",
|
||||
cksum, cfm->checksum);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* If everything is ok, set reset, data and code pointers */
|
||||
img_hdr = (struct cycx_fw_header *)&cfm->image;
|
||||
#ifdef FIRMWARE_DEBUG
|
||||
pr_info("%s: image sizes\n", __func__);
|
||||
pr_info(" reset=%lu\n", img_hdr->reset_size);
|
||||
pr_info(" data=%lu\n", img_hdr->data_size);
|
||||
pr_info(" code=%lu\n", img_hdr->code_size);
|
||||
#endif
|
||||
reset_image = ((u8 *)img_hdr) + sizeof(struct cycx_fw_header);
|
||||
data_image = reset_image + img_hdr->reset_size;
|
||||
code_image = data_image + img_hdr->data_size;
|
||||
|
||||
/*---- Start load ----*/
|
||||
/* Announce */
|
||||
pr_info("loading firmware %s (ID=%u)...\n",
|
||||
cfm->descr[0] ? cfm->descr : "unknown firmware",
|
||||
cfm->info.codeid);
|
||||
|
||||
for (i = 0 ; i < 5 ; i++) {
|
||||
/* Reset Cyclom hardware */
|
||||
if (!reset_cyc2x(hw->dpmbase)) {
|
||||
pr_err("dpm problem or board not found\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Load reset.bin */
|
||||
cycx_reset_boot(hw->dpmbase, reset_image, img_hdr->reset_size);
|
||||
/* reset is waiting for boot */
|
||||
writew(GEN_POWER_ON, pt_cycld);
|
||||
msleep_interruptible(1 * 1000);
|
||||
|
||||
for (j = 0 ; j < 3 ; j++)
|
||||
if (!readw(pt_cycld))
|
||||
goto reset_loaded;
|
||||
else
|
||||
msleep_interruptible(1 * 1000);
|
||||
}
|
||||
|
||||
pr_err("reset not started\n");
|
||||
return -EINVAL;
|
||||
|
||||
reset_loaded:
|
||||
/* Load data.bin */
|
||||
if (cycx_data_boot(hw->dpmbase, data_image, img_hdr->data_size)) {
|
||||
pr_err("cannot load data file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Load code.bin */
|
||||
if (cycx_code_boot(hw->dpmbase, code_image, img_hdr->code_size)) {
|
||||
pr_err("cannot load code file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Prepare boot-time configuration data */
|
||||
cycx_bootcfg(hw);
|
||||
|
||||
/* kick-off CPU */
|
||||
cycx_start(hw->dpmbase);
|
||||
|
||||
/* Arthur Ganzert's tip: wait a while after the firmware loading...
|
||||
seg abr 26 17:17:12 EST 1999 - acme */
|
||||
msleep_interruptible(7 * 1000);
|
||||
pr_info("firmware loaded!\n");
|
||||
|
||||
/* enable interrupts */
|
||||
cycx_inten(hw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Prepare boot-time firmware configuration data.
|
||||
* o initialize configuration data area
|
||||
From async.doc - V_3.4.0 - 07/18/1994
|
||||
- As of now, only static buffers are available to the user.
|
||||
So, the bit VD_RXDIRC must be set in 'valid'. That means that user
|
||||
wants to use the static transmission and reception buffers. */
|
||||
static void cycx_bootcfg(struct cycx_hw *hw)
|
||||
{
|
||||
/* use fixed buffers */
|
||||
writeb(FIXED_BUFFERS, hw->dpmbase + CONF_OFFSET);
|
||||
}
|
||||
|
||||
/* Detect Cyclom 2x adapter.
|
||||
* Following tests are used to detect Cyclom 2x adapter:
|
||||
* to be completed based on the tests done below
|
||||
* Return 1 if detected o.k. or 0 if failed.
|
||||
* Note: This test is destructive! Adapter will be left in shutdown
|
||||
* state after the test. */
|
||||
static int detect_cyc2x(void __iomem *addr)
|
||||
{
|
||||
reset_cyc2x(addr);
|
||||
|
||||
return memory_exists(addr);
|
||||
}
|
||||
|
||||
/* Miscellaneous */
|
||||
/* Get option's index into the options list.
|
||||
* Return option's index (1 .. N) or zero if option is invalid. */
|
||||
static int get_option_index(const long *optlist, long optval)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
for (; i <= optlist[0]; ++i)
|
||||
if (optlist[i] == optval)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reset adapter's CPU. */
|
||||
static int reset_cyc2x(void __iomem *addr)
|
||||
{
|
||||
writeb(0, addr + RST_ENABLE);
|
||||
msleep_interruptible(2 * 1000);
|
||||
writeb(0, addr + RST_DISABLE);
|
||||
msleep_interruptible(2 * 1000);
|
||||
|
||||
return memory_exists(addr);
|
||||
}
|
||||
|
||||
/* Calculate 16-bit CRC using CCITT polynomial. */
|
||||
static u16 checksum(u8 *buf, u32 len)
|
||||
{
|
||||
u16 crc = 0;
|
||||
u16 mask, flag;
|
||||
|
||||
for (; len; --len, ++buf)
|
||||
for (mask = 0x80; mask; mask >>= 1) {
|
||||
flag = (crc & 0x8000);
|
||||
crc <<= 1;
|
||||
crc |= ((*buf & mask) ? 1 : 0);
|
||||
|
||||
if (flag)
|
||||
crc ^= 0x1021;
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
module_init(cycx_drv_init);
|
||||
module_exit(cycx_drv_cleanup);
|
||||
|
||||
/* End */
|
@ -1,346 +0,0 @@
|
||||
/*
|
||||
* cycx_main.c Cyclades Cyclom 2X WAN Link Driver. Main module.
|
||||
*
|
||||
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
||||
*
|
||||
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
|
||||
*
|
||||
* Based on sdlamain.c by Gene Kozin <genek@compuserve.com> &
|
||||
* Jaspreet Singh <jaspreet@sangoma.com>
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* Please look at the bitkeeper changelog (or any other scm tool that ends up
|
||||
* importing bitkeeper changelog or that replaces bitkeeper in the future as
|
||||
* main tool for linux development).
|
||||
*
|
||||
* 2001/05/09 acme Fix MODULE_DESC for debug, .bss nitpicks,
|
||||
* some cleanups
|
||||
* 2000/07/13 acme remove useless #ifdef MODULE and crap
|
||||
* #if KERNEL_VERSION > blah
|
||||
* 2000/07/06 acme __exit at cyclomx_cleanup
|
||||
* 2000/04/02 acme dprintk and cycx_debug
|
||||
* module_init/module_exit
|
||||
* 2000/01/21 acme rename cyclomx_open to cyclomx_mod_inc_use_count
|
||||
* and cyclomx_close to cyclomx_mod_dec_use_count
|
||||
* 2000/01/08 acme cleanup
|
||||
* 1999/11/06 acme cycx_down back to life (it needs to be
|
||||
* called to iounmap the dpmbase)
|
||||
* 1999/08/09 acme removed references to enable_tx_int
|
||||
* use spinlocks instead of cli/sti in
|
||||
* cyclomx_set_state
|
||||
* 1999/05/19 acme works directly linked into the kernel
|
||||
* init_waitqueue_head for 2.3.* kernel
|
||||
* 1999/05/18 acme major cleanup (polling not needed), etc
|
||||
* 1998/08/28 acme minor cleanup (ioctls for firmware deleted)
|
||||
* queue_task activated
|
||||
* 1998/08/08 acme Initial version.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/stddef.h> /* offsetof(), etc. */
|
||||
#include <linux/errno.h> /* return codes */
|
||||
#include <linux/string.h> /* inline memset(), etc. */
|
||||
#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/cyclomx.h> /* cyclomx common user API definitions */
|
||||
#include <linux/init.h> /* __init (when not using as a module) */
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
unsigned int cycx_debug;
|
||||
|
||||
MODULE_AUTHOR("Arnaldo Carvalho de Melo");
|
||||
MODULE_DESCRIPTION("Cyclom 2X Sync Card Driver.");
|
||||
MODULE_LICENSE("GPL");
|
||||
module_param(cycx_debug, int, 0);
|
||||
MODULE_PARM_DESC(cycx_debug, "cyclomx debug level");
|
||||
|
||||
/* Defines & Macros */
|
||||
|
||||
#define CYCX_DRV_VERSION 0 /* version number */
|
||||
#define CYCX_DRV_RELEASE 11 /* release (minor version) number */
|
||||
#define CYCX_MAX_CARDS 1 /* max number of adapters */
|
||||
|
||||
#define CONFIG_CYCX_CARDS 1
|
||||
|
||||
/* Function Prototypes */
|
||||
|
||||
/* WAN link driver entry points */
|
||||
static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf);
|
||||
static int cycx_wan_shutdown(struct wan_device *wandev);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
static irqreturn_t cycx_isr(int irq, void *dev_id);
|
||||
|
||||
/* Global Data
|
||||
* Note: All data must be explicitly initialized!!!
|
||||
*/
|
||||
|
||||
/* private data */
|
||||
static const char cycx_drvname[] = "cyclomx";
|
||||
static const char cycx_fullname[] = "CYCLOM 2X(tm) Sync Card Driver";
|
||||
static const char cycx_copyright[] = "(c) 1998-2003 Arnaldo Carvalho de Melo "
|
||||
"<acme@conectiva.com.br>";
|
||||
static int cycx_ncards = CONFIG_CYCX_CARDS;
|
||||
static struct cycx_device *cycx_card_array; /* adapter data space */
|
||||
|
||||
/* Kernel Loadable Module Entry Points */
|
||||
|
||||
/*
|
||||
* Module 'insert' entry point.
|
||||
* o print announcement
|
||||
* o allocate adapter data space
|
||||
* o initialize static data
|
||||
* o register all cards with WAN router
|
||||
* o calibrate Cyclom 2X shared memory access delay.
|
||||
*
|
||||
* Return: 0 Ok
|
||||
* < 0 error.
|
||||
* Context: process
|
||||
*/
|
||||
static int __init cycx_init(void)
|
||||
{
|
||||
int cnt, err = -ENOMEM;
|
||||
|
||||
pr_info("%s v%u.%u %s\n",
|
||||
cycx_fullname, CYCX_DRV_VERSION, CYCX_DRV_RELEASE,
|
||||
cycx_copyright);
|
||||
|
||||
/* Verify number of cards and allocate adapter data space */
|
||||
cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
|
||||
cycx_ncards = max_t(int, cycx_ncards, 1);
|
||||
cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device), GFP_KERNEL);
|
||||
if (!cycx_card_array)
|
||||
goto out;
|
||||
|
||||
|
||||
/* Register adapters with WAN router */
|
||||
for (cnt = 0; cnt < cycx_ncards; ++cnt) {
|
||||
struct cycx_device *card = &cycx_card_array[cnt];
|
||||
struct wan_device *wandev = &card->wandev;
|
||||
|
||||
sprintf(card->devname, "%s%d", cycx_drvname, cnt + 1);
|
||||
wandev->magic = ROUTER_MAGIC;
|
||||
wandev->name = card->devname;
|
||||
wandev->private = card;
|
||||
wandev->setup = cycx_wan_setup;
|
||||
wandev->shutdown = cycx_wan_shutdown;
|
||||
err = register_wan_device(wandev);
|
||||
|
||||
if (err) {
|
||||
pr_err("%s registration failed with error %d!\n",
|
||||
card->devname, err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
err = -ENODEV;
|
||||
if (!cnt) {
|
||||
kfree(cycx_card_array);
|
||||
goto out;
|
||||
}
|
||||
err = 0;
|
||||
cycx_ncards = cnt; /* adjust actual number of cards */
|
||||
out: return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Module 'remove' entry point.
|
||||
* o unregister all adapters from the WAN router
|
||||
* o release all remaining system resources
|
||||
*/
|
||||
static void __exit cycx_exit(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (; i < cycx_ncards; ++i) {
|
||||
struct cycx_device *card = &cycx_card_array[i];
|
||||
unregister_wan_device(card->devname);
|
||||
}
|
||||
|
||||
kfree(cycx_card_array);
|
||||
}
|
||||
|
||||
/* WAN Device Driver Entry Points */
|
||||
/*
|
||||
* Setup/configure WAN link driver.
|
||||
* o check adapter state
|
||||
* o make sure firmware is present in configuration
|
||||
* o allocate interrupt vector
|
||||
* o setup Cyclom 2X hardware
|
||||
* o call appropriate routine to perform protocol-specific initialization
|
||||
*
|
||||
* This function is called when router handles ROUTER_SETUP IOCTL. The
|
||||
* configuration structure is in kernel memory (including extended data, if
|
||||
* any).
|
||||
*/
|
||||
static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf)
|
||||
{
|
||||
int rc = -EFAULT;
|
||||
struct cycx_device *card;
|
||||
int irq;
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
if (!wandev || !wandev->private || !conf)
|
||||
goto out;
|
||||
|
||||
card = wandev->private;
|
||||
rc = -EBUSY;
|
||||
if (wandev->state != WAN_UNCONFIGURED)
|
||||
goto out;
|
||||
|
||||
rc = -EINVAL;
|
||||
if (!conf->data_size || !conf->data) {
|
||||
pr_err("%s: firmware not found in configuration data!\n",
|
||||
wandev->name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (conf->irq <= 0) {
|
||||
pr_err("%s: can't configure without IRQ!\n", wandev->name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Allocate IRQ */
|
||||
irq = conf->irq == 2 ? 9 : conf->irq; /* IRQ2 -> IRQ9 */
|
||||
|
||||
if (request_irq(irq, cycx_isr, 0, wandev->name, card)) {
|
||||
pr_err("%s: can't reserve IRQ %d!\n", wandev->name, irq);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Configure hardware, load firmware, etc. */
|
||||
memset(&card->hw, 0, sizeof(card->hw));
|
||||
card->hw.irq = irq;
|
||||
card->hw.dpmsize = CYCX_WINDOWSIZE;
|
||||
card->hw.fwid = CFID_X25_2X;
|
||||
spin_lock_init(&card->lock);
|
||||
init_waitqueue_head(&card->wait_stats);
|
||||
|
||||
rc = cycx_setup(&card->hw, conf->data, conf->data_size, conf->maddr);
|
||||
if (rc)
|
||||
goto out_irq;
|
||||
|
||||
/* Initialize WAN device data space */
|
||||
wandev->irq = irq;
|
||||
wandev->dma = wandev->ioport = 0;
|
||||
wandev->maddr = (unsigned long)card->hw.dpmbase;
|
||||
wandev->msize = card->hw.dpmsize;
|
||||
wandev->hw_opt[2] = 0;
|
||||
wandev->hw_opt[3] = card->hw.fwid;
|
||||
|
||||
/* Protocol-specific initialization */
|
||||
switch (card->hw.fwid) {
|
||||
#ifdef CONFIG_CYCLOMX_X25
|
||||
case CFID_X25_2X:
|
||||
rc = cycx_x25_wan_init(card, conf);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
pr_err("%s: this firmware is not supported!\n", wandev->name);
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
cycx_down(&card->hw);
|
||||
goto out_irq;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
out:
|
||||
return rc;
|
||||
out_irq:
|
||||
free_irq(irq, card);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shut down WAN link driver.
|
||||
* o shut down adapter hardware
|
||||
* o release system resources.
|
||||
*
|
||||
* This function is called by the router when device is being unregistered or
|
||||
* when it handles ROUTER_DOWN IOCTL.
|
||||
*/
|
||||
static int cycx_wan_shutdown(struct wan_device *wandev)
|
||||
{
|
||||
int ret = -EFAULT;
|
||||
struct cycx_device *card;
|
||||
|
||||
/* sanity checks */
|
||||
if (!wandev || !wandev->private)
|
||||
goto out;
|
||||
|
||||
ret = 0;
|
||||
if (wandev->state == WAN_UNCONFIGURED)
|
||||
goto out;
|
||||
|
||||
card = wandev->private;
|
||||
wandev->state = WAN_UNCONFIGURED;
|
||||
cycx_down(&card->hw);
|
||||
pr_info("%s: irq %d being freed!\n", wandev->name, wandev->irq);
|
||||
free_irq(wandev->irq, card);
|
||||
out: return ret;
|
||||
}
|
||||
|
||||
/* Miscellaneous */
|
||||
/*
|
||||
* Cyclom 2X Interrupt Service Routine.
|
||||
* o acknowledge Cyclom 2X hardware interrupt.
|
||||
* o call protocol-specific interrupt service routine, if any.
|
||||
*/
|
||||
static irqreturn_t cycx_isr(int irq, void *dev_id)
|
||||
{
|
||||
struct cycx_device *card = dev_id;
|
||||
|
||||
if (card->wandev.state == WAN_UNCONFIGURED)
|
||||
goto out;
|
||||
|
||||
if (card->in_isr) {
|
||||
pr_warn("%s: interrupt re-entrancy on IRQ %d!\n",
|
||||
card->devname, card->wandev.irq);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (card->isr)
|
||||
card->isr(card);
|
||||
return IRQ_HANDLED;
|
||||
out:
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
/* Set WAN device state. */
|
||||
void cycx_set_state(struct cycx_device *card, int state)
|
||||
{
|
||||
unsigned long flags;
|
||||
char *string_state = NULL;
|
||||
|
||||
spin_lock_irqsave(&card->lock, flags);
|
||||
|
||||
if (card->wandev.state != state) {
|
||||
switch (state) {
|
||||
case WAN_CONNECTED:
|
||||
string_state = "connected!";
|
||||
break;
|
||||
case WAN_DISCONNECTED:
|
||||
string_state = "disconnected!";
|
||||
break;
|
||||
}
|
||||
pr_info("%s: link %s\n", card->devname, string_state);
|
||||
card->wandev.state = state;
|
||||
}
|
||||
|
||||
card->state_tick = jiffies;
|
||||
spin_unlock_irqrestore(&card->lock, flags);
|
||||
}
|
||||
|
||||
module_init(cycx_init);
|
||||
module_exit(cycx_exit);
|
File diff suppressed because it is too large
Load Diff
@ -1,77 +0,0 @@
|
||||
#ifndef _CYCLOMX_H
|
||||
#define _CYCLOMX_H
|
||||
/*
|
||||
* cyclomx.h Cyclom 2X WAN Link Driver.
|
||||
* User-level API definitions.
|
||||
*
|
||||
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
||||
*
|
||||
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
|
||||
*
|
||||
* Based on wanpipe.h by Gene Kozin <genek@compuserve.com>
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* 2000/07/13 acme remove crap #if KERNEL_VERSION > blah
|
||||
* 2000/01/21 acme rename cyclomx_open to cyclomx_mod_inc_use_count
|
||||
* and cyclomx_close to cyclomx_mod_dec_use_count
|
||||
* 1999/05/19 acme wait_queue_head_t wait_stats(support for 2.3.*)
|
||||
* 1999/01/03 acme judicious use of data types
|
||||
* 1998/12/27 acme cleanup: PACKED not needed
|
||||
* 1998/08/08 acme Version 0.0.1
|
||||
*/
|
||||
|
||||
#include <linux/wanrouter.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/* Kernel Interface */
|
||||
|
||||
#include <linux/cycx_drv.h> /* Cyclom 2X support module API definitions */
|
||||
#include <linux/cycx_cfm.h> /* Cyclom 2X firmware module definitions */
|
||||
#ifdef CONFIG_CYCLOMX_X25
|
||||
#include <linux/cycx_x25.h>
|
||||
#endif
|
||||
|
||||
/* Adapter Data Space.
|
||||
* This structure is needed because we handle multiple cards, otherwise
|
||||
* static data would do it.
|
||||
*/
|
||||
struct cycx_device {
|
||||
char devname[WAN_DRVNAME_SZ + 1];/* card name */
|
||||
struct cycx_hw hw; /* hardware configuration */
|
||||
struct wan_device wandev; /* WAN device data space */
|
||||
u32 state_tick; /* link state timestamp */
|
||||
spinlock_t lock;
|
||||
char in_isr; /* interrupt-in-service flag */
|
||||
char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
|
||||
wait_queue_head_t wait_stats; /* to wait for the STATS indication */
|
||||
void __iomem *mbox; /* -> mailbox */
|
||||
void (*isr)(struct cycx_device* card); /* interrupt service routine */
|
||||
int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
|
||||
union {
|
||||
#ifdef CONFIG_CYCLOMX_X25
|
||||
struct { /* X.25 specific data */
|
||||
u32 lo_pvc;
|
||||
u32 hi_pvc;
|
||||
u32 lo_svc;
|
||||
u32 hi_svc;
|
||||
struct cycx_x25_stats stats;
|
||||
spinlock_t lock;
|
||||
u32 connection_keys;
|
||||
} x;
|
||||
#endif
|
||||
} u;
|
||||
};
|
||||
|
||||
/* Public Functions */
|
||||
void cycx_set_state(struct cycx_device *card, int state);
|
||||
|
||||
#ifdef CONFIG_CYCLOMX_X25
|
||||
int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf);
|
||||
#endif
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* _CYCLOMX_H */
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* cycx_drv.h CYCX Support Module. Kernel API Definitions.
|
||||
*
|
||||
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
||||
*
|
||||
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
|
||||
*
|
||||
* Based on sdladrv.h by Gene Kozin <genek@compuserve.com>
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* 1999/10/23 acme cycxhw_t cleanup
|
||||
* 1999/01/03 acme more judicious use of data types...
|
||||
* uclong, ucchar, etc deleted, the u8, u16, u32
|
||||
* types are the portable way to go.
|
||||
* 1999/01/03 acme judicious use of data types... u16, u32, etc
|
||||
* 1998/12/26 acme FIXED_BUFFERS, CONF_OFFSET,
|
||||
* removal of cy_read{bwl}
|
||||
* 1998/08/08 acme Initial version.
|
||||
*/
|
||||
#ifndef _CYCX_DRV_H
|
||||
#define _CYCX_DRV_H
|
||||
|
||||
#define CYCX_WINDOWSIZE 0x4000 /* default dual-port memory window size */
|
||||
#define GEN_CYCX_INTR 0x02
|
||||
#define RST_ENABLE 0x04
|
||||
#define START_CPU 0x06
|
||||
#define RST_DISABLE 0x08
|
||||
#define FIXED_BUFFERS 0x08
|
||||
#define TEST_PATTERN 0xaa55
|
||||
#define CMD_OFFSET 0x20
|
||||
#define CONF_OFFSET 0x0380
|
||||
#define RESET_OFFSET 0x3c00 /* For reset file load */
|
||||
#define DATA_OFFSET 0x0100 /* For code and data files load */
|
||||
#define START_OFFSET 0x3ff0 /* 80186 starts here */
|
||||
|
||||
/**
|
||||
* struct cycx_hw - Adapter hardware configuration
|
||||
* @fwid - firmware ID
|
||||
* @irq - interrupt request level
|
||||
* @dpmbase - dual-port memory base
|
||||
* @dpmsize - dual-port memory size
|
||||
* @reserved - reserved for future use
|
||||
*/
|
||||
struct cycx_hw {
|
||||
u32 fwid;
|
||||
int irq;
|
||||
void __iomem *dpmbase;
|
||||
u32 dpmsize;
|
||||
u32 reserved[5];
|
||||
};
|
||||
|
||||
/* Function Prototypes */
|
||||
extern int cycx_setup(struct cycx_hw *hw, void *sfm, u32 len, unsigned long base);
|
||||
extern int cycx_down(struct cycx_hw *hw);
|
||||
extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
|
||||
extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
|
||||
extern int cycx_exec(void __iomem *addr);
|
||||
|
||||
extern void cycx_intr(struct cycx_hw *hw);
|
||||
#endif /* _CYCX_DRV_H */
|
@ -1,129 +1,10 @@
|
||||
/*****************************************************************************
|
||||
* wanrouter.h Definitions for the WAN Multiprotocol Router Module.
|
||||
* This module provides API and common services for WAN Link
|
||||
* Drivers and is completely hardware-independent.
|
||||
*
|
||||
* Author: Nenad Corbic <ncorbic@sangoma.com>
|
||||
* Gideon Hack
|
||||
* Additions: Arnaldo Melo
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* Jul 21, 2000 Nenad Corbic Added WAN_FT1_READY State
|
||||
* Feb 24, 2000 Nenad Corbic Added support for socket based x25api
|
||||
* Jan 28, 2000 Nenad Corbic Added support for the ASYNC protocol.
|
||||
* Oct 04, 1999 Nenad Corbic Updated for 2.1.0 release
|
||||
* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
|
||||
* May 23, 1999 Arnaldo Melo Added local_addr to wanif_conf_t
|
||||
* WAN_DISCONNECTING state added
|
||||
* Jul 20, 1998 David Fong Added Inverse ARP options to 'wanif_conf_t'
|
||||
* Jun 12, 1998 David Fong Added Cisco HDLC support.
|
||||
* Dec 16, 1997 Jaspreet Singh Moved 'enable_IPX' and 'network_number' to
|
||||
* 'wanif_conf_t'
|
||||
* Dec 05, 1997 Jaspreet Singh Added 'pap', 'chap' to 'wanif_conf_t'
|
||||
* Added 'authenticator' to 'wan_ppp_conf_t'
|
||||
* Nov 06, 1997 Jaspreet Singh Changed Router Driver version to 1.1 from 1.0
|
||||
* Oct 20, 1997 Jaspreet Singh Added 'cir','bc','be' and 'mc' to 'wanif_conf_t'
|
||||
* Added 'enable_IPX' and 'network_number' to
|
||||
* 'wan_device_t'. Also added defines for
|
||||
* UDP PACKET TYPE, Interrupt test, critical values
|
||||
* for RACE conditions.
|
||||
* Oct 05, 1997 Jaspreet Singh Added 'dlci_num' and 'dlci[100]' to
|
||||
* 'wan_fr_conf_t' to configure a list of dlci(s)
|
||||
* for a NODE
|
||||
* Jul 07, 1997 Jaspreet Singh Added 'ttl' to 'wandev_conf_t' & 'wan_device_t'
|
||||
* May 29, 1997 Jaspreet Singh Added 'tx_int_enabled' to 'wan_device_t'
|
||||
* May 21, 1997 Jaspreet Singh Added 'udp_port' to 'wan_device_t'
|
||||
* Apr 25, 1997 Farhan Thawar Added 'udp_port' to 'wandev_conf_t'
|
||||
* Jan 16, 1997 Gene Kozin router_devlist made public
|
||||
* Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h).
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* wanrouter.h Legacy declarations kept around until X25 is removed
|
||||
*/
|
||||
|
||||
#ifndef _ROUTER_H
|
||||
#define _ROUTER_H
|
||||
|
||||
#include <uapi/linux/wanrouter.h>
|
||||
|
||||
/****** Kernel Interface ****************************************************/
|
||||
|
||||
#include <linux/fs.h> /* support for device drivers */
|
||||
#include <linux/proc_fs.h> /* proc filesystem pragmatics */
|
||||
#include <linux/netdevice.h> /* support for network drivers */
|
||||
#include <linux/spinlock.h> /* Support for SMP Locking */
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* WAN device data space.
|
||||
*/
|
||||
struct wan_device {
|
||||
unsigned magic; /* magic number */
|
||||
char* name; /* -> WAN device name (ASCIIZ) */
|
||||
void* private; /* -> driver private data */
|
||||
unsigned config_id; /* Configuration ID */
|
||||
/****** hardware configuration ******/
|
||||
unsigned ioport; /* adapter I/O port base #1 */
|
||||
char S514_cpu_no[1]; /* PCI CPU Number */
|
||||
unsigned char S514_slot_no; /* PCI Slot Number */
|
||||
unsigned long maddr; /* dual-port memory address */
|
||||
unsigned msize; /* dual-port memory size */
|
||||
int irq; /* interrupt request level */
|
||||
int dma; /* DMA request level */
|
||||
unsigned bps; /* data transfer rate */
|
||||
unsigned mtu; /* max physical transmit unit size */
|
||||
unsigned udp_port; /* UDP port for management */
|
||||
unsigned char ttl; /* Time To Live for UDP security */
|
||||
unsigned enable_tx_int; /* Transmit Interrupt enabled or not */
|
||||
char interface; /* RS-232/V.35, etc. */
|
||||
char clocking; /* external/internal */
|
||||
char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
|
||||
char station; /* DTE/DCE, primary/secondary, etc. */
|
||||
char connection; /* permanent/switched/on-demand */
|
||||
char signalling; /* Signalling RS232 or V35 */
|
||||
char read_mode; /* read mode: Polling or interrupt */
|
||||
char new_if_cnt; /* Number of interfaces per wanpipe */
|
||||
char del_if_cnt; /* Number of times del_if() gets called */
|
||||
unsigned char piggyback; /* Piggibacking a port */
|
||||
unsigned hw_opt[4]; /* other hardware options */
|
||||
/****** status and statistics *******/
|
||||
char state; /* device state */
|
||||
char api_status; /* device api status */
|
||||
struct net_device_stats stats; /* interface statistics */
|
||||
unsigned reserved[16]; /* reserved for future use */
|
||||
unsigned long critical; /* critical section flag */
|
||||
spinlock_t lock; /* Support for SMP Locking */
|
||||
|
||||
/****** device management methods ***/
|
||||
int (*setup) (struct wan_device *wandev, wandev_conf_t *conf);
|
||||
int (*shutdown) (struct wan_device *wandev);
|
||||
int (*update) (struct wan_device *wandev);
|
||||
int (*ioctl) (struct wan_device *wandev, unsigned cmd,
|
||||
unsigned long arg);
|
||||
int (*new_if)(struct wan_device *wandev, struct net_device *dev,
|
||||
wanif_conf_t *conf);
|
||||
int (*del_if)(struct wan_device *wandev, struct net_device *dev);
|
||||
/****** maintained by the router ****/
|
||||
struct wan_device* next; /* -> next device */
|
||||
struct net_device* dev; /* list of network interfaces */
|
||||
unsigned ndev; /* number of interfaces */
|
||||
struct proc_dir_entry *dent; /* proc filesystem entry */
|
||||
};
|
||||
|
||||
/* Public functions available for device drivers */
|
||||
extern int register_wan_device(struct wan_device *wandev);
|
||||
extern int unregister_wan_device(char *name);
|
||||
|
||||
/* Proc interface functions. These must not be called by the drivers! */
|
||||
extern int wanrouter_proc_init(void);
|
||||
extern void wanrouter_proc_cleanup(void);
|
||||
extern int wanrouter_proc_add(struct wan_device *wandev);
|
||||
extern int wanrouter_proc_delete(struct wan_device *wandev);
|
||||
extern long wanrouter_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* Public Data */
|
||||
/* list of registered devices */
|
||||
extern struct wan_device *wanrouter_router_devlist;
|
||||
|
||||
#endif /* _ROUTER_H */
|
||||
|
@ -1,452 +1,17 @@
|
||||
/*****************************************************************************
|
||||
* wanrouter.h Definitions for the WAN Multiprotocol Router Module.
|
||||
* This module provides API and common services for WAN Link
|
||||
* Drivers and is completely hardware-independent.
|
||||
*
|
||||
* Author: Nenad Corbic <ncorbic@sangoma.com>
|
||||
* Gideon Hack
|
||||
* Additions: Arnaldo Melo
|
||||
*
|
||||
* 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.
|
||||
* ============================================================================
|
||||
* Jul 21, 2000 Nenad Corbic Added WAN_FT1_READY State
|
||||
* Feb 24, 2000 Nenad Corbic Added support for socket based x25api
|
||||
* Jan 28, 2000 Nenad Corbic Added support for the ASYNC protocol.
|
||||
* Oct 04, 1999 Nenad Corbic Updated for 2.1.0 release
|
||||
* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
|
||||
* May 23, 1999 Arnaldo Melo Added local_addr to wanif_conf_t
|
||||
* WAN_DISCONNECTING state added
|
||||
* Jul 20, 1998 David Fong Added Inverse ARP options to 'wanif_conf_t'
|
||||
* Jun 12, 1998 David Fong Added Cisco HDLC support.
|
||||
* Dec 16, 1997 Jaspreet Singh Moved 'enable_IPX' and 'network_number' to
|
||||
* 'wanif_conf_t'
|
||||
* Dec 05, 1997 Jaspreet Singh Added 'pap', 'chap' to 'wanif_conf_t'
|
||||
* Added 'authenticator' to 'wan_ppp_conf_t'
|
||||
* Nov 06, 1997 Jaspreet Singh Changed Router Driver version to 1.1 from 1.0
|
||||
* Oct 20, 1997 Jaspreet Singh Added 'cir','bc','be' and 'mc' to 'wanif_conf_t'
|
||||
* Added 'enable_IPX' and 'network_number' to
|
||||
* 'wan_device_t'. Also added defines for
|
||||
* UDP PACKET TYPE, Interrupt test, critical values
|
||||
* for RACE conditions.
|
||||
* Oct 05, 1997 Jaspreet Singh Added 'dlci_num' and 'dlci[100]' to
|
||||
* 'wan_fr_conf_t' to configure a list of dlci(s)
|
||||
* for a NODE
|
||||
* Jul 07, 1997 Jaspreet Singh Added 'ttl' to 'wandev_conf_t' & 'wan_device_t'
|
||||
* May 29, 1997 Jaspreet Singh Added 'tx_int_enabled' to 'wan_device_t'
|
||||
* May 21, 1997 Jaspreet Singh Added 'udp_port' to 'wan_device_t'
|
||||
* Apr 25, 1997 Farhan Thawar Added 'udp_port' to 'wandev_conf_t'
|
||||
* Jan 16, 1997 Gene Kozin router_devlist made public
|
||||
* Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h).
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* wanrouter.h Legacy declarations kept around until X25 is removed
|
||||
*/
|
||||
|
||||
#ifndef _UAPI_ROUTER_H
|
||||
#define _UAPI_ROUTER_H
|
||||
|
||||
#define ROUTER_NAME "wanrouter" /* in case we ever change it */
|
||||
#define ROUTER_VERSION 1 /* version number */
|
||||
#define ROUTER_RELEASE 1 /* release (minor version) number */
|
||||
#define ROUTER_IOCTL 'W' /* for IOCTL calls */
|
||||
#define ROUTER_MAGIC 0x524D4157L /* signature: 'WANR' reversed */
|
||||
|
||||
/* IOCTL codes for /proc/router/<device> entries (up to 255) */
|
||||
enum router_ioctls
|
||||
{
|
||||
ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */
|
||||
ROUTER_DOWN, /* shut down device */
|
||||
ROUTER_STAT, /* get device status */
|
||||
ROUTER_IFNEW, /* add interface */
|
||||
ROUTER_IFDEL, /* delete interface */
|
||||
ROUTER_IFSTAT, /* get interface status */
|
||||
ROUTER_USER = (ROUTER_IOCTL<<8)+16, /* driver-specific calls */
|
||||
ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31
|
||||
};
|
||||
|
||||
/* identifiers for displaying proc file data for dual port adapters */
|
||||
#define PROC_DATA_PORT_0 0x8000 /* the data is for port 0 */
|
||||
#define PROC_DATA_PORT_1 0x8001 /* the data is for port 1 */
|
||||
|
||||
/* NLPID for packet encapsulation (ISO/IEC TR 9577) */
|
||||
#define NLPID_IP 0xCC /* Internet Protocol Datagram */
|
||||
#define NLPID_SNAP 0x80 /* IEEE Subnetwork Access Protocol */
|
||||
#define NLPID_CLNP 0x81 /* ISO/IEC 8473 */
|
||||
#define NLPID_ESIS 0x82 /* ISO/IEC 9542 */
|
||||
#define NLPID_ISIS 0x83 /* ISO/IEC ISIS */
|
||||
#define NLPID_Q933 0x08 /* CCITT Q.933 */
|
||||
|
||||
/* Miscellaneous */
|
||||
#define WAN_IFNAME_SZ 15 /* max length of the interface name */
|
||||
#define WAN_DRVNAME_SZ 15 /* max length of the link driver name */
|
||||
#define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */
|
||||
#define USED_BY_FIELD 8 /* max length of the used by field */
|
||||
|
||||
/* Defines for UDP PACKET TYPE */
|
||||
#define UDP_PTPIPE_TYPE 0x01
|
||||
#define UDP_FPIPE_TYPE 0x02
|
||||
#define UDP_CPIPE_TYPE 0x03
|
||||
#define UDP_DRVSTATS_TYPE 0x04
|
||||
#define UDP_INVALID_TYPE 0x05
|
||||
|
||||
/* Command return code */
|
||||
#define CMD_OK 0 /* normal firmware return code */
|
||||
#define CMD_TIMEOUT 0xFF /* firmware command timed out */
|
||||
|
||||
/* UDP Packet Management */
|
||||
#define UDP_PKT_FRM_STACK 0x00
|
||||
#define UDP_PKT_FRM_NETWORK 0x01
|
||||
|
||||
/* Maximum interrupt test counter */
|
||||
#define MAX_INTR_TEST_COUNTER 100
|
||||
|
||||
/* Critical Values for RACE conditions*/
|
||||
#define CRITICAL_IN_ISR 0xA1
|
||||
#define CRITICAL_INTR_HANDLED 0xB1
|
||||
|
||||
/****** Data Types **********************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* X.25-specific link-level configuration.
|
||||
*/
|
||||
typedef struct wan_x25_conf
|
||||
{
|
||||
unsigned lo_pvc; /* lowest permanent circuit number */
|
||||
unsigned hi_pvc; /* highest permanent circuit number */
|
||||
unsigned lo_svc; /* lowest switched circuit number */
|
||||
unsigned hi_svc; /* highest switched circuit number */
|
||||
unsigned hdlc_window; /* HDLC window size (1..7) */
|
||||
unsigned pkt_window; /* X.25 packet window size (1..7) */
|
||||
unsigned t1; /* HDLC timer T1, sec (1..30) */
|
||||
unsigned t2; /* HDLC timer T2, sec (0..29) */
|
||||
unsigned t4; /* HDLC supervisory frame timer = T4 * T1 */
|
||||
unsigned n2; /* HDLC retransmission limit (1..30) */
|
||||
unsigned t10_t20; /* X.25 RESTART timeout, sec (1..255) */
|
||||
unsigned t11_t21; /* X.25 CALL timeout, sec (1..255) */
|
||||
unsigned t12_t22; /* X.25 RESET timeout, sec (1..255) */
|
||||
unsigned t13_t23; /* X.25 CLEAR timeout, sec (1..255) */
|
||||
unsigned t16_t26; /* X.25 INTERRUPT timeout, sec (1..255) */
|
||||
unsigned t28; /* X.25 REGISTRATION timeout, sec (1..255) */
|
||||
unsigned r10_r20; /* RESTART retransmission limit (0..250) */
|
||||
unsigned r12_r22; /* RESET retransmission limit (0..250) */
|
||||
unsigned r13_r23; /* CLEAR retransmission limit (0..250) */
|
||||
unsigned ccitt_compat; /* compatibility mode: 1988/1984/1980 */
|
||||
unsigned x25_conf_opt; /* User defined x25 config optoins */
|
||||
unsigned char LAPB_hdlc_only; /* Run in HDLC only mode */
|
||||
unsigned char logging; /* Control connection logging */
|
||||
unsigned char oob_on_modem; /* Whether to send modem status to the user app */
|
||||
} wan_x25_conf_t;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Frame relay specific link-level configuration.
|
||||
*/
|
||||
typedef struct wan_fr_conf
|
||||
{
|
||||
unsigned signalling; /* local in-channel signalling type */
|
||||
unsigned t391; /* link integrity verification timer */
|
||||
unsigned t392; /* polling verification timer */
|
||||
unsigned n391; /* full status polling cycle counter */
|
||||
unsigned n392; /* error threshold counter */
|
||||
unsigned n393; /* monitored events counter */
|
||||
unsigned dlci_num; /* number of DLCs (access node) */
|
||||
unsigned dlci[100]; /* List of all DLCIs */
|
||||
} wan_fr_conf_t;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* PPP-specific link-level configuration.
|
||||
*/
|
||||
typedef struct wan_ppp_conf
|
||||
{
|
||||
unsigned restart_tmr; /* restart timer */
|
||||
unsigned auth_rsrt_tmr; /* authentication timer */
|
||||
unsigned auth_wait_tmr; /* authentication timer */
|
||||
unsigned mdm_fail_tmr; /* modem failure timer */
|
||||
unsigned dtr_drop_tmr; /* DTR drop timer */
|
||||
unsigned connect_tmout; /* connection timeout */
|
||||
unsigned conf_retry; /* max. retry */
|
||||
unsigned term_retry; /* max. retry */
|
||||
unsigned fail_retry; /* max. retry */
|
||||
unsigned auth_retry; /* max. retry */
|
||||
unsigned auth_options; /* authentication opt. */
|
||||
unsigned ip_options; /* IP options */
|
||||
char authenticator; /* AUTHENTICATOR or not */
|
||||
char ip_mode; /* Static/Host/Peer */
|
||||
} wan_ppp_conf_t;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* CHDLC-specific link-level configuration.
|
||||
*/
|
||||
typedef struct wan_chdlc_conf
|
||||
{
|
||||
unsigned char ignore_dcd; /* Protocol options: */
|
||||
unsigned char ignore_cts; /* Ignore these to determine */
|
||||
unsigned char ignore_keepalive; /* link status (Yes or No) */
|
||||
unsigned char hdlc_streaming; /* hdlc_streaming mode (Y/N) */
|
||||
unsigned char receive_only; /* no transmit buffering (Y/N) */
|
||||
unsigned keepalive_tx_tmr; /* transmit keepalive timer */
|
||||
unsigned keepalive_rx_tmr; /* receive keepalive timer */
|
||||
unsigned keepalive_err_margin; /* keepalive_error_tolerance */
|
||||
unsigned slarp_timer; /* SLARP request timer */
|
||||
} wan_chdlc_conf_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* WAN device configuration. Passed to ROUTER_SETUP IOCTL.
|
||||
*/
|
||||
typedef struct wandev_conf
|
||||
{
|
||||
unsigned magic; /* magic number (for verification) */
|
||||
unsigned config_id; /* configuration structure identifier */
|
||||
/****** hardware configuration ******/
|
||||
unsigned ioport; /* adapter I/O port base */
|
||||
unsigned long maddr; /* dual-port memory address */
|
||||
unsigned msize; /* dual-port memory size */
|
||||
int irq; /* interrupt request level */
|
||||
int dma; /* DMA request level */
|
||||
char S514_CPU_no[1]; /* S514 PCI adapter CPU number ('A' or 'B') */
|
||||
unsigned PCI_slot_no; /* S514 PCI adapter slot number */
|
||||
char auto_pci_cfg; /* S515 PCI automatic slot detection */
|
||||
char comm_port; /* Communication Port (PRI=0, SEC=1) */
|
||||
unsigned bps; /* data transfer rate */
|
||||
unsigned mtu; /* maximum transmit unit size */
|
||||
unsigned udp_port; /* UDP port for management */
|
||||
unsigned char ttl; /* Time To Live for UDP security */
|
||||
unsigned char ft1; /* FT1 Configurator Option */
|
||||
char interface; /* RS-232/V.35, etc. */
|
||||
char clocking; /* external/internal */
|
||||
char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
|
||||
char station; /* DTE/DCE, primary/secondary, etc. */
|
||||
char connection; /* permanent/switched/on-demand */
|
||||
char read_mode; /* read mode: Polling or interrupt */
|
||||
char receive_only; /* disable tx buffers */
|
||||
char tty; /* Create a fake tty device */
|
||||
unsigned tty_major; /* Major number for wanpipe tty device */
|
||||
unsigned tty_minor; /* Minor number for wanpipe tty device */
|
||||
unsigned tty_mode; /* TTY operation mode SYNC or ASYNC */
|
||||
char backup; /* Backup Mode */
|
||||
unsigned hw_opt[4]; /* other hardware options */
|
||||
unsigned reserved[4];
|
||||
/****** arbitrary data ***************/
|
||||
unsigned data_size; /* data buffer size */
|
||||
void* data; /* data buffer, e.g. firmware */
|
||||
union /****** protocol-specific ************/
|
||||
{
|
||||
wan_x25_conf_t x25; /* X.25 configuration */
|
||||
wan_ppp_conf_t ppp; /* PPP configuration */
|
||||
wan_fr_conf_t fr; /* frame relay configuration */
|
||||
wan_chdlc_conf_t chdlc; /* Cisco HDLC configuration */
|
||||
} u;
|
||||
} wandev_conf_t;
|
||||
|
||||
/* 'config_id' definitions */
|
||||
#define WANCONFIG_X25 101 /* X.25 link */
|
||||
#define WANCONFIG_FR 102 /* frame relay link */
|
||||
#define WANCONFIG_PPP 103 /* synchronous PPP link */
|
||||
#define WANCONFIG_CHDLC 104 /* Cisco HDLC Link */
|
||||
#define WANCONFIG_BSC 105 /* BiSync Streaming */
|
||||
#define WANCONFIG_HDLC 106 /* HDLC Support */
|
||||
#define WANCONFIG_MPPP 107 /* Multi Port PPP over RAW CHDLC */
|
||||
|
||||
/*
|
||||
* Configuration options defines.
|
||||
*/
|
||||
/* general options */
|
||||
#define WANOPT_OFF 0
|
||||
#define WANOPT_ON 1
|
||||
#define WANOPT_NO 0
|
||||
#define WANOPT_YES 1
|
||||
|
||||
/* intercace options */
|
||||
#define WANOPT_RS232 0
|
||||
#define WANOPT_V35 1
|
||||
|
||||
/* data encoding options */
|
||||
#define WANOPT_NRZ 0
|
||||
#define WANOPT_NRZI 1
|
||||
#define WANOPT_FM0 2
|
||||
#define WANOPT_FM1 3
|
||||
|
||||
/* link type options */
|
||||
#define WANOPT_POINTTOPOINT 0 /* RTS always active */
|
||||
#define WANOPT_MULTIDROP 1 /* RTS is active when transmitting */
|
||||
|
||||
/* clocking options */
|
||||
#define WANOPT_EXTERNAL 0
|
||||
#define WANOPT_INTERNAL 1
|
||||
|
||||
/* station options */
|
||||
#define WANOPT_DTE 0
|
||||
#define WANOPT_DCE 1
|
||||
#define WANOPT_CPE 0
|
||||
#define WANOPT_NODE 1
|
||||
#define WANOPT_SECONDARY 0
|
||||
#define WANOPT_PRIMARY 1
|
||||
|
||||
/* connection options */
|
||||
#define WANOPT_PERMANENT 0 /* DTR always active */
|
||||
#define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */
|
||||
#define WANOPT_ONDEMAND 2 /* activate DTR only before sending */
|
||||
|
||||
/* frame relay in-channel signalling */
|
||||
#define WANOPT_FR_ANSI 1 /* ANSI T1.617 Annex D */
|
||||
#define WANOPT_FR_Q933 2 /* ITU Q.933A */
|
||||
#define WANOPT_FR_LMI 3 /* LMI */
|
||||
|
||||
/* PPP IP Mode Options */
|
||||
#define WANOPT_PPP_STATIC 0
|
||||
#define WANOPT_PPP_HOST 1
|
||||
#define WANOPT_PPP_PEER 2
|
||||
|
||||
/* ASY Mode Options */
|
||||
#define WANOPT_ONE 1
|
||||
#define WANOPT_TWO 2
|
||||
#define WANOPT_ONE_AND_HALF 3
|
||||
|
||||
#define WANOPT_NONE 0
|
||||
#define WANOPT_ODD 1
|
||||
#define WANOPT_EVEN 2
|
||||
|
||||
/* CHDLC Protocol Options */
|
||||
/* DF Commented out for now.
|
||||
|
||||
#define WANOPT_CHDLC_NO_DCD IGNORE_DCD_FOR_LINK_STAT
|
||||
#define WANOPT_CHDLC_NO_CTS IGNORE_CTS_FOR_LINK_STAT
|
||||
#define WANOPT_CHDLC_NO_KEEPALIVE IGNORE_KPALV_FOR_LINK_STAT
|
||||
*/
|
||||
|
||||
/* Port options */
|
||||
#define WANOPT_PRI 0
|
||||
#define WANOPT_SEC 1
|
||||
/* read mode */
|
||||
#define WANOPT_INTR 0
|
||||
#define WANOPT_POLL 1
|
||||
|
||||
|
||||
#define WANOPT_TTY_SYNC 0
|
||||
#define WANOPT_TTY_ASYNC 1
|
||||
/*----------------------------------------------------------------------------
|
||||
* WAN Link Status Info (for ROUTER_STAT IOCTL).
|
||||
*/
|
||||
typedef struct wandev_stat
|
||||
{
|
||||
unsigned state; /* link state */
|
||||
unsigned ndev; /* number of configured interfaces */
|
||||
|
||||
/* link/interface configuration */
|
||||
unsigned connection; /* permanent/switched/on-demand */
|
||||
unsigned media_type; /* Frame relay/PPP/X.25/SDLC, etc. */
|
||||
unsigned mtu; /* max. transmit unit for this device */
|
||||
|
||||
/* physical level statistics */
|
||||
unsigned modem_status; /* modem status */
|
||||
unsigned rx_frames; /* received frames count */
|
||||
unsigned rx_overruns; /* receiver overrun error count */
|
||||
unsigned rx_crc_err; /* receive CRC error count */
|
||||
unsigned rx_aborts; /* received aborted frames count */
|
||||
unsigned rx_bad_length; /* unexpetedly long/short frames count */
|
||||
unsigned rx_dropped; /* frames discarded at device level */
|
||||
unsigned tx_frames; /* transmitted frames count */
|
||||
unsigned tx_underruns; /* aborted transmissions (underruns) count */
|
||||
unsigned tx_timeouts; /* transmission timeouts */
|
||||
unsigned tx_rejects; /* other transmit errors */
|
||||
|
||||
/* media level statistics */
|
||||
unsigned rx_bad_format; /* frames with invalid format */
|
||||
unsigned rx_bad_addr; /* frames with invalid media address */
|
||||
unsigned tx_retries; /* frames re-transmitted */
|
||||
unsigned reserved[16]; /* reserved for future use */
|
||||
} wandev_stat_t;
|
||||
|
||||
/* 'state' defines */
|
||||
enum wan_states
|
||||
{
|
||||
WAN_UNCONFIGURED, /* link/channel is not configured */
|
||||
WAN_DISCONNECTED, /* link/channel is disconnected */
|
||||
WAN_CONNECTING, /* connection is in progress */
|
||||
WAN_CONNECTED, /* link/channel is operational */
|
||||
WAN_LIMIT, /* for verification only */
|
||||
WAN_DUALPORT, /* for Dual Port cards */
|
||||
WAN_DISCONNECTING,
|
||||
WAN_FT1_READY /* FT1 Configurator Ready */
|
||||
WAN_CONNECTED /* link/channel is operational */
|
||||
};
|
||||
|
||||
enum {
|
||||
WAN_LOCAL_IP,
|
||||
WAN_POINTOPOINT_IP,
|
||||
WAN_NETMASK_IP,
|
||||
WAN_BROADCAST_IP
|
||||
};
|
||||
|
||||
/* 'modem_status' masks */
|
||||
#define WAN_MODEM_CTS 0x0001 /* CTS line active */
|
||||
#define WAN_MODEM_DCD 0x0002 /* DCD line active */
|
||||
#define WAN_MODEM_DTR 0x0010 /* DTR line active */
|
||||
#define WAN_MODEM_RTS 0x0020 /* RTS line active */
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL).
|
||||
*/
|
||||
typedef struct wanif_conf
|
||||
{
|
||||
unsigned magic; /* magic number */
|
||||
unsigned config_id; /* configuration identifier */
|
||||
char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
|
||||
char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */
|
||||
char usedby[USED_BY_FIELD]; /* used by API or WANPIPE */
|
||||
unsigned idle_timeout; /* sec, before disconnecting */
|
||||
unsigned hold_timeout; /* sec, before re-connecting */
|
||||
unsigned cir; /* Committed Information Rate fwd,bwd*/
|
||||
unsigned bc; /* Committed Burst Size fwd, bwd */
|
||||
unsigned be; /* Excess Burst Size fwd, bwd */
|
||||
unsigned char enable_IPX; /* Enable or Disable IPX */
|
||||
unsigned char inarp; /* Send Inverse ARP requests Y/N */
|
||||
unsigned inarp_interval; /* sec, between InARP requests */
|
||||
unsigned long network_number; /* Network Number for IPX */
|
||||
char mc; /* Multicast on or off */
|
||||
char local_addr[WAN_ADDRESS_SZ+1];/* local media address, ASCIIZ */
|
||||
unsigned char port; /* board port */
|
||||
unsigned char protocol; /* prococol used in this channel (TCPOX25 or X25) */
|
||||
char pap; /* PAP enabled or disabled */
|
||||
char chap; /* CHAP enabled or disabled */
|
||||
unsigned char userid[511]; /* List of User Id */
|
||||
unsigned char passwd[511]; /* List of passwords */
|
||||
unsigned char sysname[31]; /* Name of the system */
|
||||
unsigned char ignore_dcd; /* Protocol options: */
|
||||
unsigned char ignore_cts; /* Ignore these to determine */
|
||||
unsigned char ignore_keepalive; /* link status (Yes or No) */
|
||||
unsigned char hdlc_streaming; /* Hdlc streaming mode (Y/N) */
|
||||
unsigned keepalive_tx_tmr; /* transmit keepalive timer */
|
||||
unsigned keepalive_rx_tmr; /* receive keepalive timer */
|
||||
unsigned keepalive_err_margin; /* keepalive_error_tolerance */
|
||||
unsigned slarp_timer; /* SLARP request timer */
|
||||
unsigned char ttl; /* Time To Live for UDP security */
|
||||
char interface; /* RS-232/V.35, etc. */
|
||||
char clocking; /* external/internal */
|
||||
unsigned bps; /* data transfer rate */
|
||||
unsigned mtu; /* maximum transmit unit size */
|
||||
unsigned char if_down; /* brind down interface when disconnected */
|
||||
unsigned char gateway; /* Is this interface a gateway */
|
||||
unsigned char true_if_encoding; /* Set the dev->type to true board protocol */
|
||||
|
||||
unsigned char asy_data_trans; /* async API options */
|
||||
unsigned char rts_hs_for_receive; /* async Protocol options */
|
||||
unsigned char xon_xoff_hs_for_receive;
|
||||
unsigned char xon_xoff_hs_for_transmit;
|
||||
unsigned char dcd_hs_for_transmit;
|
||||
unsigned char cts_hs_for_transmit;
|
||||
unsigned char async_mode;
|
||||
unsigned tx_bits_per_char;
|
||||
unsigned rx_bits_per_char;
|
||||
unsigned stop_bits;
|
||||
unsigned char parity;
|
||||
unsigned break_timer;
|
||||
unsigned inter_char_timer;
|
||||
unsigned rx_complete_length;
|
||||
unsigned xon_char;
|
||||
unsigned xoff_char;
|
||||
unsigned char receive_only; /* no transmit buffering (Y/N) */
|
||||
} wanif_conf_t;
|
||||
|
||||
#endif /* _UAPI_ROUTER_H */
|
||||
|
@ -209,7 +209,6 @@ source "net/ipx/Kconfig"
|
||||
source "drivers/net/appletalk/Kconfig"
|
||||
source "net/x25/Kconfig"
|
||||
source "net/lapb/Kconfig"
|
||||
source "net/wanrouter/Kconfig"
|
||||
source "net/phonet/Kconfig"
|
||||
source "net/ieee802154/Kconfig"
|
||||
source "net/mac802154/Kconfig"
|
||||
|
@ -26,7 +26,6 @@ obj-$(CONFIG_BRIDGE) += bridge/
|
||||
obj-$(CONFIG_NET_DSA) += dsa/
|
||||
obj-$(CONFIG_IPX) += ipx/
|
||||
obj-$(CONFIG_ATALK) += appletalk/
|
||||
obj-$(CONFIG_WAN_ROUTER) += wanrouter/
|
||||
obj-$(CONFIG_X25) += x25/
|
||||
obj-$(CONFIG_LAPB) += lapb/
|
||||
obj-$(CONFIG_NETROM) += netrom/
|
||||
|
@ -69,7 +69,6 @@
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/wanrouter.h>
|
||||
#include <linux/if_bridge.h>
|
||||
#include <linux/if_frad.h>
|
||||
#include <linux/if_vlan.h>
|
||||
|
@ -1,27 +0,0 @@
|
||||
#
|
||||
# Configuration for WAN router
|
||||
#
|
||||
|
||||
config WAN_ROUTER
|
||||
tristate "WAN router (DEPRECATED)"
|
||||
depends on EXPERIMENTAL
|
||||
---help---
|
||||
Wide Area Networks (WANs), such as X.25, frame relay and leased
|
||||
lines, are used to interconnect Local Area Networks (LANs) over vast
|
||||
distances with data transfer rates significantly higher than those
|
||||
achievable with commonly used asynchronous modem connections.
|
||||
Usually, a quite expensive external device called a `WAN router' is
|
||||
needed to connect to a WAN.
|
||||
|
||||
As an alternative, WAN routing can be built into the Linux kernel.
|
||||
With relatively inexpensive WAN interface cards available on the
|
||||
market, a perfectly usable router can be built for less than half
|
||||
the price of an external router. If you have one of those cards and
|
||||
wish to use your Linux box as a WAN router, say Y here and also to
|
||||
the WAN driver for your card, below. You will then need the
|
||||
wan-tools package which is available from <ftp://ftp.sangoma.com/>.
|
||||
|
||||
To compile WAN routing support as a module, choose M here: the
|
||||
module will be called wanrouter.
|
||||
|
||||
If unsure, say N.
|
@ -1,7 +0,0 @@
|
||||
#
|
||||
# Makefile for the Linux WAN router layer.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_WAN_ROUTER) += wanrouter.o
|
||||
|
||||
wanrouter-y := wanproc.o wanmain.o
|
@ -1 +0,0 @@
|
||||
2.2.1
|
@ -1,782 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* wanmain.c WAN Multiprotocol Router Module. Main code.
|
||||
*
|
||||
* This module is completely hardware-independent and provides
|
||||
* the following common services for the WAN Link Drivers:
|
||||
* o WAN device management (registering, unregistering)
|
||||
* o Network interface management
|
||||
* o Physical connection management (dial-up, incoming calls)
|
||||
* o Logical connection management (switched virtual circuits)
|
||||
* o Protocol encapsulation/decapsulation
|
||||
*
|
||||
* Author: Gideon Hack
|
||||
*
|
||||
* Copyright: (c) 1995-1999 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.
|
||||
* ============================================================================
|
||||
* Nov 24, 2000 Nenad Corbic Updated for 2.4.X kernels
|
||||
* Nov 07, 2000 Nenad Corbic Fixed the Mulit-Port PPP for kernels 2.2.16 and
|
||||
* greater.
|
||||
* Aug 2, 2000 Nenad Corbic Block the Multi-Port PPP from running on
|
||||
* kernels 2.2.16 or greater. The SyncPPP
|
||||
* has changed.
|
||||
* Jul 13, 2000 Nenad Corbic Added SyncPPP support
|
||||
* Added extra debugging in device_setup().
|
||||
* Oct 01, 1999 Gideon Hack Update for s514 PCI card
|
||||
* Dec 27, 1996 Gene Kozin Initial version (based on Sangoma's WANPIPE)
|
||||
* Jan 16, 1997 Gene Kozin router_devlist made public
|
||||
* Jan 31, 1997 Alan Cox Hacked it about a bit for 2.1
|
||||
* Jun 27, 1997 Alan Cox realigned with vendor code
|
||||
* Oct 15, 1997 Farhan Thawar changed wan_encapsulate to add a pad byte of 0
|
||||
* Apr 20, 1998 Alan Cox Fixed 2.1 symbols
|
||||
* May 17, 1998 K. Baranowski Fixed SNAP encapsulation in wan_encapsulate
|
||||
* Dec 15, 1998 Arnaldo Melo support for firmwares of up to 128000 bytes
|
||||
* check wandev->setup return value
|
||||
* Dec 22, 1998 Arnaldo Melo vmalloc/vfree used in device_setup to allocate
|
||||
* kernel memory and copy configuration data to
|
||||
* kernel space (for big firmwares)
|
||||
* Jun 02, 1999 Gideon Hack Updates for Linux 2.0.X and 2.2.X kernels.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/stddef.h> /* offsetof(), etc. */
|
||||
#include <linux/capability.h>
|
||||
#include <linux/errno.h> /* return codes */
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h> /* support for loadable modules */
|
||||
#include <linux/slab.h> /* kmalloc(), kfree() */
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/string.h> /* inline mem*, str* functions */
|
||||
|
||||
#include <asm/byteorder.h> /* htons(), etc. */
|
||||
#include <linux/wanrouter.h> /* WAN router API definitions */
|
||||
|
||||
#include <linux/vmalloc.h> /* vmalloc, vfree */
|
||||
#include <asm/uaccess.h> /* copy_to/from_user */
|
||||
#include <linux/init.h> /* __initfunc et al. */
|
||||
|
||||
#define DEV_TO_SLAVE(dev) (*((struct net_device **)netdev_priv(dev)))
|
||||
|
||||
/*
|
||||
* Function Prototypes
|
||||
*/
|
||||
|
||||
/*
|
||||
* WAN device IOCTL handlers
|
||||
*/
|
||||
|
||||
static DEFINE_MUTEX(wanrouter_mutex);
|
||||
static int wanrouter_device_setup(struct wan_device *wandev,
|
||||
wandev_conf_t __user *u_conf);
|
||||
static int wanrouter_device_stat(struct wan_device *wandev,
|
||||
wandev_stat_t __user *u_stat);
|
||||
static int wanrouter_device_shutdown(struct wan_device *wandev);
|
||||
static int wanrouter_device_new_if(struct wan_device *wandev,
|
||||
wanif_conf_t __user *u_conf);
|
||||
static int wanrouter_device_del_if(struct wan_device *wandev,
|
||||
char __user *u_name);
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
static struct wan_device *wanrouter_find_device(char *name);
|
||||
static int wanrouter_delete_interface(struct wan_device *wandev, char *name);
|
||||
static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
|
||||
__acquires(lock);
|
||||
static void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
|
||||
__releases(lock);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Global Data
|
||||
*/
|
||||
|
||||
static char wanrouter_fullname[] = "Sangoma WANPIPE Router";
|
||||
static char wanrouter_copyright[] = "(c) 1995-2000 Sangoma Technologies Inc.";
|
||||
static char wanrouter_modname[] = ROUTER_NAME; /* short module name */
|
||||
struct wan_device* wanrouter_router_devlist; /* list of registered devices */
|
||||
|
||||
/*
|
||||
* Organize Unique Identifiers for encapsulation/decapsulation
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static unsigned char wanrouter_oui_ether[] = { 0x00, 0x00, 0x00 };
|
||||
static unsigned char wanrouter_oui_802_2[] = { 0x00, 0x80, 0xC2 };
|
||||
#endif
|
||||
|
||||
static int __init wanrouter_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
printk(KERN_INFO "%s v%u.%u %s\n",
|
||||
wanrouter_fullname, ROUTER_VERSION, ROUTER_RELEASE,
|
||||
wanrouter_copyright);
|
||||
|
||||
err = wanrouter_proc_init();
|
||||
if (err)
|
||||
printk(KERN_INFO "%s: can't create entry in proc filesystem!\n",
|
||||
wanrouter_modname);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __exit wanrouter_cleanup (void)
|
||||
{
|
||||
wanrouter_proc_cleanup();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is just plain dumb. We should move the bugger to drivers/net/wan,
|
||||
* slap it first in directory and make it module_init(). The only reason
|
||||
* for subsys_initcall() here is that net goes after drivers (why, BTW?)
|
||||
*/
|
||||
subsys_initcall(wanrouter_init);
|
||||
module_exit(wanrouter_cleanup);
|
||||
|
||||
/*
|
||||
* Kernel APIs
|
||||
*/
|
||||
|
||||
/*
|
||||
* Register WAN device.
|
||||
* o verify device credentials
|
||||
* o create an entry for the device in the /proc/net/router directory
|
||||
* o initialize internally maintained fields of the wan_device structure
|
||||
* o link device data space to a singly-linked list
|
||||
* o if it's the first device, then start kernel 'thread'
|
||||
* o increment module use count
|
||||
*
|
||||
* Return:
|
||||
* 0 Ok
|
||||
* < 0 error.
|
||||
*
|
||||
* Context: process
|
||||
*/
|
||||
|
||||
|
||||
int register_wan_device(struct wan_device *wandev)
|
||||
{
|
||||
int err, namelen;
|
||||
|
||||
if ((wandev == NULL) || (wandev->magic != ROUTER_MAGIC) ||
|
||||
(wandev->name == NULL))
|
||||
return -EINVAL;
|
||||
|
||||
namelen = strlen(wandev->name);
|
||||
if (!namelen || (namelen > WAN_DRVNAME_SZ))
|
||||
return -EINVAL;
|
||||
|
||||
if (wanrouter_find_device(wandev->name))
|
||||
return -EEXIST;
|
||||
|
||||
#ifdef WANDEBUG
|
||||
printk(KERN_INFO "%s: registering WAN device %s\n",
|
||||
wanrouter_modname, wandev->name);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Register /proc directory entry
|
||||
*/
|
||||
err = wanrouter_proc_add(wandev);
|
||||
if (err) {
|
||||
printk(KERN_INFO
|
||||
"%s: can't create /proc/net/router/%s entry!\n",
|
||||
wanrouter_modname, wandev->name);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize fields of the wan_device structure maintained by the
|
||||
* router and update local data.
|
||||
*/
|
||||
|
||||
wandev->ndev = 0;
|
||||
wandev->dev = NULL;
|
||||
wandev->next = wanrouter_router_devlist;
|
||||
wanrouter_router_devlist = wandev;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unregister WAN device.
|
||||
* o shut down device
|
||||
* o unlink device data space from the linked list
|
||||
* o delete device entry in the /proc/net/router directory
|
||||
* o decrement module use count
|
||||
*
|
||||
* Return: 0 Ok
|
||||
* <0 error.
|
||||
* Context: process
|
||||
*/
|
||||
|
||||
|
||||
int unregister_wan_device(char *name)
|
||||
{
|
||||
struct wan_device *wandev, *prev;
|
||||
|
||||
if (name == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
for (wandev = wanrouter_router_devlist, prev = NULL;
|
||||
wandev && strcmp(wandev->name, name);
|
||||
prev = wandev, wandev = wandev->next)
|
||||
;
|
||||
if (wandev == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
#ifdef WANDEBUG
|
||||
printk(KERN_INFO "%s: unregistering WAN device %s\n",
|
||||
wanrouter_modname, name);
|
||||
#endif
|
||||
|
||||
if (wandev->state != WAN_UNCONFIGURED)
|
||||
wanrouter_device_shutdown(wandev);
|
||||
|
||||
if (prev)
|
||||
prev->next = wandev->next;
|
||||
else
|
||||
wanrouter_router_devlist = wandev->next;
|
||||
|
||||
wanrouter_proc_delete(wandev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* Encapsulate packet.
|
||||
*
|
||||
* Return: encapsulation header size
|
||||
* < 0 - unsupported Ethertype
|
||||
*
|
||||
* Notes:
|
||||
* 1. This function may be called on interrupt context.
|
||||
*/
|
||||
|
||||
|
||||
int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type)
|
||||
{
|
||||
int hdr_len = 0;
|
||||
|
||||
switch (type) {
|
||||
case ETH_P_IP: /* IP datagram encapsulation */
|
||||
hdr_len += 1;
|
||||
skb_push(skb, 1);
|
||||
skb->data[0] = NLPID_IP;
|
||||
break;
|
||||
|
||||
case ETH_P_IPX: /* SNAP encapsulation */
|
||||
case ETH_P_ARP:
|
||||
hdr_len += 7;
|
||||
skb_push(skb, 7);
|
||||
skb->data[0] = 0;
|
||||
skb->data[1] = NLPID_SNAP;
|
||||
skb_copy_to_linear_data_offset(skb, 2, wanrouter_oui_ether,
|
||||
sizeof(wanrouter_oui_ether));
|
||||
*((unsigned short*)&skb->data[5]) = htons(type);
|
||||
break;
|
||||
|
||||
default: /* Unknown packet type */
|
||||
printk(KERN_INFO
|
||||
"%s: unsupported Ethertype 0x%04X on interface %s!\n",
|
||||
wanrouter_modname, type, dev->name);
|
||||
hdr_len = -EINVAL;
|
||||
}
|
||||
return hdr_len;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decapsulate packet.
|
||||
*
|
||||
* Return: Ethertype (in network order)
|
||||
* 0 unknown encapsulation
|
||||
*
|
||||
* Notes:
|
||||
* 1. This function may be called on interrupt context.
|
||||
*/
|
||||
|
||||
|
||||
__be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
int cnt = skb->data[0] ? 0 : 1; /* there may be a pad present */
|
||||
__be16 ethertype;
|
||||
|
||||
switch (skb->data[cnt]) {
|
||||
case NLPID_IP: /* IP datagramm */
|
||||
ethertype = htons(ETH_P_IP);
|
||||
cnt += 1;
|
||||
break;
|
||||
|
||||
case NLPID_SNAP: /* SNAP encapsulation */
|
||||
if (memcmp(&skb->data[cnt + 1], wanrouter_oui_ether,
|
||||
sizeof(wanrouter_oui_ether))){
|
||||
printk(KERN_INFO
|
||||
"%s: unsupported SNAP OUI %02X-%02X-%02X "
|
||||
"on interface %s!\n", wanrouter_modname,
|
||||
skb->data[cnt+1], skb->data[cnt+2],
|
||||
skb->data[cnt+3], dev->name);
|
||||
return 0;
|
||||
}
|
||||
ethertype = *((__be16*)&skb->data[cnt+4]);
|
||||
cnt += 6;
|
||||
break;
|
||||
|
||||
/* add other protocols, e.g. CLNP, ESIS, ISIS, if needed */
|
||||
|
||||
default:
|
||||
printk(KERN_INFO
|
||||
"%s: unsupported NLPID 0x%02X on interface %s!\n",
|
||||
wanrouter_modname, skb->data[cnt], dev->name);
|
||||
return 0;
|
||||
}
|
||||
skb->protocol = ethertype;
|
||||
skb->pkt_type = PACKET_HOST; /* Physically point to point */
|
||||
skb_pull(skb, cnt);
|
||||
skb_reset_mac_header(skb);
|
||||
return ethertype;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
/*
|
||||
* WAN device IOCTL.
|
||||
* o find WAN device associated with this node
|
||||
* o execute requested action or pass command to the device driver
|
||||
*/
|
||||
|
||||
long wanrouter_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct inode *inode = file->f_path.dentry->d_inode;
|
||||
int err = 0;
|
||||
struct proc_dir_entry *dent;
|
||||
struct wan_device *wandev;
|
||||
void __user *data = (void __user *)arg;
|
||||
|
||||
if (!capable(CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if ((cmd >> 8) != ROUTER_IOCTL)
|
||||
return -EINVAL;
|
||||
|
||||
dent = PDE(inode);
|
||||
if ((dent == NULL) || (dent->data == NULL))
|
||||
return -EINVAL;
|
||||
|
||||
wandev = dent->data;
|
||||
if (wandev->magic != ROUTER_MAGIC)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&wanrouter_mutex);
|
||||
switch (cmd) {
|
||||
case ROUTER_SETUP:
|
||||
err = wanrouter_device_setup(wandev, data);
|
||||
break;
|
||||
|
||||
case ROUTER_DOWN:
|
||||
err = wanrouter_device_shutdown(wandev);
|
||||
break;
|
||||
|
||||
case ROUTER_STAT:
|
||||
err = wanrouter_device_stat(wandev, data);
|
||||
break;
|
||||
|
||||
case ROUTER_IFNEW:
|
||||
err = wanrouter_device_new_if(wandev, data);
|
||||
break;
|
||||
|
||||
case ROUTER_IFDEL:
|
||||
err = wanrouter_device_del_if(wandev, data);
|
||||
break;
|
||||
|
||||
case ROUTER_IFSTAT:
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((cmd >= ROUTER_USER) &&
|
||||
(cmd <= ROUTER_USER_MAX) &&
|
||||
wandev->ioctl)
|
||||
err = wandev->ioctl(wandev, cmd, arg);
|
||||
else err = -EINVAL;
|
||||
}
|
||||
mutex_unlock(&wanrouter_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* WAN Driver IOCTL Handlers
|
||||
*/
|
||||
|
||||
/*
|
||||
* Setup WAN link device.
|
||||
* o verify user address space
|
||||
* o allocate kernel memory and copy configuration data to kernel space
|
||||
* o if configuration data includes extension, copy it to kernel space too
|
||||
* o call driver's setup() entry point
|
||||
*/
|
||||
|
||||
static int wanrouter_device_setup(struct wan_device *wandev,
|
||||
wandev_conf_t __user *u_conf)
|
||||
{
|
||||
void *data = NULL;
|
||||
wandev_conf_t *conf;
|
||||
int err = -EINVAL;
|
||||
|
||||
if (wandev->setup == NULL) { /* Nothing to do ? */
|
||||
printk(KERN_INFO "%s: ERROR, No setup script: wandev->setup()\n",
|
||||
wandev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf = kmalloc(sizeof(wandev_conf_t), GFP_KERNEL);
|
||||
if (conf == NULL){
|
||||
printk(KERN_INFO "%s: ERROR, Failed to allocate kernel memory !\n",
|
||||
wandev->name);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
if (copy_from_user(conf, u_conf, sizeof(wandev_conf_t))) {
|
||||
printk(KERN_INFO "%s: Failed to copy user config data to kernel space!\n",
|
||||
wandev->name);
|
||||
kfree(conf);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (conf->magic != ROUTER_MAGIC) {
|
||||
kfree(conf);
|
||||
printk(KERN_INFO "%s: ERROR, Invalid MAGIC Number\n",
|
||||
wandev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (conf->data_size && conf->data) {
|
||||
if (conf->data_size > 128000) {
|
||||
printk(KERN_INFO
|
||||
"%s: ERROR, Invalid firmware data size %i !\n",
|
||||
wandev->name, conf->data_size);
|
||||
kfree(conf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data = vmalloc(conf->data_size);
|
||||
if (!data) {
|
||||
printk(KERN_INFO
|
||||
"%s: ERROR, Failed allocate kernel memory !\n",
|
||||
wandev->name);
|
||||
kfree(conf);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
if (!copy_from_user(data, conf->data, conf->data_size)) {
|
||||
conf->data = data;
|
||||
err = wandev->setup(wandev, conf);
|
||||
} else {
|
||||
printk(KERN_INFO
|
||||
"%s: ERROR, Failed to copy from user data !\n",
|
||||
wandev->name);
|
||||
err = -EFAULT;
|
||||
}
|
||||
vfree(data);
|
||||
} else {
|
||||
printk(KERN_INFO
|
||||
"%s: ERROR, No firmware found ! Firmware size = %i !\n",
|
||||
wandev->name, conf->data_size);
|
||||
}
|
||||
|
||||
kfree(conf);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown WAN device.
|
||||
* o delete all not opened logical channels for this device
|
||||
* o call driver's shutdown() entry point
|
||||
*/
|
||||
|
||||
static int wanrouter_device_shutdown(struct wan_device *wandev)
|
||||
{
|
||||
struct net_device *dev;
|
||||
int err=0;
|
||||
|
||||
if (wandev->state == WAN_UNCONFIGURED)
|
||||
return 0;
|
||||
|
||||
printk(KERN_INFO "\n%s: Shutting Down!\n",wandev->name);
|
||||
|
||||
for (dev = wandev->dev; dev;) {
|
||||
err = wanrouter_delete_interface(wandev, dev->name);
|
||||
if (err)
|
||||
return err;
|
||||
/* The above function deallocates the current dev
|
||||
* structure. Therefore, we cannot use netdev_priv(dev)
|
||||
* as the next element: wandev->dev points to the
|
||||
* next element */
|
||||
dev = wandev->dev;
|
||||
}
|
||||
|
||||
if (wandev->ndev)
|
||||
return -EBUSY; /* there are opened interfaces */
|
||||
|
||||
if (wandev->shutdown)
|
||||
err=wandev->shutdown(wandev);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get WAN device status & statistics.
|
||||
*/
|
||||
|
||||
static int wanrouter_device_stat(struct wan_device *wandev,
|
||||
wandev_stat_t __user *u_stat)
|
||||
{
|
||||
wandev_stat_t stat;
|
||||
|
||||
memset(&stat, 0, sizeof(stat));
|
||||
|
||||
/* Ask device driver to update device statistics */
|
||||
if ((wandev->state != WAN_UNCONFIGURED) && wandev->update)
|
||||
wandev->update(wandev);
|
||||
|
||||
/* Fill out structure */
|
||||
stat.ndev = wandev->ndev;
|
||||
stat.state = wandev->state;
|
||||
|
||||
if (copy_to_user(u_stat, &stat, sizeof(stat)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create new WAN interface.
|
||||
* o verify user address space
|
||||
* o copy configuration data to kernel address space
|
||||
* o allocate network interface data space
|
||||
* o call driver's new_if() entry point
|
||||
* o make sure there is no interface name conflict
|
||||
* o register network interface
|
||||
*/
|
||||
|
||||
static int wanrouter_device_new_if(struct wan_device *wandev,
|
||||
wanif_conf_t __user *u_conf)
|
||||
{
|
||||
wanif_conf_t *cnf;
|
||||
struct net_device *dev = NULL;
|
||||
int err;
|
||||
|
||||
if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL))
|
||||
return -ENODEV;
|
||||
|
||||
cnf = kmalloc(sizeof(wanif_conf_t), GFP_KERNEL);
|
||||
if (!cnf)
|
||||
return -ENOBUFS;
|
||||
|
||||
err = -EFAULT;
|
||||
if (copy_from_user(cnf, u_conf, sizeof(wanif_conf_t)))
|
||||
goto out;
|
||||
|
||||
err = -EINVAL;
|
||||
if (cnf->magic != ROUTER_MAGIC)
|
||||
goto out;
|
||||
|
||||
if (cnf->config_id == WANCONFIG_MPPP) {
|
||||
printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n",
|
||||
wandev->name);
|
||||
err = -EPROTONOSUPPORT;
|
||||
goto out;
|
||||
} else {
|
||||
err = wandev->new_if(wandev, dev, cnf);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
/* Register network interface. This will invoke init()
|
||||
* function supplied by the driver. If device registered
|
||||
* successfully, add it to the interface list.
|
||||
*/
|
||||
|
||||
#ifdef WANDEBUG
|
||||
printk(KERN_INFO "%s: registering interface %s...\n",
|
||||
wanrouter_modname, dev->name);
|
||||
#endif
|
||||
|
||||
err = register_netdev(dev);
|
||||
if (!err) {
|
||||
struct net_device *slave = NULL;
|
||||
unsigned long smp_flags=0;
|
||||
|
||||
lock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
|
||||
if (wandev->dev == NULL) {
|
||||
wandev->dev = dev;
|
||||
} else {
|
||||
for (slave=wandev->dev;
|
||||
DEV_TO_SLAVE(slave);
|
||||
slave = DEV_TO_SLAVE(slave))
|
||||
DEV_TO_SLAVE(slave) = dev;
|
||||
}
|
||||
++wandev->ndev;
|
||||
|
||||
unlock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
err = 0; /* done !!! */
|
||||
goto out;
|
||||
}
|
||||
if (wandev->del_if)
|
||||
wandev->del_if(wandev, dev);
|
||||
free_netdev(dev);
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(cnf);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete WAN logical channel.
|
||||
* o verify user address space
|
||||
* o copy configuration data to kernel address space
|
||||
*/
|
||||
|
||||
static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_name)
|
||||
{
|
||||
char name[WAN_IFNAME_SZ + 1];
|
||||
int err = 0;
|
||||
|
||||
if (wandev->state == WAN_UNCONFIGURED)
|
||||
return -ENODEV;
|
||||
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
if (copy_from_user(name, u_name, WAN_IFNAME_SZ))
|
||||
return -EFAULT;
|
||||
|
||||
err = wanrouter_delete_interface(wandev, name);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* If last interface being deleted, shutdown card
|
||||
* This helps with administration at leaf nodes
|
||||
* (You can tell if the person at the other end of the phone
|
||||
* has an interface configured) and avoids DoS vulnerabilities
|
||||
* in binary driver files - this fixes a problem with the current
|
||||
* Sangoma driver going into strange states when all the network
|
||||
* interfaces are deleted and the link irrecoverably disconnected.
|
||||
*/
|
||||
|
||||
if (!wandev->ndev && wandev->shutdown)
|
||||
err = wandev->shutdown(wandev);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Miscellaneous Functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Find WAN device by name.
|
||||
* Return pointer to the WAN device data space or NULL if device not found.
|
||||
*/
|
||||
|
||||
static struct wan_device *wanrouter_find_device(char *name)
|
||||
{
|
||||
struct wan_device *wandev;
|
||||
|
||||
for (wandev = wanrouter_router_devlist;
|
||||
wandev && strcmp(wandev->name, name);
|
||||
wandev = wandev->next);
|
||||
return wandev;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete WAN logical channel identified by its name.
|
||||
* o find logical channel by its name
|
||||
* o call driver's del_if() entry point
|
||||
* o unregister network interface
|
||||
* o unlink channel data space from linked list of channels
|
||||
* o release channel data space
|
||||
*
|
||||
* Return: 0 success
|
||||
* -ENODEV channel not found.
|
||||
* -EBUSY interface is open
|
||||
*
|
||||
* Note: If (force != 0), then device will be destroyed even if interface
|
||||
* associated with it is open. It's caller's responsibility to make
|
||||
* sure that opened interfaces are not removed!
|
||||
*/
|
||||
|
||||
static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
|
||||
{
|
||||
struct net_device *dev = NULL, *prev = NULL;
|
||||
unsigned long smp_flags=0;
|
||||
|
||||
lock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
dev = wandev->dev;
|
||||
prev = NULL;
|
||||
while (dev && strcmp(name, dev->name)) {
|
||||
struct net_device **slave = netdev_priv(dev);
|
||||
prev = dev;
|
||||
dev = *slave;
|
||||
}
|
||||
unlock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
|
||||
if (dev == NULL)
|
||||
return -ENODEV; /* interface not found */
|
||||
|
||||
if (netif_running(dev))
|
||||
return -EBUSY; /* interface in use */
|
||||
|
||||
if (wandev->del_if)
|
||||
wandev->del_if(wandev, dev);
|
||||
|
||||
lock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
if (prev) {
|
||||
struct net_device **prev_slave = netdev_priv(prev);
|
||||
struct net_device **slave = netdev_priv(dev);
|
||||
|
||||
*prev_slave = *slave;
|
||||
} else {
|
||||
struct net_device **slave = netdev_priv(dev);
|
||||
wandev->dev = *slave;
|
||||
}
|
||||
--wandev->ndev;
|
||||
unlock_adapter_irq(&wandev->lock, &smp_flags);
|
||||
|
||||
printk(KERN_INFO "%s: unregistering '%s'\n", wandev->name, dev->name);
|
||||
|
||||
unregister_netdev(dev);
|
||||
|
||||
free_netdev(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
|
||||
__acquires(lock)
|
||||
{
|
||||
spin_lock_irqsave(lock, *smp_flags);
|
||||
}
|
||||
|
||||
|
||||
static void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
|
||||
__releases(lock)
|
||||
{
|
||||
spin_unlock_irqrestore(lock, *smp_flags);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(register_wan_device);
|
||||
EXPORT_SYMBOL(unregister_wan_device);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
/*
|
||||
* End
|
||||
*/
|
@ -1,380 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* wanproc.c WAN Router Module. /proc filesystem interface.
|
||||
*
|
||||
* This module is completely hardware-independent and provides
|
||||
* access to the router using Linux /proc filesystem.
|
||||
*
|
||||
* Author: Gideon Hack
|
||||
*
|
||||
* Copyright: (c) 1995-1999 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.
|
||||
* ============================================================================
|
||||
* Jun 02, 1999 Gideon Hack Updates for Linux 2.2.X kernels.
|
||||
* Jun 29, 1997 Alan Cox Merged with 1.0.3 vendor code
|
||||
* Jan 29, 1997 Gene Kozin v1.0.1. Implemented /proc read routines
|
||||
* Jan 30, 1997 Alan Cox Hacked around for 2.1
|
||||
* Dec 13, 1996 Gene Kozin Initial version (based on Sangoma's WANPIPE)
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/init.h> /* __initfunc et al. */
|
||||
#include <linux/stddef.h> /* offsetof(), etc. */
|
||||
#include <linux/errno.h> /* return codes */
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/wanrouter.h> /* WAN router API definitions */
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include <net/net_namespace.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define PROC_STATS_FORMAT "%30s: %12lu\n"
|
||||
|
||||
/****** Defines and Macros **************************************************/
|
||||
|
||||
#define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\
|
||||
(prot == WANCONFIG_X25) ? " X25" : \
|
||||
(prot == WANCONFIG_PPP) ? " PPP" : \
|
||||
(prot == WANCONFIG_CHDLC) ? " CHDLC": \
|
||||
(prot == WANCONFIG_MPPP) ? " MPPP" : \
|
||||
" Unknown" )
|
||||
|
||||
/****** Function Prototypes *************************************************/
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
|
||||
/* Miscellaneous */
|
||||
|
||||
/*
|
||||
* Structures for interfacing with the /proc filesystem.
|
||||
* Router creates its own directory /proc/net/router with the following
|
||||
* entries:
|
||||
* config device configuration
|
||||
* status global device statistics
|
||||
* <device> entry for each WAN device
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generic /proc/net/router/<file> file and inode operations
|
||||
*/
|
||||
|
||||
/*
|
||||
* /proc/net/router
|
||||
*/
|
||||
|
||||
static DEFINE_MUTEX(config_mutex);
|
||||
static struct proc_dir_entry *proc_router;
|
||||
|
||||
/* Strings */
|
||||
|
||||
/*
|
||||
* Interface functions
|
||||
*/
|
||||
|
||||
/****** Proc filesystem entry points ****************************************/
|
||||
|
||||
/*
|
||||
* Iterator
|
||||
*/
|
||||
static void *r_start(struct seq_file *m, loff_t *pos)
|
||||
{
|
||||
struct wan_device *wandev;
|
||||
loff_t l = *pos;
|
||||
|
||||
mutex_lock(&config_mutex);
|
||||
if (!l--)
|
||||
return SEQ_START_TOKEN;
|
||||
for (wandev = wanrouter_router_devlist; l-- && wandev;
|
||||
wandev = wandev->next)
|
||||
;
|
||||
return wandev;
|
||||
}
|
||||
|
||||
static void *r_next(struct seq_file *m, void *v, loff_t *pos)
|
||||
{
|
||||
struct wan_device *wandev = v;
|
||||
(*pos)++;
|
||||
return (v == SEQ_START_TOKEN) ? wanrouter_router_devlist : wandev->next;
|
||||
}
|
||||
|
||||
static void r_stop(struct seq_file *m, void *v)
|
||||
{
|
||||
mutex_unlock(&config_mutex);
|
||||
}
|
||||
|
||||
static int config_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct wan_device *p = v;
|
||||
if (v == SEQ_START_TOKEN) {
|
||||
seq_puts(m, "Device name | port |IRQ|DMA| mem.addr |"
|
||||
"mem.size|option1|option2|option3|option4\n");
|
||||
return 0;
|
||||
}
|
||||
if (!p->state)
|
||||
return 0;
|
||||
seq_printf(m, "%-15s|0x%-4X|%3u|%3u| 0x%-8lX |0x%-6X|%7u|%7u|%7u|%7u\n",
|
||||
p->name, p->ioport, p->irq, p->dma, p->maddr, p->msize,
|
||||
p->hw_opt[0], p->hw_opt[1], p->hw_opt[2], p->hw_opt[3]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int status_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct wan_device *p = v;
|
||||
if (v == SEQ_START_TOKEN) {
|
||||
seq_puts(m, "Device name |protocol|station|interface|"
|
||||
"clocking|baud rate| MTU |ndev|link state\n");
|
||||
return 0;
|
||||
}
|
||||
if (!p->state)
|
||||
return 0;
|
||||
seq_printf(m, "%-15s|%-8s| %-7s| %-9s|%-8s|%9u|%5u|%3u |",
|
||||
p->name,
|
||||
PROT_DECODE(p->config_id),
|
||||
p->config_id == WANCONFIG_FR ?
|
||||
(p->station ? "Node" : "CPE") :
|
||||
(p->config_id == WANCONFIG_X25 ?
|
||||
(p->station ? "DCE" : "DTE") :
|
||||
("N/A")),
|
||||
p->interface ? "V.35" : "RS-232",
|
||||
p->clocking ? "internal" : "external",
|
||||
p->bps,
|
||||
p->mtu,
|
||||
p->ndev);
|
||||
|
||||
switch (p->state) {
|
||||
case WAN_UNCONFIGURED:
|
||||
seq_printf(m, "%-12s\n", "unconfigured");
|
||||
break;
|
||||
case WAN_DISCONNECTED:
|
||||
seq_printf(m, "%-12s\n", "disconnected");
|
||||
break;
|
||||
case WAN_CONNECTING:
|
||||
seq_printf(m, "%-12s\n", "connecting");
|
||||
break;
|
||||
case WAN_CONNECTED:
|
||||
seq_printf(m, "%-12s\n", "connected");
|
||||
break;
|
||||
default:
|
||||
seq_printf(m, "%-12s\n", "invalid");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct seq_operations config_op = {
|
||||
.start = r_start,
|
||||
.next = r_next,
|
||||
.stop = r_stop,
|
||||
.show = config_show,
|
||||
};
|
||||
|
||||
static const struct seq_operations status_op = {
|
||||
.start = r_start,
|
||||
.next = r_next,
|
||||
.stop = r_stop,
|
||||
.show = status_show,
|
||||
};
|
||||
|
||||
static int config_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return seq_open(file, &config_op);
|
||||
}
|
||||
|
||||
static int status_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return seq_open(file, &status_op);
|
||||
}
|
||||
|
||||
static const struct file_operations config_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = config_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release,
|
||||
};
|
||||
|
||||
static const struct file_operations status_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = status_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release,
|
||||
};
|
||||
|
||||
static int wandev_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct wan_device *wandev = m->private;
|
||||
|
||||
if (wandev->magic != ROUTER_MAGIC)
|
||||
return 0;
|
||||
|
||||
if (!wandev->state) {
|
||||
seq_puts(m, "device is not configured!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Update device statistics */
|
||||
if (wandev->update) {
|
||||
int err = wandev->update(wandev);
|
||||
if (err == -EAGAIN) {
|
||||
seq_puts(m, "Device is busy!\n");
|
||||
return 0;
|
||||
}
|
||||
if (err) {
|
||||
seq_puts(m, "Device is not configured!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"total packets received", wandev->stats.rx_packets);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"total packets transmitted", wandev->stats.tx_packets);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"total bytes received", wandev->stats.rx_bytes);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"total bytes transmitted", wandev->stats.tx_bytes);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"bad packets received", wandev->stats.rx_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"packet transmit problems", wandev->stats.tx_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"received frames dropped", wandev->stats.rx_dropped);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"transmit frames dropped", wandev->stats.tx_dropped);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"multicast packets received", wandev->stats.multicast);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"transmit collisions", wandev->stats.collisions);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"receive length errors", wandev->stats.rx_length_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"receiver overrun errors", wandev->stats.rx_over_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"CRC errors", wandev->stats.rx_crc_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"frame format errors (aborts)", wandev->stats.rx_frame_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"receiver fifo overrun", wandev->stats.rx_fifo_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"receiver missed packet", wandev->stats.rx_missed_errors);
|
||||
seq_printf(m, PROC_STATS_FORMAT,
|
||||
"aborted frames transmitted", wandev->stats.tx_aborted_errors);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wandev_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, wandev_show, PDE(inode)->data);
|
||||
}
|
||||
|
||||
static const struct file_operations wandev_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = wandev_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
.unlocked_ioctl = wanrouter_ioctl,
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize router proc interface.
|
||||
*/
|
||||
|
||||
int __init wanrouter_proc_init(void)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
proc_router = proc_mkdir(ROUTER_NAME, init_net.proc_net);
|
||||
if (!proc_router)
|
||||
goto fail;
|
||||
|
||||
p = proc_create("config", S_IRUGO, proc_router, &config_fops);
|
||||
if (!p)
|
||||
goto fail_config;
|
||||
p = proc_create("status", S_IRUGO, proc_router, &status_fops);
|
||||
if (!p)
|
||||
goto fail_stat;
|
||||
return 0;
|
||||
fail_stat:
|
||||
remove_proc_entry("config", proc_router);
|
||||
fail_config:
|
||||
remove_proc_entry(ROUTER_NAME, init_net.proc_net);
|
||||
fail:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up router proc interface.
|
||||
*/
|
||||
|
||||
void wanrouter_proc_cleanup(void)
|
||||
{
|
||||
remove_proc_entry("config", proc_router);
|
||||
remove_proc_entry("status", proc_router);
|
||||
remove_proc_entry(ROUTER_NAME, init_net.proc_net);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add directory entry for WAN device.
|
||||
*/
|
||||
|
||||
int wanrouter_proc_add(struct wan_device* wandev)
|
||||
{
|
||||
if (wandev->magic != ROUTER_MAGIC)
|
||||
return -EINVAL;
|
||||
|
||||
wandev->dent = proc_create(wandev->name, S_IRUGO,
|
||||
proc_router, &wandev_fops);
|
||||
if (!wandev->dent)
|
||||
return -ENOMEM;
|
||||
wandev->dent->data = wandev;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete directory entry for WAN device.
|
||||
*/
|
||||
int wanrouter_proc_delete(struct wan_device* wandev)
|
||||
{
|
||||
if (wandev->magic != ROUTER_MAGIC)
|
||||
return -EINVAL;
|
||||
remove_proc_entry(wandev->name, proc_router);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* No /proc - output stubs
|
||||
*/
|
||||
|
||||
int __init wanrouter_proc_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wanrouter_proc_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
int wanrouter_proc_add(struct wan_device *wandev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wanrouter_proc_delete(struct wan_device *wandev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* End
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user