Fri Dec 6 02:39:58 2013 UTC ()
virtio: move a comment to a more appropriate place

no functional changes.


(yamt)
diff -r1.1 -r1.2 src/sys/dev/pci/virtioreg.h
diff -r1.1 -r1.2 src/sys/dev/pci/virtiovar.h

cvs diff -r1.1 -r1.2 src/sys/dev/pci/virtioreg.h (expand / switch to unified diff)

--- src/sys/dev/pci/virtioreg.h 2011/10/30 12:12:21 1.1
+++ src/sys/dev/pci/virtioreg.h 2013/12/06 02:39:58 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: virtioreg.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ 1/* $NetBSD: virtioreg.h,v 1.2 2013/12/06 02:39:58 yamt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 Minoura Makoto. 4 * Copyright (c) 2010 Minoura Makoto.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -137,16 +137,39 @@ struct vring_avail { @@ -137,16 +137,39 @@ struct vring_avail {
137struct vring_used_elem { 137struct vring_used_elem {
138 /* Index of start of used descriptor chain. */ 138 /* Index of start of used descriptor chain. */
139 uint32_t id; 139 uint32_t id;
140 /* Total length of the descriptor chain which was written to. */ 140 /* Total length of the descriptor chain which was written to. */
141 uint32_t len; 141 uint32_t len;
142} __packed; 142} __packed;
143 143
144struct vring_used { 144struct vring_used {
145 uint16_t flags; 145 uint16_t flags;
146 uint16_t idx; 146 uint16_t idx;
147 struct vring_used_elem ring[0]; 147 struct vring_used_elem ring[0];
148} __packed; 148} __packed;
149 149
 150/* The standard layout for the ring is a continuous chunk of memory which
 151 * looks like this. We assume num is a power of 2.
 152 *
 153 * struct vring {
 154 * // The actual descriptors (16 bytes each)
 155 * struct vring_desc desc[num];
 156 *
 157 * // A ring of available descriptor heads with free-running index.
 158 * __u16 avail_flags;
 159 * __u16 avail_idx;
 160 * __u16 available[num];
 161 *
 162 * // Padding to the next align boundary.
 163 * char pad[];
 164 *
 165 * // A ring of used descriptor heads with free-running index.
 166 * __u16 used_flags;
 167 * __u16 used_idx;
 168 * struct vring_used_elem used[num];
 169 * };
 170 * Note: for virtio PCI, align is 4096.
 171 */
 172
150#define VIRTIO_PAGE_SIZE (4096) 173#define VIRTIO_PAGE_SIZE (4096)
151 174
152#endif /* _DEV_PCI_VIRTIOREG_H_ */ 175#endif /* _DEV_PCI_VIRTIOREG_H_ */

cvs diff -r1.1 -r1.2 src/sys/dev/pci/virtiovar.h (expand / switch to unified diff)

--- src/sys/dev/pci/virtiovar.h 2011/10/30 12:12:21 1.1
+++ src/sys/dev/pci/virtiovar.h 2013/12/06 02:39:58 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ 1/* $NetBSD: virtiovar.h,v 1.2 2013/12/06 02:39:58 yamt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 Minoura Makoto. 4 * Copyright (c) 2010 Minoura Makoto.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -136,49 +136,26 @@ struct virtio_softc { @@ -136,49 +136,26 @@ struct virtio_softc {
136 bool sc_indirect; 136 bool sc_indirect;
137 137
138 int sc_nvqs; /* set by child */ 138 int sc_nvqs; /* set by child */
139 struct virtqueue *sc_vqs; /* set by child */ 139 struct virtqueue *sc_vqs; /* set by child */
140 140
141 int sc_childdevid; 141 int sc_childdevid;
142 device_t sc_child; /* set by child */ 142 device_t sc_child; /* set by child */
143 int (*sc_config_change)(struct virtio_softc*); 143 int (*sc_config_change)(struct virtio_softc*);
144 /* set by child */ 144 /* set by child */
145 int (*sc_intrhand)(struct virtio_softc*); 145 int (*sc_intrhand)(struct virtio_softc*);
146 /* set by child */ 146 /* set by child */
147}; 147};
148 148
149/* The standard layout for the ring is a continuous chunk of memory which 
150 * looks like this. We assume num is a power of 2. 
151 * 
152 * struct vring { 
153 * // The actual descriptors (16 bytes each) 
154 * struct vring_desc desc[num]; 
155 * 
156 * // A ring of available descriptor heads with free-running index. 
157 * __u16 avail_flags; 
158 * __u16 avail_idx; 
159 * __u16 available[num]; 
160 * 
161 * // Padding to the next align boundary. 
162 * char pad[]; 
163 * 
164 * // A ring of used descriptor heads with free-running index. 
165 * __u16 used_flags; 
166 * __u16 used_idx; 
167 * struct vring_used_elem used[num]; 
168 * }; 
169 * Note: for virtio PCI, align is 4096. 
170 */ 
171 
172/* public interface */ 149/* public interface */
173uint32_t virtio_negotiate_features(struct virtio_softc*, uint32_t); 150uint32_t virtio_negotiate_features(struct virtio_softc*, uint32_t);
174 151
175uint8_t virtio_read_device_config_1(struct virtio_softc *, int); 152uint8_t virtio_read_device_config_1(struct virtio_softc *, int);
176uint16_t virtio_read_device_config_2(struct virtio_softc *, int); 153uint16_t virtio_read_device_config_2(struct virtio_softc *, int);
177uint32_t virtio_read_device_config_4(struct virtio_softc *, int); 154uint32_t virtio_read_device_config_4(struct virtio_softc *, int);
178uint64_t virtio_read_device_config_8(struct virtio_softc *, int); 155uint64_t virtio_read_device_config_8(struct virtio_softc *, int);
179void virtio_write_device_config_1(struct virtio_softc *, int, uint8_t); 156void virtio_write_device_config_1(struct virtio_softc *, int, uint8_t);
180void virtio_write_device_config_2(struct virtio_softc *, int, uint16_t); 157void virtio_write_device_config_2(struct virtio_softc *, int, uint16_t);
181void virtio_write_device_config_4(struct virtio_softc *, int, uint32_t); 158void virtio_write_device_config_4(struct virtio_softc *, int, uint32_t);
182void virtio_write_device_config_8(struct virtio_softc *, int, uint64_t); 159void virtio_write_device_config_8(struct virtio_softc *, int, uint64_t);
183 160
184int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int, int, 161int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int, int,