aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/ipwireless/network.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pcmcia/ipwireless/network.c')
-rw-r--r--drivers/char/pcmcia/ipwireless/network.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c
index fe914d34f7f6..590762a7f217 100644
--- a/drivers/char/pcmcia/ipwireless/network.c
+++ b/drivers/char/pcmcia/ipwireless/network.c
@@ -29,7 +29,6 @@
29#include "main.h" 29#include "main.h"
30#include "tty.h" 30#include "tty.h"
31 31
32#define MAX_OUTGOING_PACKETS_QUEUED ipwireless_out_queue
33#define MAX_ASSOCIATED_TTYS 2 32#define MAX_ASSOCIATED_TTYS 2
34 33
35#define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP) 34#define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP)
@@ -46,7 +45,7 @@ struct ipw_network {
46 /* Number of packets queued up in hardware module. */ 45 /* Number of packets queued up in hardware module. */
47 int outgoing_packets_queued; 46 int outgoing_packets_queued;
48 /* Spinlock to avoid interrupts during shutdown */ 47 /* Spinlock to avoid interrupts during shutdown */
49 spinlock_t spinlock; 48 spinlock_t lock;
50 struct mutex close_lock; 49 struct mutex close_lock;
51 50
52 /* PPP ioctl data, not actually used anywere */ 51 /* PPP ioctl data, not actually used anywere */
@@ -68,20 +67,20 @@ static void notify_packet_sent(void *callback_data, unsigned int packet_length)
68 struct ipw_network *network = callback_data; 67 struct ipw_network *network = callback_data;
69 unsigned long flags; 68 unsigned long flags;
70 69
71 spin_lock_irqsave(&network->spinlock, flags); 70 spin_lock_irqsave(&network->lock, flags);
72 network->outgoing_packets_queued--; 71 network->outgoing_packets_queued--;
73 if (network->ppp_channel != NULL) { 72 if (network->ppp_channel != NULL) {
74 if (network->ppp_blocked) { 73 if (network->ppp_blocked) {
75 network->ppp_blocked = 0; 74 network->ppp_blocked = 0;
76 spin_unlock_irqrestore(&network->spinlock, flags); 75 spin_unlock_irqrestore(&network->lock, flags);
77 ppp_output_wakeup(network->ppp_channel); 76 ppp_output_wakeup(network->ppp_channel);
78 if (ipwireless_debug) 77 if (ipwireless_debug)
79 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 78 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
80 ": ppp unblocked\n"); 79 ": ppp unblocked\n");
81 } else 80 } else
82 spin_unlock_irqrestore(&network->spinlock, flags); 81 spin_unlock_irqrestore(&network->lock, flags);
83 } else 82 } else
84 spin_unlock_irqrestore(&network->spinlock, flags); 83 spin_unlock_irqrestore(&network->lock, flags);
85} 84}
86 85
87/* 86/*
@@ -93,8 +92,8 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
93 struct ipw_network *network = ppp_channel->private; 92 struct ipw_network *network = ppp_channel->private;
94 unsigned long flags; 93 unsigned long flags;
95 94
96 spin_lock_irqsave(&network->spinlock, flags); 95 spin_lock_irqsave(&network->lock, flags);
97 if (network->outgoing_packets_queued < MAX_OUTGOING_PACKETS_QUEUED) { 96 if (network->outgoing_packets_queued < ipwireless_out_queue) {
98 unsigned char *buf; 97 unsigned char *buf;
99 static unsigned char header[] = { 98 static unsigned char header[] = {
100 PPP_ALLSTATIONS, /* 0xff */ 99 PPP_ALLSTATIONS, /* 0xff */
@@ -103,7 +102,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
103 int ret; 102 int ret;
104 103
105 network->outgoing_packets_queued++; 104 network->outgoing_packets_queued++;
106 spin_unlock_irqrestore(&network->spinlock, flags); 105 spin_unlock_irqrestore(&network->lock, flags);
107 106
108 /* 107 /*
109 * If we have the requested amount of headroom in the skb we 108 * If we have the requested amount of headroom in the skb we
@@ -144,7 +143,9 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
144 * needs to be unblocked once we are ready to send. 143 * needs to be unblocked once we are ready to send.
145 */ 144 */
146 network->ppp_blocked = 1; 145 network->ppp_blocked = 1;
147 spin_unlock_irqrestore(&network->spinlock, flags); 146 spin_unlock_irqrestore(&network->lock, flags);
147 if (ipwireless_debug)
148 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME ": ppp blocked\n");
148 return 0; 149 return 0;
149 } 150 }
150} 151}
@@ -249,11 +250,11 @@ static void do_go_online(struct work_struct *work_go_online)
249 work_go_online); 250 work_go_online);
250 unsigned long flags; 251 unsigned long flags;
251 252
252 spin_lock_irqsave(&network->spinlock, flags); 253 spin_lock_irqsave(&network->lock, flags);
253 if (!network->ppp_channel) { 254 if (!network->ppp_channel) {
254 struct ppp_channel *channel; 255 struct ppp_channel *channel;
255 256
256 spin_unlock_irqrestore(&network->spinlock, flags); 257 spin_unlock_irqrestore(&network->lock, flags);
257 channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL); 258 channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL);
258 if (!channel) { 259 if (!channel) {
259 printk(KERN_ERR IPWIRELESS_PCCARD_NAME 260 printk(KERN_ERR IPWIRELESS_PCCARD_NAME
@@ -273,10 +274,10 @@ static void do_go_online(struct work_struct *work_go_online)
273 network->xaccm[3] = 0x60000000U; 274 network->xaccm[3] = 0x60000000U;
274 network->raccm = ~0U; 275 network->raccm = ~0U;
275 ppp_register_channel(channel); 276 ppp_register_channel(channel);
276 spin_lock_irqsave(&network->spinlock, flags); 277 spin_lock_irqsave(&network->lock, flags);
277 network->ppp_channel = channel; 278 network->ppp_channel = channel;
278 } 279 }
279 spin_unlock_irqrestore(&network->spinlock, flags); 280 spin_unlock_irqrestore(&network->lock, flags);
280} 281}
281 282
282static void do_go_offline(struct work_struct *work_go_offline) 283static void do_go_offline(struct work_struct *work_go_offline)
@@ -287,16 +288,16 @@ static void do_go_offline(struct work_struct *work_go_offline)
287 unsigned long flags; 288 unsigned long flags;
288 289
289 mutex_lock(&network->close_lock); 290 mutex_lock(&network->close_lock);
290 spin_lock_irqsave(&network->spinlock, flags); 291 spin_lock_irqsave(&network->lock, flags);
291 if (network->ppp_channel != NULL) { 292 if (network->ppp_channel != NULL) {
292 struct ppp_channel *channel = network->ppp_channel; 293 struct ppp_channel *channel = network->ppp_channel;
293 294
294 network->ppp_channel = NULL; 295 network->ppp_channel = NULL;
295 spin_unlock_irqrestore(&network->spinlock, flags); 296 spin_unlock_irqrestore(&network->lock, flags);
296 mutex_unlock(&network->close_lock); 297 mutex_unlock(&network->close_lock);
297 ppp_unregister_channel(channel); 298 ppp_unregister_channel(channel);
298 } else { 299 } else {
299 spin_unlock_irqrestore(&network->spinlock, flags); 300 spin_unlock_irqrestore(&network->lock, flags);
300 mutex_unlock(&network->close_lock); 301 mutex_unlock(&network->close_lock);
301 } 302 }
302} 303}
@@ -381,18 +382,18 @@ void ipwireless_network_packet_received(struct ipw_network *network,
381 * the PPP layer. 382 * the PPP layer.
382 */ 383 */
383 mutex_lock(&network->close_lock); 384 mutex_lock(&network->close_lock);
384 spin_lock_irqsave(&network->spinlock, flags); 385 spin_lock_irqsave(&network->lock, flags);
385 if (network->ppp_channel != NULL) { 386 if (network->ppp_channel != NULL) {
386 struct sk_buff *skb; 387 struct sk_buff *skb;
387 388
388 spin_unlock_irqrestore(&network->spinlock, 389 spin_unlock_irqrestore(&network->lock,
389 flags); 390 flags);
390 391
391 /* Send the data to the ppp_generic module. */ 392 /* Send the data to the ppp_generic module. */
392 skb = ipw_packet_received_skb(data, length); 393 skb = ipw_packet_received_skb(data, length);
393 ppp_input(network->ppp_channel, skb); 394 ppp_input(network->ppp_channel, skb);
394 } else 395 } else
395 spin_unlock_irqrestore(&network->spinlock, 396 spin_unlock_irqrestore(&network->lock,
396 flags); 397 flags);
397 mutex_unlock(&network->close_lock); 398 mutex_unlock(&network->close_lock);
398 } 399 }
@@ -410,7 +411,7 @@ struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw)
410 if (!network) 411 if (!network)
411 return NULL; 412 return NULL;
412 413
413 spin_lock_init(&network->spinlock); 414 spin_lock_init(&network->lock);
414 mutex_init(&network->close_lock); 415 mutex_init(&network->close_lock);
415 416
416 network->hardware = hw; 417 network->hardware = hw;
@@ -478,10 +479,10 @@ int ipwireless_ppp_channel_index(struct ipw_network *network)
478 int ret = -1; 479 int ret = -1;
479 unsigned long flags; 480 unsigned long flags;
480 481
481 spin_lock_irqsave(&network->spinlock, flags); 482 spin_lock_irqsave(&network->lock, flags);
482 if (network->ppp_channel != NULL) 483 if (network->ppp_channel != NULL)
483 ret = ppp_channel_index(network->ppp_channel); 484 ret = ppp_channel_index(network->ppp_channel);
484 spin_unlock_irqrestore(&network->spinlock, flags); 485 spin_unlock_irqrestore(&network->lock, flags);
485 486
486 return ret; 487 return ret;
487} 488}
@@ -491,10 +492,15 @@ int ipwireless_ppp_unit_number(struct ipw_network *network)
491 int ret = -1; 492 int ret = -1;
492 unsigned long flags; 493 unsigned long flags;
493 494
494 spin_lock_irqsave(&network->spinlock, flags); 495 spin_lock_irqsave(&network->lock, flags);
495 if (network->ppp_channel != NULL) 496 if (network->ppp_channel != NULL)
496 ret = ppp_unit_number(network->ppp_channel); 497 ret = ppp_unit_number(network->ppp_channel);
497 spin_unlock_irqrestore(&network->spinlock, flags); 498 spin_unlock_irqrestore(&network->lock, flags);
498 499
499 return ret; 500 return ret;
500} 501}
502
503int ipwireless_ppp_mru(const struct ipw_network *network)
504{
505 return network->mru;
506}