idxd: Eliminate configs

SPDK has settled on what the optimal DSA configuration is, so let's
always use it.

Change-Id: I24b9b717709d553789285198b1aa391f4d7f0445
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11532
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Ben Walker 2022-01-21 12:50:31 -07:00 committed by Tomasz Zawadzki
parent 049bb9e41f
commit f0bf4e75f5
21 changed files with 93 additions and 450 deletions

View File

@ -78,62 +78,48 @@ To use the IOAT engine, use the RPC [`ioat_scan_accel_engine`](https://spdk.io/d
### IDXD Module {#accel_idxd} ### IDXD Module {#accel_idxd}
To use the DSA engine, use the RPC [`idxd_scan_accel_engine`](https://spdk.io/doc/jsonrpc.html). With an optional parameter To use the DSA engine, use the RPC
of `-c` and providing a configuration number of either 0 or 1, users can determine which pre-defined configuration can be used. [`idxd_scan_accel_engine`](https://spdk.io/doc/jsonrpc.html). By default, this
With an optional parameter of `-k` to use kernel or user space driver. These pre-defined configurations determine how the DSA engine will attempt to load the SPDK user-space idxd driver. To use the built-in
will be setup in terms of work queues and engines. The DSA engine is very flexible allowing for various configurations of kernel driver on Linux, add the `-k` parameter. See the next section for
these elements to either account for different quality of service requirements or to isolate hardware paths where the back details on using the kernel driver.
end media is of varying latency (i.e. persistent memory vs DRAM). The pre-defined configurations are as follows:
0: A single work queue backed with four DSA engines. This is a generic configuration The DSA hardware supports a limited queue depth and channels. This means that
that enables the hardware to best determine which engine to use as it pulls in new only a limited number of `spdk_thread`s will be able to acquire a channel.
operations. Design software to deal with the inability to get a channel.
1: Two separate work queues each backed with two DSA engines. This is another
generic configuration that is documented in the specification and allows the
application to partition submissions across two work queues. This would be useful
when different priorities might be desired per group.
There are several other configurations that are possible that include quality
of service parameters on the work queues that are not currently utilized by
the module. Specialized use of DSA may require different configurations that
can be added to the module as needed.
When a new channel starts, a DSA device will be assigned to the channel. The accel
idxd module has been tuned for the most likely best performance case. The result
is that there is a limited number of channels that can be supported based on the
number of DSA devices in the system. Additionally, for best performance, the accel
idxd module will only use DSA devices on the same socket as the requesting
channel/thread. If an error occurs on initialization indicating that there are no
more DSA devices available either try fewer threads or, if on a 2 socket system,
try spreading threads across cores if possible.
### How to use kernel idxd driver {#accel_idxd_kernel} ### How to use kernel idxd driver {#accel_idxd_kernel}
There are several dependencies to leverage kernel idxd driver for driving DSA devices. There are several dependencies to leverage the Linux idxd driver for driving DSA devices.
1 Linux kernel support: To leverage kernel space idxd driver, you need to have a Linux kernel with 1 Linux kernel support: You need to have a Linux kernel with the `idxd` driver
`idxd` driver loaded with scalable mode. And currently SPDK uses the character device while `idxd` driver is loaded. Futher, add the following command line options to the kernel boot
enabled in the kernel. So when booting the machine, we need to add additional configuration in commands:
the grub, i.e, revise the kernel boot commandline `intel_iommu=on,sm_on` with VT-d turned on in BIOS.
2 User library dependency: Users need to install `idxd-config` library. For example, users can ```bash
download the library from [idxd-config repo](https://github.com/intel/idxd-config). After the intel_iommu=on,sm_on
library is installed, users can use the `accel-config` command to configure the work queues(WQs) ```
of the idxd devices managed by the kernel with the following steps:
2 User library dependency: Users need to install the `accel-config` library.
This is often packaged, but the source is available on
[GitHub](https://github.com/intel/idxd-config). After the library is installed,
users can use the `accel-config` command to configure the work queues(WQs) of
the idxd devices managed by the kernel with the following steps:
```bash ```bash
accel-config disable-wq dsa0/wq0.1 accel-config disable-wq dsa0/wq0.1
accel-config disable-device dsa0 accel-config disable-device dsa0
accel-config config-wq --group-id=0 --mode=dedicated --wq-size=16 --type=user --name="MyApp1" accel-config config-wq --group-id=0 --mode=dedicated --wq-size=128 --type=user --name="MyApp1"
--priority=10 --block-on-fault=1 dsa0/wq0.1 --priority=10 --block-on-fault=1 dsa0/wq0.1
accel-config config-engine dsa0/engine0.0 --group-id=0
accel-config config-engine dsa0/engine0.1 --group-id=0 accel-config config-engine dsa0/engine0.1 --group-id=0
accel-config config-engine dsa0/engine0.2 --group-id=0
accel-config config-engine dsa0/engine0.3 --group-id=0
accel-config enable-device dsa0 accel-config enable-device dsa0
accel-config enable-wq dsa0/wq0.1 accel-config enable-wq dsa0/wq0.1
``` ```
For more details on the usage of `idxd-config`, please refer to DSA can be configured in many ways, but the above configuration is needed for use with SPDK.
[idxd-config usage](https://github.com/intel/idxd-config/tree/master/Documentation/accfg).
### Software Module {#accel_sw} ### Software Module {#accel_sw}

View File

@ -1502,7 +1502,6 @@ This feature is considered as experimental.
Name | Optional | Type | Description Name | Optional | Type | Description
----------------------- | -------- | ----------- | ----------- ----------------------- | -------- | ----------- | -----------
config_number | Required | number | Pre-defined config # to use (ie 0, 1). See [docs.](https://spdk.io/doc/idxd.html)
config_kernel_mode | Optional | Boolean | If set, will use kernel idxd driver. config_kernel_mode | Optional | Boolean | If set, will use kernel idxd driver.
#### Example #### Example
@ -1512,7 +1511,6 @@ Example request:
~~~json ~~~json
{ {
"params": { "params": {
"config_number": 0,
"config_kernel_mode": false "config_kernel_mode": false
}, },
"jsonrpc": "2.0", "jsonrpc": "2.0",

View File

@ -169,7 +169,7 @@ attach_cb(void *cb_ctx, struct spdk_idxd_device *idxd)
static int static int
idxd_init(void) idxd_init(void)
{ {
spdk_idxd_set_config(0, g_idxd_kernel_mode); spdk_idxd_set_config(g_idxd_kernel_mode);
if (spdk_idxd_probe(NULL, attach_cb) != 0) { if (spdk_idxd_probe(NULL, attach_cb) != 0) {
fprintf(stderr, "idxd_probe() failed\n"); fprintf(stderr, "idxd_probe() failed\n");

View File

@ -133,10 +133,9 @@ void spdk_idxd_detach(struct spdk_idxd_device *idxd);
/** /**
* Sets the IDXD configuration. * Sets the IDXD configuration.
* *
* \param config_number the configuration number for a valid IDXD config.
* \param kernel_mode true if using kernel driver. * \param kernel_mode true if using kernel driver.
*/ */
void spdk_idxd_set_config(uint32_t config_number, bool kernel_mode); void spdk_idxd_set_config(bool kernel_mode);
/** /**
* Build and submit an idxd memory copy request. * Build and submit an idxd memory copy request.

View File

@ -45,8 +45,6 @@
extern "C" { extern "C" {
#endif #endif
#define IDXD_MAX_CONFIG_NUM 1
enum dsa_opcode { enum dsa_opcode {
IDXD_OPCODE_NOOP = 0, IDXD_OPCODE_NOOP = 0,
IDXD_OPCODE_BATCH = 1, IDXD_OPCODE_BATCH = 1,

View File

@ -51,31 +51,6 @@
static STAILQ_HEAD(, spdk_idxd_impl) g_idxd_impls = STAILQ_HEAD_INITIALIZER(g_idxd_impls); static STAILQ_HEAD(, spdk_idxd_impl) g_idxd_impls = STAILQ_HEAD_INITIALIZER(g_idxd_impls);
static struct spdk_idxd_impl *g_idxd_impl; static struct spdk_idxd_impl *g_idxd_impl;
/*
* g_dev_cfg gives us 2 pre-set configurations of DSA to choose from
* via RPC.
*/
struct device_config *g_dev_cfg = NULL;
/*
* Pre-built configurations. Variations depend on various factors
* including how many different types of target latency profiles there
* are, how many different QOS requirements there might be, etc.
*/
struct device_config g_dev_cfg0 = {
.config_num = 0,
.num_groups = 1,
.total_wqs = 1,
.total_engines = 4,
};
struct device_config g_dev_cfg1 = {
.config_num = 1,
.num_groups = 2,
.total_wqs = 4,
.total_engines = 4,
};
uint32_t uint32_t
spdk_idxd_get_socket(struct spdk_idxd_device *idxd) spdk_idxd_get_socket(struct spdk_idxd_device *idxd)
{ {
@ -146,16 +121,10 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd)
chan->portal_offset = (idxd->num_channels * PORTAL_STRIDE) & PORTAL_MASK; chan->portal_offset = (idxd->num_channels * PORTAL_STRIDE) & PORTAL_MASK;
idxd->num_channels++; idxd->num_channels++;
/* Round robin the WQ selection for the chan on this IDXD device. */
idxd->wq_id++;
if (idxd->wq_id == g_dev_cfg->total_wqs) {
idxd->wq_id = 0;
}
pthread_mutex_unlock(&idxd->num_channels_lock); pthread_mutex_unlock(&idxd->num_channels_lock);
/* Allocate descriptors and completions */ /* Allocate descriptors and completions */
num_descriptors = idxd->queues[idxd->wq_id].wqcfg.wq_size / idxd->chan_per_device; num_descriptors = idxd->queues[0].wqcfg.wq_size / idxd->chan_per_device;
chan->desc_base = desc = spdk_zmalloc(num_descriptors * sizeof(struct idxd_hw_desc), chan->desc_base = desc = spdk_zmalloc(num_descriptors * sizeof(struct idxd_hw_desc),
0x40, NULL, 0x40, NULL,
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
@ -295,9 +264,8 @@ idxd_get_impl_by_name(const char *impl_name)
return NULL; return NULL;
} }
/* Called via RPC to select a pre-defined configuration. */
void void
spdk_idxd_set_config(uint32_t config_num, bool kernel_mode) spdk_idxd_set_config(bool kernel_mode)
{ {
if (kernel_mode) { if (kernel_mode) {
g_idxd_impl = idxd_get_impl_by_name(KERNEL_DRIVER_NAME); g_idxd_impl = idxd_get_impl_by_name(KERNEL_DRIVER_NAME);
@ -310,21 +278,6 @@ spdk_idxd_set_config(uint32_t config_num, bool kernel_mode)
kernel_mode ? KERNEL_DRIVER_NAME : USERSPACE_DRIVER_NAME); kernel_mode ? KERNEL_DRIVER_NAME : USERSPACE_DRIVER_NAME);
return; return;
} }
switch (config_num) {
case 0:
g_dev_cfg = &g_dev_cfg0;
break;
case 1:
g_dev_cfg = &g_dev_cfg1;
break;
default:
g_dev_cfg = &g_dev_cfg0;
SPDK_ERRLOG("Invalid config, using default\n");
break;
}
g_idxd_impl->set_config(g_dev_cfg, config_num);
} }
static void static void

View File

@ -157,7 +157,6 @@ struct idxd_wq {
struct spdk_idxd_impl { struct spdk_idxd_impl {
const char *name; const char *name;
void (*set_config)(struct device_config *g_dev_cfg, uint32_t config_num);
int (*probe)(void *cb_ctx, spdk_idxd_attach_cb attach_cb); int (*probe)(void *cb_ctx, spdk_idxd_attach_cb attach_cb);
void (*destruct)(struct spdk_idxd_device *idxd); void (*destruct)(struct spdk_idxd_device *idxd);
void (*dump_sw_error)(struct spdk_idxd_device *idxd, void *portal); void (*dump_sw_error)(struct spdk_idxd_device *idxd, void *portal);
@ -168,9 +167,8 @@ struct spdk_idxd_impl {
struct spdk_idxd_device { struct spdk_idxd_device {
struct spdk_idxd_impl *impl; struct spdk_idxd_impl *impl;
void *portals; void *portal;
uint32_t socket_id; uint32_t socket_id;
int wq_id;
uint32_t num_channels; uint32_t num_channels;
uint32_t total_wq_size; uint32_t total_wq_size;
uint32_t chan_per_device; uint32_t chan_per_device;

View File

@ -48,7 +48,12 @@
#define MAX_DSA_DEVICE_ID 16 #define MAX_DSA_DEVICE_ID 16
struct device_config g_kernel_dev_cfg = {}; struct device_config g_kernel_dev_cfg = {
.config_num = 0,
.num_groups = 1,
.total_wqs = 1,
.total_engines = 4,
};
struct spdk_wq_context { struct spdk_wq_context {
struct accfg_wq *wq; struct accfg_wq *wq;
@ -85,8 +90,6 @@ static uint32_t bsr(uint32_t val)
return msb - 1; return msb - 1;
} }
static void init_idxd_impl(struct spdk_idxd_device *idxd);
static int static int
dsa_setup_single_wq(struct spdk_kernel_idxd_device *kernel_idxd, struct accfg_wq *wq, int shared) dsa_setup_single_wq(struct spdk_kernel_idxd_device *kernel_idxd, struct accfg_wq *wq, int shared)
{ {
@ -285,6 +288,41 @@ kernel_idxd_wq_config(struct spdk_kernel_idxd_device *kernel_idxd)
return 0; return 0;
} }
static int _kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb, int dev_id);
static int
kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb)
{
int i;
for (i = 0; i < MAX_DSA_DEVICE_ID; i++) {
_kernel_idxd_probe(cb_ctx, attach_cb, i);
}
return 0;
}
static void
kernel_idxd_dump_sw_error(struct spdk_idxd_device *idxd, void *portal)
{
/* Need to be enhanced later */
}
static char *
kernel_idxd_portal_get_addr(struct spdk_idxd_device *idxd)
{
struct spdk_kernel_idxd_device *kernel_idxd = __kernel_idxd(idxd);
return (char *)kernel_idxd->wq_ctx[0].wq_reg;
}
static struct spdk_idxd_impl g_kernel_idxd_impl = {
.name = "kernel",
.probe = kernel_idxd_probe,
.destruct = kernel_idxd_device_destruct,
.dump_sw_error = kernel_idxd_dump_sw_error,
.portal_get_addr = kernel_idxd_portal_get_addr,
};
static int static int
_kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb, int dev_id) _kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb, int dev_id)
{ {
@ -312,7 +350,7 @@ _kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb, int dev_id)
goto end; goto end;
} }
init_idxd_impl(&kernel_idxd->idxd); kernel_idxd->idxd.impl = &g_kernel_idxd_impl;
kernel_idxd->ctx = ctx; kernel_idxd->ctx = ctx;
/* Supporting non-shared mode first. /* Supporting non-shared mode first.
@ -341,51 +379,4 @@ end:
return rc; return rc;
} }
static int
kernel_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb)
{
int i;
for (i = 0; i < MAX_DSA_DEVICE_ID; i++) {
_kernel_idxd_probe(cb_ctx, attach_cb, i);
}
return 0;
}
static void
kernel_idxd_dump_sw_error(struct spdk_idxd_device *idxd, void *portal)
{
/* Need to be enhanced later */
}
static void
kernel_idxd_set_config(struct device_config *dev_cfg, uint32_t config_num)
{
g_kernel_dev_cfg = *dev_cfg;
}
static char *
kernel_idxd_portal_get_addr(struct spdk_idxd_device *idxd)
{
struct spdk_kernel_idxd_device *kernel_idxd = __kernel_idxd(idxd);
assert(idxd->wq_id <= (g_kernel_dev_cfg.total_wqs - 1));
return (char *)kernel_idxd->wq_ctx[idxd->wq_id].wq_reg;
}
static struct spdk_idxd_impl g_kernel_idxd_impl = {
.name = "kernel",
.set_config = kernel_idxd_set_config,
.probe = kernel_idxd_probe,
.destruct = kernel_idxd_device_destruct,
.dump_sw_error = kernel_idxd_dump_sw_error,
.portal_get_addr = kernel_idxd_portal_get_addr,
};
static void
init_idxd_impl(struct spdk_idxd_device *idxd)
{
idxd->impl = &g_kernel_idxd_impl;
}
SPDK_IDXD_IMPL_REGISTER(kernel, &g_kernel_idxd_impl); SPDK_IDXD_IMPL_REGISTER(kernel, &g_kernel_idxd_impl);

View File

@ -62,7 +62,12 @@ typedef bool (*spdk_idxd_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev
#define __user_idxd(idxd) (struct spdk_user_idxd_device *)idxd #define __user_idxd(idxd) (struct spdk_user_idxd_device *)idxd
pthread_mutex_t g_driver_lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t g_driver_lock = PTHREAD_MUTEX_INITIALIZER;
static struct device_config g_user_dev_cfg = {}; struct device_config g_user_dev_cfg = {
.config_num = 0,
.num_groups = 1,
.total_wqs = 1,
.total_engines = 4,
};
static struct spdk_idxd_device *idxd_attach(struct spdk_pci_device *device); static struct spdk_idxd_device *idxd_attach(struct spdk_pci_device *device);
@ -98,12 +103,6 @@ _idxd_write_8(struct spdk_idxd_device *idxd, uint32_t offset, uint64_t value)
spdk_mmio_write_8((uint64_t *)(user_idxd->reg_base + offset), value); spdk_mmio_write_8((uint64_t *)(user_idxd->reg_base + offset), value);
} }
static void
user_idxd_set_config(struct device_config *dev_cfg, uint32_t config_num)
{
g_user_dev_cfg = *dev_cfg;
}
/* Used for control commands, not for descriptor submission. */ /* Used for control commands, not for descriptor submission. */
static int static int
idxd_wait_cmd(struct spdk_idxd_device *idxd, int _timeout) idxd_wait_cmd(struct spdk_idxd_device *idxd, int _timeout)
@ -142,7 +141,7 @@ idxd_unmap_pci_bar(struct spdk_idxd_device *idxd, int bar)
if (bar == IDXD_MMIO_BAR) { if (bar == IDXD_MMIO_BAR) {
addr = (void *)user_idxd->reg_base; addr = (void *)user_idxd->reg_base;
} else if (bar == IDXD_WQ_BAR) { } else if (bar == IDXD_WQ_BAR) {
addr = (void *)idxd->portals; addr = (void *)idxd->portal;
} }
if (addr) { if (addr) {
@ -175,7 +174,7 @@ idxd_map_pci_bars(struct spdk_idxd_device *idxd)
} }
return -EINVAL; return -EINVAL;
} }
idxd->portals = addr; idxd->portal = addr;
return 0; return 0;
} }
@ -547,12 +546,11 @@ user_idxd_dump_sw_err(struct spdk_idxd_device *idxd, void *portal)
static char * static char *
user_idxd_portal_get_addr(struct spdk_idxd_device *idxd) user_idxd_portal_get_addr(struct spdk_idxd_device *idxd)
{ {
return (char *)idxd->portals + idxd->wq_id * WQ_TOTAL_PORTAL_SIZE; return (char *)idxd->portal;
} }
static struct spdk_idxd_impl g_user_idxd_impl = { static struct spdk_idxd_impl g_user_idxd_impl = {
.name = "user", .name = "user",
.set_config = user_idxd_set_config,
.probe = user_idxd_probe, .probe = user_idxd_probe,
.destruct = user_idxd_device_destruct, .destruct = user_idxd_device_destruct,
.dump_sw_error = user_idxd_dump_sw_err, .dump_sw_error = user_idxd_dump_sw_err,

View File

@ -50,7 +50,6 @@
static bool g_idxd_enable = false; static bool g_idxd_enable = false;
static bool g_kernel_mode = false; static bool g_kernel_mode = false;
uint32_t g_config_number;
enum channel_state { enum channel_state {
IDXD_CHANNEL_ACTIVE, IDXD_CHANNEL_ACTIVE,
@ -388,17 +387,11 @@ attach_cb(void *cb_ctx, struct spdk_idxd_device *idxd)
} }
void void
accel_engine_idxd_enable_probe(uint32_t config_number, bool kernel_mode) accel_engine_idxd_enable_probe(bool kernel_mode)
{ {
if (config_number > IDXD_MAX_CONFIG_NUM) {
SPDK_ERRLOG("Invalid config number, using default of 0\n");
config_number = 0;
}
g_config_number = config_number;
g_kernel_mode = kernel_mode; g_kernel_mode = kernel_mode;
g_idxd_enable = true; g_idxd_enable = true;
spdk_idxd_set_config(g_config_number, g_kernel_mode); spdk_idxd_set_config(g_kernel_mode);
} }
static int static int
@ -452,7 +445,6 @@ accel_engine_idxd_write_config_json(struct spdk_json_write_ctx *w)
spdk_json_write_object_begin(w); spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "idxd_scan_accel_engine"); spdk_json_write_named_string(w, "method", "idxd_scan_accel_engine");
spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_object_begin(w, "params");
spdk_json_write_named_uint32(w, "config_number", g_config_number);
spdk_json_write_named_uint32(w, "config_kernel_mode", g_kernel_mode); spdk_json_write_named_uint32(w, "config_kernel_mode", g_kernel_mode);
spdk_json_write_object_end(w); spdk_json_write_object_end(w);
spdk_json_write_object_end(w); spdk_json_write_object_end(w);

View File

@ -38,6 +38,6 @@
#define IDXD_MAX_DEVICES 16 #define IDXD_MAX_DEVICES 16
void accel_engine_idxd_enable_probe(uint32_t config_number, bool kernel_mode); void accel_engine_idxd_enable_probe(bool kernel_mode);
#endif /* SPDK_ACCEL_ENGINE_IDXD_H */ #endif /* SPDK_ACCEL_ENGINE_IDXD_H */

View File

@ -40,12 +40,10 @@
#include "spdk/env.h" #include "spdk/env.h"
struct rpc_idxd_scan_accel_engine { struct rpc_idxd_scan_accel_engine {
uint32_t config_number;
bool config_kernel_mode; bool config_kernel_mode;
}; };
static const struct spdk_json_object_decoder rpc_idxd_scan_accel_engine_decoder[] = { static const struct spdk_json_object_decoder rpc_idxd_scan_accel_engine_decoder[] = {
{"config_number", offsetof(struct rpc_idxd_scan_accel_engine, config_number), spdk_json_decode_uint32},
{"config_kernel_mode", offsetof(struct rpc_idxd_scan_accel_engine, config_kernel_mode), spdk_json_decode_bool, true}, {"config_kernel_mode", offsetof(struct rpc_idxd_scan_accel_engine, config_kernel_mode), spdk_json_decode_bool, true},
}; };
@ -67,12 +65,12 @@ rpc_idxd_scan_accel_engine(struct spdk_jsonrpc_request *request,
} }
if (req.config_kernel_mode) { if (req.config_kernel_mode) {
SPDK_NOTICELOG("Enabling IDXD kernel with config #%u\n", req.config_number); SPDK_NOTICELOG("Enabling IDXD kernel-mode\n");
} else { } else {
SPDK_NOTICELOG("Enabling IDXD with config #%u\n", req.config_number); SPDK_NOTICELOG("Enabling IDXD user-mode\n");
} }
accel_engine_idxd_enable_probe(req.config_number, req.config_kernel_mode); accel_engine_idxd_enable_probe(req.config_kernel_mode);
spdk_jsonrpc_send_bool_response(request, true); spdk_jsonrpc_send_bool_response(request, true);
} }
SPDK_RPC_REGISTER("idxd_scan_accel_engine", rpc_idxd_scan_accel_engine, SPDK_RPC_STARTUP) SPDK_RPC_REGISTER("idxd_scan_accel_engine", rpc_idxd_scan_accel_engine, SPDK_RPC_STARTUP)

View File

@ -1230,7 +1230,7 @@ class SPDKTarget(Target):
nvme_adminq_poll_period_us=100000, retry_count=4) nvme_adminq_poll_period_us=100000, retry_count=4)
if self.enable_idxd: if self.enable_idxd:
rpc.idxd.idxd_scan_accel_engine(self.client, config_number=0, config_kernel_mode=None) rpc.idxd.idxd_scan_accel_engine(self.client, config_kernel_mode=None)
self.log_print("Target IDXD accel engine enabled") self.log_print("Target IDXD accel engine enabled")
rpc.app.framework_set_scheduler(self.client, name=self.scheduler_name) rpc.app.framework_set_scheduler(self.client, name=self.scheduler_name)

View File

@ -2531,12 +2531,10 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
# idxd # idxd
def idxd_scan_accel_engine(args): def idxd_scan_accel_engine(args):
rpc.idxd.idxd_scan_accel_engine(args.client, config_number=args.config_number, rpc.idxd.idxd_scan_accel_engine(args.client, config_kernel_mode=args.config_kernel_mode)
config_kernel_mode=args.config_kernel_mode)
p = subparsers.add_parser('idxd_scan_accel_engine', p = subparsers.add_parser('idxd_scan_accel_engine',
help='Set config and enable idxd accel engine offload.') help='Set config and enable idxd accel engine offload.')
p.add_argument('-c', '--config-number', help="""Pre-defined configuration number to use. See docs.""", type=int)
p.add_argument('-k', '--config-kernel-mode', help='Use Kernel mode idxd', p.add_argument('-k', '--config-kernel-mode', help='Use Kernel mode idxd',
action='store_true', dest='config_kernel_mode') action='store_true', dest='config_kernel_mode')
p.set_defaults(func=idxd_scan_accel_engine, config_kernel_mode=None) p.set_defaults(func=idxd_scan_accel_engine, config_kernel_mode=None)

View File

@ -1,13 +1,11 @@
def idxd_scan_accel_engine(client, config_number=None, config_kernel_mode=None): def idxd_scan_accel_engine(client, config_kernel_mode=None):
"""Scan and enable IDXD accel engine. """Scan and enable IDXD accel engine.
Args: Args:
config_number: Pre-defined configuration number, see docs.
config_kernel_mode: Use kernel IDXD driver. (optional) config_kernel_mode: Use kernel IDXD driver. (optional)
""" """
params = {} params = {}
params['config_number'] = config_number
if config_kernel_mode is not None: if config_kernel_mode is not None:
params['config_kernel_mode'] = config_kernel_mode params['config_kernel_mode'] = config_kernel_mode
return client.call('idxd_scan_accel_engine', params) return client.call('idxd_scan_accel_engine', params)

View File

@ -34,11 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..) SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = idxd.c idxd_user.c DIRS-y = idxd_user.c
ifeq ($(CONFIG_IDXD_KERNEL),y)
DIRS-y += idxd_kernel.c
endif
.PHONY: all clean $(DIRS-y) .PHONY: all clean $(DIRS-y)

