And more network clean-ups and fixes.
This commit is contained in:
@@ -105,7 +105,6 @@ extern netdev_t network_devs[32];
|
||||
|
||||
/* Function prototypes. */
|
||||
extern void network_wait(uint8_t wait);
|
||||
extern void network_poll(void);
|
||||
extern void network_busy(uint8_t set);
|
||||
extern void network_end(void);
|
||||
|
||||
@@ -115,7 +114,6 @@ extern void network_close(void);
|
||||
extern void network_reset(void);
|
||||
extern int network_available(void);
|
||||
extern void network_tx(uint8_t *, int);
|
||||
extern void network_do_tx(void);
|
||||
extern int network_tx_queue_check(void);
|
||||
|
||||
extern int net_pcap_prepare(netdev_t *);
|
||||
|
@@ -180,11 +180,6 @@ poll_thread(void *arg)
|
||||
/* Request ownership of the device. */
|
||||
network_wait(1);
|
||||
|
||||
#if 0
|
||||
/* Wait for a poll request. */
|
||||
network_poll();
|
||||
#endif
|
||||
|
||||
if (pcap == NULL) {
|
||||
network_wait(0);
|
||||
break;
|
||||
@@ -211,12 +206,9 @@ poll_thread(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for the next packet to arrive. */
|
||||
/* Wait for the next packet to arrive - network_do_tx() is called from there. */
|
||||
tx = network_tx_queue_check();
|
||||
|
||||
if (tx)
|
||||
network_do_tx();
|
||||
|
||||
/* Release ownership of the device. */
|
||||
network_wait(0);
|
||||
|
||||
|
@@ -362,11 +362,6 @@ poll_thread(void *arg)
|
||||
/* Request ownership of the queue. */
|
||||
network_wait(1);
|
||||
|
||||
#if 0
|
||||
/* Wait for a poll request. */
|
||||
network_poll();
|
||||
#endif
|
||||
|
||||
/* Stop processing if asked to. */
|
||||
if (slirp->stop) {
|
||||
network_wait(0);
|
||||
@@ -376,12 +371,9 @@ poll_thread(void *arg)
|
||||
/* See if there is any work. */
|
||||
slirp_tic(slirp);
|
||||
|
||||
/* Wait for the next packet to arrive. */
|
||||
/* Wait for the next packet to arrive - network_do_tx() is called from there. */
|
||||
tx = network_tx_queue_check();
|
||||
|
||||
if (tx)
|
||||
network_do_tx();
|
||||
|
||||
/* Release ownership of the queue. */
|
||||
network_wait(0);
|
||||
|
||||
|
@@ -120,8 +120,8 @@ static mutex_t *network_mutex;
|
||||
static uint8_t *network_mac;
|
||||
static uint8_t network_timer_active = 0;
|
||||
static pc_timer_t network_rx_queue_timer;
|
||||
static netpkt_t *first_pkt[2] = { NULL, NULL },
|
||||
*last_pkt[2] = { NULL, NULL };
|
||||
static netpkt_t *first_pkt[3] = { NULL, NULL, NULL },
|
||||
*last_pkt[3] = { NULL, NULL, NULL };
|
||||
|
||||
|
||||
static struct {
|
||||
@@ -201,20 +201,6 @@ network_wait(uint8_t wait)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
network_poll(void)
|
||||
{
|
||||
network_wait(0);
|
||||
|
||||
while (poll_data.busy)
|
||||
thread_wait_event(poll_data.wake_poll_thread, -1);
|
||||
|
||||
network_wait(1);
|
||||
|
||||
thread_reset_event(poll_data.wake_poll_thread);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
network_busy(uint8_t set)
|
||||
{
|
||||
@@ -359,7 +345,7 @@ network_rx_queue(void *priv)
|
||||
return;
|
||||
}
|
||||
|
||||
network_busy(1);
|
||||
// network_busy(1);
|
||||
|
||||
network_queue_get(0, &pkt);
|
||||
if ((pkt != NULL) && (pkt->len > 0)) {
|
||||
@@ -374,7 +360,11 @@ network_rx_queue(void *priv)
|
||||
if (ret)
|
||||
network_queue_advance(0);
|
||||
|
||||
network_busy(0);
|
||||
/* Transmission. */
|
||||
network_queue_get(2, &pkt);
|
||||
network_queue_put(1, pkt->priv, pkt->data, pkt->len);
|
||||
|
||||
// network_busy(0);
|
||||
|
||||
network_wait(0);
|
||||
}
|
||||
@@ -416,8 +406,8 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST
|
||||
break;
|
||||
}
|
||||
|
||||
first_pkt[0] = first_pkt[1] = NULL;
|
||||
last_pkt[0] = last_pkt[1] = NULL;
|
||||
first_pkt[0] = first_pkt[1] = first_pkt[2] = NULL;
|
||||
last_pkt[0] = last_pkt[1] = last_pkt[2] = NULL;
|
||||
memset(&network_rx_queue_timer, 0x00, sizeof(pc_timer_t));
|
||||
timer_add(&network_rx_queue_timer, network_rx_queue, NULL, 0);
|
||||
/* 10 mbps. */
|
||||
@@ -555,7 +545,7 @@ network_tx(uint8_t *bufp, int len)
|
||||
|
||||
ui_sb_update_icon(SB_NETWORK, 1);
|
||||
|
||||
network_queue_put(1, NULL, bufp, len);
|
||||
network_queue_put(2, NULL, bufp, len);
|
||||
|
||||
ui_sb_update_icon(SB_NETWORK, 0);
|
||||
|
||||
@@ -564,13 +554,16 @@ network_tx(uint8_t *bufp, int len)
|
||||
|
||||
|
||||
/* Actually transmit the packet. */
|
||||
void
|
||||
network_do_tx(void)
|
||||
int
|
||||
network_tx_queue_check(void)
|
||||
{
|
||||
netpkt_t *pkt = NULL;
|
||||
|
||||
if ((first_pkt[1] == NULL) && (last_pkt[1] == NULL))
|
||||
return 0;
|
||||
|
||||
if (network_tx_pause)
|
||||
return;
|
||||
return 1;
|
||||
|
||||
network_queue_get(1, &pkt);
|
||||
if ((pkt != NULL) && (pkt->len > 0)) {
|
||||
@@ -586,15 +579,6 @@ network_do_tx(void)
|
||||
}
|
||||
}
|
||||
network_queue_advance(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
network_tx_queue_check(void)
|
||||
{
|
||||
if ((first_pkt[1] == NULL) && (last_pkt[1] == NULL))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user