aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/include/mac.h53
-rw-r--r--os/hal/platforms/STM32/mac_lld.c5
2 files changed, 51 insertions, 7 deletions
diff --git a/os/hal/include/mac.h b/os/hal/include/mac.h
index 6f70aff44..2903bd07c 100644
--- a/os/hal/include/mac.h
+++ b/os/hal/include/mac.h
@@ -121,17 +121,58 @@ typedef struct MACDriver MACDriver;
/**
* @brief Reads from a receive descriptor's stream.
*
- * @param[in] rdp pointer to a @p MACReceiveDescriptor structure
- * @param[in] buf pointer to the buffer that will receive the read data
- * @param[in] size number of bytes to be read
- * @return The number of bytes read from the descriptor's stream, this
- * value can be less than the amount specified in the
- * parameter @p size if there are no more bytes to read.
+ * @param[in] rdp pointer to a @p MACReceiveDescriptor structure
+ * @param[in] buf pointer to the buffer that will receive the read data
+ * @param[in] size number of bytes to be read
+ * @return The number of bytes read from the descriptor's stream,
+ * this value can be less than the amount specified in the
+ * parameter @p size if there are no more bytes to read.
*
* @api
*/
#define macReadReceiveDescriptor(rdp, buf, size) \
mac_lld_read_receive_descriptor(rdp, buf, size)
+
+#if MAC_SUPPORTS_ZERO_COPY || defined(__DOXYGEN__)
+/**
+ * @brief Returns a pointer to the next transmit buffer in the descriptor
+ * chain.
+ * @note The API guarantees that enough buffers can be requested to fill
+ * a whole frame.
+ *
+ * @param[in] tdp pointer to a @p MACTransmitDescriptor structure
+ * @param[in] size size of the requested buffer. Specify the frame size
+ * 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.
+ * @return Pointer to the returned buffer.
+ *
+ * @api
+ */
+#define macGetNextTransmitBuffer(tdp, size, sizep) \
+ mac_lld_get_next_transmit_buffer(tdp, bufp)
+
+/**
+ * @brief Returns a pointer to the next receive buffer in the descriptor
+ * chain.
+ * @note The API guarantees that the descriptor chain contains a whole
+ * frame.
+ *
+ * @param[in] rdp pointer to a @p MACReceiveDescriptor structure
+ * @param[out] sizep pointer to variable receiving the buffer size, it is
+ * zero when the last buffer has already been returned.
+ * @return Pointer to the returned buffer.
+ * @retval NULL if the buffer chain has been entirely scanned.
+ *
+ * @api
+ */
+#define magGetNextReceiveBuffer(rdp, sizep) \
+ mac_lld_get_next_receive_buffer(rdp, sizep)
+#endif /* MAC_SUPPORTS_ZERO_COPY */
/** @} */
/*===========================================================================*/
diff --git a/os/hal/platforms/STM32/mac_lld.c b/os/hal/platforms/STM32/mac_lld.c
index 36620b934..3721670f9 100644
--- a/os/hal/platforms/STM32/mac_lld.c
+++ b/os/hal/platforms/STM32/mac_lld.c
@@ -536,9 +536,12 @@ msg_t mac_lld_get_receive_descriptor(MACDriver *macp,
}
/* Invalid frame found, purging.*/
rdes->rdes0 = STM32_RDES0_OWN;
- rdes = macp->rxptr = (stm32_eth_rx_descriptor_t *)rdes->rdes3;
+ rdes = (stm32_eth_rx_descriptor_t *)rdes->rdes3;
}
+ /* Next descriptor to check.*/
+ macp->rxptr = rdes;
+
chSysUnlock();
return RDY_TIMEOUT;
}