* This function should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf might be * chained. * * @param psNetif the lwip network interface structure for this ethernetif * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type) * @return RT_EOK if the packet coui32d be sent * an err_t va
| 566 | * an err_t value if the packet coui32dn't be sent |
| 567 | */ |
| 568 | static rt_err_t |
| 569 | tivaif_transmit(net_device_t dev, struct pbuf *p) |
| 570 | { |
| 571 | tStellarisIF *pIF; |
| 572 | tDescriptor *pDesc; |
| 573 | struct pbuf *pBuf; |
| 574 | uint32_t ui32NumChained, ui32NumDescs; |
| 575 | bool bFirst; |
| 576 | SYS_ARCH_DECL_PROTECT(lev); |
| 577 | |
| 578 | LWIP_DEBUGF(NETIF_DEBUG, ("tivaif_transmit 0x%08x, len %d\n", p, |
| 579 | p->tot_len)); |
| 580 | |
| 581 | /** |
| 582 | * This entire function must run within a "critical section" to preserve |
| 583 | * the integrity of the transmit pbuf queue. |
| 584 | */ |
| 585 | SYS_ARCH_PROTECT(lev); |
| 586 | |
| 587 | /* Update our transmit attempt counter. */ |
| 588 | DRIVER_STATS_INC(TXCount); |
| 589 | |
| 590 | /** |
| 591 | * Increase the reference count on the packet provided so that we can |
| 592 | * hold on to it until we are finished transmitting its content. |
| 593 | */ |
| 594 | pbuf_ref(p); |
| 595 | |
| 596 | /** |
| 597 | * Determine whether all buffers passed are within SRAM and, if not, copy |
| 598 | * the pbuf into SRAM-resident buffers so that the Ethernet DMA can access |
| 599 | * the data. |
| 600 | */ |
| 601 | p = tivaif_check_pbuf(p); |
| 602 | |
| 603 | /* Make sure we still have a valid buffer (it may have been copied) */ |
| 604 | if(!p) |
| 605 | { |
| 606 | LINK_STATS_INC(link.memerr); |
| 607 | SYS_ARCH_UNPROTECT(lev); |
| 608 | return(-RT_ENOMEM); |
| 609 | } |
| 610 | |
| 611 | /* Get our state data from the netif structure we were passed. */ |
| 612 | //pIF = (tStellarisIF *)psNetif->state; |
| 613 | pIF = dev->dma_if; |
| 614 | |
| 615 | /* Make sure that the transmit descriptors are not all in use */ |
| 616 | pDesc = &(pIF->pTxDescList->pDescriptors[pIF->pTxDescList->ui32Write]); |
| 617 | if(pDesc->pBuf) |
| 618 | { |
| 619 | /** |
| 620 | * The current write descriptor has a pbuf attached to it so this |
| 621 | * implies that the ring is full. Reject this transmit request with a |
| 622 | * memory error since we can't satisfy it just now. |
| 623 | */ |
| 624 | pbuf_free(p); |
| 625 | LINK_STATS_INC(link.memerr); |
no test coverage detected