trans_virtio.c (99b1bb61b225c3eb4d3b196d4f1d041695b19a7e) | trans_virtio.c (b49d8b5d7007a673796f3f99688b46931293873e) |
---|---|
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 * --- 249 unchanged lines hidden (view full) --- 258 * 259 */ 260 261static int 262p9_virtio_request(struct p9_client *client, struct p9_req_t *req) 263{ 264 int in, out, inp, outp; 265 struct virtio_chan *chan = client->trans; | 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 * --- 249 unchanged lines hidden (view full) --- 258 * 259 */ 260 261static int 262p9_virtio_request(struct p9_client *client, struct p9_req_t *req) 263{ 264 int in, out, inp, outp; 265 struct virtio_chan *chan = client->trans; |
266 char *rdata = (char *)req->rc+sizeof(struct p9_fcall); | |
267 unsigned long flags; 268 size_t pdata_off = 0; 269 struct trans_rpage_info *rpinfo = NULL; 270 int err, pdata_len = 0; 271 272 P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio request\n"); 273 274 req->status = REQ_STATUS_SENT; --- 66 unchanged lines hidden (view full) --- 341 if (req->tc->pbuf_size && 342 ((req->tc->id == P9_TREAD) || (req->tc->id == P9_TREADDIR))) { 343 /* 344 * Take care of additional Read payload. 345 * 11 is the read/write header = PDU Header(7) + IO Size (4). 346 * Arrange in such a way that server places header in the 347 * alloced memory and payload onto the user buffer. 348 */ | 266 unsigned long flags; 267 size_t pdata_off = 0; 268 struct trans_rpage_info *rpinfo = NULL; 269 int err, pdata_len = 0; 270 271 P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio request\n"); 272 273 req->status = REQ_STATUS_SENT; --- 66 unchanged lines hidden (view full) --- 340 if (req->tc->pbuf_size && 341 ((req->tc->id == P9_TREAD) || (req->tc->id == P9_TREADDIR))) { 342 /* 343 * Take care of additional Read payload. 344 * 11 is the read/write header = PDU Header(7) + IO Size (4). 345 * Arrange in such a way that server places header in the 346 * alloced memory and payload onto the user buffer. 347 */ |
349 inp = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, 11); | 348 inp = pack_sg_list(chan->sg, out, 349 VIRTQUEUE_NUM, req->rc->sdata, 11); |
350 /* 351 * Running executables in the filesystem may result in 352 * a read request with kernel buffer as opposed to user buffer. 353 */ 354 if (req->tc->pubuf && P9_IS_USER_CONTEXT) { 355 in = pack_sg_list_p(chan->sg, out+inp, VIRTQUEUE_NUM, 356 pdata_off, rpinfo->rp_data, pdata_len); 357 } else { 358 char *pbuf; 359 if (req->tc->pubuf) 360 pbuf = (__force char *) req->tc->pubuf; 361 else 362 pbuf = req->tc->pkbuf; 363 364 in = pack_sg_list(chan->sg, out+inp, VIRTQUEUE_NUM, 365 pbuf, req->tc->pbuf_size); 366 } 367 in += inp; 368 } else { | 350 /* 351 * Running executables in the filesystem may result in 352 * a read request with kernel buffer as opposed to user buffer. 353 */ 354 if (req->tc->pubuf && P9_IS_USER_CONTEXT) { 355 in = pack_sg_list_p(chan->sg, out+inp, VIRTQUEUE_NUM, 356 pdata_off, rpinfo->rp_data, pdata_len); 357 } else { 358 char *pbuf; 359 if (req->tc->pubuf) 360 pbuf = (__force char *) req->tc->pubuf; 361 else 362 pbuf = req->tc->pkbuf; 363 364 in = pack_sg_list(chan->sg, out+inp, VIRTQUEUE_NUM, 365 pbuf, req->tc->pbuf_size); 366 } 367 in += inp; 368 } else { |
369 in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, 370 req->rc->capacity); | 369 in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, 370 req->rc->sdata, req->rc->capacity); |
371 } 372 373 err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); 374 if (err < 0) { 375 if (err == -ENOSPC) { 376 chan->ring_bufs_avail = 0; 377 spin_unlock_irqrestore(&chan->lock, flags); 378 err = wait_event_interruptible(*chan->vc_wq, --- 208 unchanged lines hidden (view full) --- 587}; 588 589static struct p9_trans_module p9_virtio_trans = { 590 .name = "virtio", 591 .create = p9_virtio_create, 592 .close = p9_virtio_close, 593 .request = p9_virtio_request, 594 .cancel = p9_virtio_cancel, | 371 } 372 373 err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); 374 if (err < 0) { 375 if (err == -ENOSPC) { 376 chan->ring_bufs_avail = 0; 377 spin_unlock_irqrestore(&chan->lock, flags); 378 err = wait_event_interruptible(*chan->vc_wq, --- 208 unchanged lines hidden (view full) --- 587}; 588 589static struct p9_trans_module p9_virtio_trans = { 590 .name = "virtio", 591 .create = p9_virtio_create, 592 .close = p9_virtio_close, 593 .request = p9_virtio_request, 594 .cancel = p9_virtio_cancel, |
595 .maxsize = PAGE_SIZE*VIRTQUEUE_NUM, | 595 596 /* 597 * We leave one entry for input and one entry for response 598 * headers. We also skip one more entry to accomodate, address 599 * that are not at page boundary, that can result in an extra 600 * page in zero copy. 601 */ 602 .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3), |
596 .pref = P9_TRANS_PREF_PAYLOAD_SEP, 597 .def = 0, 598 .owner = THIS_MODULE, 599}; 600 601/* The standard init function */ 602static int __init p9_virtio_init(void) 603{ --- 19 unchanged lines hidden --- | 603 .pref = P9_TRANS_PREF_PAYLOAD_SEP, 604 .def = 0, 605 .owner = THIS_MODULE, 606}; 607 608/* The standard init function */ 609static int __init p9_virtio_init(void) 610{ --- 19 unchanged lines hidden --- |