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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * eth1394.h -- Ethernet driver for Linux IEEE-1394 Subsystem
  3.  *
  4.  * Copyright (C) 2000 Bonin Franck <boninf@free.fr>
  5.  *           (C) 2001 Ben Collins <bcollins@debian.org>
  6.  *
  7.  * Mainly based on work by Emanuel Pirker and Andreas E. Bombe
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software Foundation,
  21.  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  */
  23. #ifndef __ETH1394_H
  24. #define __ETH1394_H
  25. /* Register for incoming packets. This is 8192 bytes, which supports up to
  26.  * 1600mbs. We'll need to change this if that ever becomes "small" :)  */
  27. #define ETHER1394_REGION_ADDR_LEN 8192
  28. #define ETHER1394_REGION_ADDR 0xfffff0200000ULL
  29. #define ETHER1394_REGION_ADDR_END (ETHER1394_REGION_ADDR + ETHER1394_REGION_ADDR_LEN)
  30. /* Node set == 64 */
  31. #define NODE_SET (ALL_NODES + 1)
  32. /* Private structure for our ethernet driver */
  33. struct eth1394_priv {
  34. struct net_device_stats stats; /* Device stats  */
  35. struct hpsb_host *host; /* The card for this dev  */
  36. unsigned char max_rec[NODE_SET];/* Max payload per node  */
  37. unsigned char sspd[NODE_SET]; /* Max speed per node  */
  38. u16 fifo_hi[ALL_NODES]; /* 16bit hi fifo offset per node */
  39. u32 fifo_lo[ALL_NODES]; /* 32bit lo fifo offset per node */
  40. u64 eui[ALL_NODES]; /* EUI-64 per node  */
  41. spinlock_t lock; /* Private lock  */
  42. };
  43. struct host_info {
  44. struct list_head list;
  45. struct hpsb_host *host;
  46. struct net_device *dev;
  47. };
  48. /* This is our task struct. It's used for the packet complete callback.  */
  49. struct packet_task {
  50. struct sk_buff *skb; /* Socket buffer we are sending */
  51. nodeid_t dest_node; /* Destination of the packet */
  52. u64 addr; /* Address */
  53. struct tq_struct tq; /* The task */
  54. };
  55. /* IP1394 headers */
  56. #include <asm/byteorder.h>
  57. /* Unfragmented */
  58. #if defined __BIG_ENDIAN_BITFIELD
  59. struct eth1394_uf_hdr {
  60. u8 lf:2;
  61. u16 res:14;
  62. u16 ether_type; /* Ethernet packet type */
  63. } __attribute__((packed));
  64. #elif defined __LITTLE_ENDIAN_BITFIELD
  65. struct eth1394_uf_hdr {
  66. u16 res:14;
  67. u8 lf:2;
  68. u16 ether_type;
  69. } __attribute__((packed));
  70. #else
  71. #error Unknown bit field type
  72. #endif
  73. /* First fragment */
  74. #if defined __BIG_ENDIAN_BITFIELD
  75. struct eth1394_ff_hdr {
  76. u8 lf:2;
  77. u8 res1:2;
  78. u16 dg_size:12; /* Datagram size */
  79. u16 ether_type; /* Ethernet packet type */
  80. u16 dgl; /* Datagram label */
  81. u16 res2;
  82. } __attribute__((packed));
  83. #elif defined __LITTLE_ENDIAN_BITFIELD
  84. struct eth1394_ff_hdr {
  85. u16 dg_size:12;
  86. u8 res1:2;
  87. u8 lf:2;
  88. u16 ether_type;
  89. u16 dgl;
  90. u16 res2;
  91. } __attribute__((packed));
  92. #else
  93. #error Unknown bit field type
  94. #endif
  95. /* XXX: Subsequent fragments, including last */
  96. #if defined __BIG_ENDIAN_BITFIELD
  97. struct eth1394_sf_hdr {
  98. u8 lf:2;
  99. u8 res1:2;
  100. u16 dg_size:12; /* Datagram size */
  101. u8 res2:6;
  102. u16 fg_off:10; /* Fragment offset */
  103. u16 dgl; /* Datagram label */
  104. u16 res3;
  105. } __attribute__((packed));
  106. #elif defined __LITTLE_ENDIAN_BITFIELD
  107. struct eth1394_sf_hdr {
  108. u16 dg_size:12;
  109. u8 res1:2;
  110. u8 lf:2;
  111. u16 fg_off:10;
  112. u8 res2:6;
  113. u16 dgl;
  114. u16 res3;
  115. } __attribute__((packed));
  116. #else
  117. #error Unknown bit field type
  118. #endif
  119. #if defined __BIG_ENDIAN_BITFIELD
  120. struct eth1394_common_hdr {
  121. u8 lf:2;
  122. u16 pad1:14;
  123. } __attribute__((packed));
  124. #elif defined __LITTLE_ENDIAN_BITFIELD
  125. struct eth1394_common_hdr {
  126. u16 pad1:14;
  127. u8 lf:2;
  128. } __attribute__((packed));
  129. #else
  130. #error Unknown bit field type
  131. #endif
  132. struct eth1394_hdr_words {
  133. u16 word1;
  134. u16 word2;
  135. u16 word3;
  136. u16 word4;
  137. };
  138. union eth1394_hdr {
  139. struct eth1394_common_hdr common;
  140. struct eth1394_uf_hdr uf;
  141. struct eth1394_ff_hdr ff;
  142. struct eth1394_sf_hdr sf;
  143. struct eth1394_hdr_words words;
  144. };
  145. /* End of IP1394 headers */
  146. /* Fragment types */
  147. #define ETH1394_HDR_LF_UF 0 /* unfragmented */
  148. #define ETH1394_HDR_LF_FF 1 /* first fragment */
  149. #define ETH1394_HDR_LF_LF 2 /* last fragment */
  150. #define ETH1394_HDR_LF_IF 3 /* interior fragment */
  151. #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
  152. /* Our arp packet (ARPHRD_IEEE1394) */
  153. struct eth1394_arp {
  154. u16 hw_type; /* 0x0018 */
  155. u16 proto_type; /* 0x0806 */
  156. u8 hw_addr_len; /* 16  */
  157. u8 ip_addr_len; /* 4 */
  158. u16 opcode; /* ARP Opcode */
  159. /* Above is exactly the same format as struct arphdr */
  160. u64 s_uniq_id; /* Sender's 64bit EUI */
  161. u8 max_rec; /* Sender's max packet size */
  162. u8 sspd; /* Sender's max speed */
  163. u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
  164. u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
  165. u32 sip; /* Sender's IP Address */
  166. u32 tip; /* IP Address of requested hw addr */
  167. };
  168. /* Network timeout */
  169. #define ETHER1394_TIMEOUT 100000
  170. #endif /* __ETH1394_H */