diff options
author | jchandra <jchandra@FreeBSD.org> | 2013-01-24 15:49:47 +0000 |
---|---|---|
committer | jchandra <jchandra@FreeBSD.org> | 2013-01-24 15:49:47 +0000 |
commit | b243ad67b98ace316d7c3db69ef3ee2421139b90 (patch) | |
tree | 6ea5d819094545a64cc4f6c52942b70737ae5ccd /sys/mips/nlm | |
parent | 83606c3801cb37a82dc9f9f70c04f00fb41d3866 (diff) | |
download | FreeBSD-src-b243ad67b98ace316d7c3db69ef3ee2421139b90.zip FreeBSD-src-b243ad67b98ace316d7c3db69ef3ee2421139b90.tar.gz |
Little-endian and other fixes for Broadcom XLP network driver
The changes are:
- the microcore code loaded into the NAE has to be byteswapped
in LE
- the descriptors in memory for a P2P NAE descriptor has to be
byteswapped in LE
- the m_data pointer is already cacheline aligned, so the
unnecessary m_adj to cacheline size can be removed
- fix mask used to obtain physical address from the Tx freeback
descriptor
- fix a compile error in code under #ifdef
Obtained from: Venkatesh J V <venkatesh.vivekanandan@broadcom.com>
Diffstat (limited to 'sys/mips/nlm')
-rw-r--r-- | sys/mips/nlm/dev/net/xlpge.c | 14 | ||||
-rw-r--r-- | sys/mips/nlm/hal/ucore_loader.h | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/sys/mips/nlm/dev/net/xlpge.c b/sys/mips/nlm/dev/net/xlpge.c index 4e22bbd..6d221e4 100644 --- a/sys/mips/nlm/dev/net/xlpge.c +++ b/sys/mips/nlm/dev/net/xlpge.c @@ -869,6 +869,7 @@ xlpge_tx(struct ifnet *ifp, struct mbuf *mbuf_chain) vm_offset_t buf = (vm_offset_t) m->m_data; int len = m->m_len; int frag_sz; + uint64_t desc; /*printf("m_data = %p len %d\n", m->m_data, len); */ while (len) { @@ -883,8 +884,9 @@ xlpge_tx(struct ifnet *ifp, struct mbuf *mbuf_chain) frag_sz = PAGE_SIZE - (buf & PAGE_MASK); if (len < frag_sz) frag_sz = len; - p2p->frag[pos] = nae_tx_desc(P2D_NEOP, 0, 127, + desc = nae_tx_desc(P2D_NEOP, 0, 127, frag_sz, paddr); + p2p->frag[pos] = htobe64(desc); pos++; len -= frag_sz; buf += frag_sz; @@ -894,7 +896,7 @@ xlpge_tx(struct ifnet *ifp, struct mbuf *mbuf_chain) KASSERT(pos != 0, ("Zero-length mbuf chain?\n")); /* Make the last one P2D EOP */ - p2p->frag[pos-1] |= (uint64_t)P2D_EOP << 62; + p2p->frag[pos-1] |= htobe64((uint64_t)P2D_EOP << 62); /* stash useful pointers in the desc */ p2p->frag[XLP_NTXFRAGS-3] = 0xf00bad; @@ -1131,7 +1133,8 @@ get_buf(void) if ((m_new = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR)) == NULL) return (NULL); m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - m_adj(m_new, NAE_CACHELINE_SIZE - ((uintptr_t)m_new->m_data & 0x1f)); + KASSERT(((uintptr_t)m_new->m_data & (NAE_CACHELINE_SIZE - 1)) == 0, + ("m_new->m_data is not cacheline aligned")); md = (uint64_t *)m_new->m_data; md[0] = (intptr_t)m_new; /* Back Ptr */ md[1] = 0xf00bad; @@ -1140,10 +1143,9 @@ get_buf(void) #ifdef INVARIANTS temp1 = vtophys((vm_offset_t) m_new->m_data); temp2 = vtophys((vm_offset_t) m_new->m_data + 1536); - KASSERT(temp1 + 1536) != temp2, + KASSERT((temp1 + 1536) != temp2, ("Alloced buffer is not contiguous")); #endif - return ((void *)m_new->m_data); } @@ -1552,7 +1554,7 @@ nlm_xlpge_msgring_handler(int vc, int size, int code, int src_id, ifp->if_opackets++; } else if (size > 1) { /* Recieve packet */ - phys_addr = msg->msg[1] & 0xffffffffe0ULL; + phys_addr = msg->msg[1] & 0xffffffffc0ULL; length = (msg->msg[1] >> 40) & 0x3fff; length -= MAC_CRC_LEN; diff --git a/sys/mips/nlm/hal/ucore_loader.h b/sys/mips/nlm/hal/ucore_loader.h index 8298c82..cace077 100644 --- a/sys/mips/nlm/hal/ucore_loader.h +++ b/sys/mips/nlm/hal/ucore_loader.h @@ -49,7 +49,7 @@ nlm_ucore_load_image(uint64_t nae_base, int ucore) size = sizeof(ucore_app_bin)/sizeof(uint32_t); for (i = 0; i < size; i++, addr += 4) - nlm_store_word_daddr(addr, p[i]); + nlm_store_word_daddr(addr, htobe32(p[i])); /* add a 'nop' if number of instructions are odd */ if (size & 0x1) |