firewire.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2004 Doug Rabson
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. */
  28. #ifndef _NET_FIREWIRE_H_
  29. #define _NET_FIREWIRE_H_
  30. #define FW_ENCAP_UNFRAG 0
  31. #define FW_ENCAP_FIRST 1
  32. #define FW_ENCAP_LAST 2
  33. #define FW_ENCAP_NEXT 3
  34. union fw_encap {
  35. uint32_t ul[2];
  36. struct {
  37. #if BYTE_ORDER == BIG_ENDIAN
  38. uint32_t lf :2;
  39. uint32_t reserved :14;
  40. uint32_t ether_type :16;
  41. #else
  42. uint32_t ether_type :16;
  43. uint32_t reserved :14;
  44. uint32_t lf :2;
  45. #endif
  46. } unfrag;
  47. struct {
  48. #if BYTE_ORDER == BIG_ENDIAN
  49. uint32_t lf :2;
  50. uint32_t reserved1 :2;
  51. uint32_t datagram_size :12;
  52. uint32_t ether_type :16;
  53. uint32_t dgl :16;
  54. uint32_t reserved2 :16;
  55. #else
  56. uint32_t ether_type :16;
  57. uint32_t datagram_size :12;
  58. uint32_t reserved1 :2;
  59. uint32_t lf :2;
  60. uint32_t reserved2 :16;
  61. uint32_t dgl :16;
  62. #endif
  63. } firstfrag;
  64. struct {
  65. #if BYTE_ORDER == BIG_ENDIAN
  66. uint32_t lf :2;
  67. uint32_t reserved1 :2;
  68. uint32_t datagram_size :12;
  69. uint32_t reserved2 :4;
  70. uint32_t fragment_offset :12;
  71. uint32_t dgl :16;
  72. uint32_t reserved3 :16;
  73. #else
  74. uint32_t fragment_offset :12;
  75. uint32_t reserved2 :4;
  76. uint32_t datagram_size :12;
  77. uint32_t reserved1 :2;
  78. uint32_t lf :2;
  79. uint32_t reserved3 :16;
  80. uint32_t dgl :16;
  81. #endif
  82. } nextfrag;
  83. };
  84. #define MTAG_FIREWIRE 1394
  85. #define MTAG_FIREWIRE_HWADDR 0
  86. #define MTAG_FIREWIRE_SENDER_EUID 1
  87. struct fw_hwaddr {
  88. uint32_t sender_unique_ID_hi;
  89. uint32_t sender_unique_ID_lo;
  90. uint8_t sender_max_rec;
  91. uint8_t sspd;
  92. uint16_t sender_unicast_FIFO_hi;
  93. uint32_t sender_unicast_FIFO_lo;
  94. };
  95. /*
  96. * BPF wants to see one of these.
  97. */
  98. struct fw_bpfhdr {
  99. uint8_t firewire_dhost[8];
  100. uint8_t firewire_shost[8];
  101. uint16_t firewire_type;
  102. };
  103. #ifdef _KERNEL
  104. /*
  105. * A structure to track the reassembly of a link-level fragmented
  106. * datagram.
  107. */
  108. struct fw_reass {
  109. STAILQ_ENTRY(fw_reass) fr_link;
  110. uint32_t fr_id; /* host+dgl */
  111. struct mbuf *fr_frags; /* chain of frags */
  112. };
  113. STAILQ_HEAD(fw_reass_list, fw_reass);
  114. struct fw_com {
  115. struct ifnet *fc_ifp;
  116. struct fw_hwaddr fc_hwaddr;
  117. struct firewire_comm *fc_fc;
  118. uint8_t fc_broadcast_channel;
  119. uint8_t fc_speed; /* our speed */
  120. uint16_t fc_node; /* our nodeid */
  121. struct fw_reass_list fc_frags; /* partial datagrams */
  122. };
  123. #define IFP2FWC(ifp) ((struct fw_com *)if_getl2com(ifp))
  124. extern void firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src);
  125. extern void firewire_ifattach(struct ifnet *, struct fw_hwaddr *);
  126. extern void firewire_ifdetach(struct ifnet *);
  127. extern void firewire_busreset(struct ifnet *);
  128. extern int firewire_ioctl(struct ifnet *, u_long, caddr_t);
  129. #endif /* !_KERNEL */
  130. #endif /* !_NET_FIREWIRE_H_ */