Skip to content

Commit

Permalink
Improve 10BASE-T operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Oct 22, 2024
1 parent 5105d4a commit 67200c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions lwip/netif/w5500if.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ struct w5500if {
u16 txQueue[W5500_TX_QUEUELEN + 1];
u16 rxQueue;
lwpq_t unlockQueue;
lwpq_t syncQueue;
struct eth_addr *ethaddr;
};

Expand Down Expand Up @@ -488,6 +489,8 @@ static s32 ExiHandler(s32 chan, s32 dev)
W5500_WriteReg(chan, W5500_S0_CR, W5500_Sn_CR_SEND);
}
}

LWP_ThreadSignal(w5500if->syncQueue);
}

if (ir & W5500_Sn_IR_RECV) {
Expand Down Expand Up @@ -646,10 +649,12 @@ static err_t w5500_output(struct netif *netif, struct pbuf *p)
return ERR_CONN;
}

if (w5500if->txQueued < 0 || w5500if->txQueued >= W5500_TX_QUEUELEN ||
while (w5500if->txQueued < 0 || w5500if->txQueued >= W5500_TX_QUEUELEN ||
(u16)(w5500if->txQueue[w5500if->txQueued] - w5500if->txQueue[0]) > (W5500_TX_BUFSIZE - p->tot_len)) {
IRQ_Restore(level);
return ERR_IF;
if (LWP_ThreadSleep(w5500if->syncQueue)) {
IRQ_Restore(level);
return ERR_IF;
}
}

while (!EXI_Lock(chan, dev, UnlockedHandler))
Expand Down Expand Up @@ -697,6 +702,7 @@ err_t w5500if_init(struct netif *netif)
netif->flags = NETIF_FLAG_BROADCAST;

LWP_InitQueue(&w5500if->unlockQueue);
LWP_InitQueue(&w5500if->syncQueue);

w5500if->ethaddr = (struct eth_addr *)netif->hwaddr;
w5500_netif = netif;
Expand All @@ -721,6 +727,7 @@ err_t w5500if_init(struct netif *netif)
}
}

LWP_CloseQueue(w5500if->syncQueue);
LWP_CloseQueue(w5500if->unlockQueue);

mem_free(w5500if);
Expand Down
13 changes: 10 additions & 3 deletions lwip/netif/w6100if.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ struct w6100if {
u16 txQueue[W6100_TX_QUEUELEN + 1];
u16 rxQueue;
lwpq_t unlockQueue;
lwpq_t syncQueue;
struct eth_addr *ethaddr;
};

Expand Down Expand Up @@ -844,6 +845,8 @@ static s32 ExiHandler(s32 chan, s32 dev)
W6100_WriteReg(chan, W6100_S0_CR, W6100_Sn_CR_SEND);
}
}

LWP_ThreadSignal(w6100if->syncQueue);
}

if (ir & W6100_Sn_IR_RECV) {
Expand Down Expand Up @@ -1006,10 +1009,12 @@ static err_t w6100_output(struct netif *netif, struct pbuf *p)
return ERR_CONN;
}

if (w6100if->txQueued < 0 || w6100if->txQueued >= W6100_TX_QUEUELEN ||
while (w6100if->txQueued < 0 || w6100if->txQueued >= W6100_TX_QUEUELEN ||
(u16)(w6100if->txQueue[w6100if->txQueued] - w6100if->txQueue[0]) > (W6100_TX_BUFSIZE - p->tot_len)) {
IRQ_Restore(level);
return ERR_IF;
if (LWP_ThreadSleep(w6100if->syncQueue)) {
IRQ_Restore(level);
return ERR_IF;
}
}

while (!EXI_Lock(chan, dev, UnlockedHandler))
Expand Down Expand Up @@ -1057,6 +1062,7 @@ err_t w6100if_init(struct netif *netif)
netif->flags = NETIF_FLAG_BROADCAST;

LWP_InitQueue(&w6100if->unlockQueue);
LWP_InitQueue(&w6100if->syncQueue);

w6100if->ethaddr = (struct eth_addr *)netif->hwaddr;
w6100_netif = netif;
Expand All @@ -1081,6 +1087,7 @@ err_t w6100if_init(struct netif *netif)
}
}

LWP_CloseQueue(w6100if->syncQueue);
LWP_CloseQueue(w6100if->unlockQueue);

mem_free(w6100if);
Expand Down

0 comments on commit 67200c9

Please sign in to comment.