Version:  2.0.40 2.2.26 2.4.37 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7

Linux/drivers/net/usb/pegasus.c

  1 /*
  2  *  Copyright (c) 1999-2013 Petko Manolov (petkan@nucleusys.com)
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation.
  7  *
  8  *      ChangeLog:
  9  *              ....    Most of the time spent on reading sources & docs.
 10  *              v0.2.x  First official release for the Linux kernel.
 11  *              v0.3.0  Beutified and structured, some bugs fixed.
 12  *              v0.3.x  URBifying bulk requests and bugfixing. First relatively
 13  *                      stable release. Still can touch device's registers only
 14  *                      from top-halves.
 15  *              v0.4.0  Control messages remained unurbified are now URBs.
 16  *                      Now we can touch the HW at any time.
 17  *              v0.4.9  Control urbs again use process context to wait. Argh...
 18  *                      Some long standing bugs (enable_net_traffic) fixed.
 19  *                      Also nasty trick about resubmiting control urb from
 20  *                      interrupt context used. Please let me know how it
 21  *                      behaves. Pegasus II support added since this version.
 22  *                      TODO: suppressing HCD warnings spewage on disconnect.
 23  *              v0.4.13 Ethernet address is now set at probe(), not at open()
 24  *                      time as this seems to break dhcpd.
 25  *              v0.5.0  branch to 2.5.x kernels
 26  *              v0.5.1  ethtool support added
 27  *              v0.5.5  rx socket buffers are in a pool and the their allocation
 28  *                      is out of the interrupt routine.
 29  *              ...
 30  *              v0.9.3  simplified [get|set]_register(s), async update registers
 31  *                      logic revisited, receive skb_pool removed.
 32  */
 33 
 34 #include <linux/sched.h>
 35 #include <linux/slab.h>
 36 #include <linux/init.h>
 37 #include <linux/delay.h>
 38 #include <linux/netdevice.h>
 39 #include <linux/etherdevice.h>
 40 #include <linux/ethtool.h>
 41 #include <linux/mii.h>
 42 #include <linux/usb.h>
 43 #include <linux/module.h>
 44 #include <asm/byteorder.h>
 45 #include <asm/uaccess.h>
 46 #include "pegasus.h"
 47 
 48 /*
 49  * Version Information
 50  */
 51 #define DRIVER_VERSION "v0.9.3 (2013/04/25)"
 52 #define DRIVER_AUTHOR "Petko Manolov <petkan@nucleusys.com>"
 53 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
 54 
 55 static const char driver_name[] = "pegasus";
 56 
 57 #undef  PEGASUS_WRITE_EEPROM
 58 #define BMSR_MEDIA      (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \
 59                         BMSR_100FULL | BMSR_ANEGCAPABLE)
 60 
 61 static bool loopback;
 62 static bool mii_mode;
 63 static char *devid;
 64 
 65 static struct usb_eth_dev usb_dev_id[] = {
 66 #define PEGASUS_DEV(pn, vid, pid, flags)        \
 67         {.name = pn, .vendor = vid, .device = pid, .private = flags},
 68 #define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \
 69         PEGASUS_DEV(pn, vid, pid, flags)
 70 #include "pegasus.h"
 71 #undef  PEGASUS_DEV
 72 #undef  PEGASUS_DEV_CLASS
 73         {NULL, 0, 0, 0},
 74         {NULL, 0, 0, 0}
 75 };
 76 
 77 static struct usb_device_id pegasus_ids[] = {
 78 #define PEGASUS_DEV(pn, vid, pid, flags) \
 79         {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
 80 /*
 81  * The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product
 82  * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to
 83  * ignore adaptors belonging to the "Wireless" class 0xE0. For this one
 84  * case anyway, seeing as the pegasus is for "Wired" adaptors.
 85  */
 86 #define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \
 87         {.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \
 88         .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass},
 89 #include "pegasus.h"
 90 #undef  PEGASUS_DEV
 91 #undef  PEGASUS_DEV_CLASS
 92         {},
 93         {}
 94 };
 95 
 96 MODULE_AUTHOR(DRIVER_AUTHOR);
 97 MODULE_DESCRIPTION(DRIVER_DESC);
 98 MODULE_LICENSE("GPL");
 99 module_param(loopback, bool, 0);
100 module_param(