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,31 +570,35 @@ 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) {
/*
* Pass the packet up the chain.
* FIXME: Packet filtering hook could be done here.
*/
/*
* Invalidate the buffer for this descriptor
*/
rtems_cache_invalidate_multiple_data_lines((const void *)rxBd->buffer, rxBd->length);
m = sc->rxMbuf[rxBdIndex];
m->m_len = m->m_pkthdr.len = rxBd->length - sizeof(uint32_t);
FEC_UNLOCK(sc);
(*sc->ifp->if_input)(sc->ifp, m);
FEC_LOCK(sc);
/* /*
* Allocate a new mbuf * Allocate a new mbuf
*/ */
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR); n = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
m->m_pkthdr.rcvif = ifp;
sc->rxMbuf[rxBdIndex] = m; if (n != NULL) {
rxBd->buffer = mtod (m, void *); /*
} * Pass the packet up the chain.
else { * FIXME: Packet filtering hook could be done here.
*/
/*
* Invalidate the buffer for this descriptor
*/
rtems_cache_invalidate_multiple_data_lines(rxBd->buffer, rxBd->length);
m = sc->rxMbuf[rxBdIndex];
m->m_len = m->m_pkthdr.len = rxBd->length - ETHER_CRC_LEN;
FEC_UNLOCK(sc);
(*sc->ifp->if_input)(sc->ifp, m);
FEC_LOCK(sc);
} else {
/* Drop incoming frame if no new mbuf is available */
n = m;
}
} 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