[riot-notifications] [RIOT-OS/RIOT] drivers/stm32_eth: add RX timestamps (#15610)

Marian Buschsieweke notifications at github.com
Tue Jan 12 20:34:06 CET 2021


@maribu commented on this pull request.



> +        if (rx_curr->status & RX_DESC_STAT_LS) {
+            if (IS_USED(MODULE_PERIPH_PTP)) {
+                info->timestamp = rx_curr->ts_low;
+                info->timestamp += (uint64_t)rx_curr->ts_high * NS_PER_SEC;
+                info->flags |= NETDEV_ETH_RX_INFO_FLAG_TIMESTAMP;
+            }
+            rx_curr->status = RX_DESC_STAT_OWN;
+            rx_curr = rx_curr->desc_next;
+            break;
+        }
         rx_curr->status = RX_DESC_STAT_OWN;
         rx_curr = rx_curr->desc_next;

It is not so trivial. There are some special cases:

- When the CRC sum didn't fit in the last descriptor used for the Ethernet SDU, one additional descriptor is used to store the (remaining bytes of the) CRC sum. Hence, one descriptor more needs to be freed than was copied
- The timestamp needs to be taken from the last descriptor *before* it is passed on to the DMA

It would however be nice to free each descriptor after the data is fetched, as this would result in better handling of traffic bursts. (The DMA sooner gets the descriptors back, which decreases the chance of frames being dropped.) I will give it a second look on whether I manage to implement this more elegant.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15610#discussion_r556026753
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210112/62c1fea0/attachment-0001.htm>


More information about the notifications mailing list