hv_storvsc_drv_freebsd.c (263065) | hv_storvsc_drv_freebsd.c (266794) |
---|---|
1/*- 2 * Copyright (c) 2009-2012 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 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/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c 263065 2014-03-12 07:27:05Z mav $"); | 36__FBSDID("$FreeBSD: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c 266794 2014-05-28 09:06:36Z marius $"); |
37 38#include <sys/param.h> 39#include <sys/proc.h> 40#include <sys/condvar.h> 41#include <sys/systm.h> 42#include <sys/sockio.h> 43#include <sys/mbuf.h> 44#include <sys/malloc.h> --- 246 unchanged lines hidden (view full) --- 291 vstor_packet->operation = VSTOR_OPERATION_BEGININITIALIZATION; 292 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 293 294 295 ret = hv_vmbus_channel_send_packet( 296 dev->channel, 297 vstor_packet, 298 sizeof(struct vstor_packet), | 37 38#include <sys/param.h> 39#include <sys/proc.h> 40#include <sys/condvar.h> 41#include <sys/systm.h> 42#include <sys/sockio.h> 43#include <sys/mbuf.h> 44#include <sys/malloc.h> --- 246 unchanged lines hidden (view full) --- 291 vstor_packet->operation = VSTOR_OPERATION_BEGININITIALIZATION; 292 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 293 294 295 ret = hv_vmbus_channel_send_packet( 296 dev->channel, 297 vstor_packet, 298 sizeof(struct vstor_packet), |
299 (uint64_t)request, | 299 (uint64_t)(uintptr_t)request, |
300 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 301 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 302 303 if (ret != 0) { 304 goto cleanup; 305 } 306 307 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 17 unchanged lines hidden (view full) --- 325 326 /* revision is only significant for Windows guests */ 327 vstor_packet->u.version.revision = 0; 328 329 ret = hv_vmbus_channel_send_packet( 330 dev->channel, 331 vstor_packet, 332 sizeof(struct vstor_packet), | 300 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 301 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 302 303 if (ret != 0) { 304 goto cleanup; 305 } 306 307 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 17 unchanged lines hidden (view full) --- 325 326 /* revision is only significant for Windows guests */ 327 vstor_packet->u.version.revision = 0; 328 329 ret = hv_vmbus_channel_send_packet( 330 dev->channel, 331 vstor_packet, 332 sizeof(struct vstor_packet), |
333 (uint64_t)request, | 333 (uint64_t)(uintptr_t)request, |
334 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 335 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 336 337 if (ret != 0) { 338 goto cleanup; 339 } 340 341 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 14 unchanged lines hidden (view full) --- 356 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 357 vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; 358 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 359 360 ret = hv_vmbus_channel_send_packet( 361 dev->channel, 362 vstor_packet, 363 sizeof(struct vstor_packet), | 334 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 335 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 336 337 if (ret != 0) { 338 goto cleanup; 339 } 340 341 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 14 unchanged lines hidden (view full) --- 356 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 357 vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; 358 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 359 360 ret = hv_vmbus_channel_send_packet( 361 dev->channel, 362 vstor_packet, 363 sizeof(struct vstor_packet), |
364 (uint64_t)request, | 364 (uint64_t)(uintptr_t)request, |
365 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 366 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 367 368 if ( ret != 0) { 369 goto cleanup; 370 } 371 372 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 11 unchanged lines hidden (view full) --- 384 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 385 vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; 386 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 387 388 ret = hv_vmbus_channel_send_packet( 389 dev->channel, 390 vstor_packet, 391 sizeof(struct vstor_packet), | 365 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 366 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 367 368 if ( ret != 0) { 369 goto cleanup; 370 } 371 372 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 11 unchanged lines hidden (view full) --- 384 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 385 vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; 386 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 387 388 ret = hv_vmbus_channel_send_packet( 389 dev->channel, 390 vstor_packet, 391 sizeof(struct vstor_packet), |
392 (uint64_t)request, | 392 (uint64_t)(uintptr_t)request, |
393 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 394 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 395 396 if (ret != 0) { 397 goto cleanup; 398 } 399 400 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 76 unchanged lines hidden (view full) --- 477 sema_init(&request->synch_sema, 0, "stor synch sema"); 478 479 vstor_packet->operation = VSTOR_OPERATION_RESETBUS; 480 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 481 482 ret = hv_vmbus_channel_send_packet(dev->channel, 483 vstor_packet, 484 sizeof(struct vstor_packet), | 393 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 394 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 395 396 if (ret != 0) { 397 goto cleanup; 398 } 399 400 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 76 unchanged lines hidden (view full) --- 477 sema_init(&request->synch_sema, 0, "stor synch sema"); 478 479 vstor_packet->operation = VSTOR_OPERATION_RESETBUS; 480 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 481 482 ret = hv_vmbus_channel_send_packet(dev->channel, 483 vstor_packet, 484 sizeof(struct vstor_packet), |
485 (uint64_t)&sc->hs_reset_req, | 485 (uint64_t)(uintptr_t)&sc->hs_reset_req, |
486 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 487 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 488 489 if (ret != 0) { 490 goto cleanup; 491 } 492 493 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 48 unchanged lines hidden (view full) --- 542 543 mtx_unlock(&request->softc->hs_lock); 544 if (request->data_buf.length) { 545 ret = hv_vmbus_channel_send_packet_multipagebuffer( 546 device->channel, 547 &request->data_buf, 548 vstor_packet, 549 sizeof(struct vstor_packet), | 486 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 487 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 488 489 if (ret != 0) { 490 goto cleanup; 491 } 492 493 ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */ --- 48 unchanged lines hidden (view full) --- 542 543 mtx_unlock(&request->softc->hs_lock); 544 if (request->data_buf.length) { 545 ret = hv_vmbus_channel_send_packet_multipagebuffer( 546 device->channel, 547 &request->data_buf, 548 vstor_packet, 549 sizeof(struct vstor_packet), |
550 (uint64_t)request); | 550 (uint64_t)(uintptr_t)request); |
551 552 } else { 553 ret = hv_vmbus_channel_send_packet( 554 device->channel, 555 vstor_packet, 556 sizeof(struct vstor_packet), | 551 552 } else { 553 ret = hv_vmbus_channel_send_packet( 554 device->channel, 555 vstor_packet, 556 sizeof(struct vstor_packet), |
557 (uint64_t)request, | 557 (uint64_t)(uintptr_t)request, |
558 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 559 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 560 } 561 mtx_lock(&request->softc->hs_lock); 562 563 if (ret != 0) { 564 printf("Unable to send packet %p ret %d", vstor_packet, ret); 565 } else { --- 63 unchanged lines hidden (view full) --- 629 ret = hv_vmbus_channel_recv_packet( 630 device->channel, 631 packet, 632 roundup2(sizeof(struct vstor_packet), 8), 633 &bytes_recvd, 634 &request_id); 635 636 while ((ret == 0) && (bytes_recvd > 0)) { | 558 HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 559 HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 560 } 561 mtx_lock(&request->softc->hs_lock); 562 563 if (ret != 0) { 564 printf("Unable to send packet %p ret %d", vstor_packet, ret); 565 } else { --- 63 unchanged lines hidden (view full) --- 629 ret = hv_vmbus_channel_recv_packet( 630 device->channel, 631 packet, 632 roundup2(sizeof(struct vstor_packet), 8), 633 &bytes_recvd, 634 &request_id); 635 636 while ((ret == 0) && (bytes_recvd > 0)) { |
637 request = (struct hv_storvsc_request *)request_id; | 637 request = (struct hv_storvsc_request *)(uintptr_t)request_id; |
638 KASSERT(request, ("request")); 639 640 if ((request == &sc->hs_init_req) || 641 (request == &sc->hs_reset_req)) { 642 memcpy(&request->vstor_packet, packet, 643 sizeof(struct vstor_packet)); 644 sema_post(&request->synch_sema); 645 } else { --- 750 unchanged lines hidden --- | 638 KASSERT(request, ("request")); 639 640 if ((request == &sc->hs_init_req) || 641 (request == &sc->hs_reset_req)) { 642 memcpy(&request->vstor_packet, packet, 643 sizeof(struct vstor_packet)); 644 sema_post(&request->synch_sema); 645 } else { --- 750 unchanged lines hidden --- |