patch-2.3.45 linux/drivers/net/wan/cycx_x25.c

Next file: linux/drivers/net/wan/lapbether.c
Previous file: linux/drivers/net/tulip.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.44/linux/drivers/net/wan/cycx_x25.c linux/drivers/net/wan/cycx_x25.c
@@ -93,6 +93,9 @@
 /* This is an extension of the 'struct net_device' we create for each network
    interface to keep the rest of X.25 channel-specific data. */
 typedef struct x25_channel {
+	/* This member must be first. */
+	struct net_device *slave;	/* WAN slave */
+
 	char name[WAN_IFNAME_SZ+1];	/* interface name, ASCIIZ */
 	char addr[WAN_ADDRESS_SZ+1];	/* media address, ASCIIZ */
 	char *local_addr;		/* local media address, ASCIIZ -
@@ -502,12 +505,10 @@
 	x25_channel_t *chan = dev->priv;
 	cycx_t *card = chan->card;
 
-	if (dev->start)
+	if (test_bit(LINK_STATE_START, &dev->state))
 		return -EBUSY; /* only one open is allowed */ 
 
-	dev->interrupt = 0;
-	dev->tbusy = 0;
-	dev->start = 1;
+	netif_start_queue(dev);
 	cyclomx_mod_inc_use_count(card);
 
 	return 0;
@@ -521,8 +522,8 @@
 	x25_channel_t *chan = dev->priv;
 	cycx_t *card = chan->card;
 
-	dev->start = 0;
-
+	netif_stop_queue(dev);
+	
 	if (chan->state == WAN_CONNECTED || chan->state == WAN_CONNECTING)
 		chan_disconnect(dev);
 		
@@ -556,7 +557,7 @@
 }
 
 /* Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission).
+ * o set busy flag (marks start of the transmission).
  * o check link state. If link is not up, then drop the packet.
  * o check channel status. If it's down then initiate a call.
  * o pass a packet to corresponding WAN device.
@@ -575,11 +576,6 @@
 	x25_channel_t *chan = dev->priv;
 	cycx_t *card = chan->card;
 
-	if (dev->tbusy) {
-		++chan->ifstats.rx_dropped;	
-		return -EBUSY;	
-	}
-
 	if (!chan->svc)
 		chan->protocol = skb->protocol;
 
@@ -595,14 +591,14 @@
 		switch (chan->state) {
 			case WAN_DISCONNECTED:
 				if (chan_connect(dev)) {
-					dev->tbusy = 1;
+					netif_stop_queue(dev);
 					return -EBUSY;
 				}
 				/* fall thru */
 			case WAN_CONNECTED:
 				reset_timer(dev);
 				dev->trans_start = jiffies;
-				dev->tbusy = 1;
+				netif_stop_queue(dev);
 
 				if (chan_send(dev, skb))
 					return -EBUSY;
@@ -632,8 +628,8 @@
 		skb_pull(skb, 1); /* Remove control byte */
 		reset_timer(dev);
 		dev->trans_start = jiffies;
-		dev->tbusy = 1;
-
+		netif_stop_queue(dev);
+		
 		if (chan_send(dev, skb)) {
 			/* prepare for future retransmissions */
 			skb_push(skb, 1);
@@ -705,9 +701,6 @@
 	cycx_poke(&card->hw, 0, &z, sizeof(z));
 	cycx_poke(&card->hw, X25_RXMBOX_OFFS, &z, sizeof(z));
 	card->in_isr = 0;
-
-	if (card->buff_int_mode_unbusy)
-		mark_bh(NET_BH);
 }
 
 /* Transmit interrupt handler.
@@ -724,7 +717,7 @@
 	/* unbusy device and then dev_tint(); */
 	if ((dev = get_dev_by_lcn(wandev, lcn)) != NULL) {
 		card->buff_int_mode_unbusy = 1;
-		dev->tbusy = 0;
+		netif_wake_queue(dev);
 	} else
 		printk(KERN_ERR "%s:ackvc for inexistent lcn %d\n",
 				 card->devname, lcn);
@@ -1263,11 +1256,13 @@
 static struct net_device *get_dev_by_lcn (wan_device_t *wandev, s16 lcn)
 {
 	struct net_device *dev = wandev->dev;
+	x25_channel_t *chan;
 
-	for (; dev; dev = dev->slave)
-		if (((x25_channel_t*)dev->priv)->lcn == lcn)
+	while (dev) {
+		if (chan->lcn == lcn)
 			break;
-	
+		dev = chan->slave;
+	}	
 	return dev;
 }
 
@@ -1275,11 +1270,13 @@
 static struct net_device *get_dev_by_dte_addr (wan_device_t *wandev, char *dte)
 {
 	struct net_device *dev = wandev->dev;
+	x25_channel_t *chan;
 
-	for (; dev; dev = dev->slave)
-		if (!strcmp(((x25_channel_t*)dev->priv)->addr, dte))
+	while (dev) {
+		if (!strcmp(chan->addr, dte))
 			break;
-
+		dev = chan->slave;
+	}
 	return dev;
 }
 
@@ -1357,7 +1354,7 @@
 			case WAN_CONNECTED:
 				string_state = "connected!";
 				*(u16*)dev->dev_addr = htons(chan->lcn);
-				dev->tbusy = 0;
+				netif_wake_queue(dev);
 				reset_timer(dev);
 
 				if (chan->protocol == ETH_P_X25)
@@ -1384,7 +1381,7 @@
 				if (chan->protocol == ETH_P_X25)
 					chan_x25_send_event(dev, 2);
 
-				dev->tbusy = 0;
+				netif_wake_queue(dev);
 				break;
 		}
 
@@ -1560,15 +1557,16 @@
 	struct net_device *dev = wandev->dev;
 
 	printk(KERN_INFO "X.25 dev states\n");
-	printk(KERN_INFO "name: addr:           tbusy:  protocol:\n");
+	printk(KERN_INFO "name: addr:           txoff:  protocol:\n");
 	printk(KERN_INFO "---------------------------------------\n");
 
-	for (; dev; dev = dev->slave) {
+	while(dev) {
 		x25_channel_t *chan = dev->priv;
 
-		printk(KERN_INFO "%-5.5s %-15.15s   %ld     ETH_P_%s\n",
-				 chan->name, chan->addr, dev->tbusy,
+		printk(KERN_INFO "%-5.5s %-15.15s   %d     ETH_P_%s\n",
+				 chan->name, chan->addr, test_bit(LINK_STATE_XOFF, &dev->state),
 				 chan->protocol == ETH_P_IP ? "IP" : "X25");
+		dev = chan->slave;
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)