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