diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-02-16 01:07:24 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-02-16 01:07:24 +0000 |
commit | 95db6b748fc86297827fbd9c9ef174d491c9ad89 (patch) | |
tree | 27a92a942821cde1edda9a1b088718d436b3efe4 /drivers/net/wan | |
parent | 45b27b0a0652331d104c953a5b192d843fff88f8 (diff) |
Merge with Linux 2.3.40.
Diffstat (limited to 'drivers/net/wan')
-rw-r--r-- | drivers/net/wan/cycx_drv.c | 57 | ||||
-rw-r--r-- | drivers/net/wan/cycx_main.c | 68 | ||||
-rw-r--r-- | drivers/net/wan/cycx_x25.c | 191 | ||||
-rw-r--r-- | drivers/net/wan/syncppp.c | 6 | ||||
-rw-r--r-- | drivers/net/wan/z85230.c | 119 | ||||
-rw-r--r-- | drivers/net/wan/z85230.h | 3 |
6 files changed, 225 insertions, 219 deletions
diff --git a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c index 53cb71837..491b04057 100644 --- a/drivers/net/wan/cycx_drv.c +++ b/drivers/net/wan/cycx_drv.c @@ -1,13 +1,13 @@ /* * cycx_drv.c Cyclom 2X Support Module. * -* This module is a library of common hardware-specific +* This module is a library of common hardware specific * functions used by the Cyclades Cyclom 2X sync card. * -* Copyright: (c) 1998, 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> -* * Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br> * +* Copyright: (c) 1998-2000 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 @@ -15,15 +15,16 @@ * 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/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] and isa_memcpy_to -* and fromio +* 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! +* 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 @@ -65,7 +66,7 @@ #include <asm/io.h> /* read[wl], write[wl], ioremap, iounmap */ #define MOD_VERSION 0 -#define MOD_RELEASE 4 +#define MOD_RELEASE 5 #ifdef MODULE MODULE_AUTHOR("Arnaldo Carvalho de Melo"); @@ -103,7 +104,8 @@ static u16 checksum(u8 *buf, u32 len); /* private data */ static char modname[] = "cycx_drv"; static char fullname[] = "Cyclom 2X Support Module"; -static char copyright[] = "(c) 1998, 1999 Arnaldo Carvalho de Melo"; +static char copyright[] = "(c) 1998-2000 Arnaldo Carvalho de Melo " + "<acme@conectiva.com.br>"; /* Hardware configuration options. * These are arrays of configuration options used by verification routines. @@ -130,8 +132,9 @@ static u32 cycx_2x_irq_options[] = { 7, 3, 5, 9, 10, 11, 12, 15 }; #ifdef MODULE int init_module(void) { - printk(KERN_INFO "%s v%u.%u %s\n", - fullname, MOD_VERSION, MOD_RELEASE, copyright); + printk(KERN_INFO "%s v%u.%u %s\n", fullname, MOD_VERSION, MOD_RELEASE, + copyright); + return 0; } /* Module 'remove' entry point. @@ -198,6 +201,7 @@ EXPORT_SYMBOL(cycx_down); int cycx_down(cycxhw_t *hw) { iounmap((u32 *)hw->dpmbase); + return 0; } @@ -226,7 +230,9 @@ int cycx_exec(u32 addr) while (cyc2x_readw(addr)) { udelay(1000); - if (++i > 50) return -1; + + if (++i > 50) + return -1; } return 0; @@ -271,7 +277,8 @@ static int memory_exists(u32 addr) cyc2x_writew(TEST_PATTERN, addr + 0x10); if (cyc2x_readw(addr + 0x10) == TEST_PATTERN) - if (cyc2x_readw(addr + 0x10) == TEST_PATTERN) return 1; + if (cyc2x_readw(addr + 0x10) == TEST_PATTERN) + return 1; delay_cycx(1); } @@ -298,6 +305,7 @@ static int buffer_load(u32 addr, u8 *buffer, u32 cnt) { cyc2x_memcpy_toio(addr + DATA_OFFSET, buffer, cnt); cyc2x_writew(GEN_BOOT_DAT, addr + CMD_OFFSET); + return wait_cyc(addr); } @@ -434,38 +442,39 @@ static int load_cyc2x(cycxhw_t *hw, cfm_t *cfm, u32 len) if (((len - sizeof(cfm_t) - 1) != cfm->info.codesize) || */ if (cksum != cfm->checksum) { - printk(KERN_ERR "%s:" __FUNCTION__ ": firmware corrupted!\n", modname); + printk(KERN_ERR "%s:" __FUNCTION__ ": firmware corrupted!\n", + modname); printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n", - len - sizeof(cfm_t) - 1, cfm->info.codesize); + len - sizeof(cfm_t) - 1, cfm->info.codesize); printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n", - cksum, cfm->checksum); + cksum, cfm->checksum); return -EINVAL; } /* If everything is ok, set reset, data and code pointers */ - img_hdr = (cycx_header_t*)(((u8*) cfm) + sizeof(cfm_t) - 1); + img_hdr = (cycx_header_t*)(((u8*)cfm) + sizeof(cfm_t) - 1); #ifdef FIRMWARE_DEBUG printk(KERN_INFO "%s:" __FUNCTION__ ": image sizes\n", modname); printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size); printk(KERN_INFO " data=%lu\n", img_hdr->data_size); printk(KERN_INFO " code=%lu\n", img_hdr->code_size); #endif - reset_image = ((u8 *) img_hdr) + sizeof(cycx_header_t); + reset_image = ((u8 *)img_hdr) + sizeof(cycx_header_t); data_image = reset_image + img_hdr->reset_size; code_image = data_image + img_hdr->data_size; /*---- Start load ----*/ /* Announce */ printk(KERN_INFO "%s: loading firmware %s (ID=%u)...\n", modname, - (cfm->descr[0] != '\0') ? cfm->descr : "unknown firmware", - cfm->info.codeid); + cfm->descr[0] ? cfm->descr : "unknown firmware", + cfm->info.codeid); for (i = 0 ; i < 5 ; i++) { /* Reset Cyclom hardware */ if (!reset_cyc2x(hw->dpmbase)) { - printk(KERN_ERR "%s: dpm problem or board not " - "found.\n", modname); + printk(KERN_ERR "%s: dpm problem or board not found\n", + modname); return -EINVAL; } @@ -536,6 +545,7 @@ static void cycx_bootcfg(cycxhw_t *hw) static int detect_cyc2x(u32 addr) { reset_cyc2x(addr); + return memory_exists(addr); } @@ -560,6 +570,7 @@ static int reset_cyc2x(u32 addr) delay_cycx(2); cyc2x_writeb(0, addr + RST_DISABLE); delay_cycx(2); + return memory_exists(addr); } diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c index ecca37521..b9b72ddeb 100644 --- a/drivers/net/wan/cycx_main.c +++ b/drivers/net/wan/cycx_main.c @@ -3,7 +3,7 @@ * * Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br> * -* Copyright: (c) 1998, 1999 Arnaldo Carvalho de Melo +* Copyright: (c) 1998-2000 Arnaldo Carvalho de Melo * * Based on sdlamain.c by Gene Kozin <genek@compuserve.com> & * Jaspreet Singh <jaspreet@sangoma.com> @@ -13,6 +13,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * ============================================================================ +* 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 @@ -48,7 +49,7 @@ MODULE_DESCRIPTION("Cyclom 2X Sync Card Driver."); /* Defines & Macros */ #define DRV_VERSION 0 /* version number */ -#define DRV_RELEASE 4 /* release (minor version) number */ +#define DRV_RELEASE 5 /* release (minor version) number */ #define MAX_CARDS 1 /* max number of adapters */ #ifndef CONFIG_CYCLOMX_CARDS /* configurable option */ @@ -76,7 +77,8 @@ static void cycx_isr (int irq, void *dev_id, struct pt_regs *regs); /* private data */ static char drvname[] = "cyclomx"; static char fullname[] = "CYCLOM 2X(tm) Sync Card Driver"; -static char copyright[] = "(c) 1998, 1999 Arnaldo Carvalho de Melo"; +static char copyright[] = "(c) 1998-2000 Arnaldo Carvalho de Melo " + "<acme@conectiva.com.br>"; static int ncards = CONFIG_CYCLOMX_CARDS; static cycx_t *card_array = NULL; /* adapter data space */ @@ -88,7 +90,7 @@ static cycx_t *card_array = NULL; /* adapter data space */ * o allocate adapter data space * o initialize static data * o register all cards with WAN router - * o calibrate CYCX shared memory access delay. + * o calibrate Cyclom 2X shared memory access delay. * * Return: 0 Ok * < 0 error. @@ -110,7 +112,8 @@ int __init cyclomx_init (void) ncards = max(ncards, 1); card_array = kmalloc(sizeof(cycx_t) * ncards, GFP_KERNEL); - if (card_array == NULL) return -ENOMEM; + if (!card_array) + return -ENOMEM; memset(card_array, 0, sizeof(cycx_t) * ncards); @@ -136,7 +139,8 @@ int __init cyclomx_init (void) } } - if (cnt) ncards = cnt; /* adjust actual number of cards */ + if (cnt) + ncards = cnt; /* adjust actual number of cards */ else { kfree(card_array); err = -ENODEV; @@ -165,13 +169,12 @@ void cleanup_module (void) #endif /* WAN Device Driver Entry Points */ /* - * Setup/confugure WAN link driver. + * Setup/configure WAN link driver. * o check adapter state * o make sure firmware is present in configuration * o allocate interrupt vector - * o setup CYCLOM X hardware + * o setup Cyclom 2X hardware * o call appropriate routine to perform protocol-specific initialization - * o mark I/O region as used * * This function is called when router handles ROUTER_SETUP IOCTL. The * configuration structure is in kernel memory (including extended data, if @@ -184,13 +187,15 @@ static int setup (wan_device_t *wandev, wandev_conf_t *conf) int irq; /* Sanity checks */ - if (!wandev || !wandev->private || !conf) return -EFAULT; + if (!wandev || !wandev->private || !conf) + return -EFAULT; card = wandev->private; - if (wandev->state != WAN_UNCONFIGURED) return -EBUSY; + if (wandev->state != WAN_UNCONFIGURED) + return -EBUSY; - if (!conf->data_size || (conf->data == NULL)) { + if (!conf->data_size || !conf->data) { printk(KERN_ERR "%s: firmware not found in configuration " "data!\n", wandev->name); return -EINVAL; @@ -213,7 +218,7 @@ static int setup (wan_device_t *wandev, wandev_conf_t *conf) /* Configure hardware, load firmware, etc. */ memset(&card->hw, 0, sizeof(cycxhw_t)); - card->hw.irq = (conf->irq == 9) ? 2 : conf->irq; + card->hw.irq = irq; card->hw.dpmbase = conf->maddr; card->hw.dpmsize = CYCX_WINDOWSIZE; card->hw.fwid = CFID_X25_2X; @@ -230,7 +235,7 @@ static int setup (wan_device_t *wandev, wandev_conf_t *conf) return err; } - /* Intialize WAN device data space */ + /* Initialize WAN device data space */ wandev->irq = irq; wandev->dma = wandev->ioport = 0; wandev->maddr = (unsigned long*)card->hw.dpmbase; @@ -241,7 +246,9 @@ static int setup (wan_device_t *wandev, wandev_conf_t *conf) /* Protocol-specific initialization */ switch (card->hw.fwid) { #ifdef CONFIG_CYCLOMX_X25 - case CFID_X25_2X: err = cyx_init(card, conf); break; + case CFID_X25_2X: + err = cyx_init(card, conf); + break; #endif default: printk(KERN_ERR "%s: this firmware is not supported!\n", @@ -271,15 +278,19 @@ static int shutdown (wan_device_t *wandev) cycx_t *card; /* sanity checks */ - if (!wandev || !wandev->private) return -EFAULT; + if (!wandev || !wandev->private) + return -EFAULT; - if (wandev->state == WAN_UNCONFIGURED) return 0; + if (wandev->state == WAN_UNCONFIGURED) + return 0; card = wandev->private; wandev->state = WAN_UNCONFIGURED; cycx_down(&card->hw); - printk(KERN_INFO "%s: irq %d being freed!\n", wandev->name, wandev->irq); + printk(KERN_INFO "%s: irq %d being freed!\n", wandev->name, + wandev->irq); free_irq(wandev->irq, card); + return 0; } @@ -289,7 +300,9 @@ static int shutdown (wan_device_t *wandev) * o perform requested action * * This function is called when router handles one of the reserved user - * IOCTLs. Note that 'arg' stil points to user address space. + * IOCTLs. Note that 'arg' still points to user address space. + * + * no reserved ioctls for the cyclom 2x up to now */ static int ioctl (wan_device_t *wandev, unsigned cmd, unsigned long arg) { @@ -298,8 +311,8 @@ static int ioctl (wan_device_t *wandev, unsigned cmd, unsigned long arg) /* Miscellaneous */ /* - * CYCX Interrupt Service Routine. - * o acknowledge CYCX hardware interrupt. + * Cyclom 2X Interrupt Service Routine. + * o acknowledge Cyclom 2X hardware interrupt. * o call protocol-specific interrupt service routine, if any. */ static void cycx_isr (int irq, void *dev_id, struct pt_regs *regs) @@ -347,27 +360,22 @@ void cyclomx_close (cycx_t *card) void cyclomx_set_state (cycx_t *card, int state) { unsigned long host_cpu_flags; + char *string_state = NULL; spin_lock_irqsave(&card->lock, host_cpu_flags); if (card->wandev.state != state) { switch (state) { case WAN_CONNECTED: - printk (KERN_INFO "%s: link connected!\n", - card->devname); - break; - - case WAN_CONNECTING: - printk (KERN_INFO "%s: link connecting...\n", - card->devname); + string_state = "connected!"; break; case WAN_DISCONNECTED: - printk (KERN_INFO "%s: link disconnected!\n", - card->devname); + string_state = "disconnected!"; break; } + printk(KERN_INFO "%s: link %s\n", card->devname, string_state); card->wandev.state = state; } diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index cb41eb5b1..e9156df92 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c @@ -1,8 +1,9 @@ /* -* cycx_x25.c CYCLOM X WAN Link Driver. X.25 module. +* cycx_x25.c Cyclom 2X WAN Link Driver. X.25 module. * * Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br> -* Copyright: (c) 1998, 1999 Arnaldo Carvalho de Melo +* +* Copyright: (c) 1998-2000 Arnaldo Carvalho de Melo * * Based on sdla_x25.c by Gene Kozin <genek@compuserve.com> * @@ -11,7 +12,8 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * ============================================================================ -* 1999/10/27 acme use ARPHRD_HWX25 so that the x25 stack know +* 2000/01/08 acme cleanup +* 1999/10/27 acme use ARPHRD_HWX25 so that the X.25 stack know * that we have a X.25 stack implemented in * firmware onboard * 1999/10/18 acme support for X.25 sockets in if_send, @@ -35,7 +37,7 @@ * AFAIT, with ARPHRD_ETHER). This seems to be * needed to use socket(AF_X25)... * Now the config file must specify a peer media -* address for svc channes over a crossover cable. +* address for svc channels over a crossover cable. * Removed hold_timeout from x25_channel_t, * not used. * A little enhancement in the DEBUG processing @@ -79,7 +81,7 @@ #include <linux/wanrouter.h> /* WAN router definitions */ #include <asm/byteorder.h> /* htons(), etc. */ #include <linux/if_arp.h> /* ARPHRD_HWX25 */ -#include <linux/cyclomx.h> /* CYCLOM X common user API definitions */ +#include <linux/cyclomx.h> /* Cyclom 2X common user API definitions */ #include <linux/cycx_x25.h> /* X.25 firmware API definitions */ /* Defines & Macros */ @@ -87,7 +89,7 @@ #define X25_CHAN_MTU 2048 /* unfragmented logical channel MTU */ /* Data Structures */ -/* This is an extention of the 'struct net_device' we create for each network +/* This is an extension of the 'struct net_device' we create for each network interface to keep the rest of X.25 channel-specific data. */ typedef struct x25_channel { char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */ @@ -110,7 +112,8 @@ typedef struct x25_channel { /* Function Prototypes */ /* WAN link driver entry points. These are called by the WAN router module. */ static int update (wan_device_t *wandev), - new_if (wan_device_t *wandev, struct net_device *dev,wanif_conf_t *conf), + new_if (wan_device_t *wandev, struct net_device *dev, + wanif_conf_t *conf), del_if (wan_device_t *wandev, struct net_device *dev); /* Network device interface */ @@ -139,7 +142,8 @@ static void cyx_isr (cycx_t *card), /* X.25 firmware interface functions */ static int x25_configure (cycx_t *card, TX25Config *conf), x25_get_stats (cycx_t *card), - x25_send (cycx_t *card, u8 link, u8 lcn, u8 bitm, int len,void *buf), + x25_send (cycx_t *card, u8 link, u8 lcn, u8 bitm, int len, + void *buf), x25_connect_response (cycx_t *card, x25_channel_t *chan), x25_disconnect_response (cycx_t *card, u8 link, u8 lcn); @@ -182,7 +186,7 @@ static void x25_dump_devs(wan_device_t *wandev); /* X.25 Protocol Initialization routine. * - * This routine is called by the main CYCLOM X module during setup. At this + * This routine is called by the main Cyclom 2X module during setup. At this * point adapter is completely initialized and X.25 firmware is running. * o read firmware version (to make sure it's alive) * o configure adapter @@ -206,7 +210,7 @@ int cyx_init (cycx_t *card, wandev_conf_t *conf) card->u.x.connection_keys = 0; card->u.x.lock = SPIN_LOCK_UNLOCKED; - /* Configure adapter. Here we set resonable defaults, then parse + /* Configure adapter. Here we set reasonable defaults, then parse * device configuration structure and set configuration options. * Most configuration options are verified and corrected (if * necessary) since we can't rely on the adapter to do so and don't @@ -302,6 +306,7 @@ int cyx_init (cycx_t *card, wandev_conf_t *conf) card->wandev.new_if = new_if; card->wandev.del_if = del_if; card->wandev.state = WAN_DISCONNECTED; + return 0; } @@ -317,6 +322,7 @@ static int update (wan_device_t *wandev) return -ENODEV; x25_get_stats(wandev->private); + return 0; } @@ -326,7 +332,7 @@ static int update (wan_device_t *wandev) * o parse media- and hardware-specific configuration * o make sure that a new channel can be created * o allocate resources, if necessary - * o prepare network device structure for registaration. + * o prepare network device structure for registration. * * Return: 0 o.k. * < 0 failure (channel will not be created) */ @@ -380,7 +386,7 @@ static int new_if (wan_device_t *wandev, struct net_device *dev, wanif_conf_t *c strncpy(chan->addr, &conf->addr[1], WAN_ADDRESS_SZ); init_timer(&chan->timer); chan->timer.function = chan_timer; - chan->timer.data = (unsigned long) dev; + chan->timer.data = (unsigned long)dev; /* Set channel timeouts (default if not specified) */ chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90; @@ -413,6 +419,7 @@ static int new_if (wan_device_t *wandev, struct net_device *dev, wanif_conf_t *c dev->name = chan->name; dev->init = if_init; dev->priv = chan; + return 0; } @@ -480,6 +487,7 @@ static int if_init (struct net_device *dev) /* Initialize socket buffers */ dev_init_buffers(dev); set_chan_state(dev, WAN_DISCONNECTED); + return 0; } @@ -518,6 +526,7 @@ static int if_close (struct net_device *dev) chan_disconnect(dev); cyclomx_close(card); + return 0; } @@ -533,6 +542,7 @@ static int if_header (struct sk_buff *skb, struct net_device *dev, u16 type, void *daddr, void *saddr, unsigned len) { skb->protocol = type; + return dev->hard_header_len; } @@ -632,6 +642,7 @@ static int if_send (struct sk_buff *skb, struct net_device *dev) free_packet: dev_kfree_skb(skb); + return 0; } @@ -710,7 +721,7 @@ static void tx_intr (cycx_t *card, TX25Cmd *cmd) cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn)); /* unbusy device and then dev_tint(); */ - if ((dev = get_dev_by_lcn (wandev, lcn)) != NULL) { + if ((dev = get_dev_by_lcn(wandev, lcn)) != NULL) { card->buff_int_mode_unbusy = 1; dev->tbusy = 0; } else @@ -721,14 +732,14 @@ static void tx_intr (cycx_t *card, TX25Cmd *cmd) /* Receive interrupt handler. * This routine handles fragmented IP packets using M-bit according to the * RFC1356. - * o map ligical channel number to network interface. + * o map logical channel number to network interface. * o allocate socket buffer or append received packet to the existing one. * o if M-bit is reset (i.e. it's the last packet in a sequence) then * decapsulate packet and pass socket buffer to the protocol stack. * * Notes: * 1. When allocating a socket buffer, if M-bit is set then more data is - * comming and we have to allocate buffer for the maximum IP packet size + * coming and we have to allocate buffer for the maximum IP packet size * expected on this channel. * 2. If something goes wrong and X.25 packet has to be dropped (e.g. no * socket buffers available) the whole packet sequence must be discarded. */ @@ -884,7 +895,7 @@ static void connect_confirm_intr (cycx_t *card, TX25Cmd *cmd) set_chan_state(dev, WAN_CONNECTED); } -/* Disonnect confirm interrupt handler. */ +/* Disconnect confirm interrupt handler. */ static void disconnect_confirm_intr (cycx_t *card, TX25Cmd *cmd) { wan_device_t *wandev = &card->wandev; @@ -934,7 +945,7 @@ static void log_intr (cycx_t *card, TX25Cmd *cmd) cycx_peek(&card->hw, cmd->buf, &msg_code, sizeof(msg_code)); cycx_peek(&card->hw, cmd->buf + 2, &link, sizeof(link)); cycx_peek(&card->hw, cmd->buf + 4, &size, sizeof(size)); - /* at most 20 bytes are available... thanx to Daniela :) */ + /* at most 20 bytes are available... thanks to Daniela :) */ toread = size < 20 ? size : 20; cycx_peek(&card->hw, cmd->buf + 10, &bf, toread); cycx_peek(&card->hw, cmd->buf + 10 + toread, &code, 1); @@ -987,8 +998,9 @@ static void hex_dump(char *msg, unsigned char *p, int len) printk(KERN_INFO "%s: %s\n", msg, hex); } #endif -/* CYCLOM X Firmware-Specific Functions */ -/* Exec x25 command. */ + +/* Cyclom 2X Firmware-Specific Functions */ +/* Exec X.25 command. */ static int x25_exec (cycx_t *card, int command, int link, void *d1, int len1, void *d2, int len2) { @@ -1007,7 +1019,7 @@ static int x25_exec (cycx_t *card, int command, int link, /* write command */ cycx_poke(&card->hw, X25_MBOX_OFFS, &c, sizeof(c) - sizeof(c.buf)); - /* write x25 data */ + /* write X.25 data */ if (d1) { cycx_poke(&card->hw, addr, d1, len1); @@ -1016,7 +1028,7 @@ static int x25_exec (cycx_t *card, int command, int link, u32 addr1 = 0xA00 + 0x400 * link; cycx_poke(&card->hw, addr + len1, d2, 249); - cycx_poke(&card->hw, addr1, ((u8*) d2) + 249, + cycx_poke(&card->hw, addr1, ((u8*)d2) + 249, len2 - 249); } else cycx_poke(&card->hw, addr + len1, d2, len2); @@ -1069,7 +1081,7 @@ static int x25_configure (cycx_t *card, TX25Config *conf) static int x25_get_stats (cycx_t *card) { /* the firmware expects 20 in the size field!!! - thanx to Daniela */ + thanks to Daniela */ int err = x25_exec(card, X25_STATISTIC, 0, NULL, 20, NULL, 0); if (err) @@ -1095,6 +1107,7 @@ static int x25_get_stats (cycx_t *card) card->wandev.stats.tx_errors = 0; /* not available from fw */ x25_dump_devs(&card->wandev); + return 0; } @@ -1180,7 +1193,7 @@ static int x25_place_call (cycx_t *card, x25_channel_t *chan) ++len; d[5] = mylen << 4 | remotelen; - d[6 + len + 1] = 0xCC; /* TCP/IP over X.25, thanx to Daniela :) */ + d[6 + len + 1] = 0xCC; /* TCP/IP over X.25, thanks to Daniela :) */ if ((err = x25_exec(card, X25_CONNECT_REQUEST, chan->link, &d, 7 + len + 1, NULL, 0)) != 0) @@ -1200,7 +1213,7 @@ static int x25_connect_response (cycx_t *card, x25_channel_t *chan) d[0] = d[3] = chan->lcn; d[2] = 0x10; d[4] = 0x0F; - d[7] = 0xCC; /* TCP/IP over X.25, thanx Daniela */ + d[7] = 0xCC; /* TCP/IP over X.25, thanks Daniela */ return x25_exec(card, X25_CONNECT_RESPONSE, chan->link, &d, 8, NULL, 0); } @@ -1214,6 +1227,7 @@ static int x25_disconnect_response (cycx_t *card, u8 link, u8 lcn) d[0] = d[3] = lcn; d[2] = 0x10; d[4] = 0x17; + return x25_exec(card, X25_DISCONNECT_RESPONSE, link, &d, 5, NULL, 0); } @@ -1252,6 +1266,7 @@ static struct net_device *get_dev_by_lcn (wan_device_t *wandev, s16 lcn) for (; dev; dev = dev->slave) if (((x25_channel_t*)dev->priv)->lcn == lcn) break; + return dev; } @@ -1261,8 +1276,9 @@ static struct net_device *get_dev_by_dte_addr (wan_device_t *wandev, char *dte) struct net_device *dev = wandev->dev; for (; dev; dev = dev->slave) - if (!strcmp (((x25_channel_t*)dev->priv)->addr, dte)) + if (!strcmp(((x25_channel_t*)dev->priv)->addr, dte)) break; + return dev; } @@ -1281,10 +1297,13 @@ static int chan_connect (struct net_device *dev) if (chan->svc) { if (!chan->addr[0]) return -EINVAL; /* no destination address */ + dprintk(KERN_INFO "%s: placing X.25 call to %s...\n", card->devname, chan->addr); + if (x25_place_call(card, chan)) return -EIO; + set_chan_state(dev, WAN_CONNECTING); return 1; } else @@ -1309,18 +1328,14 @@ static void chan_disconnect (struct net_device *dev) /* Called by kernel timer */ static void chan_timer (unsigned long d) { - struct net_device *dev = (struct net_device*) d; + struct net_device *dev = (struct net_device *)d; x25_channel_t *chan = dev->priv; - switch (chan->state) { - case WAN_CONNECTED: - chan_disconnect(dev); - break; - default: - printk (KERN_ERR "%s: chan_timer for svc (%s) not " - "connected!\n", - chan->card->devname, dev->name); - } + if (chan->state == WAN_CONNECTED) + chan_disconnect(dev); + else + printk(KERN_ERR "%s: chan_timer for svc (%s) not connected!\n", + chan->card->devname, dev->name); } /* Set logical channel state. */ @@ -1329,6 +1344,7 @@ static void set_chan_state (struct net_device *dev, u8 state) x25_channel_t *chan = dev->priv; cycx_t *card = chan->card; u32 flags = 0; + char *string_state = NULL; spin_lock_irqsave(&card->lock, flags); @@ -1338,9 +1354,7 @@ static void set_chan_state (struct net_device *dev, u8 state) switch (state) { case WAN_CONNECTED: - printk (KERN_INFO "%s: interface %s " - "connected!\n", - card->devname, dev->name); + string_state = "connected!"; *(u16*)dev->dev_addr = htons(chan->lcn); dev->tbusy = 0; reset_timer(dev); @@ -1351,21 +1365,16 @@ static void set_chan_state (struct net_device *dev, u8 state) break; case WAN_CONNECTING: - printk (KERN_INFO "%s: interface %s " - "connecting...\n", - card->devname, dev->name); + string_state = "connecting..."; break; case WAN_DISCONNECTING: - printk (KERN_INFO "%s: interface %s " - "disconnecting...\n", - card->devname, dev->name); + string_state = "disconnecting..."; break; case WAN_DISCONNECTED: - printk (KERN_INFO "%s: interface %s " - "disconnected!\n", - card->devname, dev->name); + string_state = "disconnected!"; + if (chan->svc) { *(unsigned short*)dev->dev_addr = 0; chan->lcn = 0; @@ -1378,6 +1387,8 @@ static void set_chan_state (struct net_device *dev, u8 state) break; } + printk (KERN_INFO "%s: interface %s %s\n", card->devname, + dev->name, string_state); chan->state = state; } @@ -1419,6 +1430,7 @@ static int chan_send (struct net_device *dev, struct sk_buff *skb) ++chan->ifstats.tx_packets; chan->ifstats.tx_bytes += len; + return 0; } @@ -1488,7 +1500,7 @@ static unsigned dec_to_uint (u8 *str, int len) len = strlen(str); for (; len && is_digit(*str); ++str, --len) - val = (val * 10) + (*str - (unsigned)'0'); + val = (val * 10) + (*str - (unsigned) '0'); return val; } @@ -1497,66 +1509,65 @@ static void reset_timer(struct net_device *dev) { x25_channel_t *chan = dev->priv; - if (!chan->svc) - return; - - del_timer(&chan->timer); - chan->timer.expires = jiffies + chan->idle_tmout * HZ; - add_timer(&chan->timer); + if (chan->svc) { + del_timer(&chan->timer); + chan->timer.expires = jiffies + chan->idle_tmout * HZ; + add_timer(&chan->timer); + } } #ifdef CYCLOMX_X25_DEBUG static void x25_dump_config(TX25Config *conf) { - printk (KERN_INFO "x25 configuration\n"); - printk (KERN_INFO "-----------------\n"); - printk (KERN_INFO "link number=%d\n", conf->link); - printk (KERN_INFO "line speed=%d\n", conf->speed); - printk (KERN_INFO "clock=%sternal\n", conf->clock == 8 ? "Ex" : "In"); - printk (KERN_INFO "# level 2 retransm.=%d\n", conf->n2); - printk (KERN_INFO "level 2 window=%d\n", conf->n2win); - printk (KERN_INFO "level 3 window=%d\n", conf->n3win); - printk (KERN_INFO "# logical channels=%d\n", conf->nvc); - printk (KERN_INFO "level 3 pkt len=%d\n", conf->pktlen); - printk (KERN_INFO "my address=%d\n", conf->locaddr); - printk (KERN_INFO "remote address=%d\n", conf->remaddr); - printk (KERN_INFO "t1=%d seconds\n", conf->t1); - printk (KERN_INFO "t2=%d seconds\n", conf->t2); - printk (KERN_INFO "t21=%d seconds\n", conf->t21); - printk (KERN_INFO "# PVCs=%d\n", conf->npvc); - printk (KERN_INFO "t23=%d seconds\n", conf->t23); - printk (KERN_INFO "flags=0x%x\n", conf->flags); + printk(KERN_INFO "X.25 configuration\n"); + printk(KERN_INFO "-----------------\n"); + printk(KERN_INFO "link number=%d\n", conf->link); + printk(KERN_INFO "line speed=%d\n", conf->speed); + printk(KERN_INFO "clock=%sternal\n", conf->clock == 8 ? "Ex" : "In"); + printk(KERN_INFO "# level 2 retransm.=%d\n", conf->n2); + printk(KERN_INFO "level 2 window=%d\n", conf->n2win); + printk(KERN_INFO "level 3 window=%d\n", conf->n3win); + printk(KERN_INFO "# logical channels=%d\n", conf->nvc); + printk(KERN_INFO "level 3 pkt len=%d\n", conf->pktlen); + printk(KERN_INFO "my address=%d\n", conf->locaddr); + printk(KERN_INFO "remote address=%d\n", conf->remaddr); + printk(KERN_INFO "t1=%d seconds\n", conf->t1); + printk(KERN_INFO "t2=%d seconds\n", conf->t2); + printk(KERN_INFO "t21=%d seconds\n", conf->t21); + printk(KERN_INFO "# PVCs=%d\n", conf->npvc); + printk(KERN_INFO "t23=%d seconds\n", conf->t23); + printk(KERN_INFO "flags=0x%x\n", conf->flags); } static void x25_dump_stats(TX25Stats *stats) { - printk (KERN_INFO "x25 statistics\n"); - printk (KERN_INFO "--------------\n"); - printk (KERN_INFO "rx_crc_errors=%d\n", stats->rx_crc_errors); - printk (KERN_INFO "rx_over_errors=%d\n", stats->rx_over_errors); - printk (KERN_INFO "n2_tx_frames=%d\n", stats->n2_tx_frames); - printk (KERN_INFO "n2_rx_frames=%d\n", stats->n2_rx_frames); - printk (KERN_INFO "tx_timeouts=%d\n", stats->tx_timeouts); - printk (KERN_INFO "rx_timeouts=%d\n", stats->rx_timeouts); - printk (KERN_INFO "n3_tx_packets=%d\n", stats->n3_tx_packets); - printk (KERN_INFO "n3_rx_packets=%d\n", stats->n3_rx_packets); - printk (KERN_INFO "tx_aborts=%d\n", stats->tx_aborts); - printk (KERN_INFO "rx_aborts=%d\n", stats->rx_aborts); + printk(KERN_INFO "X.25 statistics\n"); + printk(KERN_INFO "--------------\n"); + printk(KERN_INFO "rx_crc_errors=%d\n", stats->rx_crc_errors); + printk(KERN_INFO "rx_over_errors=%d\n", stats->rx_over_errors); + printk(KERN_INFO "n2_tx_frames=%d\n", stats->n2_tx_frames); + printk(KERN_INFO "n2_rx_frames=%d\n", stats->n2_rx_frames); + printk(KERN_INFO "tx_timeouts=%d\n", stats->tx_timeouts); + printk(KERN_INFO "rx_timeouts=%d\n", stats->rx_timeouts); + printk(KERN_INFO "n3_tx_packets=%d\n", stats->n3_tx_packets); + printk(KERN_INFO "n3_rx_packets=%d\n", stats->n3_rx_packets); + printk(KERN_INFO "tx_aborts=%d\n", stats->tx_aborts); + printk(KERN_INFO "rx_aborts=%d\n", stats->rx_aborts); } static void x25_dump_devs(wan_device_t *wandev) { struct net_device *dev = wandev->dev; - printk (KERN_INFO "x25 dev states\n"); - printk (KERN_INFO "name: addr: tbusy: protocol:\n"); - printk (KERN_INFO "---------------------------------------\n"); + printk(KERN_INFO "X.25 dev states\n"); + printk(KERN_INFO "name: addr: tbusy: protocol:\n"); + printk(KERN_INFO "---------------------------------------\n"); for (; dev; dev = dev->slave) { x25_channel_t *chan = dev->priv; - printk (KERN_INFO "%-5.5s %-15.15s %ld ETH_P_%s\n", - chan->name, chan->addr, dev->tbusy, - chan->protocol == ETH_P_IP ? "IP" : "X25"); + printk(KERN_INFO "%-5.5s %-15.15s %ld ETH_P_%s\n", + chan->name, chan->addr, dev->tbusy, + chan->protocol == ETH_P_IP ? "IP" : "X25"); } } diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c index bfa2bf89f..6113365c1 100644 --- a/drivers/net/wan/syncppp.c +++ b/drivers/net/wan/syncppp.c @@ -660,14 +660,14 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) h = (struct cisco_packet *)skb->data; skb_pull(skb, sizeof(struct cisco_packet*)); if (sp->pp_flags & PP_DEBUG) - printk (KERN_WARNING "%s: cisco input: %d bytes <%lxh %xh %xh %xh %xh-%xh>\n", + printk (KERN_WARNING "%s: cisco input: %d bytes <%xh %xh %xh %xh %xh-%xh>\n", dev->name, skb->len, ntohl (h->type), h->par1, h->par2, h->rel, h->time0, h->time1); switch (ntohl (h->type)) { default: if (sp->pp_flags & PP_DEBUG) - printk (KERN_WARNING "%s: unknown cisco packet type: 0x%lx\n", + printk (KERN_WARNING "%s: unknown cisco packet type: 0x%x\n", dev->name, ntohl (h->type)); break; case CISCO_ADDR_REPLY: @@ -814,7 +814,7 @@ static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2) ch->time1 = htons ((u16) t); if (sp->pp_flags & PP_DEBUG) - printk (KERN_WARNING "%s: cisco output: <%lxh %xh %xh %xh %xh-%xh>\n", + printk (KERN_WARNING "%s: cisco output: <%xh %xh %xh %xh %xh-%xh>\n", dev->name, ntohl (ch->type), ch->par1, ch->par2, ch->rel, ch->time0, ch->time1); sp->obytes += skb->len; diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c index a802170ce..f6b385de5 100644 --- a/drivers/net/wan/z85230.c +++ b/drivers/net/wan/z85230.c @@ -5,18 +5,18 @@ * 2 of the License, or (at your option) any later version. * * (c) Copyright 1998 Building Number Three Ltd + * (c) Copyright 2000 Red Hat Software * * Development of this driver was funded by Equiinet Ltd * http://www.equiinet.com * * ChangeLog: * - * Asynchronous mode dropped for 2.2. For 2.3 we will attempt the + * Asynchronous mode dropped for 2.2. For 2.5 we will attempt the * unification of all the Z85x30 asynchronous drivers for real. * - * To Do: - * - * Finish DMA mode support. + * DMA now uses get_free_page as kmalloc buffers may span a 64K + * boundary. * * Performance * @@ -170,7 +170,7 @@ EXPORT_SYMBOL(z8530_hdlc_kilostream); /* * As above but for enhanced chips. */ - + u8 z8530_hdlc_kilostream_85230[]= { 4, SYNC_ENAB|SDLC|X1CLK, @@ -355,13 +355,15 @@ static void z8530_status(struct z8530_channel *chan) z8530_tx_done(chan); } - if(altered&DCD) + if(altered&chan->dcdcheck) { - if(status&DCD) + if(status&chan->dcdcheck) { printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3]|RxENABLE); - if(chan->netdevice) + if(chan->netdevice && + ((chan->netdevice->type == ARPHRD_HDLC) || + (chan->netdevice->type == ARPHRD_PPP))) sppp_reopen(chan->netdevice); } else @@ -441,7 +443,6 @@ static void z8530_dma_status(struct z8530_channel *chan) if(status&TxEOM) { flags=claim_dma_lock(); - /* Transmit underrun */ disable_dma(chan->txdma); clear_dma_ff(chan->txdma); chan->txdma_on=0; @@ -449,13 +450,15 @@ static void z8530_dma_status(struct z8530_channel *chan) z8530_tx_done(chan); } } - if(altered&DCD) + if(altered&chan->dcdcheck) { - if(status&DCD) + if(status&chan->dcdcheck) { printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3]|RxENABLE); - if(chan->netdevice) + if(chan->netdevice && + ((chan->netdevice->type == ARPHRD_HDLC) || + (chan->netdevice->type == ARPHRD_PPP))) sppp_reopen(chan->netdevice); } else @@ -662,39 +665,28 @@ int z8530_sync_dma_open(struct net_device *dev, struct z8530_channel *c) c->txdma_on = 0; /* - * Allocate the DMA flip buffers + * Allocate the DMA flip buffers. Limit by page size. + * Everyone runs 1500 mtu or less on wan links so this + * should be fine. */ - c->rx_buf[0]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); + if(c->mtu > PAGE_SIZE/2) + return -EMSGSIZE; + + c->rx_buf[0]=(void *)get_free_page(GFP_KERNEL|GFP_DMA); if(c->rx_buf[0]==NULL) return -ENOBUFS; - c->rx_buf[1]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); - if(c->rx_buf[1]==NULL) - { - kfree(c->rx_buf[0]); - c->rx_buf[0]=NULL; - return -ENOBUFS; - } + c->rx_buf[1]=c->rx_buf[0]+PAGE_SIZE/2; - c->tx_dma_buf[0]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); + c->tx_dma_buf[0]=(void *)get_free_page(GFP_KERNEL|GFP_DMA); if(c->tx_dma_buf[0]==NULL) { - kfree(c->rx_buf[0]); - kfree(c->rx_buf[1]); - c->rx_buf[0]=NULL; - return -ENOBUFS; - } - c->tx_dma_buf[1]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); - if(c->tx_dma_buf[1]==NULL) - { - kfree(c->tx_dma_buf[0]); - kfree(c->rx_buf[0]); - kfree(c->rx_buf[1]); + free_page((unsigned long)c->rx_buf[0]); c->rx_buf[0]=NULL; - c->rx_buf[1]=NULL; - c->tx_dma_buf[0]=NULL; return -ENOBUFS; } + c->tx_dma_buf[1]=c->tx_dma_buf[0]+PAGE_SIZE/2; + c->tx_dma_used=0; c->dma_tx = 1; c->dma_num=0; @@ -806,24 +798,14 @@ int z8530_sync_dma_close(struct net_device *dev, struct z8530_channel *c) if(c->rx_buf[0]) { - kfree(c->rx_buf[0]); + free_page((unsigned long)c->rx_buf[0]); c->rx_buf[0]=NULL; } - if(c->rx_buf[1]) - { - kfree(c->rx_buf[1]); - c->rx_buf[1]=NULL; - } if(c->tx_dma_buf[0]) { - kfree(c->tx_dma_buf[0]); + free_page((unsigned long)c->tx_dma_buf[0]); c->tx_dma_buf[0]=NULL; } - if(c->tx_dma_buf[1]) - { - kfree(c->tx_dma_buf[1]); - c->tx_dma_buf[1]=NULL; - } chk=read_zsreg(c,R0); write_zsreg(c, R3, c->regs[R3]); z8530_rtsdtr(c,0); @@ -857,25 +839,21 @@ int z8530_sync_txdma_open(struct net_device *dev, struct z8530_channel *c) c->rxdma_on = 0; c->txdma_on = 0; - c->tx_dma_buf[0]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); + /* + * Allocate the DMA flip buffers. Limit by page size. + * Everyone runs 1500 mtu or less on wan links so this + * should be fine. + */ + + if(c->mtu > PAGE_SIZE/2) + return -EMSGSIZE; + + c->tx_dma_buf[0]=(void *)get_free_page(GFP_KERNEL|GFP_DMA); if(c->tx_dma_buf[0]==NULL) - { - kfree(c->rx_buf[0]); - kfree(c->rx_buf[1]); - c->rx_buf[0]=NULL; return -ENOBUFS; - } - c->tx_dma_buf[1]=kmalloc(c->mtu, GFP_KERNEL|GFP_DMA); - if(c->tx_dma_buf[1]==NULL) - { - kfree(c->tx_dma_buf[0]); - kfree(c->rx_buf[0]); - kfree(c->rx_buf[1]); - c->rx_buf[0]=NULL; - c->rx_buf[1]=NULL; - c->tx_dma_buf[0]=NULL; - return -ENOBUFS; - } + + c->tx_dma_buf[1] = c->tx_dma_buf[0] + PAGE_SIZE/2; + c->tx_dma_used=0; c->dma_num=0; c->dma_ready=1; @@ -960,14 +938,9 @@ int z8530_sync_txdma_close(struct net_device *dev, struct z8530_channel *c) if(c->tx_dma_buf[0]) { - kfree(c->tx_dma_buf[0]); + free_page((unsigned long)c->tx_dma_buf[0]); c->tx_dma_buf[0]=NULL; } - if(c->tx_dma_buf[1]) - { - kfree(c->tx_dma_buf[1]); - c->tx_dma_buf[1]=NULL; - } chk=read_zsreg(c,R0); write_zsreg(c, R3, c->regs[R3]); z8530_rtsdtr(c,0); @@ -1012,6 +985,8 @@ int z8530_init(struct z8530_dev *dev) floating IRQ transition when we reset the chip */ dev->chanA.irqs=&z8530_nop; dev->chanB.irqs=&z8530_nop; + dev->chanA.dcdcheck=DCD; + dev->chanB.dcdcheck=DCD; /* Reset the chip */ write_zsreg(&dev->chanA, R9, 0xC0); udelay(200); @@ -1104,7 +1079,7 @@ int z8530_channel_load(struct z8530_channel *c, u8 *rtable) c->mtu=1500; c->max=0; c->count=0; - c->status=0; /* Fixme - check DCD now */ + c->status=read_zsreg(c, R0); c->sync=1; write_zsreg(c, R3, c->regs[R3]|RxENABLE); return 0; @@ -1251,7 +1226,7 @@ static void z8530_rx_done(struct z8530_channel *c) * Save the ready state and the buffer currently * being used as the DMA target */ - + int ready=c->dma_ready; unsigned char *rxb=c->rx_buf[c->dma_num]; unsigned long flags; diff --git a/drivers/net/wan/z85230.h b/drivers/net/wan/z85230.h index 0b4b48748..dcad711b0 100644 --- a/drivers/net/wan/z85230.h +++ b/drivers/net/wan/z85230.h @@ -270,6 +270,7 @@ struct z8530_channel struct sk_buff *skb; /* Buffer dptr points into */ struct sk_buff *skb2; /* Pending buffer */ u8 status; /* Current DCD */ + u8 dcdcheck; /* which bit to check for line */ u8 sync; /* Set if in sync mode */ u8 regs[32]; /* Register map for the chip */ @@ -413,7 +414,7 @@ extern void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb); * Standard interrupt vector sets */ -struct z8530_irqhandler z8530_sync, z8530_async, z8530_nop; +extern struct z8530_irqhandler z8530_sync, z8530_async, z8530_nop; /* * Asynchronous Interfacing |