aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-29 09:22:37 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-29 09:22:37 +0000
commit5b3b5aa16024ab417c2d8cea5dc693ea71be3638 (patch)
tree64f7967fb715a9041a13cc87158fb44ec6029fd6 /os/hal/platforms
parent76d8262f134d41c05adda7edb27d9868ca847941 (diff)
downloadChibiOS-5b3b5aa16024ab417c2d8cea5dc693ea71be3638.tar.gz
ChibiOS-5b3b5aa16024ab417c2d8cea5dc693ea71be3638.tar.bz2
ChibiOS-5b3b5aa16024ab417c2d8cea5dc693ea71be3638.zip
Zero-copy for STM32 MAC driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4985 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/AT91SAM7/mac_lld.h5
-rw-r--r--os/hal/platforms/STM32/mac_lld.c27
-rw-r--r--os/hal/platforms/STM32/mac_lld.h2
3 files changed, 26 insertions, 8 deletions
diff --git a/os/hal/platforms/AT91SAM7/mac_lld.h b/os/hal/platforms/AT91SAM7/mac_lld.h
index 33613b45d..475180c9d 100644
--- a/os/hal/platforms/AT91SAM7/mac_lld.h
+++ b/os/hal/platforms/AT91SAM7/mac_lld.h
@@ -35,6 +35,11 @@
/* 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_TRANSMIT_BUFFERS_SIZE MAC_BUFFERS_SIZE
#define EMAC_RECEIVE_DESCRIPTORS \
diff --git a/os/hal/platforms/STM32/mac_lld.c b/os/hal/platforms/STM32/mac_lld.c
index 25a5155ee..9573e991f 100644
--- a/os/hal/platforms/STM32/mac_lld.c
+++ b/os/hal/platforms/STM32/mac_lld.c
@@ -624,18 +624,26 @@ bool_t mac_lld_poll_link_status(MACDriver *macp) {
* on the first call then scale the value down subtracting
* the amount of data already copied into the previous
* buffers.
- * @param[out] sizep pointer to variable receiving the real buffer size.
- * The returned value can be less than the amount
- * requested, this means that more buffers must be
- * requested in order to fill the frame data entirely.
+ * @param[out] sizep pointer to variable receiving the buffer size, it is
+ * zero when the last buffer has already been returned.
+ * Note that a returned size lower than the amount
+ * requested means that more buffers must be requested
+ * in order to fill the frame data entirely.
* @return Pointer to the returned buffer.
+ * @retval NULL if the buffer chain has been entirely scanned.
*
* @notapi
*/
uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
size_t size,
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;
}
@@ -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,
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;
}
#endif /* MAC_USE_ZERO_COPY */
diff --git a/os/hal/platforms/STM32/mac_lld.h b/os/hal/platforms/STM32/mac_lld.h
index 59c39ac17..f765f1699 100644
--- a/os/hal/platforms/STM32/mac_lld.h
+++ b/os/hal/platforms/STM32/mac_lld.h
@@ -291,7 +291,6 @@ typedef struct {
* @brief Available space size.
*/
size_t size;
- /* End of the mandatory fields.*/
/**
* @brief Pointer to the physical descriptor.
*/
@@ -310,7 +309,6 @@ typedef struct {
* @brief Available data size.
*/
size_t size;
- /* End of the mandatory fields.*/
/**
* @brief Pointer to the physical descriptor.
*/