network: support > 10Mbps throughput

This commit is contained in:
Adrien Moulin
2022-08-27 17:08:50 +02:00
parent 9c65d20621
commit c0b6c55926
3 changed files with 13 additions and 3 deletions

View File

@@ -62,6 +62,9 @@
#define NET_CARD_MAX 4
#define NET_HOST_INTF_MAX 64
#define NET_PERIOD_10M 0.8
#define NET_PERIOD_100M 0.08
/* Supported network cards. */
enum {
NONE = 0,
@@ -128,6 +131,7 @@ struct _netcard_t {
mutex_t *rx_mutex;
pc_timer_t timer;
int card_num;
double byte_period;
};
typedef struct {

View File

@@ -2025,11 +2025,15 @@ pcnet_bcr_writew(nic_t *dev, uint16_t rap, uint16_t val)
case BCR_BSBC:
case BCR_EECAS:
case BCR_PLAT:
case BCR_MIICAS:
case BCR_MIIADDR:
dev->aBCR[rap] = val;
break;
case BCR_MIICAS:
dev->netcard->byte_period = (dev->board == DEV_AM79C973 && (val & 0x28)) ? NET_PERIOD_100M : NET_PERIOD_10M;
dev->aBCR[rap] = val;
break;
case BCR_STVAL:
val &= 0xffff;
dev->aBCR[BCR_STVAL] = val;
@@ -3055,6 +3059,7 @@ pcnet_init(const device_t *info)
/* Attach ourselves to the network module. */
dev->netcard = network_attach(dev, dev->aPROM, pcnetReceiveNoSync, pcnetWaitReceiveAvail, pcnetSetLinkState);
dev->netcard->byte_period = (dev->board == DEV_AM79C973) ? NET_PERIOD_100M : NET_PERIOD_10M;
timer_add(&dev->timer, pcnetPollTimer, dev, 0);

View File

@@ -379,7 +379,7 @@ network_rx_queue(void *priv)
card->host_drv.notify_in(card->host_drv.priv);
}
double timer_period = 0.762939453125 * (rx_bytes > tx_bytes ? rx_bytes : tx_bytes);
double timer_period = card->byte_period * (rx_bytes > tx_bytes ? rx_bytes : tx_bytes);
if (timer_period < 200)
timer_period = 200;
@@ -409,6 +409,7 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETL
card->tx_mutex = thread_create_mutex();
card->rx_mutex = thread_create_mutex();
card->card_num = net_card_current;
card->byte_period = NET_PERIOD_10M;
for (int i=0; i<3; i++) {
network_queue_init(&card->queues[i]);
@@ -440,7 +441,7 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETL
}
timer_add(&card->timer, network_rx_queue, card, 0);
timer_on_auto(&card->timer, 0.762939453125 * 2.0);
timer_on_auto(&card->timer, 100);
return card;
}