diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-12-28 15:15:09 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-12-28 15:15:09 +0000 |
commit | 22dcca914b67892038958a03b527ca9df25ac916 (patch) | |
tree | 92bbb71680bed5bb61da242e1b325d1479fca679 /os/hal | |
parent | 17d265e3bac954e0e934bc528afa8de1ba1f1b60 (diff) | |
download | ChibiOS-22dcca914b67892038958a03b527ca9df25ac916.tar.gz ChibiOS-22dcca914b67892038958a03b527ca9df25ac916.tar.bz2 ChibiOS-22dcca914b67892038958a03b527ca9df25ac916.zip |
MAC API tentative extension, small improvement to STM32 MAC driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4983 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/include/mac.h | 53 | ||||
-rw-r--r-- | os/hal/platforms/STM32/mac_lld.c | 5 |
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;
}
|