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