Commit 052ea0ba authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

vmd: method for removing devices behind VMD



Added new RPC, vmd_remove_device, that allows users to remove a PCI
device managed by the VMD library simulating a hot-remove.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifb84818ce8d147d1d586b52590527e85fe9c10de
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13957


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTom Nabarro <tom.nabarro@intel.com>
parent 9a9aed4e
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -9997,6 +9997,39 @@ Example response:
}
~~~

### vmd_remove_device {#rpc_vmd_remove_device}

Remove a device behind a VMD.

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
addr                    | Required | string      | Address of the device to remove.

### Example

~~~json
{
  "jsonrpc": "2.0",
  "method": "vmd_remove_device",
  "params": {
    "addr": "5d0505:01:00.0"
  }
  "id": 1
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

### spdk_get_version {#rpc_spdk_get_version}

Get the version info of the running SPDK application.
+10 −0
Original line number Diff line number Diff line
@@ -80,6 +80,16 @@ int spdk_vmd_get_led_state(struct spdk_pci_device *pci_device, enum spdk_vmd_led
 */
int spdk_vmd_hotplug_monitor(void);

/**
 * Removes a given device from the PCI subsystem simulating a hot-remove.  If the device is being
 * actively used by another module, the actual detach might be deferred.
 *
 * \param addr Address of a PCI device to remove.
 *
 * \return 0 if the device was successfully removed, negative errno otherwise.
 */
int spdk_vmd_remove_device(const struct spdk_pci_addr *addr);

#ifdef __cplusplus
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 4
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = vmd.c led.c
LIBNAME = vmd
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
	spdk_vmd_set_led_state;
	spdk_vmd_get_led_state;
	spdk_vmd_hotplug_monitor;
	spdk_vmd_remove_device;

	local: *;
};
+16 −0
Original line number Diff line number Diff line
@@ -1419,6 +1419,22 @@ spdk_vmd_hotplug_monitor(void)
	return num_hotplugs;
}

int
spdk_vmd_remove_device(const struct spdk_pci_addr *addr)
{
	struct vmd_pci_device *device;

	device = vmd_find_device(addr);
	if (device == NULL) {
		return -ENODEV;
	}

	assert(strcmp(spdk_pci_device_get_type(&device->pci), "vmd") == 0);
	vmd_remove_device(device);

	return 0;
}

static int
vmd_attach_device(const struct spdk_pci_addr *addr)
{
Loading