summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJiaojinxing <jiaojinxing1987@gmail.com>2015-04-22 01:47:41 (GMT)
committer Jiaojinxing <jiaojinxing1987@gmail.com>2015-04-22 01:47:41 (GMT)
commita0200eddd20b23bb7aefc07dbdfd1dea9c5d991b (patch)
tree31283e03ca6b894a860ee9e7b39dc9835c12f835
parenta9be28472068087b39c85e2ccf7512a4a29231f1 (diff)
downloadbspam335x-a0200eddd20b23bb7aefc07dbdfd1dea9c5d991b.zip
bspam335x-a0200eddd20b23bb7aefc07dbdfd1dea9c5d991b.tar.gz
bspam335x-a0200eddd20b23bb7aefc07dbdfd1dea9c5d991b.tar.bz2
Fixed CPSW driver BUG.
-rw-r--r--SylixOS/driver/netif/cpswif.c59
1 files changed, 16 insertions, 43 deletions
diff --git a/SylixOS/driver/netif/cpswif.c b/SylixOS/driver/netif/cpswif.c
index 2874c53..13ee7cb 100644
--- a/SylixOS/driver/netif/cpswif.c
+++ b/SylixOS/driver/netif/cpswif.c
@@ -251,10 +251,6 @@ struct txch {
/* The number of free bd's, which can be sent */
volatile u32_t free_num;
-
- /* The tail of the bd chain, being sent */
- volatile struct cpdma_tx_bd *begin;
- volatile struct cpdma_tx_bd *end;
}txch;
volatile struct cpdma_tx_bd *free_head;
@@ -1588,7 +1584,6 @@ cpswif_rxbd_alloc(struct cpswinst *cpswinst) {
pbuf_header(p, -ETH_PAD_SIZE);
#endif
#endif
-#ifndef SYLIXOS
#ifdef LWIP_CACHE_ENABLED
/**
* Clean the pbuf structure info. This is needed to prevent losing
@@ -1596,7 +1591,6 @@ cpswif_rxbd_alloc(struct cpswinst *cpswinst) {
*/
CacheDataCleanBuff((u32_t)(p), (u32_t)(SIZEOF_STRUCT_PBUF));
#endif
-#endif
curr_bd->bufptr = (u32_t)(p->payload);
curr_bd->bufoff_len = p->len;
curr_bd->flags_pktlen = CPDMA_BUF_DESC_OWNER;
@@ -1708,15 +1702,10 @@ cpswif_transmit(struct netif *netif, struct pbuf *pbuf) {
/* Intialize the buffer pointer and length */
curr_bd->bufptr = (u32_t)(q->payload);
curr_bd->bufoff_len = (q->len) & CPDMA_BD_LEN_MASK;
- curr_bd->pbuf = pbuf;
-
bd_end = curr_bd;
+ curr_bd->pbuf = pbuf;
curr_bd = curr_bd->next;
- if (q->next) {
- curr_bd->flags_pktlen = 0;
- }
-
/* Decrement free bds, since one is consumed */
txch->free_num--;
}
@@ -1729,10 +1718,7 @@ cpswif_transmit(struct netif *netif, struct pbuf *pbuf) {
txch->free_head = curr_bd;
/* For the first time, write the HDP with the filled bd */
- if(txch->send_head == NULL) {
-
- txch->send_head = bd_to_send;
-
+ if(txch->send_tail == NULL) {
CPSWCPDMATxHdrDescPtrWrite(cpswinst->cpdma_base,
(u32_t)(bd_to_send), 0);
} else {
@@ -2007,8 +1993,7 @@ cpswif_cpdma_init(struct cpswinst *cpswinst) {
/* Initialize the CPDMA memory. Only Channel 0 is supported */
txch->free_head = (volatile struct cpdma_tx_bd*)(cpswinst->cppi_ram_base);
- txch->begin = txch->free_head;
- txch->send_head = NULL;
+ txch->send_head = txch->free_head;
txch->send_tail = NULL;
/* Allocate half of the CPPI RAM for TX buffer descriptors */
@@ -2027,9 +2012,7 @@ cpswif_cpdma_init(struct cpswinst *cpswinst) {
curr_txbd = curr_txbd->next;
num_bd--;
}
- last_txbd->next = txch->begin;
-
- txch->end = last_txbd + 1;
+ last_txbd->next = txch->free_head;
/* Initialize the descriptors for the RX channel */
rxch = &(cpswinst->rxch);
@@ -2272,15 +2255,6 @@ cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr) {
/* Get the pbuf which is associated with the current bd */
pbuf = curr_bd->pbuf;
-#ifdef SYLIXOS
-#ifdef LWIP_CACHE_ENABLED
- /**
- * Invalidate the cache lines of the pbuf including payload. Because
- * the memory contents got changed by DMA.
- */
- CacheDataInvalidateBuff((u32_t)pbuf->payload, (PBUF_LEN_MAX));
-#endif
-#else
#ifdef LWIP_CACHE_ENABLED
/**
* Invalidate the cache lines of the pbuf including payload. Because
@@ -2288,7 +2262,6 @@ cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr) {
*/
CacheDataInvalidateBuff((u32_t)pbuf, (PBUF_LEN_MAX + SIZEOF_STRUCT_PBUF));
#endif
-#endif
/* Update the len and tot_len fields for the pbuf in the chain */
pbuf->len = (u16_t)(tot_len);
@@ -2386,7 +2359,7 @@ cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
curr_bd = send_head;
/* Check for correct start of packet */
- while(curr_bd && ((curr_bd->flags_pktlen) & CPDMA_BUF_DESC_SOP)) {
+ while((curr_bd->flags_pktlen) & CPDMA_BUF_DESC_SOP) {
#ifndef SYLIXOS
/* Make sure that the transmission is over */
@@ -2400,11 +2373,14 @@ cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
return;
}
#else
- if(curr_bd->flags_pktlen & CPDMA_BUF_DESC_OWNER) {
+ if(((curr_bd->flags_pktlen & CPDMA_BUF_DESC_OWNER)
+ == CPDMA_BUF_DESC_OWNER)) {
API_SemaphoreBPost(cpswinst->txlock);
API_TimeMSleep(10);
API_SemaphoreBPend(cpswinst->txlock, LW_OPTION_WAIT_INFINITE);
- if(curr_bd->flags_pktlen & CPDMA_BUF_DESC_OWNER) {
+
+ if(((curr_bd->flags_pktlen & CPDMA_BUF_DESC_OWNER)
+ == CPDMA_BUF_DESC_OWNER)) {
CPSWCPDMATxHdrDescPtrWrite(cpswinst->cpdma_base,
(u32_t)(curr_bd), 0);
API_SemaphoreBPost(cpswinst->txlock);
@@ -2436,25 +2412,22 @@ cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
}
}
- send_head->flags_pktlen = 0;
- curr_bd->flags_pktlen = 0;
-
- /* Acknowledge CPSW and free the corresponding pbuf */
- CPSWCPDMATxCPWrite(cpswinst->cpdma_base, 0, (u32_t)curr_bd);
+ send_head->flags_pktlen &= ~(CPDMA_BUF_DESC_SOP);
+ curr_bd->flags_pktlen &= ~(CPDMA_BUF_DESC_EOP);
/**
* If there are no more data transmitted, the next interrupt
* shall happen with the pbuf associated with the free_head
*/
if(curr_bd->next == NULL) {
- curr_bd->next = curr_bd + 1 == txch->end ? txch->begin : curr_bd + 1;
-
- txch->send_head = NULL;
- txch->send_tail = NULL;
+ txch->send_head = txch->free_head;
} else {
txch->send_head = curr_bd->next;
}
+ /* Acknowledge CPSW and free the corresponding pbuf */
+ CPSWCPDMATxCPWrite(cpswinst->cpdma_base, 0, (u32_t)curr_bd);
+
#ifdef SYLIXOS
#ifdef CPSW_DUAL_MAC_MODE
if_num = (inst_num * MAX_SLAVEPORT_PER_INST) + to_port - 1;