eth1394.h 6.4 KB

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