FreeBSD/Linux Kernel Cross Reference
sys/dev/cxgb/sys/mvec.h
1 /**************************************************************************
2 *
3 * Copyright (c) 2007,2009 Kip Macy kmacy@freebsd.org
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. The name of Kip Macy nor the names of other
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: releng/8.0/sys/dev/cxgb/sys/mvec.h 195006 2009-06-25 21:50:15Z np $
29 *
30 ***************************************************************************/
31
32 #ifndef _MVEC_H_
33 #define _MVEC_H_
34 #include <machine/bus.h>
35
36 #define M_DDP 0x200000 /* direct data placement mbuf */
37 #define EXT_PHYS 10 /* physical/bus address */
38
39 #define m_cur_offset m_ext.ext_size /* override to provide ddp offset */
40 #define m_seq m_pkthdr.csum_data /* stored sequence */
41 #define m_ddp_gl m_ext.ext_buf /* ddp list */
42 #define m_ddp_flags m_pkthdr.csum_flags /* ddp flags */
43 #define m_ulp_mode m_pkthdr.tso_segsz /* upper level protocol */
44
45 static __inline void
46 busdma_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map,
47 struct mbuf *m, bus_dma_segment_t *seg)
48 {
49 #if defined(__i386__) || defined(__amd64__)
50 seg->ds_addr = pmap_kextract(mtod(m, vm_offset_t));
51 seg->ds_len = m->m_len;
52 #else
53 int nsegstmp;
54
55 bus_dmamap_load_mbuf_sg(tag, map, m, seg, &nsegstmp, 0);
56 #endif
57 }
58
59 int busdma_map_sg_collapse(bus_dma_tag_t tag, bus_dmamap_t map,
60 struct mbuf **m, bus_dma_segment_t *segs, int *nsegs);
61 void busdma_map_sg_vec(bus_dma_tag_t tag, bus_dmamap_t map,
62 struct mbuf *m, bus_dma_segment_t *segs, int *nsegs);
63 static __inline int
64 busdma_map_sgl(bus_dma_segment_t *vsegs, bus_dma_segment_t *segs, int count)
65 {
66 while (count--) {
67 segs->ds_addr = pmap_kextract((vm_offset_t)vsegs->ds_addr);
68 segs->ds_len = vsegs->ds_len;
69 segs++;
70 vsegs++;
71 }
72 return (0);
73 }
74
75 static __inline void
76 m_freem_list(struct mbuf *m)
77 {
78 struct mbuf *n;
79
80 while (m != NULL) {
81 n = m->m_nextpkt;
82 if (n != NULL)
83 prefetch(n);
84 m_freem(m);
85 m = n;
86 }
87 }
88
89
90 #endif /* _MVEC_H_ */
Cache object: 04c0fc2988a37066b32294bc8835fd16
|