aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 17:25:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 17:25:41 -0500
commit5fbbf5f648a9c4ef99276854f05b2255d1b004d3 (patch)
tree59c9ae762c3df2800e894001b3de58c5f1972486 /drivers/isdn
parentce279e6ec91c49f2c5f59f7492e19d39edbf8bbd (diff)
parent56cf391a9462a4897ea660a6af3662dda5ae8c84 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (84 commits) wimax: fix kernel-doc for debufs_dentry member of struct wimax_dev net: convert pegasus driver to net_device_ops bnx2x: Prevent eeprom set when driver is down net: switch kaweth driver to netdevops pcnet32: round off carrier watch timer i2400m/usb: wrap USB power saving in #ifdef CONFIG_PM wimax: testing for rfkill support should also test for CONFIG_RFKILL_MODULE wimax: fix kconfig interactions with rfkill and input layers wimax: fix '#ifndef CONFIG_BUG' layout to avoid warning r6040: bump release number to 0.20 r6040: warn about MAC address being unset r6040: check PHY status when bringing interface up r6040: make printks consistent with DRV_NAME gianfar: Fixup use of BUS_ID_SIZE mlx4_en: Returning real Max in get_ringparam mlx4_en: Consider inline packets on completion netdev: bfin_mac: enable bfin_mac net dev driver for BF51x qeth: convert to net_device_ops vlan: add neigh_setup dm9601: warn on invalid mac address ...
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/hysdn/hysdn_net.c77
-rw-r--r--drivers/isdn/i4l/isdn_net.c69
2 files changed, 76 insertions, 70 deletions
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index 7ee5bd9f2bb4..579974cf4c9a 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -38,16 +38,12 @@ char *hysdn_net_revision = "$Revision: 1.8.6.4 $";
38/* inside the definition. */ 38/* inside the definition. */
39/****************************************************************************/ 39/****************************************************************************/
40struct net_local { 40struct net_local {
41 struct net_device netdev; /* the network device */
42 struct net_device_stats stats;
43 /* additional vars may be added here */
44 char dev_name[9]; /* our own device name */
45
46 /* Tx control lock. This protects the transmit buffer ring 41 /* Tx control lock. This protects the transmit buffer ring
47 * state along with the "tx full" state of the driver. This 42 * state along with the "tx full" state of the driver. This
48 * means all netif_queue flow control actions are protected 43 * means all netif_queue flow control actions are protected
49 * by this lock as well. 44 * by this lock as well.
50 */ 45 */
46 struct net_device *dev;
51 spinlock_t lock; 47 spinlock_t lock;
52 struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */ 48 struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */
53 int in_idx, out_idx; /* indexes to buffer ring */ 49 int in_idx, out_idx; /* indexes to buffer ring */
@@ -55,15 +51,6 @@ struct net_local {
55}; /* net_local */ 51}; /* net_local */
56 52
57 53
58/*****************************************************/
59/* Get the current statistics for this card. */
60/* This may be called with the card open or closed ! */
61/*****************************************************/
62static struct net_device_stats *
63net_get_stats(struct net_device *dev)
64{
65 return (&((struct net_local *) dev)->stats);
66} /* net_device_stats */
67 54
68/*********************************************************************/ 55/*********************************************************************/
69/* Open/initialize the board. This is called (in the current kernel) */ 56/* Open/initialize the board. This is called (in the current kernel) */
@@ -182,8 +169,8 @@ hysdn_tx_netack(hysdn_card * card)
182 if (!lp->sk_count) 169 if (!lp->sk_count)
183 return; /* error condition */ 170 return; /* error condition */
184 171
185 lp->stats.tx_packets++; 172 lp->dev->stats.tx_packets++;
186 lp->stats.tx_bytes += lp->skbs[lp->out_idx]->len; 173 lp->dev->stats.tx_bytes += lp->skbs[lp->out_idx]->len;
187 174
188 dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */ 175 dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */
189 if (lp->out_idx >= MAX_SKB_BUFFERS) 176 if (lp->out_idx >= MAX_SKB_BUFFERS)
@@ -200,29 +187,30 @@ void
200hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) 187hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
201{ 188{
202 struct net_local *lp = card->netif; 189 struct net_local *lp = card->netif;
190 struct net_device *dev = lp->dev;
203 struct sk_buff *skb; 191 struct sk_buff *skb;
204 192
205 if (!lp) 193 if (!lp)
206 return; /* non existing device */ 194 return; /* non existing device */
207 195
208 lp->stats.rx_bytes += len; 196 dev->stats.rx_bytes += len;
209 197
210 skb = dev_alloc_skb(len); 198 skb = dev_alloc_skb(len);
211 if (skb == NULL) { 199 if (skb == NULL) {
212 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", 200 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
213 lp->netdev.name); 201 dev->name);
214 lp->stats.rx_dropped++; 202 dev->stats.rx_dropped++;
215 return; 203 return;
216 } 204 }
217 /* copy the data */ 205 /* copy the data */
218 memcpy(skb_put(skb, len), buf, len); 206 memcpy(skb_put(skb, len), buf, len);
219 207
220 /* determine the used protocol */ 208 /* determine the used protocol */
221 skb->protocol = eth_type_trans(skb, &lp->netdev); 209 skb->protocol = eth_type_trans(skb, dev);
222 210
223 netif_rx(skb); 211 dev->stats.rx_packets++; /* adjust packet count */
224 lp->stats.rx_packets++; /* adjust packet count */
225 212
213 netif_rx(skb);
226} /* hysdn_rx_netpkt */ 214} /* hysdn_rx_netpkt */
227 215
228/*****************************************************/ 216/*****************************************************/
@@ -242,24 +230,15 @@ hysdn_tx_netget(hysdn_card * card)
242 return (lp->skbs[lp->out_idx]); /* next packet to send */ 230 return (lp->skbs[lp->out_idx]); /* next packet to send */
243} /* hysdn_tx_netget */ 231} /* hysdn_tx_netget */
244 232
233static const struct net_device_ops hysdn_netdev_ops = {
234 .ndo_open = net_open,
235 .ndo_stop = net_close,
236 .ndo_start_xmit = net_send_packet,
237 .ndo_change_mtu = eth_change_mtu,
238 .ndo_set_mac_address = eth_mac_addr,
239 .ndo_validate_addr = eth_validate_addr,
240};
245 241
246/*******************************************/
247/* init function called by register device */
248/*******************************************/
249static int
250net_init(struct net_device *dev)
251{
252 /* setup the function table */
253 dev->open = net_open;
254 dev->stop = net_close;
255 dev->hard_start_xmit = net_send_packet;
256 dev->get_stats = net_get_stats;
257
258 /* Fill in the fields of the device structure with ethernet values. */
259 ether_setup(dev);
260
261 return (0); /* success */
262} /* net_init */
263 242
264/*****************************************************************************/ 243/*****************************************************************************/
265/* hysdn_net_create creates a new net device for the given card. If a device */ 244/* hysdn_net_create creates a new net device for the given card. If a device */
@@ -271,28 +250,34 @@ hysdn_net_create(hysdn_card * card)
271{ 250{
272 struct net_device *dev; 251 struct net_device *dev;
273 int i; 252 int i;
253 struct net_local *lp;
254
274 if(!card) { 255 if(!card) {
275 printk(KERN_WARNING "No card-pt in hysdn_net_create!\n"); 256 printk(KERN_WARNING "No card-pt in hysdn_net_create!\n");
276 return (-ENOMEM); 257 return (-ENOMEM);
277 } 258 }
278 hysdn_net_release(card); /* release an existing net device */ 259 hysdn_net_release(card); /* release an existing net device */
279 if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) { 260
261 dev = alloc_etherdev(sizeof(struct net_local));
262 if (!dev) {
280 printk(KERN_WARNING "HYSDN: unable to allocate mem\n"); 263 printk(KERN_WARNING "HYSDN: unable to allocate mem\n");
281 return (-ENOMEM); 264 return (-ENOMEM);
282 } 265 }
283 266
267 lp = netdev_priv(dev);
268 lp->dev = dev;
269
270 dev->netdev_ops = &hysdn_netdev_ops;
284 spin_lock_init(&((struct net_local *) dev)->lock); 271 spin_lock_init(&((struct net_local *) dev)->lock);
285 272
286 /* initialise necessary or informing fields */ 273 /* initialise necessary or informing fields */
287 dev->base_addr = card->iobase; /* IO address */ 274 dev->base_addr = card->iobase; /* IO address */
288 dev->irq = card->irq; /* irq */ 275 dev->irq = card->irq; /* irq */
289 dev->init = net_init; /* the init function of the device */ 276
290 if(dev->name) { 277 dev->netdev_ops = &hysdn_netdev_ops;
291 strcpy(dev->name, ((struct net_local *) dev)->dev_name);
292 }
293 if ((i = register_netdev(dev))) { 278 if ((i = register_netdev(dev))) {
294 printk(KERN_WARNING "HYSDN: unable to create network device\n"); 279 printk(KERN_WARNING "HYSDN: unable to create network device\n");
295 kfree(dev); 280 free_netdev(dev);
296 return (i); 281 return (i);
297 } 282 }
298 dev->ml_priv = card; /* remember pointer to own data structure */ 283 dev->ml_priv = card; /* remember pointer to own data structure */
@@ -316,7 +301,7 @@ hysdn_net_release(hysdn_card * card)
316 return (0); /* non existing */ 301 return (0); /* non existing */
317 302
318 card->netif = NULL; /* clear out pointer */ 303 card->netif = NULL; /* clear out pointer */
319 dev->stop(dev); /* close the device */ 304 net_close(dev);
320 305
321 flush_tx_buffers((struct net_local *) dev); /* empty buffers */ 306 flush_tx_buffers((struct net_local *) dev); /* empty buffers */
322 307
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 023ea11d2f9e..7c5f97033b9f 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -1485,6 +1485,24 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1485 return (rc); 1485 return (rc);
1486} 1486}
1487 1487
1488
1489static int isdn_net_ioctl(struct net_device *dev,
1490 struct ifreq *ifr, int cmd)
1491{
1492 isdn_net_local *lp = (isdn_net_local *) netdev_priv(dev);
1493
1494 switch (lp->p_encap) {
1495#ifdef CONFIG_ISDN_PPP
1496 case ISDN_NET_ENCAP_SYNCPPP:
1497 return isdn_ppp_dev_ioctl(dev, ifr, cmd);
1498#endif
1499 case ISDN_NET_ENCAP_CISCOHDLCK:
1500 return isdn_ciscohdlck_dev_ioctl(dev, ifr, cmd);
1501 default:
1502 return -EINVAL;
1503 }
1504}
1505
1488/* called via cisco_timer.function */ 1506/* called via cisco_timer.function */
1489static void 1507static void
1490isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) 1508isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
@@ -1998,23 +2016,6 @@ isdn_net_init(struct net_device *ndev)
1998 ushort max_hlhdr_len = 0; 2016 ushort max_hlhdr_len = 0;
1999 int drvidx; 2017 int drvidx;
2000 2018
2001 ether_setup(ndev);
2002 ndev->header_ops = NULL;
2003
2004 /* Setup the generic properties */
2005 ndev->mtu = 1500;
2006 ndev->flags = IFF_NOARP|IFF_POINTOPOINT;
2007 ndev->type = ARPHRD_ETHER;
2008 ndev->addr_len = ETH_ALEN;
2009 ndev->validate_addr = NULL;
2010
2011 /* for clients with MPPP maybe higher values better */
2012 ndev->tx_queue_len = 30;
2013
2014 /* The ISDN-specific entries in the device structure. */
2015 ndev->open = &isdn_net_open;
2016 ndev->hard_start_xmit = &isdn_net_start_xmit;
2017
2018 /* 2019 /*
2019 * up till binding we ask the protocol layer to reserve as much 2020 * up till binding we ask the protocol layer to reserve as much
2020 * as we might need for HL layer 2021 * as we might need for HL layer
@@ -2026,9 +2027,6 @@ isdn_net_init(struct net_device *ndev)
2026 max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen; 2027 max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen;
2027 2028
2028 ndev->hard_header_len = ETH_HLEN + max_hlhdr_len; 2029 ndev->hard_header_len = ETH_HLEN + max_hlhdr_len;
2029 ndev->stop = &isdn_net_close;
2030 ndev->get_stats = &isdn_net_get_stats;
2031 ndev->do_ioctl = NULL;
2032 return 0; 2030 return 0;
2033} 2031}
2034 2032
@@ -2508,6 +2506,19 @@ isdn_net_force_dial(char *name)
2508 return (isdn_net_force_dial_lp(p->local)); 2506 return (isdn_net_force_dial_lp(p->local));
2509} 2507}
2510 2508
2509/* The ISDN-specific entries in the device structure. */
2510static const struct net_device_ops isdn_netdev_ops = {
2511 .ndo_init = isdn_net_init,
2512 .ndo_open = isdn_net_open,
2513 .ndo_stop = isdn_net_close,
2514 .ndo_do_ioctl = isdn_net_ioctl,
2515
2516 .ndo_validate_addr = NULL,
2517 .ndo_start_xmit = isdn_net_start_xmit,
2518 .ndo_get_stats = isdn_net_get_stats,
2519 .ndo_tx_timeout = isdn_net_tx_timeout,
2520};
2521
2511/* 2522/*
2512 * Helper for alloc_netdev() 2523 * Helper for alloc_netdev()
2513 */ 2524 */
@@ -2515,7 +2526,20 @@ static void _isdn_setup(struct net_device *dev)
2515{ 2526{
2516 isdn_net_local *lp = netdev_priv(dev); 2527 isdn_net_local *lp = netdev_priv(dev);
2517 2528
2529 ether_setup(dev);
2530
2518 dev->flags = IFF_NOARP | IFF_POINTOPOINT; 2531 dev->flags = IFF_NOARP | IFF_POINTOPOINT;
2532 /* Setup the generic properties */
2533 dev->mtu = 1500;
2534 dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2535 dev->type = ARPHRD_ETHER;
2536 dev->addr_len = ETH_ALEN;
2537 dev->header_ops = NULL;
2538 dev->netdev_ops = &isdn_netdev_ops;
2539
2540 /* for clients with MPPP maybe higher values better */
2541 dev->tx_queue_len = 30;
2542
2519 lp->p_encap = ISDN_NET_ENCAP_RAWIP; 2543 lp->p_encap = ISDN_NET_ENCAP_RAWIP;
2520 lp->magic = ISDN_NET_MAGIC; 2544 lp->magic = ISDN_NET_MAGIC;
2521 lp->last = lp; 2545 lp->last = lp;
@@ -2570,7 +2594,7 @@ isdn_net_new(char *name, struct net_device *master)
2570 return NULL; 2594 return NULL;
2571 } 2595 }
2572 netdev->local = netdev_priv(netdev->dev); 2596 netdev->local = netdev_priv(netdev->dev);
2573 netdev->dev->init = isdn_net_init; 2597
2574 if (master) { 2598 if (master) {
2575 /* Device shall be a slave */ 2599 /* Device shall be a slave */
2576 struct net_device *p = MASTER_TO_SLAVE(master); 2600 struct net_device *p = MASTER_TO_SLAVE(master);
@@ -2588,7 +2612,6 @@ isdn_net_new(char *name, struct net_device *master)
2588 /* 2612 /*
2589 * Watchdog timer (currently) for master only. 2613 * Watchdog timer (currently) for master only.
2590 */ 2614 */
2591 netdev->dev->tx_timeout = isdn_net_tx_timeout;
2592 netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT; 2615 netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT;
2593 if (register_netdev(netdev->dev) != 0) { 2616 if (register_netdev(netdev->dev) != 0) {
2594 printk(KERN_WARNING "isdn_net: Could not register net-device\n"); 2617 printk(KERN_WARNING "isdn_net: Could not register net-device\n");
@@ -2704,7 +2727,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2704#else 2727#else
2705 p->dev->type = ARPHRD_PPP; /* change ARP type */ 2728 p->dev->type = ARPHRD_PPP; /* change ARP type */
2706 p->dev->addr_len = 0; 2729 p->dev->addr_len = 0;
2707 p->dev->do_ioctl = isdn_ppp_dev_ioctl;
2708#endif 2730#endif
2709 break; 2731 break;
2710 case ISDN_NET_ENCAP_X25IFACE: 2732 case ISDN_NET_ENCAP_X25IFACE:
@@ -2718,7 +2740,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2718#endif 2740#endif
2719 break; 2741 break;
2720 case ISDN_NET_ENCAP_CISCOHDLCK: 2742 case ISDN_NET_ENCAP_CISCOHDLCK:
2721 p->dev->do_ioctl = isdn_ciscohdlck_dev_ioctl;
2722 break; 2743 break;
2723 default: 2744 default:
2724 if( cfg->p_encap >= 0 && 2745 if( cfg->p_encap >= 0 &&