some code clean ups
This commit is contained in:
parent
498654447c
commit
4285fd5287
1 changed files with 30 additions and 44 deletions
|
@ -389,13 +389,13 @@ void mmnif_print_driver_status(void)
|
|||
for (i = 0; i < MMNIF_MAX_DESCRIPTORS; i++)
|
||||
{
|
||||
if (mmnif->rx_buff->desc_table[i].stat != 0)
|
||||
DEBUGPRINTF("0x%.2X\t0x%p\t%X\t\n",
|
||||
DEBUGPRINTF("0x%.2X\t%p\t%X\t\n",
|
||||
mmnif->rx_buff->desc_table[i].stat,
|
||||
mmnif->rx_buff->desc_table[i].addr,
|
||||
mmnif->rx_buff->desc_table[i].len);
|
||||
}
|
||||
DEBUGPRINTF("\n\nretrive via interrupt : %d\n", mmnif->rx_buff->iv_intr);
|
||||
DEBUGPRINTF("ring heap start addr: 0x%p\n", mmnif->rx_buff + sizeof(mm_rx_buffer_t));
|
||||
DEBUGPRINTF("ring heap start addr: %p\n", mmnif->rx_buff + sizeof(mm_rx_buffer_t));
|
||||
DEBUGPRINTF("head: 0x%X\ttail: 0x%X\n", mmnif->rx_buff->head, mmnif->rx_buff->tail);
|
||||
mmnif_print_stats();
|
||||
}
|
||||
|
@ -728,7 +728,6 @@ realloc:
|
|||
#if USE_CACHE
|
||||
#if MMNIF_USE_MPB
|
||||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
|
||||
#endif
|
||||
#endif
|
||||
if (mmnif_commit_packet(dest_ip, write_address))
|
||||
|
@ -736,7 +735,7 @@ realloc:
|
|||
DEBUGPRINTF("mmnif_tx(): packet somehow lost during commit\n");
|
||||
}
|
||||
#ifdef DEBUG_MMNIF_PACKET
|
||||
// DEBUGPRINTF("\n SEND 0x%p with length: %d\n",(char*)heap_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2);
|
||||
// DEBUGPRINTF("\n SEND %p with length: %d\n",(char*)heap_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2);
|
||||
// hex_dump(p->tot_len, p->payload);
|
||||
#endif
|
||||
|
||||
|
@ -898,7 +897,6 @@ realloc:
|
|||
#if USE_CACHE
|
||||
#if MMNIF_USE_MPB
|
||||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
|
||||
#endif
|
||||
#endif
|
||||
if (mmnif_commit_packet_bypass(dest->dest_ip, write_address, dest->remote_socket))
|
||||
|
@ -906,7 +904,7 @@ realloc:
|
|||
DEBUGPRINTF("mmnif_tx(): packet somehow lost during commit\n");
|
||||
}
|
||||
#ifdef DEBUG_MMNIF_PACKET
|
||||
// DEBUGPRINTF("\n SEND 0x%p with length: %d\n",(char*)mpb_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2);
|
||||
// DEBUGPRINTF("\n SEND %p with length: %d\n",(char*)mpb_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2);
|
||||
// hex_dump(p->tot_len, p->payload);
|
||||
#endif
|
||||
|
||||
|
@ -1001,16 +999,16 @@ err_t mmnif_init(struct netif *netif)
|
|||
/* Alloc and clear shared memory for rx_buff
|
||||
*/
|
||||
header_size = (sizeof(mm_rx_buffer_t));
|
||||
DEBUGPRINTF("mmnif_init() : size of mm_rx_buffer_t : %d", sizeof(mm_rx_buffer_t));
|
||||
DEBUGPRINTF("mmnif_init() : size of mm_rx_buffer_t : %d\n", sizeof(mm_rx_buffer_t));
|
||||
|
||||
// align mpb size to the granularity of a page size
|
||||
header_size = (header_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
|
||||
header_start_address = (void*) RCCE_shmalloc(header_size * MMNIF_CORES);
|
||||
DEBUGPRINTF("RCCE_shmalloc : 0x%p", header_start_address);
|
||||
DEBUGPRINTF("RCCE_shmalloc : %p\n", header_start_address);
|
||||
|
||||
// map physical address in the virtual address space
|
||||
header_start_address = (void*) map_region(0, (size_t) header_start_address, (MMNIF_CORES * header_size) >> PAGE_SHIFT, MAP_KERNEL_SPACE | MAP_NO_CACHE);
|
||||
DEBUGPRINTF("map_region : 0x%p", header_start_address);
|
||||
DEBUGPRINTF("map_region : %p\n", header_start_address);
|
||||
mmnif->rx_buff = (mm_rx_buffer_t *) (header_start_address + (header_size) * (own_ip_address - router_ip_address));
|
||||
|
||||
/* Alloc and clear shared memory for rx_buff
|
||||
|
@ -1022,22 +1020,20 @@ err_t mmnif_init(struct netif *netif)
|
|||
|
||||
#if MMNIF_USE_MPB
|
||||
heap_start_address = RCCE_malloc(RCCE_LINE_SIZE);
|
||||
DEBUGPRINTF("MessagePassingBuffer allocated @ : 0x%p\n", heap_start_address);
|
||||
DEBUGPRINTF("MessagePassingBuffer allocated @ : %p\n", heap_start_address);
|
||||
for (i = heap_size / RCCE_LINE_SIZE; i > 0; i--)
|
||||
{
|
||||
if (!RCCE_malloc(RCCE_LINE_SIZE)) ;
|
||||
|
||||
if (!RCCE_malloc(RCCE_LINE_SIZE))
|
||||
{
|
||||
|
||||
// DEBUGPRINTF("mmnif init(): allocating shared memory failed\n");
|
||||
// return ERR_MEM;
|
||||
//DEBUGPRINTF("mmnif init(): allocating shared memory failed\n");
|
||||
//return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
heap_start_address = (void*) RCCE_shmalloc(heap_size * MMNIF_CORES);
|
||||
n = (int) heap_start_address;
|
||||
DEBUGPRINTF("RCCE_shmalloc : 0x%p", header_start_address);
|
||||
DEBUGPRINTF("RCCE_shmalloc : %p\n", header_start_address);
|
||||
|
||||
// map physical address in the virtual address space
|
||||
#if USE_CACHE
|
||||
|
@ -1048,13 +1044,13 @@ err_t mmnif_init(struct netif *netif)
|
|||
heap_start_address = (void*) map_region(0, (size_t) heap_start_address, (MMNIF_CORES * heap_size) >> PAGE_SHIFT, MAP_KERNEL_SPACE | MAP_NO_CACHE | MAP_MPE);
|
||||
#endif // USE_CAHCE
|
||||
#endif // MMNIF_USE_MPB
|
||||
DEBUGPRINTF("map_region : 0x%p", header_start_address);
|
||||
DEBUGPRINTF("map_region : %p\n", header_start_address);
|
||||
|
||||
#if MMNIF_USE_MPB
|
||||
mmnif->rx_heap = heap_start_address;
|
||||
heap_start_address =
|
||||
heap_start_address - (own_ip_address - router_ip_address) * 0x2000;
|
||||
DEBUGPRINTF("heap_start_address : 0x%p", heap_start_address);
|
||||
DEBUGPRINTF("heap_start_address : %p\n", heap_start_address);
|
||||
|
||||
// heap_start_address = 0xC0000000;
|
||||
// mmnif->rx_heap = heap_start_address + (heap_size) * (own_ip_address - router_ip_address);
|
||||
|
@ -1070,10 +1066,11 @@ err_t mmnif_init(struct netif *netif)
|
|||
memset(mmnif->rx_buff, 0, header_size);
|
||||
memset(mmnif->rx_heap, 0, heap_size);
|
||||
|
||||
#if USE_CACHE
|
||||
*((int *)RCCE_fool_write_combine_buffer) = 1;
|
||||
|
||||
#if USE_CACHE
|
||||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
#endif
|
||||
|
||||
if (own_ip_address == router_ip_address)
|
||||
{
|
||||
kprintf("Test0: MEMCPY 2048B");
|
||||
|
@ -1082,14 +1079,13 @@ err_t mmnif_init(struct netif *netif)
|
|||
{
|
||||
memcpy(mmnif->rx_heap + heap_size, mmnif->rx_heap, 2048);
|
||||
|
||||
#if USE_CACHE
|
||||
*((int *)RCCE_fool_write_combine_buffer) = 1;
|
||||
flush_cache();
|
||||
|
||||
#if USE_CACHE
|
||||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
#endif
|
||||
memcpy(mmnif->rx_heap, mmnif->rx_heap, 2048);
|
||||
} tmp2 = get_clock_tick();
|
||||
kprintf("memcpy'd' %d bytes in %d ticks", n * 2048, (tmp2 - tmp1));
|
||||
kprintf("memcpy'd' %d bytes in %d ticks\n", n * 2048, (tmp2 - tmp1));
|
||||
}
|
||||
|
||||
/* set initial values
|
||||
|
@ -1233,10 +1229,7 @@ anotherpacket:
|
|||
packet = (char *)b->desc_table[rdesc].addr;
|
||||
length = b->desc_table[rdesc].len;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
bp = mmnif_hashlookup(b->desc_table[rdesc].
|
||||
fast_sock);
|
||||
if (!bp)
|
||||
|
@ -1246,10 +1239,7 @@ anotherpacket:
|
|||
b->desc_table[rdesc].fast_sock);
|
||||
mmnif->rx_buff->desc_table[rdesc].stat = MMNIF_STATUS_PROC;
|
||||
mmnif_rxbuff_free();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b->desc_table[rdesc].stat = MMNIF_STATUS_INPROC;
|
||||
|
||||
#if MMNIF_FAST_SOCKET_BLOCK
|
||||
|
@ -1295,7 +1285,7 @@ anotherpacket:
|
|||
*/
|
||||
|
||||
#ifdef DEBUG_MMNIF_PACKET
|
||||
DEBUGPRINTF("\n RECIEVED - 0x%p with legth: %d\n", packet, length);
|
||||
DEBUGPRINTF("\n RECIEVED - %p with legth: %d\n", packet, length);
|
||||
hex_dump(length, packet);
|
||||
|
||||
#endif
|
||||
|
@ -1311,8 +1301,7 @@ anotherpacket:
|
|||
}
|
||||
#if USE_CACHE
|
||||
asm volatile (".byte 0x0f; .byte 0x0a;\n");
|
||||
|
||||
#endif /* */
|
||||
#endif
|
||||
|
||||
/* copy packet to pbuf structure going through linked list */
|
||||
for (q = p, i = 0; q != NULL; q = q->next)
|
||||
|
@ -1320,11 +1309,9 @@ anotherpacket:
|
|||
|
||||
#if MMNIF_USE_MPB
|
||||
memcpy_get((uint8_t *) q->payload, &packet[i], q->len);
|
||||
|
||||
#else /* */
|
||||
#else
|
||||
memcpy((uint8_t *) q->payload, &packet[i], q->len);
|
||||
|
||||
#endif /* */
|
||||
#endif
|
||||
i += q->len;
|
||||
}
|
||||
|
||||
|
@ -1430,7 +1417,7 @@ static int mmnif_rx_bypass(struct netif *netif, int s, void *data, uint32_t len)
|
|||
*/
|
||||
|
||||
#ifdef DEBUG_MMNIF_PACKET
|
||||
DEBUGPRINTF("\n RECIEVED - 0x%p with legth: %d\n", packet, length);
|
||||
DEBUGPRINTF("\n RECIEVED - %p with legth: %d\n", packet, length);
|
||||
hex_dump(length, packet);
|
||||
|
||||
#endif /* */
|
||||
|
@ -1725,16 +1712,15 @@ int mmnif_closesocket(int s)
|
|||
*/
|
||||
void mmnif_irqhandler()
|
||||
{
|
||||
mmnif_t *mmnif;
|
||||
//mmnif_t *mmnif;
|
||||
|
||||
/* return if mmnif_dev is not yet initialized */
|
||||
if (!mmnif_dev)
|
||||
{
|
||||
DEBUGPRINTF
|
||||
("mmnif_irqhandler(): the driver is not initialized yet\n");
|
||||
DEBUGPRINTF("mmnif_irqhandler(): the driver is not initialized yet\n");
|
||||
return;
|
||||
}
|
||||
mmnif = (mmnif_t *) mmnif_dev->state;
|
||||
//mmnif = (mmnif_t *) mmnif_dev->state;
|
||||
mmnif_rx(mmnif_dev);
|
||||
|
||||
// while (mmnif->rx_buff->dcount < MMNIF_MAX_DESCRIPTORS)
|
||||
|
|
Loading…
Add table
Reference in a new issue