aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/irlan/irlan_eth.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda/irlan/irlan_eth.c')
-rw-r--r--net/irda/irlan/irlan_eth.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index b0ccc455b747..672ab3f69033 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -1,8 +1,8 @@
1/********************************************************************* 1/*********************************************************************
2 * 2 *
3 * Filename: irlan_eth.c 3 * Filename: irlan_eth.c
4 * Version: 4 * Version:
5 * Description: 5 * Description:
6 * Status: Experimental. 6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no> 7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Thu Oct 15 08:37:58 1998 8 * Created at: Thu Oct 15 08:37:58 1998
@@ -11,18 +11,18 @@
11 * Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov> 11 * Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
12 * slip.c by Laurence Culhane, <loz@holmes.demon.co.uk> 12 * slip.c by Laurence Culhane, <loz@holmes.demon.co.uk>
13 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 13 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
14 * 14 *
15 * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. 15 * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved.
16 * 16 *
17 * This program is free software; you can redistribute it and/or 17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as 18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of 19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version. 20 * the License, or (at your option) any later version.
21 * 21 *
22 * Neither Dag Brattli nor University of Tromsų admit liability nor 22 * Neither Dag Brattli nor University of Tromsų admit liability nor
23 * provide warranty for any of this software. This material is 23 * provide warranty for any of this software. This material is
24 * provided "AS-IS" and at no charge. 24 * provided "AS-IS" and at no charge.
25 * 25 *
26 ********************************************************************/ 26 ********************************************************************/
27 27
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
@@ -55,7 +55,7 @@ static void irlan_eth_setup(struct net_device *dev)
55{ 55{
56 dev->open = irlan_eth_open; 56 dev->open = irlan_eth_open;
57 dev->stop = irlan_eth_close; 57 dev->stop = irlan_eth_close;
58 dev->hard_start_xmit = irlan_eth_xmit; 58 dev->hard_start_xmit = irlan_eth_xmit;
59 dev->get_stats = irlan_eth_get_stats; 59 dev->get_stats = irlan_eth_get_stats;
60 dev->set_multicast_list = irlan_eth_set_multicast_list; 60 dev->set_multicast_list = irlan_eth_set_multicast_list;
61 dev->destructor = free_netdev; 61 dev->destructor = free_netdev;
@@ -63,8 +63,8 @@ static void irlan_eth_setup(struct net_device *dev)
63 SET_MODULE_OWNER(dev); 63 SET_MODULE_OWNER(dev);
64 64
65 ether_setup(dev); 65 ether_setup(dev);
66 66
67 /* 67 /*
68 * Lets do all queueing in IrTTP instead of this device driver. 68 * Lets do all queueing in IrTTP instead of this device driver.
69 * Queueing here as well can introduce some strange latency 69 * Queueing here as well can introduce some strange latency
70 * problems, which we will avoid by setting the queue size to 0. 70 * problems, which we will avoid by setting the queue size to 0.
@@ -104,17 +104,17 @@ struct net_device *alloc_irlandev(const char *name)
104static int irlan_eth_open(struct net_device *dev) 104static int irlan_eth_open(struct net_device *dev)
105{ 105{
106 struct irlan_cb *self = netdev_priv(dev); 106 struct irlan_cb *self = netdev_priv(dev);
107 107
108 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 108 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
109 109
110 /* Ready to play! */ 110 /* Ready to play! */
111 netif_stop_queue(dev); /* Wait until data link is ready */ 111 netif_stop_queue(dev); /* Wait until data link is ready */
112 112
113 /* We are now open, so time to do some work */ 113 /* We are now open, so time to do some work */
114 self->disconnect_reason = 0; 114 self->disconnect_reason = 0;
115 irlan_client_wakeup(self, self->saddr, self->daddr); 115 irlan_client_wakeup(self, self->saddr, self->daddr);
116 116
117 /* Make sure we have a hardware address before we return, 117 /* Make sure we have a hardware address before we return,
118 so DHCP clients gets happy */ 118 so DHCP clients gets happy */
119 return wait_event_interruptible(self->open_wait, 119 return wait_event_interruptible(self->open_wait,
120 !self->tsap_data->connected); 120 !self->tsap_data->connected);
@@ -124,30 +124,30 @@ static int irlan_eth_open(struct net_device *dev)
124 * Function irlan_eth_close (dev) 124 * Function irlan_eth_close (dev)
125 * 125 *
126 * Stop the ether network device, his function will usually be called by 126 * Stop the ether network device, his function will usually be called by
127 * ifconfig down. We should now disconnect the link, We start the 127 * ifconfig down. We should now disconnect the link, We start the
128 * close timer, so that the instance will be removed if we are unable 128 * close timer, so that the instance will be removed if we are unable
129 * to discover the remote device after the disconnect. 129 * to discover the remote device after the disconnect.
130 */ 130 */
131static int irlan_eth_close(struct net_device *dev) 131static int irlan_eth_close(struct net_device *dev)
132{ 132{
133 struct irlan_cb *self = netdev_priv(dev); 133 struct irlan_cb *self = netdev_priv(dev);
134 134
135 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 135 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
136 136
137 /* Stop device */ 137 /* Stop device */
138 netif_stop_queue(dev); 138 netif_stop_queue(dev);
139 139
140 irlan_close_data_channel(self); 140 irlan_close_data_channel(self);
141 irlan_close_tsaps(self); 141 irlan_close_tsaps(self);
142 142
143 irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL); 143 irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
144 irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); 144 irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
145 145
146 /* Remove frames queued on the control channel */ 146 /* Remove frames queued on the control channel */
147 skb_queue_purge(&self->client.txq); 147 skb_queue_purge(&self->client.txq);
148 148
149 self->client.tx_busy = 0; 149 self->client.tx_busy = 0;
150 150
151 return 0; 151 return 0;
152} 152}
153 153
@@ -164,7 +164,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
164 164
165 /* skb headroom large enough to contain all IrDA-headers? */ 165 /* skb headroom large enough to contain all IrDA-headers? */
166 if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) { 166 if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) {
167 struct sk_buff *new_skb = 167 struct sk_buff *new_skb =
168 skb_realloc_headroom(skb, self->max_header_size); 168 skb_realloc_headroom(skb, self->max_header_size);
169 169
170 /* We have to free the original skb anyway */ 170 /* We have to free the original skb anyway */
@@ -176,7 +176,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
176 176
177 /* Use the new skb instead */ 177 /* Use the new skb instead */
178 skb = new_skb; 178 skb = new_skb;
179 } 179 }
180 180
181 dev->trans_start = jiffies; 181 dev->trans_start = jiffies;
182 182
@@ -187,7 +187,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
187 ret = irttp_data_request(self->tsap_data, skb); 187 ret = irttp_data_request(self->tsap_data, skb);
188 188
189 if (ret < 0) { 189 if (ret < 0) {
190 /* 190 /*
191 * IrTTPs tx queue is full, so we just have to 191 * IrTTPs tx queue is full, so we just have to
192 * drop the frame! You might think that we should 192 * drop the frame! You might think that we should
193 * just return -1 and don't deallocate the frame, 193 * just return -1 and don't deallocate the frame,
@@ -195,15 +195,15 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
195 * we have replaced the original skb with a new 195 * we have replaced the original skb with a new
196 * one with larger headroom, and that would really 196 * one with larger headroom, and that would really
197 * confuse do_dev_queue_xmit() in dev.c! I have 197 * confuse do_dev_queue_xmit() in dev.c! I have
198 * tried :-) DB 198 * tried :-) DB
199 */ 199 */
200 /* irttp_data_request already free the packet */ 200 /* irttp_data_request already free the packet */
201 self->stats.tx_dropped++; 201 self->stats.tx_dropped++;
202 } else { 202 } else {
203 self->stats.tx_packets++; 203 self->stats.tx_packets++;
204 self->stats.tx_bytes += skb->len; 204 self->stats.tx_bytes += skb->len;
205 } 205 }
206 206
207 return 0; 207 return 0;
208} 208}
209 209
@@ -218,37 +218,37 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
218 struct irlan_cb *self = instance; 218 struct irlan_cb *self = instance;
219 219
220 if (skb == NULL) { 220 if (skb == NULL) {
221 ++self->stats.rx_dropped; 221 ++self->stats.rx_dropped;
222 return 0; 222 return 0;
223 } 223 }
224 if (skb->len < ETH_HLEN) { 224 if (skb->len < ETH_HLEN) {
225 IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n", 225 IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n",
226 __FUNCTION__, skb->len); 226 __FUNCTION__, skb->len);
227 ++self->stats.rx_dropped; 227 ++self->stats.rx_dropped;
228 dev_kfree_skb(skb); 228 dev_kfree_skb(skb);
229 return 0; 229 return 0;
230 } 230 }
231 231
232 /* 232 /*
233 * Adopt this frame! Important to set all these fields since they 233 * Adopt this frame! Important to set all these fields since they
234 * might have been previously set by the low level IrDA network 234 * might have been previously set by the low level IrDA network
235 * device driver 235 * device driver
236 */ 236 */
237 skb->dev = self->dev; 237 skb->dev = self->dev;
238 skb->protocol=eth_type_trans(skb, skb->dev); /* Remove eth header */ 238 skb->protocol=eth_type_trans(skb, skb->dev); /* Remove eth header */
239 239
240 self->stats.rx_packets++; 240 self->stats.rx_packets++;
241 self->stats.rx_bytes += skb->len; 241 self->stats.rx_bytes += skb->len;
242 242
243 netif_rx(skb); /* Eat it! */ 243 netif_rx(skb); /* Eat it! */
244 244
245 return 0; 245 return 0;
246} 246}
247 247
248/* 248/*
249 * Function irlan_eth_flow (status) 249 * Function irlan_eth_flow (status)
250 * 250 *
251 * Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by 251 * Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by
252 * controlling the queue stop/start. 252 * controlling the queue stop/start.
253 * 253 *
254 * The IrDA link layer has the advantage to have flow control, and 254 * The IrDA link layer has the advantage to have flow control, and
@@ -268,11 +268,11 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
268 268
269 IRDA_ASSERT(self != NULL, return;); 269 IRDA_ASSERT(self != NULL, return;);
270 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 270 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
271 271
272 dev = self->dev; 272 dev = self->dev;
273 273
274 IRDA_ASSERT(dev != NULL, return;); 274 IRDA_ASSERT(dev != NULL, return;);
275 275
276 IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __FUNCTION__, 276 IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __FUNCTION__,
277 flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START", 277 flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START",
278 netif_running(dev)); 278 netif_running(dev));
@@ -301,10 +301,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
301{ 301{
302 struct in_device *in_dev; 302 struct in_device *in_dev;
303 303
304 /* 304 /*
305 * When we get a new MAC address do a gratuitous ARP. This 305 * When we get a new MAC address do a gratuitous ARP. This
306 * is useful if we have changed access points on the same 306 * is useful if we have changed access points on the same
307 * subnet. 307 * subnet.
308 */ 308 */
309#ifdef CONFIG_INET 309#ifdef CONFIG_INET
310 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); 310 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
@@ -313,10 +313,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
313 if (in_dev == NULL) 313 if (in_dev == NULL)
314 goto out; 314 goto out;
315 if (in_dev->ifa_list) 315 if (in_dev->ifa_list)
316 316
317 arp_send(ARPOP_REQUEST, ETH_P_ARP, 317 arp_send(ARPOP_REQUEST, ETH_P_ARP,
318 in_dev->ifa_list->ifa_address, 318 in_dev->ifa_list->ifa_address,
319 dev, 319 dev,
320 in_dev->ifa_list->ifa_address, 320 in_dev->ifa_list->ifa_address,
321 NULL, dev->dev_addr, NULL); 321 NULL, dev->dev_addr, NULL);
322out: 322out:
@@ -331,9 +331,9 @@ out:
331 * 331 *
332 */ 332 */
333#define HW_MAX_ADDRS 4 /* Must query to get it! */ 333#define HW_MAX_ADDRS 4 /* Must query to get it! */
334static void irlan_eth_set_multicast_list(struct net_device *dev) 334static void irlan_eth_set_multicast_list(struct net_device *dev)
335{ 335{
336 struct irlan_cb *self = netdev_priv(dev); 336 struct irlan_cb *self = netdev_priv(dev);
337 337
338 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 338 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
339 339
@@ -346,7 +346,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
346 if (dev->flags & IFF_PROMISC) { 346 if (dev->flags & IFF_PROMISC) {
347 /* Enable promiscuous mode */ 347 /* Enable promiscuous mode */
348 IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n"); 348 IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n");
349 } 349 }
350 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { 350 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) {
351 /* Disable promiscuous mode, use normal mode. */ 351 /* Disable promiscuous mode, use normal mode. */
352 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __FUNCTION__ ); 352 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __FUNCTION__ );
@@ -378,7 +378,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
378 * Get the current statistics for this device 378 * Get the current statistics for this device
379 * 379 *
380 */ 380 */
381static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev) 381static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev)
382{ 382{
383 struct irlan_cb *self = netdev_priv(dev); 383 struct irlan_cb *self = netdev_priv(dev);
384 384