eth1394.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. };
  59. /* Define a fake hardware header format for the networking core. Note that
  60. * header size cannot exceed 16 bytes as that is the size of the header cache.
  61. * Also, we do not need the source address in the header so we omit it and
  62. * keep the header to under 16 bytes */
  63. #define ETH1394_ALEN (8)
  64. #define ETH1394_HLEN (10)
  65. struct eth1394hdr {
  66. unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
  67. unsigned short h_proto; /* packet type ID field */
  68. } __attribute__((packed));
  69. static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
  70. {
  71. return (struct eth1394hdr *)skb_mac_header(skb);
  72. }
  73. typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
  74. /* IP1394 headers */
  75. /* Unfragmented */
  76. #if defined __BIG_ENDIAN_BITFIELD
  77. struct eth1394_uf_hdr {
  78. u16 lf:2;
  79. u16 res:14;
  80. u16 ether_type; /* Ethernet packet type */
  81. } __attribute__((packed));
  82. #elif defined __LITTLE_ENDIAN_BITFIELD
  83. struct eth1394_uf_hdr {
  84. u16 res:14;
  85. u16 lf:2;
  86. u16 ether_type;
  87. } __attribute__((packed));
  88. #else
  89. #error Unknown bit field type
  90. #endif
  91. /* First fragment */
  92. #if defined __BIG_ENDIAN_BITFIELD
  93. struct eth1394_ff_hdr {
  94. u16 lf:2;
  95. u16 res1:2;
  96. u16 dg_size:12; /* Datagram size */
  97. u16 ether_type; /* Ethernet packet type */
  98. u16 dgl; /* Datagram label */
  99. u16 res2;
  100. } __attribute__((packed));
  101. #elif defined __LITTLE_ENDIAN_BITFIELD
  102. struct eth1394_ff_hdr {
  103. u16 dg_size:12;
  104. u16 res1:2;
  105. u16 lf:2;
  106. u16 ether_type;
  107. u16 dgl;
  108. u16 res2;
  109. } __attribute__((packed));
  110. #else
  111. #error Unknown bit field type
  112. #endif
  113. /* XXX: Subsequent fragments, including last */
  114. #if defined __BIG_ENDIAN_BITFIELD
  115. struct eth1394_sf_hdr {
  116. u16 lf:2;
  117. u16 res1:2;
  118. u16 dg_size:12; /* Datagram size */
  119. u16 res2:4;
  120. u16 fg_off:12; /* Fragment offset */
  121. u16 dgl; /* Datagram label */
  122. u16 res3;
  123. } __attribute__((packed));
  124. #elif defined __LITTLE_ENDIAN_BITFIELD
  125. struct eth1394_sf_hdr {
  126. u16 dg_size:12;
  127. u16 res1:2;
  128. u16 lf:2;
  129. u16 fg_off:12;
  130. u16 res2:4;
  131. u16 dgl;
  132. u16 res3;
  133. } __attribute__((packed));
  134. #else
  135. #error Unknown bit field type
  136. #endif
  137. #if defined __BIG_ENDIAN_BITFIELD
  138. struct eth1394_common_hdr {
  139. u16 lf:2;
  140. u16 pad1:14;
  141. } __attribute__((packed));
  142. #elif defined __LITTLE_ENDIAN_BITFIELD
  143. struct eth1394_common_hdr {
  144. u16 pad1:14;
  145. u16 lf:2;
  146. } __attribute__((packed));
  147. #else
  148. #error Unknown bit field type
  149. #endif
  150. struct eth1394_hdr_words {
  151. u16 word1;
  152. u16 word2;
  153. u16 word3;
  154. u16 word4;
  155. };
  156. union eth1394_hdr {
  157. struct eth1394_common_hdr common;
  158. struct eth1394_uf_hdr uf;
  159. struct eth1394_ff_hdr ff;
  160. struct eth1394_sf_hdr sf;
  161. struct eth1394_hdr_words words;
  162. };
  163. /* End of IP1394 headers */
  164. /* Fragment types */
  165. #define ETH1394_HDR_LF_UF 0 /* unfragmented */
  166. #define ETH1394_HDR_LF_FF 1 /* first fragment */
  167. #define ETH1394_HDR_LF_LF 2 /* last fragment */
  168. #define ETH1394_HDR_LF_IF 3 /* interior fragment */
  169. #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
  170. /* Our arp packet (ARPHRD_IEEE1394) */
  171. struct eth1394_arp {
  172. u16 hw_type; /* 0x0018 */
  173. u16 proto_type; /* 0x0806 */
  174. u8 hw_addr_len; /* 16 */
  175. u8 ip_addr_len; /* 4 */
  176. u16 opcode; /* ARP Opcode */
  177. /* Above is exactly the same format as struct arphdr */
  178. u64 s_uniq_id; /* Sender's 64bit EUI */
  179. u8 max_rec; /* Sender's max packet size */
  180. u8 sspd; /* Sender's max speed */
  181. u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
  182. u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
  183. u32 sip; /* Sender's IP Address */
  184. u32 tip; /* IP Address of requested hw addr */
  185. };
  186. /* Network timeout */
  187. #define ETHER1394_TIMEOUT 100000
  188. /* This is our task struct. It's used for the packet complete callback. */
  189. struct packet_task {
  190. struct sk_buff *skb;
  191. int outstanding_pkts;
  192. eth1394_tx_type tx_type;
  193. int max_payload;
  194. struct hpsb_packet *packet;
  195. struct eth1394_priv *priv;
  196. union eth1394_hdr hdr;
  197. u64 addr;
  198. u16 dest_node;
  199. };
  200. #endif /* __ETH1394_H */