mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
cpu/sam0_eth: fix return values of sam0_eth_send()
This commit is contained in:
parent
a86411b81e
commit
4eb1c35fe3
@ -217,45 +217,42 @@ void sam0_eth_get_mac(eui48_t *out)
|
|||||||
|
|
||||||
int sam0_eth_send(const struct iolist *iolist)
|
int sam0_eth_send(const struct iolist *iolist)
|
||||||
{
|
{
|
||||||
unsigned len = iolist_size(iolist);
|
|
||||||
unsigned tx_len = 0;
|
unsigned tx_len = 0;
|
||||||
tx_curr = &tx_desc[tx_idx];
|
tx_curr = &tx_desc[tx_idx];
|
||||||
|
|
||||||
if (_is_sleeping) {
|
if (_is_sleeping) {
|
||||||
return -ENOTSUP;
|
return -ENETDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load packet data into TX buffer */
|
/* load packet data into TX buffer */
|
||||||
for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
|
for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
|
||||||
if (tx_len + iol->iol_len > ETHERNET_MAX_LEN) {
|
if (tx_len + iol->iol_len > ETHERNET_MAX_LEN) {
|
||||||
return -EBUSY;
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
if (iol->iol_len) {
|
if (iol->iol_len) {
|
||||||
memcpy ((uint32_t*)(tx_curr->address + tx_len), iol->iol_base, iol->iol_len);
|
memcpy ((uint32_t*)(tx_curr->address + tx_len), iol->iol_base, iol->iol_len);
|
||||||
tx_len += iol->iol_len;
|
tx_len += iol->iol_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len == tx_len) {
|
|
||||||
/* Clear and set the frame size */
|
/* Clear and set the frame size */
|
||||||
tx_curr->status = (len & DESC_TX_STATUS_LEN_MASK)
|
tx_curr->status = (tx_len & DESC_TX_STATUS_LEN_MASK)
|
||||||
/* Indicate this is the last buffer and the frame is ready */
|
/* Indicate this is the last buffer and the frame is ready */
|
||||||
| DESC_TX_STATUS_LAST_BUF;
|
| DESC_TX_STATUS_LAST_BUF;
|
||||||
/* Prepare next buffer index */
|
/* Prepare next buffer index */
|
||||||
if (++tx_idx == ETH_TX_BUFFER_COUNT) {
|
if (++tx_idx == ETH_TX_BUFFER_COUNT) {
|
||||||
/* Set WRAP flag to indicate last buffer */
|
/* Set WRAP flag to indicate last buffer */
|
||||||
tx_curr->status |= DESC_TX_STATUS_WRAP;
|
tx_curr->status |= DESC_TX_STATUS_WRAP;
|
||||||
tx_idx = 0;
|
tx_idx = 0;
|
||||||
}
|
|
||||||
__DMB();
|
|
||||||
/* Start transmission */
|
|
||||||
GMAC->NCR.reg |= GMAC_NCR_TSTART;
|
|
||||||
/* Set the next buffer */
|
|
||||||
tx_curr = &tx_desc[tx_idx];
|
|
||||||
}
|
}
|
||||||
else {
|
__DMB();
|
||||||
DEBUG("Mismatch TX len, abort send\n");
|
|
||||||
}
|
/* Start transmission */
|
||||||
return len;
|
GMAC->NCR.reg |= GMAC_NCR_TSTART;
|
||||||
|
/* Set the next buffer */
|
||||||
|
tx_curr = &tx_desc[tx_idx];
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned _sam0_eth_get_last_len(void)
|
unsigned _sam0_eth_get_last_len(void)
|
||||||
|
@ -197,15 +197,8 @@ static int _sam0_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
|
|
||||||
static int _sam0_eth_send(netdev_t *netdev, const iolist_t *iolist)
|
static int _sam0_eth_send(netdev_t *netdev, const iolist_t *iolist)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED);
|
netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED);
|
||||||
ret = sam0_eth_send(iolist);
|
return sam0_eth_send(iolist);
|
||||||
if (ret == -EOVERFLOW) {
|
|
||||||
/* TODO: use a specific netdev callback here ? */
|
|
||||||
return -EOVERFLOW;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sam0_eth_confirm_send(netdev_t *netdev, void *info)
|
static int _sam0_eth_confirm_send(netdev_t *netdev, void *info)
|
||||||
|
Loading…
Reference in New Issue
Block a user