CDCEther.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. // Portions of this file taken from
  2. // Petko Manolov - Petkan (petkan@dce.bg)
  3. // from his driver pegasus.h
  4. /*
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18.  */
  19. /* From CDC Spec Table 24 */
  20. #define CS_INTERFACE 0x24
  21. #define CDC_ETHER_MAX_MTU 1536
  22. /* These definitions are used with the ether_dev_t flags element */
  23. #define CDC_ETHER_PRESENT 0x00000001
  24. #define CDC_ETHER_RUNNING 0x00000002
  25. #define CDC_ETHER_TX_BUSY 0x00000004
  26. #define CDC_ETHER_RX_BUSY 0x00000008
  27. #define CDC_ETHER_UNPLUG 0x00000040
  28. #define CDC_ETHER_TX_TIMEOUT (HZ*10)
  29. #define TX_UNDERRUN 0x80
  30. #define EXCESSIVE_COL 0x40
  31. #define LATE_COL 0x20
  32. #define NO_CARRIER 0x10
  33. #define LOSS_CARRIER 0x08
  34. #define JABBER_TIMEOUT 0x04
  35. #define CDC_ETHER_REQT_READ 0xc0
  36. #define CDC_ETHER_REQT_WRITE 0x40
  37. #define CDC_ETHER_REQ_GET_REGS 0xf0
  38. #define CDC_ETHER_REQ_SET_REGS 0xf1
  39. #define CDC_ETHER_REQ_SET_REG PIPERIDER_REQ_SET_REGS
  40. typedef struct _ether_dev_t {
  41. struct usb_device *usb;
  42. struct net_device *net;
  43. struct net_device_stats stats;
  44. unsigned flags;
  45. unsigned properties;
  46. int configuration_num;
  47. int bConfigurationValue;
  48. int comm_interface;
  49. int comm_bInterfaceNumber;
  50. int comm_interface_altset_num;
  51. int comm_bAlternateSetting;
  52. int comm_ep_in;
  53. int data_interface;
  54. int data_bInterfaceNumber;
  55. int data_interface_altset_num_with_traffic;
  56. int data_bAlternateSetting_with_traffic;
  57. int data_interface_altset_num_without_traffic;
  58. int data_bAlternateSetting_without_traffic;
  59. int data_ep_in;
  60. int data_ep_out;
  61. int data_ep_out_size;
  62. __u16 bcdCDC;
  63. __u8 iMACAddress;
  64. __u32 bmEthernetStatistics;
  65. __u16 wMaxSegmentSize;
  66. __u16 wNumberMCFilters;
  67. __u8 bNumberPowerFilters;
  68. __u16 mode_flags;
  69. int intr_interval;
  70. struct usb_ctrlrequest ctrl_dr;
  71. struct urb rx_urb, tx_urb, intr_urb, ctrl_urb;
  72. unsigned char rx_buff[CDC_ETHER_MAX_MTU] __attribute__((aligned(L1_CACHE_BYTES)));
  73. unsigned char tx_buff[CDC_ETHER_MAX_MTU] __attribute__((aligned(L1_CACHE_BYTES)));
  74. unsigned char intr_buff[8] __attribute__((aligned(L1_CACHE_BYTES))) ;
  75. } ether_dev_t;
  76. /* These definitions used in the Ethernet Packet Filtering requests */
  77. /* See CDC Spec Table 62 */
  78. #define MODE_FLAG_PROMISCUOUS   (1<<0)
  79. #define MODE_FLAG_ALL_MULTICAST (1<<1)
  80. #define MODE_FLAG_DIRECTED      (1<<2)
  81. #define MODE_FLAG_BROADCAST     (1<<3)
  82. #define MODE_FLAG_MULTICAST     (1<<4)
  83. /* CDC Spec class requests - CDC Spec Table 46 */
  84. #define SET_ETHERNET_MULTICAST_FILTER    0x40
  85. #define SET_ETHERNET_PACKET_FILTER       0x43
  86. /* These definitions are used with the ether_dev_t properties field */
  87. #define HAVE_NOTIFICATION_ELEMENT 0x0001
  88. #define PERFECT_FILTERING 0x0002
  89. #define NO_SET_MULTICAST 0x0004
  90. /* These definitions are used in the requirements parser */
  91. #define REQ_HDR_FUNC_DESCR 0x0001
  92. #define REQ_UNION_FUNC_DESCR 0x0002
  93. #define REQ_ETH_FUNC_DESCR 0x0004
  94. #define REQUIREMENTS_TOTAL REQ_ETH_FUNC_DESCR | REQ_UNION_FUNC_DESCR | REQ_HDR_FUNC_DESCR
  95. /* Some useful lengths */
  96. #define HEADER_FUNC_DESC_LEN 0x5
  97. #define UNION_FUNC_DESC_LEN 0x5
  98. #define ETHERNET_FUNC_DESC_LEN 0xD /* 13 for all you decimal weenies */