void fec_send(IF_PACKET *pkt, IF_BUFFER *buf) { NBUF *tx_buf; IF_BUFFER *data_buf; uint16 size; int i; /* Allocate new TX buffer */ tx_buf = nbuf_tx_allocate(); if (!tx_buf) return; /* Prepare ethernet header */ tx_buf->data[0] = pkt->addr[0]; tx_buf->data[1] = pkt->addr[1]; tx_buf->data[2] = pkt->addr[2]; tx_buf->data[3] = pkt->addr[3]; tx_buf->data[4] = pkt->addr[4]; tx_buf->data[5] = pkt->addr[5]; tx_buf->data[6] = eeprom.fec_mac[0]; tx_buf->data[7] = eeprom.fec_mac[1]; tx_buf->data[8] = eeprom.fec_mac[2]; tx_buf->data[9] = eeprom.fec_mac[3]; tx_buf->data[10] = eeprom.fec_mac[4]; tx_buf->data[11] = eeprom.fec_mac[5]; tx_buf->data[12] = pkt->type >> 8; tx_buf->data[13] = pkt->type & 0xFF; /* Copy packet data */ data_buf = buf; size = 14; do { for (i = 0; i < data_buf->size; i++) tx_buf->data[size+i] = data_buf->data[i]; size += data_buf->size; } while (data_buf = data_buf->next); /* Set Frame ready for transmit */ tx_buf->length = size; tx_buf->status |= TX_BD_R; /* Mark the buffer as not in use */ nbuf_tx_release(tx_buf); /* Indicate that there has been a transmit buffer produced */ MCF5282_FEC_TDAR = 1; }
err_t mcf523xfec_output_raw( struct netif *netif, struct pbuf *p ) { err_t res; nbuf_t *pNBuf; mcf523xfec_if_t *fecif = netif->state; int i; struct pbuf *q; #if ETH_PAD_SIZE pbuf_header( p, -ETH_PAD_SIZE ); /* drop the padding word */ #endif /* Test if we can handle such big frames. If not drop it. */ if( p->tot_len > MCF_FEC_MTU ) { #if LINK_STATS lwip_stats.link.lenerr++; #endif res = ERR_BUF; } /* Test if our network buffer scheme can handle a packet of this size. If * not drop it and return a memory error. */ else if( p->tot_len > TX_BUFFER_SIZE ) { #ifdef LINK_STATS lwip_stats.link.memerr++; #endif res = ERR_MEM; } /* Allocate a transmit buffer. If no buffer is available drop the frame. */ else if( ( pNBuf = nbuf_tx_allocate( ) ) == NULL ) { LWIP_ASSERT( "mcf523xfec_output_raw: pNBuf != NULL\n", pNBuf != NULL ); #ifdef LINK_STATS lwip_stats.link.memerr++; #endif res = ERR_MEM; } else { q = p; i = 0; do { memcpy( &pNBuf->data[i], q->payload, q->len ); i += q->len; } while( ( q = q->next ) != NULL ); pNBuf->length = p->tot_len; /* Set Frame ready for transmission. */ pNBuf->status |= TX_BD_R; /* Mark the buffer as not in use so the FEC can take it. */ nbuf_tx_release( pNBuf ); /* Indicate that a new transmit buffer has been produced. */ MCF_FEC_TDAR = 1; #if LINK_STATS lwip_stats.link.xmit++; #endif res = ERR_OK; } sys_sem_signal( fecif->tx_sem ); #if ETH_PAD_SIZE buf_header( p, ETH_PAD_SIZE ); #endif return res; }