hv_storvsc_drv_freebsd.c (307455) | hv_storvsc_drv_freebsd.c (307456) |
---|---|
1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 29/** 30 * StorVSC driver for Hyper-V. This driver presents a SCSI HBA interface 31 * to the Comman Access Method (CAM) layer. CAM control blocks (CCBs) are 32 * converted into VSCSI protocol messages which are delivered to the parent 33 * partition StorVSP driver over the Hyper-V VMBUS. 34 */ 35#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 29/** 30 * StorVSC driver for Hyper-V. This driver presents a SCSI HBA interface 31 * to the Comman Access Method (CAM) layer. CAM control blocks (CCBs) are 32 * converted into VSCSI protocol messages which are delivered to the parent 33 * partition StorVSP driver over the Hyper-V VMBUS. 34 */ 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c 307455 2016-10-17 02:30:45Z sephe $"); | 36__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c 307456 2016-10-17 02:34:13Z sephe $"); |
37 38#include <sys/param.h> 39#include <sys/proc.h> 40#include <sys/condvar.h> 41#include <sys/time.h> 42#include <sys/systm.h> 43#include <sys/sockio.h> 44#include <sys/mbuf.h> --- 306 unchanged lines hidden (view full) --- 351 sema_init(&request->synch_sema, 0, ("stor_synch_sema")); 352 353 vstor_packet = &request->vstor_packet; 354 355 vstor_packet->operation = VSTOR_OPERATION_CREATE_MULTI_CHANNELS; 356 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 357 vstor_packet->u.multi_channels_cnt = request_channels_cnt; 358 | 37 38#include <sys/param.h> 39#include <sys/proc.h> 40#include <sys/condvar.h> 41#include <sys/time.h> 42#include <sys/systm.h> 43#include <sys/sockio.h> 44#include <sys/mbuf.h> --- 306 unchanged lines hidden (view full) --- 351 sema_init(&request->synch_sema, 0, ("stor_synch_sema")); 352 353 vstor_packet = &request->vstor_packet; 354 355 vstor_packet->operation = VSTOR_OPERATION_CREATE_MULTI_CHANNELS; 356 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 357 vstor_packet->u.multi_channels_cnt = request_channels_cnt; 358 |
359 ret = hv_vmbus_channel_send_packet( 360 sc->hs_chan, 361 vstor_packet, 362 VSTOR_PKT_SIZE, 363 (uint64_t)(uintptr_t)request, 364 VMBUS_CHANPKT_TYPE_INBAND, 365 VMBUS_CHANPKT_FLAG_RC); | 359 ret = vmbus_chan_send(sc->hs_chan, 360 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 361 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
366 367 /* wait for 5 seconds */ 368 ret = sema_timedwait(&request->synch_sema, 5 * hz); 369 if (ret != 0) { 370 printf("Storvsc_error: create multi-channel timeout, %d\n", 371 ret); 372 return; 373 } --- 48 unchanged lines hidden (view full) --- 422 * Initiate the vsc/vsp initialization protocol on the open channel 423 */ 424 sema_init(&request->synch_sema, 0, ("stor_synch_sema")); 425 426 vstor_packet->operation = VSTOR_OPERATION_BEGININITIALIZATION; 427 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 428 429 | 362 363 /* wait for 5 seconds */ 364 ret = sema_timedwait(&request->synch_sema, 5 * hz); 365 if (ret != 0) { 366 printf("Storvsc_error: create multi-channel timeout, %d\n", 367 ret); 368 return; 369 } --- 48 unchanged lines hidden (view full) --- 418 * Initiate the vsc/vsp initialization protocol on the open channel 419 */ 420 sema_init(&request->synch_sema, 0, ("stor_synch_sema")); 421 422 vstor_packet->operation = VSTOR_OPERATION_BEGININITIALIZATION; 423 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 424 425 |
430 ret = hv_vmbus_channel_send_packet( 431 sc->hs_chan, 432 vstor_packet, 433 VSTOR_PKT_SIZE, 434 (uint64_t)(uintptr_t)request, 435 VMBUS_CHANPKT_TYPE_INBAND, 436 VMBUS_CHANPKT_FLAG_RC); | 426 ret = vmbus_chan_send(sc->hs_chan, 427 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 428 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
437 438 if (ret != 0) 439 goto cleanup; 440 441 /* wait 5 seconds */ 442 ret = sema_timedwait(&request->synch_sema, 5 * hz); 443 if (ret != 0) 444 goto cleanup; --- 11 unchanged lines hidden (view full) --- 456 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 457 458 vstor_packet->u.version.major_minor = 459 vmstor_proto_list[i].proto_version; 460 461 /* revision is only significant for Windows guests */ 462 vstor_packet->u.version.revision = 0; 463 | 429 430 if (ret != 0) 431 goto cleanup; 432 433 /* wait 5 seconds */ 434 ret = sema_timedwait(&request->synch_sema, 5 * hz); 435 if (ret != 0) 436 goto cleanup; --- 11 unchanged lines hidden (view full) --- 448 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 449 450 vstor_packet->u.version.major_minor = 451 vmstor_proto_list[i].proto_version; 452 453 /* revision is only significant for Windows guests */ 454 vstor_packet->u.version.revision = 0; 455 |
464 ret = hv_vmbus_channel_send_packet( 465 sc->hs_chan, 466 vstor_packet, 467 VSTOR_PKT_SIZE, 468 (uint64_t)(uintptr_t)request, 469 VMBUS_CHANPKT_TYPE_INBAND, 470 VMBUS_CHANPKT_FLAG_RC); | 456 ret = vmbus_chan_send(sc->hs_chan, 457 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 458 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
471 472 if (ret != 0) 473 goto cleanup; 474 475 /* wait 5 seconds */ 476 ret = sema_timedwait(&request->synch_sema, 5 * hz); 477 478 if (ret) --- 20 unchanged lines hidden (view full) --- 499 } 500 /** 501 * Query channel properties 502 */ 503 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 504 vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; 505 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 506 | 459 460 if (ret != 0) 461 goto cleanup; 462 463 /* wait 5 seconds */ 464 ret = sema_timedwait(&request->synch_sema, 5 * hz); 465 466 if (ret) --- 20 unchanged lines hidden (view full) --- 487 } 488 /** 489 * Query channel properties 490 */ 491 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 492 vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; 493 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 494 |
507 ret = hv_vmbus_channel_send_packet( 508 sc->hs_chan, 509 vstor_packet, 510 VSTOR_PKT_SIZE, 511 (uint64_t)(uintptr_t)request, 512 VMBUS_CHANPKT_TYPE_INBAND, 513 VMBUS_CHANPKT_FLAG_RC); | 495 ret = vmbus_chan_send(sc->hs_chan, 496 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 497 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
514 515 if ( ret != 0) 516 goto cleanup; 517 518 /* wait 5 seconds */ 519 ret = sema_timedwait(&request->synch_sema, 5 * hz); 520 521 if (ret != 0) --- 13 unchanged lines hidden (view full) --- 535 HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { 536 support_multichannel = TRUE; 537 } 538 539 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 540 vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; 541 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 542 | 498 499 if ( ret != 0) 500 goto cleanup; 501 502 /* wait 5 seconds */ 503 ret = sema_timedwait(&request->synch_sema, 5 * hz); 504 505 if (ret != 0) --- 13 unchanged lines hidden (view full) --- 519 HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { 520 support_multichannel = TRUE; 521 } 522 523 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 524 vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; 525 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 526 |
543 ret = hv_vmbus_channel_send_packet( 544 sc->hs_chan, 545 vstor_packet, 546 VSTOR_PKT_SIZE, 547 (uint64_t)(uintptr_t)request, 548 VMBUS_CHANPKT_TYPE_INBAND, 549 VMBUS_CHANPKT_FLAG_RC); | 527 ret = vmbus_chan_send(sc->hs_chan, 528 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 529 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
550 551 if (ret != 0) { 552 goto cleanup; 553 } 554 555 /* wait 5 seconds */ 556 ret = sema_timedwait(&request->synch_sema, 5 * hz); 557 --- 68 unchanged lines hidden (view full) --- 626 request->softc = sc; 627 vstor_packet = &request->vstor_packet; 628 629 sema_init(&request->synch_sema, 0, "stor synch sema"); 630 631 vstor_packet->operation = VSTOR_OPERATION_RESETBUS; 632 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 633 | 530 531 if (ret != 0) { 532 goto cleanup; 533 } 534 535 /* wait 5 seconds */ 536 ret = sema_timedwait(&request->synch_sema, 5 * hz); 537 --- 68 unchanged lines hidden (view full) --- 606 request->softc = sc; 607 vstor_packet = &request->vstor_packet; 608 609 sema_init(&request->synch_sema, 0, "stor synch sema"); 610 611 vstor_packet->operation = VSTOR_OPERATION_RESETBUS; 612 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 613 |
634 ret = hv_vmbus_channel_send_packet(dev->channel, 635 vstor_packet, 636 VSTOR_PKT_SIZE, 637 (uint64_t)(uintptr_t)&sc->hs_reset_req, 638 VMBUS_CHANPKT_TYPE_INBAND, 639 VMBUS_CHANPKT_FLAG_RC); | 614 ret = vmbus_chan_send(dev->channel, 615 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 616 vstor_packet, VSTOR_PKT_SIZE, 617 (uint64_t)(uintptr_t)&sc->hs_reset_req); |
640 641 if (ret != 0) { 642 goto cleanup; 643 } 644 645 ret = sema_timedwait(&request->synch_sema, 5 * hz); /* KYS 5 seconds */ 646 647 if (ret) { --- 42 unchanged lines hidden (view full) --- 690 outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); 691 692 mtx_unlock(&request->softc->hs_lock); 693 if (request->prp_list.gpa_range.gpa_len) { 694 ret = vmbus_chan_send_prplist(outgoing_channel, 695 &request->prp_list.gpa_range, request->prp_cnt, 696 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); 697 } else { | 618 619 if (ret != 0) { 620 goto cleanup; 621 } 622 623 ret = sema_timedwait(&request->synch_sema, 5 * hz); /* KYS 5 seconds */ 624 625 if (ret) { --- 42 unchanged lines hidden (view full) --- 668 outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); 669 670 mtx_unlock(&request->softc->hs_lock); 671 if (request->prp_list.gpa_range.gpa_len) { 672 ret = vmbus_chan_send_prplist(outgoing_channel, 673 &request->prp_list.gpa_range, request->prp_cnt, 674 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); 675 } else { |
698 ret = hv_vmbus_channel_send_packet( 699 outgoing_channel, 700 vstor_packet, 701 VSTOR_PKT_SIZE, 702 (uint64_t)(uintptr_t)request, 703 VMBUS_CHANPKT_TYPE_INBAND, 704 VMBUS_CHANPKT_FLAG_RC); | 676 ret = vmbus_chan_send(outgoing_channel, 677 VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, 678 vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); |
705 } 706 mtx_lock(&request->softc->hs_lock); 707 708 if (ret != 0) { 709 printf("Unable to send packet %p ret %d", vstor_packet, ret); 710 } else { 711 atomic_add_int(&sc->hs_num_out_reqs, 1); 712 } --- 1361 unchanged lines hidden --- | 679 } 680 mtx_lock(&request->softc->hs_lock); 681 682 if (ret != 0) { 683 printf("Unable to send packet %p ret %d", vstor_packet, ret); 684 } else { 685 atomic_add_int(&sc->hs_num_out_reqs, 1); 686 } --- 1361 unchanged lines hidden --- |