memdesc: Add a MEMDESC_VMPAGES descriptor type.

This memory descriptor is backed by an array of VM pages.  This type
requires adding a new field to 'struct memdesc' to hold the offset
within the first page.  For LP64 systems, this new field is added in
an existing padding hole so does not increase the size.  For ILP32
systems, this grows 'struct memdesc' from 12 to 16 bytes.

Reviewed by:	imp, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41028
This commit is contained in:
John Baldwin
2023-07-14 11:31:42 -07:00
parent 3dba010e49
commit bab38b44dd
2 changed files with 24 additions and 1 deletions
+4
View File
@@ -583,6 +583,10 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map,
error = _bus_dmamap_load_mbuf_sg(dmat, map, mem->u.md_mbuf,
NULL, &nsegs, flags);
break;
case MEMDESC_VMPAGES:
error = _bus_dmamap_load_ma(dmat, map, mem->u.md_ma,
mem->md_len, mem->md_offset, flags, NULL, &nsegs);
break;
}
nsegs++;
+20 -1
View File
@@ -35,6 +35,7 @@ struct bio;
struct bus_dma_segment;
struct uio;
struct mbuf;
struct vm_page;
union ccb;
/*
@@ -49,11 +50,15 @@ struct memdesc {
struct bio *md_bio;
struct uio *md_uio;
struct mbuf *md_mbuf;
struct vm_page **md_ma;
} u;
union { /* type specific data. */
size_t md_len; /* VADDR, PADDR */
size_t md_len; /* VADDR, PADDR, VMPAGES */
int md_nseg; /* VLIST, PLIST */
};
union {
uint32_t md_offset; /* VMPAGES */
};
uint32_t md_type; /* Type of memory. */
};
@@ -64,6 +69,7 @@ struct memdesc {
#define MEMDESC_BIO 5 /* Pointer to a bio (block io). */
#define MEMDESC_UIO 6 /* Pointer to a uio (any io). */
#define MEMDESC_MBUF 7 /* Pointer to a mbuf (network io). */
#define MEMDESC_VMPAGES 8 /* Pointer to array of VM pages. */
static inline struct memdesc
memdesc_vaddr(void *vaddr, size_t len)
@@ -146,6 +152,19 @@ memdesc_mbuf(struct mbuf *mbuf)
return (mem);
}
static inline struct memdesc
memdesc_vmpages(struct vm_page **ma, size_t len, u_int ma_offset)
{
struct memdesc mem;
mem.u.md_ma = ma;
mem.md_len = len;
mem.md_type = MEMDESC_VMPAGES;
mem.md_offset = ma_offset;
return (mem);
}
struct memdesc memdesc_ccb(union ccb *ccb);
#endif /* _SYS_MEMDESC_H_ */