View File

@ -1,38 +0,0 @@
#
# BSD LICENSE
#
# Copyright (c) Intel Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
TEST_FILE = idxd_ut.c
include $(SPDK_ROOT_DIR)/mk/spdk.unittest.mk

View File

@ -1,90 +0,0 @@
/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "spdk_cunit.h"
#include "spdk_internal/mock.h"
#include "spdk_internal/idxd.h"
#include "common/lib/test_env.c"
#include "idxd/idxd.h"
#include "idxd/idxd.c"
static void
user_idxd_set_config(struct device_config *dev_cfg, uint32_t config_num)
{
}
static struct spdk_idxd_impl g_user_idxd_impl = {
.name = "user",
.set_config = user_idxd_set_config,
};
static int
test_spdk_idxd_set_config(void)
{
g_dev_cfg = NULL;
spdk_idxd_set_config(false, 0);
SPDK_CU_ASSERT_FATAL(g_dev_cfg != NULL);
CU_ASSERT(memcmp(&g_dev_cfg0, g_dev_cfg, sizeof(struct device_config)) == 0);
return 0;
}
static int
test_setup(void)
{
idxd_impl_register(&g_user_idxd_impl);
g_dev_cfg = &g_dev_cfg0;
return 0;
}
int main(int argc, char **argv)
{
CU_pSuite suite = NULL;
unsigned int num_failures;
CU_set_error_action(CUEA_ABORT);
CU_initialize_registry();
suite = CU_add_suite("idxd", test_setup, NULL);
CU_ADD_TEST(suite, test_spdk_idxd_set_config);
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
num_failures = CU_get_number_of_failures();
CU_cleanup_registry();
return num_failures;
}

View File

@ -1,38 +0,0 @@
#
# BSD LICENSE
#
# Copyright (c) Intel Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
TEST_FILE = idxd_kernel_ut.c
include $(SPDK_ROOT_DIR)/mk/spdk.unittest.mk

View File

@ -1,93 +0,0 @@
/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "spdk_cunit.h"
#include "spdk_internal/mock.h"
#include "spdk_internal/idxd.h"
#include "common/lib/test_env.c"
#include "idxd/idxd.h"
#include "idxd/idxd_kernel.c"
DEFINE_STUB_V(idxd_impl_register, (struct spdk_idxd_impl *impl));
static int
test_kernel_idxd_set_config(void)
{
struct spdk_kernel_idxd_device kernel_idxd = {};
int rc;
kernel_idxd.wq_ctx = calloc(g_kernel_dev_cfg.num_groups, sizeof(*kernel_idxd.wq_ctx));
SPDK_CU_ASSERT_FATAL(kernel_idxd.wq_ctx != NULL);
kernel_idxd.wq_active_num = 1;
rc = kernel_idxd_wq_config(&kernel_idxd);
CU_ASSERT(rc == 0);
free(kernel_idxd.idxd.groups);
free(kernel_idxd.idxd.queues);
free(kernel_idxd.wq_ctx);
return 0;
}
static int
test_setup(void)
{
g_kernel_dev_cfg.config_num = 0;
g_kernel_dev_cfg.num_groups = 1;
g_kernel_dev_cfg.total_wqs = 1;
g_kernel_dev_cfg.total_engines = 4;
return 0;
}
int main(int argc, char **argv)
{
CU_pSuite suite = NULL;
unsigned int num_failures;
CU_set_error_action(CUEA_ABORT);
CU_initialize_registry();
suite = CU_add_suite("idxdi_kernel", test_setup, NULL);
CU_ADD_TEST(suite, test_kernel_idxd_set_config);
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
num_failures = CU_get_number_of_failures();
CU_cleanup_registry();
return num_failures;
}

View File

@ -208,7 +208,6 @@ fi
run_test "unittest_accel" $valgrind $testdir/lib/accel/accel.c/accel_engine_ut run_test "unittest_accel" $valgrind $testdir/lib/accel/accel.c/accel_engine_ut
run_test "unittest_ioat" $valgrind $testdir/lib/ioat/ioat.c/ioat_ut run_test "unittest_ioat" $valgrind $testdir/lib/ioat/ioat.c/ioat_ut
if grep -q '#define SPDK_CONFIG_IDXD 1' $rootdir/include/spdk/config.h; then if grep -q '#define SPDK_CONFIG_IDXD 1' $rootdir/include/spdk/config.h; then
run_test "unittest_idxd" $valgrind $testdir/lib/idxd/idxd.c/idxd_ut
run_test "unittest_idxd_user" $valgrind $testdir/lib/idxd/idxd_user.c/idxd_user_ut run_test "unittest_idxd_user" $valgrind $testdir/lib/idxd/idxd_user.c/idxd_user_ut
fi fi
run_test "unittest_iscsi" unittest_iscsi run_test "unittest_iscsi" unittest_iscsi