1b530cc79SEric Van Hensbergen /* 2fea511a6SEric Van Hensbergen * The Virtio 9p transport driver 3b530cc79SEric Van Hensbergen * 4e2735b77SEric Van Hensbergen * This is a block based transport driver based on the lguest block driver 5e2735b77SEric Van Hensbergen * code. 6b530cc79SEric Van Hensbergen * 7fea511a6SEric Van Hensbergen * Copyright (C) 2007, 2008 Eric Van Hensbergen, IBM Corporation 8b530cc79SEric Van Hensbergen * 9b530cc79SEric Van Hensbergen * Based on virtio console driver 10b530cc79SEric Van Hensbergen * Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation 11b530cc79SEric Van Hensbergen * 12b530cc79SEric Van Hensbergen * This program is free software; you can redistribute it and/or modify 13b530cc79SEric Van Hensbergen * it under the terms of the GNU General Public License version 2 14b530cc79SEric Van Hensbergen * as published by the Free Software Foundation. 15b530cc79SEric Van Hensbergen * 16b530cc79SEric Van Hensbergen * This program is distributed in the hope that it will be useful, 17b530cc79SEric Van Hensbergen * but WITHOUT ANY WARRANTY; without even the implied warranty of 18b530cc79SEric Van Hensbergen * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19b530cc79SEric Van Hensbergen * GNU General Public License for more details. 20b530cc79SEric Van Hensbergen * 21b530cc79SEric Van Hensbergen * You should have received a copy of the GNU General Public License 22b530cc79SEric Van Hensbergen * along with this program; if not, write to: 23b530cc79SEric Van Hensbergen * Free Software Foundation 24b530cc79SEric Van Hensbergen * 51 Franklin Street, Fifth Floor 25b530cc79SEric Van Hensbergen * Boston, MA 02111-1301 USA 26b530cc79SEric Van Hensbergen * 27b530cc79SEric Van Hensbergen */ 28b530cc79SEric Van Hensbergen 29*5d385153SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 30*5d385153SJoe Perches 31b530cc79SEric Van Hensbergen #include <linux/in.h> 32b530cc79SEric Van Hensbergen #include <linux/module.h> 33b530cc79SEric Van Hensbergen #include <linux/net.h> 34b530cc79SEric Van Hensbergen #include <linux/ipv6.h> 35b530cc79SEric Van Hensbergen #include <linux/errno.h> 36b530cc79SEric Van Hensbergen #include <linux/kernel.h> 37b530cc79SEric Van Hensbergen #include <linux/un.h> 38b530cc79SEric Van Hensbergen #include <linux/uaccess.h> 39b530cc79SEric Van Hensbergen #include <linux/inet.h> 40b530cc79SEric Van Hensbergen #include <linux/idr.h> 41b530cc79SEric Van Hensbergen #include <linux/file.h> 425a0e3ad6STejun Heo #include <linux/slab.h> 43b530cc79SEric Van Hensbergen #include <net/9p/9p.h> 44b530cc79SEric Van Hensbergen #include <linux/parser.h> 458b81ef58SEric Van Hensbergen #include <net/9p/client.h> 46b530cc79SEric Van Hensbergen #include <net/9p/transport.h> 47b530cc79SEric Van Hensbergen #include <linux/scatterlist.h> 4868da9ba4SVenkateswararao Jujjuri (JV) #include <linux/swap.h> 49b530cc79SEric Van Hensbergen #include <linux/virtio.h> 50b530cc79SEric Van Hensbergen #include <linux/virtio_9p.h> 514038866dSVenkateswararao Jujjuri (JV) #include "trans_common.h" 52b530cc79SEric Van Hensbergen 53e2735b77SEric Van Hensbergen #define VIRTQUEUE_NUM 128 54e2735b77SEric Van Hensbergen 55b530cc79SEric Van Hensbergen /* a single mutex to manage channel initialization and attachment */ 56c1549497SJosef 'Jeff' Sipek static DEFINE_MUTEX(virtio_9p_lock); 5768da9ba4SVenkateswararao Jujjuri (JV) static DECLARE_WAIT_QUEUE_HEAD(vp_wq); 5868da9ba4SVenkateswararao Jujjuri (JV) static atomic_t vp_pinned = ATOMIC_INIT(0); 59b530cc79SEric Van Hensbergen 60ee443996SEric Van Hensbergen /** 61ee443996SEric Van Hensbergen * struct virtio_chan - per-instance transport information 62ee443996SEric Van Hensbergen * @initialized: whether the channel is initialized 63ee443996SEric Van Hensbergen * @inuse: whether the channel is in use 64ee443996SEric Van Hensbergen * @lock: protects multiple elements within this structure 650e15597eSAbhishek Kulkarni * @client: client instance 66ee443996SEric Van Hensbergen * @vdev: virtio dev associated with this channel 67ee443996SEric Van Hensbergen * @vq: virtio queue associated with this channel 68ee443996SEric Van Hensbergen * @sg: scatter gather list which is used to pack a request (protected?) 69ee443996SEric Van Hensbergen * 70ee443996SEric Van Hensbergen * We keep all per-channel information in a structure. 71b530cc79SEric Van Hensbergen * This structure is allocated within the devices dev->mem space. 72b530cc79SEric Van Hensbergen * A pointer to the structure will get put in the transport private. 73ee443996SEric Van Hensbergen * 74b530cc79SEric Van Hensbergen */ 75ee443996SEric Van Hensbergen 7637c1209dSAneesh Kumar K.V struct virtio_chan { 77ee443996SEric Van Hensbergen bool inuse; 78b530cc79SEric Van Hensbergen 79e2735b77SEric Van Hensbergen spinlock_t lock; 80e2735b77SEric Van Hensbergen 81fea511a6SEric Van Hensbergen struct p9_client *client; 82b530cc79SEric Van Hensbergen struct virtio_device *vdev; 83e2735b77SEric Van Hensbergen struct virtqueue *vq; 8452f44e0dSVenkateswararao Jujjuri (JV) int ring_bufs_avail; 8552f44e0dSVenkateswararao Jujjuri (JV) wait_queue_head_t *vc_wq; 8668da9ba4SVenkateswararao Jujjuri (JV) /* This is global limit. Since we don't have a global structure, 8768da9ba4SVenkateswararao Jujjuri (JV) * will be placing it in each channel. 8868da9ba4SVenkateswararao Jujjuri (JV) */ 8968da9ba4SVenkateswararao Jujjuri (JV) int p9_max_pages; 90e2735b77SEric Van Hensbergen /* Scatterlist: can be too big for stack. */ 91e2735b77SEric Van Hensbergen struct scatterlist sg[VIRTQUEUE_NUM]; 9237c1209dSAneesh Kumar K.V 9397ee9b02SAneesh Kumar K.V int tag_len; 9497ee9b02SAneesh Kumar K.V /* 9597ee9b02SAneesh Kumar K.V * tag name to identify a mount Non-null terminated 9697ee9b02SAneesh Kumar K.V */ 9797ee9b02SAneesh Kumar K.V char *tag; 9897ee9b02SAneesh Kumar K.V 9937c1209dSAneesh Kumar K.V struct list_head chan_list; 10037c1209dSAneesh Kumar K.V }; 10137c1209dSAneesh Kumar K.V 10237c1209dSAneesh Kumar K.V static struct list_head virtio_chan_list; 103b530cc79SEric Van Hensbergen 104b530cc79SEric Van Hensbergen /* How many bytes left in this page. */ 105b530cc79SEric Van Hensbergen static unsigned int rest_of_page(void *data) 106b530cc79SEric Van Hensbergen { 107b530cc79SEric Van Hensbergen return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); 108b530cc79SEric Van Hensbergen } 109b530cc79SEric Van Hensbergen 110ee443996SEric Van Hensbergen /** 111ee443996SEric Van Hensbergen * p9_virtio_close - reclaim resources of a channel 1120e15597eSAbhishek Kulkarni * @client: client instance 113ee443996SEric Van Hensbergen * 114ee443996SEric Van Hensbergen * This reclaims a channel by freeing its resources and 115ee443996SEric Van Hensbergen * reseting its inuse flag. 116ee443996SEric Van Hensbergen * 117ee443996SEric Van Hensbergen */ 118ee443996SEric Van Hensbergen 1198b81ef58SEric Van Hensbergen static void p9_virtio_close(struct p9_client *client) 120b530cc79SEric Van Hensbergen { 1218b81ef58SEric Van Hensbergen struct virtio_chan *chan = client->trans; 122b530cc79SEric Van Hensbergen 123c1549497SJosef 'Jeff' Sipek mutex_lock(&virtio_9p_lock); 124fb786100SAneesh Kumar K.V if (chan) 125b530cc79SEric Van Hensbergen chan->inuse = false; 126c1549497SJosef 'Jeff' Sipek mutex_unlock(&virtio_9p_lock); 127b530cc79SEric Van Hensbergen } 128b530cc79SEric Van Hensbergen 129ee443996SEric Van Hensbergen /** 130ee443996SEric Van Hensbergen * req_done - callback which signals activity from the server 131ee443996SEric Van Hensbergen * @vq: virtio queue activity was received on 132ee443996SEric Van Hensbergen * 133ee443996SEric Van Hensbergen * This notifies us that the server has triggered some activity 134ee443996SEric Van Hensbergen * on the virtio channel - most likely a response to request we 135ee443996SEric Van Hensbergen * sent. Figure out which requests now have responses and wake up 136ee443996SEric Van Hensbergen * those threads. 137ee443996SEric Van Hensbergen * 138ee443996SEric Van Hensbergen * Bugs: could do with some additional sanity checking, but appears to work. 139ee443996SEric Van Hensbergen * 140ee443996SEric Van Hensbergen */ 141ee443996SEric Van Hensbergen 142e2735b77SEric Van Hensbergen static void req_done(struct virtqueue *vq) 143b530cc79SEric Van Hensbergen { 144e2735b77SEric Van Hensbergen struct virtio_chan *chan = vq->vdev->priv; 145e2735b77SEric Van Hensbergen struct p9_fcall *rc; 146e2735b77SEric Van Hensbergen unsigned int len; 147e2735b77SEric Van Hensbergen struct p9_req_t *req; 148419b3956SVenkateswararao Jujjuri (JV) unsigned long flags; 149b530cc79SEric Van Hensbergen 150*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, ": request done\n"); 15191b8534fSEric Van Hensbergen 152a01a9840SVenkateswararao Jujjuri (JV) while (1) { 153419b3956SVenkateswararao Jujjuri (JV) spin_lock_irqsave(&chan->lock, flags); 154419b3956SVenkateswararao Jujjuri (JV) rc = virtqueue_get_buf(chan->vq, &len); 155a01a9840SVenkateswararao Jujjuri (JV) if (rc == NULL) { 156a01a9840SVenkateswararao Jujjuri (JV) spin_unlock_irqrestore(&chan->lock, flags); 157a01a9840SVenkateswararao Jujjuri (JV) break; 158a01a9840SVenkateswararao Jujjuri (JV) } 15952f44e0dSVenkateswararao Jujjuri (JV) chan->ring_bufs_avail = 1; 16052f44e0dSVenkateswararao Jujjuri (JV) spin_unlock_irqrestore(&chan->lock, flags); 16153bda3e5SVenkateswararao Jujjuri (JV) /* Wakeup if anyone waiting for VirtIO ring space. */ 16253bda3e5SVenkateswararao Jujjuri (JV) wake_up(chan->vc_wq); 163*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, ": rc %p\n", rc); 164*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, ": lookup tag %d\n", rc->tag); 165fea511a6SEric Van Hensbergen req = p9_tag_lookup(chan->client, rc->tag); 166a01a9840SVenkateswararao Jujjuri (JV) req->status = REQ_STATUS_RCVD; 16791b8534fSEric Van Hensbergen p9_client_cb(chan->client, req); 168e2735b77SEric Van Hensbergen } 169b530cc79SEric Van Hensbergen } 170b530cc79SEric Van Hensbergen 171ee443996SEric Van Hensbergen /** 172ee443996SEric Van Hensbergen * pack_sg_list - pack a scatter gather list from a linear buffer 173ee443996SEric Van Hensbergen * @sg: scatter/gather list to pack into 174ee443996SEric Van Hensbergen * @start: which segment of the sg_list to start at 175ee443996SEric Van Hensbergen * @limit: maximum segment to pack data to 176ee443996SEric Van Hensbergen * @data: data to pack into scatter/gather list 177ee443996SEric Van Hensbergen * @count: amount of data to pack into the scatter/gather list 178ee443996SEric Van Hensbergen * 179ee443996SEric Van Hensbergen * sg_lists have multiple segments of various sizes. This will pack 180ee443996SEric Van Hensbergen * arbitrary data into an existing scatter gather list, segmenting the 181ee443996SEric Van Hensbergen * data as necessary within constraints. 182ee443996SEric Van Hensbergen * 183ee443996SEric Van Hensbergen */ 184ee443996SEric Van Hensbergen 185abfa034eSAneesh Kumar K.V static int pack_sg_list(struct scatterlist *sg, int start, 186abfa034eSAneesh Kumar K.V int limit, char *data, int count) 187e2735b77SEric Van Hensbergen { 188e2735b77SEric Van Hensbergen int s; 189e2735b77SEric Van Hensbergen int index = start; 190e2735b77SEric Van Hensbergen 191e2735b77SEric Van Hensbergen while (count) { 192e2735b77SEric Van Hensbergen s = rest_of_page(data); 193e2735b77SEric Van Hensbergen if (s > count) 194e2735b77SEric Van Hensbergen s = count; 195e2735b77SEric Van Hensbergen sg_set_buf(&sg[index++], data, s); 196e2735b77SEric Van Hensbergen count -= s; 197e2735b77SEric Van Hensbergen data += s; 198d6584f3aSJulia Lawall BUG_ON(index > limit); 199e2735b77SEric Van Hensbergen } 200e2735b77SEric Van Hensbergen 201e2735b77SEric Van Hensbergen return index-start; 202e2735b77SEric Van Hensbergen } 203e2735b77SEric Van Hensbergen 20491b8534fSEric Van Hensbergen /* We don't currently allow canceling of virtio requests */ 20591b8534fSEric Van Hensbergen static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req) 20691b8534fSEric Van Hensbergen { 20791b8534fSEric Van Hensbergen return 1; 20891b8534fSEric Van Hensbergen } 20991b8534fSEric Van Hensbergen 210ee443996SEric Van Hensbergen /** 2114038866dSVenkateswararao Jujjuri (JV) * pack_sg_list_p - Just like pack_sg_list. Instead of taking a buffer, 2124038866dSVenkateswararao Jujjuri (JV) * this takes a list of pages. 2134038866dSVenkateswararao Jujjuri (JV) * @sg: scatter/gather list to pack into 2144038866dSVenkateswararao Jujjuri (JV) * @start: which segment of the sg_list to start at 2154038866dSVenkateswararao Jujjuri (JV) * @**pdata: a list of pages to add into sg. 216abfa034eSAneesh Kumar K.V * @nr_pages: number of pages to pack into the scatter/gather list 217abfa034eSAneesh Kumar K.V * @data: data to pack into scatter/gather list 2184038866dSVenkateswararao Jujjuri (JV) * @count: amount of data to pack into the scatter/gather list 2194038866dSVenkateswararao Jujjuri (JV) */ 2204038866dSVenkateswararao Jujjuri (JV) static int 221abfa034eSAneesh Kumar K.V pack_sg_list_p(struct scatterlist *sg, int start, int limit, 222abfa034eSAneesh Kumar K.V struct page **pdata, int nr_pages, char *data, int count) 2234038866dSVenkateswararao Jujjuri (JV) { 224abfa034eSAneesh Kumar K.V int i = 0, s; 225abfa034eSAneesh Kumar K.V int data_off; 2264038866dSVenkateswararao Jujjuri (JV) int index = start; 2274038866dSVenkateswararao Jujjuri (JV) 228abfa034eSAneesh Kumar K.V BUG_ON(nr_pages > (limit - start)); 229abfa034eSAneesh Kumar K.V /* 230abfa034eSAneesh Kumar K.V * if the first page doesn't start at 231abfa034eSAneesh Kumar K.V * page boundary find the offset 232abfa034eSAneesh Kumar K.V */ 233abfa034eSAneesh Kumar K.V data_off = offset_in_page(data); 234abfa034eSAneesh Kumar K.V while (nr_pages) { 235abfa034eSAneesh Kumar K.V s = rest_of_page(data); 236abfa034eSAneesh Kumar K.V if (s > count) 237abfa034eSAneesh Kumar K.V s = count; 238abfa034eSAneesh Kumar K.V sg_set_page(&sg[index++], pdata[i++], s, data_off); 239abfa034eSAneesh Kumar K.V data_off = 0; 240abfa034eSAneesh Kumar K.V data += s; 2414038866dSVenkateswararao Jujjuri (JV) count -= s; 242abfa034eSAneesh Kumar K.V nr_pages--; 2434038866dSVenkateswararao Jujjuri (JV) } 2444038866dSVenkateswararao Jujjuri (JV) return index - start; 2454038866dSVenkateswararao Jujjuri (JV) } 2464038866dSVenkateswararao Jujjuri (JV) 2474038866dSVenkateswararao Jujjuri (JV) /** 24891b8534fSEric Van Hensbergen * p9_virtio_request - issue a request 2490e15597eSAbhishek Kulkarni * @client: client instance issuing the request 2500e15597eSAbhishek Kulkarni * @req: request to be issued 251ee443996SEric Van Hensbergen * 252ee443996SEric Van Hensbergen */ 253ee443996SEric Van Hensbergen 254e2735b77SEric Van Hensbergen static int 25591b8534fSEric Van Hensbergen p9_virtio_request(struct p9_client *client, struct p9_req_t *req) 256e2735b77SEric Van Hensbergen { 257abfa034eSAneesh Kumar K.V int err; 258abfa034eSAneesh Kumar K.V int in, out; 259419b3956SVenkateswararao Jujjuri (JV) unsigned long flags; 260abfa034eSAneesh Kumar K.V struct virtio_chan *chan = client->trans; 261e2735b77SEric Van Hensbergen 262*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "9p debug: virtio request\n"); 263e2735b77SEric Van Hensbergen 264419b3956SVenkateswararao Jujjuri (JV) req->status = REQ_STATUS_SENT; 265abfa034eSAneesh Kumar K.V req_retry: 266419b3956SVenkateswararao Jujjuri (JV) spin_lock_irqsave(&chan->lock, flags); 2674038866dSVenkateswararao Jujjuri (JV) 2684038866dSVenkateswararao Jujjuri (JV) /* Handle out VirtIO ring buffers */ 269abfa034eSAneesh Kumar K.V out = pack_sg_list(chan->sg, 0, 270abfa034eSAneesh Kumar K.V VIRTQUEUE_NUM, req->tc->sdata, req->tc->size); 2714038866dSVenkateswararao Jujjuri (JV) 272abfa034eSAneesh Kumar K.V in = pack_sg_list(chan->sg, out, 273abfa034eSAneesh Kumar K.V VIRTQUEUE_NUM, req->rc->sdata, req->rc->capacity); 274e2735b77SEric Van Hensbergen 275419b3956SVenkateswararao Jujjuri (JV) err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); 276419b3956SVenkateswararao Jujjuri (JV) if (err < 0) { 27752f44e0dSVenkateswararao Jujjuri (JV) if (err == -ENOSPC) { 27852f44e0dSVenkateswararao Jujjuri (JV) chan->ring_bufs_avail = 0; 27952f44e0dSVenkateswararao Jujjuri (JV) spin_unlock_irqrestore(&chan->lock, flags); 28052f44e0dSVenkateswararao Jujjuri (JV) err = wait_event_interruptible(*chan->vc_wq, 28152f44e0dSVenkateswararao Jujjuri (JV) chan->ring_bufs_avail); 28252f44e0dSVenkateswararao Jujjuri (JV) if (err == -ERESTARTSYS) 28352f44e0dSVenkateswararao Jujjuri (JV) return err; 28452f44e0dSVenkateswararao Jujjuri (JV) 285*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "Retry virtio request\n"); 286abfa034eSAneesh Kumar K.V goto req_retry; 287abfa034eSAneesh Kumar K.V } else { 288abfa034eSAneesh Kumar K.V spin_unlock_irqrestore(&chan->lock, flags); 289*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, 290*5d385153SJoe Perches "virtio rpc add_buf returned failure\n"); 291abfa034eSAneesh Kumar K.V return -EIO; 292abfa034eSAneesh Kumar K.V } 293abfa034eSAneesh Kumar K.V } 294abfa034eSAneesh Kumar K.V virtqueue_kick(chan->vq); 295abfa034eSAneesh Kumar K.V spin_unlock_irqrestore(&chan->lock, flags); 296abfa034eSAneesh Kumar K.V 297*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n"); 298abfa034eSAneesh Kumar K.V return 0; 299abfa034eSAneesh Kumar K.V } 300abfa034eSAneesh Kumar K.V 301abfa034eSAneesh Kumar K.V static int p9_get_mapped_pages(struct virtio_chan *chan, 302abfa034eSAneesh Kumar K.V struct page **pages, char *data, 303abfa034eSAneesh Kumar K.V int nr_pages, int write, int kern_buf) 304abfa034eSAneesh Kumar K.V { 305abfa034eSAneesh Kumar K.V int err; 306abfa034eSAneesh Kumar K.V if (!kern_buf) { 307abfa034eSAneesh Kumar K.V /* 308abfa034eSAneesh Kumar K.V * We allow only p9_max_pages pinned. We wait for the 309abfa034eSAneesh Kumar K.V * Other zc request to finish here 310abfa034eSAneesh Kumar K.V */ 311abfa034eSAneesh Kumar K.V if (atomic_read(&vp_pinned) >= chan->p9_max_pages) { 312abfa034eSAneesh Kumar K.V err = wait_event_interruptible(vp_wq, 313abfa034eSAneesh Kumar K.V (atomic_read(&vp_pinned) < chan->p9_max_pages)); 314abfa034eSAneesh Kumar K.V if (err == -ERESTARTSYS) 315abfa034eSAneesh Kumar K.V return err; 316abfa034eSAneesh Kumar K.V } 317abfa034eSAneesh Kumar K.V err = p9_payload_gup(data, &nr_pages, pages, write); 318abfa034eSAneesh Kumar K.V if (err < 0) 319abfa034eSAneesh Kumar K.V return err; 320abfa034eSAneesh Kumar K.V atomic_add(nr_pages, &vp_pinned); 321abfa034eSAneesh Kumar K.V } else { 322abfa034eSAneesh Kumar K.V /* kernel buffer, no need to pin pages */ 323abfa034eSAneesh Kumar K.V int s, index = 0; 324abfa034eSAneesh Kumar K.V int count = nr_pages; 325abfa034eSAneesh Kumar K.V while (nr_pages) { 326abfa034eSAneesh Kumar K.V s = rest_of_page(data); 327abfa034eSAneesh Kumar K.V pages[index++] = virt_to_page(data); 328abfa034eSAneesh Kumar K.V data += s; 329abfa034eSAneesh Kumar K.V nr_pages--; 330abfa034eSAneesh Kumar K.V } 331abfa034eSAneesh Kumar K.V nr_pages = count; 332abfa034eSAneesh Kumar K.V } 333abfa034eSAneesh Kumar K.V return nr_pages; 334abfa034eSAneesh Kumar K.V } 335abfa034eSAneesh Kumar K.V 336abfa034eSAneesh Kumar K.V /** 337abfa034eSAneesh Kumar K.V * p9_virtio_zc_request - issue a zero copy request 338abfa034eSAneesh Kumar K.V * @client: client instance issuing the request 339abfa034eSAneesh Kumar K.V * @req: request to be issued 340abfa034eSAneesh Kumar K.V * @uidata: user bffer that should be ued for zero copy read 341abfa034eSAneesh Kumar K.V * @uodata: user buffer that shoud be user for zero copy write 342abfa034eSAneesh Kumar K.V * @inlen: read buffer size 343abfa034eSAneesh Kumar K.V * @olen: write buffer size 344abfa034eSAneesh Kumar K.V * @hdrlen: reader header size, This is the size of response protocol data 345abfa034eSAneesh Kumar K.V * 346abfa034eSAneesh Kumar K.V */ 347abfa034eSAneesh Kumar K.V static int 348abfa034eSAneesh Kumar K.V p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, 349abfa034eSAneesh Kumar K.V char *uidata, char *uodata, int inlen, 350abfa034eSAneesh Kumar K.V int outlen, int in_hdr_len, int kern_buf) 351abfa034eSAneesh Kumar K.V { 352abfa034eSAneesh Kumar K.V int in, out, err; 353abfa034eSAneesh Kumar K.V unsigned long flags; 354abfa034eSAneesh Kumar K.V int in_nr_pages = 0, out_nr_pages = 0; 355abfa034eSAneesh Kumar K.V struct page **in_pages = NULL, **out_pages = NULL; 356abfa034eSAneesh Kumar K.V struct virtio_chan *chan = client->trans; 357abfa034eSAneesh Kumar K.V 358*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "virtio request\n"); 359abfa034eSAneesh Kumar K.V 360abfa034eSAneesh Kumar K.V if (uodata) { 361abfa034eSAneesh Kumar K.V out_nr_pages = p9_nr_pages(uodata, outlen); 362abfa034eSAneesh Kumar K.V out_pages = kmalloc(sizeof(struct page *) * out_nr_pages, 363abfa034eSAneesh Kumar K.V GFP_NOFS); 364abfa034eSAneesh Kumar K.V if (!out_pages) { 365abfa034eSAneesh Kumar K.V err = -ENOMEM; 366abfa034eSAneesh Kumar K.V goto err_out; 367abfa034eSAneesh Kumar K.V } 368abfa034eSAneesh Kumar K.V out_nr_pages = p9_get_mapped_pages(chan, out_pages, uodata, 369abfa034eSAneesh Kumar K.V out_nr_pages, 0, kern_buf); 370abfa034eSAneesh Kumar K.V if (out_nr_pages < 0) { 371abfa034eSAneesh Kumar K.V err = out_nr_pages; 372abfa034eSAneesh Kumar K.V kfree(out_pages); 373abfa034eSAneesh Kumar K.V out_pages = NULL; 374abfa034eSAneesh Kumar K.V goto err_out; 375abfa034eSAneesh Kumar K.V } 376abfa034eSAneesh Kumar K.V } 377abfa034eSAneesh Kumar K.V if (uidata) { 378abfa034eSAneesh Kumar K.V in_nr_pages = p9_nr_pages(uidata, inlen); 379abfa034eSAneesh Kumar K.V in_pages = kmalloc(sizeof(struct page *) * in_nr_pages, 380abfa034eSAneesh Kumar K.V GFP_NOFS); 381abfa034eSAneesh Kumar K.V if (!in_pages) { 382abfa034eSAneesh Kumar K.V err = -ENOMEM; 383abfa034eSAneesh Kumar K.V goto err_out; 384abfa034eSAneesh Kumar K.V } 385abfa034eSAneesh Kumar K.V in_nr_pages = p9_get_mapped_pages(chan, in_pages, uidata, 386abfa034eSAneesh Kumar K.V in_nr_pages, 1, kern_buf); 387abfa034eSAneesh Kumar K.V if (in_nr_pages < 0) { 388abfa034eSAneesh Kumar K.V err = in_nr_pages; 389abfa034eSAneesh Kumar K.V kfree(in_pages); 390abfa034eSAneesh Kumar K.V in_pages = NULL; 391abfa034eSAneesh Kumar K.V goto err_out; 392abfa034eSAneesh Kumar K.V } 393abfa034eSAneesh Kumar K.V } 394abfa034eSAneesh Kumar K.V req->status = REQ_STATUS_SENT; 395abfa034eSAneesh Kumar K.V req_retry_pinned: 396abfa034eSAneesh Kumar K.V spin_lock_irqsave(&chan->lock, flags); 397abfa034eSAneesh Kumar K.V /* out data */ 398abfa034eSAneesh Kumar K.V out = pack_sg_list(chan->sg, 0, 399abfa034eSAneesh Kumar K.V VIRTQUEUE_NUM, req->tc->sdata, req->tc->size); 400abfa034eSAneesh Kumar K.V 401abfa034eSAneesh Kumar K.V if (out_pages) 402abfa034eSAneesh Kumar K.V out += pack_sg_list_p(chan->sg, out, VIRTQUEUE_NUM, 403abfa034eSAneesh Kumar K.V out_pages, out_nr_pages, uodata, outlen); 404abfa034eSAneesh Kumar K.V /* 405abfa034eSAneesh Kumar K.V * Take care of in data 406abfa034eSAneesh Kumar K.V * For example TREAD have 11. 407abfa034eSAneesh Kumar K.V * 11 is the read/write header = PDU Header(7) + IO Size (4). 408abfa034eSAneesh Kumar K.V * Arrange in such a way that server places header in the 409abfa034eSAneesh Kumar K.V * alloced memory and payload onto the user buffer. 410abfa034eSAneesh Kumar K.V */ 411abfa034eSAneesh Kumar K.V in = pack_sg_list(chan->sg, out, 412abfa034eSAneesh Kumar K.V VIRTQUEUE_NUM, req->rc->sdata, in_hdr_len); 413abfa034eSAneesh Kumar K.V if (in_pages) 414abfa034eSAneesh Kumar K.V in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM, 415abfa034eSAneesh Kumar K.V in_pages, in_nr_pages, uidata, inlen); 416abfa034eSAneesh Kumar K.V 417abfa034eSAneesh Kumar K.V err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); 418abfa034eSAneesh Kumar K.V if (err < 0) { 419abfa034eSAneesh Kumar K.V if (err == -ENOSPC) { 420abfa034eSAneesh Kumar K.V chan->ring_bufs_avail = 0; 421abfa034eSAneesh Kumar K.V spin_unlock_irqrestore(&chan->lock, flags); 422abfa034eSAneesh Kumar K.V err = wait_event_interruptible(*chan->vc_wq, 423abfa034eSAneesh Kumar K.V chan->ring_bufs_avail); 424abfa034eSAneesh Kumar K.V if (err == -ERESTARTSYS) 425abfa034eSAneesh Kumar K.V goto err_out; 426abfa034eSAneesh Kumar K.V 427*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "Retry virtio request\n"); 428316ad550SVenkateswararao Jujjuri (JV) goto req_retry_pinned; 42952f44e0dSVenkateswararao Jujjuri (JV) } else { 430419b3956SVenkateswararao Jujjuri (JV) spin_unlock_irqrestore(&chan->lock, flags); 431*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, 432*5d385153SJoe Perches "virtio rpc add_buf returned failure\n"); 433abfa034eSAneesh Kumar K.V err = -EIO; 434abfa034eSAneesh Kumar K.V goto err_out; 435e2735b77SEric Van Hensbergen } 43652f44e0dSVenkateswararao Jujjuri (JV) } 437dc3f5e68SMichael S. Tsirkin virtqueue_kick(chan->vq); 438419b3956SVenkateswararao Jujjuri (JV) spin_unlock_irqrestore(&chan->lock, flags); 439*5d385153SJoe Perches p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n"); 440abfa034eSAneesh Kumar K.V err = wait_event_interruptible(*req->wq, 441abfa034eSAneesh Kumar K.V req->status >= REQ_STATUS_RCVD); 442abfa034eSAneesh Kumar K.V /* 443abfa034eSAneesh Kumar K.V * Non kernel buffers are pinned, unpin them 444abfa034eSAneesh Kumar K.V */ 445abfa034eSAneesh Kumar K.V err_out: 446abfa034eSAneesh Kumar K.V if (!kern_buf) { 447abfa034eSAneesh Kumar K.V if (in_pages) { 448abfa034eSAneesh Kumar K.V p9_release_pages(in_pages, in_nr_pages); 449abfa034eSAneesh Kumar K.V atomic_sub(in_nr_pages, &vp_pinned); 450abfa034eSAneesh Kumar K.V } 451abfa034eSAneesh Kumar K.V if (out_pages) { 452abfa034eSAneesh Kumar K.V p9_release_pages(out_pages, out_nr_pages); 453abfa034eSAneesh Kumar K.V atomic_sub(out_nr_pages, &vp_pinned); 454abfa034eSAneesh Kumar K.V } 455abfa034eSAneesh Kumar K.V /* wakeup anybody waiting for slots to pin pages */ 456abfa034eSAneesh Kumar K.V wake_up(&vp_wq); 457abfa034eSAneesh Kumar K.V } 458abfa034eSAneesh Kumar K.V kfree(in_pages); 459abfa034eSAneesh Kumar K.V kfree(out_pages); 460abfa034eSAneesh Kumar K.V return err; 461e2735b77SEric Van Hensbergen } 462e2735b77SEric Van Hensbergen 46386c84373SAneesh Kumar K.V static ssize_t p9_mount_tag_show(struct device *dev, 46486c84373SAneesh Kumar K.V struct device_attribute *attr, char *buf) 46586c84373SAneesh Kumar K.V { 46686c84373SAneesh Kumar K.V struct virtio_chan *chan; 46786c84373SAneesh Kumar K.V struct virtio_device *vdev; 46886c84373SAneesh Kumar K.V 46986c84373SAneesh Kumar K.V vdev = dev_to_virtio(dev); 47086c84373SAneesh Kumar K.V chan = vdev->priv; 47186c84373SAneesh Kumar K.V 47286c84373SAneesh Kumar K.V return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); 47386c84373SAneesh Kumar K.V } 47486c84373SAneesh Kumar K.V 47586c84373SAneesh Kumar K.V static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL); 47686c84373SAneesh Kumar K.V 477ee443996SEric Van Hensbergen /** 478ee443996SEric Van Hensbergen * p9_virtio_probe - probe for existence of 9P virtio channels 479ee443996SEric Van Hensbergen * @vdev: virtio device to probe 480ee443996SEric Van Hensbergen * 48137c1209dSAneesh Kumar K.V * This probes for existing virtio channels. 482ee443996SEric Van Hensbergen * 483ee443996SEric Van Hensbergen */ 484ee443996SEric Van Hensbergen 485e2735b77SEric Van Hensbergen static int p9_virtio_probe(struct virtio_device *vdev) 486b530cc79SEric Van Hensbergen { 48797ee9b02SAneesh Kumar K.V __u16 tag_len; 48897ee9b02SAneesh Kumar K.V char *tag; 489b530cc79SEric Van Hensbergen int err; 490b530cc79SEric Van Hensbergen struct virtio_chan *chan; 491b530cc79SEric Van Hensbergen 49237c1209dSAneesh Kumar K.V chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL); 49337c1209dSAneesh Kumar K.V if (!chan) { 494*5d385153SJoe Perches pr_err("Failed to allocate virtio 9P channel\n"); 495b530cc79SEric Van Hensbergen err = -ENOMEM; 496b530cc79SEric Van Hensbergen goto fail; 497b530cc79SEric Van Hensbergen } 498b530cc79SEric Van Hensbergen 499e2735b77SEric Van Hensbergen chan->vdev = vdev; 500e2735b77SEric Van Hensbergen 501e2735b77SEric Van Hensbergen /* We expect one virtqueue, for requests. */ 502d2a7dddaSMichael S. Tsirkin chan->vq = virtio_find_single_vq(vdev, req_done, "requests"); 503e2735b77SEric Van Hensbergen if (IS_ERR(chan->vq)) { 504e2735b77SEric Van Hensbergen err = PTR_ERR(chan->vq); 505e2735b77SEric Van Hensbergen goto out_free_vq; 506b530cc79SEric Van Hensbergen } 507e2735b77SEric Van Hensbergen chan->vq->vdev->priv = chan; 508e2735b77SEric Van Hensbergen spin_lock_init(&chan->lock); 509b530cc79SEric Van Hensbergen 510e2735b77SEric Van Hensbergen sg_init_table(chan->sg, VIRTQUEUE_NUM); 511b530cc79SEric Van Hensbergen 512b530cc79SEric Van Hensbergen chan->inuse = false; 51397ee9b02SAneesh Kumar K.V if (virtio_has_feature(vdev, VIRTIO_9P_MOUNT_TAG)) { 51497ee9b02SAneesh Kumar K.V vdev->config->get(vdev, 51597ee9b02SAneesh Kumar K.V offsetof(struct virtio_9p_config, tag_len), 51697ee9b02SAneesh Kumar K.V &tag_len, sizeof(tag_len)); 51797ee9b02SAneesh Kumar K.V } else { 51897ee9b02SAneesh Kumar K.V err = -EINVAL; 51997ee9b02SAneesh Kumar K.V goto out_free_vq; 52097ee9b02SAneesh Kumar K.V } 52197ee9b02SAneesh Kumar K.V tag = kmalloc(tag_len, GFP_KERNEL); 52297ee9b02SAneesh Kumar K.V if (!tag) { 52397ee9b02SAneesh Kumar K.V err = -ENOMEM; 52497ee9b02SAneesh Kumar K.V goto out_free_vq; 52597ee9b02SAneesh Kumar K.V } 52697ee9b02SAneesh Kumar K.V vdev->config->get(vdev, offsetof(struct virtio_9p_config, tag), 52797ee9b02SAneesh Kumar K.V tag, tag_len); 52897ee9b02SAneesh Kumar K.V chan->tag = tag; 52997ee9b02SAneesh Kumar K.V chan->tag_len = tag_len; 53086c84373SAneesh Kumar K.V err = sysfs_create_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr); 53186c84373SAneesh Kumar K.V if (err) { 53252f44e0dSVenkateswararao Jujjuri (JV) goto out_free_tag; 53386c84373SAneesh Kumar K.V } 53452f44e0dSVenkateswararao Jujjuri (JV) chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL); 53552f44e0dSVenkateswararao Jujjuri (JV) if (!chan->vc_wq) { 53652f44e0dSVenkateswararao Jujjuri (JV) err = -ENOMEM; 53752f44e0dSVenkateswararao Jujjuri (JV) goto out_free_tag; 53852f44e0dSVenkateswararao Jujjuri (JV) } 53952f44e0dSVenkateswararao Jujjuri (JV) init_waitqueue_head(chan->vc_wq); 54052f44e0dSVenkateswararao Jujjuri (JV) chan->ring_bufs_avail = 1; 54168da9ba4SVenkateswararao Jujjuri (JV) /* Ceiling limit to avoid denial of service attacks */ 54268da9ba4SVenkateswararao Jujjuri (JV) chan->p9_max_pages = nr_free_buffer_pages()/4; 54352f44e0dSVenkateswararao Jujjuri (JV) 54437c1209dSAneesh Kumar K.V mutex_lock(&virtio_9p_lock); 54537c1209dSAneesh Kumar K.V list_add_tail(&chan->chan_list, &virtio_chan_list); 54637c1209dSAneesh Kumar K.V mutex_unlock(&virtio_9p_lock); 547b530cc79SEric Van Hensbergen return 0; 548b530cc79SEric Van Hensbergen 54952f44e0dSVenkateswararao Jujjuri (JV) out_free_tag: 55052f44e0dSVenkateswararao Jujjuri (JV) kfree(tag); 551e2735b77SEric Van Hensbergen out_free_vq: 552d2a7dddaSMichael S. Tsirkin vdev->config->del_vqs(vdev); 55337c1209dSAneesh Kumar K.V kfree(chan); 554b530cc79SEric Van Hensbergen fail: 555b530cc79SEric Van Hensbergen return err; 556b530cc79SEric Van Hensbergen } 557b530cc79SEric Van Hensbergen 558ee443996SEric Van Hensbergen 559ee443996SEric Van Hensbergen /** 560ee443996SEric Van Hensbergen * p9_virtio_create - allocate a new virtio channel 5618b81ef58SEric Van Hensbergen * @client: client instance invoking this transport 562ee443996SEric Van Hensbergen * @devname: string identifying the channel to connect to (unused) 563ee443996SEric Van Hensbergen * @args: args passed from sys_mount() for per-transport options (unused) 564ee443996SEric Van Hensbergen * 565ee443996SEric Van Hensbergen * This sets up a transport channel for 9p communication. Right now 566b530cc79SEric Van Hensbergen * we only match the first available channel, but eventually we couldlook up 567b530cc79SEric Van Hensbergen * alternate channels by matching devname versus a virtio_config entry. 568b530cc79SEric Van Hensbergen * We use a simple reference count mechanism to ensure that only a single 569ee443996SEric Van Hensbergen * mount has a channel open at a time. 570ee443996SEric Van Hensbergen * 571ee443996SEric Van Hensbergen */ 572ee443996SEric Van Hensbergen 5738b81ef58SEric Van Hensbergen static int 5748b81ef58SEric Van Hensbergen p9_virtio_create(struct p9_client *client, const char *devname, char *args) 575b530cc79SEric Van Hensbergen { 57637c1209dSAneesh Kumar K.V struct virtio_chan *chan; 577c1a7c226SAneesh Kumar K.V int ret = -ENOENT; 57837c1209dSAneesh Kumar K.V int found = 0; 579b530cc79SEric Van Hensbergen 580c1549497SJosef 'Jeff' Sipek mutex_lock(&virtio_9p_lock); 58137c1209dSAneesh Kumar K.V list_for_each_entry(chan, &virtio_chan_list, chan_list) { 5820b20406cSSven Eckelmann if (!strncmp(devname, chan->tag, chan->tag_len) && 5830b20406cSSven Eckelmann strlen(devname) == chan->tag_len) { 584f75580c4SAneesh Kumar K.V if (!chan->inuse) { 585b530cc79SEric Van Hensbergen chan->inuse = true; 58637c1209dSAneesh Kumar K.V found = 1; 587b530cc79SEric Van Hensbergen break; 588f75580c4SAneesh Kumar K.V } 589c1a7c226SAneesh Kumar K.V ret = -EBUSY; 590f75580c4SAneesh Kumar K.V } 591b530cc79SEric Van Hensbergen } 592c1549497SJosef 'Jeff' Sipek mutex_unlock(&virtio_9p_lock); 593b530cc79SEric Van Hensbergen 59437c1209dSAneesh Kumar K.V if (!found) { 595*5d385153SJoe Perches pr_err("no channels available\n"); 596c1a7c226SAneesh Kumar K.V return ret; 597b530cc79SEric Van Hensbergen } 598b530cc79SEric Van Hensbergen 5998b81ef58SEric Van Hensbergen client->trans = (void *)chan; 600562ada61SEric Van Hensbergen client->status = Connected; 601fea511a6SEric Van Hensbergen chan->client = client; 602b530cc79SEric Van Hensbergen 6038b81ef58SEric Van Hensbergen return 0; 604b530cc79SEric Van Hensbergen } 605b530cc79SEric Van Hensbergen 606ee443996SEric Van Hensbergen /** 607ee443996SEric Van Hensbergen * p9_virtio_remove - clean up resources associated with a virtio device 608ee443996SEric Van Hensbergen * @vdev: virtio device to remove 609ee443996SEric Van Hensbergen * 610ee443996SEric Van Hensbergen */ 611ee443996SEric Van Hensbergen 612f3933545SEric Van Hensbergen static void p9_virtio_remove(struct virtio_device *vdev) 613f3933545SEric Van Hensbergen { 614f3933545SEric Van Hensbergen struct virtio_chan *chan = vdev->priv; 615f3933545SEric Van Hensbergen 616f3933545SEric Van Hensbergen BUG_ON(chan->inuse); 617d2a7dddaSMichael S. Tsirkin vdev->config->del_vqs(vdev); 61837c1209dSAneesh Kumar K.V 61937c1209dSAneesh Kumar K.V mutex_lock(&virtio_9p_lock); 62037c1209dSAneesh Kumar K.V list_del(&chan->chan_list); 62137c1209dSAneesh Kumar K.V mutex_unlock(&virtio_9p_lock); 62286c84373SAneesh Kumar K.V sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr); 62397ee9b02SAneesh Kumar K.V kfree(chan->tag); 62452f44e0dSVenkateswararao Jujjuri (JV) kfree(chan->vc_wq); 62537c1209dSAneesh Kumar K.V kfree(chan); 62637c1209dSAneesh Kumar K.V 627f3933545SEric Van Hensbergen } 628f3933545SEric Van Hensbergen 629b530cc79SEric Van Hensbergen static struct virtio_device_id id_table[] = { 630b530cc79SEric Van Hensbergen { VIRTIO_ID_9P, VIRTIO_DEV_ANY_ID }, 631b530cc79SEric Van Hensbergen { 0 }, 632b530cc79SEric Van Hensbergen }; 633b530cc79SEric Van Hensbergen 63497ee9b02SAneesh Kumar K.V static unsigned int features[] = { 63597ee9b02SAneesh Kumar K.V VIRTIO_9P_MOUNT_TAG, 63697ee9b02SAneesh Kumar K.V }; 63797ee9b02SAneesh Kumar K.V 638b530cc79SEric Van Hensbergen /* The standard "struct lguest_driver": */ 639b530cc79SEric Van Hensbergen static struct virtio_driver p9_virtio_drv = { 64097ee9b02SAneesh Kumar K.V .feature_table = features, 64197ee9b02SAneesh Kumar K.V .feature_table_size = ARRAY_SIZE(features), 642b530cc79SEric Van Hensbergen .driver.name = KBUILD_MODNAME, 643b530cc79SEric Van Hensbergen .driver.owner = THIS_MODULE, 644b530cc79SEric Van Hensbergen .id_table = id_table, 645b530cc79SEric Van Hensbergen .probe = p9_virtio_probe, 646f3933545SEric Van Hensbergen .remove = p9_virtio_remove, 647b530cc79SEric Van Hensbergen }; 648b530cc79SEric Van Hensbergen 649b530cc79SEric Van Hensbergen static struct p9_trans_module p9_virtio_trans = { 650b530cc79SEric Van Hensbergen .name = "virtio", 651b530cc79SEric Van Hensbergen .create = p9_virtio_create, 6528b81ef58SEric Van Hensbergen .close = p9_virtio_close, 65391b8534fSEric Van Hensbergen .request = p9_virtio_request, 654abfa034eSAneesh Kumar K.V .zc_request = p9_virtio_zc_request, 65591b8534fSEric Van Hensbergen .cancel = p9_virtio_cancel, 656b49d8b5dSAneesh Kumar K.V /* 657b49d8b5dSAneesh Kumar K.V * We leave one entry for input and one entry for response 658b49d8b5dSAneesh Kumar K.V * headers. We also skip one more entry to accomodate, address 659b49d8b5dSAneesh Kumar K.V * that are not at page boundary, that can result in an extra 660b49d8b5dSAneesh Kumar K.V * page in zero copy. 661b49d8b5dSAneesh Kumar K.V */ 662b49d8b5dSAneesh Kumar K.V .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3), 663b530cc79SEric Van Hensbergen .def = 0, 66472029fe8STejun Heo .owner = THIS_MODULE, 665b530cc79SEric Van Hensbergen }; 666b530cc79SEric Van Hensbergen 667b530cc79SEric Van Hensbergen /* The standard init function */ 668b530cc79SEric Van Hensbergen static int __init p9_virtio_init(void) 669b530cc79SEric Van Hensbergen { 67037c1209dSAneesh Kumar K.V INIT_LIST_HEAD(&virtio_chan_list); 671b530cc79SEric Van Hensbergen 672b530cc79SEric Van Hensbergen v9fs_register_trans(&p9_virtio_trans); 673b530cc79SEric Van Hensbergen return register_virtio_driver(&p9_virtio_drv); 674b530cc79SEric Van Hensbergen } 675b530cc79SEric Van Hensbergen 676f3933545SEric Van Hensbergen static void __exit p9_virtio_cleanup(void) 677f3933545SEric Van Hensbergen { 678f3933545SEric Van Hensbergen unregister_virtio_driver(&p9_virtio_drv); 67972029fe8STejun Heo v9fs_unregister_trans(&p9_virtio_trans); 680f3933545SEric Van Hensbergen } 681f3933545SEric Van Hensbergen 682b530cc79SEric Van Hensbergen module_init(p9_virtio_init); 683f3933545SEric Van Hensbergen module_exit(p9_virtio_cleanup); 684b530cc79SEric Van Hensbergen 685b530cc79SEric Van Hensbergen MODULE_DEVICE_TABLE(virtio, id_table); 686b530cc79SEric Van Hensbergen MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); 687b530cc79SEric Van Hensbergen MODULE_DESCRIPTION("Virtio 9p Transport"); 688b530cc79SEric Van Hensbergen MODULE_LICENSE("GPL"); 689