Commit 4e0ca20a authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

idxd: Do not present pci device info in accel_engine_idxd.c module



Purpose: We will also support the kernel idxd driver, so we do not
need export this feature in the module file.

Change-Id: I965e031497920f527962ba187bccd81de6977b8f
Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7336


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent a7c37873
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2,6 +2,11 @@

## v21.07: (Upcoming Release)

### idxd

Remove the probe_cb parameter in spdk_idxd_probe function. And remove the definition
of spdk_idxd_probe_cb function pointer. It should be implemented in idxd_user.c.

## v21.04:

### accel
+2 −15
Original line number Diff line number Diff line
@@ -86,26 +86,14 @@ int spdk_idxd_reconfigure_chan(struct spdk_idxd_io_channel *chan);
 */
typedef void (*spdk_idxd_req_cb)(void *arg, int status);

/**
 * Callback for spdk_idxd_probe() enumeration.
 *
 * \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_idxd_probe().
 * \param pci_dev PCI device that is being probed.
 *
 * \return true to attach to this device.
 */
typedef bool (*spdk_idxd_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev);

/**
 * Callback for spdk_idxd_probe() to report a device that has been attached to
 * the userspace IDXD driver.
 *
 * \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_idxd_probe().
 * \param pci_dev PCI device that was attached to the driver.
 * \param idxd IDXD device that was attached to the driver.
 */
typedef void (*spdk_idxd_attach_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev,
				    struct spdk_idxd_device *idxd);
typedef void (*spdk_idxd_attach_cb)(void *cb_ctx, struct spdk_idxd_device *idxd);

/**
 * Enumerate the IDXD devices attached to the system and attach the userspace
@@ -119,13 +107,12 @@ typedef void (*spdk_idxd_attach_cb)(void *cb_ctx, struct spdk_pci_device *pci_de
 *
 * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of
 * the callbacks.
 * \param probe_cb will be called once per IDXD device found in the system.
 * \param attach_cb will be called for devices for which probe_cb returned true
 * once the IDXD controller has been attached to the userspace driver.
 *
 * \return 0 on success, -1 on failure.
 */
int spdk_idxd_probe(void *cb_ctx, spdk_idxd_probe_cb probe_cb, spdk_idxd_attach_cb attach_cb);
int spdk_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb);

