Subject: Patch to x86 bus_dma back-end to use mbuf dma optimizations
To: None <tech-kern@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 03/29/2003 13:34:29
--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This patch is third in a series of simple patches to improve network
performance contributed by Wasabi Systems.

What this does it use the cached physical addresses for mbufs and clusters
in the x86 bus_dma back-end.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=x86-bus_dma-patch

Index: bus_dma.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/bus_dma.c,v
retrieving revision 1.1
diff -c -r1.1 bus_dma.c
*** bus_dma.c	2003/03/12 00:09:52	1.1
--- bus_dma.c	2003/03/29 21:30:04
***************
*** 185,192 ****
  	seg = 0;
  	error = 0;
  	for (m = m0; m != NULL && error == 0; m = m->m_next) {
! 		error = _bus_dmamap_load_buffer(t, map, m->m_data, m->m_len,
! 		    NULL, flags, &lastaddr, &seg, first);
  		first = 0;
  	}
  	if (error == 0) {
--- 185,220 ----
  	seg = 0;
  	error = 0;
  	for (m = m0; m != NULL && error == 0; m = m->m_next) {
! 		if (m->m_len == 0)
! 			continue;
! 		/* XXX Could be better about coalescing. */
! 		/* XXX Doesn't check boundaries. */
! 		switch (m->m_flags & (M_EXT|M_EXT_CLUSTER)) {
! 		case M_EXT|M_EXT_CLUSTER:
! 			/* XXX KDASSERT */
! 			KASSERT(m->m_ext.ext_paddr != M_PADDR_INVALID);
! 			lastaddr = m->m_ext.ext_paddr +
! 			    (m->m_data - m->m_ext.ext_buf);
!  have_addr:
! 			if (first == 0 &&
! 			    ++seg >= map->_dm_segcnt) {
! 				error = EFBIG;
! 				break;
! 			}
! 			map->dm_segs[seg].ds_addr = lastaddr;
! 			map->dm_segs[seg].ds_len = m->m_len;
! 			lastaddr += m->m_len;
! 			break;
! 
! 		case 0:
! 			lastaddr = m->m_paddr + M_BUFOFFSET(m) +
! 			    (m->m_data - M_BUFADDR(m));
! 			goto have_addr;
! 
! 		default:
! 			error = _bus_dmamap_load_buffer(t, map, m->m_data,
! 			    m->m_len, NULL, flags, &lastaddr, &seg, first);
! 		}
  		first = 0;
  	}
  	if (error == 0) {

--nFreZHaLTZJo0R7j--