eth1394.h 6.6 KB

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