diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2017-06-03 08:50:39 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2017-06-03 08:50:39 +0000 |
commit | d2e739346f9e461b7a5afbecfc9a5fb2644db1ab (patch) | |
tree | b8ad992706a5891607d14c5e5435fe366adf9553 | |
parent | 776d2b3b65ce881f926ef5c0d74aaef367c8f473 (diff) |
vioblk/virtio: Re-arrange some struct members
This reduces holes/padding and makes the structs smaller.
-rw-r--r-- | sys/dev/pv/vioblk.c | 13 | ||||
-rw-r--r-- | sys/dev/pv/virtiovar.h | 4 |
2 files changed, 8 insertions, 9 deletions
diff --git a/sys/dev/pv/vioblk.c b/sys/dev/pv/vioblk.c index 64552e3e0ec..cf8a0337fc6 100644 --- a/sys/dev/pv/vioblk.c +++ b/sys/dev/pv/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.7 2017/05/30 19:28:09 sf Exp $ */ +/* $OpenBSD: vioblk.c,v 1.8 2017/06/03 08:50:38 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -87,12 +87,13 @@ struct virtio_feature_name vioblk_feature_names[] = { struct virtio_blk_req { struct virtio_blk_req_hdr vr_hdr; uint8_t vr_status; - struct scsi_xfer *vr_xs; +#define VR_DMA_END offsetof(struct virtio_blk_req, vr_qe_index) + int16_t vr_qe_index; int vr_len; + struct scsi_xfer *vr_xs; bus_dmamap_t vr_cmdsts; bus_dmamap_t vr_payload; SLIST_ENTRY(virtio_blk_req) vr_list; - int vr_qe_index; }; struct vioblk_softc { @@ -710,8 +711,7 @@ vioblk_alloc_reqs(struct vioblk_softc *sc, int qsize) vr->vr_len = VIOBLK_DONE; r = bus_dmamap_create(sc->sc_virtio->sc_dmat, - offsetof(struct virtio_blk_req, vr_xs), 1, - offsetof(struct virtio_blk_req, vr_xs), 0, + VR_DMA_END, 1, VR_DMA_END, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &vr->vr_cmdsts); if (r != 0) { printf("cmd dmamap creation failed, err %d\n", r); @@ -719,8 +719,7 @@ vioblk_alloc_reqs(struct vioblk_softc *sc, int qsize) goto err_reqs; } r = bus_dmamap_load(sc->sc_virtio->sc_dmat, vr->vr_cmdsts, - &vr->vr_hdr, offsetof(struct virtio_blk_req, vr_xs), NULL, - BUS_DMA_NOWAIT); + &vr->vr_hdr, VR_DMA_END, NULL, BUS_DMA_NOWAIT); if (r != 0) { printf("command dmamap load failed, err %d\n", r); nreqs = i; diff --git a/sys/dev/pv/virtiovar.h b/sys/dev/pv/virtiovar.h index 7b8a2f04d62..4b1f71c7e37 100644 --- a/sys/dev/pv/virtiovar.h +++ b/sys/dev/pv/virtiovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtiovar.h,v 1.5 2017/05/30 12:47:47 krw Exp $ */ +/* $OpenBSD: virtiovar.h,v 1.6 2017/06/03 08:50:38 sf Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -86,9 +86,9 @@ struct vq_entry { /* The following are used only in the `head' entry */ int16_t qe_next; /* next enq slot */ - struct vring_desc *qe_desc_base; /* pointer to vd array */ int16_t qe_indirect; /* 1 if using indirect */ int16_t qe_vr_index; /* index in sc_reqs array */ + struct vring_desc *qe_desc_base; /* pointer to vd array */ }; struct virtqueue { |