MAC now works with checksum offload
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11412 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
ed3b2c44f5
commit
58271f2049
|
@ -358,7 +358,7 @@ void mac_lld_start(MACDriver *macp) {
|
||||||
macp->rxptr = (sama_eth_rx_descriptor_t *)__eth_rd;
|
macp->rxptr = (sama_eth_rx_descriptor_t *)__eth_rd;
|
||||||
|
|
||||||
for (i = 0; i < SAMA_MAC_TRANSMIT_BUFFERS; i++)
|
for (i = 0; i < SAMA_MAC_TRANSMIT_BUFFERS; i++)
|
||||||
__eth_td[i].tdes1 |= SAMA_TDES1_LAST_BUFF | SAMA_TDES1_USED;
|
__eth_td[i].tdes1 |= SAMA_TDES1_LAST_BUFF | SAMA_TDES1_USED | (SAMA_TDES1_LENGTH_BUFF & BUFFER_SIZE);
|
||||||
|
|
||||||
macp->txptr = (sama_eth_tx_descriptor_t *)__eth_td;
|
macp->txptr = (sama_eth_tx_descriptor_t *)__eth_td;
|
||||||
|
|
||||||
|
@ -387,14 +387,12 @@ void mac_lld_start(MACDriver *macp) {
|
||||||
uint32_t ncfgr = GMAC0->GMAC_NCFGR;
|
uint32_t ncfgr = GMAC0->GMAC_NCFGR;
|
||||||
|
|
||||||
#if SAMA_MAC_IP_CHECKSUM_OFFLOAD
|
#if SAMA_MAC_IP_CHECKSUM_OFFLOAD
|
||||||
GMAC0->GMAC_NCFGR = GMAC_NCFGR_RXCOEN | GMAC_NCFGR_SPD |
|
GMAC0->GMAC_NCFGR = GMAC_NCFGR_SPD | GMAC_NCFGR_FD | GMAC_NCFGR_RXCOEN |
|
||||||
GMAC_NCFGR_FD | GMAC_NCFGR_MAXFS |
|
GMAC_NCFGR_MAXFS | GMAC_NCFGR_RFCS | ncfgr;
|
||||||
GMAC_NCFGR_RFCS | ncfgr;
|
|
||||||
GMAC0->GMAC_DCFGR |= GMAC_DCFGR_TXCOEN;
|
GMAC0->GMAC_DCFGR |= GMAC_DCFGR_TXCOEN;
|
||||||
#else
|
#else
|
||||||
GMAC0->GMAC_NCFGR = GMAC_NCFGR_SPD | GMAC_NCFGR_FD |
|
GMAC0->GMAC_NCFGR = GMAC_NCFGR_SPD | GMAC_NCFGR_FD |
|
||||||
GMAC_NCFGR_MAXFS | GMAC_NCFGR_RFCS |
|
GMAC_NCFGR_MAXFS | GMAC_NCFGR_RFCS| ncfgr;
|
||||||
ncfgr;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* DMA configuration:
|
/* DMA configuration:
|
||||||
|
@ -428,8 +426,6 @@ void mac_lld_start(MACDriver *macp) {
|
||||||
/* Enable RX and TX.*/
|
/* Enable RX and TX.*/
|
||||||
GMAC0->GMAC_NCR |= GMAC_NCR_RXEN | GMAC_NCR_TXEN;
|
GMAC0->GMAC_NCR |= GMAC_NCR_RXEN | GMAC_NCR_TXEN;
|
||||||
|
|
||||||
/* Starts transmission */
|
|
||||||
// GMAC0->GMAC_NCR |= GMAC_NCR_TSTART;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -574,11 +570,7 @@ msg_t mac_lld_get_receive_descriptor(MACDriver *macp,
|
||||||
/* Iterates through received frames until a valid one is found, invalid
|
/* Iterates through received frames until a valid one is found, invalid
|
||||||
frames are discarded.*/
|
frames are discarded.*/
|
||||||
while (rdes->rdes0 & SAMA_RDES0_OWN) {
|
while (rdes->rdes0 & SAMA_RDES0_OWN) {
|
||||||
if (rdes->rdes1 & (SAMA_RDES1_EOF | SAMA_RDES1_SOF)
|
if (rdes->rdes1 & (SAMA_RDES1_EOF | SAMA_RDES1_SOF)) {
|
||||||
#if SAMA_MAC_IP_CHECKSUM_OFFLOAD
|
|
||||||
&& (rdes->rdes1 & (SAMA_RDES1_CHECKSUM_IP_TCP | SAMA_RDES1_CHECKSUM_IP_UDP))
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
/* Found a valid one.*/
|
/* Found a valid one.*/
|
||||||
rdp->offset = 0;
|
rdp->offset = 0;
|
||||||
/* Only with RFCS set */
|
/* Only with RFCS set */
|
||||||
|
@ -728,9 +720,6 @@ size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
|
||||||
if (size > tdp->size - tdp->offset)
|
if (size > tdp->size - tdp->offset)
|
||||||
size = tdp->size - tdp->offset;
|
size = tdp->size - tdp->offset;
|
||||||
|
|
||||||
/* Configure lentgh of buffer */
|
|
||||||
tdp->physdesc->tdes1 |= (SAMA_TDES1_LENGTH_BUFF & size);
|
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
memcpy((uint8_t *)(tdp->physdesc->tdes0) + tdp->offset, buf, size);
|
memcpy((uint8_t *)(tdp->physdesc->tdes0) + tdp->offset, buf, size);
|
||||||
tdp->offset += size;
|
tdp->offset += size;
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
* @brief IP checksum offload.
|
* @brief IP checksum offload.
|
||||||
* @details The following modes are available:
|
* @details The following modes are available:
|
||||||
* - 0 Function disabled.
|
* - 0 Function disabled.
|
||||||
* - 1 Only IP header checksum calculation and insertion are enabled.
|
* - 1 IP/TCP/UDP header checksum calculation and insertion are enabled.
|
||||||
*/
|
*/
|
||||||
#if !defined(SAMA_MAC_IP_CHECKSUM_OFFLOAD) || defined(__DOXYGEN__)
|
#if !defined(SAMA_MAC_IP_CHECKSUM_OFFLOAD) || defined(__DOXYGEN__)
|
||||||
#define SAMA_MAC_IP_CHECKSUM_OFFLOAD 1
|
#define SAMA_MAC_IP_CHECKSUM_OFFLOAD 1
|
||||||
|
|
Loading…
Reference in New Issue