o wan/cycx: remove unneeded ioctl stub and fix namespace

parent 630cfa38
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later 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, * 2001/05/09 acme Fix MODULE_DESC for debug, .bss nitpicks,
* some cleanups * some cleanups
* 2000/07/13 acme remove useless #ifdef MODULE and crap * 2000/07/13 acme remove useless #ifdef MODULE and crap
...@@ -46,11 +50,8 @@ ...@@ -46,11 +50,8 @@
#include <linux/ioport.h> /* request_region(), release_region() */ #include <linux/ioport.h> /* request_region(), release_region() */
#include <linux/wanrouter.h> /* WAN router definitions */ #include <linux/wanrouter.h> /* WAN router definitions */
#include <linux/cyclomx.h> /* cyclomx common user API definitions */ #include <linux/cyclomx.h> /* cyclomx common user API definitions */
#include <asm/uaccess.h> /* kernel <-> user copy */
#include <linux/init.h> /* __init (when not using as a module) */ #include <linux/init.h> /* __init (when not using as a module) */
/* Debug */
unsigned int cycx_debug; unsigned int cycx_debug;
MODULE_AUTHOR("Arnaldo Carvalho de Melo"); MODULE_AUTHOR("Arnaldo Carvalho de Melo");
...@@ -61,18 +62,17 @@ MODULE_PARM_DESC(cycx_debug, "cyclomx debug level"); ...@@ -61,18 +62,17 @@ MODULE_PARM_DESC(cycx_debug, "cyclomx debug level");
/* Defines & Macros */ /* Defines & Macros */
#define DRV_VERSION 0 /* version number */ #define CYCX_DRV_VERSION 0 /* version number */
#define DRV_RELEASE 10 /* release (minor version) number */ #define CYCX_DRV_RELEASE 11 /* release (minor version) number */
#define MAX_CARDS 1 /* max number of adapters */ #define CYCX_MAX_CARDS 1 /* max number of adapters */
#define CONFIG_CYCLOMX_CARDS 1 #define CONFIG_CYCX_CARDS 1
/* Function Prototypes */ /* Function Prototypes */
/* WAN link driver entry points */ /* WAN link driver entry points */
static int setup(struct wan_device *wandev, wandev_conf_t *conf); static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf);
static int shutdown(struct wan_device *wandev); static int cycx_wan_shutdown(struct wan_device *wandev);
static int ioctl(struct wan_device *wandev, unsigned cmd, unsigned long arg);
/* Miscellaneous functions */ /* Miscellaneous functions */
static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs);
...@@ -82,12 +82,12 @@ static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs); ...@@ -82,12 +82,12 @@ static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs);
*/ */
/* private data */ /* private data */
static char drvname[] = "cyclomx"; static char cycx_drvname[] = "cyclomx";
static char fullname[] = "CYCLOM 2X(tm) Sync Card Driver"; static char cycx_fullname[] = "CYCLOM 2X(tm) Sync Card Driver";
static char copyright[] = "(c) 1998-2001 Arnaldo Carvalho de Melo " static char cycx_copyright[] = "(c) 1998-2003 Arnaldo Carvalho de Melo "
"<acme@conectiva.com.br>"; "<acme@conectiva.com.br>";
static int ncards = CONFIG_CYCLOMX_CARDS; static int cycx_ncards = CONFIG_CYCX_CARDS;
static struct cycx_device *card_array; /* adapter data space */ static struct cycx_device *cycx_card_array; /* adapter data space */
/* Kernel Loadable Module Entry Points */ /* Kernel Loadable Module Entry Points */
...@@ -103,51 +103,52 @@ static struct cycx_device *card_array; /* adapter data space */ ...@@ -103,51 +103,52 @@ static struct cycx_device *card_array; /* adapter data space */
* < 0 error. * < 0 error.
* Context: process * Context: process
*/ */
int __init cyclomx_init(void) int __init cycx_init(void)
{ {
int cnt, err = -ENOMEM; int cnt, err = -ENOMEM;
printk(KERN_INFO "%s v%u.%u %s\n", printk(KERN_INFO "%s v%u.%u %s\n",
fullname, DRV_VERSION, DRV_RELEASE, copyright); cycx_fullname, CYCX_DRV_VERSION, CYCX_DRV_RELEASE,
cycx_copyright);
/* Verify number of cards and allocate adapter data space */ /* Verify number of cards and allocate adapter data space */
ncards = min_t(int, ncards, MAX_CARDS); cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
ncards = max_t(int, ncards, 1); cycx_ncards = max_t(int, cycx_ncards, 1);
card_array = kmalloc(sizeof(struct cycx_device) * ncards, GFP_KERNEL); cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards,
if (!card_array) GFP_KERNEL);
if (!cycx_card_array)
goto out; goto out;
memset(card_array, 0, sizeof(struct cycx_device) * ncards); memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards);
/* Register adapters with WAN router */ /* Register adapters with WAN router */
for (cnt = 0; cnt < ncards; ++cnt) { for (cnt = 0; cnt < cycx_ncards; ++cnt) {
struct cycx_device *card = &card_array[cnt]; struct cycx_device *card = &cycx_card_array[cnt];
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
sprintf(card->devname, "%s%d", drvname, cnt + 1); sprintf(card->devname, "%s%d", cycx_drvname, cnt + 1);
wandev->magic = ROUTER_MAGIC; wandev->magic = ROUTER_MAGIC;
wandev->name = card->devname; wandev->name = card->devname;
wandev->private = card; wandev->private = card;
wandev->setup = setup; wandev->setup = cycx_wan_setup;
wandev->shutdown = shutdown; wandev->shutdown = cycx_wan_shutdown;
wandev->ioctl = ioctl;
err = register_wan_device(wandev); err = register_wan_device(wandev);
if (err) { if (err) {
printk(KERN_ERR "%s: %s registration failed with " printk(KERN_ERR "%s: %s registration failed with "
"error %d!\n", "error %d!\n",
drvname, card->devname, err); cycx_drvname, card->devname, err);
break; break;
} }
} }
err = -ENODEV; err = -ENODEV;
if (!cnt) { if (!cnt) {
kfree(card_array); kfree(cycx_card_array);
goto out; goto out;
} }
err = 0; err = 0;
ncards = cnt; /* adjust actual number of cards */ cycx_ncards = cnt; /* adjust actual number of cards */
out: return err; out: return err;
} }
...@@ -156,16 +157,16 @@ out: return err; ...@@ -156,16 +157,16 @@ out: return err;
* o unregister all adapters from the WAN router * o unregister all adapters from the WAN router
* o release all remaining system resources * o release all remaining system resources
*/ */
static void __exit cyclomx_cleanup(void) static void __exit cycx_exit(void)
{ {
int i = 0; int i = 0;
for (; i < ncards; ++i) { for (; i < cycx_ncards; ++i) {
struct cycx_device *card = &card_array[i]; struct cycx_device *card = &cycx_card_array[i];
unregister_wan_device(card->devname); unregister_wan_device(card->devname);
} }
kfree(card_array); kfree(cycx_card_array);
} }
/* WAN Device Driver Entry Points */ /* WAN Device Driver Entry Points */
...@@ -181,9 +182,9 @@ static void __exit cyclomx_cleanup(void) ...@@ -181,9 +182,9 @@ static void __exit cyclomx_cleanup(void)
* configuration structure is in kernel memory (including extended data, if * configuration structure is in kernel memory (including extended data, if
* any). * any).
*/ */
static int setup(struct wan_device *wandev, wandev_conf_t *conf) static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf)
{ {
int err = -EFAULT; int rc = -EFAULT;
struct cycx_device *card; struct cycx_device *card;
int irq; int irq;
...@@ -193,11 +194,11 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf) ...@@ -193,11 +194,11 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf)
goto out; goto out;
card = wandev->private; card = wandev->private;
err = -EBUSY; rc = -EBUSY;
if (wandev->state != WAN_UNCONFIGURED) if (wandev->state != WAN_UNCONFIGURED)
goto out; goto out;
err = -EINVAL; rc = -EINVAL;
if (!conf->data_size || !conf->data) { if (!conf->data_size || !conf->data) {
printk(KERN_ERR "%s: firmware not found in configuration " printk(KERN_ERR "%s: firmware not found in configuration "
"data!\n", wandev->name); "data!\n", wandev->name);
...@@ -228,8 +229,8 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf) ...@@ -228,8 +229,8 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf)
card->lock = SPIN_LOCK_UNLOCKED; card->lock = SPIN_LOCK_UNLOCKED;
init_waitqueue_head(&card->wait_stats); init_waitqueue_head(&card->wait_stats);
err = cycx_setup(&card->hw, conf->data, conf->data_size); rc = cycx_setup(&card->hw, conf->data, conf->data_size);
if (err) if (rc)
goto out_irq; goto out_irq;
/* Initialize WAN device data space */ /* Initialize WAN device data space */
...@@ -244,22 +245,23 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf) ...@@ -244,22 +245,23 @@ static int setup(struct wan_device *wandev, wandev_conf_t *conf)
switch (card->hw.fwid) { switch (card->hw.fwid) {
#ifdef CONFIG_CYCLOMX_X25 #ifdef CONFIG_CYCLOMX_X25
case CFID_X25_2X: case CFID_X25_2X:
err = cyx_init(card, conf); rc = cycx_x25_wan_init(card, conf);
break; break;
#endif #endif
default: default:
printk(KERN_ERR "%s: this firmware is not supported!\n", printk(KERN_ERR "%s: this firmware is not supported!\n",
wandev->name); wandev->name);
err = -EINVAL; rc = -EINVAL;
} }
if (err) { if (rc) {
cycx_down(&card->hw); cycx_down(&card->hw);
goto out_irq; goto out_irq;
} }
err = 0; rc = 0;
out: return err; out:
return rc;
out_irq: out_irq:
free_irq(irq, card); free_irq(irq, card);
goto out; goto out;
...@@ -273,7 +275,7 @@ out: return err; ...@@ -273,7 +275,7 @@ out: return err;
* This function is called by the router when device is being unregistered or * This function is called by the router when device is being unregistered or
* when it handles ROUTER_DOWN IOCTL. * when it handles ROUTER_DOWN IOCTL.
*/ */
static int shutdown(struct wan_device *wandev) static int cycx_wan_shutdown(struct wan_device *wandev)
{ {
int ret = -EFAULT; int ret = -EFAULT;
struct cycx_device *card; struct cycx_device *card;
...@@ -295,21 +297,6 @@ static int shutdown(struct wan_device *wandev) ...@@ -295,21 +297,6 @@ static int shutdown(struct wan_device *wandev)
out: return ret; out: return ret;
} }
/*
* Driver I/O control.
* o verify arguments
* o perform requested action
*
* This function is called when router handles one of the reserved user
* IOCTLs. Note that 'arg' still points to user address space.
*
* no reserved ioctls for the cyclom 2x up to now
*/
static int ioctl(struct wan_device *wandev, unsigned cmd, unsigned long arg)
{
return -EINVAL;
}
/* Miscellaneous */ /* Miscellaneous */
/* /*
* Cyclom 2X Interrupt Service Routine. * Cyclom 2X Interrupt Service Routine.
...@@ -332,11 +319,12 @@ static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -332,11 +319,12 @@ static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs)
if (card->isr) if (card->isr)
card->isr(card); card->isr(card);
return IRQ_HANDLED; return IRQ_HANDLED;
out: return IRQ_NONE; out:
return IRQ_NONE;
} }
/* Set WAN device state. */ /* Set WAN device state. */
void cyclomx_set_state(struct cycx_device *card, int state) void cycx_set_state(struct cycx_device *card, int state)
{ {
unsigned long flags; unsigned long flags;
char *string_state = NULL; char *string_state = NULL;
...@@ -360,5 +348,5 @@ void cyclomx_set_state(struct cycx_device *card, int state) ...@@ -360,5 +348,5 @@ void cyclomx_set_state(struct cycx_device *card, int state)
spin_unlock_irqrestore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
} }
module_init(cyclomx_init); module_init(cycx_init);
module_exit(cyclomx_cleanup); module_exit(cycx_exit);
...@@ -94,8 +94,8 @@ ...@@ -94,8 +94,8 @@
#include <linux/cycx_x25.h> /* X.25 firmware API definitions */ #include <linux/cycx_x25.h> /* X.25 firmware API definitions */
/* Defines & Macros */ /* Defines & Macros */
#define MAX_CMD_RETRY 5 #define CYCX_X25_MAX_CMD_RETRY 5
#define X25_CHAN_MTU 2048 /* unfragmented logical channel MTU */ #define CYCX_X25_CHAN_MTU 2048 /* unfragmented logical channel MTU */
/* Data Structures */ /* Data Structures */
/* This is an extension of the 'struct net_device' we create for each network /* This is an extension of the 'struct net_device' we create for each network
...@@ -123,56 +123,65 @@ struct cycx_x25_channel { ...@@ -123,56 +123,65 @@ struct cycx_x25_channel {
/* Function Prototypes */ /* Function Prototypes */
/* WAN link driver entry points. These are called by the WAN router module. */ /* WAN link driver entry points. These are called by the WAN router module. */
static int update(struct wan_device *wandev), static int cycx_wan_update(struct wan_device *wandev),
new_if(struct wan_device *wandev, struct net_device *dev, cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
wanif_conf_t *conf), wanif_conf_t *conf),
del_if(struct wan_device *wandev, struct net_device *dev); cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev);
/* Network device interface */ /* Network device interface */
static int if_init(struct net_device *dev), static int cycx_netdevice_init(struct net_device *dev),
if_open(struct net_device *dev), cycx_netdevice_open(struct net_device *dev),
if_close(struct net_device *dev), cycx_netdevice_stop(struct net_device *dev),
if_header(struct sk_buff *skb, struct net_device *dev, cycx_netdevice_hard_header(struct sk_buff *skb,
u16 type, void *daddr, void *saddr, unsigned len), struct net_device *dev, u16 type,
if_rebuild_hdr(struct sk_buff *skb), void *daddr, void *saddr, unsigned len),
if_send(struct sk_buff *skb, struct net_device *dev); cycx_netdevice_rebuild_header(struct sk_buff *skb),
cycx_netdevice_hard_start_xmit(struct sk_buff *skb,
static struct net_device_stats *if_stats(struct net_device *dev); struct net_device *dev);
static struct net_device_stats *
cycx_netdevice_get_stats(struct net_device *dev);
/* Interrupt handlers */ /* Interrupt handlers */
static void cyx_isr(struct cycx_device *card), static void cycx_x25_irq_handler(struct cycx_device *card),
tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), cycx_x25_irq_tx(struct cycx_device *card, struct cycx_x25_cmd *cmd),
rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd),
log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), cycx_x25_irq_log(struct cycx_device *card,
stat_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), struct cycx_x25_cmd *cmd),
connect_confirm_intr(struct cycx_device *card, cycx_x25_irq_stat(struct cycx_device *card,
struct cycx_x25_cmd *cmd),
cycx_x25_irq_connect_confirm(struct cycx_device *card,
struct cycx_x25_cmd *cmd),
cycx_x25_irq_disconnect_confirm(struct cycx_device *card,
struct cycx_x25_cmd *cmd),
cycx_x25_irq_connect(struct cycx_device *card,
struct cycx_x25_cmd *cmd), struct cycx_x25_cmd *cmd),
disconnect_confirm_intr(struct cycx_device *card, cycx_x25_irq_disconnect(struct cycx_device *card,
struct cycx_x25_cmd *cmd), struct cycx_x25_cmd *cmd),
connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), cycx_x25_irq_spurious(struct cycx_device *card,
disconnect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd), struct cycx_x25_cmd *cmd);
spur_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd);
/* X.25 firmware interface functions */ /* X.25 firmware interface functions */
static int x25_configure(struct cycx_device *card, static int cycx_x25_configure(struct cycx_device *card,
struct cycx_x25_config *conf), struct cycx_x25_config *conf),
x25_get_stats(struct cycx_device *card), cycx_x25_get_stats(struct cycx_device *card),
x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm, int len, cycx_x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm,
void *buf), int len, void *buf),
x25_connect_response(struct cycx_device *card, cycx_x25_connect_response(struct cycx_device *card,
struct cycx_x25_channel *chan), struct cycx_x25_channel *chan),
x25_disconnect_response(struct cycx_device *card, u8 link, u8 lcn); cycx_x25_disconnect_response(struct cycx_device *card, u8 link,
u8 lcn);
/* channel functions */ /* channel functions */
static int chan_connect(struct net_device *dev), static int cycx_x25_chan_connect(struct net_device *dev),
chan_send(struct net_device *dev, struct sk_buff *skb); cycx_x25_chan_send(struct net_device *dev, struct sk_buff *skb);
static void chan_disconnect(struct net_device *dev), static void cycx_x25_chan_disconnect(struct net_device *dev),
chan_x25_send_event(struct net_device *dev, u8 event); cycx_x25_chan_send_event(struct net_device *dev, u8 event);
/* Miscellaneous functions */ /* Miscellaneous functions */
static void set_chan_state(struct net_device *dev, u8 state), static void cycx_x25_set_chan_state(struct net_device *dev, u8 state),
chan_timer(unsigned long d); cycx_x25_chan_timer(unsigned long d);
static void nibble_to_byte(u8 *s, u8 *d, u8 len, u8 nibble), static void nibble_to_byte(u8 *s, u8 *d, u8 len, u8 nibble),
reset_timer(struct net_device *dev); reset_timer(struct net_device *dev);
...@@ -182,20 +191,21 @@ static u8 log2(u32 n); ...@@ -182,20 +191,21 @@ static u8 log2(u32 n);
static unsigned dec_to_uint(u8 *str, int len); static unsigned dec_to_uint(u8 *str, int len);
static struct net_device *get_dev_by_lcn(struct wan_device *wandev, s16 lcn); static struct net_device *cycx_x25_get_dev_by_lcn(struct wan_device *wandev,
static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev, s16 lcn);
char *dte); static struct net_device *
cycx_x25_get_dev_by_dte_addr(struct wan_device *wandev, char *dte);
#ifdef CYCLOMX_X25_DEBUG #ifdef CYCLOMX_X25_DEBUG
static void hex_dump(char *msg, unsigned char *p, int len); static void hex_dump(char *msg, unsigned char *p, int len);
static void x25_dump_config(struct cycx_x25_config *conf); static void cycx_x25_dump_config(struct cycx_x25_config *conf);
static void x25_dump_stats(struct cycx_x25_stats *stats); static void cycx_x25_dump_stats(struct cycx_x25_stats *stats);
static void x25_dump_devs(struct wan_device *wandev); static void cycx_x25_dump_devs(struct wan_device *wandev);
#else #else
#define hex_dump(msg, p, len) #define hex_dump(msg, p, len)
#define x25_dump_config(conf) #define cycx_x25_dump_config(conf)
#define x25_dump_stats(stats) #define cycx_x25_dump_stats(stats)
#define x25_dump_devs(wandev) #define cycx_x25_dump_devs(wandev)
#endif #endif
/* Public Functions */ /* Public Functions */
...@@ -208,7 +218,7 @@ static void x25_dump_devs(struct wan_device *wandev); ...@@ -208,7 +218,7 @@ static void x25_dump_devs(struct wan_device *wandev);
* *
* Return: 0 o.k. * Return: 0 o.k.
* < 0 failure. */ * < 0 failure. */
int cyx_init(struct cycx_device *card, wandev_conf_t *conf) int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf)
{ {
struct cycx_x25_config cfg; struct cycx_x25_config cfg;
...@@ -306,7 +316,7 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf) ...@@ -306,7 +316,7 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf)
cfg.n2 = min_t(unsigned int, conf->u.x25.n2, 30); cfg.n2 = min_t(unsigned int, conf->u.x25.n2, 30);
/* initialize adapter */ /* initialize adapter */
if (x25_configure(card, &cfg)) if (cycx_x25_configure(card, &cfg))
return -EIO; return -EIO;
/* Initialize protocol-specific fields of adapter data space */ /* Initialize protocol-specific fields of adapter data space */
...@@ -314,11 +324,11 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf) ...@@ -314,11 +324,11 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf)
card->wandev.interface = conf->interface; card->wandev.interface = conf->interface;
card->wandev.clocking = conf->clocking; card->wandev.clocking = conf->clocking;
card->wandev.station = conf->station; card->wandev.station = conf->station;
card->isr = cyx_isr; card->isr = cycx_x25_irq_handler;
card->exec = NULL; card->exec = NULL;
card->wandev.update = update; card->wandev.update = cycx_wan_update;
card->wandev.new_if = new_if; card->wandev.new_if = cycx_wan_new_if;
card->wandev.del_if = del_if; card->wandev.del_if = cycx_wan_del_if;
card->wandev.state = WAN_DISCONNECTED; card->wandev.state = WAN_DISCONNECTED;
return 0; return 0;
...@@ -326,7 +336,7 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf) ...@@ -326,7 +336,7 @@ int cyx_init(struct cycx_device *card, wandev_conf_t *conf)
/* WAN Device Driver Entry Points */ /* WAN Device Driver Entry Points */
/* Update device status & statistics. */ /* Update device status & statistics. */
static int update(struct wan_device *wandev) static int cycx_wan_update(struct wan_device *wandev)
{ {
/* sanity checks */ /* sanity checks */
if (!wandev || !wandev->private) if (!wandev || !wandev->private)
...@@ -335,7 +345,7 @@ static int update(struct wan_device *wandev) ...@@ -335,7 +345,7 @@ static int update(struct wan_device *wandev)
if (wandev->state == WAN_UNCONFIGURED) if (wandev->state == WAN_UNCONFIGURED)
return -ENODEV; return -ENODEV;
x25_get_stats(wandev->private); cycx_x25_get_stats(wandev->private);
return 0; return 0;
} }
...@@ -350,8 +360,8 @@ static int update(struct wan_device *wandev) ...@@ -350,8 +360,8 @@ static int update(struct wan_device *wandev)
* *
* Return: 0 o.k. * Return: 0 o.k.
* < 0 failure (channel will not be created) */ * < 0 failure (channel will not be created) */
static int new_if(struct wan_device *wandev, struct net_device *dev, static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
wanif_conf_t *conf) wanif_conf_t *conf)
{ {
struct cycx_device *card = wandev->private; struct cycx_device *card = wandev->private;
struct cycx_x25_channel *chan; struct cycx_x25_channel *chan;
...@@ -402,8 +412,8 @@ static int new_if(struct wan_device *wandev, struct net_device *dev, ...@@ -402,8 +412,8 @@ static int new_if(struct wan_device *wandev, struct net_device *dev,
chan->svc = 1; chan->svc = 1;
strncpy(chan->addr, &conf->addr[1], WAN_ADDRESS_SZ); strncpy(chan->addr, &conf->addr[1], WAN_ADDRESS_SZ);
init_timer(&chan->timer); init_timer(&chan->timer);
chan->timer.function = chan_timer; chan->timer.function = cycx_x25_chan_timer;
chan->timer.data = (unsigned long)dev; chan->timer.data = (unsigned long)dev;
/* Set channel timeouts (default if not specified) */ /* Set channel timeouts (default if not specified) */
chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90; chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90;
...@@ -434,14 +444,14 @@ static int new_if(struct wan_device *wandev, struct net_device *dev, ...@@ -434,14 +444,14 @@ static int new_if(struct wan_device *wandev, struct net_device *dev,
/* prepare network device data space for registration */ /* prepare network device data space for registration */
strcpy(dev->name, chan->name); strcpy(dev->name, chan->name);
dev->init = if_init; dev->init = cycx_netdevice_init;
dev->priv = chan; dev->priv = chan;
return 0; return 0;
} }
/* Delete logical channel. */ /* Delete logical channel. */
static int del_if(struct wan_device *wandev, struct net_device *dev) static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
{ {
if (dev->priv) { if (dev->priv) {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
...@@ -467,43 +477,44 @@ static int del_if(struct wan_device *wandev, struct net_device *dev) ...@@ -467,43 +477,44 @@ static int del_if(struct wan_device *wandev, struct net_device *dev)
* This routine is called only once for each interface, during Linux network * This routine is called only once for each interface, during Linux network
* interface registration. Returning anything but zero will fail interface * interface registration. Returning anything but zero will fail interface
* registration. */ * registration. */
static int if_init(struct net_device *dev) static int cycx_netdevice_init(struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
struct cycx_device *card = chan->card; struct cycx_device *card = chan->card;
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
/* Initialize device driver entry points */ /* Initialize device driver entry points */
dev->open = if_open; dev->open = cycx_netdevice_open;
dev->stop = if_close; dev->stop = cycx_netdevice_stop;
dev->hard_header = if_header; dev->hard_header = cycx_netdevice_hard_header;
dev->rebuild_header = if_rebuild_hdr; dev->rebuild_header = cycx_netdevice_rebuild_header;
dev->hard_start_xmit = if_send; dev->hard_start_xmit = cycx_netdevice_hard_start_xmit;
dev->get_stats = if_stats; dev->get_stats = cycx_netdevice_get_stats;
/* Initialize media-specific parameters */ /* Initialize media-specific parameters */
dev->mtu = X25_CHAN_MTU; dev->mtu = CYCX_X25_CHAN_MTU;
dev->type = ARPHRD_HWX25; /* ARP h/w type */ dev->type = ARPHRD_HWX25; /* ARP h/w type */
dev->hard_header_len = 0; /* media header length */ dev->hard_header_len = 0; /* media header length */
dev->addr_len = 0; /* hardware address length */ dev->addr_len = 0; /* hardware address length */
if (!chan->svc) if (!chan->svc)
*(u16*)dev->dev_addr = htons(chan->lcn); *(u16*)dev->dev_addr = htons(chan->lcn);
/* Initialize hardware parameters (just for reference) */ /* Initialize hardware parameters (just for reference) */
dev->irq = wandev->irq; dev->irq = wandev->irq;
dev->dma = wandev->dma; dev->dma = wandev->dma;
dev->base_addr = wandev->ioport; dev->base_addr = wandev->ioport;
dev->mem_start = (unsigned long)wandev->maddr; dev->mem_start = (unsigned long)wandev->maddr;
dev->mem_end = (unsigned long)(wandev->maddr + wandev->msize - 1); dev->mem_end = (unsigned long)(wandev->maddr +
dev->flags |= IFF_NOARP; wandev->msize - 1);
dev->flags |= IFF_NOARP;
/* Set transmit buffer queue length */ /* Set transmit buffer queue length */
dev->tx_queue_len = 10; dev->tx_queue_len = 10;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
/* Initialize socket buffers */ /* Initialize socket buffers */
set_chan_state(dev, WAN_DISCONNECTED); cycx_x25_set_chan_state(dev, WAN_DISCONNECTED);
return 0; return 0;
} }
...@@ -513,7 +524,7 @@ static int if_init(struct net_device *dev) ...@@ -513,7 +524,7 @@ static int if_init(struct net_device *dev)
* o if link is disconnected then initiate connection * o if link is disconnected then initiate connection
* *
* Return 0 if O.k. or errno. */ * Return 0 if O.k. or errno. */
static int if_open(struct net_device *dev) static int cycx_netdevice_open(struct net_device *dev)
{ {
if (netif_running(dev)) if (netif_running(dev))
return -EBUSY; /* only one open is allowed */ return -EBUSY; /* only one open is allowed */
...@@ -525,14 +536,14 @@ static int if_open(struct net_device *dev) ...@@ -525,14 +536,14 @@ static int if_open(struct net_device *dev)
/* Close network interface. /* Close network interface.
* o reset flags. * o reset flags.
* o if there's no more open channels then disconnect physical link. */ * o if there's no more open channels then disconnect physical link. */
static int if_close(struct net_device *dev) static int cycx_netdevice_stop(struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
netif_stop_queue(dev); netif_stop_queue(dev);
if (chan->state == WAN_CONNECTED || chan->state == WAN_CONNECTING) if (chan->state == WAN_CONNECTED || chan->state == WAN_CONNECTING)
chan_disconnect(dev); cycx_x25_chan_disconnect(dev);
return 0; return 0;
} }
...@@ -545,8 +556,9 @@ static int if_close(struct net_device *dev) ...@@ -545,8 +556,9 @@ static int if_close(struct net_device *dev)
* set skb->protocol to 0 and discard packet later. * set skb->protocol to 0 and discard packet later.
* *
* Return: media header length. */ * Return: media header length. */
static int if_header(struct sk_buff *skb, struct net_device *dev, static int cycx_netdevice_hard_header(struct sk_buff *skb,
u16 type, void *daddr, void *saddr, unsigned len) struct net_device *dev, u16 type,
void *daddr, void *saddr, unsigned len)
{ {
skb->protocol = type; skb->protocol = type;
...@@ -556,7 +568,7 @@ static int if_header(struct sk_buff *skb, struct net_device *dev, ...@@ -556,7 +568,7 @@ static int if_header(struct sk_buff *skb, struct net_device *dev,
/* * Re-build media header. /* * Re-build media header.
* Return: 1 physical address resolved. * Return: 1 physical address resolved.
* 0 physical address not resolved */ * 0 physical address not resolved */
static int if_rebuild_hdr(struct sk_buff *skb) static int cycx_netdevice_rebuild_header(struct sk_buff *skb)
{ {
return 1; return 1;
} }
...@@ -576,7 +588,8 @@ static int if_rebuild_hdr(struct sk_buff *skb) ...@@ -576,7 +588,8 @@ static int if_rebuild_hdr(struct sk_buff *skb)
* bottom half" (with interrupts enabled). * bottom half" (with interrupts enabled).
* 2. Setting tbusy flag will inhibit further transmit requests from the * 2. Setting tbusy flag will inhibit further transmit requests from the
* protocol stack and can be used for flow control with protocol layer. */ * protocol stack and can be used for flow control with protocol layer. */
static int if_send(struct sk_buff *skb, struct net_device *dev) static int cycx_netdevice_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
struct cycx_device *card = chan->card; struct cycx_device *card = chan->card;
...@@ -595,7 +608,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev) ...@@ -595,7 +608,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev)
} else if (chan->protocol == ETH_P_IP) { } else if (chan->protocol == ETH_P_IP) {
switch (chan->state) { switch (chan->state) {
case WAN_DISCONNECTED: case WAN_DISCONNECTED:
if (chan_connect(dev)) { if (cycx_x25_chan_connect(dev)) {
netif_stop_queue(dev); netif_stop_queue(dev);
return -EBUSY; return -EBUSY;
} }
...@@ -605,7 +618,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev) ...@@ -605,7 +618,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies; dev->trans_start = jiffies;
netif_stop_queue(dev); netif_stop_queue(dev);
if (chan_send(dev, skb)) if (cycx_x25_chan_send(dev, skb))
return -EBUSY; return -EBUSY;
break; break;
...@@ -617,10 +630,10 @@ static int if_send(struct sk_buff *skb, struct net_device *dev) ...@@ -617,10 +630,10 @@ static int if_send(struct sk_buff *skb, struct net_device *dev)
switch (skb->data[0]) { switch (skb->data[0]) {
case 0: break; case 0: break;
case 1: /* Connect request */ case 1: /* Connect request */
chan_connect(dev); cycx_x25_chan_connect(dev);
goto free_packet; goto free_packet;
case 2: /* Disconnect request */ case 2: /* Disconnect request */
chan_disconnect(dev); cycx_x25_chan_disconnect(dev);
goto free_packet; goto free_packet;
default: default:
printk(KERN_INFO printk(KERN_INFO
...@@ -635,7 +648,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev) ...@@ -635,7 +648,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies; dev->trans_start = jiffies;
netif_stop_queue(dev); netif_stop_queue(dev);
if (chan_send(dev, skb)) { if (cycx_x25_chan_send(dev, skb)) {
/* prepare for future retransmissions */ /* prepare for future retransmissions */
skb_push(skb, 1); skb_push(skb, 1);
return -EBUSY; return -EBUSY;
...@@ -650,7 +663,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev) ...@@ -650,7 +663,7 @@ static int if_send(struct sk_buff *skb, struct net_device *dev)
/* Get Ethernet-style interface statistics. /* Get Ethernet-style interface statistics.
* Return a pointer to struct net_device_stats */ * Return a pointer to struct net_device_stats */
static struct net_device_stats *if_stats(struct net_device *dev) static struct net_device_stats *cycx_netdevice_get_stats(struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
...@@ -659,7 +672,7 @@ static struct net_device_stats *if_stats(struct net_device *dev) ...@@ -659,7 +672,7 @@ static struct net_device_stats *if_stats(struct net_device *dev)
/* Interrupt Handlers */ /* Interrupt Handlers */
/* X.25 Interrupt Service Routine. */ /* X.25 Interrupt Service Routine. */
static void cyx_isr(struct cycx_device *card) static void cycx_x25_irq_handler(struct cycx_device *card)
{ {
struct cycx_x25_cmd cmd; struct cycx_x25_cmd cmd;
u16 z = 0; u16 z = 0;
...@@ -670,37 +683,38 @@ static void cyx_isr(struct cycx_device *card) ...@@ -670,37 +683,38 @@ static void cyx_isr(struct cycx_device *card)
switch (cmd.command) { switch (cmd.command) {
case X25_DATA_INDICATION: case X25_DATA_INDICATION:
rx_intr(card, &cmd); cycx_x25_irq_rx(card, &cmd);
break; break;
case X25_ACK_FROM_VC: case X25_ACK_FROM_VC:
tx_intr(card, &cmd); cycx_x25_irq_tx(card, &cmd);
break; break;
case X25_LOG: case X25_LOG:
log_intr(card, &cmd); cycx_x25_irq_log(card, &cmd);
break; break;
case X25_STATISTIC: case X25_STATISTIC:
stat_intr(card, &cmd); cycx_x25_irq_stat(card, &cmd);
break; break;
case X25_CONNECT_CONFIRM: case X25_CONNECT_CONFIRM:
connect_confirm_intr(card, &cmd); cycx_x25_irq_connect_confirm(card, &cmd);
break; break;
case X25_CONNECT_INDICATION: case X25_CONNECT_INDICATION:
connect_intr(card, &cmd); cycx_x25_irq_connect(card, &cmd);
break; break;
case X25_DISCONNECT_INDICATION: case X25_DISCONNECT_INDICATION:
disconnect_intr(card, &cmd); cycx_x25_irq_disconnect(card, &cmd);
break; break;
case X25_DISCONNECT_CONFIRM: case X25_DISCONNECT_CONFIRM:
disconnect_confirm_intr(card, &cmd); cycx_x25_irq_disconnect_confirm(card, &cmd);
break; break;
case X25_LINE_ON: case X25_LINE_ON:
cyclomx_set_state(card, WAN_CONNECTED); cycx_set_state(card, WAN_CONNECTED);
break; break;
case X25_LINE_OFF: case X25_LINE_OFF:
cyclomx_set_state(card, WAN_DISCONNECTED); cycx_set_state(card, WAN_DISCONNECTED);
break; break;
default: default:
spur_intr(card, &cmd); /* unwanted interrupt */ cycx_x25_irq_spurious(card, &cmd);
break;
} }
cycx_poke(&card->hw, 0, &z, sizeof(z)); cycx_poke(&card->hw, 0, &z, sizeof(z));
...@@ -711,7 +725,7 @@ static void cyx_isr(struct cycx_device *card) ...@@ -711,7 +725,7 @@ static void cyx_isr(struct cycx_device *card)
/* Transmit interrupt handler. /* Transmit interrupt handler.
* o Release socket buffer * o Release socket buffer
* o Clear 'tbusy' flag */ * o Clear 'tbusy' flag */
static void tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_tx(struct cycx_device *card, struct cycx_x25_cmd *cmd)
{ {
struct net_device *dev; struct net_device *dev;
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
...@@ -720,7 +734,8 @@ static void tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -720,7 +734,8 @@ static void tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn)); cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn));
/* unbusy device and then dev_tint(); */ /* unbusy device and then dev_tint(); */
if ((dev = get_dev_by_lcn(wandev, lcn)) != NULL) { dev = cycx_x25_get_dev_by_lcn(wandev, lcn);
if (dev) {
card->buff_int_mode_unbusy = 1; card->buff_int_mode_unbusy = 1;
netif_wake_queue(dev); netif_wake_queue(dev);
} else } else
...@@ -742,7 +757,7 @@ static void tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -742,7 +757,7 @@ static void tx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
* expected on this channel. * expected on this channel.
* 2. If something goes wrong and X.25 packet has to be dropped (e.g. no * 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. */ * socket buffers available) the whole packet sequence must be discarded. */
static void rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd)
{ {
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
struct net_device *dev; struct net_device *dev;
...@@ -755,7 +770,8 @@ static void rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -755,7 +770,8 @@ static void rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
cycx_peek(&card->hw, cmd->buf + 4, &bitm, sizeof(bitm)); cycx_peek(&card->hw, cmd->buf + 4, &bitm, sizeof(bitm));
bitm &= 0x10; bitm &= 0x10;
if ((dev = get_dev_by_lcn(wandev, lcn)) == NULL) { dev = cycx_x25_get_dev_by_lcn(wandev, lcn);
if (!dev) {
/* Invalid channel, discard packet */ /* Invalid channel, discard packet */
printk(KERN_INFO "%s: receiving on orphaned LCN %d!\n", printk(KERN_INFO "%s: receiving on orphaned LCN %d!\n",
card->devname, lcn); card->devname, lcn);
...@@ -826,7 +842,8 @@ static void rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -826,7 +842,8 @@ static void rx_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
} }
/* Connect interrupt handler. */ /* Connect interrupt handler. */
static void connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_connect(struct cycx_device *card,
struct cycx_x25_cmd *cmd)
{ {
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
struct net_device *dev = NULL; struct net_device *dev = NULL;
...@@ -851,10 +868,11 @@ static void connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -851,10 +868,11 @@ static void connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
if (sizerem) if (sizerem)
nibble_to_byte(d + (sizeloc >> 1), rem, sizerem, sizeloc & 1); nibble_to_byte(d + (sizeloc >> 1), rem, sizerem, sizeloc & 1);
dprintk(1, KERN_INFO "connect_intr:lcn=%d, local=%s, remote=%s\n", dprintk(1, KERN_INFO "%s:lcn=%d, local=%s, remote=%s\n",
lcn, loc, rem); __FUNCTION__, lcn, loc, rem);
if ((dev = get_dev_by_dte_addr(wandev, rem)) == NULL) { dev = cycx_x25_get_dev_by_dte_addr(wandev, rem);
if (!dev) {
/* Invalid channel, discard packet */ /* Invalid channel, discard packet */
printk(KERN_INFO "%s: connect not expected: remote %s!\n", printk(KERN_INFO "%s: connect not expected: remote %s!\n",
card->devname, rem); card->devname, rem);
...@@ -863,13 +881,13 @@ static void connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -863,13 +881,13 @@ static void connect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
chan = dev->priv; chan = dev->priv;
chan->lcn = lcn; chan->lcn = lcn;
x25_connect_response(card, chan); cycx_x25_connect_response(card, chan);
set_chan_state(dev, WAN_CONNECTED); cycx_x25_set_chan_state(dev, WAN_CONNECTED);
} }
/* Connect confirm interrupt handler. */ /* Connect confirm interrupt handler. */
static void connect_confirm_intr(struct cycx_device *card, static void cycx_x25_irq_connect_confirm(struct cycx_device *card,
struct cycx_x25_cmd *cmd) struct cycx_x25_cmd *cmd)
{ {
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
struct net_device *dev; struct net_device *dev;
...@@ -878,10 +896,11 @@ static void connect_confirm_intr(struct cycx_device *card, ...@@ -878,10 +896,11 @@ static void connect_confirm_intr(struct cycx_device *card,
cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn)); cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn));
cycx_peek(&card->hw, cmd->buf + 1, &key, sizeof(key)); cycx_peek(&card->hw, cmd->buf + 1, &key, sizeof(key));
dprintk(1, KERN_INFO "%s: connect_confirm_intr:lcn=%d, key=%d\n", dprintk(1, KERN_INFO "%s: %s:lcn=%d, key=%d\n",
card->devname, lcn, key); card->devname, __FUNCTION__, lcn, key);
if ((dev = get_dev_by_lcn(wandev, -key)) == NULL) { dev = cycx_x25_get_dev_by_lcn(wandev, -key);
if (!dev) {
/* Invalid channel, discard packet */ /* Invalid channel, discard packet */
clear_bit(--key, (void*)&card->u.x.connection_keys); clear_bit(--key, (void*)&card->u.x.connection_keys);
printk(KERN_INFO "%s: connect confirm not expected: lcn %d, " printk(KERN_INFO "%s: connect confirm not expected: lcn %d, "
...@@ -892,51 +911,54 @@ static void connect_confirm_intr(struct cycx_device *card, ...@@ -892,51 +911,54 @@ static void connect_confirm_intr(struct cycx_device *card,
clear_bit(--key, (void*)&card->u.x.connection_keys); clear_bit(--key, (void*)&card->u.x.connection_keys);
chan = dev->priv; chan = dev->priv;
chan->lcn = lcn; chan->lcn = lcn;
set_chan_state(dev, WAN_CONNECTED); cycx_x25_set_chan_state(dev, WAN_CONNECTED);
} }
/* Disconnect confirm interrupt handler. */ /* Disconnect confirm interrupt handler. */
static void disconnect_confirm_intr(struct cycx_device *card, static void cycx_x25_irq_disconnect_confirm(struct cycx_device *card,
struct cycx_x25_cmd *cmd) struct cycx_x25_cmd *cmd)
{ {
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
struct net_device *dev; struct net_device *dev;
u8 lcn; u8 lcn;
cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn)); cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn));
dprintk(1, KERN_INFO "%s: disconnect_confirm_intr:lcn=%d\n", dprintk(1, KERN_INFO "%s: %s:lcn=%d\n",
card->devname, lcn); card->devname, __FUNCTION__, lcn);
if ((dev = get_dev_by_lcn(wandev, lcn)) == NULL) { dev = cycx_x25_get_dev_by_lcn(wandev, lcn);
if (!dev) {
/* Invalid channel, discard packet */ /* Invalid channel, discard packet */
printk(KERN_INFO "%s:disconnect confirm not expected!:lcn %d\n", printk(KERN_INFO "%s:disconnect confirm not expected!:lcn %d\n",
card->devname, lcn); card->devname, lcn);
return; return;
} }
set_chan_state(dev, WAN_DISCONNECTED); cycx_x25_set_chan_state(dev, WAN_DISCONNECTED);
} }
/* disconnect interrupt handler. */ /* disconnect interrupt handler. */
static void disconnect_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_disconnect(struct cycx_device *card,
struct cycx_x25_cmd *cmd)
{ {
struct wan_device *wandev = &card->wandev; struct wan_device *wandev = &card->wandev;
struct net_device *dev; struct net_device *dev;
u8 lcn; u8 lcn;
cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn)); cycx_peek(&card->hw, cmd->buf, &lcn, sizeof(lcn));
dprintk(1, KERN_INFO "disconnect_intr:lcn=%d\n", lcn); dprintk(1, KERN_INFO "%s:lcn=%d\n", __FUNCTION__, lcn);
if ((dev = get_dev_by_lcn(wandev, lcn)) != NULL) { dev = cycx_x25_get_dev_by_lcn(wandev, lcn);
if (dev) {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
x25_disconnect_response(card, chan->link, lcn); cycx_x25_disconnect_response(card, chan->link, lcn);
set_chan_state(dev, WAN_DISCONNECTED); cycx_x25_set_chan_state(dev, WAN_DISCONNECTED);
} else } else
x25_disconnect_response(card, 0, lcn); cycx_x25_disconnect_response(card, 0, lcn);
} }
/* LOG interrupt handler. */ /* LOG interrupt handler. */
static void log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_log(struct cycx_device *card, struct cycx_x25_cmd *cmd)
{ {
#if CYCLOMX_X25_DEBUG #if CYCLOMX_X25_DEBUG
char bf[20]; char bf[20];
...@@ -952,7 +974,7 @@ static void log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -952,7 +974,7 @@ static void log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
cycx_peek(&card->hw, cmd->buf + 10 + toread, &code, 1); cycx_peek(&card->hw, cmd->buf + 10 + toread, &code, 1);
cycx_peek(&card->hw, cmd->buf + 10 + toread + 1, &routine, 1); cycx_peek(&card->hw, cmd->buf + 10 + toread + 1, &routine, 1);
printk(KERN_INFO "cyx_isr: X25_LOG (0x4500) indic.:\n"); printk(KERN_INFO "cycx_x25_irq_handler: X25_LOG (0x4500) indic.:\n");
printk(KERN_INFO "cmd->buf=0x%X\n", cmd->buf); printk(KERN_INFO "cmd->buf=0x%X\n", cmd->buf);
printk(KERN_INFO "Log message code=0x%X\n", msg_code); printk(KERN_INFO "Log message code=0x%X\n", msg_code);
printk(KERN_INFO "Link=%d\n", link); printk(KERN_INFO "Link=%d\n", link);
...@@ -964,20 +986,22 @@ static void log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) ...@@ -964,20 +986,22 @@ static void log_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd)
} }
/* STATISTIC interrupt handler. */ /* STATISTIC interrupt handler. */
static void stat_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_stat(struct cycx_device *card,
struct cycx_x25_cmd *cmd)
{ {
cycx_peek(&card->hw, cmd->buf, &card->u.x.stats, cycx_peek(&card->hw, cmd->buf, &card->u.x.stats,
sizeof(card->u.x.stats)); sizeof(card->u.x.stats));
hex_dump("stat_intr", (unsigned char*)&card->u.x.stats, hex_dump("cycx_x25_irq_stat", (unsigned char*)&card->u.x.stats,
sizeof(card->u.x.stats)); sizeof(card->u.x.stats));
x25_dump_stats(&card->u.x.stats); cycx_x25_dump_stats(&card->u.x.stats);
wake_up_interruptible(&card->wait_stats); wake_up_interruptible(&card->wait_stats);
} }
/* Spurious interrupt handler. /* Spurious interrupt handler.
* o print a warning * o print a warning
* If number of spurious interrupts exceeded some limit, then ??? */ * If number of spurious interrupts exceeded some limit, then ??? */
static void spur_intr(struct cycx_device *card, struct cycx_x25_cmd *cmd) static void cycx_x25_irq_spurious(struct cycx_device *card,
struct cycx_x25_cmd *cmd)
{ {
printk(KERN_INFO "%s: spurious interrupt (0x%X)!\n", printk(KERN_INFO "%s: spurious interrupt (0x%X)!\n",
card->devname, cmd->command); card->devname, cmd->command);
...@@ -1008,7 +1032,7 @@ static int x25_exec(struct cycx_device *card, int command, int link, ...@@ -1008,7 +1032,7 @@ static int x25_exec(struct cycx_device *card, int command, int link,
struct cycx_x25_cmd c; struct cycx_x25_cmd c;
unsigned long flags; unsigned long flags;
u32 addr = 0x1200 + 0x2E0 * link + 0x1E2; u32 addr = 0x1200 + 0x2E0 * link + 0x1E2;
u8 retry = MAX_CMD_RETRY; u8 retry = CYCX_X25_MAX_CMD_RETRY;
int err = 0; int err = 0;
c.command = command; c.command = command;
...@@ -1050,7 +1074,8 @@ static int x25_exec(struct cycx_device *card, int command, int link, ...@@ -1050,7 +1074,8 @@ static int x25_exec(struct cycx_device *card, int command, int link,
} }
/* Configure adapter. */ /* Configure adapter. */
static int x25_configure(struct cycx_device *card, struct cycx_x25_config *conf) static int cycx_x25_configure(struct cycx_device *card,
struct cycx_x25_config *conf)
{ {
struct { struct {
u16 nlinks; u16 nlinks;
...@@ -1071,15 +1096,15 @@ static int x25_configure(struct cycx_device *card, struct cycx_x25_config *conf) ...@@ -1071,15 +1096,15 @@ static int x25_configure(struct cycx_device *card, struct cycx_x25_config *conf)
x25_cmd_conf.conf[1].clock = 8; x25_cmd_conf.conf[1].clock = 8;
x25_cmd_conf.conf[1].flags = 0; /* default = RS232 */ x25_cmd_conf.conf[1].flags = 0; /* default = RS232 */
x25_dump_config(&x25_cmd_conf.conf[0]); cycx_x25_dump_config(&x25_cmd_conf.conf[0]);
x25_dump_config(&x25_cmd_conf.conf[1]); cycx_x25_dump_config(&x25_cmd_conf.conf[1]);
return x25_exec(card, X25_CONFIG, 0, return x25_exec(card, X25_CONFIG, 0,
&x25_cmd_conf, sizeof(x25_cmd_conf), NULL, 0); &x25_cmd_conf, sizeof(x25_cmd_conf), NULL, 0);
} }
/* Get protocol statistics. */ /* Get protocol statistics. */
static int x25_get_stats(struct cycx_device *card) static int cycx_x25_get_stats(struct cycx_device *card)
{ {
/* the firmware expects 20 in the size field!!! /* the firmware expects 20 in the size field!!!
thanks to Daniela */ thanks to Daniela */
...@@ -1107,7 +1132,7 @@ static int x25_get_stats(struct cycx_device *card) ...@@ -1107,7 +1132,7 @@ static int x25_get_stats(struct cycx_device *card)
card->wandev.stats.collisions = 0; /* not available from fw */ card->wandev.stats.collisions = 0; /* not available from fw */
card->wandev.stats.tx_errors = 0; /* not available from fw */ card->wandev.stats.tx_errors = 0; /* not available from fw */
x25_dump_devs(&card->wandev); cycx_x25_dump_devs(&card->wandev);
return 0; return 0;
} }
...@@ -1207,8 +1232,8 @@ static int x25_place_call(struct cycx_device *card, ...@@ -1207,8 +1232,8 @@ static int x25_place_call(struct cycx_device *card,
} }
/* Place X.25 CONNECT RESPONSE. */ /* Place X.25 CONNECT RESPONSE. */
static int x25_connect_response(struct cycx_device *card, static int cycx_x25_connect_response(struct cycx_device *card,
struct cycx_x25_channel *chan) struct cycx_x25_channel *chan)
{ {
u8 d[8]; u8 d[8];
...@@ -1222,7 +1247,8 @@ static int x25_connect_response(struct cycx_device *card, ...@@ -1222,7 +1247,8 @@ static int x25_connect_response(struct cycx_device *card,
} }
/* Place X.25 DISCONNECT RESPONSE. */ /* Place X.25 DISCONNECT RESPONSE. */
static int x25_disconnect_response(struct cycx_device *card, u8 link, u8 lcn) static int cycx_x25_disconnect_response(struct cycx_device *card, u8 link,
u8 lcn)
{ {
char d[5]; char d[5];
...@@ -1251,8 +1277,8 @@ static int x25_clear_call(struct cycx_device *card, u8 link, u8 lcn, u8 cause, ...@@ -1251,8 +1277,8 @@ static int x25_clear_call(struct cycx_device *card, u8 link, u8 lcn, u8 cause,
} }
/* Send X.25 data packet. */ /* Send X.25 data packet. */
static int x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm, int len, static int cycx_x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm,
void *buf) int len, void *buf)
{ {
u8 d[] = "?\xFF\x10??"; u8 d[] = "?\xFF\x10??";
...@@ -1264,7 +1290,8 @@ static int x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm, int len, ...@@ -1264,7 +1290,8 @@ static int x25_send(struct cycx_device *card, u8 link, u8 lcn, u8 bitm, int len,
/* Miscellaneous */ /* Miscellaneous */
/* Find network device by its channel number. */ /* Find network device by its channel number. */
static struct net_device *get_dev_by_lcn(struct wan_device *wandev, s16 lcn) static struct net_device *cycx_x25_get_dev_by_lcn(struct wan_device *wandev,
s16 lcn)
{ {
struct net_device *dev = wandev->dev; struct net_device *dev = wandev->dev;
struct cycx_x25_channel *chan; struct cycx_x25_channel *chan;
...@@ -1280,8 +1307,8 @@ static struct net_device *get_dev_by_lcn(struct wan_device *wandev, s16 lcn) ...@@ -1280,8 +1307,8 @@ static struct net_device *get_dev_by_lcn(struct wan_device *wandev, s16 lcn)
} }
/* Find network device by its remote dte address. */ /* Find network device by its remote dte address. */
static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev, static struct net_device *
char *dte) cycx_x25_get_dev_by_dte_addr(struct wan_device *wandev, char *dte)
{ {
struct net_device *dev = wandev->dev; struct net_device *dev = wandev->dev;
struct cycx_x25_channel *chan; struct cycx_x25_channel *chan;
...@@ -1303,7 +1330,7 @@ static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev, ...@@ -1303,7 +1330,7 @@ static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev,
* Return: 0 connected * Return: 0 connected
* >0 connection in progress * >0 connection in progress
* <0 failure */ * <0 failure */
static int chan_connect(struct net_device *dev) static int cycx_x25_chan_connect(struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
struct cycx_device *card = chan->card; struct cycx_device *card = chan->card;
...@@ -1318,42 +1345,42 @@ static int chan_connect(struct net_device *dev) ...@@ -1318,42 +1345,42 @@ static int chan_connect(struct net_device *dev)
if (x25_place_call(card, chan)) if (x25_place_call(card, chan))
return -EIO; return -EIO;
set_chan_state(dev, WAN_CONNECTING); cycx_x25_set_chan_state(dev, WAN_CONNECTING);
return 1; return 1;
} else } else
set_chan_state(dev, WAN_CONNECTED); cycx_x25_set_chan_state(dev, WAN_CONNECTED);
return 0; return 0;
} }
/* Disconnect logical channel. /* Disconnect logical channel.
* o if SVC then clear X.25 call */ * o if SVC then clear X.25 call */
static void chan_disconnect(struct net_device *dev) static void cycx_x25_chan_disconnect(struct net_device *dev)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
if (chan->svc) { if (chan->svc) {
x25_clear_call(chan->card, chan->link, chan->lcn, 0, 0); x25_clear_call(chan->card, chan->link, chan->lcn, 0, 0);
set_chan_state(dev, WAN_DISCONNECTING); cycx_x25_set_chan_state(dev, WAN_DISCONNECTING);
} else } else
set_chan_state(dev, WAN_DISCONNECTED); cycx_x25_set_chan_state(dev, WAN_DISCONNECTED);
} }
/* Called by kernel timer */ /* Called by kernel timer */
static void chan_timer(unsigned long d) static void cycx_x25_chan_timer(unsigned long d)
{ {
struct net_device *dev = (struct net_device *)d; struct net_device *dev = (struct net_device *)d;
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
if (chan->state == WAN_CONNECTED) if (chan->state == WAN_CONNECTED)
chan_disconnect(dev); cycx_x25_chan_disconnect(dev);
else else
printk(KERN_ERR "%s: chan_timer for svc (%s) not connected!\n", printk(KERN_ERR "%s: %s for svc (%s) not connected!\n",
chan->card->devname, dev->name); chan->card->devname, __FUNCTION__, dev->name);
} }
/* Set logical channel state. */ /* Set logical channel state. */
static void set_chan_state(struct net_device *dev, u8 state) static void cycx_x25_set_chan_state(struct net_device *dev, u8 state)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
struct cycx_device *card = chan->card; struct cycx_device *card = chan->card;
...@@ -1374,7 +1401,7 @@ static void set_chan_state(struct net_device *dev, u8 state) ...@@ -1374,7 +1401,7 @@ static void set_chan_state(struct net_device *dev, u8 state)
reset_timer(dev); reset_timer(dev);
if (chan->protocol == ETH_P_X25) if (chan->protocol == ETH_P_X25)
chan_x25_send_event(dev, 1); cycx_x25_chan_send_event(dev, 1);
break; break;
case WAN_CONNECTING: case WAN_CONNECTING:
...@@ -1392,7 +1419,7 @@ static void set_chan_state(struct net_device *dev, u8 state) ...@@ -1392,7 +1419,7 @@ static void set_chan_state(struct net_device *dev, u8 state)
} }
if (chan->protocol == ETH_P_X25) if (chan->protocol == ETH_P_X25)
chan_x25_send_event(dev, 2); cycx_x25_chan_send_event(dev, 2);
netif_wake_queue(dev); netif_wake_queue(dev);
break; break;
...@@ -1419,7 +1446,7 @@ static void set_chan_state(struct net_device *dev, u8 state) ...@@ -1419,7 +1446,7 @@ static void set_chan_state(struct net_device *dev, u8 state)
* the packet into 'complete sequence' using M-bit. * the packet into 'complete sequence' using M-bit.
* 2. When transmission is complete, an event notification should be issued * 2. When transmission is complete, an event notification should be issued
* to the router. */ * to the router. */
static int chan_send(struct net_device *dev, struct sk_buff *skb) static int cycx_x25_chan_send(struct net_device *dev, struct sk_buff *skb)
{ {
struct cycx_x25_channel *chan = dev->priv; struct cycx_x25_channel *chan = dev->priv;
struct cycx_device *card = chan->card; struct cycx_device *card = chan->card;
...@@ -1431,7 +1458,7 @@ static int chan_send(struct net_device *dev, struct sk_buff *skb) ...@@ -1431,7 +1458,7 @@ static int chan_send(struct net_device *dev, struct sk_buff *skb)
bitm = 0x10; /* set M-bit (more data) */ bitm = 0x10; /* set M-bit (more data) */
} }
if (x25_send(card, chan->link, chan->lcn, bitm, len, skb->data)) if (cycx_x25_send(card, chan->link, chan->lcn, bitm, len, skb->data))
return 1; return 1;
if (bitm) { if (bitm) {
...@@ -1447,7 +1474,7 @@ static int chan_send(struct net_device *dev, struct sk_buff *skb) ...@@ -1447,7 +1474,7 @@ static int chan_send(struct net_device *dev, struct sk_buff *skb)
/* Send event (connection, disconnection, etc) to X.25 socket layer */ /* Send event (connection, disconnection, etc) to X.25 socket layer */
static void chan_x25_send_event(struct net_device *dev, u8 event) static void cycx_x25_chan_send_event(struct net_device *dev, u8 event)
{ {
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *ptr; unsigned char *ptr;
...@@ -1525,7 +1552,7 @@ static void reset_timer(struct net_device *dev) ...@@ -1525,7 +1552,7 @@ static void reset_timer(struct net_device *dev)
mod_timer(&chan->timer, jiffies+chan->idle_tmout*HZ); mod_timer(&chan->timer, jiffies+chan->idle_tmout*HZ);
} }
#ifdef CYCLOMX_X25_DEBUG #ifdef CYCLOMX_X25_DEBUG
static void x25_dump_config(struct cycx_x25_config *conf) static void cycx_x25_dump_config(struct cycx_x25_config *conf)
{ {
printk(KERN_INFO "X.25 configuration\n"); printk(KERN_INFO "X.25 configuration\n");
printk(KERN_INFO "-----------------\n"); printk(KERN_INFO "-----------------\n");
...@@ -1547,7 +1574,7 @@ static void x25_dump_config(struct cycx_x25_config *conf) ...@@ -1547,7 +1574,7 @@ static void x25_dump_config(struct cycx_x25_config *conf)
printk(KERN_INFO "flags=0x%x\n", conf->flags); printk(KERN_INFO "flags=0x%x\n", conf->flags);
} }
static void x25_dump_stats(struct cycx_x25_stats *stats) static void cycx_x25_dump_stats(struct cycx_x25_stats *stats)
{ {
printk(KERN_INFO "X.25 statistics\n"); printk(KERN_INFO "X.25 statistics\n");
printk(KERN_INFO "--------------\n"); printk(KERN_INFO "--------------\n");
...@@ -1563,7 +1590,7 @@ static void x25_dump_stats(struct cycx_x25_stats *stats) ...@@ -1563,7 +1590,7 @@ static void x25_dump_stats(struct cycx_x25_stats *stats)
printk(KERN_INFO "rx_aborts=%d\n", stats->rx_aborts); printk(KERN_INFO "rx_aborts=%d\n", stats->rx_aborts);
} }
static void x25_dump_devs(struct wan_device *wandev) static void cycx_x25_dump_devs(struct wan_device *wandev)
{ {
struct net_device *dev = wandev->dev; struct net_device *dev = wandev->dev;
......
...@@ -71,10 +71,10 @@ struct cycx_device { ...@@ -71,10 +71,10 @@ struct cycx_device {
}; };
/* Public Functions */ /* Public Functions */
void cyclomx_set_state(struct cycx_device *card, int state); void cycx_set_state(struct cycx_device *card, int state);
#ifdef CONFIG_CYCLOMX_X25 #ifdef CONFIG_CYCLOMX_X25
int cyx_init(struct cycx_device *card, wandev_conf_t *conf); int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf);
#endif #endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _CYCLOMX_H */ #endif /* _CYCLOMX_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment