if_ffec_mpc8xx: Use M_NOWAIT for incoming frames

Update #3523.
This commit is contained in:
Sebastian Huber 2018-09-14 10:21:52 +02:00
parent d101ed8614
commit 1b70957bd1

View File

@ -536,6 +536,8 @@ static void fec_rxDaemon (void *arg)
*/ */
rxBdIndex = 0; rxBdIndex = 0;
for (;;) { for (;;) {
struct mbuf *n;
rxBd = sc->rxBdBase + rxBdIndex; rxBd = sc->rxBdBase + rxBdIndex;
/* /*
@ -568,6 +570,12 @@ static void fec_rxDaemon (void *arg)
* Check that packet is valid * Check that packet is valid
*/ */
if (status & M8xx_BD_LAST) { if (status & M8xx_BD_LAST) {
/*
* Allocate a new mbuf
*/
n = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (n != NULL) {
/* /*
* Pass the packet up the chain. * Pass the packet up the chain.
* FIXME: Packet filtering hook could be done here. * FIXME: Packet filtering hook could be done here.
@ -576,23 +584,21 @@ static void fec_rxDaemon (void *arg)
/* /*
* Invalidate the buffer for this descriptor * Invalidate the buffer for this descriptor
*/ */
rtems_cache_invalidate_multiple_data_lines((const void *)rxBd->buffer, rxBd->length); rtems_cache_invalidate_multiple_data_lines(rxBd->buffer, rxBd->length);
m = sc->rxMbuf[rxBdIndex]; m = sc->rxMbuf[rxBdIndex];
m->m_len = m->m_pkthdr.len = rxBd->length - sizeof(uint32_t); m->m_len = m->m_pkthdr.len = rxBd->length - ETHER_CRC_LEN;
FEC_UNLOCK(sc); FEC_UNLOCK(sc);
(*sc->ifp->if_input)(sc->ifp, m); (*sc->ifp->if_input)(sc->ifp, m);
FEC_LOCK(sc); FEC_LOCK(sc);
} else {
/* /* Drop incoming frame if no new mbuf is available */
* Allocate a new mbuf n = m;
*/
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
m->m_pkthdr.rcvif = ifp;
sc->rxMbuf[rxBdIndex] = m;
rxBd->buffer = mtod (m, void *);
} }
else { } else {
/* Reuse mbuf */
n = m;
/* /*
* Something went wrong with the reception * Something went wrong with the reception
*/ */
@ -611,11 +617,15 @@ static void fec_rxDaemon (void *arg)
if (status & M8xx_BD_COLLISION) if (status & M8xx_BD_COLLISION)
sc->rxCollision++; sc->rxCollision++;
} }
n->m_pkthdr.rcvif = ifp;
sc->rxMbuf[rxBdIndex] = n;
rxBd->buffer = mtod (n, void *);
/* /*
* Reenable the buffer descriptor * Reenable the buffer descriptor
*/ */
rxBd->status = (status & M8xx_BD_WRAP) | rxBd->status = (status & M8xx_BD_WRAP) | M8xx_BD_EMPTY;
M8xx_BD_EMPTY;
m8xx.fec.r_des_active = 0x1000000; m8xx.fec.r_des_active = 0x1000000;
/* /*
* Move to next buffer descriptor * Move to next buffer descriptor