From 2c73b2f10b59b8b441d4c357a3bdc47742552081 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Sat, 17 Sep 2016 22:19:26 +0300 Subject: [PATCH 1/2] lkl tools: virtio blk: fix capacity Fix reported capacity and add comments describing the required behaviour of the disk host backend operations. Signed-off-by: Octavian Purdila --- tools/lkl/include/lkl_host.h | 28 ++++++++++++++++++++++++++-- tools/lkl/lib/virtio_blk.c | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/lkl/include/lkl_host.h b/tools/lkl/include/lkl_host.h index 07208494af3279..2baddbc10334c7 100644 --- a/tools/lkl/include/lkl_host.h +++ b/tools/lkl/include/lkl_host.h @@ -30,12 +30,20 @@ struct iovec { extern struct lkl_dev_blk_ops lkl_dev_blk_ops; +/** + * struct lkl_blk_req - block device request + * + * @type: type of request + * @prio: priority of request - currently unused + * @sector: offset in units 512 bytes for read / write requests + * @buf: an array of buffers to be used for read / write requests + * @count: the number of buffers + */ +struct lkl_blk_req { #define LKL_DEV_BLK_TYPE_READ 0 #define LKL_DEV_BLK_TYPE_WRITE 1 #define LKL_DEV_BLK_TYPE_FLUSH 4 #define LKL_DEV_BLK_TYPE_FLUSH_OUT 5 - -struct lkl_blk_req { unsigned int type; unsigned int prio; unsigned long long sector; @@ -43,11 +51,27 @@ struct lkl_blk_req { int count; }; +/** + * struct lkl_dev_blk_ops - block device host operations + */ struct lkl_dev_blk_ops { + /** + * @get_capacity: returns the disk capacity in bytes + * + * @disk - the disk for which the capacity is requested; + * @res - pointer to receive the capacity, in bytes; + * @returns - 0 in case of success, negative value in case of error + */ int (*get_capacity)(struct lkl_disk disk, unsigned long long *res); #define LKL_DEV_BLK_STATUS_OK 0 #define LKL_DEV_BLK_STATUS_IOERR 1 #define LKL_DEV_BLK_STATUS_UNSUP 2 + /** + * @request: issue a block request + * + * @disk - the disk the request is issued to; + * @req - a request described by &struct lkl_blk_req + */ int (*request)(struct lkl_disk disk, struct lkl_blk_req *req); }; diff --git a/tools/lkl/lib/virtio_blk.c b/tools/lkl/lib/virtio_blk.c index 2c037cfd52490f..adde44cc012d35 100644 --- a/tools/lkl/lib/virtio_blk.c +++ b/tools/lkl/lib/virtio_blk.c @@ -96,7 +96,7 @@ int lkl_disk_add(struct lkl_disk *disk) ret = -LKL_ENOMEM; goto out_free; } - dev->config.capacity = capacity; + dev->config.capacity = capacity / 512; ret = virtio_dev_setup(&dev->dev, 1, 32); if (ret) From 6fc0b787106f2c48d74e0b56876e78f1188293f5 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Sat, 17 Sep 2016 22:25:00 +0300 Subject: [PATCH 2/2] lkl tools: virtio: fix kernel-doc comments Update a few comments to make them kernel-doc compatible. Signed-off-by: Octavian Purdila --- tools/lkl/include/lkl_host.h | 47 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/tools/lkl/include/lkl_host.h b/tools/lkl/include/lkl_host.h index 2baddbc10334c7..2dd8a2db83576d 100644 --- a/tools/lkl/include/lkl_host.h +++ b/tools/lkl/include/lkl_host.h @@ -13,7 +13,7 @@ extern struct lkl_host_operations lkl_host_ops; /** * lkl_printf - print a message via the host print operation * - * @fmt - printf like format string + * @fmt: printf like format string */ int lkl_printf(const char *fmt, ...); @@ -80,21 +80,25 @@ struct lkl_netdev { uint8_t has_vnet_hdr: 1; }; +/** + * struct lkl_dev_net_ops - network device host operations + */ struct lkl_dev_net_ops { - /* - * Writes a L2 packet into the net device. + /** + * @tx: writes a L2 packet into the net device * * The data buffer can only hold 0 or 1 complete packets. * - * @nd - pointer to the network device - * @iov - pointer to the buffer vector + * @nd - pointer to the network device; + * @iov - pointer to the buffer vector; * @cnt - # of vectors in iov. + * * @returns number of bytes transmitted */ int (*tx)(struct lkl_netdev *nd, struct iovec *iov, int cnt); - /* - * Reads a packet from the net device. + /** + * @rx: reads a packet from the net device. * * It must only read one complete packet if present. * @@ -104,6 +108,7 @@ struct lkl_dev_net_ops { * @nd - pointer to the network device * @iov - pointer to the buffer vector to store the packet * @cnt - # of vectors in iov. + * * @returns number of bytes read for success or < 0 if error */ int (*rx)(struct lkl_netdev *nd, struct iovec *iov, int cnt); @@ -112,28 +117,36 @@ struct lkl_dev_net_ops { #define LKL_DEV_NET_POLL_TX 2 #define LKL_DEV_NET_POLL_HUP 4 - /* - * Polls a net device. + /** + * @poll: polls a net device * - * Supports the following events: LKL_DEV_NET_POLL_RX (readable), - * LKL_DEV_NET_POLL_TX (writable) or LKL_DEV_NET_POLL_HUP (the close - * operations has been issued and we need to clean up). Blocks until one - * event is available. + * Supports the following events: LKL_DEV_NET_POLL_RX + * (readable), LKL_DEV_NET_POLL_TX (writable) or + * LKL_DEV_NET_POLL_HUP (the close operations has been issued + * and we need to clean up). Blocks until one event is + * available. * * @nd - pointer to the network device + * + * @returns - LKL_DEV_NET_POLL_RX, LKL_DEV_NET_POLL_TX, + * LKL_DEV_NET_POLL_HUP or a negative value for errors */ int (*poll)(struct lkl_netdev *nd); - /* - * Make poll wakeup and return LKL_DEV_NET_POLL_HUP. + /** + * @poll_hup: make poll wakeup and return LKL_DEV_NET_POLL_HUP + * + * @nd - pointer to the network device */ void (*poll_hup)(struct lkl_netdev *nd); - /* - * Frees a network device. + /** + * @free: frees a network device * * Implementation must release its resources and free the network device * structure. + * + * @nd - pointer to the network device */ void (*free)(struct lkl_netdev *nd); };