if_ncmreg.h revision 1.1.4.2 1 1.1.4.2 perseant /* $NetBSD: if_ncmreg.h,v 1.1.4.2 2025/08/02 05:57:05 perseant Exp $ */
2 1.1.4.2 perseant
3 1.1.4.2 perseant /*-
4 1.1.4.2 perseant * Copyright (c) 2025 The NetBSD Foundation, Inc.
5 1.1.4.2 perseant * All rights reserved.
6 1.1.4.2 perseant *
7 1.1.4.2 perseant * This code is derived from software contributed to The NetBSD Foundation
8 1.1.4.2 perseant * by Maya Rashish
9 1.1.4.2 perseant *
10 1.1.4.2 perseant * Redistribution and use in source and binary forms, with or without
11 1.1.4.2 perseant * modification, are permitted provided that the following conditions
12 1.1.4.2 perseant * are met:
13 1.1.4.2 perseant * 1. Redistributions of source code must retain the above copyright
14 1.1.4.2 perseant * notice, this list of conditions and the following disclaimer.
15 1.1.4.2 perseant * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.4.2 perseant * notice, this list of conditions and the following disclaimer in the
17 1.1.4.2 perseant * documentation and/or other materials provided with the distribution.
18 1.1.4.2 perseant *
19 1.1.4.2 perseant * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.4.2 perseant * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.4.2 perseant * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.4.2 perseant * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.4.2 perseant * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.4.2 perseant * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.4.2 perseant * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.4.2 perseant * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.4.2 perseant * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.4.2 perseant * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.4.2 perseant * POSSIBILITY OF SUCH DAMAGE.
30 1.1.4.2 perseant */
31 1.1.4.2 perseant
32 1.1.4.2 perseant /*
33 1.1.4.2 perseant * USB Network Control Model (NCM)
34 1.1.4.2 perseant * https://www.usb.org/sites/default/files/NCM10_012011.zip
35 1.1.4.2 perseant */
36 1.1.4.2 perseant
37 1.1.4.2 perseant #ifndef _NCM_H_
38 1.1.4.2 perseant #define _NCM_H_
39 1.1.4.2 perseant
40 1.1.4.2 perseant #include <dev/usb/usb.h>
41 1.1.4.2 perseant
42 1.1.4.2 perseant #define NCM_MIN_TX_BUFSZ \
43 1.1.4.2 perseant (ETHERMTU + ETHER_HDR_LEN \
44 1.1.4.2 perseant + sizeof(struct ncm_header16) \
45 1.1.4.2 perseant + sizeof(struct ncm_pointer16))
46 1.1.4.2 perseant
47 1.1.4.2 perseant struct ncm_header16 {
48 1.1.4.2 perseant #define NCM_HDR16_SIG 0x484d434e
49 1.1.4.2 perseant uDWord dwSignature;
50 1.1.4.2 perseant uWord wHeaderLength;
51 1.1.4.2 perseant uWord wSequence;
52 1.1.4.2 perseant uWord wBlockLength;
53 1.1.4.2 perseant uWord wNdpIndex;
54 1.1.4.2 perseant } UPACKED;
55 1.1.4.2 perseant
56 1.1.4.2 perseant struct ncm_header32 {
57 1.1.4.2 perseant #define NCM_HDR32_SIG 0x686d636e
58 1.1.4.2 perseant uDWord dwSignature;
59 1.1.4.2 perseant uWord wHeaderLength;
60 1.1.4.2 perseant uWord wSequence;
61 1.1.4.2 perseant uDWord dwBlockLength;
62 1.1.4.2 perseant uDWord dwNdpIndex;
63 1.1.4.2 perseant } UPACKED;
64 1.1.4.2 perseant
65 1.1.4.2 perseant struct ncm_pointer16 {
66 1.1.4.2 perseant uWord wDatagramIndex;
67 1.1.4.2 perseant uWord wDatagramLength;
68 1.1.4.2 perseant } UPACKED;
69 1.1.4.2 perseant
70 1.1.4.2 perseant struct ncm_dptab16 {
71 1.1.4.2 perseant #define NCM_PTR16_SIG_NO_CRC 0x304d434e
72 1.1.4.2 perseant #define NCM_PTR16_SIG_CRC 0x314d434e
73 1.1.4.2 perseant uDWord dwSignature;
74 1.1.4.2 perseant uWord wLength;
75 1.1.4.2 perseant uWord wNextNdpIndex;
76 1.1.4.2 perseant struct ncm_pointer16 datagram[2];
77 1.1.4.2 perseant } UPACKED;
78 1.1.4.2 perseant
79 1.1.4.2 perseant struct ncm_pointer32 {
80 1.1.4.2 perseant uDWord dwDatagramIndex;
81 1.1.4.2 perseant uDWord dwDatagramLength;
82 1.1.4.2 perseant } UPACKED;
83 1.1.4.2 perseant
84 1.1.4.2 perseant struct ncm_dptab32 {
85 1.1.4.2 perseant #define NCM_PTR32_SIG_NO_CRC 0x306d636e
86 1.1.4.2 perseant #define NCM_PTR32_SIG_CRC 0x316d636e
87 1.1.4.2 perseant uDWord dwSignature;
88 1.1.4.2 perseant uWord wLength;
89 1.1.4.2 perseant uWord wReserved6;
90 1.1.4.2 perseant uWord wNextNdpIndex;
91 1.1.4.2 perseant uDWord dwReserved12;
92 1.1.4.2 perseant struct ncm_pointer32 datagram[2];
93 1.1.4.2 perseant } UPACKED;
94 1.1.4.2 perseant
95 1.1.4.2 perseant #define NCM_GET_NTB_PARAMETERS 0x80
96 1.1.4.2 perseant struct ncm_ntb_parameters {
97 1.1.4.2 perseant uWord wLength;
98 1.1.4.2 perseant uByte bmNtbFormatsSupported[2];
99 1.1.4.2 perseant uDWord dwNtbInMaxSize;
100 1.1.4.2 perseant uWord wNdpInDivisor;
101 1.1.4.2 perseant uWord wNdpInPayloadRemainder;
102 1.1.4.2 perseant uWord wNdpInAlignment;
103 1.1.4.2 perseant uWord wReserved;
104 1.1.4.2 perseant uDWord dwNtbOutMaxSize;
105 1.1.4.2 perseant uWord wNdpOutDivisor;
106 1.1.4.2 perseant uWord wNdpOutPayloadRemainder;
107 1.1.4.2 perseant uWord wNdpOutAlignment;
108 1.1.4.2 perseant uWord wNtbOutMaxDatagrams;
109 1.1.4.2 perseant } UPACKED;
110 1.1.4.2 perseant
111 1.1.4.2 perseant #endif /* _NCM_H_ */
112