MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / tivaif_receive

Function tivaif_receive

bsp/tm4c129x/drivers/drv_eth.c:799–969  ·  view source on GitHub ↗

* This function will process all receive descriptors that contain newly read * data and pass complete frames up the lwIP stack as they are found. The * timestamp of the packet will be placed into the pbuf structure if PTPD is * enabled. * * This function is called only from the Ethernet interrupt handler. * * @param psNetif the lwip network interface structure for this ethernetif * @retur

Source from the content-addressed store, hash-verified

797 * @return None.
798 */
799static void
800tivaif_receive(net_device_t dev)
801{
802 tDescriptorList *pDescList;
803 tStellarisIF *pIF;
804 static struct pbuf *pBuf = NULL;
805 uint32_t ui32DescEnd;
806
807 /* Get a pointer to our state data */
808 pIF = dev->dma_if;
809
810 /* Get a pointer to the receive descriptor list. */
811 pDescList = pIF->pRxDescList;
812
813 /* Start with a NULL pbuf so that we don't try to link chain the first
814 * time round.
815 */
816 //pBuf = NULL;
817
818 /* Determine where we start and end our walk of the descriptor list */
819 ui32DescEnd = pDescList->ui32Read ? (pDescList->ui32Read - 1) : (pDescList->ui32NumDescs - 1);
820
821 /* Step through the descriptors that are marked for CPU attention. */
822 while(pDescList->ui32Read != ui32DescEnd)
823 {
824 /* Does the current descriptor have a buffer attached to it? */
825 if(pDescList->pDescriptors[pDescList->ui32Read].pBuf)
826 {
827 /* Yes - determine if the host has filled it yet. */
828 if(pDescList->pDescriptors[pDescList->ui32Read].Desc.ui32CtrlStatus &
829 DES0_RX_CTRL_OWN)
830 {
831 /* The DMA engine still owns the descriptor so we are finished */
832 break;
833 }
834
835 DRIVER_STATS_INC(RXBufReadCount);
836
837 /* If this descriptor contains the end of the packet, fix up the
838 * buffer size accordingly.
839 */
840 if(pDescList->pDescriptors[pDescList->ui32Read].Desc.ui32CtrlStatus &
841 DES0_RX_STAT_LAST_DESC)
842 {
843 /* This is the last descriptor for the frame so fix up the
844 * length. It is safe for us to modify the internal fields
845 * directly here (rather than calling pbuf_realloc) since we
846 * know each of these pbufs is never chained.
847 */
848 pDescList->pDescriptors[pDescList->ui32Read].pBuf->len =
849 (pDescList->pDescriptors[pDescList->ui32Read].Desc.ui32CtrlStatus &
850 DES0_RX_STAT_FRAME_LENGTH_M) >>
851 DES0_RX_STAT_FRAME_LENGTH_S;
852 pDescList->pDescriptors[pDescList->ui32Read].pBuf->tot_len =
853 pDescList->pDescriptors[pDescList->ui32Read].pBuf->len;
854 }
855
856 if(pBuf)

Callers 1

tivaif_interruptFunction · 0.85

Calls 4

rt_mb_sendFunction · 0.85
pbuf_catFunction · 0.50
pbuf_freeFunction · 0.50
pbuf_allocFunction · 0.50

Tested by

no test coverage detected