summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2015-11-25 14:00:28 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2015-11-25 14:00:28 +0000
commitec8fce94d4df7931db32d5c28dac993f37b128d8 (patch)
tree2eaa357ec796358e536c8fc6d473b688dee7cf0b /sys/arch
parentd8c58306c0616a2c6c4bbf71db8a2fd46cf95f3e (diff)
Simplify the setup of gather segments.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/octeon/dev/if_cnmac.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c
index f7ac8d6fd63..e565b369770 100644
--- a/sys/arch/octeon/dev/if_cnmac.c
+++ b/sys/arch/octeon/dev/if_cnmac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cnmac.c,v 1.35 2015/11/25 03:09:58 dlg Exp $ */
+/* $OpenBSD: if_cnmac.c,v 1.36 2015/11/25 14:00:27 visa Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -782,8 +782,6 @@ octeon_eth_send_makecmd_w1(int size, paddr_t addr)
size, addr); /* size, addr */
}
-/* TODO: use bus_dma(9) */
-
#define KVTOPHYS(addr) if_cnmac_kvtophys((vaddr_t)(addr))
paddr_t if_cnmac_kvtophys(vaddr_t);
@@ -797,8 +795,7 @@ if_cnmac_kvtophys(vaddr_t kva)
else if (kva >= CKSEG1_BASE && kva < CKSEG1_BASE + CKSEG_SIZE)
return CKSEG1_TO_PHYS(kva);
- printf("kva %lx is not able to convert physical address\n", kva);
- panic("if_cnmac_kvtophys");
+ panic("%s: non-direct mapped address %p", __func__, (void *)kva);
}
int
@@ -807,49 +804,18 @@ octeon_eth_send_makecmd_gbuf(struct octeon_eth_softc *sc, struct mbuf *m0,
{
struct mbuf *m;
int segs = 0;
- uint32_t laddr, rlen, nlen;
for (m = m0; m != NULL; m = m->m_next) {
-
if (__predict_false(m->m_len == 0))
continue;
-#if 0
- OCTEON_ETH_KASSERT(((uint32_t)m->m_data & (PAGE_SIZE - 1))
- == (kvtophys((vaddr_t)m->m_data) & (PAGE_SIZE - 1)));
-#endif
-
- /*
- * aligned 4k
- */
- laddr = (uintptr_t)m->m_data & (PAGE_SIZE - 1);
-
- if (laddr + m->m_len > PAGE_SIZE) {
- /* XXX */
- rlen = PAGE_SIZE - laddr;
- nlen = m->m_len - rlen;
- *(gbuf + segs) = octeon_eth_send_makecmd_w1(rlen,
- KVTOPHYS(m->m_data));
- segs++;
- if (segs > 63) {
- return 1;
- }
- /* XXX */
- } else {
- rlen = 0;
- nlen = m->m_len;
- }
-
- *(gbuf + segs) = octeon_eth_send_makecmd_w1(nlen,
- KVTOPHYS((caddr_t)m->m_data + rlen));
- segs++;
- if (segs > 63) {
+ if (segs >= OCTEON_POOL_SIZE_SG / sizeof(uint64_t))
return 1;
- }
+ gbuf[segs] = octeon_eth_send_makecmd_w1(m->m_len,
+ KVTOPHYS(m->m_data));
+ segs++;
}
- OCTEON_ETH_KASSERT(m == NULL);
-
*rsegs = segs;
return 0;