[mc1322x] Faster than 3Kb/s
Jon Smirl
jonsmirl at gmail.com
Wed Dec 23 14:36:48 EST 2009
The first web server patch ran at 3Kb/s. That was primarily because
the PHY was being reinitialized on each send. This patch applies on
top of the first one. Now the web server runs at 190Kb/s for
fragmented packets.
The send routine is still a mess. I have to have the 2300 delay loop
or it won't work. Can anyone write some code to send a chain of
packets as fast as possible, chaining the sends together using
interrupts? Interrupt driven sends would let me pipeline building
packets with sending them.
int maca_send(const void *payload, unsigned short payload_len) {
volatile uint32_t i, j;
volatile uint32_t retry;
volatile uint32_t len;
struct packet_t *packet;
int status;
len = payload_len;
/* wait for maca to finish what it's doing */
disable_irq(MACA);
maca_on();
reg32(MACA_SFTCLK) = reg32(MACA_CLK) + 2;
while(status_is_not_completed()) {};
ResumeMACASync(1);
for (j = 0; j < 2300; j++) {}
led_red_on();
/* the mc1322x promiscuous mode doen't appear to be entirely promiscuous */
/* in MACA_RAW_MODE, all transmitted packets are prepended with
MACA_RAW_PREPEND */
/* received packets get stripped of this */
/* i.e. it's "raw" with respect to the upper layers of RIME */
#if MACA_RAW_MODE
PRINTF("maca: in raw mode sending 0x%0x + %d bytes\n",
MACA_RAW_PREPEND, payload_len);
tx_buf[0] = MACA_RAW_PREPEND;
len++;
for(i = 1; i <= payload_len; i++) {
/* copy payload into tx buf */
tx_buf[i] = ((uint8_t *)payload)[i - 1];
PRINTF(" %02x", ((uint8_t *)payload)[i - 1]);
}
#else
//PRINTF("maca: sending %d bytes\n", payload_len);
for(i = 0; i < payload_len; i++) {
/* copy payload into tx buf */
tx_buf[i] = ((uint8_t *)payload)[i];
//PRINTF(" %02x", ((uint8_t *)payload)[i]);
}
#endif
//PRINTF("\n");
/* set dma tx pointer to the payload */
/* and set the tx len */
reg32(MACA_TXLEN) = (uint32_t)(len + 2);
reg32(MACA_DMATX) = (uint32_t)tx_buf;
packet = list_head(rx_empty);
reg32(MACA_DMARX) = (uint32_t)&packet->data[0];
reg32(MACA_TMREN) = 0;
/* do the transmit */
reg32(MACA_CONTROL) = ( (1 << maca_ctrl_prm) |
(maca_ctrl_mode_no_cca << maca_ctrl_mode) |
(1 << maca_ctrl_asap) |
(maca_ctrl_seq_tx));
/* wait for transmit to finish */
/* maybe wait until action complete instead? */
while (!action_complete_irq()) {};
reg32(MACA_CLRIRQ) = (1 << maca_irq_acpl);
post_receive();
enable_irq(MACA);
led_red_off();
return 0;
}
--
Jon Smirl
jonsmirl at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: speed
Type: application/octet-stream
Size: 8936 bytes
Desc: not available
URL: <http://devl.org/pipermail/mc1322x/attachments/20091223/7569556c/attachment.obj>
More information about the mc1322x
mailing list