mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
committed by
Alan Carvalho de Assis
parent
4c706771c3
commit
f618de9c97
+21
-17
@@ -177,20 +177,20 @@ static int cdcacm_requeue_rdrequest(FAR struct cdcacm_dev_s *priv,
|
||||
static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv);
|
||||
static void cdcacm_rxtimeout(int argc, wdparm_t arg1, ...);
|
||||
|
||||
/* Request helpers *********************************************************/
|
||||
/* Request helpers **********************************************************/
|
||||
|
||||
static struct usbdev_req_s *cdcacm_allocreq(FAR struct usbdev_ep_s *ep,
|
||||
uint16_t len);
|
||||
static void cdcacm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* Flow Control ************************************************************/
|
||||
/* Flow Control *************************************************************/
|
||||
|
||||
#ifdef CONFIG_CDCACM_IFLOWCONTROL
|
||||
static int cdcacm_serialstate(FAR struct cdcacm_dev_s *priv);
|
||||
#endif
|
||||
|
||||
/* Configuration ***********************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
static void cdcacm_resetconfig(FAR struct cdcacm_dev_s *priv);
|
||||
static int cdcacm_epconfigure(FAR struct usbdev_ep_s *ep,
|
||||
@@ -200,7 +200,7 @@ static int cdcacm_epconfigure(FAR struct usbdev_ep_s *ep,
|
||||
static int cdcacm_setconfig(FAR struct cdcacm_dev_s *priv,
|
||||
uint8_t config);
|
||||
|
||||
/* Completion event handlers ***********************************************/
|
||||
/* Completion event handlers ************************************************/
|
||||
|
||||
static void cdcacm_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
@@ -209,7 +209,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req);
|
||||
|
||||
/* USB class device ********************************************************/
|
||||
/* USB class device *********************************************************/
|
||||
|
||||
static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev);
|
||||
@@ -461,7 +461,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
*
|
||||
* Description:
|
||||
* A normal completion event was received by the read completion handler
|
||||
* at the interrupt level (with interrupts disabled). This function handles
|
||||
* at the interrupt level (with interrupts disabled). This function handles
|
||||
* the USB packet and provides the received data to the uart RX buffer.
|
||||
*
|
||||
* Assumptions:
|
||||
@@ -520,7 +520,7 @@ static int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
* and that the actual capacity of the RX buffer is (recv->size - 1).
|
||||
*/
|
||||
|
||||
watermark = (CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * recv->size) / 100;
|
||||
watermark = CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * recv->size / 100;
|
||||
DEBUGASSERT(watermark > 0 && watermark < (recv->size - 1));
|
||||
#endif
|
||||
|
||||
@@ -558,8 +558,8 @@ static int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
|
||||
if (nbuffered >= watermark)
|
||||
{
|
||||
/* Let the lower level driver know that the watermark level has been
|
||||
* crossed. It will probably activate RX flow control.
|
||||
/* Let the lower level driver know that the watermark level has
|
||||
* been crossed. It will probably activate RX flow control.
|
||||
*/
|
||||
|
||||
if (cdcuart_rxflowcontrol(&priv->serdev, nbuffered, true))
|
||||
@@ -1311,7 +1311,8 @@ static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev)
|
||||
{
|
||||
FAR struct cdcacm_dev_s *priv = ((FAR struct cdcacm_driver_s *)driver)->dev;
|
||||
FAR struct cdcacm_dev_s *priv =
|
||||
((FAR struct cdcacm_driver_s *)driver)->dev;
|
||||
FAR struct cdcacm_wrreq_s *wrcontainer;
|
||||
FAR struct cdcacm_rdreq_s *rdcontainer;
|
||||
irqstate_t flags;
|
||||
@@ -1458,7 +1459,9 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Report if we are selfpowered (unless we are part of a composite device) */
|
||||
/* Report if we are selfpowered (unless we are part of a
|
||||
* composite device)
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_CDCACM_COMPOSITE
|
||||
#ifdef CONFIG_USBDEV_SELFPOWERED
|
||||
@@ -1876,7 +1879,8 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
if (dataout && len <= SIZEOF_CDC_LINECODING) /* REVISIT */
|
||||
{
|
||||
memcpy(&priv->linecoding, dataout, SIZEOF_CDC_LINECODING);
|
||||
memcpy(&priv->linecoding,
|
||||
dataout, SIZEOF_CDC_LINECODING);
|
||||
}
|
||||
|
||||
/* Respond with a zero length packet */
|
||||
@@ -2564,8 +2568,8 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
* and cdcuart_attach are called called)
|
||||
* 2. With enable==false while transferring data from the RX buffer
|
||||
* 2. With enable==true while waiting for more incoming data
|
||||
* 3. With enable==false when the port is closed (just before cdcuart_detach
|
||||
* and cdcuart_shutdown are called).
|
||||
* 3. With enable==false when the port is closed (just before
|
||||
* cdcuart_detach and cdcuart_shutdown are called).
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the serial upper-half driver running on the thread of
|
||||
@@ -3100,8 +3104,8 @@ int cdcacm_initialize(int minor, FAR void **handle)
|
||||
*
|
||||
* Input Parameters:
|
||||
* There is one parameter, it differs in typing depending upon whether the
|
||||
* CDC/ACM driver is an internal part of a composite device, or a standalone
|
||||
* USB driver:
|
||||
* CDC/ACM driver is an internal part of a composite device, or a
|
||||
* standalone USB driver:
|
||||
*
|
||||
* classdev - The class object returned by cdcacm_classobject()
|
||||
* handle - The opaque handle representing the class object returned by
|
||||
@@ -3217,7 +3221,7 @@ void cdcacm_get_composite_devdesc(struct composite_devdesc_s *dev)
|
||||
dev->nconfigs = CDCACM_NCONFIGS; /* Number of configurations supported */
|
||||
dev->configid = CDCACM_CONFIGID; /* The only supported configuration ID */
|
||||
|
||||
/* Let the construction function calculate the size of the config descriptor */
|
||||
/* Let the construction function calculate the size of config descriptor */
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
dev->cfgdescsize = cdcacm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0);
|
||||
|
||||
+50
-41
@@ -111,7 +111,9 @@
|
||||
# define CONFIG_CDCECM_NINTERFACES 1
|
||||
#endif
|
||||
|
||||
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
|
||||
/* TX poll delay = 1 seconds.
|
||||
* CLK_TCK is the number of clock ticks per second
|
||||
*/
|
||||
|
||||
#define CDCECM_WDDELAY (1*CLK_TCK)
|
||||
|
||||
@@ -119,7 +121,7 @@
|
||||
|
||||
#define CDCECM_TXTIMEOUT (60*CLK_TCK)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the Ethernet header */
|
||||
/* This is a helper pointer for accessing the contents of Ethernet header */
|
||||
|
||||
#define BUF ((struct eth_hdr_s *)self->dev.d_buf)
|
||||
|
||||
@@ -127,8 +129,8 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* The cdcecm_driver_s encapsulates all state information for a single hardware
|
||||
* interface
|
||||
/* The cdcecm_driver_s encapsulates all state information for a single
|
||||
* hardware interface
|
||||
*/
|
||||
|
||||
struct cdcecm_driver_s
|
||||
@@ -143,7 +145,8 @@ struct cdcecm_driver_s
|
||||
FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint */
|
||||
uint8_t config; /* Selected configuration number */
|
||||
|
||||
uint8_t pktbuf[CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE];
|
||||
uint8_t pktbuf[CONFIG_NET_ETH_PKTSIZE +
|
||||
CONFIG_NET_GUARDSIZE];
|
||||
|
||||
struct usbdev_req_s *rdreq; /* Single read request */
|
||||
bool rxpending; /* Packet available in rdreq */
|
||||
@@ -323,8 +326,8 @@ static const struct usb_devdesc_s g_devdesc =
|
||||
|
||||
static int cdcecm_transmit(FAR struct cdcecm_driver_s *self)
|
||||
{
|
||||
/* Wait until the USB device request for Ethernet frame transmissions becomes
|
||||
* available.
|
||||
/* Wait until the USB device request for Ethernet frame transmissions
|
||||
* becomes available.
|
||||
*/
|
||||
|
||||
while (nxsem_wait(&self->wrreq_idle) != OK)
|
||||
@@ -352,7 +355,8 @@ static int cdcecm_transmit(FAR struct cdcecm_driver_s *self)
|
||||
* devif_poll() may be called:
|
||||
*
|
||||
* 1. When the preceding TX packet send is complete,
|
||||
* 2. When the preceding TX packet send times out and the interface is reset
|
||||
* 2. When the preceding TX packet send times out and the interface is
|
||||
* reset
|
||||
* 3. During normal TX polling
|
||||
*
|
||||
* Input Parameters:
|
||||
@@ -510,7 +514,7 @@ static void cdcecm_receive(FAR struct cdcecm_driver_s *self)
|
||||
self->dev.d_len = self->rdreq->xfrd;
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the packet tap */
|
||||
/* When packet sockets are enabled, feed the frame into the tap */
|
||||
|
||||
pkt_input(&self->dev);
|
||||
#endif
|
||||
@@ -561,7 +565,7 @@ static void cdcecm_receive(FAR struct cdcecm_driver_s *self)
|
||||
NETDEV_RXARP(&self->dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, the field d_len will set to a value > 0.
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (self->dev.d_len > 0)
|
||||
@@ -646,9 +650,9 @@ static void cdcecm_interrupt_work(FAR void *arg)
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Check if a packet transmission just completed. If so, call cdcecm_txdone.
|
||||
* This may disable further Tx interrupts if there are no pending
|
||||
* transmissions.
|
||||
/* Check if a packet transmission just completed. If so, call
|
||||
* cdcecm_txdone. This may disable further Tx interrupts if there
|
||||
* are no pending transmissions.
|
||||
*/
|
||||
|
||||
if (self->txdone)
|
||||
@@ -772,9 +776,9 @@ static int cdcecm_ifup(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
|
||||
#endif
|
||||
|
||||
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
|
||||
/* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
|
||||
|
||||
/* Instantiate the MAC address from priv->dev.d_mac.ether.ether_addr_octet */
|
||||
/* Instantiate MAC address from priv->dev.d_mac.ether.ether_addr_octet */
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6
|
||||
/* Set up IPv6 multicast address filtering */
|
||||
@@ -929,7 +933,8 @@ static int cdcecm_txavail(FAR struct net_driver_s *dev)
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
|
||||
static int cdcecm_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
static int cdcecm_addmac(FAR struct net_driver_s *dev,
|
||||
FAR const uint8_t *mac)
|
||||
{
|
||||
FAR struct cdcecm_driver_s *priv =
|
||||
(FAR struct cdcecm_driver_s *)dev->d_private;
|
||||
@@ -945,8 +950,8 @@ static int cdcecm_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
* Name: cdcecm_rmmac
|
||||
*
|
||||
* Description:
|
||||
* NuttX Callback: Remove the specified MAC address from the hardware multicast
|
||||
* address filtering
|
||||
* NuttX Callback: Remove the specified MAC address from the hardware
|
||||
* multicast address filtering
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Reference to the NuttX driver state structure
|
||||
@@ -1123,7 +1128,8 @@ static void cdcecm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
{
|
||||
DEBUGASSERT(!self->rxpending);
|
||||
self->rxpending = true;
|
||||
work_queue(ETHWORK, &self->irqwork, cdcecm_interrupt_work, self, 0);
|
||||
work_queue(ETHWORK, &self->irqwork,
|
||||
cdcecm_interrupt_work, self, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1227,13 +1233,13 @@ static void cdcecm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_resetconfig
|
||||
*
|
||||
* Description:
|
||||
* Mark the device as not configured and disable all endpoints.
|
||||
*
|
||||
******************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static void cdcecm_resetconfig(FAR struct cdcecm_driver_s *self)
|
||||
{
|
||||
@@ -1259,7 +1265,7 @@ static void cdcecm_resetconfig(FAR struct cdcecm_driver_s *self)
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_setconfig
|
||||
*
|
||||
* Set the device configuration by allocating and configuring endpoints and
|
||||
@@ -1300,7 +1306,8 @@ static int cdcecm_setconfig(FAR struct cdcecm_driver_s *self, uint8_t config)
|
||||
self->epint->priv = self;
|
||||
|
||||
bool is_high_speed = (self->usbdev.speed == USB_SPEED_HIGH);
|
||||
cdcecm_mkepdesc(CDCECM_EP_BULKIN_IDX, &epdesc, &self->devinfo, is_high_speed);
|
||||
cdcecm_mkepdesc(CDCECM_EP_BULKIN_IDX,
|
||||
&epdesc, &self->devinfo, is_high_speed);
|
||||
ret = EP_CONFIGURE(self->epbulkin, &epdesc, false);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -1310,7 +1317,8 @@ static int cdcecm_setconfig(FAR struct cdcecm_driver_s *self, uint8_t config)
|
||||
|
||||
self->epbulkin->priv = self;
|
||||
|
||||
cdcecm_mkepdesc(CDCECM_EP_BULKOUT_IDX, &epdesc, &self->devinfo, is_high_speed);
|
||||
cdcecm_mkepdesc(CDCECM_EP_BULKOUT_IDX,
|
||||
&epdesc, &self->devinfo, is_high_speed);
|
||||
ret = EP_CONFIGURE(self->epbulkout, &epdesc, true);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -1355,7 +1363,7 @@ error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_setinterface
|
||||
*
|
||||
****************************************************************************/
|
||||
@@ -1734,7 +1742,7 @@ static int16_t cdcecm_mkcfgdesc(FAR uint8_t *desc,
|
||||
return len;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_getdescriptor
|
||||
*
|
||||
* Description:
|
||||
@@ -1752,10 +1760,10 @@ static int16_t cdcecm_mkcfgdesc(FAR uint8_t *desc,
|
||||
* The size in bytes of the requested USB Descriptor or a negated errno in
|
||||
* case of failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int cdcecm_getdescriptor(FAR struct cdcecm_driver_s *self, uint8_t type,
|
||||
uint8_t index, FAR void *desc)
|
||||
static int cdcecm_getdescriptor(FAR struct cdcecm_driver_s *self,
|
||||
uint8_t type, uint8_t index, FAR void *desc)
|
||||
{
|
||||
uinfo("type: 0x%02hhx, index: 0x%02hhx\n", type, index);
|
||||
|
||||
@@ -1851,7 +1859,7 @@ static int cdcecm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
/* Pre-allocate read requests. The buffer size is one full packet. */
|
||||
|
||||
self->rdreq = cdcecm_allocreq(self->epbulkout,
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
if (self->rdreq == NULL)
|
||||
{
|
||||
uerr("Out of memory\n");
|
||||
@@ -1864,7 +1872,7 @@ static int cdcecm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
/* Pre-allocate a single write request. Buffer size is one full packet. */
|
||||
|
||||
self->wrreq = cdcecm_allocreq(self->epbulkin,
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE);
|
||||
if (self->wrreq == NULL)
|
||||
{
|
||||
uerr("Out of memory\n");
|
||||
@@ -2035,12 +2043,12 @@ static int cdcecm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* SetEthernetPacketFilter is the only required CDCECM subclass
|
||||
* specific request, but it is still ok to always operate in
|
||||
* promiscuous mode and rely on the host to do the filtering. This
|
||||
* is especially true for our case: A simulated point-to-point
|
||||
* connection.
|
||||
* promiscuous mode and rely on the host to do the filtering.
|
||||
* This is especially true for our case:
|
||||
* A simulated point-to-point connection.
|
||||
*/
|
||||
|
||||
uinfo("ECM_SET_PACKET_FILTER. wValue: 0x%04hx, wIndex: 0x%04hx\n",
|
||||
uinfo("ECM_SET_PACKET_FILTER wValue: 0x%04hx, wIndex: 0x%04hx\n",
|
||||
GETUINT16(ctrl->value), GETUINT16(ctrl->index));
|
||||
|
||||
ret = OK;
|
||||
@@ -2093,7 +2101,8 @@ static void cdcecm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int cdcecm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
|
||||
static int cdcecm_classobject(int minor,
|
||||
FAR struct usbdev_devinfo_s *devinfo,
|
||||
FAR struct usbdevclass_driver_s **classdev)
|
||||
{
|
||||
FAR struct cdcecm_driver_s *self;
|
||||
@@ -2180,8 +2189,8 @@ static int cdcecm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
|
||||
*
|
||||
* Input Parameters:
|
||||
* There is one parameter, it differs in typing depending upon whether the
|
||||
* CDC/ECM driver is an internal part of a composite device, or a standalone
|
||||
* USB driver:
|
||||
* CDC/ECM driver is an internal part of a composite device, or a
|
||||
* standalone USB driver:
|
||||
*
|
||||
* classdev - The class object returned by cdcacm_classobject()
|
||||
* handle - The opaque handle representing the class object returned by
|
||||
@@ -2266,8 +2275,8 @@ void cdcecm_uninitialize(FAR void *handle)
|
||||
* Name: cdcecm_initialize
|
||||
*
|
||||
* Description:
|
||||
* Register CDC/ECM USB device interface. Register the corresponding network
|
||||
* driver to NuttX and bring up the network.
|
||||
* Register CDC/ECM USB device interface. Register the corresponding
|
||||
* network driver to NuttX and bring up the network.
|
||||
*
|
||||
* Input Parameters:
|
||||
* minor - Device minor number.
|
||||
@@ -2348,7 +2357,7 @@ void cdcecm_get_composite_devdesc(struct composite_devdesc_s *dev)
|
||||
dev->nconfigs = CDCECM_NCONFIGS; /* Number of configurations supported */
|
||||
dev->configid = CDCECM_CONFIGID; /* The only supported configuration ID */
|
||||
|
||||
/* Let the construction function calculate the size of the config descriptor */
|
||||
/* Let the construction function calculate the size of config descriptor */
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
dev->cfgdescsize = cdcecm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0);
|
||||
|
||||
+60
-39
@@ -101,7 +101,9 @@
|
||||
#define RNDIS_BUFFER_SIZE CONFIG_NET_ETH_PKTSIZE
|
||||
#define RNDIS_BUFFER_COUNT 4
|
||||
|
||||
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
|
||||
/* TX poll delay = 1 seconds.
|
||||
* CLK_TCK is the number of clock ticks per second
|
||||
*/
|
||||
|
||||
#define RNDIS_WDDELAY (1*CLK_TCK)
|
||||
|
||||
@@ -394,8 +396,8 @@ static uint8_t g_rndis_default_mac_addr[6] =
|
||||
};
|
||||
|
||||
/* These lists give dummy responses to be returned to PC. The values are
|
||||
* chosen so that Windows is happy - other operating systems don't really care
|
||||
* much.
|
||||
* chosen so that Windows is happy - other operating systems don't really
|
||||
* care much.
|
||||
*/
|
||||
|
||||
static const uint32_t g_rndis_supported_oids[] =
|
||||
@@ -474,8 +476,8 @@ static const struct rndis_oid_value_s g_rndis_oid_values[] =
|
||||
* When the reception of an Ethernet packet is complete, a worker to process
|
||||
* the packet is scheduled and bulk OUT endpoint is set to NAK.
|
||||
*
|
||||
* The processing worker passes the buffer to the network. When the network is
|
||||
* done processing the packet, the buffer might contain data to be sent.
|
||||
* The processing worker passes the buffer to the network. When the network
|
||||
* is done processing the packet, the buffer might contain data to be sent.
|
||||
* If so, the corresponding write request is queued on the bulk IN endpoint.
|
||||
* The NAK state on bulk OUT endpoint is cleared to allow new packets to
|
||||
* arrive. If there's no data to send, the request is returned to the list of
|
||||
@@ -832,7 +834,8 @@ static uint16_t rndis_fillrequest(FAR struct rndis_dev_s *priv,
|
||||
{
|
||||
/* Send the required headers */
|
||||
|
||||
FAR struct rndis_packet_msg *msg = (FAR struct rndis_packet_msg *)req->buf;
|
||||
FAR struct rndis_packet_msg *msg =
|
||||
(FAR struct rndis_packet_msg *)req->buf;
|
||||
memset(msg, 0, RNDIS_PACKET_HDR_SIZE);
|
||||
|
||||
msg->msgtype = RNDIS_PACKET_MSG;
|
||||
@@ -959,7 +962,8 @@ static void rndis_rxdispatch(FAR void *arg)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
uerr("ERROR: Unsupported packet type dropped (%02x)\n", htons(hdr->type));
|
||||
uerr("ERROR: Unsupported packet type dropped (%02x)\n",
|
||||
htons(hdr->type));
|
||||
NETDEV_RXDROPPED(&priv->netdev);
|
||||
priv->netdev.d_len = 0;
|
||||
}
|
||||
@@ -1035,8 +1039,8 @@ static int rndis_txpoll(FAR struct net_driver_s *dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
* been examined.
|
||||
/* If zero is returned, the polling will continue until all connections
|
||||
* have been examined.
|
||||
*/
|
||||
|
||||
return ret;
|
||||
@@ -1204,7 +1208,7 @@ static int rndis_txavail(FAR struct net_driver_s *dev)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: rndis_recvpacket
|
||||
*
|
||||
* Description:
|
||||
@@ -1213,7 +1217,7 @@ static int rndis_txavail(FAR struct net_driver_s *dev)
|
||||
* Assumptions:
|
||||
* Called from the USB interrupt handler with interrupts disabled.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
||||
FAR uint8_t *reqbuf, uint16_t reqlen)
|
||||
@@ -1238,7 +1242,8 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
||||
{
|
||||
/* The packet contains a RNDIS packet message header */
|
||||
|
||||
FAR struct rndis_packet_msg *msg = (FAR struct rndis_packet_msg *)reqbuf;
|
||||
FAR struct rndis_packet_msg *msg =
|
||||
(FAR struct rndis_packet_msg *)reqbuf;
|
||||
if (msg->msgtype == RNDIS_PACKET_MSG)
|
||||
{
|
||||
priv->current_rx_received = reqlen;
|
||||
@@ -1247,16 +1252,17 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
||||
|
||||
/* According to RNDIS-over-USB send, if the message length is a
|
||||
* multiple of endpoint max packet size, the host must send an
|
||||
* additional single-byte zero packet. Take that in account here.
|
||||
* additional single-byte zero packet. Take that in account
|
||||
* here.
|
||||
*/
|
||||
|
||||
if ((priv->current_rx_msglen % priv->epbulkout->maxpacket) == 0)
|
||||
if (!(priv->current_rx_msglen % priv->epbulkout->maxpacket))
|
||||
{
|
||||
priv->current_rx_msglen += 1;
|
||||
}
|
||||
|
||||
/* Data offset is defined as an offset from the beginning of the
|
||||
* offset field itself
|
||||
/* Data offset is defined as an offset from the beginning of
|
||||
* the offset field itself
|
||||
*/
|
||||
|
||||
priv->current_rx_datagram_offset = msg->dataoffset + 8;
|
||||
@@ -1279,19 +1285,22 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
||||
priv->current_rx_received <= priv->current_rx_datagram_size +
|
||||
priv->current_rx_datagram_offset)
|
||||
{
|
||||
size_t index = priv->current_rx_received - priv->current_rx_datagram_offset;
|
||||
size_t copysize = min(reqlen, priv->current_rx_datagram_size - index);
|
||||
size_t index = priv->current_rx_received -
|
||||
priv->current_rx_datagram_offset;
|
||||
size_t copysize = min(reqlen,
|
||||
priv->current_rx_datagram_size - index);
|
||||
|
||||
/* Check if the received packet exceeds request buffer */
|
||||
|
||||
if ((index + copysize) <= CONFIG_NET_ETH_PKTSIZE)
|
||||
{
|
||||
memcpy(&priv->rx_req->req->buf[RNDIS_PACKET_HDR_SIZE + index], reqbuf,
|
||||
copysize);
|
||||
memcpy(&priv->rx_req->req->buf[RNDIS_PACKET_HDR_SIZE + index],
|
||||
reqbuf, copysize);
|
||||
}
|
||||
else
|
||||
{
|
||||
uerr("The packet exceeds request buffer (reqlen=%d) \n", reqlen);
|
||||
uerr("The packet exceeds request buffer (reqlen=%d) \n",
|
||||
reqlen);
|
||||
}
|
||||
}
|
||||
priv->current_rx_received += reqlen;
|
||||
@@ -1342,8 +1351,9 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool rndis_prepare_response(FAR struct rndis_dev_s *priv, size_t size,
|
||||
FAR struct rndis_command_header *request_hdr)
|
||||
static bool
|
||||
rndis_prepare_response(FAR struct rndis_dev_s *priv, size_t size,
|
||||
FAR struct rndis_command_header *request_hdr)
|
||||
{
|
||||
FAR struct rndis_response_header *hdr =
|
||||
(FAR struct rndis_response_header *)priv->ctrlreq->buf;
|
||||
@@ -1403,7 +1413,8 @@ static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv)
|
||||
****************************************************************************/
|
||||
|
||||
static int rndis_handle_control_message(FAR struct rndis_dev_s *priv,
|
||||
FAR uint8_t *dataout, uint16_t outlen)
|
||||
FAR uint8_t *dataout,
|
||||
uint16_t outlen)
|
||||
{
|
||||
FAR struct rndis_command_header *cmd_hdr =
|
||||
(FAR struct rndis_command_header *)dataout;
|
||||
@@ -1453,7 +1464,8 @@ static int rndis_handle_control_message(FAR struct rndis_dev_s *priv,
|
||||
resp->hdr.status = RNDIS_STATUS_NOT_SUPPORTED;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof(g_rndis_oid_values) / sizeof(g_rndis_oid_values[0]);
|
||||
i < sizeof(g_rndis_oid_values) /
|
||||
sizeof(g_rndis_oid_values[0]);
|
||||
i++)
|
||||
{
|
||||
bool match = (g_rndis_oid_values[i].objid == req->objid);
|
||||
@@ -1642,7 +1654,8 @@ static void rndis_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
return;
|
||||
|
||||
default: /* Some other error occurred */
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED),
|
||||
(uint16_t)-req->result);
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -2074,8 +2087,9 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* Pre-allocate the IN interrupt endpoint */
|
||||
|
||||
priv->epintin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]),
|
||||
true, USB_EP_ATTR_XFER_INT);
|
||||
priv->epintin = DEV_ALLOCEP(dev,
|
||||
USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]),
|
||||
true, USB_EP_ATTR_XFER_INT);
|
||||
if (!priv->epintin)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0);
|
||||
@@ -2098,8 +2112,9 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* Pre-allocate the IN bulk endpoint */
|
||||
|
||||
priv->epbulkin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]),
|
||||
true, USB_EP_ATTR_XFER_BULK);
|
||||
priv->epbulkin = DEV_ALLOCEP(dev,
|
||||
USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]),
|
||||
true, USB_EP_ATTR_XFER_BULK);
|
||||
if (!priv->epbulkin)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0);
|
||||
@@ -2376,8 +2391,9 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
case USB_REQ_GETDESCRIPTOR:
|
||||
{
|
||||
/* The value field specifies the descriptor type in the MS byte and the
|
||||
* descriptor index in the LS byte (order is little endian)
|
||||
/* The value field specifies the descriptor type in the MS byte
|
||||
* and the descriptor index in the LS byte (order is little
|
||||
* endian)
|
||||
*/
|
||||
|
||||
switch (ctrl->value[1])
|
||||
@@ -2402,13 +2418,14 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
/* index == language code. */
|
||||
|
||||
ret = usbclass_mkstrdesc(ctrl->value[0],
|
||||
(FAR struct usb_strdesc_s *)ctrlreq->buf);
|
||||
(FAR struct usb_strdesc_s *)ctrlreq->buf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC), value);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC),
|
||||
value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2435,7 +2452,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
break;
|
||||
|
||||
default:
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ),
|
||||
ctrl->req);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2445,7 +2463,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
case USB_REQ_TYPE_CLASS:
|
||||
{
|
||||
if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_INTERFACE)
|
||||
if ((ctrl->type & USB_REQ_RECIPIENT_MASK) ==
|
||||
USB_REQ_RECIPIENT_INTERFACE)
|
||||
{
|
||||
if (ctrl->req == RNDIS_SEND_ENCAPSULATED_COMMAND)
|
||||
{
|
||||
@@ -2657,7 +2676,8 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
|
||||
|
||||
/* Configure the IN bulk endpoint */
|
||||
|
||||
usbclass_copy_epdesc(RNDIS_EP_BULKIN_IDX, &epdesc, &priv->devinfo, hispeed);
|
||||
usbclass_copy_epdesc(RNDIS_EP_BULKIN_IDX,
|
||||
&epdesc, &priv->devinfo, hispeed);
|
||||
ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -2670,7 +2690,8 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
|
||||
|
||||
/* Configure the OUT bulk endpoint */
|
||||
|
||||
usbclass_copy_epdesc(RNDIS_EP_BULKOUT_IDX, &epdesc, &priv->devinfo, hispeed);
|
||||
usbclass_copy_epdesc(RNDIS_EP_BULKOUT_IDX,
|
||||
&epdesc, &priv->devinfo, hispeed);
|
||||
ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -2728,7 +2749,7 @@ static int usbclass_classobject(int minor,
|
||||
|
||||
/* Allocate the structures needed */
|
||||
|
||||
alloc = (FAR struct rndis_alloc_s *)kmm_zalloc(sizeof(struct rndis_alloc_s));
|
||||
alloc = kmm_zalloc(sizeof(struct rndis_alloc_s));
|
||||
if (!alloc)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0);
|
||||
|
||||
Reference in New Issue
Block a user