summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-05-29 12:30:37 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-05-29 12:30:37 -0600
commit888ff3f3c2b85d178a7c375807eb66ab3ab52872 (patch)
tree370760feb6255b0ab8577e66d5606562786c8548
parent26346bebfa749b55d1dd983c478d14c913eb9619 (diff)
downloadnuttx-888ff3f3c2b85d178a7c375807eb66ab3ab52872.tar.gz
nuttx-888ff3f3c2b85d178a7c375807eb66ab3ab52872.tar.bz2
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.
-rw-r--r--nuttx/configs/stm32f3discovery/README.txt4
-rw-r--r--nuttx/configs/stm32f4discovery/README.txt4
-rw-r--r--nuttx/drivers/usbdev/Kconfig48
-rw-r--r--nuttx/drivers/usbdev/cdcacm.c21
-rw-r--r--nuttx/drivers/usbdev/pl2303.c33
-rw-r--r--nuttx/include/nuttx/usb/cdcacm.h11
6 files changed, 64 insertions, 57 deletions
diff --git a/nuttx/configs/stm32f3discovery/README.txt b/nuttx/configs/stm32f3discovery/README.txt
index 12811b8a0..8477b797e 100644
--- a/nuttx/configs/stm32f3discovery/README.txt
+++ b/nuttx/configs/stm32f3discovery/README.txt
@@ -892,7 +892,7 @@ Where <subdir> is one of the following:
the standard CDC/ACM serial device by changing:
Drivers->USB Device Driver Support
- CONFIG_CDCACM=y : Disable the CDC/ACM serial device class
- CONFIG_CDCACM_CONSOLE=y : The CDC/ACM serial device is NOT the console
+ CONFIG_CDCACM=n : Disable the CDC/ACM serial device class
+ CONFIG_CDCACM_CONSOLE=n : The CDC/ACM serial device is NOT the console
CONFIG_PL2303=y : The Prolifics PL2303 emulation is enabled
CONFIG_PL2303_CONSOLE=y : The PL2303 serial device is the console
diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt
index e94bd466b..f3cd7901b 100644
--- a/nuttx/configs/stm32f4discovery/README.txt
+++ b/nuttx/configs/stm32f4discovery/README.txt
@@ -1676,8 +1676,8 @@ Where <subdir> is one of the following:
You could also use the non-standard PL2303 serial device instead of
the standard CDC/ACM serial device by changing:
- CONFIG_CDCACM=y : Disable the CDC/ACM serial device class
- CONFIG_CDCACM_CONSOLE=y : The CDC/ACM serial device is NOT the console
+ CONFIG_CDCACM=n : Disable the CDC/ACM serial device class
+ CONFIG_CDCACM_CONSOLE=n : The CDC/ACM serial device is NOT the console
CONFIG_PL2303=y : The Prolifics PL2303 emulation is enabled
CONFIG_PL2303_CONSOLE=y : The PL2303 serial device is the console
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;
diff --git a/nuttx/include/nuttx/usb/cdcacm.h b/nuttx/include/nuttx/usb/cdcacm.h
index 49dc4ee12..4e331b569 100644
--- a/nuttx/include/nuttx/usb/cdcacm.h
+++ b/nuttx/include/nuttx/usb/cdcacm.h
@@ -121,6 +121,10 @@
/* Endpoint number and size (in bytes) of the CDC device-to-host (IN) data
* bulk endpoint. NOTE that difference sizes may be selected for full (FS)
* or high speed (HS) modes.
+ *
+ * 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.
*/
#ifndef CONFIG_CDCACM_EPBULKIN
@@ -135,9 +139,16 @@
# define CONFIG_CDCACM_EPBULKIN_HSSIZE 512
#endif
+#ifndef CONFIG_CDCACM_BULKIN_REQLEN
+# define CONFIG_CDCACM_BULKIN_REQLEN 96
+#endif
+
/* Endpoint number and size (in bytes) of the CDC host-to-device (OUT) data
* bulk endpoint. NOTE that difference sizes may be selected for full (FS)
* or high speed (HS) modes.
+ *
+ * NOTE: The BULKOUT request buffer size is always the same as the
+ * maxpacket size.
*/
#ifndef CONFIG_CDCACM_EPBULKOUT