9
0
Fork 0

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.

This commit is contained in:
Gregory Nutt 2013-05-29 12:30:37 -06:00
parent 26346bebfa
commit 888ff3f3c2
6 changed files with 64 additions and 57 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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++)
{

View File

@ -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;

View File

@ -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