• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /************************************************************************************
2  * include/nuttx/usb/rndis.h
3  *
4  *   Copyright (C) 2011-2017 Gregory Nutt. All rights reserved.
5  *   Copyright (c) Huawei Technologies Co., Ltd. 2017-2019. All rights reserved.
6  *   Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>,
7               Petteri Aimonen <jpa@git.mail.kapsi.fi>
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
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
17  *    the documentation and/or other materials provided with the
18  *    distribution.
19  * 3. Neither the name NuttX nor the names of its contributors may be
20  *    used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
30  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  ************************************************************************************/
37 /****************************************************************************
38  * Notice of Export Control Law
39  * ===============================================
40  * Huawei LiteOS may be subject to applicable export control laws and regulations,
41  * which might include those applicable to Huawei LiteOS of U.S. and the country in
42  * which you are located.
43  * Import, export and usage of Huawei LiteOS in any manner by you shall be in
44  * compliance with such applicable export control laws and regulations.
45  ****************************************************************************/
46 
47 #ifndef __INCLUDE_NUTTX_USB_RNDIS_H
48 #define __INCLUDE_NUTTX_USB_RNDIS_H
49 
50 /************************************************************************************
51  * Included Files
52  ************************************************************************************/
53 
54 #include <linux/module.h>
55 #include <los_mac.h>
56 #include "gadget/usbdev.h"
57 #include "gadget/rndis_std.h"
58 #include "net/usb_eth_drv.h"
59 
60 /************************************************************************************
61  * Public Data
62  ************************************************************************************/
63 
64 #undef EXTERN
65 #if defined(__cplusplus)
66 #  define EXTERN extern "C"
67 extern "C"
68 {
69 #else
70 #  define EXTERN extern
71 #endif
72 
73 #define RNDIS_PACKET_HDR_SIZE   (sizeof(struct rndis_packet_msg))
74 
75 #define RNDIS_EP_INTIN_IDX        (0)
76 #define RNDIS_EP_BULKIN_IDX       (1)
77 #define RNDIS_EP_BULKOUT_IDX      (2)
78 
79 /* Endpoint configuration ****************************************************/
80 
81 #define RNDIS_MKEPINTIN(desc)     ((desc)->epno[RNDIS_EP_INTIN_IDX])
82 
83 #define RNDIS_MKEPBULKIN(desc)    ((desc)->epno[RNDIS_EP_BULKIN_IDX])
84 
85 #define RNDIS_MKEPBULKOUT(desc)   ((desc)->epno[RNDIS_EP_BULKOUT_IDX])
86 
87 extern struct rndis_hs_descriptor g_rndis_hs_desc;
88 extern struct rndis_hs_function_descriptor g_rndis_hs_func_desc;
89 
90 /************************************************************************************
91  * Public Functions
92  ************************************************************************************/
93 
94 extern int usbdev_rndis_initialize (struct module *mod, int n, void *arg);
95 
96 extern void rndis_tx(struct los_eth_driver *sc, const struct eth_drv_sg *sg_list,
97                      int sg_len, uint32_t total_len, UINTPTR key);
98 extern void usbdev_rndis_initialize_sub(struct composite_devdesc_s *dev,
99                                         int ifnobase, int minor);
100 
101 #undef EXTERN
102 #if defined(__cplusplus)
103 }
104 #endif
105 
106 #endif /* __INCLUDE_NUTTX_USB_RNDIS_H */
107