Fix issues reported on PR #1233

This commit is contained in:
Alan C. Assis 2020-06-14 19:59:38 -03:00 committed by patacongo
parent 6ff18a7f3b
commit 7609b67496
6 changed files with 42 additions and 28 deletions

View file

@ -265,8 +265,9 @@ endif # USBHOST_CDCACM
config USBHOST_CDCMBIM
bool "CDC/MBIM support"
default n
depends on USBHOST_HAVE_ASYNCH && !USBHOST_BULK_DISABLE && !USBHOST_INT_DISABLE
depends on USBHOST_HAVE_ASYNCH && !USBHOST_BULK_DISABLE && !USBHOST_INT_DISABLE && EXPERIMENTAL
select USBHOST_ASYNCH
select NET_MBIM
---help---
Select this option to build in host support for CDC/MBIM network
devices.

View file

@ -56,6 +56,7 @@
****************************************************************************/
/* put in cdc.h */
#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
#define USB_CDC_GET_NTB_PARAMETERS 0x80
@ -564,10 +565,10 @@ static ssize_t cdcwdm_write(FAR struct file *filep, FAR const char *buffer,
static int cdcwdm_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct usbhost_cdcmbim_s *priv;
int ret = OK;
int i;
int ret = OK;
int i;
DEBUGASSERT(filep && filep->f_inode && fds);
inode = filep->f_inode;
@ -803,9 +804,11 @@ static void usbhost_bulkin_work(FAR void *arg)
{
struct usbhost_cdcmbim_s *priv;
struct usbhost_hubport_s *hport;
struct usb_cdc_ncm_nth16_s *nth;
uint16_t ndpoffset;
uint16_t dgram_len;
uint16_t dgram_off;
uint16_t block_len;
priv = (struct usbhost_cdcmbim_s *)arg;
DEBUGASSERT(priv);
@ -828,8 +831,7 @@ static void usbhost_bulkin_work(FAR void *arg)
/* Parse the NTB header */
struct usb_cdc_ncm_nth16_s *nth =
(struct usb_cdc_ncm_nth16_s *)priv->rxnetbuf;
nth = (struct usb_cdc_ncm_nth16_s *)priv->rxnetbuf;
if (usbhost_getle32(nth->signature) != USB_CDC_NCM_NTH16_SIGNATURE)
{
@ -837,7 +839,7 @@ static void usbhost_bulkin_work(FAR void *arg)
goto out;
}
uint16_t block_len = usbhost_getle16(nth->block_length);
block_len = usbhost_getle16(nth->block_length);
if (block_len > priv->bulkinbytes)
{
@ -856,6 +858,7 @@ static void usbhost_bulkin_work(FAR void *arg)
do
{
struct usb_cdc_ncm_dpe16_s *dpe;
struct usb_cdc_ncm_ndp16_s *ndp
= (struct usb_cdc_ncm_ndp16_s *)(priv->rxnetbuf + ndpoffset);
@ -863,8 +866,6 @@ static void usbhost_bulkin_work(FAR void *arg)
/* Parse each DPE */
struct usb_cdc_ncm_dpe16_s *dpe;
for (dpe = ndp->dpe16; usbhost_getle16(dpe->index); dpe++)
{
dgram_off = usbhost_getle16(dpe->index);
@ -904,7 +905,17 @@ out:
static void usbhost_rxdata_work(FAR void *arg)
{
/* Would be nice if CTRLIN would return how many bytes it read... */
struct mbim_header_s
{
uint8_t type[4];
uint8_t len[4];
};
FAR struct usbhost_cdcmbim_s *priv;
struct mbim_header_s *hdr;
uint32_t len;
int ret;
priv = (FAR struct usbhost_cdcmbim_s *)arg;
@ -931,16 +942,8 @@ static void usbhost_rxdata_work(FAR void *arg)
goto errout;
}
/* Would be nice if CTRLIN would return how many bytes it read... */
struct mbim_header_s
{
uint8_t type[4];
uint8_t len[4];
};
struct mbim_header_s *hdr = (struct mbim_header_s *)priv->comm_rxbuf;
uint32_t len = usbhost_getle32(hdr->len);
hdr = (struct mbim_header_s *)priv->comm_rxbuf;
len = usbhost_getle32(hdr->len);
if (len > priv->maxctrlsize)
{

View file

@ -156,7 +156,7 @@ enum net_lltype_e
NET_LL_IEEE80211, /* IEEE 802.11 */
NET_LL_IEEE802154, /* IEEE 802.15.4 MAC */
NET_LL_PKTRADIO, /* Non-standard packet radio */
NET_LL_MBIM
NET_LL_MBIM /* CDC-MBIM USB host driver */
};
/* This defines a bitmap big enough for one bit for each socket option */

View file

@ -1,4 +1,4 @@
/****************************************************************************
/*****************************************************************************
* include/nuttx/usb/cdc.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -16,7 +16,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
*****************************************************************************/
#ifndef __INCLUDE_NUTTX_USB_CDC_H
#define __INCLUDE_NUTTX_USB_CDC_H
@ -930,7 +930,9 @@ struct cdc_linecoding_s
struct cdc_linestatus_s
{
uint8_t size[2]; /* wLength, Size of this structure, in bytes */
uint8_t ringer[4]; /* dwRingerBitmap, Ringer Conf bitmap for this line */
uint8_t ringer[4]; /* dwRingerBitmap, Ringer Configuration bitmap for this
* line
*/
uint8_t line[4]; /* dwLineState, Defines current state of the line */
uint32_t call[1]; /* dwCallStateN, Current state of call N on the line */
};

View file

@ -150,6 +150,11 @@ config NET_LOOPBACK_PKTSIZE
CONFIG_NET_LOOPBACK_PKTSIZE is zero, meaning that this maximum
packet size will be used by loopback driver.
menuconfig NET_MBIM
bool "MBIM modem support"
depends on USBHOST_CDCMBIM
default n
menuconfig NET_SLIP
bool "SLIP support"
select ARCH_HAVE_NETDEV_STATISTICS

View file

@ -314,11 +314,14 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
devfmt = NETDEV_TUN_FORMAT;
break;
#endif
case NET_LL_MBIM:
llhdrlen = 0;
pktsize = 1200;
devfmt = NETDEV_WWAN_FORMAT;
break;
#ifdef CONFIG_NET_MBIM
case NET_LL_MBIM:
llhdrlen = 0;
pktsize = 1200;
devfmt = NETDEV_WWAN_FORMAT;
break;
#endif
default:
nerr("ERROR: Unrecognized link type: %d\n", lltype);