Fix issues reported on PR #1233
This commit is contained in:
parent
6ff18a7f3b
commit
7609b67496
6 changed files with 42 additions and 28 deletions
|
@ -265,8 +265,9 @@ endif # USBHOST_CDCACM
|
||||||
config USBHOST_CDCMBIM
|
config USBHOST_CDCMBIM
|
||||||
bool "CDC/MBIM support"
|
bool "CDC/MBIM support"
|
||||||
default n
|
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 USBHOST_ASYNCH
|
||||||
|
select NET_MBIM
|
||||||
---help---
|
---help---
|
||||||
Select this option to build in host support for CDC/MBIM network
|
Select this option to build in host support for CDC/MBIM network
|
||||||
devices.
|
devices.
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* put in cdc.h */
|
/* put in cdc.h */
|
||||||
|
|
||||||
#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||||
#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||||
#define USB_CDC_GET_NTB_PARAMETERS 0x80
|
#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,
|
static int cdcwdm_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode;
|
FAR struct inode *inode;
|
||||||
FAR struct usbhost_cdcmbim_s *priv;
|
FAR struct usbhost_cdcmbim_s *priv;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUGASSERT(filep && filep->f_inode && fds);
|
DEBUGASSERT(filep && filep->f_inode && fds);
|
||||||
inode = filep->f_inode;
|
inode = filep->f_inode;
|
||||||
|
@ -803,9 +804,11 @@ static void usbhost_bulkin_work(FAR void *arg)
|
||||||
{
|
{
|
||||||
struct usbhost_cdcmbim_s *priv;
|
struct usbhost_cdcmbim_s *priv;
|
||||||
struct usbhost_hubport_s *hport;
|
struct usbhost_hubport_s *hport;
|
||||||
|
struct usb_cdc_ncm_nth16_s *nth;
|
||||||
uint16_t ndpoffset;
|
uint16_t ndpoffset;
|
||||||
uint16_t dgram_len;
|
uint16_t dgram_len;
|
||||||
uint16_t dgram_off;
|
uint16_t dgram_off;
|
||||||
|
uint16_t block_len;
|
||||||
|
|
||||||
priv = (struct usbhost_cdcmbim_s *)arg;
|
priv = (struct usbhost_cdcmbim_s *)arg;
|
||||||
DEBUGASSERT(priv);
|
DEBUGASSERT(priv);
|
||||||
|
@ -828,8 +831,7 @@ static void usbhost_bulkin_work(FAR void *arg)
|
||||||
|
|
||||||
/* Parse the NTB header */
|
/* Parse the NTB header */
|
||||||
|
|
||||||
struct usb_cdc_ncm_nth16_s *nth =
|
nth = (struct usb_cdc_ncm_nth16_s *)priv->rxnetbuf;
|
||||||
(struct usb_cdc_ncm_nth16_s *)priv->rxnetbuf;
|
|
||||||
|
|
||||||
if (usbhost_getle32(nth->signature) != USB_CDC_NCM_NTH16_SIGNATURE)
|
if (usbhost_getle32(nth->signature) != USB_CDC_NCM_NTH16_SIGNATURE)
|
||||||
{
|
{
|
||||||
|
@ -837,7 +839,7 @@ static void usbhost_bulkin_work(FAR void *arg)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t block_len = usbhost_getle16(nth->block_length);
|
block_len = usbhost_getle16(nth->block_length);
|
||||||
|
|
||||||
if (block_len > priv->bulkinbytes)
|
if (block_len > priv->bulkinbytes)
|
||||||
{
|
{
|
||||||
|
@ -856,6 +858,7 @@ static void usbhost_bulkin_work(FAR void *arg)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
struct usb_cdc_ncm_dpe16_s *dpe;
|
||||||
struct usb_cdc_ncm_ndp16_s *ndp
|
struct usb_cdc_ncm_ndp16_s *ndp
|
||||||
= (struct usb_cdc_ncm_ndp16_s *)(priv->rxnetbuf + ndpoffset);
|
= (struct usb_cdc_ncm_ndp16_s *)(priv->rxnetbuf + ndpoffset);
|
||||||
|
|
||||||
|
@ -863,8 +866,6 @@ static void usbhost_bulkin_work(FAR void *arg)
|
||||||
|
|
||||||
/* Parse each DPE */
|
/* Parse each DPE */
|
||||||
|
|
||||||
struct usb_cdc_ncm_dpe16_s *dpe;
|
|
||||||
|
|
||||||
for (dpe = ndp->dpe16; usbhost_getle16(dpe->index); dpe++)
|
for (dpe = ndp->dpe16; usbhost_getle16(dpe->index); dpe++)
|
||||||
{
|
{
|
||||||
dgram_off = usbhost_getle16(dpe->index);
|
dgram_off = usbhost_getle16(dpe->index);
|
||||||
|
@ -904,7 +905,17 @@ out:
|
||||||
|
|
||||||
static void usbhost_rxdata_work(FAR void *arg)
|
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;
|
FAR struct usbhost_cdcmbim_s *priv;
|
||||||
|
struct mbim_header_s *hdr;
|
||||||
|
uint32_t len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
priv = (FAR struct usbhost_cdcmbim_s *)arg;
|
priv = (FAR struct usbhost_cdcmbim_s *)arg;
|
||||||
|
@ -931,16 +942,8 @@ static void usbhost_rxdata_work(FAR void *arg)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Would be nice if CTRLIN would return how many bytes it read... */
|
hdr = (struct mbim_header_s *)priv->comm_rxbuf;
|
||||||
|
len = usbhost_getle32(hdr->len);
|
||||||
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);
|
|
||||||
|
|
||||||
if (len > priv->maxctrlsize)
|
if (len > priv->maxctrlsize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ enum net_lltype_e
|
||||||
NET_LL_IEEE80211, /* IEEE 802.11 */
|
NET_LL_IEEE80211, /* IEEE 802.11 */
|
||||||
NET_LL_IEEE802154, /* IEEE 802.15.4 MAC */
|
NET_LL_IEEE802154, /* IEEE 802.15.4 MAC */
|
||||||
NET_LL_PKTRADIO, /* Non-standard packet radio */
|
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 */
|
/* This defines a bitmap big enough for one bit for each socket option */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/****************************************************************************
|
/*****************************************************************************
|
||||||
* include/nuttx/usb/cdc.h
|
* include/nuttx/usb/cdc.h
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
* License for the specific language governing permissions and limitations
|
* License for the specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_USB_CDC_H
|
#ifndef __INCLUDE_NUTTX_USB_CDC_H
|
||||||
#define __INCLUDE_NUTTX_USB_CDC_H
|
#define __INCLUDE_NUTTX_USB_CDC_H
|
||||||
|
@ -930,7 +930,9 @@ struct cdc_linecoding_s
|
||||||
struct cdc_linestatus_s
|
struct cdc_linestatus_s
|
||||||
{
|
{
|
||||||
uint8_t size[2]; /* wLength, Size of this structure, in bytes */
|
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 */
|
uint8_t line[4]; /* dwLineState, Defines current state of the line */
|
||||||
uint32_t call[1]; /* dwCallStateN, Current state of call N on the line */
|
uint32_t call[1]; /* dwCallStateN, Current state of call N on the line */
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,6 +150,11 @@ config NET_LOOPBACK_PKTSIZE
|
||||||
CONFIG_NET_LOOPBACK_PKTSIZE is zero, meaning that this maximum
|
CONFIG_NET_LOOPBACK_PKTSIZE is zero, meaning that this maximum
|
||||||
packet size will be used by loopback driver.
|
packet size will be used by loopback driver.
|
||||||
|
|
||||||
|
menuconfig NET_MBIM
|
||||||
|
bool "MBIM modem support"
|
||||||
|
depends on USBHOST_CDCMBIM
|
||||||
|
default n
|
||||||
|
|
||||||
menuconfig NET_SLIP
|
menuconfig NET_SLIP
|
||||||
bool "SLIP support"
|
bool "SLIP support"
|
||||||
select ARCH_HAVE_NETDEV_STATISTICS
|
select ARCH_HAVE_NETDEV_STATISTICS
|
||||||
|
|
|
@ -314,11 +314,14 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
|
||||||
devfmt = NETDEV_TUN_FORMAT;
|
devfmt = NETDEV_TUN_FORMAT;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case NET_LL_MBIM:
|
|
||||||
llhdrlen = 0;
|
#ifdef CONFIG_NET_MBIM
|
||||||
pktsize = 1200;
|
case NET_LL_MBIM:
|
||||||
devfmt = NETDEV_WWAN_FORMAT;
|
llhdrlen = 0;
|
||||||
break;
|
pktsize = 1200;
|
||||||
|
devfmt = NETDEV_WWAN_FORMAT;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
nerr("ERROR: Unrecognized link type: %d\n", lltype);
|
nerr("ERROR: Unrecognized link type: %d\n", lltype);
|
||||||
|
|
Loading…
Reference in a new issue