/**
 * Detach specified device returned by spdk_idxd_probe() from the IDXD driver.
+2 −2
Original line number Diff line number Diff line
@@ -353,14 +353,14 @@ idxd_device_destruct(struct spdk_idxd_device *idxd)
}

int
spdk_idxd_probe(void *cb_ctx, spdk_idxd_probe_cb probe_cb, spdk_idxd_attach_cb attach_cb)
spdk_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb)
{
	if (g_idxd_impl == NULL) {
		SPDK_ERRLOG("No idxd impl is selected\n");
		return -1;
	}

	return g_idxd_impl->probe(cb_ctx, probe_cb, attach_cb);
	return g_idxd_impl->probe(cb_ctx, attach_cb);
}

void
+1 −2
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ struct idxd_wq {
struct spdk_idxd_impl {
	const char *name;
	void (*set_config)(struct device_config *g_dev_cfg, uint32_t config_num);
	int (*probe)(void *cb_ctx, spdk_idxd_probe_cb probe_cb, spdk_idxd_attach_cb attach_cb);
	int (*probe)(void *cb_ctx, spdk_idxd_attach_cb attach_cb);
	void (*destruct)(struct spdk_idxd_device *idxd);
	uint64_t (*read_8)(struct spdk_idxd_device *idxd, void *portal, uint32_t offset);
	char *(*portal_get_addr)(struct spdk_idxd_device *idxd);
@@ -192,7 +192,6 @@ struct spdk_idxd_impl {
};

struct spdk_idxd_device {
	struct spdk_pci_device		*device;
	struct spdk_idxd_impl		*impl;
	void				*portals;
	int				wq_id;
+36 −7
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@

struct spdk_user_idxd_device {
	struct spdk_idxd_device	idxd;
	struct spdk_pci_device	*device;
	int			sock_id;
	struct idxd_registers	registers;
	void			*reg_base;
@@ -56,6 +57,8 @@ struct spdk_user_idxd_device {
	uint32_t                        perfmon_offset;
};

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

pthread_mutex_t	g_driver_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -149,7 +152,7 @@ idxd_unmap_pci_bar(struct spdk_idxd_device *idxd, int bar)
	}

	if (addr) {
		rc = spdk_pci_device_unmap_bar(idxd->device, 0, addr);
		rc = spdk_pci_device_unmap_bar(user_idxd->device, 0, addr);
	}
	return rc;
}
@@ -162,14 +165,14 @@ idxd_map_pci_bars(struct spdk_idxd_device *idxd)
	uint64_t phys_addr, size;
	struct spdk_user_idxd_device *user_idxd = __user_idxd(idxd);

	rc = spdk_pci_device_map_bar(idxd->device, IDXD_MMIO_BAR, &addr, &phys_addr, &size);
	rc = spdk_pci_device_map_bar(user_idxd->device, IDXD_MMIO_BAR, &addr, &phys_addr, &size);
	if (rc != 0 || addr == NULL) {
		SPDK_ERRLOG("pci_device_map_range failed with error code %d\n", rc);
		return -1;
	}
	user_idxd->reg_base = addr;

	rc = spdk_pci_device_map_bar(idxd->device, IDXD_WQ_BAR, &addr, &phys_addr, &size);
	rc = spdk_pci_device_map_bar(user_idxd->device, IDXD_WQ_BAR, &addr, &phys_addr, &size);
	if (rc != 0 || addr == NULL) {
		SPDK_ERRLOG("pci_device_map_range failed with error code %d\n", rc);
		rc = idxd_unmap_pci_bar(idxd, IDXD_MMIO_BAR);
@@ -422,12 +425,15 @@ err_reset:
static void
user_idxd_device_destruct(struct spdk_idxd_device *idxd)
{
	struct spdk_user_idxd_device *user_idxd = __user_idxd(idxd);

	idxd_unmap_pci_bar(idxd, IDXD_MMIO_BAR);
	idxd_unmap_pci_bar(idxd, IDXD_WQ_BAR);
	free(idxd->groups);
	free(idxd->queues);

	free(idxd);
	spdk_pci_device_detach(user_idxd->device);
	free(user_idxd);
}

struct idxd_enum_ctx {
@@ -450,14 +456,37 @@ idxd_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
			return -EINVAL;
		}

		enum_ctx->attach_cb(enum_ctx->cb_ctx, pci_dev, idxd);
		enum_ctx->attach_cb(enum_ctx->cb_ctx, idxd);
	}

	return 0;
}


static bool
probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev)
{
	struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr(pci_dev);

	SPDK_NOTICELOG(
		" Found matching device at %04x:%02x:%02x.%x vendor:0x%04x device:0x%04x\n",
		pci_addr.domain,
		pci_addr.bus,
		pci_addr.dev,
		pci_addr.func,
		spdk_pci_device_get_vendor_id(pci_dev),
		spdk_pci_device_get_device_id(pci_dev));

	/* Claim the device in case conflict with other process */
	if (spdk_pci_device_claim(pci_dev) < 0) {
		return false;
	}

	return true;
}

static int
user_idxd_probe(void *cb_ctx, spdk_idxd_probe_cb probe_cb, spdk_idxd_attach_cb attach_cb)
user_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb)
{
	int rc;
	struct idxd_enum_ctx enum_ctx;
@@ -518,8 +547,8 @@ idxd_attach(struct spdk_pci_device *device)
	}

	idxd = &user_idxd->idxd;
	user_idxd->device = device;
	idxd->impl = &g_user_idxd_impl;
	idxd->device = device;
	pthread_mutex_init(&idxd->num_channels_lock, NULL);

	/* Enable PCI busmaster. */
Loading