| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 2 |  * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 |  * Filename:      irlan_eth.c | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 4 |  * Version: | 
 | 5 |  * Description: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 |  * Status:        Experimental. | 
 | 7 |  * Author:        Dag Brattli <dagb@cs.uit.no> | 
 | 8 |  * Created at:    Thu Oct 15 08:37:58 1998 | 
 | 9 |  * Modified at:   Tue Mar 21 09:06:41 2000 | 
 | 10 |  * Modified by:   Dag Brattli <dagb@cs.uit.no> | 
 | 11 |  * Sources:       skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov> | 
 | 12 |  *                slip.c by Laurence Culhane,   <loz@holmes.demon.co.uk> | 
 | 13 |  *                          Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 14 |  * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  *     Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 16 |  * | 
 | 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 | 
 | 19 |  *     published by the Free Software Foundation; either version 2 of | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 |  *     the License, or (at your option) any later version. | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 21 |  * | 
| Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 22 |  *     Neither Dag Brattli nor University of Tromsø admit liability nor | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 23 |  *     provide warranty for any of this software. This material is | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 |  *     provided "AS-IS" and at no charge. | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 25 |  * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 |  ********************************************************************/ | 
 | 27 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/netdevice.h> | 
 | 29 | #include <linux/etherdevice.h> | 
 | 30 | #include <linux/inetdevice.h> | 
 | 31 | #include <linux/if_arp.h> | 
 | 32 | #include <linux/module.h> | 
 | 33 | #include <net/arp.h> | 
 | 34 |  | 
 | 35 | #include <net/irda/irda.h> | 
 | 36 | #include <net/irda/irmod.h> | 
 | 37 | #include <net/irda/irlan_common.h> | 
 | 38 | #include <net/irda/irlan_client.h> | 
 | 39 | #include <net/irda/irlan_event.h> | 
 | 40 | #include <net/irda/irlan_eth.h> | 
 | 41 |  | 
 | 42 | static int  irlan_eth_open(struct net_device *dev); | 
 | 43 | static int  irlan_eth_close(struct net_device *dev); | 
 | 44 | static int  irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev); | 
 | 45 | static void irlan_eth_set_multicast_list( struct net_device *dev); | 
 | 46 | static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev); | 
 | 47 |  | 
 | 48 | /* | 
 | 49 |  * Function irlan_eth_setup (dev) | 
 | 50 |  * | 
 | 51 |  *    The network device initialization function. | 
 | 52 |  * | 
 | 53 |  */ | 
 | 54 | static void irlan_eth_setup(struct net_device *dev) | 
 | 55 | { | 
 | 56 | 	dev->open               = irlan_eth_open; | 
 | 57 | 	dev->stop               = irlan_eth_close; | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 58 | 	dev->hard_start_xmit    = irlan_eth_xmit; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | 	dev->get_stats	        = irlan_eth_get_stats; | 
 | 60 | 	dev->set_multicast_list = irlan_eth_set_multicast_list; | 
 | 61 | 	dev->destructor		= free_netdev; | 
 | 62 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | 	ether_setup(dev); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 64 |  | 
 | 65 | 	/* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | 	 * Lets do all queueing in IrTTP instead of this device driver. | 
 | 67 | 	 * Queueing here as well can introduce some strange latency | 
 | 68 | 	 * problems, which we will avoid by setting the queue size to 0. | 
 | 69 | 	 */ | 
 | 70 | 	/* | 
 | 71 | 	 * The bugs in IrTTP and IrLAN that created this latency issue | 
 | 72 | 	 * have now been fixed, and we can propagate flow control properly | 
 | 73 | 	 * to the network layer. However, this requires a minimal queue of | 
 | 74 | 	 * packets for the device. | 
 | 75 | 	 * Without flow control, the Tx Queue is 14 (ttp) + 0 (dev) = 14 | 
 | 76 | 	 * With flow control, the Tx Queue is 7 (ttp) + 4 (dev) = 11 | 
 | 77 | 	 * See irlan_eth_flow_indication()... | 
 | 78 | 	 * Note : this number was randomly selected and would need to | 
 | 79 | 	 * be adjusted. | 
 | 80 | 	 * Jean II */ | 
 | 81 | 	dev->tx_queue_len = 4; | 
 | 82 | } | 
 | 83 |  | 
 | 84 | /* | 
 | 85 |  * Function alloc_irlandev | 
 | 86 |  * | 
 | 87 |  *    Allocate network device and control block | 
 | 88 |  * | 
 | 89 |  */ | 
 | 90 | struct net_device *alloc_irlandev(const char *name) | 
 | 91 | { | 
 | 92 | 	return alloc_netdev(sizeof(struct irlan_cb), name, | 
 | 93 | 			    irlan_eth_setup); | 
 | 94 | } | 
 | 95 |  | 
 | 96 | /* | 
 | 97 |  * Function irlan_eth_open (dev) | 
 | 98 |  * | 
 | 99 |  *    Network device has been opened by user | 
 | 100 |  * | 
 | 101 |  */ | 
 | 102 | static int irlan_eth_open(struct net_device *dev) | 
 | 103 | { | 
 | 104 | 	struct irlan_cb *self = netdev_priv(dev); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 105 |  | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 106 | 	IRDA_DEBUG(2, "%s()\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 |  | 
 | 108 | 	/* Ready to play! */ | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 109 | 	netif_stop_queue(dev); /* Wait until data link is ready */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 |  | 
 | 111 | 	/* We are now open, so time to do some work */ | 
 | 112 | 	self->disconnect_reason = 0; | 
 | 113 | 	irlan_client_wakeup(self, self->saddr, self->daddr); | 
 | 114 |  | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 115 | 	/* Make sure we have a hardware address before we return, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | 	   so DHCP clients gets happy */ | 
 | 117 | 	return wait_event_interruptible(self->open_wait, | 
 | 118 | 					!self->tsap_data->connected); | 
 | 119 | } | 
 | 120 |  | 
 | 121 | /* | 
 | 122 |  * Function irlan_eth_close (dev) | 
 | 123 |  * | 
 | 124 |  *    Stop the ether network device, his function will usually be called by | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 125 |  *    ifconfig down. We should now disconnect the link, We start the | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 |  *    close timer, so that the instance will be removed if we are unable | 
 | 127 |  *    to discover the remote device after the disconnect. | 
 | 128 |  */ | 
 | 129 | static int irlan_eth_close(struct net_device *dev) | 
 | 130 | { | 
 | 131 | 	struct irlan_cb *self = netdev_priv(dev); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 132 |  | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 133 | 	IRDA_DEBUG(2, "%s()\n", __func__ ); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 134 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | 	/* Stop device */ | 
 | 136 | 	netif_stop_queue(dev); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 137 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | 	irlan_close_data_channel(self); | 
 | 139 | 	irlan_close_tsaps(self); | 
 | 140 |  | 
 | 141 | 	irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 142 | 	irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); | 
 | 143 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | 	/* Remove frames queued on the control channel */ | 
 | 145 | 	skb_queue_purge(&self->client.txq); | 
 | 146 |  | 
 | 147 | 	self->client.tx_busy = 0; | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 148 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | 	return 0; | 
 | 150 | } | 
 | 151 |  | 
 | 152 | /* | 
 | 153 |  * Function irlan_eth_tx (skb) | 
 | 154 |  * | 
 | 155 |  *    Transmits ethernet frames over IrDA link. | 
 | 156 |  * | 
 | 157 |  */ | 
 | 158 | static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev) | 
 | 159 | { | 
 | 160 | 	struct irlan_cb *self = netdev_priv(dev); | 
 | 161 | 	int ret; | 
 | 162 |  | 
 | 163 | 	/* skb headroom large enough to contain all IrDA-headers? */ | 
 | 164 | 	if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) { | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 165 | 		struct sk_buff *new_skb = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | 			skb_realloc_headroom(skb, self->max_header_size); | 
 | 167 |  | 
 | 168 | 		/*  We have to free the original skb anyway */ | 
 | 169 | 		dev_kfree_skb(skb); | 
 | 170 |  | 
 | 171 | 		/* Did the realloc succeed? */ | 
 | 172 | 		if (new_skb == NULL) | 
 | 173 | 			return 0; | 
 | 174 |  | 
 | 175 | 		/* Use the new skb instead */ | 
 | 176 | 		skb = new_skb; | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 177 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 |  | 
 | 179 | 	dev->trans_start = jiffies; | 
 | 180 |  | 
 | 181 | 	/* Now queue the packet in the transport layer */ | 
 | 182 | 	if (self->use_udata) | 
 | 183 | 		ret = irttp_udata_request(self->tsap_data, skb); | 
 | 184 | 	else | 
 | 185 | 		ret = irttp_data_request(self->tsap_data, skb); | 
 | 186 |  | 
 | 187 | 	if (ret < 0) { | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 188 | 		/* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | 		 * IrTTPs tx queue is full, so we just have to | 
 | 190 | 		 * drop the frame! You might think that we should | 
 | 191 | 		 * just return -1 and don't deallocate the frame, | 
 | 192 | 		 * but that is dangerous since it's possible that | 
 | 193 | 		 * we have replaced the original skb with a new | 
 | 194 | 		 * one with larger headroom, and that would really | 
 | 195 | 		 * confuse do_dev_queue_xmit() in dev.c! I have | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 196 | 		 * tried :-) DB | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | 		 */ | 
 | 198 | 		/* irttp_data_request already free the packet */ | 
 | 199 | 		self->stats.tx_dropped++; | 
 | 200 | 	} else { | 
 | 201 | 		self->stats.tx_packets++; | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 202 | 		self->stats.tx_bytes += skb->len; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | 	} | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 204 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | 	return 0; | 
 | 206 | } | 
 | 207 |  | 
 | 208 | /* | 
 | 209 |  * Function irlan_eth_receive (handle, skb) | 
 | 210 |  * | 
 | 211 |  *    This function gets the data that is received on the data channel | 
 | 212 |  * | 
 | 213 |  */ | 
 | 214 | int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb) | 
 | 215 | { | 
 | 216 | 	struct irlan_cb *self = instance; | 
 | 217 |  | 
 | 218 | 	if (skb == NULL) { | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 219 | 		++self->stats.rx_dropped; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | 		return 0; | 
 | 221 | 	} | 
 | 222 | 	if (skb->len < ETH_HLEN) { | 
 | 223 | 		IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n", | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 224 | 			   __func__, skb->len); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 225 | 		++self->stats.rx_dropped; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | 		dev_kfree_skb(skb); | 
 | 227 | 		return 0; | 
 | 228 | 	} | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 229 |  | 
 | 230 | 	/* | 
 | 231 | 	 * Adopt this frame! Important to set all these fields since they | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | 	 * might have been previously set by the low level IrDA network | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 233 | 	 * device driver | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | 	 */ | 
| Arnaldo Carvalho de Melo | 4c13eb6 | 2007-04-25 17:40:23 -0700 | [diff] [blame] | 235 | 	skb->protocol = eth_type_trans(skb, self->dev); /* Remove eth header */ | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 236 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | 	self->stats.rx_packets++; | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 238 | 	self->stats.rx_bytes += skb->len; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 |  | 
 | 240 | 	netif_rx(skb);   /* Eat it! */ | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 241 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | 	return 0; | 
 | 243 | } | 
 | 244 |  | 
 | 245 | /* | 
 | 246 |  * Function irlan_eth_flow (status) | 
 | 247 |  * | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 248 |  *    Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 |  *    controlling the queue stop/start. | 
 | 250 |  * | 
 | 251 |  * The IrDA link layer has the advantage to have flow control, and | 
 | 252 |  * IrTTP now properly handles that. Flow controlling the higher layers | 
 | 253 |  * prevent us to drop Tx packets in here (up to 15% for a TCP socket, | 
 | 254 |  * more for UDP socket). | 
 | 255 |  * Also, this allow us to reduce the overall transmit queue, which means | 
 | 256 |  * less latency in case of mixed traffic. | 
 | 257 |  * Jean II | 
 | 258 |  */ | 
 | 259 | void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow) | 
 | 260 | { | 
 | 261 | 	struct irlan_cb *self; | 
 | 262 | 	struct net_device *dev; | 
 | 263 |  | 
 | 264 | 	self = (struct irlan_cb *) instance; | 
 | 265 |  | 
 | 266 | 	IRDA_ASSERT(self != NULL, return;); | 
 | 267 | 	IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 268 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | 	dev = self->dev; | 
 | 270 |  | 
 | 271 | 	IRDA_ASSERT(dev != NULL, return;); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 272 |  | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 273 | 	IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __func__, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | 		   flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START", | 
 | 275 | 		   netif_running(dev)); | 
 | 276 |  | 
 | 277 | 	switch (flow) { | 
 | 278 | 	case FLOW_STOP: | 
 | 279 | 		/* IrTTP is full, stop higher layers */ | 
 | 280 | 		netif_stop_queue(dev); | 
 | 281 | 		break; | 
 | 282 | 	case FLOW_START: | 
 | 283 | 	default: | 
 | 284 | 		/* Tell upper layers that its time to transmit frames again */ | 
 | 285 | 		/* Schedule network layer */ | 
 | 286 | 		netif_wake_queue(dev); | 
 | 287 | 		break; | 
 | 288 | 	} | 
 | 289 | } | 
 | 290 |  | 
 | 291 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 |  * Function set_multicast_list (dev) | 
 | 293 |  * | 
 | 294 |  *    Configure the filtering of the device | 
 | 295 |  * | 
 | 296 |  */ | 
 | 297 | #define HW_MAX_ADDRS 4 /* Must query to get it! */ | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 298 | static void irlan_eth_set_multicast_list(struct net_device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 300 | 	struct irlan_cb *self = netdev_priv(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 |  | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 302 | 	IRDA_DEBUG(2, "%s()\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 |  | 
 | 304 | 	/* Check if data channel has been connected yet */ | 
 | 305 | 	if (self->client.state != IRLAN_DATA) { | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 306 | 		IRDA_DEBUG(1, "%s(), delaying!\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | 		return; | 
 | 308 | 	} | 
 | 309 |  | 
 | 310 | 	if (dev->flags & IFF_PROMISC) { | 
 | 311 | 		/* Enable promiscuous mode */ | 
| Joe Perches | cc53ded | 2007-12-20 14:00:51 -0800 | [diff] [blame] | 312 | 		IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n"); | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 313 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | 	else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { | 
 | 315 | 		/* Disable promiscuous mode, use normal mode. */ | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 316 | 		IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | 		/* hardware_set_filter(NULL); */ | 
 | 318 |  | 
 | 319 | 		irlan_set_multicast_filter(self, TRUE); | 
 | 320 | 	} | 
 | 321 | 	else if (dev->mc_count) { | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 322 | 		IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | 		/* Walk the address list, and load the filter */ | 
 | 324 | 		/* hardware_set_filter(dev->mc_list); */ | 
 | 325 |  | 
 | 326 | 		irlan_set_multicast_filter(self, TRUE); | 
 | 327 | 	} | 
 | 328 | 	else { | 
| Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 329 | 		IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__ ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | 		irlan_set_multicast_filter(self, FALSE); | 
 | 331 | 	} | 
 | 332 |  | 
 | 333 | 	if (dev->flags & IFF_BROADCAST) | 
 | 334 | 		irlan_set_broadcast_filter(self, TRUE); | 
 | 335 | 	else | 
 | 336 | 		irlan_set_broadcast_filter(self, FALSE); | 
 | 337 | } | 
 | 338 |  | 
 | 339 | /* | 
 | 340 |  * Function irlan_get_stats (dev) | 
 | 341 |  * | 
 | 342 |  *    Get the current statistics for this device | 
 | 343 |  * | 
 | 344 |  */ | 
| YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 345 | static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | { | 
 | 347 | 	struct irlan_cb *self = netdev_priv(dev); | 
 | 348 |  | 
 | 349 | 	return &self->stats; | 
 | 350 | } |