trans_virtio.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /*
  2. * The Virtio 9p transport driver
  3. *
  4. * This is a block based transport driver based on the lguest block driver
  5. * code.
  6. *
  7. * Copyright (C) 2007, 2008 Eric Van Hensbergen, IBM Corporation
  8. *
  9. * Based on virtio console driver
  10. * Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to:
  23. * Free Software Foundation
  24. * 51 Franklin Street, Fifth Floor
  25. * Boston, MA 02111-1301 USA
  26. *
  27. */
  28. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  29. #include <linux/in.h>
  30. #include <linux/module.h>
  31. #include <linux/net.h>
  32. #include <linux/ipv6.h>
  33. #include <linux/errno.h>
  34. #include <linux/kernel.h>
  35. #include <linux/un.h>
  36. #include <linux/uaccess.h>
  37. #include <linux/inet.h>
  38. #include <linux/idr.h>
  39. #include <linux/file.h>
  40. #include <linux/slab.h>
  41. #include <net/9p/9p.h>
  42. #include <linux/parser.h>
  43. #include <net/9p/client.h>
  44. #include <net/9p/transport.h>
  45. #include <linux/scatterlist.h>
  46. #include <linux/swap.h>
  47. #include <linux/virtio.h>
  48. #include <linux/virtio_9p.h>
  49. #include "trans_common.h"
  50. #define VIRTQUEUE_NUM 128
  51. /* a single mutex to manage channel initialization and attachment */
  52. static DEFINE_MUTEX(virtio_9p_lock);
  53. static DECLARE_WAIT_QUEUE_HEAD(vp_wq);
  54. static atomic_t vp_pinned = ATOMIC_INIT(0);
  55. /**
  56. * struct virtio_chan - per-instance transport information
  57. * @initialized: whether the channel is initialized
  58. * @inuse: whether the channel is in use
  59. * @lock: protects multiple elements within this structure
  60. * @client: client instance
  61. * @vdev: virtio dev associated with this channel
  62. * @vq: virtio queue associated with this channel
  63. * @sg: scatter gather list which is used to pack a request (protected?)
  64. *
  65. * We keep all per-channel information in a structure.
  66. * This structure is allocated within the devices dev->mem space.
  67. * A pointer to the structure will get put in the transport private.
  68. *
  69. */
  70. struct virtio_chan {
  71. bool inuse;
  72. spinlock_t lock;
  73. struct p9_client *client;
  74. struct virtio_device *vdev;
  75. struct virtqueue *vq;
  76. int ring_bufs_avail;
  77. wait_queue_head_t *vc_wq;
  78. /* This is global limit. Since we don't have a global structure,
  79. * will be placing it in each channel.
  80. */
  81. int p9_max_pages;
  82. /* Scatterlist: can be too big for stack. */
  83. struct scatterlist sg[VIRTQUEUE_NUM];
  84. int tag_len;
  85. /*
  86. * tag name to identify a mount Non-null terminated
  87. */
  88. char *tag;
  89. struct list_head chan_list;
  90. };
  91. static struct list_head virtio_chan_list;
  92. /* How many bytes left in this page. */
  93. static unsigned int rest_of_page(void *data)
  94. {
  95. return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE);
  96. }
  97. /**
  98. * p9_virtio_close - reclaim resources of a channel
  99. * @client: client instance
  100. *
  101. * This reclaims a channel by freeing its resources and
  102. * reseting its inuse flag.
  103. *
  104. */
  105. static void p9_virtio_close(struct p9_client *client)
  106. {
  107. struct virtio_chan *chan = client->trans;
  108. mutex_lock(&virtio_9p_lock);
  109. if (chan)
  110. chan->inuse = false;
  111. mutex_unlock(&virtio_9p_lock);
  112. }
  113. /**
  114. * req_done - callback which signals activity from the server
  115. * @vq: virtio queue activity was received on
  116. *
  117. * This notifies us that the server has triggered some activity
  118. * on the virtio channel - most likely a response to request we
  119. * sent. Figure out which requests now have responses and wake up
  120. * those threads.
  121. *
  122. * Bugs: could do with some additional sanity checking, but appears to work.
  123. *
  124. */
  125. static void req_done(struct virtqueue *vq)
  126. {
  127. struct virtio_chan *chan = vq->vdev->priv;
  128. struct p9_fcall *rc;
  129. unsigned int len;
  130. struct p9_req_t *req;
  131. unsigned long flags;
  132. p9_debug(P9_DEBUG_TRANS, ": request done\n");
  133. while (1) {
  134. spin_lock_irqsave(&chan->lock, flags);
  135. rc = virtqueue_get_buf(chan->vq, &len);
  136. if (rc == NULL) {
  137. spin_unlock_irqrestore(&chan->lock, flags);
  138. break;
  139. }
  140. chan->ring_bufs_avail = 1;
  141. spin_unlock_irqrestore(&chan->lock, flags);
  142. /* Wakeup if anyone waiting for VirtIO ring space. */
  143. wake_up(chan->vc_wq);
  144. p9_debug(P9_DEBUG_TRANS, ": rc %p\n", rc);
  145. p9_debug(P9_DEBUG_TRANS, ": lookup tag %d\n", rc->tag);
  146. req = p9_tag_lookup(chan->client, rc->tag);
  147. req->status = REQ_STATUS_RCVD;
  148. p9_client_cb(chan->client, req);
  149. }
  150. }
  151. /**
  152. * pack_sg_list - pack a scatter gather list from a linear buffer
  153. * @sg: scatter/gather list to pack into
  154. * @start: which segment of the sg_list to start at
  155. * @limit: maximum segment to pack data to
  156. * @data: data to pack into scatter/gather list
  157. * @count: amount of data to pack into the scatter/gather list
  158. *
  159. * sg_lists have multiple segments of various sizes. This will pack
  160. * arbitrary data into an existing scatter gather list, segmenting the
  161. * data as necessary within constraints.
  162. *
  163. */
  164. static int pack_sg_list(struct scatterlist *sg, int start,
  165. int limit, char *data, int count)
  166. {
  167. int s;
  168. int index = start;
  169. while (count) {
  170. s = rest_of_page(data);
  171. if (s > count)
  172. s = count;
  173. sg_set_buf(&sg[index++], data, s);
  174. count -= s;
  175. data += s;
  176. BUG_ON(index > limit);
  177. }
  178. return index-start;
  179. }
  180. /* We don't currently allow canceling of virtio requests */
  181. static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req)
  182. {
  183. return 1;
  184. }
  185. /**
  186. * pack_sg_list_p - Just like pack_sg_list. Instead of taking a buffer,
  187. * this takes a list of pages.
  188. * @sg: scatter/gather list to pack into
  189. * @start: which segment of the sg_list to start at
  190. * @**pdata: a list of pages to add into sg.
  191. * @nr_pages: number of pages to pack into the scatter/gather list
  192. * @data: data to pack into scatter/gather list
  193. * @count: amount of data to pack into the scatter/gather list
  194. */
  195. static int
  196. pack_sg_list_p(struct scatterlist *sg, int start, int limit,
  197. struct page **pdata, int nr_pages, char *data, int count)
  198. {
  199. int i = 0, s;
  200. int data_off;
  201. int index = start;
  202. BUG_ON(nr_pages > (limit - start));
  203. /*
  204. * if the first page doesn't start at
  205. * page boundary find the offset
  206. */
  207. data_off = offset_in_page(data);
  208. while (nr_pages) {
  209. s = rest_of_page(data);
  210. if (s > count)
  211. s = count;
  212. sg_set_page(&sg[index++], pdata[i++], s, data_off);
  213. data_off = 0;
  214. data += s;
  215. count -= s;
  216. nr_pages--;
  217. }
  218. return index - start;
  219. }
  220. /**
  221. * p9_virtio_request - issue a request
  222. * @client: client instance issuing the request
  223. * @req: request to be issued
  224. *
  225. */
  226. static int
  227. p9_virtio_request(struct p9_client *client, struct p9_req_t *req)
  228. {
  229. int err;
  230. int in, out;
  231. unsigned long flags;
  232. struct virtio_chan *chan = client->trans;
  233. p9_debug(P9_DEBUG_TRANS, "9p debug: virtio request\n");
  234. req->status = REQ_STATUS_SENT;
  235. req_retry:
  236. spin_lock_irqsave(&chan->lock, flags);
  237. /* Handle out VirtIO ring buffers */
  238. out = pack_sg_list(chan->sg, 0,
  239. VIRTQUEUE_NUM, req->tc->sdata, req->tc->size);
  240. in = pack_sg_list(chan->sg, out,
  241. VIRTQUEUE_NUM, req->rc->sdata, req->rc->capacity);
  242. err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc);
  243. if (err < 0) {
  244. if (err == -ENOSPC) {
  245. chan->ring_bufs_avail = 0;
  246. spin_unlock_irqrestore(&chan->lock, flags);
  247. err = wait_event_interruptible(*chan->vc_wq,
  248. chan->ring_bufs_avail);
  249. if (err == -ERESTARTSYS)
  250. return err;
  251. p9_debug(P9_DEBUG_TRANS, "Retry virtio request\n");
  252. goto req_retry;
  253. } else {
  254. spin_unlock_irqrestore(&chan->lock, flags);
  255. p9_debug(P9_DEBUG_TRANS,
  256. "virtio rpc add_buf returned failure\n");
  257. return -EIO;
  258. }
  259. }
  260. virtqueue_kick(chan->vq);
  261. spin_unlock_irqrestore(&chan->lock, flags);
  262. p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
  263. return 0;
  264. }
  265. static int p9_get_mapped_pages(struct virtio_chan *chan,
  266. struct page **pages, char *data,
  267. int nr_pages, int write, int kern_buf)
  268. {
  269. int err;
  270. if (!kern_buf) {
  271. /*
  272. * We allow only p9_max_pages pinned. We wait for the
  273. * Other zc request to finish here
  274. */
  275. if (atomic_read(&vp_pinned) >= chan->p9_max_pages) {
  276. err = wait_event_interruptible(vp_wq,
  277. (atomic_read(&vp_pinned) < chan->p9_max_pages));
  278. if (err == -ERESTARTSYS)
  279. return err;
  280. }
  281. err = p9_payload_gup(data, &nr_pages, pages, write);
  282. if (err < 0)
  283. return err;
  284. atomic_add(nr_pages, &vp_pinned);
  285. } else {
  286. /* kernel buffer, no need to pin pages */
  287. int s, index = 0;
  288. int count = nr_pages;
  289. while (nr_pages) {
  290. s = rest_of_page(data);
  291. pages[index++] = virt_to_page(data);
  292. data += s;
  293. nr_pages--;
  294. }
  295. nr_pages = count;
  296. }
  297. return nr_pages;
  298. }
  299. /**
  300. * p9_virtio_zc_request - issue a zero copy request
  301. * @client: client instance issuing the request
  302. * @req: request to be issued
  303. * @uidata: user bffer that should be ued for zero copy read
  304. * @uodata: user buffer that shoud be user for zero copy write
  305. * @inlen: read buffer size
  306. * @olen: write buffer size
  307. * @hdrlen: reader header size, This is the size of response protocol data
  308. *
  309. */
  310. static int
  311. p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
  312. char *uidata, char *uodata, int inlen,
  313. int outlen, int in_hdr_len, int kern_buf)
  314. {
  315. int in, out, err;
  316. unsigned long flags;
  317. int in_nr_pages = 0, out_nr_pages = 0;
  318. struct page **in_pages = NULL, **out_pages = NULL;
  319. struct virtio_chan *chan = client->trans;
  320. p9_debug(P9_DEBUG_TRANS, "virtio request\n");
  321. if (uodata) {
  322. out_nr_pages = p9_nr_pages(uodata, outlen);
  323. out_pages = kmalloc(sizeof(struct page *) * out_nr_pages,
  324. GFP_NOFS);
  325. if (!out_pages) {
  326. err = -ENOMEM;
  327. goto err_out;
  328. }
  329. out_nr_pages = p9_get_mapped_pages(chan, out_pages, uodata,
  330. out_nr_pages, 0, kern_buf);
  331. if (out_nr_pages < 0) {
  332. err = out_nr_pages;
  333. kfree(out_pages);
  334. out_pages = NULL;
  335. goto err_out;
  336. }
  337. }
  338. if (uidata) {
  339. in_nr_pages = p9_nr_pages(uidata, inlen);
  340. in_pages = kmalloc(sizeof(struct page *) * in_nr_pages,
  341. GFP_NOFS);
  342. if (!in_pages) {
  343. err = -ENOMEM;
  344. goto err_out;
  345. }
  346. in_nr_pages = p9_get_mapped_pages(chan, in_pages, uidata,
  347. in_nr_pages, 1, kern_buf);
  348. if (in_nr_pages < 0) {
  349. err = in_nr_pages;
  350. kfree(in_pages);
  351. in_pages = NULL;
  352. goto err_out;
  353. }
  354. }
  355. req->status = REQ_STATUS_SENT;
  356. req_retry_pinned:
  357. spin_lock_irqsave(&chan->lock, flags);
  358. /* out data */
  359. out = pack_sg_list(chan->sg, 0,
  360. VIRTQUEUE_NUM, req->tc->sdata, req->tc->size);
  361. if (out_pages)
  362. out += pack_sg_list_p(chan->sg, out, VIRTQUEUE_NUM,
  363. out_pages, out_nr_pages, uodata, outlen);
  364. /*
  365. * Take care of in data
  366. * For example TREAD have 11.
  367. * 11 is the read/write header = PDU Header(7) + IO Size (4).
  368. * Arrange in such a way that server places header in the
  369. * alloced memory and payload onto the user buffer.
  370. */
  371. in = pack_sg_list(chan->sg, out,
  372. VIRTQUEUE_NUM, req->rc->sdata, in_hdr_len);
  373. if (in_pages)
  374. in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM,
  375. in_pages, in_nr_pages, uidata, inlen);
  376. err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc);
  377. if (err < 0) {
  378. if (err == -ENOSPC) {
  379. chan->ring_bufs_avail = 0;
  380. spin_unlock_irqrestore(&chan->lock, flags);
  381. err = wait_event_interruptible(*chan->vc_wq,
  382. chan->ring_bufs_avail);
  383. if (err == -ERESTARTSYS)
  384. goto err_out;
  385. p9_debug(P9_DEBUG_TRANS, "Retry virtio request\n");
  386. goto req_retry_pinned;
  387. } else {
  388. spin_unlock_irqrestore(&chan->lock, flags);
  389. p9_debug(P9_DEBUG_TRANS,
  390. "virtio rpc add_buf returned failure\n");
  391. err = -EIO;
  392. goto err_out;
  393. }
  394. }
  395. virtqueue_kick(chan->vq);
  396. spin_unlock_irqrestore(&chan->lock, flags);
  397. p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
  398. err = wait_event_interruptible(*req->wq,
  399. req->status >= REQ_STATUS_RCVD);
  400. /*
  401. * Non kernel buffers are pinned, unpin them
  402. */
  403. err_out:
  404. if (!kern_buf) {
  405. if (in_pages) {
  406. p9_release_pages(in_pages, in_nr_pages);
  407. atomic_sub(in_nr_pages, &vp_pinned);
  408. }
  409. if (out_pages) {
  410. p9_release_pages(out_pages, out_nr_pages);
  411. atomic_sub(out_nr_pages, &vp_pinned);
  412. }
  413. /* wakeup anybody waiting for slots to pin pages */
  414. wake_up(&vp_wq);
  415. }
  416. kfree(in_pages);
  417. kfree(out_pages);
  418. return err;
  419. }
  420. static ssize_t p9_mount_tag_show(struct device *dev,
  421. struct device_attribute *attr, char *buf)
  422. {
  423. struct virtio_chan *chan;
  424. struct virtio_device *vdev;
  425. vdev = dev_to_virtio(dev);
  426. chan = vdev->priv;
  427. return snprintf(buf, chan->tag_len + 1, "%s", chan->tag);
  428. }
  429. static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL);
  430. /**
  431. * p9_virtio_probe - probe for existence of 9P virtio channels
  432. * @vdev: virtio device to probe
  433. *
  434. * This probes for existing virtio channels.
  435. *
  436. */
  437. static int p9_virtio_probe(struct virtio_device *vdev)
  438. {
  439. __u16 tag_len;
  440. char *tag;
  441. int err;
  442. struct virtio_chan *chan;
  443. chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL);
  444. if (!chan) {
  445. pr_err("Failed to allocate virtio 9P channel\n");
  446. err = -ENOMEM;
  447. goto fail;
  448. }
  449. chan->vdev = vdev;
  450. /* We expect one virtqueue, for requests. */
  451. chan->vq = virtio_find_single_vq(vdev, req_done, "requests");
  452. if (IS_ERR(chan->vq)) {
  453. err = PTR_ERR(chan->vq);
  454. goto out_free_vq;
  455. }
  456. chan->vq->vdev->priv = chan;
  457. spin_lock_init(&chan->lock);
  458. sg_init_table(chan->sg, VIRTQUEUE_NUM);
  459. chan->inuse = false;
  460. if (virtio_has_feature(vdev, VIRTIO_9P_MOUNT_TAG)) {
  461. vdev->config->get(vdev,
  462. offsetof(struct virtio_9p_config, tag_len),
  463. &tag_len, sizeof(tag_len));
  464. } else {
  465. err = -EINVAL;
  466. goto out_free_vq;
  467. }
  468. tag = kmalloc(tag_len, GFP_KERNEL);
  469. if (!tag) {
  470. err = -ENOMEM;
  471. goto out_free_vq;
  472. }
  473. vdev->config->get(vdev, offsetof(struct virtio_9p_config, tag),
  474. tag, tag_len);
  475. chan->tag = tag;
  476. chan->tag_len = tag_len;
  477. err = sysfs_create_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
  478. if (err) {
  479. goto out_free_tag;
  480. }
  481. chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
  482. if (!chan->vc_wq) {
  483. err = -ENOMEM;
  484. goto out_free_tag;
  485. }
  486. init_waitqueue_head(chan->vc_wq);
  487. chan->ring_bufs_avail = 1;
  488. /* Ceiling limit to avoid denial of service attacks */
  489. chan->p9_max_pages = nr_free_buffer_pages()/4;
  490. mutex_lock(&virtio_9p_lock);
  491. list_add_tail(&chan->chan_list, &virtio_chan_list);
  492. mutex_unlock(&virtio_9p_lock);
  493. return 0;
  494. out_free_tag:
  495. kfree(tag);
  496. out_free_vq:
  497. vdev->config->del_vqs(vdev);
  498. kfree(chan);
  499. fail:
  500. return err;
  501. }
  502. /**
  503. * p9_virtio_create - allocate a new virtio channel
  504. * @client: client instance invoking this transport
  505. * @devname: string identifying the channel to connect to (unused)
  506. * @args: args passed from sys_mount() for per-transport options (unused)
  507. *
  508. * This sets up a transport channel for 9p communication. Right now
  509. * we only match the first available channel, but eventually we couldlook up
  510. * alternate channels by matching devname versus a virtio_config entry.
  511. * We use a simple reference count mechanism to ensure that only a single
  512. * mount has a channel open at a time.
  513. *
  514. */
  515. static int
  516. p9_virtio_create(struct p9_client *client, const char *devname, char *args)
  517. {
  518. struct virtio_chan *chan;
  519. int ret = -ENOENT;
  520. int found = 0;
  521. mutex_lock(&virtio_9p_lock);
  522. list_for_each_entry(chan, &virtio_chan_list, chan_list) {
  523. if (!strncmp(devname, chan->tag, chan->tag_len) &&
  524. strlen(devname) == chan->tag_len) {
  525. if (!chan->inuse) {
  526. chan->inuse = true;
  527. found = 1;
  528. break;
  529. }
  530. ret = -EBUSY;
  531. }
  532. }
  533. mutex_unlock(&virtio_9p_lock);
  534. if (!found) {
  535. pr_err("no channels available\n");
  536. return ret;
  537. }
  538. client->trans = (void *)chan;
  539. client->status = Connected;
  540. chan->client = client;
  541. return 0;
  542. }
  543. /**
  544. * p9_virtio_remove - clean up resources associated with a virtio device
  545. * @vdev: virtio device to remove
  546. *
  547. */
  548. static void p9_virtio_remove(struct virtio_device *vdev)
  549. {
  550. struct virtio_chan *chan = vdev->priv;
  551. BUG_ON(chan->inuse);
  552. vdev->config->del_vqs(vdev);
  553. mutex_lock(&virtio_9p_lock);
  554. list_del(&chan->chan_list);
  555. mutex_unlock(&virtio_9p_lock);
  556. sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
  557. kfree(chan->tag);
  558. kfree(chan->vc_wq);
  559. kfree(chan);
  560. }
  561. static struct virtio_device_id id_table[] = {
  562. { VIRTIO_ID_9P, VIRTIO_DEV_ANY_ID },
  563. { 0 },
  564. };
  565. static unsigned int features[] = {
  566. VIRTIO_9P_MOUNT_TAG,
  567. };
  568. /* The standard "struct lguest_driver": */
  569. static struct virtio_driver p9_virtio_drv = {
  570. .feature_table = features,
  571. .feature_table_size = ARRAY_SIZE(features),
  572. .driver.name = KBUILD_MODNAME,
  573. .driver.owner = THIS_MODULE,
  574. .id_table = id_table,
  575. .probe = p9_virtio_probe,
  576. .remove = p9_virtio_remove,
  577. };
  578. static struct p9_trans_module p9_virtio_trans = {
  579. .name = "virtio",
  580. .create = p9_virtio_create,
  581. .close = p9_virtio_close,
  582. .request = p9_virtio_request,
  583. .zc_request = p9_virtio_zc_request,
  584. .cancel = p9_virtio_cancel,
  585. /*
  586. * We leave one entry for input and one entry for response
  587. * headers. We also skip one more entry to accomodate, address
  588. * that are not at page boundary, that can result in an extra
  589. * page in zero copy.
  590. */
  591. .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3),
  592. .def = 0,
  593. .owner = THIS_MODULE,
  594. };
  595. /* The standard init function */
  596. static int __init p9_virtio_init(void)
  597. {
  598. INIT_LIST_HEAD(&virtio_chan_list);
  599. v9fs_register_trans(&p9_virtio_trans);
  600. return register_virtio_driver(&p9_virtio_drv);
  601. }
  602. static void __exit p9_virtio_cleanup(void)
  603. {
  604. unregister_virtio_driver(&p9_virtio_drv);
  605. v9fs_unregister_trans(&p9_virtio_trans);
  606. }
  607. module_init(p9_virtio_init);
  608. module_exit(p9_virtio_cleanup);
  609. MODULE_DEVICE_TABLE(virtio, id_table);
  610. MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
  611. MODULE_DESCRIPTION("Virtio 9p Transport");
  612. MODULE_LICENSE("GPL");