eth1394.h 6.6 KB

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