History

vfio: Remove migration protocol v1 documentation

v1 was never implemented and is replaced by v2. The old uAPI documentation is removed from the header file. The old uAPI definitions are still kept in the header file to ease transition for userspace copying these headers. They will be fully removed down the road.

Jason Gunthorpe committed 4 years ago

Commit 0f3f9cd1 parent 8cb3d831 file · +2 −198Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/vfio.h+2−198
@@ -323,7 +323,7 @@ struct vfio_region_info_cap_type { · 322 unmodified lines
323#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)323#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
324#define VFIO_REGION_TYPE_GFX (1)324#define VFIO_REGION_TYPE_GFX (1)
325#define VFIO_REGION_TYPE_CCW (2)325#define VFIO_REGION_TYPE_CCW (2)
326#define VFIO_REGION_TYPE_MIGRATION (3)326#define VFIO_REGION_TYPE_MIGRATION_DEPRECATED (3)
327 327
328/* sub-types for VFIO_REGION_TYPE_PCI_* */328/* sub-types for VFIO_REGION_TYPE_PCI_* */
329 329
@@ -405,203 +405,7 @@ struct vfio_region_gfx_edid { · 75 unmodified lines
405#define VFIO_REGION_SUBTYPE_CCW_CRW (3)405#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
406 406
407/* sub-types for VFIO_REGION_TYPE_MIGRATION */407/* sub-types for VFIO_REGION_TYPE_MIGRATION */
408#define VFIO_REGION_SUBTYPE_MIGRATION (1)408#define VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED (1)
409
410/*
411 * The structure vfio_device_migration_info is placed at the 0th offset of
412 * the VFIO_REGION_SUBTYPE_MIGRATION region to get and set VFIO device related
413 * migration information. Field accesses from this structure are only supported
414 * at their native width and alignment. Otherwise, the result is undefined and
415 * vendor drivers should return an error.
416 *
417 * device_state: (read/write)
418 * - The user application writes to this field to inform the vendor driver
419 * about the device state to be transitioned to.
420 * - The vendor driver should take the necessary actions to change the
421 * device state. After successful transition to a given state, the
422 * vendor driver should return success on write(device_state, state)
423 * system call. If the device state transition fails, the vendor driver
424 * should return an appropriate -errno for the fault condition.
425 * - On the user application side, if the device state transition fails,
426 * that is, if write(device_state, state) returns an error, read
427 * device_state again to determine the current state of the device from
428 * the vendor driver.
429 * - The vendor driver should return previous state of the device unless
430 * the vendor driver has encountered an internal error, in which case
431 * the vendor driver may report the device_state VFIO_DEVICE_STATE_ERROR.
432 * - The user application must use the device reset ioctl to recover the
433 * device from VFIO_DEVICE_STATE_ERROR state. If the device is
434 * indicated to be in a valid device state by reading device_state, the
435 * user application may attempt to transition the device to any valid
436 * state reachable from the current state or terminate itself.
437 *
438 * device_state consists of 3 bits:
439 * - If bit 0 is set, it indicates the _RUNNING state. If bit 0 is clear,
440 * it indicates the _STOP state. When the device state is changed to
441 * _STOP, driver should stop the device before write() returns.
442 * - If bit 1 is set, it indicates the _SAVING state, which means that the
443 * driver should start gathering device state information that will be
444 * provided to the VFIO user application to save the device's state.
445 * - If bit 2 is set, it indicates the _RESUMING state, which means that
446 * the driver should prepare to resume the device. Data provided through
447 * the migration region should be used to resume the device.
448 * Bits 3 - 31 are reserved for future use. To preserve them, the user
449 * application should perform a read-modify-write operation on this
450 * field when modifying the specified bits.
451 *
452 * +------- _RESUMING
453 * |+------ _SAVING
454 * ||+----- _RUNNING
455 * |||
456 * 000b => Device Stopped, not saving or resuming
457 * 001b => Device running, which is the default state
458 * 010b => Stop the device & save the device state, stop-and-copy state
459 * 011b => Device running and save the device state, pre-copy state
460 * 100b => Device stopped and the device state is resuming
461 * 101b => Invalid state
462 * 110b => Error state
463 * 111b => Invalid state
464 *
465 * State transitions:
466 *
467 * _RESUMING _RUNNING Pre-copy Stop-and-copy _STOP
468 * (100b) (001b) (011b) (010b) (000b)
469 * 0. Running or default state
470 * |
471 *
472 * 1. Normal Shutdown (optional)
473 * |------------------------------------->|
474 *
475 * 2. Save the state or suspend
476 * |------------------------->|---------->|
477 *
478 * 3. Save the state during live migration
479 * |----------->|------------>|---------->|
480 *
481 * 4. Resuming
482 * |<---------|
483 *
484 * 5. Resumed
485 * |--------->|
486 *
487 * 0. Default state of VFIO device is _RUNNING when the user application starts.
488 * 1. During normal shutdown of the user application, the user application may
489 * optionally change the VFIO device state from _RUNNING to _STOP. This
490 * transition is optional. The vendor driver must support this transition but
491 * must not require it.
492 * 2. When the user application saves state or suspends the application, the
493 * device state transitions from _RUNNING to stop-and-copy and then to _STOP.
494 * On state transition from _RUNNING to stop-and-copy, driver must stop the
495 * device, save the device state and send it to the application through the
496 * migration region. The sequence to be followed for such transition is given
497 * below.
498 * 3. In live migration of user application, the state transitions from _RUNNING
499 * to pre-copy, to stop-and-copy, and to _STOP.
500 * On state transition from _RUNNING to pre-copy, the driver should start
501 * gathering the device state while the application is still running and send
502 * the device state data to application through the migration region.
503 * On state transition from pre-copy to stop-and-copy, the driver must stop
504 * the device, save the device state and send it to the user application
505 * through the migration region.
506 * Vendor drivers must support the pre-copy state even for implementations
507 * where no data is provided to the user before the stop-and-copy state. The
508 * user must not be required to consume all migration data before the device
509 * transitions to a new state, including the stop-and-copy state.
510 * The sequence to be followed for above two transitions is given below.
511 * 4. To start the resuming phase, the device state should be transitioned from
512 * the _RUNNING to the _RESUMING state.
513 * In the _RESUMING state, the driver should use the device state data
514 * received through the migration region to resume the device.
515 * 5. After providing saved device data to the driver, the application should
516 * change the state from _RESUMING to _RUNNING.
517 *
518 * reserved:
519 * Reads on this field return zero and writes are ignored.
520 *
521 * pending_bytes: (read only)
522 * The number of pending bytes still to be migrated from the vendor driver.
523 *
524 * data_offset: (read only)
525 * The user application should read data_offset field from the migration
526 * region. The user application should read the device data from this
527 * offset within the migration region during the _SAVING state or write
528 * the device data during the _RESUMING state. See below for details of
529 * sequence to be followed.
530 *
531 * data_size: (read/write)
532 * The user application should read data_size to get the size in bytes of
533 * the data copied in the migration region during the _SAVING state and
534 * write the size in bytes of the data copied in the migration region
535 * during the _RESUMING state.
536 *
537 * The format of the migration region is as follows:
538 * ------------------------------------------------------------------
539 * |vfio_device_migration_info| data section |
540 * | | /////////////////////////////// |
541 * ------------------------------------------------------------------
542 * ^ ^
543 * offset 0-trapped part data_offset
544 *
545 * The structure vfio_device_migration_info is always followed by the data
546 * section in the region, so data_offset will always be nonzero. The offset
547 * from where the data is copied is decided by the kernel driver. The data
548 * section can be trapped, mmapped, or partitioned, depending on how the kernel
549 * driver defines the data section. The data section partition can be defined
550 * as mapped by the sparse mmap capability. If mmapped, data_offset must be
551 * page aligned, whereas initial section which contains the
552 * vfio_device_migration_info structure, might not end at the offset, which is
553 * page aligned. The user is not required to access through mmap regardless
554 * of the capabilities of the region mmap.
555 * The vendor driver should determine whether and how to partition the data
556 * section. The vendor driver should return data_offset accordingly.
557 *
558 * The sequence to be followed while in pre-copy state and stop-and-copy state
559 * is as follows:
560 * a. Read pending_bytes, indicating the start of a new iteration to get device
561 * data. Repeated read on pending_bytes at this stage should have no side
562 * effects.
563 * If pending_bytes == 0, the user application should not iterate to get data
564 * for that device.
565 * If pending_bytes > 0, perform the following steps.
566 * b. Read data_offset, indicating that the vendor driver should make data
567 * available through the data section. The vendor driver should return this
568 * read operation only after data is available from (region + data_offset)
569 * to (region + data_offset + data_size).
570 * c. Read data_size, which is the amount of data in bytes available through
571 * the migration region.
572 * Read on data_offset and data_size should return the offset and size of
573 * the current buffer if the user application reads data_offset and
574 * data_size more than once here.
575 * d. Read data_size bytes of data from (region + data_offset) from the
576 * migration region.
577 * e. Process the data.
578 * f. Read pending_bytes, which indicates that the data from the previous
579 * iteration has been read. If pending_bytes > 0, go to step b.
580 *
581 * The user application can transition from the _SAVING|_RUNNING
582 * (pre-copy state) to the _SAVING (stop-and-copy) state regardless of the
583 * number of pending bytes. The user application should iterate in _SAVING
584 * (stop-and-copy) until pending_bytes is 0.
585 *
586 * The sequence to be followed while _RESUMING device state is as follows:
587 * While data for this device is available, repeat the following steps:
588 * a. Read data_offset from where the user application should write data.
589 * b. Write migration data starting at the migration region + data_offset for
590 * the length determined by data_size from the migration source.
591 * c. Write data_size, which indicates to the vendor driver that data is
592 * written in the migration region. Vendor driver must return this write
593 * operations on consuming data. Vendor driver should apply the
594 * user-provided migration region data to the device resume state.
595 *
596 * If an error occurs during the above sequences, the vendor driver can return
597 * an error code for next read() or write() operation, which will terminate the
598 * loop. The user application should then take the next necessary action, for
599 * example, failing migration or terminating the user application.
600 *
601 * For the user application, data is opaque. The user application should write
602 * data in the same order as the data is received and the data should be of
603 * same transaction size at the source.
604 */
605 409
606struct vfio_device_migration_info {410struct vfio_device_migration_info {
607 __u32 device_state; /* VFIO device state */411 __u32 device_state; /* VFIO device state */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t