minor optimizations

This commit is contained in:
Stefan Lankes 2011-10-20 08:46:27 -07:00
parent e3a8c1ae77
commit c74ee965ca

View file

@ -324,7 +324,7 @@ inline static void* memcpy_to_nc(void* dest, const void *src, size_t count)
/* trigger an interrupt on the remote processor
* so he knows there is a packet to read
*/
inline static int mmnif_trigger_irq(int dest_ip, int safe)
inline static int mmnif_trigger_irq(int dest_ip)
{
int tmp, x, y, z, addr;
int ue = dest_ip - 1;
@ -334,13 +334,11 @@ inline static int mmnif_trigger_irq(int dest_ip, int safe)
y = Y_PID(RC_COREID[ue]);
addr = CRB_ADDR(x, y) + (z == 0 ? GLCFG0 : GLCFG1);
if (safe) {
// send interrupt to ue
do {
NOP8;
tmp = ReadConfigReg(addr);
} while (tmp & 1);
} else tmp = ReadConfigReg(addr);
// send interrupt to ue
do {
NOP8;
tmp = ReadConfigReg(addr);
} while (tmp & 1);
tmp |= 1;
SetConfigReg(addr, tmp);
@ -432,7 +430,7 @@ static uint8_t mmnif_get_destination(struct netif *netif, struct pbuf *p)
* right inside of the buffer which is used for communication
* with the remote end
*/
static uint32_t mmnif_rxbuff_alloc(uint8_t dest, uint16_t len/*, uint32_t id*/)
static uint32_t mmnif_rxbuff_alloc(uint8_t dest, uint16_t len)
{
uint32_t ret = 0;
volatile mm_rx_buffer_t *rb = (mm_rx_buffer_t *) ((char *)header_start_address + (dest - 1) * header_size);
@ -660,7 +658,7 @@ realloc:
mmnif->stats.tx++;
mmnif->stats.tx_bytes += p->tot_len;
mmnif_trigger_irq(dest_ip, 1);
mmnif_trigger_irq(dest_ip);
return ERR_OK;
@ -761,7 +759,6 @@ static err_t mmnif_tx_bypass(struct netif * netif, void *pbuff, uint16_t size, i
//mm_rx_buffer_t *rb = (mm_rx_buffer_t *) ((char *)header_start_address + (dest->dest_ip - 1) * header_size);
/* allocate memory for the packet in the remote buffer */
//id = ++dest->counter;
realloc:
write_address = mmnif_rxbuff_alloc(dest->dest_ip, size);
if (!write_address)
@ -804,8 +801,7 @@ realloc:
mmnif->stats.tx++;
mmnif->stats.tx_bytes += size;
if (size >= ((MMNIF_RX_BUFFERLEN / 2) - 1))
mmnif_trigger_irq(dest->dest_ip, 0);
mmnif_trigger_irq(dest->dest_ip);
return ERR_OK;
}
@ -821,25 +817,24 @@ int mmnif_send(int s, void *data, size_t size, int flags)
if (p != 0)
{
if (size < ((MMNIF_RX_BUFFERLEN / 2) - 1)) {
if (size < ((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE)) {
if (mmnif_tx_bypass(mmnif_dev, data, size, s) == ERR_OK)
total_size = size;
return size;
} else {
j = size / (((MMNIF_RX_BUFFERLEN / 2) - 1));
k = size - (j * (((MMNIF_RX_BUFFERLEN / 2) - 1)));
j = size / (((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE));
k = size - (j * (((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE)));
for (i = 0; i < j; i++)
{
if (mmnif_tx_bypass(mmnif_dev, (char*) data + i * ((MMNIF_RX_BUFFERLEN / 2) - 1), ((MMNIF_RX_BUFFERLEN / 2) - 1), s) != ERR_OK)
goto out;
total_size += (MMNIF_RX_BUFFERLEN / 2) - 1;
if (mmnif_tx_bypass(mmnif_dev, (char*) data + i * ((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE), ((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE), s) != ERR_OK)
return total_size;
total_size += (MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE;
}
if (mmnif_tx_bypass(mmnif_dev, data + (j - 1) * ((MMNIF_RX_BUFFERLEN / 2) - 1), k, s) == ERR_OK)
if (mmnif_tx_bypass(mmnif_dev, data + (j - 1) * ((MMNIF_RX_BUFFERLEN / 2) - CLINE_SIZE), k, s) == ERR_OK)
total_size += k;
}
out:
mmnif_trigger_irq(p->dest_ip, 1);
return total_size;
}
@ -1290,7 +1285,6 @@ int mmnif_recv(int s, void *data, uint32_t len, int flags)
{
mmnif_t* mmnif = (mmnif_t *) mmnif_dev->state;
bypass_rxdesc_t *p = mmnif_hashlookup(s);
int ret;
if (p == 0)
return lwip_recv(s, data, len, flags);
@ -1316,9 +1310,8 @@ int mmnif_recv(int s, void *data, uint32_t len, int flags)
bp = mmnif_hashlookup(b->desc_table[rdesc].fast_sock);
if (bp) {
b->desc_table[rdesc].stat = MMNIF_STATUS_INPROC;
ret = mmnif_rx_bypass(mmnif_dev, s, data, len);
irq_nested_enable(state);
return ret;
return mmnif_rx_bypass(mmnif_dev, s, data, len);
}
}
}