eth1394.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. #include <linux/netdevice.h>
  26. #include <linux/skbuff.h>
  27. #include <asm/byteorder.h>
  28. #include "ieee1394.h"
  29. #include "ieee1394_types.h"
  30. /* Register for incoming packets. This is 4096 bytes, which supports up to
  31. * S3200 (per Table 16-3 of IEEE 1394b-2002). */
  32. #define ETHER1394_REGION_ADDR_LEN 4096
  33. /* GASP identifier numbers for IPv4 over IEEE 1394 */
  34. #define ETHER1394_GASP_SPECIFIER_ID 0x00005E
  35. #define ETHER1394_GASP_SPECIFIER_ID_HI ((0x00005E >> 8) & 0xffff)
  36. #define ETHER1394_GASP_SPECIFIER_ID_LO (0x00005E & 0xff)
  37. #define ETHER1394_GASP_VERSION 1
  38. #define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* for GASP header */
  39. #define ETHER1394_GASP_BUFFERS 16
  40. #define NODE_SET (ALL_NODES + 1) /* Node set == 64 */
  41. enum eth1394_bc_states { ETHER1394_BC_ERROR,
  42. ETHER1394_BC_RUNNING,
  43. ETHER1394_BC_STOPPED };
  44. /* Private structure for our ethernet driver */
  45. struct eth1394_priv {
  46. struct net_device_stats stats; /* Device stats */
  47. struct hpsb_host *host; /* The card for this dev */
  48. u16 bc_maxpayload; /* Max broadcast payload */
  49. u8 bc_sspd; /* Max broadcast speed */
  50. u64 local_fifo; /* Local FIFO Address */
  51. spinlock_t lock; /* Private lock */
  52. int broadcast_channel; /* Async stream Broadcast Channel */
  53. enum eth1394_bc_states bc_state; /* broadcast channel state */
  54. struct hpsb_iso *iso; /* Async stream recv handle */
  55. int bc_dgl; /* Outgoing broadcast datagram label */
  56. struct list_head ip_node_list; /* List of IP capable nodes */
  57. struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
  58. struct work_struct wake; /* Wake up after xmit failure */
  59. struct net_device *wake_dev; /* Stupid backlink for .wake */
  60. nodeid_t wake_node; /* Destination of failed xmit */
  61. };
  62. /* Define a fake hardware header format for the networking core. Note that
  63. * header size cannot exceed 16 bytes as that is the size of the header cache.
  64. * Also, we do not need the source address in the header so we omit it and
  65. * keep the header to under 16 bytes */
  66. #define ETH1394_ALEN (8)
  67. #define ETH1394_HLEN (10)
  68. struct eth1394hdr {
  69. unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
  70. unsigned short h_proto; /* packet type ID field */
  71. } __attribute__((packed));
  72. static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
  73. {
  74. return (struct eth1394hdr *)skb_mac_header(skb);
  75. }
  76. typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
  77. /* IP1394 headers */
  78. /* Unfragmented */
  79. #if defined __BIG_ENDIAN_BITFIELD
  80. struct eth1394_uf_hdr {
  81. u16 lf:2;
  82. u16 res:14;
  83. u16 ether_type; /* Ethernet packet type */
  84. } __attribute__((packed));
  85. #elif defined __LITTLE_ENDIAN_BITFIELD
  86. struct eth1394_uf_hdr {
  87. u16 res:14;
  88. u16 lf:2;
  89. u16 ether_type;
  90. } __attribute__((packed));
  91. #else
  92. #error Unknown bit field type
  93. #endif
  94. /* First fragment */
  95. #if defined __BIG_ENDIAN_BITFIELD
  96. struct eth1394_ff_hdr {
  97. u16 lf:2;
  98. u16 res1:2;
  99. u16 dg_size:12; /* Datagram size */
  100. u16 ether_type; /* Ethernet packet type */
  101. u16 dgl; /* Datagram label */
  102. u16 res2;
  103. } __attribute__((packed));
  104. #elif defined __LITTLE_ENDIAN_BITFIELD
  105. struct eth1394_ff_hdr {
  106. u16 dg_size:12;
  107. u16 res1:2;
  108. u16 lf:2;
  109. u16 ether_type;
  110. u16 dgl;
  111. u16 res2;
  112. } __attribute__((packed));
  113. #else
  114. #error Unknown bit field type
  115. #endif
  116. /* XXX: Subsequent fragments, including last */
  117. #if defined __BIG_ENDIAN_BITFIELD
  118. struct eth1394_sf_hdr {
  119. u16 lf:2;
  120. u16 res1:2;
  121. u16 dg_size:12; /* Datagram size */
  122. u16 res2:4;
  123. u16 fg_off:12; /* Fragment offset */
  124. u16 dgl; /* Datagram label */
  125. u16 res3;
  126. } __attribute__((packed));
  127. #elif defined __LITTLE_ENDIAN_BITFIELD
  128. struct eth1394_sf_hdr {
  129. u16 dg_size:12;
  130. u16 res1:2;
  131. u16 lf:2;
  132. u16 fg_off:12;
  133. u16 res2:4;
  134. u16 dgl;
  135. u16 res3;
  136. } __attribute__((packed));
  137. #else
  138. #error Unknown bit field type
  139. #endif
  140. #if defined __BIG_ENDIAN_BITFIELD
  141. struct eth1394_common_hdr {
  142. u16 lf:2;
  143. u16 pad1:14;
  144. } __attribute__((packed));
  145. #elif defined __LITTLE_ENDIAN_BITFIELD
  146. struct eth1394_common_hdr {
  147. u16 pad1:14;
  148. u16 lf:2;
  149. } __attribute__((packed));
  150. #else
  151. #error Unknown bit field type
  152. #endif
  153. struct eth1394_hdr_words {
  154. u16 word1;
  155. u16 word2;
  156. u16 word3;
  157. u16 word4;
  158. };
  159. union eth1394_hdr {
  160. struct eth1394_common_hdr common;
  161. struct eth1394_uf_hdr uf;
  162. struct eth1394_ff_hdr ff;
  163. struct eth1394_sf_hdr sf;
  164. struct eth1394_hdr_words words;
  165. };
  166. /* End of IP1394 headers */
  167. /* Fragment types */
  168. #define ETH1394_HDR_LF_UF 0 /* unfragmented */
  169. #define ETH1394_HDR_LF_FF 1 /* first fragment */
  170. #define ETH1394_HDR_LF_LF 2 /* last fragment */
  171. #define ETH1394_HDR_LF_IF 3 /* interior fragment */
  172. #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
  173. /* Our arp packet (ARPHRD_IEEE1394) */
  174. struct eth1394_arp {
  175. u16 hw_type; /* 0x0018 */
  176. u16 proto_type; /* 0x0806 */
  177. u8 hw_addr_len; /* 16 */
  178. u8 ip_addr_len; /* 4 */
  179. u16 opcode; /* ARP Opcode */
  180. /* Above is exactly the same format as struct arphdr */
  181. u64 s_uniq_id; /* Sender's 64bit EUI */
  182. u8 max_rec; /* Sender's max packet size */
  183. u8 sspd; /* Sender's max speed */
  184. u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
  185. u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
  186. u32 sip; /* Sender's IP Address */
  187. u32 tip; /* IP Address of requested hw addr */
  188. };
  189. /* Network timeout */
  190. #define ETHER1394_TIMEOUT 100000
  191. /* This is our task struct. It's used for the packet complete callback. */
  192. struct packet_task {
  193. struct sk_buff *skb;
  194. int outstanding_pkts;
  195. eth1394_tx_type tx_type;
  196. int max_payload;
  197. struct hpsb_packet *packet;
  198. struct eth1394_priv *priv;
  199. union eth1394_hdr hdr;
  200. u64 addr;
  201. u16 dest_node;
  202. };
  203. #endif /* __ETH1394_H */