From: till straumann <till.straum...@alumni.tu-berlin.de>

Must be careful to skip empty buffers and to correctly
identify the last non-empty buffer (since that is the one
whose associated descriptor stores the head of the chain
for deferred cleanup).

Update #4344
---
 .../beatnik/net/if_mve/mv643xx_eth_bsdnet.c   | 42 +++++++++++--------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c 
b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
index 2bafe09ac7..f8400c9f13 100644
--- a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
+++ b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
@@ -245,8 +245,8 @@ struct mveth_softc {
 
 typedef struct BsdMveIter {
        MveEthBufIter it;
-       struct mbuf  *m;
-       struct mbuf  *h;
+       struct mbuf  *next;
+       struct mbuf  *head;
 } BsdMveIter;
 
 /* GLOBAL VARIABLES */
@@ -462,21 +462,34 @@ bail:
        return m;
 }
 
-static MveEthBufIter *fillIter(struct mbuf *m, BsdMveIter *it)
+static inline struct mbuf *skipEmpty(struct mbuf *m)
 {
-       if ( (it->m = (void*)m) ) {
+       while ( m && ( 0 == m->m_len ) ) {
+               m = m->m_next;
+       }
+       return m;
+}
+
+static MveEthBufIter *nextBuf(MveEthBufIter *arg)
+{
+BsdMveIter  *it = (BsdMveIter*)arg;
+struct mbuf *m;
+       if ( (m = it->next) ) {
+               it->next    = skipEmpty( m->m_next );
                it->it.data = mtod(m, void*);
                it->it.len  = m->m_len;
-               it->it.uptr = m->m_next ? it->h : 0;
+               it->it.uptr = it->next ? 0 : it->head;
                return (MveEthBufIter*)it;
        }
        return 0;
 }
 
-static MveEthBufIter *nextBuf(MveEthBufIter *arg)
+static MveEthBufIter *initIter(BsdMveIter *it, struct mbuf *m)
 {
-BsdMveIter *it = (BsdMveIter*)arg;
-       return fillIter( it->m->m_next, it );
+       it->head = m;
+       it->next = skipEmpty( m );
+       /* Fill with first buf info */
+       return nextBuf( &it->it );
 }
 
 int
@@ -501,12 +514,10 @@ startover:
                return 0;
 
        /* find first mbuf with actual data */
-       while ( 0 == m1->m_len ) {
-               if ( ! (m1 = m1->m_next) ) {
-                       /* end reached and still no data to send ?? */
-                       m_freem(m_head);
-                       return 0;
-               }
+       if ( ! initIter( &iter, m_head ) ) {
+               /* end reached and still no data to send ?? */
+               m_freem(m_head);
+               return 0;
        }
 
 #ifdef MVETH_DEBUG_TX_DUMP
@@ -524,9 +535,6 @@ startover:
        }
 #endif
 
-       fillIter( m_head, &iter );
-       iter.h = m_head;
-
        rval = BSP_mve_send_buf_chain( mp, nextBuf, &iter.it );
 
        if ( -2 == rval ) {
-- 
2.26.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to