rndis_driver.h
Go to the documentation of this file.
1 /**
2  * @file rndis_driver.h
3  * @brief RNDIS driver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _RNDIS_DRIVER_H
32 #define _RNDIS_DRIVER_H
33 
34 //Dependencies
35 #include "core/nic.h"
36 
37 //Number of TX buffers
38 #ifndef RNDIS_TX_BUFFER_COUNT
39  #define RNDIS_TX_BUFFER_COUNT 2
40 #elif (RNDIS_TX_BUFFER_COUNT < 1)
41  #error RNDIS_TX_BUFFER_COUNT parameter is not valid
42 #endif
43 
44 //TX buffer size
45 #ifndef RNDIS_TX_BUFFER_SIZE
46  #define RNDIS_TX_BUFFER_SIZE 2048
47 #elif (RNDIS_TX_BUFFER_SIZE != 2048)
48  #error RNDIS_TX_BUFFER_SIZE parameter is not valid
49 #endif
50 
51 //Number of RX buffers
52 #ifndef RNDIS_RX_BUFFER_COUNT
53  #define RNDIS_RX_BUFFER_COUNT 1
54 #elif (RNDIS_RX_BUFFER_COUNT < 1)
55  #error RNDIS_RX_BUFFER_COUNT parameter is not valid
56 #endif
57 
58 //RX buffer size
59 #ifndef RNDIS_RX_BUFFER_SIZE
60  #define RNDIS_RX_BUFFER_SIZE 2048
61 #elif (RNDIS_RX_BUFFER_SIZE != 2048)
62  #error RNDIS_RX_BUFFER_SIZE parameter is not valid
63 #endif
64 
65 
66 /**
67  * @brief TX buffer descriptor
68  **/
69 
70 typedef struct
71 {
73  size_t length;
76 
77 
78 /**
79  * @brief RX buffer descriptor
80  **/
81 
82 typedef struct
83 {
85  size_t length;
88 
89 
90 //RNDIS driver
91 extern const NicDriver rndisDriver;
92 //Underlying network interface
94 
95 //TX and RX buffers
98 
99 //Buffer indexes
101 extern uint_t rndisTxReadIndex;
103 extern uint_t rndisRxReadIndex;
104 
105 //RNDIS driver related functions
107 
108 void rndisDriverTick(NetInterface *interface);
109 
110 void rndisDriverEnableIrq(NetInterface *interface);
111 void rndisDriverDisableIrq(NetInterface *interface);
112 void rndisDriverEventHandler(NetInterface *interface);
113 
115  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
116 
118  uint8_t *buffer, size_t size, size_t *length);
119 
121 
122 #endif
#define RNDIS_TX_BUFFER_SIZE
Definition: rndis_driver.h:46
uint_t rndisRxWriteIndex
Definition: rndis_driver.c:53
int bool_t
Definition: compiler_port.h:53
void rndisDriverEnableIrq(NetInterface *interface)
Enable interrupts.
Definition: rndis_driver.c:139
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t data[]
Definition: ethernet.h:222
#define RNDIS_RX_BUFFER_SIZE
Definition: rndis_driver.h:60
error_t rndisDriverReceivePacket(NetInterface *interface, uint8_t *buffer, size_t size, size_t *length)
Receive a packet.
Definition: rndis_driver.c:329
NetInterface * rndisDriverInterface
Definition: rndis_driver.c:44
error_t rndisDriverSetMulticastFilter(NetInterface *interface)
Configure multicast MAC address filtering.
Definition: rndis_driver.c:413
error_t rndisDriverInit(NetInterface *interface)
RNDIS driver initialization.
Definition: rndis_driver.c:88
error_t rndisDriverSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Definition: rndis_driver.c:227
error_t
Error codes.
Definition: error.h:43
#define RNDIS_TX_BUFFER_COUNT
Definition: rndis_driver.h:39
#define NetInterface
Definition: net.h:36
RX buffer descriptor.
Definition: rndis_driver.h:83
#define NetTxAncillary
Definition: net_misc.h:36
RndisRxBufferDesc rndisRxBuffer[RNDIS_RX_BUFFER_COUNT]
Definition: rndis_driver.c:48
uint8_t length
Definition: tcp.h:368
TX buffer descriptor.
Definition: rndis_driver.h:71
void rndisDriverEventHandler(NetInterface *interface)
RNDIS driver event handler.
Definition: rndis_driver.c:163
uint_t rndisTxWriteIndex
Definition: rndis_driver.c:51
const NicDriver rndisDriver
RNDIS driver.
Definition: rndis_driver.c:61
Network interface controller abstraction layer.
void rndisDriverTick(NetInterface *interface)
RNDIS driver timer handler.
Definition: rndis_driver.c:128
#define RNDIS_RX_BUFFER_COUNT
Definition: rndis_driver.h:53
void rndisDriverDisableIrq(NetInterface *interface)
Disable interrupts.
Definition: rndis_driver.c:151
uint_t rndisTxReadIndex
Definition: rndis_driver.c:52
unsigned int uint_t
Definition: compiler_port.h:50
NIC driver.
Definition: nic.h:286
RndisTxBufferDesc rndisTxBuffer[RNDIS_TX_BUFFER_COUNT]
Definition: rndis_driver.c:47
uint_t rndisRxReadIndex
Definition: rndis_driver.c:54