remove (obsolete) TX buffer
This commit is contained in:
parent
14785b5e23
commit
6205ab74fe
1 changed files with 34 additions and 57 deletions
|
@ -85,8 +85,8 @@
|
|||
* regarding the driver & its configuration
|
||||
*/
|
||||
|
||||
#define MMNIF_TX_BUFFERLEN 2048
|
||||
#define MMNIF_TX_QUEUELEN 4
|
||||
//#define MMNIF_TX_BUFFERLEN 2048
|
||||
//#define MMNIF_TX_QUEUELEN 4
|
||||
|
||||
#define MMNIF_RX_BUFFERLEN 7*1024
|
||||
#define MMNIF_MAX_DESCRIPTORS 64
|
||||
|
@ -259,8 +259,8 @@ typedef struct mmnif {
|
|||
* - pointer to transmit buffer
|
||||
* - pointer to recive buffer
|
||||
*/
|
||||
uint8_t tx_queue;
|
||||
uint8_t *tx_buff[MMNIF_TX_QUEUELEN];
|
||||
//uint8_t tx_queue;
|
||||
//uint8_t *tx_buff[MMNIF_TX_QUEUELEN];
|
||||
mm_rx_buffer_t *rx_buff;
|
||||
uint8_t *rx_heap;
|
||||
|
||||
|
@ -600,54 +600,33 @@ static void mmnif_rxbuff_free(void)
|
|||
static err_t mmnif_tx(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
mmnif_t *mmnif = netif->state;
|
||||
uint8_t slot = mmnif->tx_queue;
|
||||
uint32_t write_address;
|
||||
//uint8_t slot = mmnif->tx_queue;
|
||||
size_t write_address;
|
||||
uint32_t i;
|
||||
struct pbuf *q; /* interator */
|
||||
uint8_t build_buff = TRUE;
|
||||
uint32_t dest_ip = mmnif_get_destination(netif, p);
|
||||
//uint8_t chances = 20;
|
||||
//mm_rx_buffer_t *rb = (mm_rx_buffer_t *) ((char *)header_start_address + (dest_ip - 1) * header_size);
|
||||
|
||||
spinlock_lock(&mmnif->lock);
|
||||
mmnif->tx_queue++;
|
||||
spinlock_unlock(&mmnif->lock);
|
||||
//spinlock_lock(&mmnif->lock);
|
||||
//mmnif->tx_queue++;
|
||||
//spinlock_unlock(&mmnif->lock);
|
||||
|
||||
/* Perform serveral sanity checks on the packet and the buffers:
|
||||
* - is the queue full?
|
||||
* - is the output packet to big?
|
||||
*/
|
||||
if (mmnif->tx_queue > MMNIF_TX_QUEUELEN)
|
||||
/*if (mmnif->tx_queue > MMNIF_TX_QUEUELEN)
|
||||
{
|
||||
DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n");
|
||||
goto drop_packet;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (p->tot_len > MMNIF_TX_BUFFERLEN)
|
||||
/*if (p->tot_len > MMNIF_TX_BUFFERLEN)
|
||||
{
|
||||
DEBUGPRINTF("mmnif_tx(): packet is longer than %d bytes\n", MMNIF_TX_BUFFERLEN);
|
||||
goto drop_packet;
|
||||
}
|
||||
|
||||
/* check if the pbuf consists only of one element
|
||||
* if that is the case it would be much overhead
|
||||
* copying that packet again
|
||||
*/
|
||||
if (!p->next)
|
||||
build_buff = FALSE;
|
||||
|
||||
if (build_buff)
|
||||
{
|
||||
|
||||
/* build the payload out of the p's
|
||||
* ensure that the packet is in one memory chunk stored in the transmid buffer
|
||||
*/
|
||||
for (q = p, i = 0; q != 0; q = q->next)
|
||||
{
|
||||
memcpy(mmnif->tx_buff[slot] + i, q->payload, q->len);
|
||||
i += q->len;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/* allocate memory for the packet in the remote buffer */
|
||||
realloc:
|
||||
|
@ -682,18 +661,16 @@ realloc:
|
|||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
|
||||
#endif
|
||||
if (build_buff)
|
||||
|
||||
for (q = p, i = 0; q != 0; q = q->next)
|
||||
{
|
||||
#if MMNIF_USE_MPB
|
||||
memcpy_put(write_address, mmnif->tx_buff[slot], CLINE_ALIGN(p->tot_len));
|
||||
memcpy_put((char*) write_address + i, q->payload, q->len);
|
||||
#else
|
||||
memcpy((void*)write_address, mmnif->tx_buff[slot], CLINE_ALIGN(p->tot_len));
|
||||
#endif
|
||||
else
|
||||
#if MMNIF_USE_MPB
|
||||
memcpy_put(write_address, p->payload, CLINE_ALIGN(p->tot_len));
|
||||
#else
|
||||
memcpy((void*)write_address, p->payload, CLINE_ALIGN(p->tot_len));
|
||||
memcpy((char*)write_address+ i, q->payload, q->len);
|
||||
#endif
|
||||
i += q->len;
|
||||
}
|
||||
|
||||
*((int *)RCCE_fool_write_combine_buffer) = 1;
|
||||
#if USE_CACHE
|
||||
|
@ -712,9 +689,9 @@ realloc:
|
|||
#endif
|
||||
|
||||
/* release the tx_queue because it's finished */
|
||||
spinlock_lock(&mmnif->lock);
|
||||
mmnif->tx_queue--;
|
||||
spinlock_unlock(&mmnif->lock);
|
||||
//spinlock_lock(&mmnif->lock);
|
||||
//mmnif->tx_queue--;
|
||||
//spinlock_unlock(&mmnif->lock);
|
||||
|
||||
/* just gather some stats */
|
||||
LINK_STATS_INC(link.xmit);
|
||||
|
@ -731,9 +708,9 @@ drop_packet:
|
|||
DEBUGPRINTF("mmnif_tx(): packet dropped");
|
||||
#endif
|
||||
|
||||
spinlock_lock(&mmnif->lock);
|
||||
mmnif->tx_queue--;
|
||||
spinlock_unlock(&mmnif->lock);
|
||||
//spinlock_lock(&mmnif->lock);
|
||||
//mmnif->tx_queue--;
|
||||
//spinlock_unlock(&mmnif->lock);
|
||||
LINK_STATS_INC(link.drop);
|
||||
mmnif->stats.tx_err++;
|
||||
|
||||
|
@ -1080,17 +1057,17 @@ err_t mmnif_init(struct netif *netif)
|
|||
|
||||
/* Alloc and clear internal memory for tx_buff
|
||||
*/
|
||||
mmnif->tx_buff[0] = kmalloc(MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
/*mmnif->tx_buff[0] = kmalloc(MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
if (!(mmnif->tx_buff[0]))
|
||||
{
|
||||
DEBUGPRINTF("mmnif init: out of memory tx\n");
|
||||
return ERR_MEM;
|
||||
}
|
||||
mmnif->tx_queue = 0;
|
||||
memset(mmnif->tx_buff[0], 0x00, MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
}*/
|
||||
//mmnif->tx_queue = 0;
|
||||
//memset(mmnif->tx_buff[0], 0x00, MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
|
||||
for (i=0; i<MMNIF_TX_QUEUELEN-1; i++)
|
||||
mmnif->tx_buff[i + 1] = mmnif->tx_buff[i] + MMNIF_TX_BUFFERLEN;
|
||||
//for (i=0; i<MMNIF_TX_QUEUELEN-1; i++)
|
||||
// mmnif->tx_buff[i + 1] = mmnif->tx_buff[i] + MMNIF_TX_BUFFERLEN;
|
||||
|
||||
for (i=0; i<MMNIF_HASHTABLE_SIZE; i++)
|
||||
{
|
||||
|
@ -1133,7 +1110,7 @@ err_t mmnif_init(struct netif *netif)
|
|||
netif->linkoutput = mmnif_tx;
|
||||
|
||||
/* maximum transfer unit */
|
||||
netif->mtu = MMNIF_TX_BUFFERLEN;
|
||||
netif->mtu = 1500; //MMNIF_TX_BUFFERLEN;
|
||||
|
||||
/* broadcast capability, keep all default flags */
|
||||
netif->flags |= NETIF_FLAG_BROADCAST;
|
||||
|
@ -1704,7 +1681,7 @@ err_t mmnif_shutdown(void)
|
|||
|
||||
err = netifapi_netif_set_down(mmnif_dev);
|
||||
|
||||
kfree(mmnif->tx_buff[0], MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
//kfree(mmnif->tx_buff[0], MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN);
|
||||
//RCCE_shfree(mpb_start_address);
|
||||
mmnif_dev = NULL;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue