Address PR kern/148307 - fix if_ath TX mbuf alignment/size constraint checks
The existing code only checked the alignment of the first mbuf and didn't enforce the size constraints. This commit introduces a simple function to check the alignment and size of all mbufs in the list. This fixes the initial issue in the PR. PR: kern/148307 Reviewed by: gonzo@
This commit is contained in:
parent
76780f208c
commit
ef54d27641
@ -833,6 +833,28 @@ arge_init_locked(struct arge_softc *sc)
|
||||
ARGE_WRITE(sc, AR71XX_DMA_INTR, DMA_INTR_ALL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return whether the mbuf chain is correctly aligned
|
||||
* for the arge TX engine.
|
||||
*
|
||||
* The TX engine requires each fragment to be aligned to a
|
||||
* 4 byte boundary and the size of each fragment except
|
||||
* the last to be a multiple of 4 bytes.
|
||||
*/
|
||||
static int
|
||||
arge_mbuf_chain_is_tx_aligned(struct mbuf *m0)
|
||||
{
|
||||
struct mbuf *m;
|
||||
|
||||
for (m = m0; m != NULL; m = m->m_next) {
|
||||
if((mtod(m, intptr_t) & 3) != 0)
|
||||
return 0;
|
||||
if ((m->m_next != NULL) && ((m->m_len & 0x03) != 0))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
|
||||
* pointers to the fragment pointers.
|
||||
@ -853,7 +875,7 @@ arge_encap(struct arge_softc *sc, struct mbuf **m_head)
|
||||
* even 4 bytes
|
||||
*/
|
||||
m = *m_head;
|
||||
if((mtod(m, intptr_t) & 3) != 0) {
|
||||
if (! arge_mbuf_chain_is_tx_aligned(m)) {
|
||||
m = m_defrag(*m_head, M_DONTWAIT);
|
||||
if (m == NULL) {
|
||||
*m_head = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user