Commit a01d4ab4 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan lapb] switch to use net_device instead of custom token

lapb functions that used to take a token to select lapb_cb they'll deal with
are switched to getting net_device instead.  Callbacks switched to using
lapb->dev instead of lapb->token.
parent c360d0a6
...@@ -44,7 +44,7 @@ static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb) ...@@ -44,7 +44,7 @@ static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb)
if (!dev || !dev->priv) { if (!dev || !dev->priv) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
} else { } else {
lapb_data_received(dev->priv, skb); lapb_data_received(dev, skb);
} }
} }
...@@ -82,7 +82,7 @@ static int comxlapb_open(struct net_device *dev) ...@@ -82,7 +82,7 @@ static int comxlapb_open(struct net_device *dev)
return -ENODEV; return -ENODEV;
} }
err = lapb_connect_request(ch); err = lapb_connect_request(dev);
if (ch->debug_flags & DEBUG_COMX_LAPB) { if (ch->debug_flags & DEBUG_COMX_LAPB) {
comx_debug(dev, "%s: lapb opened, error code: %d\n", comx_debug(dev, "%s: lapb opened, error code: %d\n",
...@@ -108,7 +108,7 @@ static int comxlapb_close(struct net_device *dev) ...@@ -108,7 +108,7 @@ static int comxlapb_close(struct net_device *dev)
comx_debug(dev, "%s: lapb closed\n", dev->name); comx_debug(dev, "%s: lapb closed\n", dev->name);
} }
lapb_disconnect_request(ch); lapb_disconnect_request(dev);
ch->init_status &= ~LINE_OPEN; ch->init_status &= ~LINE_OPEN;
ch->line_status &= ~PROTO_UP; ch->line_status &= ~PROTO_UP;
...@@ -130,11 +130,11 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -130,11 +130,11 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev)
case 0x00: case 0x00:
break; // transmit break; // transmit
case 0x01: case 0x01:
lapb_connect_request(ch); lapb_connect_request(dev);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
case 0x02: case 0x02:
lapb_disconnect_request(ch); lapb_disconnect_request(dev);
default: default:
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -145,7 +145,7 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -145,7 +145,7 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
lapb_data_request(ch, skb2); lapb_data_request(dev, skb2);
} }
return FRAME_ACCEPTED; return FRAME_ACCEPTED;
...@@ -157,7 +157,7 @@ static int comxlapb_statistics(struct net_device *dev, char *page) ...@@ -157,7 +157,7 @@ static int comxlapb_statistics(struct net_device *dev, char *page)
int len = 0; int len = 0;
len += sprintf(page + len, "Line status: "); len += sprintf(page + len, "Line status: ");
if (lapb_getparms(dev->priv, &parms) != LAPB_OK) { if (lapb_getparms(dev, &parms) != LAPB_OK) {
len += sprintf(page + len, "not initialized\n"); len += sprintf(page + len, "not initialized\n");
return len; return len;
} }
...@@ -178,7 +178,7 @@ static int comxlapb_read_proc(char *page, char **start, off_t off, int count, ...@@ -178,7 +178,7 @@ static int comxlapb_read_proc(char *page, char **start, off_t off, int count,
struct lapb_parms_struct parms; struct lapb_parms_struct parms;
int len = 0; int len = 0;
if (lapb_getparms(dev->priv, &parms)) { if (lapb_getparms(dev, &parms)) {
return -ENODEV; return -ENODEV;
} }
...@@ -223,7 +223,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, ...@@ -223,7 +223,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer,
unsigned long parm; unsigned long parm;
char *page; char *page;
if (lapb_getparms(dev->priv, &parms)) { if (lapb_getparms(dev, &parms)) {
return -ENODEV; return -ENODEV;
} }
...@@ -243,23 +243,23 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, ...@@ -243,23 +243,23 @@ static int comxlapb_write_proc(struct file *file, const char *buffer,
parm=simple_strtoul(page,NULL,10); parm=simple_strtoul(page,NULL,10);
if (parm > 0 && parm < 100) { if (parm > 0 && parm < 100) {
parms.t1=parm; parms.t1=parm;
lapb_setparms(dev->priv, &parms); lapb_setparms(dev, &parms);
} }
} else if (strcmp(entry->name, FILENAME_T2) == 0) { } else if (strcmp(entry->name, FILENAME_T2) == 0) {
parm=simple_strtoul(page, NULL, 10); parm=simple_strtoul(page, NULL, 10);
if (parm > 0 && parm < 100) { if (parm > 0 && parm < 100) {
parms.t2=parm; parms.t2=parm;
lapb_setparms(dev->priv, &parms); lapb_setparms(dev, &parms);
} }
} else if (strcmp(entry->name, FILENAME_N2) == 0) { } else if (strcmp(entry->name, FILENAME_N2) == 0) {
parm=simple_strtoul(page, NULL, 10); parm=simple_strtoul(page, NULL, 10);
if (parm > 0 && parm < 100) { if (parm > 0 && parm < 100) {
parms.n2=parm; parms.n2=parm;
lapb_setparms(dev->priv, &parms); lapb_setparms(dev, &parms);
} }
} else if (strcmp(entry->name, FILENAME_WINDOW) == 0) { } else if (strcmp(entry->name, FILENAME_WINDOW) == 0) {
parms.window = simple_strtoul(page, NULL, 10); parms.window = simple_strtoul(page, NULL, 10);
lapb_setparms(dev->priv, &parms); lapb_setparms(dev, &parms);
} else if (strcmp(entry->name, FILENAME_MODE) == 0) { } else if (strcmp(entry->name, FILENAME_MODE) == 0) {
if (comx_strcasecmp(page, "dte") == 0) { if (comx_strcasecmp(page, "dte") == 0) {
parms.mode &= ~(LAPB_DCE | LAPB_DTE); parms.mode &= ~(LAPB_DCE | LAPB_DTE);
...@@ -276,7 +276,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, ...@@ -276,7 +276,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer,
parms.mode &= ~LAPB_STANDARD; parms.mode &= ~LAPB_STANDARD;
parms.mode |= LAPB_EXTENDED; parms.mode |= LAPB_EXTENDED;
} }
lapb_setparms(dev->priv, &parms); lapb_setparms(dev, &parms);
} else { } else {
printk(KERN_ERR "comxlapb_write_proc: internal error, filename %s\n", printk(KERN_ERR "comxlapb_write_proc: internal error, filename %s\n",
entry->name); entry->name);
...@@ -287,9 +287,9 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, ...@@ -287,9 +287,9 @@ static int comxlapb_write_proc(struct file *file, const char *buffer,
return count; return count;
} }
static void comxlapb_connected(void *token, int reason) static void comxlapb_connected(struct net_device *dev, int reason)
{ {
struct comx_channel *ch = token; struct comx_channel *ch = dev->priv;
struct proc_dir_entry *comxdir = ch->procdir->subdir; struct proc_dir_entry *comxdir = ch->procdir->subdir;
if (ch->debug_flags & DEBUG_COMX_LAPB) { if (ch->debug_flags & DEBUG_COMX_LAPB) {
...@@ -327,9 +327,9 @@ static void comxlapb_connected(void *token, int reason) ...@@ -327,9 +327,9 @@ static void comxlapb_connected(void *token, int reason)
comx_status(ch->dev, ch->line_status); comx_status(ch->dev, ch->line_status);
} }
static void comxlapb_disconnected(void *token, int reason) static void comxlapb_disconnected(struct net_device *dev, int reason)
{ {
struct comx_channel *ch = token; struct comx_channel *ch = dev->priv;
struct proc_dir_entry *comxdir = ch->procdir->subdir; struct proc_dir_entry *comxdir = ch->procdir->subdir;
if (ch->debug_flags & DEBUG_COMX_LAPB) { if (ch->debug_flags & DEBUG_COMX_LAPB) {
...@@ -366,9 +366,9 @@ static void comxlapb_disconnected(void *token, int reason) ...@@ -366,9 +366,9 @@ static void comxlapb_disconnected(void *token, int reason)
comx_status(ch->dev, ch->line_status); comx_status(ch->dev, ch->line_status);
} }
static int comxlapb_data_indication(void *token, struct sk_buff *skb) static int comxlapb_data_indication(struct net_device *dev, struct sk_buff *skb)
{ {
struct comx_channel *ch = token; struct comx_channel *ch = dev->priv;
if (ch->dev->type == ARPHRD_X25) { if (ch->dev->type == ARPHRD_X25) {
skb_push(skb, 1); skb_push(skb, 1);
...@@ -387,9 +387,9 @@ static int comxlapb_data_indication(void *token, struct sk_buff *skb) ...@@ -387,9 +387,9 @@ static int comxlapb_data_indication(void *token, struct sk_buff *skb)
return comx_rx(ch->dev, skb); return comx_rx(ch->dev, skb);
} }
static void comxlapb_data_transmit(void *token, struct sk_buff *skb) static void comxlapb_data_transmit(struct net_device *dev, struct sk_buff *skb)
{ {
struct comx_channel *ch = token; struct comx_channel *ch = dev->priv;
if (ch->HW_send_packet) { if (ch->HW_send_packet) {
ch->HW_send_packet(ch->dev, skb); ch->HW_send_packet(ch->dev, skb);
...@@ -417,7 +417,7 @@ static int comxlapb_exit(struct net_device *dev) ...@@ -417,7 +417,7 @@ static int comxlapb_exit(struct net_device *dev)
if (ch->debug_flags & DEBUG_COMX_LAPB) { if (ch->debug_flags & DEBUG_COMX_LAPB) {
comx_debug(dev, "%s: unregistering lapb\n", dev->name); comx_debug(dev, "%s: unregistering lapb\n", dev->name);
} }
lapb_unregister(dev->priv); lapb_unregister(dev);
remove_proc_entry(FILENAME_T1, ch->procdir); remove_proc_entry(FILENAME_T1, ch->procdir);
remove_proc_entry(FILENAME_T2, ch->procdir); remove_proc_entry(FILENAME_T2, ch->procdir);
......
...@@ -25,21 +25,20 @@ ...@@ -25,21 +25,20 @@
/* These functions are callbacks called by LAPB layer */ /* These functions are callbacks called by LAPB layer */
static void x25_connect_disconnect(void *token, int reason, int code) static void x25_connect_disconnect(struct net_device *dev, int reason, int code)
{ {
hdlc_device *hdlc = token;
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *ptr; unsigned char *ptr;
if ((skb = dev_alloc_skb(1)) == NULL) { if ((skb = dev_alloc_skb(1)) == NULL) {
printk(KERN_ERR "%s: out of memory\n", hdlc_to_name(hdlc)); printk(KERN_ERR "%s: out of memory\n", dev->name);
return; return;
} }
ptr = skb_put(skb, 1); ptr = skb_put(skb, 1);
*ptr = code; *ptr = code;
skb->dev = hdlc_to_dev(hdlc); skb->dev = dev;
skb->protocol = htons(ETH_P_X25); skb->protocol = htons(ETH_P_X25);
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
...@@ -49,23 +48,22 @@ static void x25_connect_disconnect(void *token, int reason, int code) ...@@ -49,23 +48,22 @@ static void x25_connect_disconnect(void *token, int reason, int code)
static void x25_connected(void *token, int reason) static void x25_connected(struct net_device *dev, int reason)
{ {
x25_connect_disconnect(token, reason, 1); x25_connect_disconnect(dev, reason, 1);
} }
static void x25_disconnected(void *token, int reason) static void x25_disconnected(struct net_device *dev, int reason)
{ {
x25_connect_disconnect(token, reason, 2); x25_connect_disconnect(dev, reason, 2);
} }
static int x25_data_indication(void *token, struct sk_buff *skb) static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
{ {
hdlc_device *hdlc = token;
unsigned char *ptr; unsigned char *ptr;
skb_push(skb, 1); skb_push(skb, 1);
...@@ -76,7 +74,7 @@ static int x25_data_indication(void *token, struct sk_buff *skb) ...@@ -76,7 +74,7 @@ static int x25_data_indication(void *token, struct sk_buff *skb)
ptr = skb->data; ptr = skb->data;
*ptr = 0; *ptr = 0;
skb->dev = hdlc_to_dev(hdlc); skb->dev = dev;
skb->protocol = htons(ETH_P_X25); skb->protocol = htons(ETH_P_X25);
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
...@@ -86,10 +84,10 @@ static int x25_data_indication(void *token, struct sk_buff *skb) ...@@ -86,10 +84,10 @@ static int x25_data_indication(void *token, struct sk_buff *skb)
static void x25_data_transmit(void *token, struct sk_buff *skb) static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb)
{ {
hdlc_device *hdlc = token; hdlc_device *hdlc = dev_to_hdlc(dev);
hdlc->xmit(skb, hdlc_to_dev(hdlc)); /* Ignore return value :-( */ hdlc->xmit(skb, dev); /* Ignore return value :-( */
} }
...@@ -104,15 +102,15 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -104,15 +102,15 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev)
switch (skb->data[0]) { switch (skb->data[0]) {
case 0: /* Data to be transmitted */ case 0: /* Data to be transmitted */
skb_pull(skb, 1); skb_pull(skb, 1);
if ((result = lapb_data_request(hdlc, skb)) != LAPB_OK) if ((result = lapb_data_request(dev, skb)) != LAPB_OK)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
case 1: case 1:
if ((result = lapb_connect_request(hdlc))!= LAPB_OK) { if ((result = lapb_connect_request(dev))!= LAPB_OK) {
if (result == LAPB_CONNECTED) if (result == LAPB_CONNECTED)
/* Send connect confirm. msg to level 3 */ /* Send connect confirm. msg to level 3 */
x25_connected(hdlc, 0); x25_connected(dev, 0);
else else
printk(KERN_ERR "%s: LAPB connect request " printk(KERN_ERR "%s: LAPB connect request "
"failed, error code = %i\n", "failed, error code = %i\n",
...@@ -121,10 +119,10 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -121,10 +119,10 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev)
break; break;
case 2: case 2:
if ((result = lapb_disconnect_request(hdlc)) != LAPB_OK) { if ((result = lapb_disconnect_request(dev)) != LAPB_OK) {
if (result == LAPB_NOTCONNECTED) if (result == LAPB_NOTCONNECTED)
/* Send disconnect confirm. msg to level 3 */ /* Send disconnect confirm. msg to level 3 */
x25_disconnected(hdlc, 0); x25_disconnected(dev, 0);
else else
printk(KERN_ERR "%s: LAPB disconnect request " printk(KERN_ERR "%s: LAPB disconnect request "
"failed, error code = %i\n", "failed, error code = %i\n",
...@@ -164,7 +162,7 @@ static int x25_open(hdlc_device *hdlc) ...@@ -164,7 +162,7 @@ static int x25_open(hdlc_device *hdlc)
static void x25_close(hdlc_device *hdlc) static void x25_close(hdlc_device *hdlc)
{ {
lapb_unregister(hdlc); lapb_unregister(hdlc_to_dev(hdlc));
} }
...@@ -178,7 +176,7 @@ static int x25_rx(struct sk_buff *skb) ...@@ -178,7 +176,7 @@ static int x25_rx(struct sk_buff *skb)
return NET_RX_DROP; return NET_RX_DROP;
} }
if (lapb_data_received(hdlc, skb) == LAPB_OK) if (lapb_data_received(skb->dev, skb) == LAPB_OK)
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
hdlc->stats.rx_errors++; hdlc->stats.rx_errors++;
......
...@@ -110,7 +110,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe ...@@ -110,7 +110,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
skb_pull(skb, 2); /* Remove the length bytes */ skb_pull(skb, 2); /* Remove the length bytes */
skb_trim(skb, len); /* Set the length of the data */ skb_trim(skb, len); /* Set the length of the data */
if ((err = lapb_data_received(lapbeth, skb)) != LAPB_OK) { if ((err = lapb_data_received(lapbeth->axdev, skb)) != LAPB_OK) {
printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err); printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err);
goto drop_unlock; goto drop_unlock;
} }
...@@ -125,9 +125,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe ...@@ -125,9 +125,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
return 0; return 0;
} }
static int lapbeth_data_indication(void *token, struct sk_buff *skb) static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)token;
unsigned char *ptr; unsigned char *ptr;
skb_push(skb, 1); skb_push(skb, 1);
...@@ -138,7 +137,7 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb) ...@@ -138,7 +137,7 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb)
ptr = skb->data; ptr = skb->data;
*ptr = 0x00; *ptr = 0x00;
skb->dev = lapbeth->axdev; skb->dev = dev;
skb->protocol = htons(ETH_P_X25); skb->protocol = htons(ETH_P_X25);
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
...@@ -152,7 +151,6 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb) ...@@ -152,7 +151,6 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb)
*/ */
static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)dev->priv;
int err = -ENODEV; int err = -ENODEV;
/* /*
...@@ -168,12 +166,12 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -168,12 +166,12 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
err = 0; err = 0;
break; break;
case 0x01: case 0x01:
if ((err = lapb_connect_request(lapbeth)) != LAPB_OK) if ((err = lapb_connect_request(dev)) != LAPB_OK)
printk(KERN_ERR "lapbeth: lapb_connect_request " printk(KERN_ERR "lapbeth: lapb_connect_request "
"error: %d\n", err); "error: %d\n", err);
goto drop_ok; goto drop_ok;
case 0x02: case 0x02:
if ((err = lapb_disconnect_request(lapbeth)) != LAPB_OK) if ((err = lapb_disconnect_request(dev)) != LAPB_OK)
printk(KERN_ERR "lapbeth: lapb_disconnect_request " printk(KERN_ERR "lapbeth: lapb_disconnect_request "
"err: %d\n", err); "err: %d\n", err);
/* Fall thru */ /* Fall thru */
...@@ -183,7 +181,7 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -183,7 +181,7 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
skb_pull(skb, 1); skb_pull(skb, 1);
if ((err = lapb_data_request(lapbeth, skb)) != LAPB_OK) { if ((err = lapb_data_request(dev, skb)) != LAPB_OK) {
printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err);
err = -ENOMEM; err = -ENOMEM;
goto drop; goto drop;
...@@ -198,9 +196,9 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -198,9 +196,9 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
goto out; goto out;
} }
static void lapbeth_data_transmit(void *token, struct sk_buff *skb) static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)token; struct lapbethdev *lapbeth = ndev->priv;
unsigned char *ptr; unsigned char *ptr;
struct net_device *dev; struct net_device *dev;
int size = skb->len; int size = skb->len;
...@@ -222,9 +220,8 @@ static void lapbeth_data_transmit(void *token, struct sk_buff *skb) ...@@ -222,9 +220,8 @@ static void lapbeth_data_transmit(void *token, struct sk_buff *skb)
dev_queue_xmit(skb); dev_queue_xmit(skb);
} }
static void lapbeth_connected(void *token, int reason) static void lapbeth_connected(struct net_device *dev, int reason)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)token;
unsigned char *ptr; unsigned char *ptr;
struct sk_buff *skb = dev_alloc_skb(1); struct sk_buff *skb = dev_alloc_skb(1);
...@@ -236,7 +233,7 @@ static void lapbeth_connected(void *token, int reason) ...@@ -236,7 +233,7 @@ static void lapbeth_connected(void *token, int reason)
ptr = skb_put(skb, 1); ptr = skb_put(skb, 1);
*ptr = 0x01; *ptr = 0x01;
skb->dev = lapbeth->axdev; skb->dev = dev;
skb->protocol = htons(ETH_P_X25); skb->protocol = htons(ETH_P_X25);
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
...@@ -245,9 +242,8 @@ static void lapbeth_connected(void *token, int reason) ...@@ -245,9 +242,8 @@ static void lapbeth_connected(void *token, int reason)
netif_rx(skb); netif_rx(skb);
} }
static void lapbeth_disconnected(void *token, int reason) static void lapbeth_disconnected(struct net_device *dev, int reason)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)token;
unsigned char *ptr; unsigned char *ptr;
struct sk_buff *skb = dev_alloc_skb(1); struct sk_buff *skb = dev_alloc_skb(1);
...@@ -259,7 +255,7 @@ static void lapbeth_disconnected(void *token, int reason) ...@@ -259,7 +255,7 @@ static void lapbeth_disconnected(void *token, int reason)
ptr = skb_put(skb, 1); ptr = skb_put(skb, 1);
*ptr = 0x02; *ptr = 0x02;
skb->dev = lapbeth->axdev; skb->dev = dev;
skb->protocol = htons(ETH_P_X25); skb->protocol = htons(ETH_P_X25);
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
...@@ -318,12 +314,11 @@ static int lapbeth_open(struct net_device *dev) ...@@ -318,12 +314,11 @@ static int lapbeth_open(struct net_device *dev)
static int lapbeth_close(struct net_device *dev) static int lapbeth_close(struct net_device *dev)
{ {
struct lapbethdev *lapbeth = (struct lapbethdev *)dev->priv;
int err; int err;
netif_stop_queue(dev); netif_stop_queue(dev);
if ((err = lapb_unregister(lapbeth)) != LAPB_OK) if ((err = lapb_unregister(dev)) != LAPB_OK)
printk(KERN_ERR "lapbeth: lapb_unregister error - %d\n", err); printk(KERN_ERR "lapbeth: lapb_unregister error - %d\n", err);
return 0; return 0;
......
...@@ -213,7 +213,7 @@ static void x25_asy_bump(struct x25_asy *sl) ...@@ -213,7 +213,7 @@ static void x25_asy_bump(struct x25_asy *sl)
memcpy(skb_put(skb,count), sl->rbuff, count); memcpy(skb_put(skb,count), sl->rbuff, count);
skb->mac.raw=skb->data; skb->mac.raw=skb->data;
skb->protocol=htons(ETH_P_X25); skb->protocol=htons(ETH_P_X25);
if((err=lapb_data_received(sl,skb))!=LAPB_OK) if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK)
{ {
kfree_skb(skb); kfree_skb(skb);
printk(KERN_DEBUG "x25_asy: data received err - %d\n",err); printk(KERN_DEBUG "x25_asy: data received err - %d\n",err);
...@@ -324,12 +324,12 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -324,12 +324,12 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
case 0x00:break; case 0x00:break;
case 0x01: /* Connection request .. do nothing */ case 0x01: /* Connection request .. do nothing */
if((err=lapb_connect_request(sl))!=LAPB_OK) if((err=lapb_connect_request(dev))!=LAPB_OK)
printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
case 0x02: /* Disconnect request .. do nothing - hang up ?? */ case 0x02: /* Disconnect request .. do nothing - hang up ?? */
if((err=lapb_disconnect_request(sl))!=LAPB_OK) if((err=lapb_disconnect_request(dev))!=LAPB_OK)
printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err);
default: default:
kfree_skb(skb); kfree_skb(skb);
...@@ -347,7 +347,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -347,7 +347,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
* 14 Oct 1994 Dmitry Gorodchanin. * 14 Oct 1994 Dmitry Gorodchanin.
*/ */
if((err=lapb_data_request(sl,skb))!=LAPB_OK) if((err=lapb_data_request(dev,skb))!=LAPB_OK)
{ {
printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err);
kfree_skb(skb); kfree_skb(skb);
...@@ -366,7 +366,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -366,7 +366,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
* at the net layer. * at the net layer.
*/ */
static int x25_asy_data_indication(void *token, struct sk_buff *skb) static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
{ {
skb->dev->last_rx = jiffies; skb->dev->last_rx = jiffies;
return netif_rx(skb); return netif_rx(skb);
...@@ -378,9 +378,9 @@ static int x25_asy_data_indication(void *token, struct sk_buff *skb) ...@@ -378,9 +378,9 @@ static int x25_asy_data_indication(void *token, struct sk_buff *skb)
* perhaps lapb should allow us to bounce this ? * perhaps lapb should allow us to bounce this ?
*/ */
static void x25_asy_data_transmit(void *token, struct sk_buff *skb) static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb)
{ {
struct x25_asy *sl=token; struct x25_asy *sl=dev->priv;
spin_lock(&sl->lock); spin_lock(&sl->lock);
if (netif_queue_stopped(sl->dev) || sl->tty == NULL) if (netif_queue_stopped(sl->dev) || sl->tty == NULL)
...@@ -405,9 +405,9 @@ static void x25_asy_data_transmit(void *token, struct sk_buff *skb) ...@@ -405,9 +405,9 @@ static void x25_asy_data_transmit(void *token, struct sk_buff *skb)
* LAPB connection establish/down information. * LAPB connection establish/down information.
*/ */
static void x25_asy_connected(void *token, int reason) static void x25_asy_connected(struct net_device *dev, int reason)
{ {
struct x25_asy *sl = token; struct x25_asy *sl = dev->priv;
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *ptr; unsigned char *ptr;
...@@ -428,9 +428,9 @@ static void x25_asy_connected(void *token, int reason) ...@@ -428,9 +428,9 @@ static void x25_asy_connected(void *token, int reason)
sl->dev->last_rx = jiffies; sl->dev->last_rx = jiffies;
} }
static void x25_asy_disconnected(void *token, int reason) static void x25_asy_disconnected(struct net_device *dev, int reason)
{ {
struct x25_asy *sl = token; struct x25_asy *sl = dev->priv;
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *ptr; unsigned char *ptr;
...@@ -525,7 +525,7 @@ static int x25_asy_close(struct net_device *dev) ...@@ -525,7 +525,7 @@ static int x25_asy_close(struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
sl->rcount = 0; sl->rcount = 0;
sl->xleft = 0; sl->xleft = 0;
if((err=lapb_unregister(sl))!=LAPB_OK) if((err=lapb_unregister(dev))!=LAPB_OK)
printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",err); printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",err);
spin_unlock(&sl->lock); spin_unlock(&sl->lock);
return 0; return 0;
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
#define LAPB_DCE 0x04 #define LAPB_DCE 0x04
struct lapb_register_struct { struct lapb_register_struct {
void (*connect_confirmation)(void *token, int reason); void (*connect_confirmation)(struct net_device *dev, int reason);
void (*connect_indication)(void *token, int reason); void (*connect_indication)(struct net_device *dev, int reason);
void (*disconnect_confirmation)(void *token, int reason); void (*disconnect_confirmation)(struct net_device *dev, int reason);
void (*disconnect_indication)(void *token, int reason); void (*disconnect_indication)(struct net_device *dev, int reason);
int (*data_indication)(void *token, struct sk_buff *skb); int (*data_indication)(struct net_device *dev, struct sk_buff *skb);
void (*data_transmit)(void *token, struct sk_buff *skb); void (*data_transmit)(struct net_device *dev, struct sk_buff *skb);
}; };
struct lapb_parms_struct { struct lapb_parms_struct {
...@@ -45,12 +45,12 @@ struct lapb_parms_struct { ...@@ -45,12 +45,12 @@ struct lapb_parms_struct {
}; };
extern int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks); extern int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks);
extern int lapb_unregister(void *token); extern int lapb_unregister(struct net_device *dev);
extern int lapb_getparms(void *token, struct lapb_parms_struct *parms); extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms);
extern int lapb_setparms(void *token, struct lapb_parms_struct *parms); extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms);
extern int lapb_connect_request(void *token); extern int lapb_connect_request(struct net_device *dev);
extern int lapb_disconnect_request(void *token); extern int lapb_disconnect_request(struct net_device *dev);
extern int lapb_data_request(void *token, struct sk_buff *skb); extern int lapb_data_request(struct net_device *dev, struct sk_buff *skb);
extern int lapb_data_received(void *token, struct sk_buff *skb); extern int lapb_data_received(struct net_device *dev, struct sk_buff *skb);
#endif #endif
...@@ -81,18 +81,14 @@ static void __lapb_insert_cb(struct lapb_cb *lapb) ...@@ -81,18 +81,14 @@ static void __lapb_insert_cb(struct lapb_cb *lapb)
lapb_hold(lapb); lapb_hold(lapb);
} }
/* static struct lapb_cb *__lapb_devtostruct(struct net_device *dev)
* Convert the integer token used by the device driver into a pointer
* to a LAPB control structure.
*/
static struct lapb_cb *__lapb_tokentostruct(void *token)
{ {
struct list_head *entry; struct list_head *entry;
struct lapb_cb *lapb, *use = NULL; struct lapb_cb *lapb, *use = NULL;
list_for_each(entry, &lapb_list) { list_for_each(entry, &lapb_list) {
lapb = list_entry(entry, struct lapb_cb, node); lapb = list_entry(entry, struct lapb_cb, node);
if (lapb->token == token) { if (lapb->dev == dev) {
use = lapb; use = lapb;
break; break;
} }
...@@ -104,12 +100,12 @@ static struct lapb_cb *__lapb_tokentostruct(void *token) ...@@ -104,12 +100,12 @@ static struct lapb_cb *__lapb_tokentostruct(void *token)
return use; return use;
} }
static struct lapb_cb *lapb_tokentostruct(void *token) static struct lapb_cb *lapb_devtostruct(struct net_device *dev)
{ {
struct lapb_cb *rc; struct lapb_cb *rc;
read_lock_bh(&lapb_list_lock); read_lock_bh(&lapb_list_lock);
rc = __lapb_tokentostruct(token); rc = __lapb_devtostruct(dev);
read_unlock_bh(&lapb_list_lock); read_unlock_bh(&lapb_list_lock);
return rc; return rc;
...@@ -151,7 +147,7 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru ...@@ -151,7 +147,7 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru
write_lock_bh(&lapb_list_lock); write_lock_bh(&lapb_list_lock);
lapb = __lapb_tokentostruct(token); lapb = __lapb_devtostruct(dev);
if (lapb) { if (lapb) {
lapb_put(lapb); lapb_put(lapb);
goto out; goto out;
...@@ -176,13 +172,13 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru ...@@ -176,13 +172,13 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru
return rc; return rc;
} }
int lapb_unregister(void *token) int lapb_unregister(struct net_device *dev)
{ {
struct lapb_cb *lapb; struct lapb_cb *lapb;
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
write_unlock_bh(&lapb_list_lock); write_unlock_bh(&lapb_list_lock);
lapb = __lapb_tokentostruct(token); lapb = __lapb_devtostruct(dev);
if (!lapb) if (!lapb)
goto out; goto out;
...@@ -200,10 +196,10 @@ int lapb_unregister(void *token) ...@@ -200,10 +196,10 @@ int lapb_unregister(void *token)
return rc; return rc;
} }
int lapb_getparms(void *token, struct lapb_parms_struct *parms) int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms)
{ {
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
if (!lapb) if (!lapb)
goto out; goto out;
...@@ -232,10 +228,10 @@ int lapb_getparms(void *token, struct lapb_parms_struct *parms) ...@@ -232,10 +228,10 @@ int lapb_getparms(void *token, struct lapb_parms_struct *parms)
return rc; return rc;
} }
int lapb_setparms(void *token, struct lapb_parms_struct *parms) int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms)
{ {
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
if (!lapb) if (!lapb)
goto out; goto out;
...@@ -265,9 +261,9 @@ int lapb_setparms(void *token, struct lapb_parms_struct *parms) ...@@ -265,9 +261,9 @@ int lapb_setparms(void *token, struct lapb_parms_struct *parms)
return rc; return rc;
} }
int lapb_connect_request(void *token) int lapb_connect_request(struct net_device *dev)
{ {
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
if (!lapb) if (!lapb)
...@@ -295,9 +291,9 @@ int lapb_connect_request(void *token) ...@@ -295,9 +291,9 @@ int lapb_connect_request(void *token)
return rc; return rc;
} }
int lapb_disconnect_request(void *token) int lapb_disconnect_request(struct net_device *dev)
{ {
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
if (!lapb) if (!lapb)
...@@ -347,9 +343,9 @@ int lapb_disconnect_request(void *token) ...@@ -347,9 +343,9 @@ int lapb_disconnect_request(void *token)
return rc; return rc;
} }
int lapb_data_request(void *token, struct sk_buff *skb) int lapb_data_request(struct net_device *dev, struct sk_buff *skb)
{ {
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
if (!lapb) if (!lapb)
...@@ -368,9 +364,9 @@ int lapb_data_request(void *token, struct sk_buff *skb) ...@@ -368,9 +364,9 @@ int lapb_data_request(void *token, struct sk_buff *skb)
return rc; return rc;
} }
int lapb_data_received(void *token, struct sk_buff *skb) int lapb_data_received(struct net_device *dev, struct sk_buff *skb)
{ {
struct lapb_cb *lapb = lapb_tokentostruct(token); struct lapb_cb *lapb = lapb_devtostruct(dev);
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
if (lapb) { if (lapb) {
...@@ -385,31 +381,31 @@ int lapb_data_received(void *token, struct sk_buff *skb) ...@@ -385,31 +381,31 @@ int lapb_data_received(void *token, struct sk_buff *skb)
void lapb_connect_confirmation(struct lapb_cb *lapb, int reason) void lapb_connect_confirmation(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.connect_confirmation) if (lapb->callbacks.connect_confirmation)
lapb->callbacks.connect_confirmation(lapb->token, reason); lapb->callbacks.connect_confirmation(lapb->dev, reason);
} }
void lapb_connect_indication(struct lapb_cb *lapb, int reason) void lapb_connect_indication(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.connect_indication) if (lapb->callbacks.connect_indication)
lapb->callbacks.connect_indication(lapb->token, reason); lapb->callbacks.connect_indication(lapb->dev, reason);
} }
void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason) void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.disconnect_confirmation) if (lapb->callbacks.disconnect_confirmation)
lapb->callbacks.disconnect_confirmation(lapb->token, reason); lapb->callbacks.disconnect_confirmation(lapb->dev, reason);
} }
void lapb_disconnect_indication(struct lapb_cb *lapb, int reason) void lapb_disconnect_indication(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.disconnect_indication) if (lapb->callbacks.disconnect_indication)
lapb->callbacks.disconnect_indication(lapb->token, reason); lapb->callbacks.disconnect_indication(lapb->dev, reason);
} }
int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb) int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb)
{ {
if (lapb->callbacks.data_indication) if (lapb->callbacks.data_indication)
return lapb->callbacks.data_indication(lapb->token, skb); return lapb->callbacks.data_indication(lapb->dev, skb);
kfree_skb(skb); kfree_skb(skb);
return NET_RX_CN_HIGH; /* For now; must be != NET_RX_DROP */ return NET_RX_CN_HIGH; /* For now; must be != NET_RX_DROP */
...@@ -420,7 +416,7 @@ int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb) ...@@ -420,7 +416,7 @@ int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb)
int used = 0; int used = 0;
if (lapb->callbacks.data_transmit) { if (lapb->callbacks.data_transmit) {
lapb->callbacks.data_transmit(lapb->token, skb); lapb->callbacks.data_transmit(lapb->dev, skb);
used = 1; used = 1;
} }
......
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