diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-05-29 12:30:37 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-05-29 12:30:37 -0600 |
commit | 888ff3f3c2b85d178a7c375807eb66ab3ab52872 (patch) | |
tree | 370760feb6255b0ab8577e66d5606562786c8548 /nuttx/drivers/usbdev | |
parent | 26346bebfa749b55d1dd983c478d14c913eb9619 (diff) | |
download | px4-nuttx-888ff3f3c2b85d178a7c375807eb66ab3ab52872.tar.gz px4-nuttx-888ff3f3c2b85d178a7c375807eb66ab3ab52872.tar.bz2 px4-nuttx-888ff3f3c2b85d178a7c375807eb66ab3ab52872.zip |
Optimize request buffer sizes in the serial USB drivers so that we avoid so many NULL packets and so that the OUT request buffer size is exactly the max packet size.
Diffstat (limited to 'nuttx/drivers/usbdev')
-rw-r--r-- | nuttx/drivers/usbdev/Kconfig | 48 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/cdcacm.c | 21 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/pl2303.c | 33 |
3 files changed, 49 insertions, 53 deletions
diff --git a/nuttx/drivers/usbdev/Kconfig b/nuttx/drivers/usbdev/Kconfig index 889f2000b..dba90e599 100644 --- a/nuttx/drivers/usbdev/Kconfig +++ b/nuttx/drivers/usbdev/Kconfig @@ -181,15 +181,15 @@ config PL2303_CONSOLE as the console device. config PL2303_EPINTIN - int "Logical endpoint numbers" + int "Interrupt IN endpoint number" default 1 config PL2303_EPBULKOUT - int "Endpoint Bulkout" + int "Bulk OUT endpoint number" default 2 config PL2303_EPBULKIN - int "Endpoint Bulkin" + int "Bulk IN endpoint number" default 3 config PL2303_EP0MAXPACKET @@ -208,6 +208,16 @@ config PL2303_NRDREQS ---help--- The number of write/read requests that can be in flight +config PL2303_BULKIN_REQLEN + int "Size of one write request buffer" + default 96 + ---help--- + Ideally, the BULKOUT request size should *not* be the same size as + the maxpacket size. That is because IN transfers of exactly the + maxpacket size will be followed by a NULL packet. The BULKOUT, + on the other hand, request buffer size is always the same as the + maxpacket size. + config PL2303_RXBUFSIZE int "Receive buffer size" default 256 @@ -290,63 +300,63 @@ config CDCACM_EP0MAXPACKET Endpoint 0 max packet size. Default 64. config CDCACM_EPINTIN - int "Hardware endpoint that supports interrupt IN operation" + int "Interrupt IN endpoint number" default 1 ---help--- The logical 7-bit address of a hardware endpoint that supports interrupt IN operation. Default 1. config CDCACM_EPINTIN_FSSIZE - int "Endpoint in full speed size" + int "Interupt IN full speed MAXPACKET size" default 64 ---help--- Max package size for the interrupt IN endpoint if full speed mode. Default 64. config CDCACM_EPINTIN_HSSIZE - int "Endpoint in high speed size" + int "Interupt IN high speed MAXPACKET size" default 64 ---help--- Max package size for the interrupt IN endpoint if high speed mode. Default 64. config CDCACM_EPBULKOUT - int "Endpoint bulk out" + int "Bulk OUT endpoint number" default 3 ---help--- The logical 7-bit address of a hardware endpoint that supports bulk OUT operation. Default: 3 config CDCACM_EPBULKOUT_FSSIZE - int "Endpoint bulk out full speed size" + int "Bulk OUT full speed MAXPACKET size" default 64 ---help--- Max package size for the bulk OUT endpoint if full speed mode. Default 64. config CDCACM_EPBULKOUT_HSSIZE - int "Endpoint bulk out high speed size" + int "Bulk OUT out high speed MAXPACKET size" default 512 ---help--- Max package size for the bulk OUT endpoint if high speed mode. Default 512. config CDCACM_EPBULKIN - int "Endpoint bulk in" + int "Bulk IN endpoint number" default 2 ---help--- The logical 7-bit address of a hardware endpoint that supports bulk IN operation. Default: 2 config CDCACM_EPBULKIN_FSSIZE - int "Endpoint bulk in full speed size" + int "Bulk IN full speed MAXPACKET size" default 64 ---help--- Max package size for the bulk IN endpoint if full speed mode. Default 64. config CDCACM_EPBULKIN_HSSIZE - int "Endpoint bulk in high speed size" + int "Bulk IN high speed MAXPACKET size" default 512 ---help--- Max package size for the bulk IN endpoint if high speed mode. @@ -364,6 +374,16 @@ config CDCACM_NRDREQS ---help--- The number of write/read requests that can be in flight +config CDCACM_BULKIN_REQLEN + int "Size of one write request buffer" + default 96 + ---help--- + Ideally, the BULKOUT request size should *not* be the same size as + the maxpacket size. That is because IN transfers of exactly the + maxpacket size will be followed by a NULL packet. The BULKOUT, + on the other hand, request buffer size is always the same as the + maxpacket size. + config CDCACM_RXBUFSIZE int "Receive buffer size" default 256 @@ -463,14 +483,14 @@ config USBMSC_EP0MAXPACKET Max packet size for endpoint 0 config USBMSC_EPBULKOUT - int "Endpoint bulk out" + int "Bulk OUT endpoint number" default 0 ---help--- The logical 7-bit address of a hardware endpoints that support bulk OUT and IN operations config USBMSC_EPBULKIN - int "Endpoint bulk in" + int "Bulk IN endpoint number" default 0 ---help--- The logical 7-bit address of a hardware endpoints that support diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c index cf0ebad82..289e1cd10 100644 --- a/nuttx/drivers/usbdev/cdcacm.c +++ b/nuttx/drivers/usbdev/cdcacm.c @@ -359,11 +359,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv) /* Get the maximum number of bytes that will fit into one bulk IN request */ -#ifdef CONFIG_CDCACM_BULKREQLEN - reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket); -#else - reqlen = ep->maxpacket; -#endif + reqlen = MAX(CONFIG_CDCACM_BULKIN_REQLEN, ep->maxpacket); while (!sq_empty(&priv->reqlist)) { @@ -841,12 +837,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep, /* Requeue the read request */ -#ifdef CONFIG_CDCACM_BULKREQLEN - req->len = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket); -#else req->len = ep->maxpacket; -#endif - ret = EP_SUBMIT(ep, req); if (ret != OK) { @@ -1013,11 +1004,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate read requests */ -#ifdef CONFIG_CDCACM_BULKREQLEN - reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, priv->epbulkout->maxpacket); -#else reqlen = priv->epbulkout->maxpacket; -#endif for (i = 0; i < CONFIG_CDCACM_NRDREQS; i++) { @@ -1036,11 +1023,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate write request containers and put in a free list */ -#ifdef CONFIG_CDCACM_BULKREQLEN - reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, priv->epbulkin->maxpacket); -#else - reqlen = priv->epbulkin->maxpacket; -#endif + reqlen = MAX(CONFIG_CDCACM_BULKIN_REQLEN, priv->epbulkin->maxpacket); for (i = 0; i < CONFIG_CDCACM_NWRREQS; i++) { diff --git a/nuttx/drivers/usbdev/pl2303.c b/nuttx/drivers/usbdev/pl2303.c index 9aa65a56c..71918ca41 100644 --- a/nuttx/drivers/usbdev/pl2303.c +++ b/nuttx/drivers/usbdev/pl2303.c @@ -101,7 +101,15 @@ # define CONFIG_PL2303_EP0MAXPACKET 64 #endif -#undef CONFIG_PL2303_BULKREQLEN +/* Ideally, the BULKOUT request size should *not* be the same size as the + * maxpacket size. That is because IN transfers of exactly the maxpacket + * size will be followed by a NULL packet. The BULKOUT request buffer + * size, on the other hand, is always the same as the maxpacket size. + */ + +#ifndef CONFIG_PL2303_BULKIN_REQLEN +# define CONFIG_PL2303_BULKIN_REQLEN 96 +#endif /* Vendor and product IDs and strings */ @@ -608,11 +616,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) /* Get the maximum number of bytes that will fit into one bulk IN request */ -#ifdef CONFIG_PL2303_BULKREQLEN - reqlen = MAX(CONFIG_PL2303_BULKREQLEN, ep->maxpacket); -#else - reqlen = ep->maxpacket; -#endif + reqlen = max(CONFIG_PL2303_BULKIN_REQLEN, ep->maxpacket); while (!sq_empty(&priv->reqlist)) { @@ -1222,12 +1226,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, /* Requeue the read request */ -#ifdef CONFIG_PL2303_BULKREQLEN - req->len = max(CONFIG_PL2303_BULKREQLEN, ep->maxpacket); -#else req->len = ep->maxpacket; -#endif - ret = EP_SUBMIT(ep, req); if (ret != OK) { @@ -1384,11 +1383,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate read requests */ -#ifdef CONFIG_PL2303_BULKREQLEN - reqlen = max(CONFIG_PL2303_BULKREQLEN, priv->epbulkout->maxpacket); -#else reqlen = priv->epbulkout->maxpacket; -#endif for (i = 0; i < CONFIG_PL2303_NRDREQS; i++) { @@ -1400,17 +1395,14 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, ret = -ENOMEM; goto errout; } + reqcontainer->req->priv = reqcontainer; reqcontainer->req->callback = usbclass_rdcomplete; } /* Pre-allocate write request containers and put in a free list */ -#ifdef CONFIG_PL2303_BULKREQLEN - reqlen = max(CONFIG_PL2303_BULKREQLEN, priv->epbulkin->maxpacket); -#else - reqlen = priv->epbulkin->maxpacket; -#endif + reqlen = max(CONFIG_PL2303_BULKIN_REQLEN, priv->epbulkin->maxpacket); for (i = 0; i < CONFIG_PL2303_NWRREQS; i++) { @@ -1422,6 +1414,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, ret = -ENOMEM; goto errout; } + reqcontainer->req->priv = reqcontainer; reqcontainer->req->callback = usbclass_wrcomplete; |