diff options
author | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 12:07:39 +0000 |
---|---|---|
committer | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 12:07:39 +0000 |
commit | 985c5269d14c5a8a17cd457c4fc643306011c2a7 (patch) | |
tree | cb424d7750a0b87a418a08b32f9e1e5e7be6f393 | |
parent | 9a114ea452c413285fcc47caf4d10cf4e5a22442 (diff) | |
download | clock-985c5269d14c5a8a17cd457c4fc643306011c2a7.tar.gz clock-985c5269d14c5a8a17cd457c4fc643306011c2a7.tar.bz2 clock-985c5269d14c5a8a17cd457c4fc643306011c2a7.zip |
handle non contiguous frames on ethernet transmit
-rw-r--r-- | app/steth.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/app/steth.c b/app/steth.c index e861606..9245d17 100644 --- a/app/steth.c +++ b/app/steth.c @@ -173,15 +173,42 @@ phy_link_an_done (uint8_t phy) } +static bool eth_tx_pbuf (struct pbuf *p) +{ + uint8_t *buf, *ptr; + uint32_t len; + + if (ETH_DES0 (TxBD) & ETH_TDES0_OWN) + return false; + + buf = (void *)ETH_DES2 (TxBD); + + + for (len = 0, ptr = buf; p; p = p->next) { + memcpy (ptr, p->payload, p->len); + ptr += p->len; + len += p->len; + } + + ETH_DES1 (TxBD) = len & ETH_TDES1_TBS1; + ETH_DES0 (TxBD) |= ETH_TDES0_LS | ETH_TDES0_FS | ETH_TDES0_OWN; + TxBD = ETH_DES3 (TxBD); + + if (ETH_DMASR & ETH_DMASR_TBUS) { + ETH_DMASR = ETH_DMASR_TBUS; + ETH_DMATPDR = 0; + } + + return true; +} + + static err_t steth_tx (struct netif *netif, struct pbuf *p) { unsigned tries = 3; - if (p->next) return ERR_IF; - - - while (!eth_tx (p->payload, p->len)) { + while (!eth_tx_pbuf (p)) { delay_us (10); if (! (tries--)) return ERR_IF; @@ -191,7 +218,6 @@ steth_tx (struct netif *netif, struct pbuf *p) return ERR_OK; } - static bool eth_rx_ptp (uint8_t *ppkt, uint32_t *len, uint32_t maxlen, uint64_t *tstamp) { bool fs = false; |