Zero-copy for STM32 MAC driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4985 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-12-29 09:22:37 +00:00
parent 76d8262f13
commit 5b3b5aa160
4 changed files with 28 additions and 8 deletions

View File

@ -35,6 +35,11 @@
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief This implementation does not support the zero-copy mode API.
*/
#define MAC_SUPPORTS_ZERO_COPY FALSE
#define EMAC_RECEIVE_BUFFERS_SIZE 128 /* Do not modify */ #define EMAC_RECEIVE_BUFFERS_SIZE 128 /* Do not modify */
#define EMAC_TRANSMIT_BUFFERS_SIZE MAC_BUFFERS_SIZE #define EMAC_TRANSMIT_BUFFERS_SIZE MAC_BUFFERS_SIZE
#define EMAC_RECEIVE_DESCRIPTORS \ #define EMAC_RECEIVE_DESCRIPTORS \

View File

@ -624,18 +624,26 @@ bool_t mac_lld_poll_link_status(MACDriver *macp) {
* on the first call then scale the value down subtracting * on the first call then scale the value down subtracting
* the amount of data already copied into the previous * the amount of data already copied into the previous
* buffers. * buffers.
* @param[out] sizep pointer to variable receiving the real buffer size. * @param[out] sizep pointer to variable receiving the buffer size, it is
* The returned value can be less than the amount * zero when the last buffer has already been returned.
* requested, this means that more buffers must be * Note that a returned size lower than the amount
* requested in order to fill the frame data entirely. * requested means that more buffers must be requested
* in order to fill the frame data entirely.
* @return Pointer to the returned buffer. * @return Pointer to the returned buffer.
* @retval NULL if the buffer chain has been entirely scanned.
* *
* @notapi * @notapi
*/ */
uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp, uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
size_t size, size_t size,
size_t *sizep) { size_t *sizep) {
(void)tdp; (void)size; (void)sizep;
if (tdp->offset == 0) {
*sizep = tdp->size;
tdp->offset = size;
return (uint8_t *)tdp->physdesc->tdes2;
}
*sizep = 0;
return NULL; return NULL;
} }
@ -655,7 +663,14 @@ uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
*/ */
const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp, const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp,
size_t *sizep) { size_t *sizep) {
(void)rdp; (void)sizep;
if (rdp->size > 0) {
*sizep = rdp->size;
rdp->offset = rdp->size;
rdp->size = 0;
return (uint8_t *)rdp->physdesc->rdes2;
}
*sizep = 0;
return NULL; return NULL;
} }
#endif /* MAC_USE_ZERO_COPY */ #endif /* MAC_USE_ZERO_COPY */

View File

@ -291,7 +291,6 @@ typedef struct {
* @brief Available space size. * @brief Available space size.
*/ */
size_t size; size_t size;
/* End of the mandatory fields.*/
/** /**
* @brief Pointer to the physical descriptor. * @brief Pointer to the physical descriptor.
*/ */
@ -310,7 +309,6 @@ typedef struct {
* @brief Available data size. * @brief Available data size.
*/ */
size_t size; size_t size;
/* End of the mandatory fields.*/
/** /**
* @brief Pointer to the physical descriptor. * @brief Pointer to the physical descriptor.
*/ */

View File

@ -90,6 +90,8 @@
(backported to 2.4.3). (backported to 2.4.3).
- FIX: Fixed wrong SPI path in platform_f105_f107.mk (bug 3598151). - FIX: Fixed wrong SPI path in platform_f105_f107.mk (bug 3598151).
- FIX: Fixed PHY powerdown issues not fixed (bug 3596911). - FIX: Fixed PHY powerdown issues not fixed (bug 3596911).
- NEW: Added zero-copy capability to the STM32 MAC driver (experimental and
not tested yet).
- NEW: Added an optional zero-copy mode API to the MAC driver model. - NEW: Added an optional zero-copy mode API to the MAC driver model.
- NEW: Added EXT driver to the STM32F3xx platform. - NEW: Added EXT driver to the STM32F3xx platform.
- NEW: Improved the STM32 EXT driver to support more than 32 channels. - NEW: Improved the STM32 EXT driver to support more than 32 channels.