Skip to contentSkip to conversation

Add DLB2 PMD

PATCH Superseded Timothy McDaniel 10 participants 366 messages Sep 11, 2020 – Nov 2, 2020 Arm/Amlogic Meson SoC support Page 4 of 8

lore
Share & tools
lore
#201 lore raw

PATCH v11 14/23 event/dlb2: add port link

In reply to Timothy McDaniel

Add port link entry point. Directed queues are identified and created at this stage. Their setup deferred until link-time, at which point we know the directed port ID. Directed queue setup will only fail if this queue is already setup or there are no directed queues left to configure.

---
 drivers/event/dlb2/dlb2.c                  | 302 ++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 633 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +
 drivers/event/dlb2/pf/dlb2_pf.c            |  50 +++
 6 files changed, 1007 insertions(+)
drivers/event/dlb2/dlb2.c +302 -0
index f0b13a4..a7e9a4c 100644
@@ -1496,6 +1496,307 @@ dlb2_eventdev_port_setup(struct rte_eventdev *dev,
 	return 0;
 }
 
+static int16_t
+dlb2_hw_map_ldb_qid_to_port(struct dlb2_hw_dev *handle,
+			    uint32_t qm_port_id,
+			    uint16_t qm_qid,
+			    uint8_t priority)
+{
+	struct dlb2_map_qid_args cfg;
+	int32_t ret;
+
+	if (handle == NULL)
+		return -EINVAL;
+
+	/* Build message */
+	cfg.port_id = qm_port_id;
+	cfg.qid = qm_qid;
+	cfg.priority = EV_TO_DLB2_PRIO(priority);
+
+	ret = dlb2_iface_map_qid(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: map qid error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		DLB2_LOG_ERR("dlb2: grp=%d, qm_port=%d, qm_qid=%d prio=%d\n",
+			     handle->domain_id, cfg.port_id,
+			     cfg.qid,
+			     cfg.priority);
+	} else {
+		DLB2_LOG_DBG("dlb2: mapped queue %d to qm_port %d\n",
+			     qm_qid, qm_port_id);
+	}
+
+	return ret;
+}
+
+static int
+dlb2_event_queue_join_ldb(struct dlb2_eventdev *dlb2,
+			  struct dlb2_eventdev_port *ev_port,
+			  struct dlb2_eventdev_queue *ev_queue,
+			  uint8_t priority)
+{
+	int first_avail = -1;
+	int ret, i;
+
+	for (i = 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) {
+		if (ev_port->link[i].valid) {
+			if (ev_port->link[i].queue_id == ev_queue->id &&
+			    ev_port->link[i].priority == priority) {
+				if (ev_port->link[i].mapped)
+					return 0; /* already mapped */
+				first_avail = i;
+			}
+		} else if (first_avail == -1)
+			first_avail = i;
+	}
+	if (first_avail == -1) {
+		DLB2_LOG_ERR("dlb2: qm_port %d has no available QID slots.\n",
+			     ev_port->qm_port.id);
+		return -EINVAL;
+	}
+
+	ret = dlb2_hw_map_ldb_qid_to_port(&dlb2->qm_instance,
+					  ev_port->qm_port.id,
+					  ev_queue->qm_queue.id,
+					  priority);
+
+	if (!ret)
+		ev_port->link[first_avail].mapped = true;
+
+	return ret;
+}
+
+static int32_t
+dlb2_hw_create_dir_queue(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *ev_queue,
+			 int32_t qm_port_id)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_create_dir_queue_args cfg;
+	int32_t ret;
+
+	/* The directed port is always configured before its queue */
+	cfg.port_id = qm_port_id;
+
+	if (ev_queue->depth_threshold == 0) {
+		cfg.depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+		ev_queue->depth_threshold = RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH;
+	} else
+		cfg.depth_threshold = ev_queue->depth_threshold;
+
+	ret = dlb2_iface_dir_queue_create(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: create DIR event queue error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return -EINVAL;
+	}
+
+	return cfg.response.id;
+}
+
+static int
+dlb2_eventdev_dir_queue_setup(struct dlb2_eventdev *dlb2,
+			      struct dlb2_eventdev_queue *ev_queue,
+			      struct dlb2_eventdev_port *ev_port)
+{
+	int32_t qm_qid;
+
+	qm_qid = dlb2_hw_create_dir_queue(dlb2, ev_queue, ev_port->qm_port.id);
+
+	if (qm_qid < 0) {
+		DLB2_LOG_ERR("Failed to create the DIR queue\n");
+		return qm_qid;
+	}
+
+	dlb2->qm_dir_to_ev_queue_id[qm_qid] = ev_queue->id;
+
+	ev_queue->qm_queue.id = qm_qid;
+
+	return 0;
+}
+
+static int
+dlb2_do_port_link(struct rte_eventdev *dev,
+		  struct dlb2_eventdev_queue *ev_queue,
+		  struct dlb2_eventdev_port *ev_port,
+		  uint8_t prio)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int err;
+
+	/* Don't link until start time. */
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		return 0;
+
+	if (ev_queue->qm_queue.is_directed)
+		err = dlb2_eventdev_dir_queue_setup(dlb2, ev_queue, ev_port);
+	else
+		err = dlb2_event_queue_join_ldb(dlb2, ev_port, ev_queue, prio);
+
+	if (err) {
+		DLB2_LOG_ERR("port link failure for %s ev_q %d, ev_port %d\n",
+			     ev_queue->qm_queue.is_directed ? "DIR" : "LDB",
+			     ev_queue->id, ev_port->id);
+
+		rte_errno = err;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dlb2_validate_port_link(struct dlb2_eventdev_port *ev_port,
+			uint8_t queue_id,
+			bool link_exists,
+			int index)
+{
+	struct dlb2_eventdev *dlb2 = ev_port->dlb2;
+	struct dlb2_eventdev_queue *ev_queue;
+	bool port_is_dir, queue_is_dir;
+
+	if (queue_id > dlb2->num_queues) {
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	ev_queue = &dlb2->ev_queues[queue_id];
+
+	if (!ev_queue->setup_done &&
+	    ev_queue->qm_queue.config_state != DLB2_PREV_CONFIGURED) {
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	port_is_dir = ev_port->qm_port.is_directed;
+	queue_is_dir = ev_queue->qm_queue.is_directed;
+
+	if (port_is_dir != queue_is_dir) {
+		DLB2_LOG_ERR("%s queue %u can't link to %s port %u\n",
+			     queue_is_dir ? "DIR" : "LDB", ev_queue->id,
+			     port_is_dir ? "DIR" : "LDB", ev_port->id);
+
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	/* Check if there is space for the requested link */
+	if (!link_exists && index == -1) {
+		DLB2_LOG_ERR("no space for new link\n");
+		rte_errno = -ENOSPC;
+		return -1;
+	}
+
+	/* Check if the directed port is already linked */
+	if (ev_port->qm_port.is_directed && ev_port->num_links > 0 &&
+	    !link_exists) {
+		DLB2_LOG_ERR("Can't link DIR port %d to >1 queues\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	/* Check if the directed queue is already linked */
+	if (ev_queue->qm_queue.is_directed && ev_queue->num_links > 0 &&
+	    !link_exists) {
+		DLB2_LOG_ERR("Can't link DIR queue %d to >1 ports\n",
+			     ev_queue->id);
+		rte_errno = -EINVAL;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_port_link(struct rte_eventdev *dev, void *event_port,
+			const uint8_t queues[], const uint8_t priorities[],
+			uint16_t nb_links)
+
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	int i, j;
+
+	RTE_SET_USED(dev);
+
+	if (ev_port == NULL) {
+		DLB2_LOG_ERR("dlb2: evport not setup\n");
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (!ev_port->setup_done &&
+	    ev_port->qm_port.config_state != DLB2_PREV_CONFIGURED) {
+		DLB2_LOG_ERR("dlb2: evport not setup\n");
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	/* Note: rte_event_port_link() ensures the PMD won't receive a NULL
+	 * queues pointer.
+	 */
+	if (nb_links == 0) {
+		DLB2_LOG_DBG("dlb2: nb_links is 0\n");
+		return 0; /* Ignore and return success */
+	}
+
+	dlb2 = ev_port->dlb2;
+
+	DLB2_LOG_DBG("Linking %u queues to %s port %d\n",
+		     nb_links,
+		     ev_port->qm_port.is_directed ? "DIR" : "LDB",
+		     ev_port->id);
+
+	for (i = 0; i < nb_links; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+		uint8_t queue_id, prio;
+		bool found = false;
+		int index = -1;
+
+		queue_id = queues[i];
+		prio = priorities[i];
+
+		/* Check if the link already exists. */
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++)
+			if (ev_port->link[j].valid) {
+				if (ev_port->link[j].queue_id == queue_id) {
+					found = true;
+					index = j;
+					break;
+				}
+			} else if (index == -1) {
+				index = j;
+			}
+
+		/* could not link */
+		if (index == -1)
+			break;
+
+		/* Check if already linked at the requested priority */
+		if (found && ev_port->link[j].priority == prio)
+			continue;
+
+		if (dlb2_validate_port_link(ev_port, queue_id, found, index))
+			break; /* return index of offending queue */
+
+		ev_queue = &dlb2->ev_queues[queue_id];
+
+		if (dlb2_do_port_link(dev, ev_queue, ev_port, prio))
+			break; /* return index of offending queue */
+
+		ev_queue->num_links++;
+
+		ev_port->link[index].queue_id = queue_id;
+		ev_port->link[index].priority = prio;
+		ev_port->link[index].valid = true;
+		/* Entry already exists?  If so, then must be prio change */
+		if (!found)
+			ev_port->num_links++;
+	}
+	return i;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1507,6 +1808,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
+		.port_link        = dlb2_eventdev_port_link,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +6 -0
index 01818c7..7d1ba73 100644
@@ -51,3 +51,9 @@ int (*dlb2_iface_ldb_port_create)(struct dlb2_hw_dev *handle,
 int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
 				  struct dlb2_create_dir_port_args *cfg,
 				  enum dlb2_cq_poll_modes poll_mode);
+
+int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
+				   struct dlb2_create_dir_queue_args *cfg);
+
+int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
+			  struct dlb2_map_qid_args *cfg);
drivers/event/dlb2/dlb2_iface.h +6 -0
index a6b923a..4eddd14 100644
@@ -50,4 +50,10 @@ extern int (*dlb2_iface_ldb_port_create)(struct dlb2_hw_dev *handle,
 extern int (*dlb2_iface_dir_port_create)(struct dlb2_hw_dev *handle,
 					 struct dlb2_create_dir_port_args *cfg,
 					 enum dlb2_cq_poll_modes poll_mode);
+
+extern int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
+					struct dlb2_create_dir_queue_args *cfg);
+
+extern int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
+				 struct dlb2_map_qid_args *cfg);
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +633 -0

636 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +10 -0
index 7104f9b..d91d186 100644
@@ -651,3 +651,13 @@ dlb2_pf_create_dir_port(struct dlb2_hw *hw,
 				       NOT_VF_REQ,
 				       PF_ID_ZERO);
 }
+
+int
+dlb2_pf_create_dir_queue(struct dlb2_hw *hw,
+			 u32 id,
+			 struct dlb2_create_dir_queue_args *args,
+			 struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_create_dir_queue(hw, id, args, resp, NOT_VF_REQ,
+					PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_pf.c +50 -0

63 lines not on this page · raw message

Signature · 1 line
2.6.4
#202 lore raw

PATCH v11 15/23 event/dlb2: add port unlink and port unlinks in progress

In reply to Timothy McDaniel

Add supports for the port unlink(s) eventdev entry points. The unlink operation is an asynchronous operation executed by a control thread, and the unlinks-in-progress function reads a counter shared with the control thread.

---
 drivers/event/dlb2/dlb2.c                  | 163 +++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 283 +++++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_pf.c            |  51 ++++++
 5 files changed, 509 insertions(+)
drivers/event/dlb2/dlb2.c +163 -0
index a7e9a4c..9357b23 100644
@@ -1797,6 +1797,166 @@ dlb2_eventdev_port_link(struct rte_eventdev *dev, void *event_port,
 	return i;
 }
 
+static int16_t
+dlb2_hw_unmap_ldb_qid_from_port(struct dlb2_hw_dev *handle,
+				uint32_t qm_port_id,
+				uint16_t qm_qid)
+{
+	struct dlb2_unmap_qid_args cfg;
+	int32_t ret;
+
+	if (handle == NULL)
+		return -EINVAL;
+
+	cfg.port_id = qm_port_id;
+	cfg.qid = qm_qid;
+
+	ret = dlb2_iface_unmap_qid(handle, &cfg);
+	if (ret < 0)
+		DLB2_LOG_ERR("dlb2: unmap qid error, ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+
+	return ret;
+}
+
+static int
+dlb2_event_queue_detach_ldb(struct dlb2_eventdev *dlb2,
+			    struct dlb2_eventdev_port *ev_port,
+			    struct dlb2_eventdev_queue *ev_queue)
+{
+	int ret, i;
+
+	/* Don't unlink until start time. */
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED)
+		return 0;
+
+	for (i = 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) {
+		if (ev_port->link[i].valid &&
+		    ev_port->link[i].queue_id == ev_queue->id)
+			break; /* found */
+	}
+
+	/* This is expected with eventdev API!
+	 * It blindly attemmpts to unmap all queues.
+	 */
+	if (i == DLB2_MAX_NUM_QIDS_PER_LDB_CQ) {
+		DLB2_LOG_DBG("dlb2: ignoring LB QID %d not mapped for qm_port %d.\n",
+			     ev_queue->qm_queue.id,
+			     ev_port->qm_port.id);
+		return 0;
+	}
+
+	ret = dlb2_hw_unmap_ldb_qid_from_port(&dlb2->qm_instance,
+					      ev_port->qm_port.id,
+					      ev_queue->qm_queue.id);
+	if (!ret)
+		ev_port->link[i].mapped = false;
+
+	return ret;
+}
+
+static int
+dlb2_eventdev_port_unlink(struct rte_eventdev *dev, void *event_port,
+			  uint8_t queues[], uint16_t nb_unlinks)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	int i;
+
+	RTE_SET_USED(dev);
+
+	if (!ev_port->setup_done) {
+		DLB2_LOG_ERR("dlb2: evport %d is not configured\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (queues == NULL || nb_unlinks == 0) {
+		DLB2_LOG_DBG("dlb2: queues is NULL or nb_unlinks is 0\n");
+		return 0; /* Ignore and return success */
+	}
+
+	/* FIXME: How to handle unlink on a directed port? */
+	if (ev_port->qm_port.is_directed) {
+		DLB2_LOG_DBG("dlb2: ignore unlink from dir port %d\n",
+			     ev_port->id);
+		rte_errno = 0;
+		return nb_unlinks; /* as if success */
+	}
+
+	dlb2 = ev_port->dlb2;
+
+	for (i = 0; i < nb_unlinks; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+		int ret, j;
+
+		if (queues[i] >= dlb2->num_queues) {
+			DLB2_LOG_ERR("dlb2: invalid queue id %d\n", queues[i]);
+			rte_errno = -EINVAL;
+			return i; /* return index of offending queue */
+		}
+
+		ev_queue = &dlb2->ev_queues[queues[i]];
+
+		/* Does a link exist? */
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++)
+			if (ev_port->link[j].queue_id == queues[i] &&
+			    ev_port->link[j].valid)
+				break;
+
+		if (j == DLB2_MAX_NUM_QIDS_PER_LDB_CQ)
+			continue;
+
+		ret = dlb2_event_queue_detach_ldb(dlb2, ev_port, ev_queue);
+		if (ret) {
+			DLB2_LOG_ERR("unlink err=%d for port %d queue %d\n",
+				     ret, ev_port->id, queues[i]);
+			rte_errno = -ENOENT;
+			return i; /* return index of offending queue */
+		}
+
+		ev_port->link[j].valid = false;
+		ev_port->num_links--;
+		ev_queue->num_links--;
+	}
+
+	return nb_unlinks;
+}
+
+static int
+dlb2_eventdev_port_unlinks_in_progress(struct rte_eventdev *dev,
+				       void *event_port)
+{
+	struct dlb2_eventdev_port *ev_port = event_port;
+	struct dlb2_eventdev *dlb2;
+	struct dlb2_hw_dev *handle;
+	struct dlb2_pending_port_unmaps_args cfg;
+	int ret;
+
+	RTE_SET_USED(dev);
+
+	if (!ev_port->setup_done) {
+		DLB2_LOG_ERR("dlb2: evport %d is not configured\n",
+			     ev_port->id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	cfg.port_id = ev_port->qm_port.id;
+	dlb2 = ev_port->dlb2;
+	handle = &dlb2->qm_instance;
+	ret = dlb2_iface_pending_port_unmaps(handle, &cfg);
+
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: num_unlinks_in_progress ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1809,6 +1969,9 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
 		.port_link        = dlb2_eventdev_port_link,
+		.port_unlink      = dlb2_eventdev_port_unlink,
+		.port_unlinks_in_progress =
+				    dlb2_eventdev_port_unlinks_in_progress,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
drivers/event/dlb2/dlb2_iface.c +6 -0
index 7d1ba73..bd241f3 100644
@@ -57,3 +57,9 @@ int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
 			  struct dlb2_map_qid_args *cfg);
+
+int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
+			    struct dlb2_unmap_qid_args *cfg);
+
+int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
+				struct dlb2_pending_port_unmaps_args *args);
drivers/event/dlb2/dlb2_iface.h +6 -0
index 4eddd14..e892036 100644
@@ -56,4 +56,10 @@ extern int (*dlb2_iface_dir_queue_create)(struct dlb2_hw_dev *handle,
 
 extern int (*dlb2_iface_map_qid)(struct dlb2_hw_dev *handle,
 				 struct dlb2_map_qid_args *cfg);
+
+extern int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
+				   struct dlb2_unmap_qid_args *cfg);
+
+extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
+				struct dlb2_pending_port_unmaps_args *args);
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +283 -0

286 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_pf.c +51 -0

63 lines not on this page · raw message

Signature · 1 line
2.6.4
#203 lore raw

PATCH v11 16/23 event/dlb2: add eventdev start

In reply to Timothy McDaniel

Add support for the eventdev start entry point.
We delay initializing some resources until
eventdev start, since the number of linked queues can be used to determine if we are dealing with a ldb or dir resource. If this is a device restart, then the previous configuration will be reapplied.

---
 drivers/event/dlb2/dlb2.c                  | 133 +++++++++++++++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c            |   3 +
 drivers/event/dlb2/dlb2_iface.h            |   3 +
 drivers/event/dlb2/pf/base/dlb2_resource.c | 123 ++++++++++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c          |  10 +++
 drivers/event/dlb2/pf/dlb2_pf.c            |  25 ++++++
 6 files changed, 297 insertions(+)
drivers/event/dlb2/dlb2.c +133 -0
index 9357b23..fa6fa7b 100644
@@ -1957,6 +1957,138 @@ dlb2_eventdev_port_unlinks_in_progress(struct rte_eventdev *dev,
 	return cfg.response.id;
 }
 
+static int
+dlb2_eventdev_reapply_configuration(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int ret, i;
+
+	/* If an event queue or port was previously configured, but hasn't been
+	 * reconfigured, reapply its original configuration.
+	 */
+	for (i = 0; i < dlb2->num_queues; i++) {
+		struct dlb2_eventdev_queue *ev_queue;
+
+		ev_queue = &dlb2->ev_queues[i];
+
+		if (ev_queue->qm_queue.config_state != DLB2_PREV_CONFIGURED)
+			continue;
+
+		ret = dlb2_eventdev_queue_setup(dev, i, &ev_queue->conf);
+		if (ret < 0) {
+			DLB2_LOG_ERR("dlb2: failed to reconfigure queue %d", i);
+			return ret;
+		}
+	}
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		struct dlb2_eventdev_port *ev_port = &dlb2->ev_ports[i];
+
+		if (ev_port->qm_port.config_state != DLB2_PREV_CONFIGURED)
+			continue;
+
+		ret = dlb2_eventdev_port_setup(dev, i, &ev_port->conf);
+		if (ret < 0) {
+			DLB2_LOG_ERR("dlb2: failed to reconfigure ev_port %d",
+				     i);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_apply_port_links(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	int i;
+
+	/* Perform requested port->queue links */
+	for (i = 0; i < dlb2->num_ports; i++) {
+		struct dlb2_eventdev_port *ev_port = &dlb2->ev_ports[i];
+		int j;
+
+		for (j = 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++) {
+			struct dlb2_eventdev_queue *ev_queue;
+			uint8_t prio, queue_id;
+
+			if (!ev_port->link[j].valid)
+				continue;
+
+			prio = ev_port->link[j].priority;
+			queue_id = ev_port->link[j].queue_id;
+
+			if (dlb2_validate_port_link(ev_port, queue_id, true, j))
+				return -EINVAL;
+
+			ev_queue = &dlb2->ev_queues[queue_id];
+
+			if (dlb2_do_port_link(dev, ev_queue, ev_port, prio))
+				return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+static int
+dlb2_eventdev_start(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_start_domain_args cfg;
+	int ret, i;
+
+	rte_spinlock_lock(&dlb2->qm_instance.resource_lock);
+	if (dlb2->run_state != DLB2_RUN_STATE_STOPPED) {
+		DLB2_LOG_ERR("bad state %d for dev_start\n",
+			     (int)dlb2->run_state);
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return -EINVAL;
+	}
+	dlb2->run_state = DLB2_RUN_STATE_STARTING;
+	rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+
+	/* If the device was configured more than once, some event ports and/or
+	 * queues may need to be reconfigured.
+	 */
+	ret = dlb2_eventdev_reapply_configuration(dev);
+	if (ret)
+		return ret;
+
+	/* The DLB PMD delays port links until the device is started. */
+	ret = dlb2_eventdev_apply_port_links(dev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < dlb2->num_ports; i++) {
+		if (!dlb2->ev_ports[i].setup_done) {
+			DLB2_LOG_ERR("dlb2: port %d not setup", i);
+			return -ESTALE;
+		}
+	}
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (dlb2->ev_queues[i].num_links == 0) {
+			DLB2_LOG_ERR("dlb2: queue %d is not linked", i);
+			return -ENOLINK;
+		}
+	}
+
+	ret = dlb2_iface_sched_domain_start(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: sched_domain_start ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	dlb2->run_state = DLB2_RUN_STATE_STARTED;
+	DLB2_LOG_DBG("dlb2: sched_domain_start completed OK\n");
+
+	return 0;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -1964,6 +2096,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 	static struct rte_eventdev_ops dlb2_eventdev_entry_ops = {
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
+		.dev_start        = dlb2_eventdev_start,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
drivers/event/dlb2/dlb2_iface.c +3 -0
index bd241f3..a86191d 100644
@@ -63,3 +63,6 @@ int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 				struct dlb2_pending_port_unmaps_args *args);
+
+int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
+				     struct dlb2_start_domain_args *cfg);
drivers/event/dlb2/dlb2_iface.h +3 -0
index e892036..7ead374 100644
@@ -62,4 +62,7 @@ extern int (*dlb2_iface_unmap_qid)(struct dlb2_hw_dev *handle,
 
 extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 				struct dlb2_pending_port_unmaps_args *args);
+
+extern int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
+				struct dlb2_start_domain_args *cfg);
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +123 -0

126 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c +10 -0
index d91d186..06b6aee 100644
@@ -661,3 +661,13 @@ dlb2_pf_create_dir_queue(struct dlb2_hw *hw,
 	return dlb2_hw_create_dir_queue(hw, id, args, resp, NOT_VF_REQ,
 					PF_ID_ZERO);
 }
+
+int
+dlb2_pf_start_domain(struct dlb2_hw *hw,
+		     u32 id,
+		     struct dlb2_start_domain_args *args,
+		     struct dlb2_cmd_response *resp)
+{
+	return dlb2_hw_start_domain(hw, id, args, resp, NOT_VF_REQ,
+				    PF_ID_ZERO);
+}
drivers/event/dlb2/pf/dlb2_pf.c +25 -0
index 33ea73e..fff2e57 100644
@@ -503,6 +503,30 @@ dlb2_pf_pending_port_unmaps(struct dlb2_hw_dev *handle,
 
 	return ret;
 }
+
+static int
+dlb2_pf_sched_domain_start(struct dlb2_hw_dev *handle,
+			   struct dlb2_start_domain_args *cfg)
+{
+	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
+	struct dlb2_cmd_response response = {0};
+	int ret;
+
+	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);
+
+	ret = dlb2_pf_start_domain(&dlb2_dev->hw,
+				   handle->domain_id,
+				   cfg,
+				   &response);
+
+	cfg->response = response;
+
+	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
+		  __func__, ret);
+
+	return ret;
+}
+
 static void
 dlb2_pf_iface_fn_ptrs_init(void)
 {
@@ -520,6 +544,7 @@ dlb2_pf_iface_fn_ptrs_init(void)
 	dlb2_iface_dir_port_create = dlb2_pf_dir_port_create;
 	dlb2_iface_map_qid = dlb2_pf_map_qid;
 	dlb2_iface_unmap_qid = dlb2_pf_unmap_qid;
+	dlb2_iface_sched_domain_start = dlb2_pf_sched_domain_start;
 	dlb2_iface_pending_port_unmaps = dlb2_pf_pending_port_unmaps;
 	dlb2_iface_get_sn_allocation = dlb2_pf_get_sn_allocation;
 	dlb2_iface_set_sn_allocation = dlb2_pf_set_sn_allocation;
Signature · 1 line
2.6.4
#204 lore raw

PATCH v11 17/23 event/dlb2: add enqueue and its burst variants

In reply to Timothy McDaniel

Add support for enqueue and its variants.

---
 doc/guides/eventdevs/dlb2.rst | 118 +++++++++
 drivers/event/dlb2/dlb2.c     | 540 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 658 insertions(+)
doc/guides/eventdevs/dlb2.rst +118 -0
index bbd6ac8..aa8bf01 100644
@@ -163,6 +163,124 @@ Flow ID
 The flow ID field is preserved in the event when it is scheduled in the
 DLB2.
 
+Hardware Credits
+~~~~~~~~~~~~~~~~
+
+DLB2 uses a hardware credit scheme to prevent software from overflowing hardware
+event storage, with each unit of storage represented by a credit. A port spends
+a credit to enqueue an event, and hardware refills the ports with credits as the
+events are scheduled to ports. Refills come from credit pools, and each port is
+a member of a load-balanced credit pool and a directed credit pool. The
+load-balanced credits are used to enqueue to load-balanced queues, and directed
+credits are used for directed queues.
+
+A DLB2 eventdev contains one load-balanced and one directed credit pool. These
+pools' sizes are controlled by the nb_events_limit field in struct
+rte_event_dev_config. The load-balanced pool is sized to contain
+nb_events_limit credits, and the directed pool is sized to contain
+nb_events_limit/4 credits. The directed pool size can be overridden with the
+num_dir_credits vdev argument, like so:
+
+    .. code-block:: console
+
+       --vdev=dlb1_event,num_dir_credits=<value>
+
+This can be used if the default allocation is too low or too high for the
+specific application needs. The PMD also supports a vdev arg that limits the
+max_num_events reported by rte_event_dev_info_get():
+
+    .. code-block:: console
+
+       --vdev=dlb1_event,max_num_events=<value>
+
+By default, max_num_events is reported as the total available load-balanced
+credits. If multiple DLB2-based applications are being used, it may be desirable
+to control how many load-balanced credits each application uses, particularly
+when application(s) are written to configure nb_events_limit equal to the
+reported max_num_events.
+
+Each port is a member of both credit pools. A port's credit allocation is
+defined by its low watermark, high watermark, and refill quanta. These three
+parameters are calculated by the dlb PMD like so:
+
+- The load-balanced high watermark is set to the port's enqueue_depth.
+  The directed high watermark is set to the minimum of the enqueue_depth and
+  the directed pool size divided by the total number of ports.
+- The refill quanta is set to half the high watermark.
+- The low watermark is set to the minimum of 16 and the refill quanta.
+
+When the eventdev is started, each port is pre-allocated a high watermark's
+worth of credits. For example, if an eventdev contains four ports with enqueue
+depths of 32 and a load-balanced credit pool size of 4096, each port will start
+with 32 load-balanced credits, and there will be 3968 credits available to
+replenish the ports. Thus, a single port is not capable of enqueueing up to the
+nb_events_limit (without any events being dequeued), since the other ports are
+retaining their initial credit allocation; in short, all ports must enqueue in
+order to reach the limit.
+
+If a port attempts to enqueue and has no credits available, the enqueue
+operation will fail and the application must retry the enqueue. Credits are
+replenished asynchronously by the DLB2 hardware.
+
+Software Credits
+~~~~~~~~~~~~~~~~
+
+The DLB2 is a "closed system" event dev, and the DLB2 PMD layers a software
+credit scheme on top of the hardware credit scheme in order to comply with
+the per-port backpressure described in the eventdev API.
+
+The DLB2's hardware scheme is local to a queue/pipeline stage: a port spends a
+credit when it enqueues to a queue, and credits are later replenished after the
+events are dequeued and released.
+
+In the software credit scheme, a credit is consumed when a new (.op =
+RTE_EVENT_OP_NEW) event is injected into the system, and the credit is
+replenished when the event is released from the system (either explicitly with
+RTE_EVENT_OP_RELEASE or implicitly in dequeue_burst()).
+
+In this model, an event is "in the system" from its first enqueue into eventdev
+until it is last dequeued. If the event goes through multiple event queues, it
+is still considered "in the system" while a worker thread is processing it.
+
+A port will fail to enqueue if the number of events in the system exceeds its
+``new_event_threshold`` (specified at port setup time). A port will also fail
+to enqueue if it lacks enough hardware credits to enqueue; load-balanced
+credits are used to enqueue to a load-balanced queue, and directed credits are
+used to enqueue to a directed queue.
+
+The out-of-credit situations are typically transient, and an eventdev
+application using the DLB2 ought to retry its enqueues if they fail.
+If enqueue fails, DLB2 PMD sets rte_errno as follows:
+
+- -ENOSPC: Credit exhaustion (either hardware or software)
+- -EINVAL: Invalid argument, such as port ID, queue ID, or sched_type.
+
+Depending on the pipeline the application has constructed, it's possible to
+enter a credit deadlock scenario wherein the worker thread lacks the credit
+to enqueue an event, and it must dequeue an event before it can recover the
+credit. If the worker thread retries its enqueue indefinitely, it will not
+make forward progress. Such deadlock is possible if the application has event
+"loops", in which an event in dequeued from queue A and later enqueued back to
+queue A.
+
+Due to this, workers should stop retrying after a time, release the events it
+is attempting to enqueue, and dequeue more events. It is important that the
+worker release the events and don't simply set them aside to retry the enqueue
+again later, because the port has limited history list size (by default, twice
+the port's dequeue_depth).
+
+Priority
+~~~~~~~~
+
+The DLB2 supports event priority and per-port queue service priority, as
+described in the eventdev header file. The DLB2 does not support 'global' event
+queue priority established at queue creation time.
+
+DLB2 supports 8 event and queue service priority levels. For both priority
+types, the PMD uses the upper three bits of the priority field to determine the
+DLB2 priority, discarding the 5 least significant bits. The 5 least significant
+event priority bits are not preserved when an event is enqueued.
+
 Reconfiguration
 ~~~~~~~~~~~~~~~
 
drivers/event/dlb2/dlb2.c +540 -0

553 lines not on this page · raw message

Signature · 1 line
2.6.4
#205 lore raw

PATCH v11 18/23 event/dlb2: add dequeue and its burst variants

In reply to Timothy McDaniel

Add support for dequeue, dequeue_burst, ...

DLB2 does not currently support interrupts, but instead use umonitor/umwait if supported by the processor. This allows the software to monitor and wait on writes to a cache-line.

DLB2 supports normal and sparse cq mode. In normal mode the hardware will pack 4 QEs into each cache line. In sparse cq mode, the hardware will only populate one QE per cache line. Software must be aware of the cq mode, and take the appropriate actions, based on the mode.

---
 doc/guides/eventdevs/dlb2.rst |  21 ++
 drivers/event/dlb2/dlb2.c     | 783 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 804 insertions(+)
doc/guides/eventdevs/dlb2.rst +21 -0
index aa8bf01..b9f57fd 100644
@@ -314,6 +314,27 @@ The PMD does not support the following configuration sequences:
 This sequence is not supported because the event device must be reconfigured
 before its ports or queues can be.
 
+Deferred Scheduling
+~~~~~~~~~~~~~~~~~~~
+
+The DLB2 PMD's default behavior for managing a CQ is to "pop" the CQ once per
+dequeued event before returning from rte_event_dequeue_burst(). This frees the
+corresponding entries in the CQ, which enables the DLB2 to schedule more events
+to it.
+
+To support applications seeking finer-grained scheduling control -- for example
+deferring scheduling to get the best possible priority scheduling and
+load-balancing -- the PMD supports a deferred scheduling mode. In this mode,
+the CQ entry is not popped until the *subsequent* rte_event_dequeue_burst()
+call. This mode only applies to load-balanced event ports with dequeue depth of
+1.
+
+To enable deferred scheduling, use the defer_sched vdev argument like so:
+
+    .. code-block:: console
+
+       --vdev=dlb1_event,defer_sched=on
+
 Atomic Inflights Allocation
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
drivers/event/dlb2/dlb2.c +783 -0

810 lines not on this page · raw message

Signature · 1 line
2.6.4
#206 lore raw

PATCH v11 19/23 event/dlb2: add eventdev stop and close

In reply to Timothy McDaniel

Add support for eventdev stop and close entry points.

---
 drivers/event/dlb2/dlb2.c                  | 257 +++++++++++++++++++++++++++--
 drivers/event/dlb2/dlb2_iface.c            |   6 +
 drivers/event/dlb2/dlb2_iface.h            |   6 +
 drivers/event/dlb2/pf/base/dlb2_resource.c |  91 ++++++++++
 drivers/event/dlb2/pf/dlb2_pf.c            |  52 ++++++
 5 files changed, 396 insertions(+), 16 deletions(-)
drivers/event/dlb2/dlb2.c +241 -16
index 631fe52..4b8f45f 100644
@@ -71,21 +71,6 @@ static struct rte_event_dev_info evdev_dlb2_default_info = {
 struct process_local_port_data
 dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
 
-/*
- * DUMMY - added so that xstats path will compile/link.
- * Will be replaced by real version in a subsequent
- * patch.
- */
-uint32_t
-dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
-		     struct dlb2_eventdev_queue *queue)
-{
-	RTE_SET_USED(dlb2);
-	RTE_SET_USED(queue);
-
-	return 0;
-}
-
 static void
 dlb2_free_qe_mem(struct dlb2_port *qm_port)
 {
@@ -1878,7 +1863,6 @@ dlb2_eventdev_port_unlink(struct rte_eventdev *dev, void *event_port,
 		return 0; /* Ignore and return success */
 	}
 
-	/* FIXME: How to handle unlink on a directed port? */
 	if (ev_port->qm_port.is_directed) {
 		DLB2_LOG_DBG("dlb2: ignore unlink from dir port %d\n",
 			     ev_port->id);
@@ -3396,6 +3380,245 @@ dlb2_event_dequeue_sparse(void *event_port, struct rte_event *ev,
 }
 
 static void
+dlb2_flush_port(struct rte_eventdev *dev, int port_id)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	eventdev_stop_flush_t flush;
+	struct rte_event ev;
+	uint8_t dev_id;
+	void *arg;
+	int i;
+
+	flush = dev->dev_ops->dev_stop_flush;
+	dev_id = dev->data->dev_id;
+	arg = dev->data->dev_stop_flush_arg;
+
+	while (rte_event_dequeue_burst(dev_id, port_id, &ev, 1, 0)) {
+		if (flush)
+			flush(dev_id, ev, arg);
+
+		if (dlb2->ev_ports[port_id].qm_port.is_directed)
+			continue;
+
+		ev.op = RTE_EVENT_OP_RELEASE;
+
+		rte_event_enqueue_burst(dev_id, port_id, &ev, 1);
+	}
+
+	/* Enqueue any additional outstanding releases */
+	ev.op = RTE_EVENT_OP_RELEASE;
+
+	for (i = dlb2->ev_ports[port_id].outstanding_releases; i > 0; i--)
+		rte_event_enqueue_burst(dev_id, port_id, &ev, 1);
+}
+
+static uint32_t
+dlb2_get_ldb_queue_depth(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *queue)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_ldb_queue_depth_args cfg;
+	int ret;
+
+	cfg.queue_id = queue->qm_queue.id;
+
+	ret = dlb2_iface_get_ldb_queue_depth(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_ldb_queue_depth ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+static uint32_t
+dlb2_get_dir_queue_depth(struct dlb2_eventdev *dlb2,
+			 struct dlb2_eventdev_queue *queue)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_get_dir_queue_depth_args cfg;
+	int ret;
+
+	cfg.queue_id = queue->qm_queue.id;
+
+	ret = dlb2_iface_get_dir_queue_depth(handle, &cfg);
+	if (ret < 0) {
+		DLB2_LOG_ERR("dlb2: get_dir_queue_depth ret=%d (driver status: %s)\n",
+			     ret, dlb2_error_strings[cfg.response.status]);
+		return ret;
+	}
+
+	return cfg.response.id;
+}
+
+uint32_t
+dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+		     struct dlb2_eventdev_queue *queue)
+{
+	if (queue->qm_queue.is_directed)
+		return dlb2_get_dir_queue_depth(dlb2, queue);
+	else
+		return dlb2_get_ldb_queue_depth(dlb2, queue);
+}
+
+static bool
+dlb2_queue_is_empty(struct dlb2_eventdev *dlb2,
+		    struct dlb2_eventdev_queue *queue)
+{
+	return dlb2_get_queue_depth(dlb2, queue) == 0;
+}
+
+static bool
+dlb2_linked_queues_empty(struct dlb2_eventdev *dlb2)
+{
+	int i;
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (dlb2->ev_queues[i].num_links == 0)
+			continue;
+		if (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			return false;
+	}
+
+	return true;
+}
+
+static bool
+dlb2_queues_empty(struct dlb2_eventdev *dlb2)
+{
+	int i;
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		if (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			return false;
+	}
+
+	return true;
+}
+
+static void
+dlb2_drain(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+	struct dlb2_eventdev_port *ev_port = NULL;
+	uint8_t dev_id;
+	int i;
+
+	dev_id = dev->data->dev_id;
+
+	while (!dlb2_linked_queues_empty(dlb2)) {
+		/* Flush all the ev_ports, which will drain all their connected
+		 * queues.
+		 */
+		for (i = 0; i < dlb2->num_ports; i++)
+			dlb2_flush_port(dev, i);
+	}
+
+	/* The queues are empty, but there may be events left in the ports. */
+	for (i = 0; i < dlb2->num_ports; i++)
+		dlb2_flush_port(dev, i);
+
+	/* If the domain's queues are empty, we're done. */
+	if (dlb2_queues_empty(dlb2))
+		return;
+
+	/* Else, there must be at least one unlinked load-balanced queue.
+	 * Select a load-balanced port with which to drain the unlinked
+	 * queue(s).
+	 */
+	for (i = 0; i < dlb2->num_ports; i++) {
+		ev_port = &dlb2->ev_ports[i];
+
+		if (!ev_port->qm_port.is_directed)
+			break;
+	}
+
+	if (i == dlb2->num_ports) {
+		DLB2_LOG_ERR("internal error: no LDB ev_ports\n");
+		return;
+	}
+
+	rte_errno = 0;
+	rte_event_port_unlink(dev_id, ev_port->id, NULL, 0);
+
+	if (rte_errno) {
+		DLB2_LOG_ERR("internal error: failed to unlink ev_port %d\n",
+			     ev_port->id);
+		return;
+	}
+
+	for (i = 0; i < dlb2->num_queues; i++) {
+		uint8_t qid, prio;
+		int ret;
+
+		if (dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			continue;
+
+		qid = i;
+		prio = 0;
+
+		/* Link the ev_port to the queue */
+		ret = rte_event_port_link(dev_id, ev_port->id, &qid, &prio, 1);
+		if (ret != 1) {
+			DLB2_LOG_ERR("internal error: failed to link ev_port %d to queue %d\n",
+				     ev_port->id, qid);
+			return;
+		}
+
+		/* Flush the queue */
+		while (!dlb2_queue_is_empty(dlb2, &dlb2->ev_queues[i]))
+			dlb2_flush_port(dev, ev_port->id);
+
+		/* Drain any extant events in the ev_port. */
+		dlb2_flush_port(dev, ev_port->id);
+
+		/* Unlink the ev_port from the queue */
+		ret = rte_event_port_unlink(dev_id, ev_port->id, &qid, 1);
+		if (ret != 1) {
+			DLB2_LOG_ERR("internal error: failed to unlink ev_port %d to queue %d\n",
+				     ev_port->id, qid);
+			return;
+		}
+	}
+}
+
+static void
+dlb2_eventdev_stop(struct rte_eventdev *dev)
+{
+	struct dlb2_eventdev *dlb2 = dlb2_pmd_priv(dev);
+
+	rte_spinlock_lock(&dlb2->qm_instance.resource_lock);
+
+	if (dlb2->run_state == DLB2_RUN_STATE_STOPPED) {
+		DLB2_LOG_DBG("Internal error: already stopped\n");
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return;
+	} else if (dlb2->run_state != DLB2_RUN_STATE_STARTED) {
+		DLB2_LOG_ERR("Internal error: bad state %d for dev_stop\n",
+			     (int)dlb2->run_state);
+		rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+		return;
+	}
+
+	dlb2->run_state = DLB2_RUN_STATE_STOPPING;
+
+	rte_spinlock_unlock(&dlb2->qm_instance.resource_lock);
+
+	dlb2_drain(dev);
+
+	dlb2->run_state = DLB2_RUN_STATE_STOPPED;
+}
+
+static int
+dlb2_eventdev_close(struct rte_eventdev *dev)
+{
+	dlb2_hw_reset_sched_domain(dev, false);
+
+	return 0;
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	struct dlb2_eventdev *dlb2;
@@ -3405,6 +3628,8 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.dev_infos_get    = dlb2_eventdev_info_get,
 		.dev_configure    = dlb2_eventdev_configure,
 		.dev_start        = dlb2_eventdev_start,
+		.dev_stop         = dlb2_eventdev_stop,
+		.dev_close        = dlb2_eventdev_close,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
drivers/event/dlb2/dlb2_iface.c +6 -0
index a86191d..5471dd8 100644
@@ -66,3 +66,9 @@ int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 
 int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
 				     struct dlb2_start_domain_args *cfg);
+
+int (*dlb2_iface_get_ldb_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_ldb_queue_depth_args *args);
+
+int (*dlb2_iface_get_dir_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_dir_queue_depth_args *args);
drivers/event/dlb2/dlb2_iface.h +6 -0
index 7ead374..b508eb0 100644
@@ -65,4 +65,10 @@ extern int (*dlb2_iface_pending_port_unmaps)(struct dlb2_hw_dev *handle,
 
 extern int (*dlb2_iface_sched_domain_start)(struct dlb2_hw_dev *handle,
 				struct dlb2_start_domain_args *cfg);
+
+extern int (*dlb2_iface_get_ldb_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_ldb_queue_depth_args *args);
+
+extern int (*dlb2_iface_get_dir_queue_depth)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_dir_queue_depth_args *args);
 #endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/pf/base/dlb2_resource.c +91 -0

94 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_pf.c +52 -0

64 lines not on this page · raw message

Signature · 1 line
2.6.4
#207 lore raw

PATCH v11 20/23 event/dlb2: add PMD's token pop public interface

In reply to Timothy McDaniel

The PMD uses a public interface to allow applications to control the token pop mode. Supported token pop modes are as follows, and they impact core scheduling affinity for ldb ports.

AUTO_POP: Pop the CQ tokens immediately after dequeueing.
DELAYED_POP: Pop CQ tokens after (dequeue_depth - 1) events
are released. Supported on load-balanced ports only.
DEFERRED_POP: Pop the CQ tokens during next dequeue operation.

---
 doc/api/doxy-api-index.md         |  3 +-
 doc/api/doxy-api.conf.in          |  1 +
 drivers/event/dlb2/dlb2.c         | 65 +++++++++++++++++++++++++++++++----
 drivers/event/dlb2/dlb2_priv.h    |  3 ++
 drivers/event/dlb2/meson.build    |  6 ++--
 drivers/event/dlb2/rte_pmd_dlb2.c | 39 +++++++++++++++++++++
 drivers/event/dlb2/rte_pmd_dlb2.h | 72 +++++++++++++++++++++++++++++++++++++++
 drivers/event/dlb2/version.map    |  6 ++++
 8 files changed, 186 insertions(+), 9 deletions(-)
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
doc/api/doxy-api-index.md +2 -1
index b865a51..e1836dc 100644
@@ -52,7 +52,8 @@ The public API headers are grouped by topics:
   [dpaa2_mempool]      (@ref rte_dpaa2_mempool.h),
   [dpaa2_cmdif]        (@ref rte_pmd_dpaa2_cmdif.h),
   [dpaa2_qdma]         (@ref rte_pmd_dpaa2_qdma.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [dlb2]               (@ref rte_pmd_dlb2.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf.in +1 -0
index c5b01a1..535321f 100644
@@ -7,6 +7,7 @@ USE_MDFILE_AS_MAINPAGE  = @TOPDIR@/doc/api/doxy-api-index.md
 INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
                           @TOPDIR@/drivers/bus/vdev \
                           @TOPDIR@/drivers/crypto/scheduler \
+                          @TOPDIR@/drivers/event/dlb2 \
                           @TOPDIR@/drivers/mempool/dpaa2 \
                           @TOPDIR@/drivers/net/ark \
                           @TOPDIR@/drivers/net/bnxt \
drivers/event/dlb2/dlb2.c +59 -6

154 lines not on this page · raw message

drivers/event/dlb2/dlb2_priv.h +3 -0
index 61567a6..b73cf3f 100644
@@ -12,6 +12,7 @@
 #include <rte_config.h>
 #include "dlb2_user.h"
 #include "dlb2_log.h"
+#include "rte_pmd_dlb2.h"
 
 #ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
 #define DLB2_INC_STAT(_stat, _incr_val) ((_stat) += _incr_val)
@@ -290,6 +291,7 @@ struct dlb2_port {
 	bool gen_bit;
 	uint16_t dir_credits;
 	uint32_t dequeue_depth;
+	enum dlb2_token_pop_mode token_pop_mode;
 	union dlb2_port_config cfg;
 	uint32_t *credit_pool[DLB2_NUM_QUEUE_TYPES]; /* use __atomic builtins */
 	uint16_t cached_ldb_credits;
@@ -298,6 +300,7 @@ struct dlb2_port {
 	bool int_armed;
 	uint16_t owed_tokens;
 	int16_t issued_releases;
+	int16_t token_pop_thresh;
 	int cq_depth;
 	uint16_t cq_idx;
 	uint16_t cq_idx_unmasked;
drivers/event/dlb2/meson.build +4 -2
index a80d7ab..2af72e2 100644
@@ -1,3 +1,4 @@
+
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
@@ -12,9 +13,10 @@ sources = files('dlb2.c',
 		'dlb2_xstats.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
-		'pf/base/dlb2_resource.c'
+		'pf/base/dlb2_resource.c',
+		'rte_pmd_dlb2.c'
 )
 
-headers = files()
+headers = files('rte_pmd_dlb2.h')
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
drivers/event/dlb2/rte_pmd_dlb2.c new file +39 -0
new file mode 100644
index 0000000..b09b585
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+
+#include "rte_pmd_dlb2.h"
+#include "dlb2_priv.h"
+#include "dlb2_inline_fns.h"
+
+int
+rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,
+				uint8_t port_id,
+				enum dlb2_token_pop_mode mode)
+{
+	struct dlb2_eventdev *dlb2;
+	struct rte_eventdev *dev;
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dlb2 = dlb2_pmd_priv(dev);
+
+	if (mode >= NUM_TOKEN_POP_MODES)
+		return -EINVAL;
+
+	/* The event device must be configured, but not yet started */
+	if (!dlb2->configured || dlb2->run_state != DLB2_RUN_STATE_STOPPED)
+		return -EINVAL;
+
+	/* The token pop mode must be set before configuring the port */
+	if (port_id >= dlb2->num_ports || dlb2->ev_ports[port_id].setup_done)
+		return -EINVAL;
+
+	dlb2->ev_ports[port_id].qm_port.token_pop_mode = mode;
+
+	return 0;
+}
drivers/event/dlb2/rte_pmd_dlb2.h new file +72 -0

72 lines not on this page · raw message

drivers/event/dlb2/version.map +6 -0
index 4a76d1d..b1e4dff 100644
@@ -1,3 +1,9 @@
 DPDK_21 {
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dlb2_set_token_pop_mode;
+};
Signature · 1 line
2.6.4
#208 lore raw

PATCH v11 21/23 event/dlb2: add PMD self-tests

In reply to Timothy McDaniel

Add a variety of self-tests for both ldb and directed ports/queues, as well as configure, start, stop, link, etc...

---
 app/test/test_eventdev.c           |    7 +
 drivers/event/dlb2/dlb2.c          |    1 +
 drivers/event/dlb2/dlb2_selftest.c | 1524 ++++++++++++++++++++++++++++++++++++
 drivers/event/dlb2/meson.build     |    3 +-
 4 files changed, 1534 insertions(+), 1 deletion(-)
 create mode 100644 drivers/event/dlb2/dlb2_selftest.c
app/test/test_eventdev.c +7 -0
index 62019c1..bcfaa53 100644
@@ -1030,6 +1030,12 @@ test_eventdev_selftest_dpaa2(void)
 	return test_eventdev_selftest_impl("event_dpaa2", "");
 }
 
+static int
+test_eventdev_selftest_dlb2(void)
+{
+	return test_eventdev_selftest_impl("dlb2_event", "");
+}
+
 REGISTER_TEST_COMMAND(eventdev_common_autotest, test_eventdev_common);
 REGISTER_TEST_COMMAND(eventdev_selftest_sw, test_eventdev_selftest_sw);
 REGISTER_TEST_COMMAND(eventdev_selftest_octeontx,
@@ -1037,3 +1043,4 @@ REGISTER_TEST_COMMAND(eventdev_selftest_octeontx,
 REGISTER_TEST_COMMAND(eventdev_selftest_octeontx2,
 		test_eventdev_selftest_octeontx2);
 REGISTER_TEST_COMMAND(eventdev_selftest_dpaa2, test_eventdev_selftest_dpaa2);
+REGISTER_TEST_COMMAND(eventdev_selftest_dlb2, test_eventdev_selftest_dlb2);
drivers/event/dlb2/dlb2.c +1 -0
index e8b4446..86299dd 100644
@@ -3692,6 +3692,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
 		.xstats_get_by_name = dlb2_eventdev_xstats_get_by_name,
 		.xstats_reset	    = dlb2_eventdev_xstats_reset,
+		.dev_selftest     = test_dlb2_eventdev,
 	};
 
 	/* Expose PMD's eventdev interface */
drivers/event/dlb2/dlb2_selftest.c new file +1524 -0

1,524 lines not on this page · raw message

drivers/event/dlb2/meson.build +2 -1
index 2af72e2..bcda3dd 100644
@@ -14,7 +14,8 @@ sources = files('dlb2.c',
 		'pf/dlb2_main.c',
 		'pf/dlb2_pf.c',
 		'pf/base/dlb2_resource.c',
-		'rte_pmd_dlb2.c'
+		'rte_pmd_dlb2.c',
+		'dlb2_selftest.c'
 )
 
 headers = files('rte_pmd_dlb2.h')
Signature · 1 line
2.6.4
#209 lore raw

PATCH v11 22/23 event/dlb2: add queue and port release

In reply to Timothy McDaniel

DLB does not support reconfiguring individual queues or ports on the fly. The entire device must be reconfigured. Previously allocated port QE and memzone memory
is freed in this patch.

---
 drivers/event/dlb2/dlb2.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/event/dlb2/dlb2.c +24 -0
index 86299dd..248296d 100644
@@ -3668,6 +3668,28 @@ dlb2_eventdev_close(struct rte_eventdev *dev)
 }
 
 static void
+dlb2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t id)
+{
+	RTE_SET_USED(dev);
+	RTE_SET_USED(id);
+
+	/* This function intentionally left blank. */
+}
+
+static void
+dlb2_eventdev_port_release(void *port)
+{
+	struct dlb2_eventdev_port *ev_port = port;
+	struct dlb2_port *qm_port;
+
+	if (ev_port) {
+		qm_port = &ev_port->qm_port;
+		if (qm_port->config_state == DLB2_CONFIGURED)
+			dlb2_free_qe_mem(qm_port);
+	}
+}
+
+static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
 	struct dlb2_eventdev *dlb2;
@@ -3681,8 +3703,10 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.dev_close        = dlb2_eventdev_close,
 		.queue_def_conf   = dlb2_eventdev_queue_default_conf_get,
 		.queue_setup      = dlb2_eventdev_queue_setup,
+		.queue_release    = dlb2_eventdev_queue_release,
 		.port_def_conf    = dlb2_eventdev_port_default_conf_get,
 		.port_setup       = dlb2_eventdev_port_setup,
+		.port_release     = dlb2_eventdev_port_release,
 		.port_link        = dlb2_eventdev_port_link,
 		.port_unlink      = dlb2_eventdev_port_unlink,
 		.port_unlinks_in_progress =
Signature · 1 line
2.6.4
#210 lore raw

PATCH v11 23/23 event/dlb2: add timeout ticks entry point

In reply to Timothy McDaniel

Adds the timeout ticks conversion function.

---
 drivers/event/dlb2/dlb2.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/event/dlb2/dlb2.c +13 -0
index 248296d..d42e48b 100644
@@ -3689,6 +3689,18 @@ dlb2_eventdev_port_release(void *port)
 	}
 }
 
+static int
+dlb2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
+			    uint64_t *timeout_ticks)
+{
+	RTE_SET_USED(dev);
+	uint64_t cycles_per_ns = rte_get_timer_hz() / 1E9;
+
+	*timeout_ticks = ns * cycles_per_ns;
+
+	return 0;
+}
+
 static void
 dlb2_entry_points_init(struct rte_eventdev *dev)
 {
@@ -3711,6 +3723,7 @@ dlb2_entry_points_init(struct rte_eventdev *dev)
 		.port_unlink      = dlb2_eventdev_port_unlink,
 		.port_unlinks_in_progress =
 				    dlb2_eventdev_port_unlinks_in_progress,
+		.timeout_ticks    = dlb2_eventdev_timeout_ticks,
 		.dump             = dlb2_eventdev_dump,
 		.xstats_get       = dlb2_eventdev_xstats_get,
 		.xstats_get_names = dlb2_eventdev_xstats_get_names,
Signature · 1 line
2.6.4
Reviewed-by Chen, Mike Ximing on the v11 series
#211 lore raw
In reply to Timothy McDaniel
Quoted 34 lines · Timothy McDaniel

The following patch series adds support for a new eventdev PMD. The DLB2 PMD adds support for the Intel Dynamic Load Balancer 2.0 (DLB2) hardware.
The DLB2 is a PCIe device that provides load-balanced, prioritized scheduling of core-to-core communication. The device consists of queues and arbiters that connect producer and consumer cores, and implements load-balanced queueing features including:
- Lock-free multi-producer/multi-consumer operation.
- Multiple priority levels for varying traffic types.
- 'Direct' traffic (i.e. multi-producer/single-consumer)
- Simple unordered load-balanced distribution.
- Atomic lock-free load balancing across multiple consumers.
- Queue element reordering feature allowing ordered load-balanced distribution.

The DLB2 hardware supports both load balanced and directed ports and queues. Unlike other eventdev devices already in the repo, not all DLB2 ports and queues are equally capable. In particular, directed ports are limited to a single link, and must be connected to a directed queue. Additionally, even though LDB ports may link multiple queues,
the number of queues that may be linked is limited by hardware.

While reviewing the code, please be aware that this PMD has full control over the DLB2 hardware. Intel will be extending the DLB2 PMD in the future (not as part of this first series) with a mode that we refer to as the bifurcated PMD. The bifurcated PMD communicates with a kernel driver to configure the device, ports, and queues, and memory maps device MMIO so datapath operations occur purely in user-space. Note that the DLB2 hardware is a successor of the DLB hardware, and as such is structured similarly, both in terms of code layout and implementation.

Quoted 2 lines

The framework to support both the PF PMD and bifurcated PMD exists in this patchset, and is why the iface.[ch] layer is present.

Finally, Series applied to dpdk-next-eventdev/for-main with the following fix[1]. Thanks.

Thanks, @David Marchand for your final review cycles.

[1]

[for-main]dell[dpdk-next-eventdev] $ ./devtools/check-git-log.sh -n 23
Wrong tag:

Quoted 187 lines

Changes since V10
=================
- converted printfs in dlb2/pf/dlb2_main.c to DLB2_LOG
- fixed a repeated word error in dlb2/pf/base/osdep_bitmap.h
- caught up with marking the patches that Gage reviewed

Changes since V9
================
Address comments from David Marchand:
- this patch-set is based on Nov 1, 2020 dpdk-next-eventdev
- fix docs build (doxy-api.conf.in and doxy-api-index.md)
- restore blank line in MAINTAINERS file
- move dlb announcement in release_20_11.rst after ethdev
- use headers = files() for exported meson public headers
- fix a typo in 'add documentation ..." commit message
- use eal version of cldemote
- convert a couple of printfs to LOG messages
- all patches build incrementally (gcc), and checkpatches reports success
- I am not able to run clang locally. If clang errors are still present I will ask IT to install clang on a build server tomorrow.

Changes since V8:
=================
- Fixed format errors in doc/api/doxy-api-index.md
- Delayed introduction of dlb2_consume_qe_immediate until add-dequeue-and-its-burst-variants.patch
- Delayed introduction of dlb2_construct_token_pop_qe until add-PMD-s-token-pop-public-interface.patch

Changes since V7:
================
- fix CENTOS build error: use __m128i instead of __v2di with _mm_stream_si128
- deleted unused dlb2_umwait and dlb2_umonitor functions

Changes since V6:
=================
- removed unused function, fixing build error
- fixed typo in port_setup commit message
- this patch series is based on dpdk-next-eventdev

Changes since V5:
================
- convert to use rte_power_monitor patches
- replace __builtin_ia32_movntdq() with _mm_stream_si128()
- remove unused functions in dlb_selftest.c
- workaround for RHEL 7 gcc brace bug

Changes since V4:
================
- moved introduction of dlb in relnotes_20_11 to first patch in series
- fixed underlines in dlb.rst that were too short
- note that the code still uses its private byte-encoded versions of umonitor/umwait, rather than the new functions in the power patch that are built on top of those intrinsics. This is intentional.

Changes since V3:
================
- updated MAINTAINERS file to alphabetically insert DLB
- don't create RTE_ symbols in pmd
- converted to use version.map scheme
- converted to use .._master_lcore instead of .._main_lcore
- this patch set is based on dpdk-next-eventdev

Changes since V2:
================
- fixed meson conditional build. Moved test into driver’s meson.build file instead of event/meson.build
- documentation is populated as associated code is introduced
- add log_register in add dynamic logging patch
- rename RTE_xxx symbol(s) as DLB2_xxx
- replaced function ptr enqueue_four with direct call to movdir64b
- remove unused port_pages
- broke up probe patch into 3 smaller patches for easier review
- changed param order of movdir64b/movntdq to match intrinsics
- added self to MAINTAINERS files
- squashed announcement of availability into last patch in series
- correct spelling errors and delete repeated words
- DPDK_21.0 -> DPDK 21 in map file
- add experimental banner to public structs and APIs

Changes since V1:
=================
- implement changes requested in code reviews by Gage Eads and Mike Chen
- fix a memzone leak
- convert to use eal rte-cpuflags patch from Liang Ma

Known Issues:
- the documentation contained in dlb2.rst is not complete, and should be updated to include command line parameters (class of service, etc ...).

Depends-on: patch-82202 ("eventdev: increase MAX QUEUES PER DEV to 255")

Timothy McDaniel (23):
event/dlb2: add documentation and meson build infrastructure event/dlb2: add dynamic logging
event/dlb2: add private data structures and constants event/dlb2: add definitions shared with LKM or shared code event/dlb2: add inline functions
event/dlb2: add eventdev probe
event/dlb2: add flexible interface
event/dlb2: add probe-time hardware init event/dlb2: add xstats
event/dlb2: add infos get and configure event/dlb2: add queue and port default conf event/dlb2: add queue setup
event/dlb2: add port setup
event/dlb2: add port link
event/dlb2: add port unlink and port unlinks in progress event/dlb2: add eventdev start
event/dlb2: add enqueue and its burst variants event/dlb2: add dequeue and its burst variants event/dlb2: add eventdev stop and close event/dlb2: add PMD's token pop public interface event/dlb2: add PMD self-tests
event/dlb2: add queue and port release
event/dlb2: add timeout ticks entry point

 MAINTAINERS                                    |    5 +
 app/test/test_eventdev.c                       |    7 +
 config/rte_config.h                            |    7 +
 doc/api/doxy-api-index.md                      |    3 +-
 doc/api/doxy-api.conf.in                       |    1 +
 doc/guides/eventdevs/dlb2.rst                  |  365 ++
 doc/guides/eventdevs/index.rst                 |    1 +
 doc/guides/rel_notes/release_20_11.rst         |    5 +
 drivers/event/dlb2/dlb2.c                      | 3947 ++++++++++++++++
 drivers/event/dlb2/dlb2_iface.c                |   74 +
 drivers/event/dlb2/dlb2_iface.h                |   74 +
 drivers/event/dlb2/dlb2_inline_fns.h           |   33 +
 drivers/event/dlb2/dlb2_log.h                  |   25 +
 drivers/event/dlb2/dlb2_priv.h                 |  578 +++
 drivers/event/dlb2/dlb2_selftest.c             | 1524 ++++++
 drivers/event/dlb2/dlb2_user.h                 |  679 +++
 drivers/event/dlb2/dlb2_xstats.c               | 1235 +++++
 drivers/event/dlb2/meson.build                 |   23 +
 drivers/event/dlb2/pf/base/dlb2_hw_types.h     |  367 ++
 drivers/event/dlb2/pf/base/dlb2_mbox.h         |  596 +++
 drivers/event/dlb2/pf/base/dlb2_osdep.h        |  230 +
 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h |  440 ++
 drivers/event/dlb2/pf/base/dlb2_osdep_list.h   |  131 +
 drivers/event/dlb2/pf/base/dlb2_osdep_types.h  |   31 +
 drivers/event/dlb2/pf/base/dlb2_regs.h         | 2527 ++++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.c     | 6027 ++++++++++++++++++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.h     | 1913 ++++++++
 drivers/event/dlb2/pf/dlb2_main.c              |  673 +++
 drivers/event/dlb2/pf/dlb2_main.h              |   97 +
 drivers/event/dlb2/pf/dlb2_pf.c                |  728 +++
 drivers/event/dlb2/rte_pmd_dlb2.c              |   39 +
 drivers/event/dlb2/rte_pmd_dlb2.h              |   72 +
 drivers/event/dlb2/version.map                 |    9 +
 drivers/event/meson.build                      |    3 +-
 34 files changed, 22467 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/eventdevs/dlb2.rst
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.h
 create mode 100644 drivers/event/dlb2/dlb2_inline_fns.h
 create mode 100644 drivers/event/dlb2/dlb2_log.h
 create mode 100644 drivers/event/dlb2/dlb2_priv.h
 create mode 100644 drivers/event/dlb2/dlb2_selftest.c
 create mode 100644 drivers/event/dlb2/dlb2_user.h
 create mode 100644 drivers/event/dlb2/dlb2_xstats.c
 create mode 100644 drivers/event/dlb2/meson.build
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_hw_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_mbox.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_list.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_regs.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.c
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.c
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_pf.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.c
 create mode 100644 drivers/event/dlb2/rte_pmd_dlb2.h
 create mode 100644 drivers/event/dlb2/version.map

--
2.6.4

#212 lore raw

PATCH v2 2/22 event/dlb2: add dynamic logging

In reply to Timothy McDaniel

This commit adds base support for dynamic logging. The default log level is NOTICE. Dynamic logging is used exclusively throughout this patchset.

---
 drivers/event/dlb2/dlb2_log.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_log.h
drivers/event/dlb2/dlb2_log.h new file +25 -0
new file mode 100644
index 0000000..dc1481e
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_EVDEV_LOG_H_
+#define _DLB2_EVDEV_LOG_H_
+
+extern int eventdev_dlb2_log_level;
+
+/* Dynamic logging */
+#define DLB2_LOG_IMPL(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, eventdev_dlb2_log_level, "%s" fmt "\n", \
+		__func__, ##args)
+
+#define DLB2_LOG_INFO(fmt, args...) \
+	DLB2_LOG_IMPL(INFO, fmt, ## args)
+
+#define DLB2_LOG_ERR(fmt, args...) \
+	DLB2_LOG_IMPL(ERR, fmt, ## args)
+
+/* remove debug logs at compile time unless actually debugging */
+#define DLB2_LOG_DBG(fmt, args...) \
+	RTE_LOG_DP(DEBUG, PMD, fmt, ## args)
+
+#endif /* _DLB2_EVDEV_LOG_H_ */
Signature · 1 line
2.6.4
#213 lore raw

Re: [dpdk-dev] [PATCH v2 02/22] event/dlb2: add dynamic logging

Quoted 18 lines · Timothy McDaniel

This commit adds base support for dynamic logging. The default log level is NOTICE. Dynamic logging is used exclusively throughout this patchset.

---
 drivers/event/dlb2/dlb2_log.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_log.h
drivers/event/dlb2/dlb2_log.h new file +0 -0
new file mode 100644
index 0000000..dc1481e

drivers/event/dlb2/dlb2_log.h line 8

Quoted 8 lines
drivers/event/dlb2/dlb2_log.h new file +8 -0
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_EVDEV_LOG_H_
+#define _DLB2_EVDEV_LOG_H_
+
+extern int eventdev_dlb2_log_level;

Move rte_log_register() calling part to this patch. Without registration this patch
is incomplete.

Quoted 19 lines
drivers/event/dlb2/dlb2_log.h new file +16 -1
+/* Dynamic logging */
+#define DLB2_LOG_IMPL(level, fmt, args...) \
+       rte_log(RTE_LOG_ ## level, eventdev_dlb2_log_level, "%s" fmt "\n", \
+               __func__, ##args)
+
+#define DLB2_LOG_INFO(fmt, args...) \
+       DLB2_LOG_IMPL(INFO, fmt, ## args)
+
+#define DLB2_LOG_ERR(fmt, args...) \
+       DLB2_LOG_IMPL(ERR, fmt, ## args)
+
+/* remove debug logs at compile time unless actually debugging */
+#define DLB2_LOG_DBG(fmt, args...) \
+       RTE_LOG_DP(DEBUG, PMD, fmt, ## args)
+
+#endif /* _DLB2_EVDEV_LOG_H_ */
--

2.6.4

#214 lore raw

Re: [dpdk-dev] [PATCH v2 02/22] event/dlb2: add dynamic logging

Quoted 35 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 18, 2020 3:57 AM
To: McDaniel, Timothy <[email protected]>
Cc: dpdk-dev <[email protected]>; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 02/22] event/dlb2: add dynamic logging

Quoted 22 lines · Timothy McDaniel

This commit adds base support for dynamic logging. The default log level is NOTICE. Dynamic logging is used exclusively throughout this patchset.

---
 drivers/event/dlb2/dlb2_log.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_log.h
drivers/event/dlb2/dlb2_log.h new file +4 -0
new file mode 100644
index 0000000..dc1481e
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
Quoted 9 lines

drivers/event/dlb2/dlb2_log.h line 8

Quoted 4 lines
drivers/event/dlb2/dlb2_log.h new file +4 -0
+#ifndef _DLB2_EVDEV_LOG_H_
+#define _DLB2_EVDEV_LOG_H_
+
+extern int eventdev_dlb2_log_level;

Move rte_log_register() calling part to this patch. Without registration this patch
is incomplete.

will do

#215 lore raw

PATCH v2 3/22 event/dlb2: add private data structures and constants

In reply to Timothy McDaniel

The header file dlb2_priv.h is used internally by the PMD. It include constants, macros for device resources, structure definitions for hardware interfaces and software state, and various forward-declarations. The header file rte_pmd_dlb2.h will be exported in a subsequent patch, but is included here due to a data structure dependency.

---
 drivers/event/dlb2/dlb2_priv.h | 575 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 575 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_priv.h
drivers/event/dlb2/dlb2_priv.h new file +575 -0
new file mode 100644
index 0000000..61567a6
@@ -0,0 +1,575 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_PRIV_H_
+#define _DLB2_PRIV_H_
+
+#include <emmintrin.h>
+#include <stdbool.h>
+
+#include <rte_eventdev.h>
+#include <rte_config.h>
+#include "dlb2_user.h"
+#include "dlb2_log.h"
+
+#ifndef RTE_LIBRTE_PMD_DLB2_QUELL_STATS
+#define DLB2_INC_STAT(_stat, _incr_val) ((_stat) += _incr_val)
+#else
+#define DLB2_INC_STAT(_stat, _incr_val)
+#endif
+
+#define EVDEV_DLB2_NAME_PMD dlb2_event
+
+/*  command line arg strings */
+#define NUMA_NODE_ARG "numa_node"
+#define DLB2_MAX_NUM_EVENTS "max_num_events"
+#define DLB2_NUM_DIR_CREDITS "num_dir_credits"
+#define DEV_ID_ARG "dev_id"
+#define DLB2_DEFER_SCHED_ARG "defer_sched"
+#define DLB2_QID_DEPTH_THRESH_ARG "qid_depth_thresh"
+#define DLB2_COS_ARG "cos"
+
+/* Begin HW related defines and structs */
+
+#define DLB2_MAX_NUM_DOMAINS 32
+#define DLB2_MAX_NUM_VFS 16
+#define DLB2_MAX_NUM_LDB_QUEUES 32
+#define DLB2_MAX_NUM_LDB_PORTS 64
+#define DLB2_MAX_NUM_DIR_PORTS 64
+#define DLB2_MAX_NUM_DIR_QUEUES 64
+#define DLB2_MAX_NUM_FLOWS (64 * 1024)
+#define DLB2_MAX_NUM_LDB_CREDITS (8 * 1024)
+#define DLB2_MAX_NUM_DIR_CREDITS (2 * 1024)
+#define DLB2_MAX_NUM_LDB_CREDIT_POOLS 64
+#define DLB2_MAX_NUM_DIR_CREDIT_POOLS 64
+#define DLB2_MAX_NUM_HIST_LIST_ENTRIES 2048
+#define DLB2_MAX_NUM_AQOS_ENTRIES 2048
+#define DLB2_MAX_NUM_QIDS_PER_LDB_CQ 8
+#define DLB2_QID_PRIORITIES 8
+#define DLB2_MAX_DEVICE_PATH 32
+#define DLB2_MIN_DEQUEUE_TIMEOUT_NS 1
+/* Note: "- 1" here to support the timeout range check in eventdev_autotest */
+#define DLB2_MAX_DEQUEUE_TIMEOUT_NS (UINT32_MAX - 1)
+#define DLB2_SW_CREDIT_BATCH_SZ 32
+#define DLB2_NUM_SN_GROUPS 2
+#define DLB2_MAX_LDB_SN_ALLOC 1024
+#define DLB2_MAX_QUEUE_DEPTH_THRESHOLD 8191
+
+/* 2048 total hist list entries and 64 total ldb ports, which
+ * makes for 2048/64 == 32 hist list entries per port. However, CQ
+ * depth must be a power of 2 and must also be >= HIST LIST entries.
+ * As a result we just limit the maximum dequeue depth to 32.
+ */
+#define DLB2_MIN_CQ_DEPTH 1
+#define DLB2_MAX_CQ_DEPTH 32
+#define DLB2_MIN_HARDWARE_CQ_DEPTH 8
+#define DLB2_NUM_HIST_LIST_ENTRIES_PER_LDB_PORT \
+	DLB2_MAX_CQ_DEPTH
+
+/*
+ * Static per queue/port provisioning values
+ */
+#define DLB2_NUM_ATOMIC_INFLIGHTS_PER_QUEUE 64
+
+#define CQ_BASE(is_dir) ((is_dir) ? DLB2_DIR_CQ_BASE : DLB2_LDB_CQ_BASE)
+#define CQ_SIZE(is_dir) ((is_dir) ? DLB2_DIR_CQ_MAX_SIZE : \
+				    DLB2_LDB_CQ_MAX_SIZE)
+#define PP_BASE(is_dir) ((is_dir) ? DLB2_DIR_PP_BASE : DLB2_LDB_PP_BASE)
+
+#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
+
+#define DLB2_NUM_QES_PER_CACHE_LINE 4
+
+#define DLB2_MAX_ENQUEUE_DEPTH 64
+#define DLB2_MIN_ENQUEUE_DEPTH 4
+
+#define DLB2_NAME_SIZE 64
+
+#define DLB2_1K 1024
+#define DLB2_2K (2 * DLB2_1K)
+#define DLB2_4K (4 * DLB2_1K)
+#define DLB2_16K (16 * DLB2_1K)
+#define DLB2_32K (32 * DLB2_1K)
+#define DLB2_1MB (DLB2_1K * DLB2_1K)
+#define DLB2_16MB (16 * DLB2_1MB)
+
+/* Use the upper 3 bits of the event priority to select the DLB2 priority */
+#define EV_TO_DLB2_PRIO(x) ((x) >> 5)
+#define DLB2_TO_EV_PRIO(x) ((x) << 5)
+
+enum dlb2_hw_port_types {
+	DLB2_LDB_PORT,
+	DLB2_DIR_PORT,
+	DLB2_NUM_PORT_TYPES /* Must be last */
+};
+
+enum dlb2_hw_queue_types {
+	DLB2_LDB_QUEUE,
+	DLB2_DIR_QUEUE,
+	DLB2_NUM_QUEUE_TYPES /* Must be last */
+};
+
+#define PORT_TYPE(p) ((p)->is_directed ? DLB2_DIR_PORT : DLB2_LDB_PORT)
+
+/* Do not change - must match hardware! */
+enum dlb2_hw_sched_type {
+	DLB2_SCHED_ATOMIC = 0,
+	DLB2_SCHED_UNORDERED,
+	DLB2_SCHED_ORDERED,
+	DLB2_SCHED_DIRECTED,
+	/* DLB2_NUM_HW_SCHED_TYPES must be last */
+	DLB2_NUM_HW_SCHED_TYPES
+};
+
+struct dlb2_hw_rsrcs {
+	int32_t nb_events_limit;
+	uint32_t num_queues;		/* Total queues (lb + dir) */
+	uint32_t num_ldb_queues;	/* Number of available ldb queues */
+	uint32_t num_ldb_ports;         /* Number of load balanced ports */
+	uint32_t num_dir_ports;         /* Number of directed ports */
+	uint32_t num_ldb_credits;       /* Number of load balanced credits */
+	uint32_t num_dir_credits;       /* Number of directed credits */
+	uint32_t reorder_window_size;   /* Size of reorder window */
+};
+
+struct dlb2_hw_resource_info {
+	/**> Max resources that can be provided */
+	struct dlb2_hw_rsrcs hw_rsrc_max;
+	int num_sched_domains;
+	uint32_t socket_id;
+};
+
+enum dlb2_enqueue_type {
+	/**>
+	 * New : Used to inject a new packet into the QM.
+	 */
+	DLB2_ENQ_NEW,
+	/**>
+	 * Forward : Enqueues a packet, and
+	 *  - if atomic: release any lock it holds in the QM
+	 *  - if ordered: release the packet for egress re-ordering
+	 */
+	DLB2_ENQ_FWD,
+	/**>
+	 * Enqueue Drop : Release an inflight packet. Must be called with
+	 * event == NULL. Used to drop a packet.
+	 *
+	 * Note that all packets dequeued from a load-balanced port must be
+	 * released, either with DLB2_ENQ_DROP or DLB2_ENQ_FWD.
+	 */
+	DLB2_ENQ_DROP,
+
+	/* marker for array sizing etc. */
+	_DLB2_NB_ENQ_TYPES
+};
+
+/* hw-specific format - do not change */
+
+struct dlb2_event_type {
+	uint8_t major:4;
+	uint8_t unused:4;
+	uint8_t sub;
+};
+
+union dlb2_opaque_data {
+	uint16_t opaque_data;
+	struct dlb2_event_type event_type;
+};
+
+struct dlb2_msg_info {
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+};
+
+#define DLB2_NEW_CMD_BYTE 0x08
+#define DLB2_FWD_CMD_BYTE 0x0A
+#define DLB2_COMP_CMD_BYTE 0x02
+#define DLB2_POP_CMD_BYTE 0x01
+#define DLB2_NOOP_CMD_BYTE 0x00
+
+/* hw-specific format - do not change */
+struct dlb2_enqueue_qe {
+	uint64_t data;
+	/* Word 3 */
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	/* Word 4 */
+	uint16_t lock_id;
+	uint8_t meas_lat:1;
+	uint8_t rsvd1:2;
+	uint8_t no_dec:1;
+	uint8_t cmp_id:4;
+	union {
+		uint8_t cmd_byte;
+		struct {
+			uint8_t cq_token:1;
+			uint8_t qe_comp:1;
+			uint8_t qe_frag:1;
+			uint8_t qe_valid:1;
+			uint8_t rsvd3:1;
+			uint8_t error:1;
+			uint8_t rsvd:2;
+		};
+	};
+};
+
+/* hw-specific format - do not change */
+struct dlb2_cq_pop_qe {
+	uint64_t data;
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	uint16_t tokens:10;
+	uint16_t rsvd2:6;
+	uint8_t meas_lat:1;
+	uint8_t rsvd1:2;
+	uint8_t no_dec:1;
+	uint8_t cmp_id:4;
+	union {
+		uint8_t cmd_byte;
+		struct {
+			uint8_t cq_token:1;
+			uint8_t qe_comp:1;
+			uint8_t qe_frag:1;
+			uint8_t qe_valid:1;
+			uint8_t rsvd3:1;
+			uint8_t error:1;
+			uint8_t rsvd:2;
+		};
+	};
+};
+
+/* hw-specific format - do not change */
+struct dlb2_dequeue_qe {
+	uint64_t data;
+	union dlb2_opaque_data u;
+	uint8_t qid;
+	uint8_t sched_type:2;
+	uint8_t priority:3;
+	uint8_t msg_type:3;
+	uint16_t flow_id:16; /* was pp_id in v1 */
+	uint8_t debug;
+	uint8_t cq_gen:1;
+	uint8_t qid_depth:2; /* 2 bits in v2 */
+	uint8_t rsvd1:2;
+	uint8_t error:1;
+	uint8_t rsvd2:2;
+};
+
+union dlb2_port_config {
+	struct dlb2_create_ldb_port_args ldb;
+	struct dlb2_create_dir_port_args dir;
+};
+
+enum dlb2_port_state {
+	PORT_CLOSED,
+	PORT_STARTED,
+	PORT_STOPPED
+};
+
+enum dlb2_configuration_state {
+	/* The resource has not been configured */
+	DLB2_NOT_CONFIGURED,
+	/* The resource was configured, but the device was stopped */
+	DLB2_PREV_CONFIGURED,
+	/* The resource is currently configured */
+	DLB2_CONFIGURED
+};
+
+struct dlb2_port {
+	uint32_t id;
+	bool is_directed;
+	bool gen_bit;
+	uint16_t dir_credits;
+	uint32_t dequeue_depth;
+	union dlb2_port_config cfg;
+	uint32_t *credit_pool[DLB2_NUM_QUEUE_TYPES]; /* use __atomic builtins */
+	uint16_t cached_ldb_credits;
+	uint16_t ldb_credits;
+	uint16_t cached_dir_credits;
+	bool int_armed;
+	uint16_t owed_tokens;
+	int16_t issued_releases;
+	int cq_depth;
+	uint16_t cq_idx;
+	uint16_t cq_idx_unmasked;
+	uint16_t cq_depth_mask;
+	uint16_t gen_bit_shift;
+	enum dlb2_port_state state;
+	enum dlb2_configuration_state config_state;
+	int num_mapped_qids;
+	uint8_t *qid_mappings;
+	struct dlb2_enqueue_qe *qe4; /* Cache line's worth of QEs (4) */
+	struct dlb2_enqueue_qe *int_arm_qe;
+	struct dlb2_cq_pop_qe *consume_qe;
+	struct dlb2_eventdev *dlb2; /* back ptr */
+	struct dlb2_eventdev_port *ev_port; /* back ptr */
+};
+
+/* Per-process per-port mmio and memory pointers */
+struct process_local_port_data {
+	uint64_t *pp_addr;
+	struct dlb2_dequeue_qe *cq_base;
+	const struct rte_memzone *mz;
+	bool mmaped;
+};
+
+struct dlb2_eventdev;
+
+struct dlb2_config {
+	int configured;
+	int reserved;
+	uint32_t num_ldb_credits;
+	uint32_t num_dir_credits;
+	struct dlb2_create_sched_domain_args resources;
+};
+
+enum dlb2_cos {
+	DLB2_COS_DEFAULT = -1,
+	DLB2_COS_0 = 0,
+	DLB2_COS_1,
+	DLB2_COS_2,
+	DLB2_COS_3
+};
+
+struct dlb2_hw_dev {
+	struct dlb2_config cfg;
+	struct dlb2_hw_resource_info info;
+	void *pf_dev; /* opaque pointer to PF PMD dev (struct dlb2_dev) */
+	uint32_t domain_id;
+	enum dlb2_cos cos_id;
+	rte_spinlock_t resource_lock; /* for MP support */
+} __rte_cache_aligned;
+
+/* End HW related defines and structs */
+
+/* Begin DLB2 PMD Eventdev related defines and structs */
+
+#define DLB2_MAX_NUM_QUEUES \
+	(DLB2_MAX_NUM_DIR_QUEUES + DLB2_MAX_NUM_LDB_QUEUES)
+
+#define DLB2_MAX_NUM_PORTS (DLB2_MAX_NUM_DIR_PORTS + DLB2_MAX_NUM_LDB_PORTS)
+#define DLB2_MAX_INPUT_QUEUE_DEPTH 256
+
+/** Structure to hold the queue to port link establishment attributes */
+
+struct dlb2_event_queue_link {
+	uint8_t queue_id;
+	uint8_t priority;
+	bool mapped;
+	bool valid;
+};
+
+struct dlb2_traffic_stats {
+	uint64_t rx_ok;
+	uint64_t rx_drop;
+	uint64_t rx_interrupt_wait;
+	uint64_t rx_umonitor_umwait;
+	uint64_t tx_ok;
+	uint64_t total_polls;
+	uint64_t zero_polls;
+	uint64_t tx_nospc_ldb_hw_credits;
+	uint64_t tx_nospc_dir_hw_credits;
+	uint64_t tx_nospc_inflight_max;
+	uint64_t tx_nospc_new_event_limit;
+	uint64_t tx_nospc_inflight_credits;
+};
+
+/* DLB2 HW sets the 2bit qid_depth in rx QEs based on the programmable depth
+ * threshold. The global default value in config/common_base (or rte_config.h)
+ * can be overridden on a per-qid basis using a vdev command line parameter.
+ * 3: depth > threshold
+ * 2: threshold >= depth > 3/4 threshold
+ * 1: 3/4 threshold >= depth > 1/2 threshold
+ * 0: depth <= 1/2 threshold.
+ */
+#define DLB2_QID_DEPTH_LE50 0
+#define DLB2_QID_DEPTH_GT50_LE75 1
+#define DLB2_QID_DEPTH_GT75_LE100 2
+#define DLB2_QID_DEPTH_GT100 3
+#define DLB2_NUM_QID_DEPTH_STAT_VALS 4 /* 2 bits */
+
+struct dlb2_queue_stats {
+	uint64_t enq_ok;
+	uint64_t qid_depth[DLB2_NUM_QID_DEPTH_STAT_VALS];
+};
+
+struct dlb2_port_stats {
+	struct dlb2_traffic_stats traffic;
+	uint64_t tx_op_cnt[4]; /* indexed by rte_event.op */
+	uint64_t tx_implicit_rel;
+	uint64_t tx_sched_cnt[DLB2_NUM_HW_SCHED_TYPES];
+	uint64_t tx_invalid;
+	uint64_t rx_sched_cnt[DLB2_NUM_HW_SCHED_TYPES];
+	uint64_t rx_sched_invalid;
+	struct dlb2_queue_stats queue[DLB2_MAX_NUM_QUEUES];
+};
+
+struct dlb2_eventdev_port {
+	struct dlb2_port qm_port; /* hw specific data structure */
+	struct rte_event_port_conf conf; /* user-supplied configuration */
+	uint16_t inflight_credits; /* num credits this port has right now */
+	uint16_t credit_update_quanta;
+	struct dlb2_eventdev *dlb2; /* backlink optimization */
+	struct dlb2_port_stats stats __rte_cache_aligned;
+	struct dlb2_event_queue_link link[DLB2_MAX_NUM_QIDS_PER_LDB_CQ];
+	int num_links;
+	uint32_t id; /* port id */
+	/* num releases yet to be completed on this port.
+	 * Only applies to load-balanced ports.
+	 */
+	uint16_t outstanding_releases;
+	uint16_t inflight_max; /* app requested max inflights for this port */
+	/* setup_done is set when the event port is setup */
+	bool setup_done;
+	/* enq_configured is set when the qm port is created */
+	bool enq_configured;
+	uint8_t implicit_release; /* release events before dequeueing */
+}  __rte_cache_aligned;
+
+struct dlb2_queue {
+	uint32_t num_qid_inflights; /* User config */
+	uint32_t num_atm_inflights; /* User config */
+	enum dlb2_configuration_state config_state;
+	int sched_type; /* LB queue only */
+	uint32_t id;
+	bool is_directed;
+};
+
+struct dlb2_eventdev_queue {
+	struct dlb2_queue qm_queue;
+	struct rte_event_queue_conf conf; /* User config */
+	int depth_threshold; /* use default if 0 */
+	uint32_t id;
+	bool setup_done;
+	uint8_t num_links;
+};
+
+enum dlb2_run_state {
+	DLB2_RUN_STATE_STOPPED = 0,
+	DLB2_RUN_STATE_STOPPING,
+	DLB2_RUN_STATE_STARTING,
+	DLB2_RUN_STATE_STARTED
+};
+
+struct dlb2_eventdev {
+	struct dlb2_eventdev_port ev_ports[DLB2_MAX_NUM_PORTS];
+	struct dlb2_eventdev_queue ev_queues[DLB2_MAX_NUM_QUEUES];
+	uint8_t qm_ldb_to_ev_queue_id[DLB2_MAX_NUM_QUEUES];
+	uint8_t qm_dir_to_ev_queue_id[DLB2_MAX_NUM_QUEUES];
+	/* store num stats and offset of the stats for each queue */
+	uint16_t xstats_count_per_qid[DLB2_MAX_NUM_QUEUES];
+	uint16_t xstats_offset_for_qid[DLB2_MAX_NUM_QUEUES];
+	/* store num stats and offset of the stats for each port */
+	uint16_t xstats_count_per_port[DLB2_MAX_NUM_PORTS];
+	uint16_t xstats_offset_for_port[DLB2_MAX_NUM_PORTS];
+	struct dlb2_get_num_resources_args hw_rsrc_query_results;
+	uint32_t xstats_count_mode_queue;
+	struct dlb2_hw_dev qm_instance; /* strictly hw related */
+	uint64_t global_dequeue_wait_ticks;
+	struct dlb2_xstats_entry *xstats;
+	struct rte_eventdev *event_dev; /* backlink to dev */
+	uint32_t xstats_count_mode_dev;
+	uint32_t xstats_count_mode_port;
+	uint32_t xstats_count;
+	uint32_t inflights; /* use __atomic builtins */
+	uint32_t new_event_limit;
+	int max_num_events_override;
+	int num_dir_credits_override;
+	volatile enum dlb2_run_state run_state;
+	uint16_t num_dir_queues; /* total num of evdev dir queues requested */
+	uint16_t num_dir_credits;
+	uint16_t num_ldb_credits;
+	uint16_t num_queues; /* total queues */
+	uint16_t num_ldb_queues; /* total num of evdev ldb queues requested */
+	uint16_t num_ports; /* total num of evdev ports requested */
+	uint16_t num_ldb_ports; /* total num of ldb ports requested */
+	uint16_t num_dir_ports; /* total num of dir ports requested */
+	bool umwait_allowed;
+	bool global_dequeue_wait; /* Not using per dequeue wait if true */
+	bool defer_sched;
+	enum dlb2_cq_poll_modes poll_mode;
+	uint8_t revision;
+	bool configured;
+	uint16_t max_ldb_credits;
+	uint16_t max_dir_credits;
+
+	/* force hw credit pool counters into exclusive cache lines */
+
+	/* use __atomic builtins */ /* shared hw cred */
+	uint32_t ldb_credit_pool __rte_cache_aligned;
+	/* use __atomic builtins */ /* shared hw cred */
+	uint32_t dir_credit_pool __rte_cache_aligned;
+};
+
+/* used for collecting and passing around the dev args */
+struct dlb2_qid_depth_thresholds {
+	int val[DLB2_MAX_NUM_QUEUES];
+};
+
+struct dlb2_devargs {
+	int socket_id;
+	int max_num_events;
+	int num_dir_credits_override;
+	int dev_id;
+	int defer_sched;
+	struct dlb2_qid_depth_thresholds qid_depth_thresholds;
+	enum dlb2_cos cos_id;
+};
+
+/* End Eventdev related defines and structs */
+
+/* Forwards for non-inlined functions */
+
+void dlb2_eventdev_dump(struct rte_eventdev *dev, FILE *f);
+
+int dlb2_xstats_init(struct dlb2_eventdev *dlb2);
+
+void dlb2_xstats_uninit(struct dlb2_eventdev *dlb2);
+
+int dlb2_eventdev_xstats_get(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
+		const unsigned int ids[], uint64_t values[], unsigned int n);
+
+int dlb2_eventdev_xstats_get_names(const struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
+		struct rte_event_dev_xstats_name *xstat_names,
+		unsigned int *ids, unsigned int size);
+
+uint64_t dlb2_eventdev_xstats_get_by_name(const struct rte_eventdev *dev,
+					  const char *name, unsigned int *id);
+
+int dlb2_eventdev_xstats_reset(struct rte_eventdev *dev,
+		enum rte_event_dev_xstats_mode mode,
+		int16_t queue_port_id,
+		const uint32_t ids[],
+		uint32_t nb_ids);
+
+int test_dlb2_eventdev(void);
+
+int dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
+				const char *name,
+				struct dlb2_devargs *dlb2_args);
+
+int dlb2_secondary_eventdev_probe(struct rte_eventdev *dev,
+				  const char *name);
+
+uint32_t dlb2_get_queue_depth(struct dlb2_eventdev *dlb2,
+			      struct dlb2_eventdev_queue *queue);
+
+int dlb2_parse_params(const char *params,
+		      const char *name,
+		      struct dlb2_devargs *dlb2_args);
+
+/* Extern globals */
+extern struct process_local_port_data dlb2_port[][DLB2_NUM_PORT_TYPES];
+
+#endif	/* _DLB2_PRIV_H_ */
Signature · 1 line
2.6.4
Reviewed-by on v2 3/22
#216 lore raw

Re: [dpdk-dev] [PATCH v2 03/22] event/dlb2: add private data structures and constants

Quoted 18 lines

-----Original Message-----
From: McDaniel, Timothy <[email protected]>
Sent: Saturday, October 17, 2020 1:21 PM
Cc: [email protected]; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Subject: [PATCH v2 03/22] event/dlb2: add private data structures and constants

The header file dlb2_priv.h is used internally by the PMD. It include constants, macros for device resources, structure definitions for hardware interfaces and software state, and various forward-declarations. The header file rte_pmd_dlb2.h will be exported in a subsequent patch, but is included here due to a data structure dependency.

Quoted 1 line

Thanks,
Gage

#217 lore raw

PATCH v2 4/22 event/dlb2: add definitions shared with LKM or shared code

In reply to Timothy McDaniel

Add headers containing structs and constants shared between the PMD and the shared code. The term shared code refers to the code that implements the hardware interface. The shared code is introduced in the probe patch, and then is extended as additional eventdev PMD entry points are added to the patchset. In the case of the bifurcated PMD (to be introduced in the future), the shared code is contained in the Linux kernel module itself.

---
 drivers/event/dlb2/dlb2_user.h | 679 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 679 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_user.h
drivers/event/dlb2/dlb2_user.h new file +679 -0
new file mode 100644
index 0000000..b5d39be
@@ -0,0 +1,679 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_USER_H
+#define __DLB2_USER_H
+
+#define DLB2_MAX_NAME_LEN 64
+
+#include <linux/types.h>
+
+enum dlb2_error {
+	DLB2_ST_SUCCESS = 0,
+	DLB2_ST_NAME_EXISTS,
+	DLB2_ST_DOMAIN_UNAVAILABLE,
+	DLB2_ST_LDB_PORTS_UNAVAILABLE,
+	DLB2_ST_DIR_PORTS_UNAVAILABLE,
+	DLB2_ST_LDB_QUEUES_UNAVAILABLE,
+	DLB2_ST_LDB_CREDITS_UNAVAILABLE,
+	DLB2_ST_DIR_CREDITS_UNAVAILABLE,
+	DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE,
+	DLB2_ST_INVALID_DOMAIN_ID,
+	DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION,
+	DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE,
+	DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE,
+	DLB2_ST_INVALID_LDB_QUEUE_ID,
+	DLB2_ST_INVALID_CQ_DEPTH,
+	DLB2_ST_INVALID_CQ_VIRT_ADDR,
+	DLB2_ST_INVALID_PORT_ID,
+	DLB2_ST_INVALID_QID,
+	DLB2_ST_INVALID_PRIORITY,
+	DLB2_ST_NO_QID_SLOTS_AVAILABLE,
+	DLB2_ST_INVALID_DIR_QUEUE_ID,
+	DLB2_ST_DIR_QUEUES_UNAVAILABLE,
+	DLB2_ST_DOMAIN_NOT_CONFIGURED,
+	DLB2_ST_INTERNAL_ERROR,
+	DLB2_ST_DOMAIN_IN_USE,
+	DLB2_ST_DOMAIN_NOT_FOUND,
+	DLB2_ST_QUEUE_NOT_FOUND,
+	DLB2_ST_DOMAIN_STARTED,
+	DLB2_ST_DOMAIN_NOT_STARTED,
+	DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES,
+	DLB2_ST_DOMAIN_RESET_FAILED,
+	DLB2_ST_MBOX_ERROR,
+	DLB2_ST_INVALID_HIST_LIST_DEPTH,
+	DLB2_ST_NO_MEMORY,
+	DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL,
+	DLB2_ST_INVALID_COS_ID,
+};
+
+static const char dlb2_error_strings[][128] = {
+	"DLB2_ST_SUCCESS",
+	"DLB2_ST_NAME_EXISTS",
+	"DLB2_ST_DOMAIN_UNAVAILABLE",
+	"DLB2_ST_LDB_PORTS_UNAVAILABLE",
+	"DLB2_ST_DIR_PORTS_UNAVAILABLE",
+	"DLB2_ST_LDB_QUEUES_UNAVAILABLE",
+	"DLB2_ST_LDB_CREDITS_UNAVAILABLE",
+	"DLB2_ST_DIR_CREDITS_UNAVAILABLE",
+	"DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE",
+	"DLB2_ST_INVALID_DOMAIN_ID",
+	"DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION",
+	"DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE",
+	"DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE",
+	"DLB2_ST_INVALID_LDB_QUEUE_ID",
+	"DLB2_ST_INVALID_CQ_DEPTH",
+	"DLB2_ST_INVALID_CQ_VIRT_ADDR",
+	"DLB2_ST_INVALID_PORT_ID",
+	"DLB2_ST_INVALID_QID",
+	"DLB2_ST_INVALID_PRIORITY",
+	"DLB2_ST_NO_QID_SLOTS_AVAILABLE",
+	"DLB2_ST_INVALID_DIR_QUEUE_ID",
+	"DLB2_ST_DIR_QUEUES_UNAVAILABLE",
+	"DLB2_ST_DOMAIN_NOT_CONFIGURED",
+	"DLB2_ST_INTERNAL_ERROR",
+	"DLB2_ST_DOMAIN_IN_USE",
+	"DLB2_ST_DOMAIN_NOT_FOUND",
+	"DLB2_ST_QUEUE_NOT_FOUND",
+	"DLB2_ST_DOMAIN_STARTED",
+	"DLB2_ST_DOMAIN_NOT_STARTED",
+	"DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES",
+	"DLB2_ST_DOMAIN_RESET_FAILED",
+	"DLB2_ST_MBOX_ERROR",
+	"DLB2_ST_INVALID_HIST_LIST_DEPTH",
+	"DLB2_ST_NO_MEMORY",
+	"DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL",
+	"DLB2_ST_INVALID_COS_ID",
+};
+
+struct dlb2_cmd_response {
+	__u32 status; /* Interpret using enum dlb2_error */
+	__u32 id;
+};
+
+/*******************/
+/* 'dlb2' commands */
+/*******************/
+
+#define DLB2_DEVICE_VERSION(x) (((x) >> 8) & 0xFF)
+#define DLB2_DEVICE_REVISION(x) ((x) & 0xFF)
+
+enum dlb2_revisions {
+	DLB2_REV_A0 = 0,
+};
+
+/*
+ * DLB2_CMD_GET_DEVICE_VERSION: Query the DLB device version.
+ *
+ *	This ioctl interface is the same in all driver versions and is always
+ *	the first ioctl.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id[7:0]: Device revision.
+ * - response.id[15:8]: Device version.
+ */
+
+struct dlb2_get_device_version_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+};
+
+/*
+ * DLB2_CMD_CREATE_SCHED_DOMAIN: Create a DLB 2.0 scheduling domain and reserve
+ *	its hardware resources. This command returns the newly created domain
+ *	ID and a file descriptor for accessing the domain.
+ *
+ * Input parameters:
+ * - num_ldb_queues: Number of load-balanced queues.
+ * - num_ldb_ports: Number of load-balanced ports that can be allocated from
+ *	from any class-of-service with available ports.
+ * - num_cos_ldb_ports[4]: Number of load-balanced ports from
+ *	classes-of-service 0-3.
+ * - num_dir_ports: Number of directed ports. A directed port has one directed
+ *	queue, so no num_dir_queues argument is necessary.
+ * - num_atomic_inflights: This specifies the amount of temporary atomic QE
+ *	storage for the domain. This storage is divided among the domain's
+ *	load-balanced queues that are configured for atomic scheduling.
+ * - num_hist_list_entries: Amount of history list storage. This is divided
+ *	among the domain's CQs.
+ * - num_ldb_credits: Amount of load-balanced QE storage (QED). QEs occupy this
+ *	space until they are scheduled to a load-balanced CQ. One credit
+ *	represents the storage for one QE.
+ * - num_dir_credits: Amount of directed QE storage (DQED). QEs occupy this
+ *	space until they are scheduled to a directed CQ. One credit represents
+ *	the storage for one QE.
+ * - cos_strict: If set, return an error if there are insufficient ports in
+ *	class-of-service N to satisfy the num_ldb_ports_cosN argument. If
+ *	unset, attempt to fulfill num_ldb_ports_cosN arguments from other
+ *	classes-of-service if class N does not contain enough free ports.
+ * - padding1: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: domain ID.
+ * - domain_fd: file descriptor for performing the domain's ioctl operations
+ * - padding0: Reserved for future use.
+ */
+struct dlb2_create_sched_domain_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	__u32 domain_fd;
+	__u32 padding0;
+	/* Input parameters */
+	__u32 num_ldb_queues;
+	__u32 num_ldb_ports;
+	__u32 num_cos_ldb_ports[4];
+	__u32 num_dir_ports;
+	__u32 num_atomic_inflights;
+	__u32 num_hist_list_entries;
+	__u32 num_ldb_credits;
+	__u32 num_dir_credits;
+	__u8 cos_strict;
+	__u8 padding1[3];
+};
+
+/*
+ * DLB2_CMD_GET_NUM_RESOURCES: Return the number of available resources
+ *	(queues, ports, etc.) that this device owns.
+ *
+ * Output parameters:
+ * - num_domains: Number of available scheduling domains.
+ * - num_ldb_queues: Number of available load-balanced queues.
+ * - num_ldb_ports: Total number of available load-balanced ports.
+ * - num_cos_ldb_ports[4]: Number of available load-balanced ports from
+ *	classes-of-service 0-3.
+ * - num_dir_ports: Number of available directed ports. There is one directed
+ *	queue for every directed port.
+ * - num_atomic_inflights: Amount of available temporary atomic QE storage.
+ * - num_hist_list_entries: Amount of history list storage.
+ * - max_contiguous_hist_list_entries: History list storage is allocated in
+ *	a contiguous chunk, and this return value is the longest available
+ *	contiguous range of history list entries.
+ * - num_ldb_credits: Amount of available load-balanced QE storage.
+ * - num_dir_credits: Amount of available directed QE storage.
+ */
+struct dlb2_get_num_resources_args {
+	/* Output parameters */
+	__u32 num_sched_domains;
+	__u32 num_ldb_queues;
+	__u32 num_ldb_ports;
+	__u32 num_cos_ldb_ports[4];
+	__u32 num_dir_ports;
+	__u32 num_atomic_inflights;
+	__u32 num_hist_list_entries;
+	__u32 max_contiguous_hist_list_entries;
+	__u32 num_ldb_credits;
+	__u32 num_dir_credits;
+};
+
+/*
+ * DLB2_CMD_SET_SN_ALLOCATION: Configure a sequence number group (PF only)
+ *
+ * Input parameters:
+ * - group: Sequence number group ID.
+ * - num: Number of sequence numbers per queue.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_set_sn_allocation_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 group;
+	__u32 num;
+};
+
+/*
+ * DLB2_CMD_GET_SN_ALLOCATION: Get a sequence number group's configuration
+ *
+ * Input parameters:
+ * - group: Sequence number group ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Specified group's number of sequence numbers per queue.
+ */
+struct dlb2_get_sn_allocation_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 group;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_CMD_SET_COS_BW: Set a bandwidth allocation percentage for a
+ *	load-balanced port class-of-service (PF only).
+ *
+ * Input parameters:
+ * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
+ * - bandwidth: class-of-service bandwidth percentage. Total bandwidth
+ *		percentages across all 4 classes cannot exceed 100%.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_set_cos_bw_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 cos_id;
+	__u32 bandwidth;
+};
+
+/*
+ * DLB2_CMD_GET_COS_BW: Get the bandwidth allocation percentage for a
+ *	load-balanced port class-of-service.
+ *
+ * Input parameters:
+ * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Specified class's bandwidth percentage.
+ */
+struct dlb2_get_cos_bw_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 cos_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_CMD_GET_SN_OCCUPANCY: Get a sequence number group's occupancy
+ *
+ * Each sequence number group has one or more slots, depending on its
+ * configuration. I.e.:
+ * - If configured for 1024 sequence numbers per queue, the group has 1 slot
+ * - If configured for 512 sequence numbers per queue, the group has 2 slots
+ *   ...
+ * - If configured for 32 sequence numbers per queue, the group has 32 slots
+ *
+ * This ioctl returns the group's number of in-use slots. If its occupancy is
+ * 0, the group's sequence number allocation can be reconfigured.
+ *
+ * Input parameters:
+ * - group: Sequence number group ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Specified group's number of used slots.
+ */
+struct dlb2_get_sn_occupancy_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 group;
+	__u32 padding0;
+};
+
+enum dlb2_cq_poll_modes {
+	DLB2_CQ_POLL_MODE_STD,
+	DLB2_CQ_POLL_MODE_SPARSE,
+
+	/* NUM_DLB2_CQ_POLL_MODE must be last */
+	NUM_DLB2_CQ_POLL_MODE,
+};
+
+/*
+ * DLB2_CMD_QUERY_CQ_POLL_MODE: Query the CQ poll mode setting
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: CQ poll mode (see enum dlb2_cq_poll_modes).
+ */
+struct dlb2_query_cq_poll_mode_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+};
+
+/********************************/
+/* 'scheduling domain' commands */
+/********************************/
+
+/*
+ * DLB2_DOMAIN_CMD_CREATE_LDB_QUEUE: Configure a load-balanced queue.
+ * Input parameters:
+ * - num_atomic_inflights: This specifies the amount of temporary atomic QE
+ *	storage for this queue. If zero, the queue will not support atomic
+ *	scheduling.
+ * - num_sequence_numbers: This specifies the number of sequence numbers used
+ *	by this queue. If zero, the queue will not support ordered scheduling.
+ *	If non-zero, the queue will not support unordered scheduling.
+ * - num_qid_inflights: The maximum number of QEs that can be inflight
+ *	(scheduled to a CQ but not completed) at any time. If
+ *	num_sequence_numbers is non-zero, num_qid_inflights must be set equal
+ *	to num_sequence_numbers.
+ * - lock_id_comp_level: Lock ID compression level. Specifies the number of
+ *	unique lock IDs the queue should compress down to. Valid compression
+ *	levels: 0, 64, 128, 256, 512, 1k, 2k, 4k, 64k. If lock_id_comp_level is
+ *	0, the queue won't compress its lock IDs.
+ * - depth_threshold: DLB sets two bits in the received QE to indicate the
+ *	depth of the queue relative to the threshold before scheduling the
+ *	QE to a CQ:
+ *	- 2’b11: depth > threshold
+ *	- 2’b10: threshold >= depth > 0.75 * threshold
+ *	- 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
+ *	- 2’b00: depth <= 0.5 * threshold
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Queue ID.
+ */
+struct dlb2_create_ldb_queue_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 num_sequence_numbers;
+	__u32 num_qid_inflights;
+	__u32 num_atomic_inflights;
+	__u32 lock_id_comp_level;
+	__u32 depth_threshold;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_CREATE_DIR_QUEUE: Configure a directed queue.
+ * Input parameters:
+ * - port_id: Port ID. If the corresponding directed port is already created,
+ *	specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
+ *	that the queue is being created before the port.
+ * - depth_threshold: DLB sets two bits in the received QE to indicate the
+ *	depth of the queue relative to the threshold before scheduling the
+ *	QE to a CQ:
+ *	- 2’b11: depth > threshold
+ *	- 2’b10: threshold >= depth > 0.75 * threshold
+ *	- 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
+ *	- 2’b00: depth <= 0.5 * threshold
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Queue ID.
+ */
+struct dlb2_create_dir_queue_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__s32 port_id;
+	__u32 depth_threshold;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_CREATE_LDB_PORT: Configure a load-balanced port.
+ * Input parameters:
+ * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
+ *	1024, inclusive.
+ * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
+ *	the CQ interrupt won't fire until there are N or more outstanding CQ
+ *	tokens.
+ * - num_hist_list_entries: Number of history list entries. This must be
+ *	greater than or equal cq_depth.
+ * - cos_id: class-of-service to allocate this port from. Must be between 0 and
+ *	3, inclusive.
+ * - cos_strict: If set, return an error if there are no available ports in the
+ *	requested class-of-service. Else, allocate the port from a different
+ *	class-of-service if the requested class has no available ports.
+ *
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: port ID.
+ */
+
+struct dlb2_create_ldb_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u16 cq_depth;
+	__u16 cq_depth_threshold;
+	__u16 cq_history_list_size;
+	__u8 cos_id;
+	__u8 cos_strict;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_CREATE_DIR_PORT: Configure a directed port.
+ * Input parameters:
+ * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
+ *	1024, inclusive.
+ * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
+ *	the CQ interrupt won't fire until there are N or more outstanding CQ
+ *	tokens.
+ * - qid: Queue ID. If the corresponding directed queue is already created,
+ *	specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
+ *	that the port is being created before the queue.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: Port ID.
+ */
+struct dlb2_create_dir_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u16 cq_depth;
+	__u16 cq_depth_threshold;
+	__s32 queue_id;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_START_DOMAIN: Mark the end of the domain configuration. This
+ *	must be called before passing QEs into the device, and no configuration
+ *	ioctls can be issued once the domain has started. Sending QEs into the
+ *	device before calling this ioctl will result in undefined behavior.
+ * Input parameters:
+ * - (None)
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_start_domain_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_MAP_QID: Map a load-balanced queue to a load-balanced port.
+ * Input parameters:
+ * - port_id: Load-balanced port ID.
+ * - qid: Load-balanced queue ID.
+ * - priority: Queue->port service priority.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_map_qid_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 qid;
+	__u32 priority;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_UNMAP_QID: Unmap a load-balanced queue to a load-balanced
+ *	port.
+ * Input parameters:
+ * - port_id: Load-balanced port ID.
+ * - qid: Load-balanced queue ID.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_unmap_qid_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 qid;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_ENABLE_LDB_PORT: Enable scheduling to a load-balanced port.
+ * Input parameters:
+ * - port_id: Load-balanced port ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_enable_ldb_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_ENABLE_DIR_PORT: Enable scheduling to a directed port.
+ * Input parameters:
+ * - port_id: Directed port ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_enable_dir_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_DISABLE_LDB_PORT: Disable scheduling to a load-balanced
+ *	port.
+ * Input parameters:
+ * - port_id: Load-balanced port ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_disable_ldb_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_DISABLE_DIR_PORT: Disable scheduling to a directed port.
+ * Input parameters:
+ * - port_id: Directed port ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ */
+struct dlb2_disable_dir_port_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_GET_LDB_QUEUE_DEPTH: Get a load-balanced queue's depth.
+ * Input parameters:
+ * - queue_id: The load-balanced queue ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: queue depth.
+ */
+struct dlb2_get_ldb_queue_depth_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 queue_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_DIR_QUEUE_DEPTH: Get a directed queue's depth.
+ * Input parameters:
+ * - queue_id: The directed queue ID.
+ * - padding0: Reserved for future use.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: queue depth.
+ */
+struct dlb2_get_dir_queue_depth_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 queue_id;
+	__u32 padding0;
+};
+
+/*
+ * DLB2_DOMAIN_CMD_PENDING_PORT_UNMAPS: Get number of queue unmap operations in
+ *	progress for a load-balanced port.
+ *
+ *	Note: This is a snapshot; the number of unmap operations in progress
+ *	is subject to change at any time.
+ *
+ * Input parameters:
+ * - port_id: Load-balanced port ID.
+ *
+ * Output parameters:
+ * - response.status: Detailed error code. In certain cases, such as if the
+ *	ioctl request arg is invalid, the driver won't set status.
+ * - response.id: number of unmaps in progress.
+ */
+struct dlb2_pending_port_unmaps_args {
+	/* Output parameters */
+	struct dlb2_cmd_response response;
+	/* Input parameters */
+	__u32 port_id;
+	__u32 padding0;
+};
+
+/*
+ * Mapping sizes for memory mapping the consumer queue (CQ) memory space, and
+ * producer port (PP) MMIO space.
+ */
+#define DLB2_CQ_SIZE 65536
+#define DLB2_PP_SIZE 4096
+
+
+#endif /* __DLB2_USER_H */
Signature · 1 line
2.6.4
#218 lore raw

PATCH v2 5/22 event/dlb2: add inline functions

In reply to Timothy McDaniel

Add miscellaneous inline functions that may be called from multiple files. These functions include inline assembly of new x86 instructions, such as movdir64b, since they are not available as builtin functions in the minimum supported GCC version.

---
 drivers/event/dlb2/dlb2_inline_fns.h | 81 ++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_inline_fns.h
drivers/event/dlb2/dlb2_inline_fns.h new file +81 -0
new file mode 100644
index 0000000..9c3c36f
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_INLINE_FNS_H_
+#define _DLB2_INLINE_FNS_H_
+
+/* Inline functions required in more than one source file. */
+
+static inline struct dlb2_eventdev *
+dlb2_pmd_priv(const struct rte_eventdev *eventdev)
+{
+	return eventdev->data->dev_private;
+}
+
+static inline void
+dlb2_umonitor(volatile void *addr)
+{
+	asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7\t\n"
+			:
+			: "D" (addr));
+}
+
+static inline void
+dlb2_umwait(int state, uint64_t timeout)
+{
+	uint32_t eax = timeout & UINT32_MAX;
+	uint32_t edx = timeout >> 32;
+
+	asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7\t\n"
+			:
+			: "D" (state),  "a" (eax), "d" (edx));
+}
+
+static inline void
+dlb2_movntdq(void *qe4, void *pp_addr)
+{
+	/* Move entire 64B cache line of QEs, 128 bits (16B) at a time. */
+	long long *_qe  = (long long *)qe4;
+	__v2di src_data0 = (__v2di){_qe[0], _qe[1]};
+	__v2di src_data1 = (__v2di){_qe[2], _qe[3]};
+	__v2di src_data2 = (__v2di){_qe[4], _qe[5]};
+	__v2di src_data3 = (__v2di){_qe[6], _qe[7]};
+
+	__builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
+	rte_wmb();
+	__builtin_ia32_movntdq((__v2di *)pp_addr + 1, (__v2di)src_data1);
+	rte_wmb();
+	__builtin_ia32_movntdq((__v2di *)pp_addr + 2, (__v2di)src_data2);
+	rte_wmb();
+	__builtin_ia32_movntdq((__v2di *)pp_addr + 3, (__v2di)src_data3);
+	rte_wmb();
+}
+
+static inline void
+dlb2_movntdq_single(void *qe4, void *pp_addr)
+{
+	long long *_qe  = (long long *)qe4;
+	__v2di src_data0 = (__v2di){_qe[0], _qe[1]};
+
+	__builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
+}
+
+static inline void
+dlb2_cldemote(void *addr)
+{
+	/* Load addr into RSI, then demote the cache line of the address
+	 * contained in that register.
+	 */
+	asm volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (addr));
+}
+
+static inline void
+dlb2_movdir64b(void *qe4, void *pp_addr)
+{
+	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
+		     :
+		     : "a" (pp_addr), "d" (qe4));
+}
+
+#endif /* _DLB2_INLINE_FNS_H_ */
Signature · 1 line
2.6.4
#219 lore raw

Re: [dpdk-dev] [PATCH v2 05/22] event/dlb2: add inline functions

Quoted 44 lines · Timothy McDaniel

Add miscellaneous inline functions that may be called from multiple files. These functions include inline assembly of new x86 instructions, such as movdir64b, since they are not available as builtin functions in the minimum supported GCC version.

---
 drivers/event/dlb2/dlb2_inline_fns.h | 81 ++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_inline_fns.h
drivers/event/dlb2/dlb2_inline_fns.h new file +24 -0
new file mode 100644
index 0000000..9c3c36f
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_INLINE_FNS_H_
+#define _DLB2_INLINE_FNS_H_
+
+/* Inline functions required in more than one source file. */
+
+static inline struct dlb2_eventdev *
+dlb2_pmd_priv(const struct rte_eventdev *eventdev)
+{
+       return eventdev->data->dev_private;
+}
+
+static inline void
+dlb2_umonitor(volatile void *addr)
+{
+       asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7\t\n"
+                       :
+                       : "D" (addr));
+}
+
+static inline void

drivers/event/dlb2/dlb2_inline_fns.h line 34

Quoted 10 lines
drivers/event/dlb2/dlb2_inline_fns.h new file +10 -0
+dlb2_umwait(int state, uint64_t timeout)
+{
+       uint32_t eax = timeout & UINT32_MAX;
+       uint32_t edx = timeout >> 32;
+
+       asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7\t\n"
+                       :
+                       : "D" (state),  "a" (eax), "d" (edx));
+}
+

Please change this instruction to use new rte public API once it gets merged.

Quoted 50 lines
drivers/event/dlb2/dlb2_inline_fns.h new file +47 -1
+static inline void
+dlb2_movntdq(void *qe4, void *pp_addr)
+{
+       /* Move entire 64B cache line of QEs, 128 bits (16B) at a time. */
+       long long *_qe  = (long long *)qe4;
+       __v2di src_data0 = (__v2di){_qe[0], _qe[1]};
+       __v2di src_data1 = (__v2di){_qe[2], _qe[3]};
+       __v2di src_data2 = (__v2di){_qe[4], _qe[5]};
+       __v2di src_data3 = (__v2di){_qe[6], _qe[7]};
+
+       __builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
+       rte_wmb();
+       __builtin_ia32_movntdq((__v2di *)pp_addr + 1, (__v2di)src_data1);
+       rte_wmb();
+       __builtin_ia32_movntdq((__v2di *)pp_addr + 2, (__v2di)src_data2);
+       rte_wmb();
+       __builtin_ia32_movntdq((__v2di *)pp_addr + 3, (__v2di)src_data3);
+       rte_wmb();
+}
+
+static inline void
+dlb2_movntdq_single(void *qe4, void *pp_addr)
+{
+       long long *_qe  = (long long *)qe4;
+       __v2di src_data0 = (__v2di){_qe[0], _qe[1]};
+
+       __builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
+}
+
+static inline void
+dlb2_cldemote(void *addr)
+{
+       /* Load addr into RSI, then demote the cache line of the address
+        * contained in that register.
+        */
+       asm volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (addr));
+}
+
+static inline void
+dlb2_movdir64b(void *qe4, void *pp_addr)
+{
+       asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
+                    :
+                    : "a" (pp_addr), "d" (qe4));
+}
+
+#endif /* _DLB2_INLINE_FNS_H_ */
--

2.6.4

#220 lore raw

Re: [dpdk-dev] [PATCH v2 05/22] event/dlb2: add inline functions

Quoted 63 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, October 18, 2020 4:00 AM
To: McDaniel, Timothy <[email protected]>
Cc: dpdk-dev <[email protected]>; Carrillo, Erik G <[email protected]>; Eads, Gage <[email protected]>; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 05/22] event/dlb2: add inline functions

Quoted 11 lines · Timothy McDaniel

Add miscellaneous inline functions that may be called from multiple files. These functions include inline assembly of new x86 instructions, such as movdir64b, since they are not available as builtin functions in the minimum supported GCC version.

---
 drivers/event/dlb2/dlb2_inline_fns.h | 81

++++++++++++++++++++++++++++++++++++

Review

Quoted 4 lines
 1 file changed, 81 insertions(+)
 create mode 100644 drivers/event/dlb2/dlb2_inline_fns.h
(quoted diff) +0 -0

b/drivers/event/dlb2/dlb2_inline_fns.h

Quoted 33 lines

new file mode 100644
index 0000000..9c3c36f

drivers/event/dlb2/dlb2_inline_fns.h new file +28 -0
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_INLINE_FNS_H_
+#define _DLB2_INLINE_FNS_H_
+
+/* Inline functions required in more than one source file. */
+
+static inline struct dlb2_eventdev *
+dlb2_pmd_priv(const struct rte_eventdev *eventdev)
+{
+       return eventdev->data->dev_private;
+}
+
+static inline void
+dlb2_umonitor(volatile void *addr)
+{
+       asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7\t\n"
+                       :
+                       : "D" (addr));
+}
+
+static inline void
+dlb2_umwait(int state, uint64_t timeout)
+{
+       uint32_t eax = timeout & UINT32_MAX;
+       uint32_t edx = timeout >> 32;
Quoted 9 lines

drivers/event/dlb2/dlb2_inline_fns.h line 34

Quoted 6 lines
drivers/event/dlb2/dlb2_inline_fns.h new file +6 -0
+
+       asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7\t\n"
+                       :
+                       : "D" (state),  "a" (eax), "d" (edx));
+}
+

Please change this instruction to use new rte public API once it gets merged.

Yes, we will do that.

#221 lore raw

PATCH v2 6/22 event/dlb2: add probe

In reply to Timothy McDaniel

The DLB2 hardware is a PCI device. This commit adds support for probe and other initialization. The dlb2_iface.[ch] files implement a flexible interface that supports both the PF PMD and the bifurcated PMD. The bifurcated PMD will be released in a future patch set. Note that the flexible interface is only used for configuration, and is not used in the data path. The shared code is added in pf/base. This PMD supports command line parameters, and those are parsed at probe-time.

---
 drivers/event/dlb2/dlb2.c                      |  532 +++++
 drivers/event/dlb2/dlb2_iface.c                |   28 +
 drivers/event/dlb2/dlb2_iface.h                |   29 +
 drivers/event/dlb2/meson.build                 |    6 +-
 drivers/event/dlb2/pf/base/dlb2_hw_types.h     |  367 ++++
 drivers/event/dlb2/pf/base/dlb2_mbox.h         |  596 ++++++
 drivers/event/dlb2/pf/base/dlb2_osdep.h        |  247 +++
 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h |  440 +++++
 drivers/event/dlb2/pf/base/dlb2_osdep_list.h   |  131 ++
 drivers/event/dlb2/pf/base/dlb2_osdep_types.h  |   31 +
 drivers/event/dlb2/pf/base/dlb2_regs.h         | 2527 ++++++++++++++++++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.c     |  274 +++
 drivers/event/dlb2/pf/base/dlb2_resource.h     | 1913 ++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c              |  615 ++++++
 drivers/event/dlb2/pf/dlb2_main.h              |  106 +
 drivers/event/dlb2/pf/dlb2_pf.c                |  244 +++
 16 files changed, 8085 insertions(+), 1 deletion(-)
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_hw_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_mbox.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_list.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_regs.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.c
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.c
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_pf.c
drivers/event/dlb2/dlb2.c new file +532 -0
new file mode 100644
index 0000000..26985b9
@@ -0,0 +1,532 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <nmmintrin.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/fcntl.h>
+
+#include <rte_common.h>
+#include <rte_config.h>
+#include <rte_cycles.h>
+#include <rte_debug.h>
+#include <rte_dev.h>
+#include <rte_errno.h>
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+#include <rte_io.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+#include <rte_malloc.h>
+#include <rte_mbuf.h>
+#include <rte_prefetch.h>
+#include <rte_ring.h>
+#include <rte_string_fns.h>
+
+#include "dlb2_priv.h"
+#include "dlb2_iface.h"
+#include "dlb2_inline_fns.h"
+
+#if !defined RTE_ARCH_X86_64
+#error "This implementation only supports RTE_ARCH_X86_64 architecture."
+#endif
+
+/*
+ * Resources exposed to eventdev. Some values overridden at runtime using
+ * values returned by the DLB kernel driver.
+ */
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV > UINT8_MAX)
+#error "RTE_EVENT_MAX_QUEUES_PER_DEV cannot fit in member max_event_queues"
+#endif
+static struct rte_event_dev_info evdev_dlb2_default_info = {
+	.driver_name = "", /* probe will set */
+	.min_dequeue_timeout_ns = DLB2_MIN_DEQUEUE_TIMEOUT_NS,
+	.max_dequeue_timeout_ns = DLB2_MAX_DEQUEUE_TIMEOUT_NS,
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV < DLB2_MAX_NUM_LDB_QUEUES)
+	.max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
+#else
+	.max_event_queues = DLB2_MAX_NUM_LDB_QUEUES,
+#endif
+	.max_event_queue_flows = DLB2_MAX_NUM_FLOWS,
+	.max_event_queue_priority_levels = DLB2_QID_PRIORITIES,
+	.max_event_priority_levels = DLB2_QID_PRIORITIES,
+	.max_event_ports = DLB2_MAX_NUM_LDB_PORTS,
+	.max_event_port_dequeue_depth = DLB2_MAX_CQ_DEPTH,
+	.max_event_port_enqueue_depth = DLB2_MAX_ENQUEUE_DEPTH,
+	.max_event_port_links = DLB2_MAX_NUM_QIDS_PER_LDB_CQ,
+	.max_num_events = DLB2_MAX_NUM_LDB_CREDITS,
+	.max_single_link_event_port_queue_pairs = DLB2_MAX_NUM_DIR_PORTS,
+	.event_dev_cap = (RTE_EVENT_DEV_CAP_QUEUE_QOS |
+			  RTE_EVENT_DEV_CAP_EVENT_QOS |
+			  RTE_EVENT_DEV_CAP_BURST_MODE |
+			  RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
+			  RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE |
+			  RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES),
+};
+
+struct process_local_port_data
+dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
+
+/* override defaults with value(s) provided on command line */
+static void
+dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,
+				 int *qid_depth_thresholds)
+{
+	int q;
+
+	for (q = 0; q < DLB2_MAX_NUM_QUEUES; q++) {
+		if (qid_depth_thresholds[q] != 0)
+			dlb2->ev_queues[q].depth_threshold =
+				qid_depth_thresholds[q];
+	}
+}
+
+static int
+dlb2_hw_query_resources(struct dlb2_eventdev *dlb2)
+{
+	struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+	struct dlb2_hw_resource_info *dlb2_info = &handle->info;
+	int ret;
+
+	/* Query driver resources provisioned for this device */
+
+	ret = dlb2_iface_get_num_resources(handle,
+					   &dlb2->hw_rsrc_query_results);
+	if (ret) {
+		DLB2_LOG_ERR("ioctl get dlb2 num resources, err=%d\n", ret);
+		return ret;
+	}
+
+	/* Complete filling in device resource info returned to evdev app,
+	 * overriding any default values.
+	 * The capabilities (CAPs) were set at compile time.
+	 */
+
+	evdev_dlb2_default_info.max_event_queues =
+		dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+	evdev_dlb2_default_info.max_event_ports =
+		dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+	evdev_dlb2_default_info.max_num_events =
+		dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+	/* Save off values used when creating the scheduling domain. */
+
+	handle->info.num_sched_domains =
+		dlb2->hw_rsrc_query_results.num_sched_domains;
+
+	handle->info.hw_rsrc_max.nb_events_limit =
+		dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+	handle->info.hw_rsrc_max.num_queues =
+		dlb2->hw_rsrc_query_results.num_ldb_queues +
+		dlb2->hw_rsrc_query_results.num_dir_ports;
+
+	handle->info.hw_rsrc_max.num_ldb_queues =
+		dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+	handle->info.hw_rsrc_max.num_ldb_ports =
+		dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+	handle->info.hw_rsrc_max.num_dir_ports =
+		dlb2->hw_rsrc_query_results.num_dir_ports;
+
+	handle->info.hw_rsrc_max.reorder_window_size =
+		dlb2->hw_rsrc_query_results.num_hist_list_entries;
+
+	rte_memcpy(dlb2_info, &handle->info.hw_rsrc_max, sizeof(*dlb2_info));
+
+	return 0;
+}
+
+#define RTE_BASE_10 10
+
+static int
+dlb2_string_to_int(int *result, const char *str)
+{
+	long ret;
+	char *endptr;
+
+	if (str == NULL || result == NULL)
+		return -EINVAL;
+
+	errno = 0;
+	ret = strtol(str, &endptr, RTE_BASE_10);
+	if (errno)
+		return -errno;
+
+	/* long int and int may be different width for some architectures */
+	if (ret < INT_MIN || ret > INT_MAX || endptr == str)
+		return -EINVAL;
+
+	*result = ret;
+	return 0;
+}
+
+static int
+set_numa_node(const char *key __rte_unused, const char *value, void *opaque)
+{
+	int *socket_id = opaque;
+	int ret;
+
+	ret = dlb2_string_to_int(socket_id, value);
+	if (ret < 0)
+		return ret;
+
+	if (*socket_id > RTE_MAX_NUMA_NODES)
+		return -EINVAL;
+	return 0;
+}
+
+static int
+set_max_num_events(const char *key __rte_unused,
+		   const char *value,
+		   void *opaque)
+{
+	int *max_num_events = opaque;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(max_num_events, value);
+	if (ret < 0)
+		return ret;
+
+	if (*max_num_events < 0 || *max_num_events >
+			DLB2_MAX_NUM_LDB_CREDITS) {
+		DLB2_LOG_ERR("dlb2: max_num_events must be between 0 and %d\n",
+			     DLB2_MAX_NUM_LDB_CREDITS);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+set_num_dir_credits(const char *key __rte_unused,
+		    const char *value,
+		    void *opaque)
+{
+	int *num_dir_credits = opaque;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(num_dir_credits, value);
+	if (ret < 0)
+		return ret;
+
+	if (*num_dir_credits < 0 ||
+	    *num_dir_credits > DLB2_MAX_NUM_DIR_CREDITS) {
+		DLB2_LOG_ERR("dlb2: num_dir_credits must be between 0 and %d\n",
+			     DLB2_MAX_NUM_DIR_CREDITS);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+set_dev_id(const char *key __rte_unused,
+	   const char *value,
+	   void *opaque)
+{
+	int *dev_id = opaque;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(dev_id, value);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int
+set_cos(const char *key __rte_unused,
+	const char *value,
+	void *opaque)
+{
+	enum dlb2_cos *cos_id = opaque;
+	int x = 0;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(&x, value);
+	if (ret < 0)
+		return ret;
+
+	if (x != DLB2_COS_DEFAULT && (x < DLB2_COS_0 || x > DLB2_COS_3)) {
+		DLB2_LOG_ERR(
+			"COS %d out of range, must be DLB2_COS_DEFAULT or 0-3\n",
+			x);
+		return -EINVAL;
+	}
+
+	*cos_id = x;
+
+	return 0;
+}
+
+
+static int
+set_qid_depth_thresh(const char *key __rte_unused,
+		     const char *value,
+		     void *opaque)
+{
+	struct dlb2_qid_depth_thresholds *qid_thresh = opaque;
+	int first, last, thresh, i;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	/* command line override may take one of the following 3 forms:
+	 * qid_depth_thresh=all:<threshold_value> ... all queues
+	 * qid_depth_thresh=qidA-qidB:<threshold_value> ... a range of queues
+	 * qid_depth_thresh=qid:<threshold_value> ... just one queue
+	 */
+	if (sscanf(value, "all:%d", &thresh) == 1) {
+		first = 0;
+		last = DLB2_MAX_NUM_QUEUES - 1;
+	} else if (sscanf(value, "%d-%d:%d", &first, &last, &thresh) == 3) {
+		/* we have everything we need */
+	} else if (sscanf(value, "%d:%d", &first, &thresh) == 2) {
+		last = first;
+	} else {
+		DLB2_LOG_ERR("Error parsing qid depth devarg. Should be all:val, qid-qid:val, or qid:val\n");
+		return -EINVAL;
+	}
+
+	if (first > last || first < 0 || last >= DLB2_MAX_NUM_QUEUES) {
+		DLB2_LOG_ERR("Error parsing qid depth devarg, invalid qid value\n");
+		return -EINVAL;
+	}
+
+	if (thresh < 0 || thresh > DLB2_MAX_QUEUE_DEPTH_THRESHOLD) {
+		DLB2_LOG_ERR("Error parsing qid depth devarg, threshold > %d\n",
+			     DLB2_MAX_QUEUE_DEPTH_THRESHOLD);
+		return -EINVAL;
+	}
+
+	for (i = first; i <= last; i++)
+		qid_thresh->val[i] = thresh; /* indexed by qid */
+
+	return 0;
+}
+
+static void
+dlb2_entry_points_init(struct rte_eventdev *dev)
+{
+	RTE_SET_USED(dev);
+
+	/* Eventdev PMD entry points */
+}
+
+int
+dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
+			    const char *name,
+			    struct dlb2_devargs *dlb2_args)
+{
+	struct dlb2_eventdev *dlb2;
+	int err;
+
+	dlb2 = dev->data->dev_private;
+
+	dlb2->event_dev = dev; /* backlink */
+
+	evdev_dlb2_default_info.driver_name = name;
+
+	dlb2->max_num_events_override = dlb2_args->max_num_events;
+	dlb2->num_dir_credits_override = dlb2_args->num_dir_credits_override;
+	dlb2->qm_instance.cos_id = dlb2_args->cos_id;
+
+	err = dlb2_iface_open(&dlb2->qm_instance, name);
+	if (err < 0) {
+		DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+			     err);
+		return err;
+	}
+
+	err = dlb2_iface_get_device_version(&dlb2->qm_instance,
+					    &dlb2->revision);
+	if (err < 0) {
+		DLB2_LOG_ERR("dlb2: failed to get the device version, err=%d\n",
+			     err);
+		return err;
+	}
+
+	err = dlb2_hw_query_resources(dlb2);
+	if (err) {
+		DLB2_LOG_ERR("get resources err=%d for %s\n",
+			     err, name);
+		return err;
+	}
+
+	dlb2_iface_hardware_init(&dlb2->qm_instance);
+
+	err = dlb2_iface_get_cq_poll_mode(&dlb2->qm_instance, &dlb2->poll_mode);
+	if (err < 0) {
+		DLB2_LOG_ERR("dlb2: failed to get the poll mode, err=%d\n",
+			     err);
+		return err;
+	}
+
+	rte_spinlock_init(&dlb2->qm_instance.resource_lock);
+
+	dlb2_iface_low_level_io_init();
+
+	dlb2_entry_points_init(dev);
+
+	dlb2_init_queue_depth_thresholds(dlb2,
+					 dlb2_args->qid_depth_thresholds.val);
+
+	return 0;
+}
+
+int
+dlb2_secondary_eventdev_probe(struct rte_eventdev *dev,
+			      const char *name)
+{
+	struct dlb2_eventdev *dlb2;
+	int err;
+
+	dlb2 = dev->data->dev_private;
+
+	evdev_dlb2_default_info.driver_name = name;
+
+	err = dlb2_iface_open(&dlb2->qm_instance, name);
+	if (err < 0) {
+		DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+			     err);
+		return err;
+	}
+
+	err = dlb2_hw_query_resources(dlb2);
+	if (err) {
+		DLB2_LOG_ERR("get resources err=%d for %s\n",
+			     err, name);
+		return err;
+	}
+
+	dlb2_iface_low_level_io_init();
+
+	dlb2_entry_points_init(dev);
+
+	return 0;
+}
+
+int
+dlb2_parse_params(const char *params,
+		  const char *name,
+		  struct dlb2_devargs *dlb2_args)
+{
+	int ret = 0;
+	static const char * const args[] = { NUMA_NODE_ARG,
+					     DLB2_MAX_NUM_EVENTS,
+					     DLB2_NUM_DIR_CREDITS,
+					     DEV_ID_ARG,
+					     DLB2_QID_DEPTH_THRESH_ARG,
+					     DLB2_COS_ARG,
+					     NULL };
+
+	if (params != NULL && params[0] != '\0') {
+		struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
+
+		if (kvlist == NULL) {
+			RTE_LOG(INFO, PMD,
+				"Ignoring unsupported parameters when creating device '%s'\n",
+				name);
+		} else {
+			int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
+						     set_numa_node,
+						     &dlb2_args->socket_id);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing numa node parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			ret = rte_kvargs_process(kvlist, DLB2_MAX_NUM_EVENTS,
+						 set_max_num_events,
+						 &dlb2_args->max_num_events);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing max_num_events parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			ret = rte_kvargs_process(kvlist,
+					DLB2_NUM_DIR_CREDITS,
+					set_num_dir_credits,
+					&dlb2_args->num_dir_credits_override);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing num_dir_credits parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			ret = rte_kvargs_process(kvlist, DEV_ID_ARG,
+						 set_dev_id,
+						 &dlb2_args->dev_id);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing dev_id parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			ret = rte_kvargs_process(
+					kvlist,
+					DLB2_QID_DEPTH_THRESH_ARG,
+					set_qid_depth_thresh,
+					&dlb2_args->qid_depth_thresholds);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing qid_depth_thresh parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			ret = rte_kvargs_process(kvlist, DLB2_COS_ARG,
+						 set_cos,
+						 &dlb2_args->cos_id);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing cos parameter",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
+			rte_kvargs_free(kvlist);
+		}
+	}
+	return ret;
+}
+RTE_LOG_REGISTER(eventdev_dlb2_log_level, pmd.event.dlb2, NOTICE);
drivers/event/dlb2/dlb2_iface.c new file +28 -0
new file mode 100644
index 0000000..0d93faf
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <stdint.h>
+
+#include "dlb2_priv.h"
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+void (*dlb2_iface_low_level_io_init)(void);
+
+int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char *name);
+
+int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+				     uint8_t *revision);
+
+void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+				   enum dlb2_cq_poll_modes *mode);
+
+int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+				    struct dlb2_get_num_resources_args *rsrcs);
drivers/event/dlb2/dlb2_iface.h new file +29 -0
new file mode 100644
index 0000000..4fb416e
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_IFACE_H_
+#define _DLB2_IFACE_H_
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+extern void (*dlb2_iface_low_level_io_init)(void);
+
+extern int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char *name);
+
+extern int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+					    uint8_t *revision);
+
+extern void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+extern int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+					  enum dlb2_cq_poll_modes *mode);
+
+extern int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+				struct dlb2_get_num_resources_args *rsrcs);
+
+#endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/meson.build +5 -1
index 54ba2c8..99b71f9 100644
@@ -1,7 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
-sources = files(
+sources = files('dlb2.c',
+		'dlb2_iface.c',
+		'pf/dlb2_main.c',
+		'pf/dlb2_pf.c',
+		'pf/base/dlb2_resource.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +367 -0

367 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_mbox.h new file +596 -0

596 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_osdep.h new file +247 -0

247 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h new file +440 -0

440 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_osdep_list.h new file +131 -0

131 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_osdep_types.h new file +31 -0
new file mode 100644
index 0000000..0a48f7e
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_TYPES_H
+#define __DLB2_OSDEP_TYPES_H
+
+#include <linux/types.h>
+
+#include <inttypes.h>
+#include <ctype.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Types for user mode PF PMD */
+typedef uint8_t         u8;
+typedef int8_t          s8;
+typedef uint16_t        u16;
+typedef int16_t         s16;
+typedef uint32_t        u32;
+typedef int32_t         s32;
+typedef uint64_t        u64;
+
+#define __iomem
+
+/* END types for user mode PF PMD */
+
+#endif /* __DLB2_OSDEP_TYPES_H */
drivers/event/dlb2/pf/base/dlb2_regs.h new file +2527 -0

587 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_resource.c new file +274 -0

274 lines not on this page · raw message

drivers/event/dlb2/pf/base/dlb2_resource.h new file +1913 -0

1,913 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.c new file +615 -0

615 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_main.h new file +106 -0

106 lines not on this page · raw message

drivers/event/dlb2/pf/dlb2_pf.c new file +244 -0

244 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.6.4

Part of the diff is not shown here. View the raw message.

#222 lore raw

Re: [dpdk-dev] [PATCH v2 06/22] event/dlb2: add probe

Quoted 12 lines · Timothy McDaniel

The DLB2 hardware is a PCI device. This commit adds support for probe and other initialization. The dlb2_iface.[ch] files implement a flexible interface that supports both the PF PMD and the bifurcated PMD. The bifurcated PMD will be released in a future patch set. Note that the flexible interface is only used for configuration, and is not used in the data path. The shared code is added in pf/base. This PMD supports command line parameters, and those are parsed at probe-time.

Quoted 1 line

There is a build issue clang10.

[for-main]dell[dpdk-next-eventdev] $ clang -v
clang version 10.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/8.4.0 Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.4.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.4.0 Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0 Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

meson -Dexamples=l3fwd --buildtype=debugoptimized --werror --default-library=static /export/dpdk-next-eventdev/devtools/.. ./build-clang-static

ccache clang -Idrivers/libtmp_rte_pmd_dlb2_event.a.p -Idrivers -I../drivers -Idrivers/event/dlb2 -I../drivers/event/dlb2 -Ilib/librte_eventdev -I../lib/librte_eventdev -I. -I.. -Iconfig -I../config -Ilib/librte_eal/include -I../lib/librte_e al/include -Ilib/librte_eal/linux/include -I../lib/librte_eal/linux/include -Ilib/librte_eal/x86/include -I../lib/librte_eal/x86/include -Ilib/librte_eal/common -I../lib/librte_eal/common -Ilib/librte_eal -I../lib/librte_eal -Ilib/librte_kv
args -I../lib/librte_kvargs -Ilib/librte_metrics -I../lib/librte_metrics -Ilib/librte_telemetry -I../lib/librte_telemetry -Ilib/librte_ring -I../lib/librte_ring -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net -I../lib/librte_net
-Ilib/librte_mbuf -I../lib/librte_mbuf -Ilib/librte_mempool
-I../lib/librte_mempool -Ilib/librte_meter -I../lib/librte_meter -Ilib/librte_hash -I../lib/librte_hash -Ilib/librte_timer -I../lib/librte_timer -Ilib/librte_cryptodev -I../lib/li brte_cryptodev -Ilib/librte_pci -I../lib/librte_pci -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O2 -g -include rte_config.h -Wextra
-Wcast-qual -Wdeprecated -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-pa cked-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -MD -MQ drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_pf_dlb2_pf.c.o -MF drivers/libtmp_rte_pmd_dlb2_event.a.p/ev ent_dlb2_pf_dlb2_pf.c.o.d -o drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_pf_dlb2_pf.c.o -c ../drivers/event/dlb2/pf/dlb2_pf.c
In file included from ../drivers/event/dlb2/pf/dlb2_pf.c:36:
../drivers/event/dlb2/pf/../dlb2_inline_fns.h:45:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
        ^

../drivers/event/dlb2/pf/../dlb2_inline_fns.h:45:2: note: did you mean '__builtin_ia32_movntq'? /usr/lib/clang/10.0.1/include/xmmintrin.h:2122:3: note:
'__builtin_ia32_movntq' declared here
__builtin_ia32_movntq(__p, __a);
^
In file included from ../drivers/event/dlb2/pf/dlb2_pf.c:36:
../drivers/event/dlb2/pf/../dlb2_inline_fns.h:61:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
        ^

2 errors generated.
[2124/2479] Compiling C object drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o
FAILED: drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o ccache clang -Idrivers/libtmp_rte_pmd_dlb2_event.a.p -Idrivers -I../drivers -Idrivers/event/dlb2 -I../drivers/event/dlb2 -Ilib/librte_eventdev -I../lib/librte_eventdev -I. -I.. -Iconfig -I../config -Ilib/librte_eal/include -I../lib/librte_e al/include -Ilib/librte_eal/linux/include -I../lib/librte_eal/linux/include -Ilib/librte_eal/x86/include -I../lib/librte_eal/x86/include -Ilib/librte_eal/common -I../lib/librte_eal/common -Ilib/librte_eal -I../lib/librte_eal -Ilib/librte_kv
args -I../lib/librte_kvargs -Ilib/librte_metrics -I../lib/librte_metrics -Ilib/librte_telemetry -I../lib/librte_telemetry -Ilib/librte_ring -I../lib/librte_ring -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net -I../lib/librte_net
-Ilib/librte_mbuf -I../lib/librte_mbuf -Ilib/librte_mempool
-I../lib/librte_mempool -Ilib/librte_meter -I../lib/librte_meter -Ilib/librte_hash -I../lib/librte_hash -Ilib/librte_timer -I../lib/librte_timer -Ilib/librte_cryptodev -I../lib/li brte_cryptodev -Ilib/librte_pci -I../lib/librte_pci -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O2 -g -include rte_config.h -Wextra
-Wcast-qual -Wdeprecated -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-pa cked-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -MD -MQ drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o -MF drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dl b2_dlb2.c.o.d -o drivers/libtmp_rte_pmd_dlb2_event.a.p/event_dlb2_dlb2.c.o -c ../drivers/event/dlb2/dlb2.c
In file included from ../drivers/event/dlb2/dlb2.c:35:
../drivers/event/dlb2/dlb2_inline_fns.h:45:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr + 0, (__v2di)src_data0);
        ^

../drivers/event/dlb2/dlb2_inline_fns.h:45:2: note: did you mean '__builtin_ia32_movntq'? /usr/lib/clang/10.0.1/include/xmmintrin.h:2122:3: note:
'__builtin_ia32_movntq' declared here
__builtin_ia32_movntq(__p, __a);
^
In file included from ../drivers/event/dlb2/dlb2.c:35:
../drivers/event/dlb2/dlb2_inline_fns.h:61:2: error: use of unknown builtin '__builtin_ia32_movntdq' [-Wimplicit-function-declaration]

        __builtin_ia32_movntdq((__v2di *)pp_addr, (__v2di)src_data0);
        ^

2 errors generated.
[2125/2479] Generating rte_common_sfc_efx.sym_chk with a meson_exe.py custom command
ninja: build stopped: subcommand failed.

Quoted 8,224 lines
---
 drivers/event/dlb2/dlb2.c                      |  532 +++++
 drivers/event/dlb2/dlb2_iface.c                |   28 +
 drivers/event/dlb2/dlb2_iface.h                |   29 +
 drivers/event/dlb2/meson.build                 |    6 +-
 drivers/event/dlb2/pf/base/dlb2_hw_types.h     |  367 ++++
 drivers/event/dlb2/pf/base/dlb2_mbox.h         |  596 ++++++
 drivers/event/dlb2/pf/base/dlb2_osdep.h        |  247 +++
 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h |  440 +++++
 drivers/event/dlb2/pf/base/dlb2_osdep_list.h   |  131 ++
 drivers/event/dlb2/pf/base/dlb2_osdep_types.h  |   31 +
 drivers/event/dlb2/pf/base/dlb2_regs.h         | 2527 ++++++++++++++++++++++++
 drivers/event/dlb2/pf/base/dlb2_resource.c     |  274 +++
 drivers/event/dlb2/pf/base/dlb2_resource.h     | 1913 ++++++++++++++++++
 drivers/event/dlb2/pf/dlb2_main.c              |  615 ++++++
 drivers/event/dlb2/pf/dlb2_main.h              |  106 +
 drivers/event/dlb2/pf/dlb2_pf.c                |  244 +++
 16 files changed, 8085 insertions(+), 1 deletion(-)
 create mode 100644 drivers/event/dlb2/dlb2.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.c
 create mode 100644 drivers/event/dlb2/dlb2_iface.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_hw_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_mbox.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_list.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_osdep_types.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_regs.h
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.c
 create mode 100644 drivers/event/dlb2/pf/base/dlb2_resource.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.c
 create mode 100644 drivers/event/dlb2/pf/dlb2_main.h
 create mode 100644 drivers/event/dlb2/pf/dlb2_pf.c
drivers/event/dlb2/dlb2.c new file +532 -0
new file mode 100644
index 0000000..26985b9
@@ -0,0 +1,532 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <nmmintrin.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/fcntl.h>
+
+#include <rte_common.h>
+#include <rte_config.h>
+#include <rte_cycles.h>
+#include <rte_debug.h>
+#include <rte_dev.h>
+#include <rte_errno.h>
+#include <rte_eventdev.h>
+#include <rte_eventdev_pmd.h>
+#include <rte_io.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+#include <rte_malloc.h>
+#include <rte_mbuf.h>
+#include <rte_prefetch.h>
+#include <rte_ring.h>
+#include <rte_string_fns.h>
+
+#include "dlb2_priv.h"
+#include "dlb2_iface.h"
+#include "dlb2_inline_fns.h"
+
+#if !defined RTE_ARCH_X86_64
+#error "This implementation only supports RTE_ARCH_X86_64 architecture."
+#endif
+
+/*
+ * Resources exposed to eventdev. Some values overridden at runtime using
+ * values returned by the DLB kernel driver.
+ */
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV > UINT8_MAX)
+#error "RTE_EVENT_MAX_QUEUES_PER_DEV cannot fit in member max_event_queues"
+#endif
+static struct rte_event_dev_info evdev_dlb2_default_info = {
+       .driver_name = "", /* probe will set */
+       .min_dequeue_timeout_ns = DLB2_MIN_DEQUEUE_TIMEOUT_NS,
+       .max_dequeue_timeout_ns = DLB2_MAX_DEQUEUE_TIMEOUT_NS,
+#if (RTE_EVENT_MAX_QUEUES_PER_DEV < DLB2_MAX_NUM_LDB_QUEUES)
+       .max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
+#else
+       .max_event_queues = DLB2_MAX_NUM_LDB_QUEUES,
+#endif
+       .max_event_queue_flows = DLB2_MAX_NUM_FLOWS,
+       .max_event_queue_priority_levels = DLB2_QID_PRIORITIES,
+       .max_event_priority_levels = DLB2_QID_PRIORITIES,
+       .max_event_ports = DLB2_MAX_NUM_LDB_PORTS,
+       .max_event_port_dequeue_depth = DLB2_MAX_CQ_DEPTH,
+       .max_event_port_enqueue_depth = DLB2_MAX_ENQUEUE_DEPTH,
+       .max_event_port_links = DLB2_MAX_NUM_QIDS_PER_LDB_CQ,
+       .max_num_events = DLB2_MAX_NUM_LDB_CREDITS,
+       .max_single_link_event_port_queue_pairs = DLB2_MAX_NUM_DIR_PORTS,
+       .event_dev_cap = (RTE_EVENT_DEV_CAP_QUEUE_QOS |
+                         RTE_EVENT_DEV_CAP_EVENT_QOS |
+                         RTE_EVENT_DEV_CAP_BURST_MODE |
+                         RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
+                         RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE |
+                         RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES),
+};
+
+struct process_local_port_data
+dlb2_port[DLB2_MAX_NUM_PORTS][DLB2_NUM_PORT_TYPES];
+
+/* override defaults with value(s) provided on command line */
+static void
+dlb2_init_queue_depth_thresholds(struct dlb2_eventdev *dlb2,
+                                int *qid_depth_thresholds)
+{
+       int q;
+
+       for (q = 0; q < DLB2_MAX_NUM_QUEUES; q++) {
+               if (qid_depth_thresholds[q] != 0)
+                       dlb2->ev_queues[q].depth_threshold =
+                               qid_depth_thresholds[q];
+       }
+}
+
+static int
+dlb2_hw_query_resources(struct dlb2_eventdev *dlb2)
+{
+       struct dlb2_hw_dev *handle = &dlb2->qm_instance;
+       struct dlb2_hw_resource_info *dlb2_info = &handle->info;
+       int ret;
+
+       /* Query driver resources provisioned for this device */
+
+       ret = dlb2_iface_get_num_resources(handle,
+                                          &dlb2->hw_rsrc_query_results);
+       if (ret) {
+               DLB2_LOG_ERR("ioctl get dlb2 num resources, err=%d\n", ret);
+               return ret;
+       }
+
+       /* Complete filling in device resource info returned to evdev app,
+        * overriding any default values.
+        * The capabilities (CAPs) were set at compile time.
+        */
+
+       evdev_dlb2_default_info.max_event_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+       evdev_dlb2_default_info.max_event_ports =
+               dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+       evdev_dlb2_default_info.max_num_events =
+               dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+       /* Save off values used when creating the scheduling domain. */
+
+       handle->info.num_sched_domains =
+               dlb2->hw_rsrc_query_results.num_sched_domains;
+
+       handle->info.hw_rsrc_max.nb_events_limit =
+               dlb2->hw_rsrc_query_results.num_ldb_credits;
+
+       handle->info.hw_rsrc_max.num_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues +
+               dlb2->hw_rsrc_query_results.num_dir_ports;
+
+       handle->info.hw_rsrc_max.num_ldb_queues =
+               dlb2->hw_rsrc_query_results.num_ldb_queues;
+
+       handle->info.hw_rsrc_max.num_ldb_ports =
+               dlb2->hw_rsrc_query_results.num_ldb_ports;
+
+       handle->info.hw_rsrc_max.num_dir_ports =
+               dlb2->hw_rsrc_query_results.num_dir_ports;
+
+       handle->info.hw_rsrc_max.reorder_window_size =
+               dlb2->hw_rsrc_query_results.num_hist_list_entries;
+
+       rte_memcpy(dlb2_info, &handle->info.hw_rsrc_max, sizeof(*dlb2_info));
+
+       return 0;
+}
+
+#define RTE_BASE_10 10
+
+static int
+dlb2_string_to_int(int *result, const char *str)
+{
+       long ret;
+       char *endptr;
+
+       if (str == NULL || result == NULL)
+               return -EINVAL;
+
+       errno = 0;
+       ret = strtol(str, &endptr, RTE_BASE_10);
+       if (errno)
+               return -errno;
+
+       /* long int and int may be different width for some architectures */
+       if (ret < INT_MIN || ret > INT_MAX || endptr == str)
+               return -EINVAL;
+
+       *result = ret;
+       return 0;
+}
+
+static int
+set_numa_node(const char *key __rte_unused, const char *value, void *opaque)
+{
+       int *socket_id = opaque;
+       int ret;
+
+       ret = dlb2_string_to_int(socket_id, value);
+       if (ret < 0)
+               return ret;
+
+       if (*socket_id > RTE_MAX_NUMA_NODES)
+               return -EINVAL;
+       return 0;
+}
+
+static int
+set_max_num_events(const char *key __rte_unused,
+                  const char *value,
+                  void *opaque)
+{
+       int *max_num_events = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(max_num_events, value);
+       if (ret < 0)
+               return ret;
+
+       if (*max_num_events < 0 || *max_num_events >
+                       DLB2_MAX_NUM_LDB_CREDITS) {
+               DLB2_LOG_ERR("dlb2: max_num_events must be between 0 and %d\n",
+                            DLB2_MAX_NUM_LDB_CREDITS);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int
+set_num_dir_credits(const char *key __rte_unused,
+                   const char *value,
+                   void *opaque)
+{
+       int *num_dir_credits = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(num_dir_credits, value);
+       if (ret < 0)
+               return ret;
+
+       if (*num_dir_credits < 0 ||
+           *num_dir_credits > DLB2_MAX_NUM_DIR_CREDITS) {
+               DLB2_LOG_ERR("dlb2: num_dir_credits must be between 0 and %d\n",
+                            DLB2_MAX_NUM_DIR_CREDITS);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int
+set_dev_id(const char *key __rte_unused,
+          const char *value,
+          void *opaque)
+{
+       int *dev_id = opaque;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(dev_id, value);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int
+set_cos(const char *key __rte_unused,
+       const char *value,
+       void *opaque)
+{
+       enum dlb2_cos *cos_id = opaque;
+       int x = 0;
+       int ret;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       ret = dlb2_string_to_int(&x, value);
+       if (ret < 0)
+               return ret;
+
+       if (x != DLB2_COS_DEFAULT && (x < DLB2_COS_0 || x > DLB2_COS_3)) {
+               DLB2_LOG_ERR(
+                       "COS %d out of range, must be DLB2_COS_DEFAULT or 0-3\n",
+                       x);
+               return -EINVAL;
+       }
+
+       *cos_id = x;
+
+       return 0;
+}
+
+
+static int
+set_qid_depth_thresh(const char *key __rte_unused,
+                    const char *value,
+                    void *opaque)
+{
+       struct dlb2_qid_depth_thresholds *qid_thresh = opaque;
+       int first, last, thresh, i;
+
+       if (value == NULL || opaque == NULL) {
+               DLB2_LOG_ERR("NULL pointer\n");
+               return -EINVAL;
+       }
+
+       /* command line override may take one of the following 3 forms:
+        * qid_depth_thresh=all:<threshold_value> ... all queues
+        * qid_depth_thresh=qidA-qidB:<threshold_value> ... a range of queues
+        * qid_depth_thresh=qid:<threshold_value> ... just one queue
+        */
+       if (sscanf(value, "all:%d", &thresh) == 1) {
+               first = 0;
+               last = DLB2_MAX_NUM_QUEUES - 1;
+       } else if (sscanf(value, "%d-%d:%d", &first, &last, &thresh) == 3) {
+               /* we have everything we need */
+       } else if (sscanf(value, "%d:%d", &first, &thresh) == 2) {
+               last = first;
+       } else {
+               DLB2_LOG_ERR("Error parsing qid depth devarg. Should be all:val, qid-qid:val, or qid:val\n");
+               return -EINVAL;
+       }
+
+       if (first > last || first < 0 || last >= DLB2_MAX_NUM_QUEUES) {
+               DLB2_LOG_ERR("Error parsing qid depth devarg, invalid qid value\n");
+               return -EINVAL;
+       }
+
+       if (thresh < 0 || thresh > DLB2_MAX_QUEUE_DEPTH_THRESHOLD) {
+               DLB2_LOG_ERR("Error parsing qid depth devarg, threshold > %d\n",
+                            DLB2_MAX_QUEUE_DEPTH_THRESHOLD);
+               return -EINVAL;
+       }
+
+       for (i = first; i <= last; i++)
+               qid_thresh->val[i] = thresh; /* indexed by qid */
+
+       return 0;
+}
+
+static void
+dlb2_entry_points_init(struct rte_eventdev *dev)
+{
+       RTE_SET_USED(dev);
+
+       /* Eventdev PMD entry points */
+}
+
+int
+dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
+                           const char *name,
+                           struct dlb2_devargs *dlb2_args)
+{
+       struct dlb2_eventdev *dlb2;
+       int err;
+
+       dlb2 = dev->data->dev_private;
+
+       dlb2->event_dev = dev; /* backlink */
+
+       evdev_dlb2_default_info.driver_name = name;
+
+       dlb2->max_num_events_override = dlb2_args->max_num_events;
+       dlb2->num_dir_credits_override = dlb2_args->num_dir_credits_override;
+       dlb2->qm_instance.cos_id = dlb2_args->cos_id;
+
+       err = dlb2_iface_open(&dlb2->qm_instance, name);
+       if (err < 0) {
+               DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_iface_get_device_version(&dlb2->qm_instance,
+                                           &dlb2->revision);
+       if (err < 0) {
+               DLB2_LOG_ERR("dlb2: failed to get the device version, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_hw_query_resources(dlb2);
+       if (err) {
+               DLB2_LOG_ERR("get resources err=%d for %s\n",
+                            err, name);
+               return err;
+       }
+
+       dlb2_iface_hardware_init(&dlb2->qm_instance);
+
+       err = dlb2_iface_get_cq_poll_mode(&dlb2->qm_instance, &dlb2->poll_mode);
+       if (err < 0) {
+               DLB2_LOG_ERR("dlb2: failed to get the poll mode, err=%d\n",
+                            err);
+               return err;
+       }
+
+       rte_spinlock_init(&dlb2->qm_instance.resource_lock);
+
+       dlb2_iface_low_level_io_init();
+
+       dlb2_entry_points_init(dev);
+
+       dlb2_init_queue_depth_thresholds(dlb2,
+                                        dlb2_args->qid_depth_thresholds.val);
+
+       return 0;
+}
+
+int
+dlb2_secondary_eventdev_probe(struct rte_eventdev *dev,
+                             const char *name)
+{
+       struct dlb2_eventdev *dlb2;
+       int err;
+
+       dlb2 = dev->data->dev_private;
+
+       evdev_dlb2_default_info.driver_name = name;
+
+       err = dlb2_iface_open(&dlb2->qm_instance, name);
+       if (err < 0) {
+               DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
+                            err);
+               return err;
+       }
+
+       err = dlb2_hw_query_resources(dlb2);
+       if (err) {
+               DLB2_LOG_ERR("get resources err=%d for %s\n",
+                            err, name);
+               return err;
+       }
+
+       dlb2_iface_low_level_io_init();
+
+       dlb2_entry_points_init(dev);
+
+       return 0;
+}
+
+int
+dlb2_parse_params(const char *params,
+                 const char *name,
+                 struct dlb2_devargs *dlb2_args)
+{
+       int ret = 0;
+       static const char * const args[] = { NUMA_NODE_ARG,
+                                            DLB2_MAX_NUM_EVENTS,
+                                            DLB2_NUM_DIR_CREDITS,
+                                            DEV_ID_ARG,
+                                            DLB2_QID_DEPTH_THRESH_ARG,
+                                            DLB2_COS_ARG,
+                                            NULL };
+
+       if (params != NULL && params[0] != '\0') {
+               struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
+
+               if (kvlist == NULL) {
+                       RTE_LOG(INFO, PMD,
+                               "Ignoring unsupported parameters when creating device '%s'\n",
+                               name);
+               } else {
+                       int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
+                                                    set_numa_node,
+                                                    &dlb2_args->socket_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing numa node parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DLB2_MAX_NUM_EVENTS,
+                                                set_max_num_events,
+                                                &dlb2_args->max_num_events);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing max_num_events parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist,
+                                       DLB2_NUM_DIR_CREDITS,
+                                       set_num_dir_credits,
+                                       &dlb2_args->num_dir_credits_override);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing num_dir_credits parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DEV_ID_ARG,
+                                                set_dev_id,
+                                                &dlb2_args->dev_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing dev_id parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(
+                                       kvlist,
+                                       DLB2_QID_DEPTH_THRESH_ARG,
+                                       set_qid_depth_thresh,
+                                       &dlb2_args->qid_depth_thresholds);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing qid_depth_thresh parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       ret = rte_kvargs_process(kvlist, DLB2_COS_ARG,
+                                                set_cos,
+                                                &dlb2_args->cos_id);
+                       if (ret != 0) {
+                               DLB2_LOG_ERR("%s: Error parsing cos parameter",
+                                            name);
+                               rte_kvargs_free(kvlist);
+                               return ret;
+                       }
+
+                       rte_kvargs_free(kvlist);
+               }
+       }
+       return ret;
+}
+RTE_LOG_REGISTER(eventdev_dlb2_log_level, pmd.event.dlb2, NOTICE);
drivers/event/dlb2/dlb2_iface.c new file +28 -0
new file mode 100644
index 0000000..0d93faf
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#include <stdint.h>
+
+#include "dlb2_priv.h"
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+void (*dlb2_iface_low_level_io_init)(void);
+
+int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char *name);
+
+int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+                                    uint8_t *revision);
+
+void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+                                  enum dlb2_cq_poll_modes *mode);
+
+int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+                                   struct dlb2_get_num_resources_args *rsrcs);
drivers/event/dlb2/dlb2_iface.h new file +29 -0
new file mode 100644
index 0000000..4fb416e
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef _DLB2_IFACE_H_
+#define _DLB2_IFACE_H_
+
+/* DLB2 PMD Internal interface function pointers.
+ * If VDEV (bifurcated PMD),  these will resolve to functions that issue ioctls
+ * serviced by DLB kernel module.
+ * If PCI (PF PMD),  these will be implemented locally in user mode.
+ */
+
+extern void (*dlb2_iface_low_level_io_init)(void);
+
+extern int (*dlb2_iface_open)(struct dlb2_hw_dev *handle, const char *name);
+
+extern int (*dlb2_iface_get_device_version)(struct dlb2_hw_dev *handle,
+                                           uint8_t *revision);
+
+extern void (*dlb2_iface_hardware_init)(struct dlb2_hw_dev *handle);
+
+extern int (*dlb2_iface_get_cq_poll_mode)(struct dlb2_hw_dev *handle,
+                                         enum dlb2_cq_poll_modes *mode);
+
+extern int (*dlb2_iface_get_num_resources)(struct dlb2_hw_dev *handle,
+                               struct dlb2_get_num_resources_args *rsrcs);
+
+#endif /* _DLB2_IFACE_H_ */
drivers/event/dlb2/meson.build +5 -1
index 54ba2c8..99b71f9 100644
@@ -1,7 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
-sources = files(
+sources = files('dlb2.c',
+               'dlb2_iface.c',
+               'pf/dlb2_main.c',
+               'pf/dlb2_pf.c',
+               'pf/base/dlb2_resource.c'
 )
 
 deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci']
drivers/event/dlb2/pf/base/dlb2_hw_types.h new file +367 -0
new file mode 100644
index 0000000..428a5e8
@@ -0,0 +1,367 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_HW_TYPES_H
+#define __DLB2_HW_TYPES_H
+
+#include "dlb2_user.h"
+
+#include "dlb2_osdep_list.h"
+#include "dlb2_osdep_types.h"
+
+#define DLB2_MAX_NUM_VDEVS                     16
+#define DLB2_MAX_NUM_DOMAINS                   32
+#define DLB2_MAX_NUM_LDB_QUEUES                        32 /* LDB == load-balanced */
+#define DLB2_MAX_NUM_DIR_QUEUES                        64 /* DIR == directed */
+#define DLB2_MAX_NUM_LDB_PORTS                 64
+#define DLB2_MAX_NUM_DIR_PORTS                 64
+#define DLB2_MAX_NUM_LDB_CREDITS               (8 * 1024)
+#define DLB2_MAX_NUM_DIR_CREDITS               (2 * 1024)
+#define DLB2_MAX_NUM_HIST_LIST_ENTRIES         2048
+#define DLB2_MAX_NUM_AQED_ENTRIES              2048
+#define DLB2_MAX_NUM_QIDS_PER_LDB_CQ           8
+#define DLB2_MAX_NUM_SEQUENCE_NUMBER_GROUPS    2
+#define DLB2_MAX_NUM_SEQUENCE_NUMBER_MODES     5
+#define DLB2_QID_PRIORITIES                    8
+#define DLB2_NUM_ARB_WEIGHTS                   8
+#define DLB2_MAX_WEIGHT                                255
+#define DLB2_NUM_COS_DOMAINS                   4
+#define DLB2_MAX_CQ_COMP_CHECK_LOOPS           409600
+#define DLB2_MAX_QID_EMPTY_CHECK_LOOPS         (32 * 64 * 1024 * (800 / 30))
+#ifdef FPGA
+#define DLB2_HZ                                        2000000
+#else
+#define DLB2_HZ                                        800000000
+#endif
+
+#define PCI_DEVICE_ID_INTEL_DLB2_PF 0x2710
+#define PCI_DEVICE_ID_INTEL_DLB2_VF 0x2711
+
+/* Interrupt related macros */
+#define DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS 1
+#define DLB2_PF_NUM_CQ_INTERRUPT_VECTORS     64
+#define DLB2_PF_TOTAL_NUM_INTERRUPT_VECTORS \
+       (DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS + \
+        DLB2_PF_NUM_CQ_INTERRUPT_VECTORS)
+#define DLB2_PF_NUM_COMPRESSED_MODE_VECTORS \
+       (DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS + 1)
+#define DLB2_PF_NUM_PACKED_MODE_VECTORS \
+       DLB2_PF_TOTAL_NUM_INTERRUPT_VECTORS
+#define DLB2_PF_COMPRESSED_MODE_CQ_VECTOR_ID \
+       DLB2_PF_NUM_NON_CQ_INTERRUPT_VECTORS
+
+/* DLB non-CQ interrupts (alarm, mailbox, WDT) */
+#define DLB2_INT_NON_CQ 0
+
+#define DLB2_ALARM_HW_SOURCE_SYS 0
+#define DLB2_ALARM_HW_SOURCE_DLB 1
+
+#define DLB2_ALARM_HW_UNIT_CHP 4
+
+#define DLB2_ALARM_SYS_AID_ILLEGAL_QID         3
+#define DLB2_ALARM_SYS_AID_DISABLED_QID                4
+#define DLB2_ALARM_SYS_AID_ILLEGAL_HCW         5
+#define DLB2_ALARM_HW_CHP_AID_ILLEGAL_ENQ      1
+#define DLB2_ALARM_HW_CHP_AID_EXCESS_TOKEN_POPS 2
+
+#define DLB2_VF_NUM_NON_CQ_INTERRUPT_VECTORS 1
+#define DLB2_VF_NUM_CQ_INTERRUPT_VECTORS     31
+#define DLB2_VF_BASE_CQ_VECTOR_ID           0
+#define DLB2_VF_LAST_CQ_VECTOR_ID           30
+#define DLB2_VF_MBOX_VECTOR_ID              31
+#define DLB2_VF_TOTAL_NUM_INTERRUPT_VECTORS \
+       (DLB2_VF_NUM_NON_CQ_INTERRUPT_VECTORS + \
+        DLB2_VF_NUM_CQ_INTERRUPT_VECTORS)
+
+#define DLB2_VDEV_MAX_NUM_INTERRUPT_VECTORS (DLB2_MAX_NUM_LDB_PORTS + \
+                                            DLB2_MAX_NUM_DIR_PORTS + 1)
+
+/*
+ * Hardware-defined base addresses. Those prefixed 'DLB2_DRV' are only used by
+ * the PF driver.
+ */
+#define DLB2_DRV_LDB_PP_BASE   0x2300000
+#define DLB2_DRV_LDB_PP_STRIDE 0x1000
+#define DLB2_DRV_LDB_PP_BOUND  (DLB2_DRV_LDB_PP_BASE + \
+                               DLB2_DRV_LDB_PP_STRIDE * DLB2_MAX_NUM_LDB_PORTS)
+#define DLB2_DRV_DIR_PP_BASE   0x2200000
+#define DLB2_DRV_DIR_PP_STRIDE 0x1000
+#define DLB2_DRV_DIR_PP_BOUND  (DLB2_DRV_DIR_PP_BASE + \
+                               DLB2_DRV_DIR_PP_STRIDE * DLB2_MAX_NUM_DIR_PORTS)
+#define DLB2_LDB_PP_BASE       0x2100000
+#define DLB2_LDB_PP_STRIDE     0x1000
+#define DLB2_LDB_PP_BOUND      (DLB2_LDB_PP_BASE + \
+                               DLB2_LDB_PP_STRIDE * DLB2_MAX_NUM_LDB_PORTS)
+#define DLB2_LDB_PP_OFFS(id)   (DLB2_LDB_PP_BASE + (id) * DLB2_PP_SIZE)
+#define DLB2_DIR_PP_BASE       0x2000000
+#define DLB2_DIR_PP_STRIDE     0x1000
+#define DLB2_DIR_PP_BOUND      (DLB2_DIR_PP_BASE + \
+                               DLB2_DIR_PP_STRIDE * DLB2_MAX_NUM_DIR_PORTS)
+#define DLB2_DIR_PP_OFFS(id)   (DLB2_DIR_PP_BASE + (id) * DLB2_PP_SIZE)
+
+struct dlb2_resource_id {
+       u32 phys_id;
+       u32 virt_id;
+       u8 vdev_owned;
+       u8 vdev_id;
+};
+
+struct dlb2_freelist {
+       u32 base;
+       u32 bound;
+       u32 offset;
+};
+
+static inline u32 dlb2_freelist_count(struct dlb2_freelist *list)
+{
+       return list->bound - list->base - list->offset;
+}
+
+struct dlb2_hcw {
+       u64 data;
+       /* Word 3 */
+       u16 opaque;
+       u8 qid;
+       u8 sched_type:2;
+       u8 priority:3;
+       u8 msg_type:3;
+       /* Word 4 */
+       u16 lock_id;
+       u8 ts_flag:1;
+       u8 rsvd1:2;
+       u8 no_dec:1;
+       u8 cmp_id:4;
+       u8 cq_token:1;
+       u8 qe_comp:1;
+       u8 qe_frag:1;
+       u8 qe_valid:1;
+       u8 int_arm:1;
+       u8 error:1;
+       u8 rsvd:2;
+};
+
+struct dlb2_ldb_queue {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       u32 num_qid_inflights;
+       u32 aqed_limit;
+       u32 sn_group; /* sn == sequence number */
+       u32 sn_slot;
+       u32 num_mappings;
+       u8 sn_cfg_valid;
+       u8 num_pending_additions;
+       u8 owned;
+       u8 configured;
+};
+
+/*
+ * Directed ports and queues are paired by nature, so the driver tracks them
+ * with a single data structure.
+ */
+struct dlb2_dir_pq_pair {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       u32 ref_cnt;
+       u8 init_tkn_cnt;
+       u8 queue_configured;
+       u8 port_configured;
+       u8 owned;
+       u8 enabled;
+};
+
+enum dlb2_qid_map_state {
+       /* The slot doesn't contain a valid queue mapping */
+       DLB2_QUEUE_UNMAPPED,
+       /* The slot contains a valid queue mapping */
+       DLB2_QUEUE_MAPPED,
+       /* The driver is mapping a queue into this slot */
+       DLB2_QUEUE_MAP_IN_PROG,
+       /* The driver is unmapping a queue from this slot */
+       DLB2_QUEUE_UNMAP_IN_PROG,
+       /*
+        * The driver is unmapping a queue from this slot, and once complete
+        * will replace it with another mapping.
+        */
+       DLB2_QUEUE_UNMAP_IN_PROG_PENDING_MAP,
+};
+
+struct dlb2_ldb_port_qid_map {
+       enum dlb2_qid_map_state state;
+       u16 qid;
+       u16 pending_qid;
+       u8 priority;
+       u8 pending_priority;
+};
+
+struct dlb2_ldb_port {
+       struct dlb2_list_entry domain_list;
+       struct dlb2_list_entry func_list;
+       struct dlb2_resource_id id;
+       struct dlb2_resource_id domain_id;
+       /* The qid_map represents the hardware QID mapping state. */
+       struct dlb2_ldb_port_qid_map qid_map[DLB2_MAX_NUM_QIDS_PER_LDB_CQ];
+       u32 hist_list_entry_base;
+       u32 hist_list_entry_limit;
+       u32 ref_cnt;
+       u8 init_tkn_cnt;
+       u8 num_pending_removals;
+       u8 num_mappings;
+       u8 owned;
+       u8 enabled;
+       u8 configured;
+};
+
+struct dlb2_sn_group {
+       u32 mode;
+       u32 sequence_numbers_per_queue;
+       u32 slot_use_bitmap;
+       u32 id;
+};
+
+static inline bool dlb2_sn_group_full(struct dlb2_sn_group *group)
+{
+       u32 mask[] = {
+               0x0000ffff,  /* 64 SNs per queue */
+               0x000000ff,  /* 128 SNs per queue */
+               0x0000000f,  /* 256 SNs per queue */
+               0x00000003,  /* 512 SNs per queue */
+               0x00000001}; /* 1024 SNs per queue */
+
+       return group->slot_use_bitmap == mask[group->mode];
+}
+
+static inline int dlb2_sn_group_alloc_slot(struct dlb2_sn_group *group)
+{
+       u32 bound[6] = {16, 8, 4, 2, 1};
+       u32 i;
+
+       for (i = 0; i < bound[group->mode]; i++) {
+               if (!(group->slot_use_bitmap & (1 << i))) {
+                       group->slot_use_bitmap |= 1 << i;
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+static inline void
+dlb2_sn_group_free_slot(struct dlb2_sn_group *group, int slot)
+{
+       group->slot_use_bitmap &= ~(1 << slot);
+}
+
+static inline int dlb2_sn_group_used_slots(struct dlb2_sn_group *group)
+{
+       int i, cnt = 0;
+
+       for (i = 0; i < 32; i++)
+               cnt += !!(group->slot_use_bitmap & (1 << i));
+
+       return cnt;
+}
+
+struct dlb2_hw_domain {
+       struct dlb2_function_resources *parent_func;
+       struct dlb2_list_entry func_list;
+       struct dlb2_list_head used_ldb_queues;
+       struct dlb2_list_head used_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head used_dir_pq_pairs;
+       struct dlb2_list_head avail_ldb_queues;
+       struct dlb2_list_head avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head avail_dir_pq_pairs;
+       u32 total_hist_list_entries;
+       u32 avail_hist_list_entries;
+       u32 hist_list_entry_base;
+       u32 hist_list_entry_offset;
+       u32 num_ldb_credits;
+       u32 num_dir_credits;
+       u32 num_avail_aqed_entries;
+       u32 num_used_aqed_entries;
+       struct dlb2_resource_id id;
+       int num_pending_removals;
+       int num_pending_additions;
+       u8 configured;
+       u8 started;
+};
+
+struct dlb2_bitmap;
+
+struct dlb2_function_resources {
+       struct dlb2_list_head avail_domains;
+       struct dlb2_list_head used_domains;
+       struct dlb2_list_head avail_ldb_queues;
+       struct dlb2_list_head avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       struct dlb2_list_head avail_dir_pq_pairs;
+       struct dlb2_bitmap *avail_hist_list_entries;
+       u32 num_avail_domains;
+       u32 num_avail_ldb_queues;
+       u32 num_avail_ldb_ports[DLB2_NUM_COS_DOMAINS];
+       u32 num_avail_dir_pq_pairs;
+       u32 num_avail_qed_entries;
+       u32 num_avail_dqed_entries;
+       u32 num_avail_aqed_entries;
+       u8 locked; /* (VDEV only) */
+};
+
+/*
+ * After initialization, each resource in dlb2_hw_resources is located in one
+ * of the following lists:
+ * -- The PF's available resources list. These are unconfigured resources owned
+ *     by the PF and not allocated to a dlb2 scheduling domain.
+ * -- A VDEV's available resources list. These are VDEV-owned unconfigured
+ *     resources not allocated to a dlb2 scheduling domain.
+ * -- A domain's available resources list. These are domain-owned unconfigured
+ *     resources.
+ * -- A domain's used resources list. These are are domain-owned configured
+ *     resources.
+ *
+ * A resource moves to a new list when a VDEV or domain is created or destroyed,
+ * or when the resource is configured.
+ */
+struct dlb2_hw_resources {
+       struct dlb2_ldb_queue ldb_queues[DLB2_MAX_NUM_LDB_QUEUES];
+       struct dlb2_ldb_port ldb_ports[DLB2_MAX_NUM_LDB_PORTS];
+       struct dlb2_dir_pq_pair dir_pq_pairs[DLB2_MAX_NUM_DIR_PORTS];
+       struct dlb2_sn_group sn_groups[DLB2_MAX_NUM_SEQUENCE_NUMBER_GROUPS];
+};
+
+struct dlb2_mbox {
+       u32 *mbox;
+       u32 *isr_in_progress;
+};
+
+struct dlb2_sw_mbox {
+       struct dlb2_mbox vdev_to_pf;
+       struct dlb2_mbox pf_to_vdev;
+       void (*pf_to_vdev_inject)(void *arg);
+       void *pf_to_vdev_inject_arg;
+};
+
+struct dlb2_hw {
+       /* BAR 0 address */
+       void  *csr_kva;
+       unsigned long csr_phys_addr;
+       /* BAR 2 address */
+       void  *func_kva;
+       unsigned long func_phys_addr;
+
+       /* Resource tracking */
+       struct dlb2_hw_resources rsrcs;
+       struct dlb2_function_resources pf;
+       struct dlb2_function_resources vdev[DLB2_MAX_NUM_VDEVS];
+       struct dlb2_hw_domain domains[DLB2_MAX_NUM_DOMAINS];
+       u8 cos_reservation[DLB2_NUM_COS_DOMAINS];
+
+       /* Virtualization */
+       int virt_mode;
+       struct dlb2_sw_mbox mbox[DLB2_MAX_NUM_VDEVS];
+       unsigned int pasid[DLB2_MAX_NUM_VDEVS];
+};
+
+#endif /* __DLB2_HW_TYPES_H */
drivers/event/dlb2/pf/base/dlb2_mbox.h new file +596 -0
new file mode 100644
index 0000000..ce462c0
@@ -0,0 +1,596 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_BASE_DLB2_MBOX_H
+#define __DLB2_BASE_DLB2_MBOX_H
+
+#include "dlb2_osdep_types.h"
+#include "dlb2_regs.h"
+
+#define DLB2_MBOX_INTERFACE_VERSION 1
+
+/*
+ * The PF uses its PF->VF mailbox to send responses to VF requests, as well as
+ * to send requests of its own (e.g. notifying a VF of an impending FLR).
+ * To avoid communication race conditions, e.g. the PF sends a response and then
+ * sends a request before the VF reads the response, the PF->VF mailbox is
+ * divided into two sections:
+ * - Bytes 0-47: PF responses
+ * - Bytes 48-63: PF requests
+ *
+ * Partitioning the PF->VF mailbox allows responses and requests to occupy the
+ * mailbox simultaneously.
+ */
+#define DLB2_PF2VF_RESP_BYTES    48
+#define DLB2_PF2VF_RESP_BASE     0
+#define DLB2_PF2VF_RESP_BASE_WORD (DLB2_PF2VF_RESP_BASE / 4)
+
+#define DLB2_PF2VF_REQ_BYTES     16
+#define DLB2_PF2VF_REQ_BASE      (DLB2_PF2VF_RESP_BASE + DLB2_PF2VF_RESP_BYTES)
+#define DLB2_PF2VF_REQ_BASE_WORD  (DLB2_PF2VF_REQ_BASE / 4)
+
+/*
+ * Similarly, the VF->PF mailbox is divided into two sections:
+ * - Bytes 0-239: VF requests
+ * -- (Bytes 0-3 are unused due to a hardware errata)
+ * - Bytes 240-255: VF responses
+ */
+#define DLB2_VF2PF_REQ_BYTES    236
+#define DLB2_VF2PF_REQ_BASE     4
+#define DLB2_VF2PF_REQ_BASE_WORD (DLB2_VF2PF_REQ_BASE / 4)
+
+#define DLB2_VF2PF_RESP_BYTES    16
+#define DLB2_VF2PF_RESP_BASE     (DLB2_VF2PF_REQ_BASE + DLB2_VF2PF_REQ_BYTES)
+#define DLB2_VF2PF_RESP_BASE_WORD (DLB2_VF2PF_RESP_BASE / 4)
+
+/* VF-initiated commands */
+enum dlb2_mbox_cmd_type {
+       DLB2_MBOX_CMD_REGISTER,
+       DLB2_MBOX_CMD_UNREGISTER,
+       DLB2_MBOX_CMD_GET_NUM_RESOURCES,
+       DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN,
+       DLB2_MBOX_CMD_RESET_SCHED_DOMAIN,
+       DLB2_MBOX_CMD_CREATE_LDB_QUEUE,
+       DLB2_MBOX_CMD_CREATE_DIR_QUEUE,
+       DLB2_MBOX_CMD_CREATE_LDB_PORT,
+       DLB2_MBOX_CMD_CREATE_DIR_PORT,
+       DLB2_MBOX_CMD_ENABLE_LDB_PORT,
+       DLB2_MBOX_CMD_DISABLE_LDB_PORT,
+       DLB2_MBOX_CMD_ENABLE_DIR_PORT,
+       DLB2_MBOX_CMD_DISABLE_DIR_PORT,
+       DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN,
+       DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN,
+       DLB2_MBOX_CMD_MAP_QID,
+       DLB2_MBOX_CMD_UNMAP_QID,
+       DLB2_MBOX_CMD_START_DOMAIN,
+       DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR,
+       DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR,
+       DLB2_MBOX_CMD_ARM_CQ_INTR,
+       DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES,
+       DLB2_MBOX_CMD_GET_SN_ALLOCATION,
+       DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH,
+       DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH,
+       DLB2_MBOX_CMD_PENDING_PORT_UNMAPS,
+       DLB2_MBOX_CMD_GET_COS_BW,
+       DLB2_MBOX_CMD_GET_SN_OCCUPANCY,
+       DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE,
+
+       /* NUM_QE_CMD_TYPES must be last */
+       NUM_DLB2_MBOX_CMD_TYPES,
+};
+
+static const char dlb2_mbox_cmd_type_strings[][128] = {
+       "DLB2_MBOX_CMD_REGISTER",
+       "DLB2_MBOX_CMD_UNREGISTER",
+       "DLB2_MBOX_CMD_GET_NUM_RESOURCES",
+       "DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN",
+       "DLB2_MBOX_CMD_RESET_SCHED_DOMAIN",
+       "DLB2_MBOX_CMD_CREATE_LDB_QUEUE",
+       "DLB2_MBOX_CMD_CREATE_DIR_QUEUE",
+       "DLB2_MBOX_CMD_CREATE_LDB_PORT",
+       "DLB2_MBOX_CMD_CREATE_DIR_PORT",
+       "DLB2_MBOX_CMD_ENABLE_LDB_PORT",
+       "DLB2_MBOX_CMD_DISABLE_LDB_PORT",
+       "DLB2_MBOX_CMD_ENABLE_DIR_PORT",
+       "DLB2_MBOX_CMD_DISABLE_DIR_PORT",
+       "DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN",
+       "DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN",
+       "DLB2_MBOX_CMD_MAP_QID",
+       "DLB2_MBOX_CMD_UNMAP_QID",
+       "DLB2_MBOX_CMD_START_DOMAIN",
+       "DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR",
+       "DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR",
+       "DLB2_MBOX_CMD_ARM_CQ_INTR",
+       "DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES",
+       "DLB2_MBOX_CMD_GET_SN_ALLOCATION",
+       "DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH",
+       "DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH",
+       "DLB2_MBOX_CMD_PENDING_PORT_UNMAPS",
+       "DLB2_MBOX_CMD_GET_COS_BW",
+       "DLB2_MBOX_CMD_GET_SN_OCCUPANCY",
+       "DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE",
+};
+
+/* PF-initiated commands */
+enum dlb2_mbox_vf_cmd_type {
+       DLB2_MBOX_VF_CMD_DOMAIN_ALERT,
+       DLB2_MBOX_VF_CMD_NOTIFICATION,
+       DLB2_MBOX_VF_CMD_IN_USE,
+
+       /* NUM_DLB2_MBOX_VF_CMD_TYPES must be last */
+       NUM_DLB2_MBOX_VF_CMD_TYPES,
+};
+
+static const char dlb2_mbox_vf_cmd_type_strings[][128] = {
+       "DLB2_MBOX_VF_CMD_DOMAIN_ALERT",
+       "DLB2_MBOX_VF_CMD_NOTIFICATION",
+       "DLB2_MBOX_VF_CMD_IN_USE",
+};
+
+#define DLB2_MBOX_CMD_TYPE(hdr) \
+       (((struct dlb2_mbox_req_hdr *)hdr)->type)
+#define DLB2_MBOX_CMD_STRING(hdr) \
+       dlb2_mbox_cmd_type_strings[DLB2_MBOX_CMD_TYPE(hdr)]
+
+enum dlb2_mbox_status_type {
+       DLB2_MBOX_ST_SUCCESS,
+       DLB2_MBOX_ST_INVALID_CMD_TYPE,
+       DLB2_MBOX_ST_VERSION_MISMATCH,
+       DLB2_MBOX_ST_INVALID_OWNER_VF,
+};
+
+static const char dlb2_mbox_status_type_strings[][128] = {
+       "DLB2_MBOX_ST_SUCCESS",
+       "DLB2_MBOX_ST_INVALID_CMD_TYPE",
+       "DLB2_MBOX_ST_VERSION_MISMATCH",
+       "DLB2_MBOX_ST_INVALID_OWNER_VF",
+};
+
+#define DLB2_MBOX_ST_TYPE(hdr) \
+       (((struct dlb2_mbox_resp_hdr *)hdr)->status)
+#define DLB2_MBOX_ST_STRING(hdr) \
+       dlb2_mbox_status_type_strings[DLB2_MBOX_ST_TYPE(hdr)]
+
+/* This structure is always the first field in a request structure */
+struct dlb2_mbox_req_hdr {
+       u32 type;
+};
+
+/* This structure is always the first field in a response structure */
+struct dlb2_mbox_resp_hdr {
+       u32 status;
+};
+
+struct dlb2_mbox_register_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 min_interface_version;
+       u16 max_interface_version;
+};
+
+struct dlb2_mbox_register_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 interface_version;
+       u8 pf_id;
+       u8 vf_id;
+       u8 is_auxiliary_vf;
+       u8 primary_vf_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_unregister_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_unregister_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_num_resources_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_num_resources_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u16 num_sched_domains;
+       u16 num_ldb_queues;
+       u16 num_ldb_ports;
+       u16 num_cos_ldb_ports[4];
+       u16 num_dir_ports;
+       u32 num_atomic_inflights;
+       u32 num_hist_list_entries;
+       u32 max_contiguous_hist_list_entries;
+       u16 num_ldb_credits;
+       u16 num_dir_credits;
+};
+
+struct dlb2_mbox_create_sched_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 num_ldb_queues;
+       u32 num_ldb_ports;
+       u32 num_cos_ldb_ports[4];
+       u32 num_dir_ports;
+       u32 num_atomic_inflights;
+       u32 num_hist_list_entries;
+       u32 num_ldb_credits;
+       u32 num_dir_credits;
+       u8 cos_strict;
+       u8 padding0[3];
+       u32 padding1;
+};
+
+struct dlb2_mbox_create_sched_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_reset_sched_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 id;
+};
+
+struct dlb2_mbox_reset_sched_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+};
+
+struct dlb2_mbox_create_ldb_queue_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 num_sequence_numbers;
+       u32 num_qid_inflights;
+       u32 num_atomic_inflights;
+       u32 lock_id_comp_level;
+       u32 depth_threshold;
+       u32 padding;
+};
+
+struct dlb2_mbox_create_ldb_queue_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_dir_queue_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 depth_threshold;
+};
+
+struct dlb2_mbox_create_dir_queue_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u16 cq_depth;
+       u16 cq_history_list_size;
+       u8 cos_id;
+       u8 cos_strict;
+       u16 padding1;
+       u64 cq_base_address;
+};
+
+struct dlb2_mbox_create_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_create_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u64 cq_base_address;
+       u16 cq_depth;
+       u16 padding0;
+       s32 queue_id;
+};
+
+struct dlb2_mbox_create_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_enable_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_ldb_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_ldb_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_dir_port_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_disable_dir_port_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_ldb_port_owned_by_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_ldb_port_owned_by_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       s32 owned;
+};
+
+struct dlb2_mbox_dir_port_owned_by_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_dir_port_owned_by_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       s32 owned;
+};
+
+struct dlb2_mbox_map_qid_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 qid;
+       u32 priority;
+       u32 padding0;
+};
+
+struct dlb2_mbox_map_qid_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 id;
+};
+
+struct dlb2_mbox_unmap_qid_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 qid;
+};
+
+struct dlb2_mbox_unmap_qid_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_start_domain_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+};
+
+struct dlb2_mbox_start_domain_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_ldb_port_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 port_id;
+       u16 thresh;
+       u16 vector;
+       u16 owner_vf;
+       u16 reserved[2];
+};
+
+struct dlb2_mbox_enable_ldb_port_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_enable_dir_port_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u16 port_id;
+       u16 thresh;
+       u16 vector;
+       u16 owner_vf;
+       u16 reserved[2];
+};
+
+struct dlb2_mbox_enable_dir_port_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding;
+};
+
+struct dlb2_mbox_arm_cq_intr_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 is_ldb;
+};
+
+struct dlb2_mbox_arm_cq_intr_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 padding0;
+};
+
+/*
+ * The alert_id and aux_alert_data follows the format of the alerts defined in
+ * dlb2_types.h. The alert id contains an enum dlb2_domain_alert_id value, and
+ * the aux_alert_data value varies depending on the alert.
+ */
+struct dlb2_mbox_vf_alert_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 alert_id;
+       u32 aux_alert_data;
+};
+
+enum dlb2_mbox_vf_notification_type {
+       DLB2_MBOX_VF_NOTIFICATION_PRE_RESET,
+       DLB2_MBOX_VF_NOTIFICATION_POST_RESET,
+
+       /* NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES must be last */
+       NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES,
+};
+
+struct dlb2_mbox_vf_notification_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 notification;
+};
+
+struct dlb2_mbox_vf_in_use_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_vf_in_use_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 in_use;
+};
+
+struct dlb2_mbox_get_sn_allocation_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 group_id;
+};
+
+struct dlb2_mbox_get_sn_allocation_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_get_ldb_queue_depth_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 queue_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_ldb_queue_depth_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 depth;
+};
+
+struct dlb2_mbox_get_dir_queue_depth_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 queue_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_get_dir_queue_depth_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 depth;
+};
+
+struct dlb2_mbox_pending_port_unmaps_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 domain_id;
+       u32 port_id;
+       u32 padding;
+};
+
+struct dlb2_mbox_pending_port_unmaps_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 num;
+};
+
+struct dlb2_mbox_get_cos_bw_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 cos_id;
+};
+
+struct dlb2_mbox_get_cos_bw_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_get_sn_occupancy_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 group_id;
+};
+
+struct dlb2_mbox_get_sn_occupancy_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 num;
+};
+
+struct dlb2_mbox_query_cq_poll_mode_cmd_req {
+       struct dlb2_mbox_req_hdr hdr;
+       u32 padding;
+};
+
+struct dlb2_mbox_query_cq_poll_mode_cmd_resp {
+       struct dlb2_mbox_resp_hdr hdr;
+       u32 error_code;
+       u32 status;
+       u32 mode;
+};
+
+#endif /* __DLB2_BASE_DLB2_MBOX_H */
drivers/event/dlb2/pf/base/dlb2_osdep.h new file +247 -0
new file mode 100644
index 0000000..43f2125
@@ -0,0 +1,247 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_H
+#define __DLB2_OSDEP_H
+
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <rte_string_fns.h>
+#include <rte_cycles.h>
+#include <rte_io.h>
+#include <rte_log.h>
+#include <rte_spinlock.h>
+#include "../dlb2_main.h"
+#include "dlb2_resource.h"
+#include "../../dlb2_log.h"
+#include "../../dlb2_user.h"
+
+
+#define DLB2_PCI_REG_READ(addr)        rte_read32((void *)addr)
+#define DLB2_PCI_REG_WRITE(reg, value) rte_write32(value, (void *)reg)
+
+/* Read/write register 'reg' in the CSR BAR space */
+#define DLB2_CSR_REG_ADDR(a, reg) ((void *)((uintptr_t)(a)->csr_kva + (reg)))
+#define DLB2_CSR_RD(hw, reg) \
+       DLB2_PCI_REG_READ(DLB2_CSR_REG_ADDR((hw), (reg)))
+#define DLB2_CSR_WR(hw, reg, value) \
+       DLB2_PCI_REG_WRITE(DLB2_CSR_REG_ADDR((hw), (reg)), (value))
+
+/* Read/write register 'reg' in the func BAR space */
+#define DLB2_FUNC_REG_ADDR(a, reg) ((void *)((uintptr_t)(a)->func_kva + (reg)))
+#define DLB2_FUNC_RD(hw, reg) \
+       DLB2_PCI_REG_READ(DLB2_FUNC_REG_ADDR((hw), (reg)))
+#define DLB2_FUNC_WR(hw, reg, value) \
+       DLB2_PCI_REG_WRITE(DLB2_FUNC_REG_ADDR((hw), (reg)), (value))
+
+/* Map to PMDs logging interface */
+#define DLB2_ERR(dev, fmt, args...) \
+       DLB2_LOG_ERR(fmt, ## args)
+
+#define DLB2_INFO(dev, fmt, args...) \
+       DLB2_LOG_INFO(fmt, ## args)
+
+#define DLB2_DEBUG(dev, fmt, args...) \
+       DLB2_LOG_DBG(fmt, ## args)
+
+/**
+ * os_udelay() - busy-wait for a number of microseconds
+ * @usecs: delay duration.
+ */
+static inline void os_udelay(int usecs)
+{
+       rte_delay_us(usecs);
+}
+
+/**
+ * os_msleep() - sleep for a number of milliseconds
+ * @usecs: delay duration.
+ */
+static inline void os_msleep(int msecs)
+{
+       rte_delay_ms(msecs);
+}
+
+#define DLB2_PP_BASE(__is_ldb) \
+       ((__is_ldb) ? DLB2_LDB_PP_BASE : DLB2_DIR_PP_BASE)
+
+/**
+ * os_map_producer_port() - map a producer port into the caller's address space
+ * @hw: dlb2_hw handle for a particular device.
+ * @port_id: port ID
+ * @is_ldb: true for load-balanced port, false for a directed port
+ *
+ * This function maps the requested producer port memory into the caller's
+ * address space.
+ *
+ * Return:
+ * Returns the base address at which the PP memory was mapped, else NULL.
+ */
+static inline void *os_map_producer_port(struct dlb2_hw *hw,
+                                        u8 port_id,
+                                        bool is_ldb)
+{
+       uint64_t addr;
+       uint64_t pp_dma_base;
+
+       pp_dma_base = (uintptr_t)hw->func_kva + DLB2_PP_BASE(is_ldb);
+       addr = (pp_dma_base + (PAGE_SIZE * port_id));
+
+       return (void *)(uintptr_t)addr;
+}
+
+/**
+ * os_unmap_producer_port() - unmap a producer port
+ * @addr: mapped producer port address
+ *
+ * This function undoes os_map_producer_port() by unmapping the producer port
+ * memory from the caller's address space.
+ *
+ * Return:
+ * Returns the base address at which the PP memory was mapped, else NULL.
+ */
+static inline void os_unmap_producer_port(struct dlb2_hw *hw, void *addr)
+{
+       RTE_SET_USED(hw);
+       RTE_SET_USED(addr);
+}
+
+/**
+ * os_fence_hcw() - fence an HCW to ensure it arrives at the device
+ * @hw: dlb2_hw handle for a particular device.
+ * @pp_addr: producer port address
+ */
+static inline void os_fence_hcw(struct dlb2_hw *hw, u64 *pp_addr)
+{
+       RTE_SET_USED(hw);
+
+       /* To ensure outstanding HCWs reach the device, read the PP address. IA
+        * memory ordering prevents reads from passing older writes, and the
+        * mfence also ensures this.
+        */
+       rte_mb();
+
+       *(volatile u64 *)pp_addr;
+}
+
+/**
+ * os_enqueue_four_hcws() - enqueue four HCWs to DLB
+ * @hw: dlb2_hw handle for a particular device.
+ * @hcw: pointer to the 64B-aligned contiguous HCW memory
+ * @addr: producer port address
+ */
+static inline void os_enqueue_four_hcws(struct dlb2_hw *hw,
+                                       struct dlb2_hcw *hcw,
+                                       void *addr)
+{
+       struct dlb2_dev *dlb2_dev;
+
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       dlb2_dev->enqueue_four(hcw, addr);
+}
+
+/**
+ * DLB2_HW_ERR() - log an error message
+ * @dlb2: dlb2_hw handle for a particular device.
+ * @...: variable string args.
+ */
+#define DLB2_HW_ERR(dlb2, ...) do {    \
+       RTE_SET_USED(dlb2);             \
+       DLB2_ERR(dlb2, __VA_ARGS__);    \
+} while (0)
+
+/**
+ * DLB2_HW_DBG() - log an info message
+ * @dlb2: dlb2_hw handle for a particular device.
+ * @...: variable string args.
+ */
+#define DLB2_HW_DBG(dlb2, ...) do {    \
+       RTE_SET_USED(dlb2);             \
+       DLB2_DEBUG(dlb2, __VA_ARGS__);  \
+} while (0)
+
+/* The callback runs until it completes all outstanding QID->CQ
+ * map and unmap requests. To prevent deadlock, this function gives other
+ * threads a chance to grab the resource mutex and configure hardware.
+ */
+static void *dlb2_complete_queue_map_unmap(void *__args)
+{
+       struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)__args;
+       int ret;
+
+       while (1) {
+               rte_spinlock_lock(&dlb2_dev->resource_mutex);
+
+               ret = dlb2_finish_unmap_qid_procedures(&dlb2_dev->hw);
+               ret += dlb2_finish_map_qid_procedures(&dlb2_dev->hw);
+
+               if (ret != 0) {
+                       rte_spinlock_unlock(&dlb2_dev->resource_mutex);
+                       /* Relinquish the CPU so the application can process
+                        * its CQs, so this function doesn't deadlock.
+                        */
+                       sched_yield();
+               } else {
+                       break;
+               }
+       }
+
+       dlb2_dev->worker_launched = false;
+
+       rte_spinlock_unlock(&dlb2_dev->resource_mutex);
+
+       return NULL;
+}
+
+
+/**
+ * os_schedule_work() - launch a thread to process pending map and unmap work
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function launches a kernel thread that will run until all pending
+ * map and unmap procedures are complete.
+ */
+static inline void os_schedule_work(struct dlb2_hw *hw)
+{
+       struct dlb2_dev *dlb2_dev;
+       pthread_t complete_queue_map_unmap_thread;
+       int ret;
+
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread,
+                                    "dlb_queue_unmap_waiter",
+                                    NULL,
+                                    dlb2_complete_queue_map_unmap,
+                                    dlb2_dev);
+       if (ret)
+               DLB2_ERR(dlb2_dev,
+                        "Could not create queue complete map/unmap thread, err=%d\n",
+                        ret);
+       else
+               dlb2_dev->worker_launched = true;
+}
+
+/**
+ * os_worker_active() - query whether the map/unmap worker thread is active
+ * @hw: dlb2_hw handle for a particular device.
+ *
+ * This function returns a boolean indicating whether a thread (launched by
+ * os_schedule_work()) is active. This function is used to determine
+ * whether or not to launch a worker thread.
+ */
+static inline bool os_worker_active(struct dlb2_hw *hw)
+{
+       struct dlb2_dev *dlb2_dev;
+
+       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
+
+       return dlb2_dev->worker_launched;
+}
+
+#endif /*  __DLB2_OSDEP_H */
drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h new file +440 -0
new file mode 100644
index 0000000..423233b
@@ -0,0 +1,440 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_BITMAP_H
+#define __DLB2_OSDEP_BITMAP_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <rte_bitmap.h>
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+#include "../dlb2_main.h"
+
+/*************************/
+/*** Bitmap operations ***/
+/*************************/
+struct dlb2_bitmap {
+       struct rte_bitmap *map;
+       unsigned int len;
+};
+
+/**
+ * dlb2_bitmap_alloc() - alloc a bitmap data structure
+ * @bitmap: pointer to dlb2_bitmap structure pointer.
+ * @len: number of entries in the bitmap.
+ *
+ * This function allocates a bitmap and initializes it with length @len. All
+ * entries are initially zero.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or len is 0.
+ * ENOMEM - could not allocate memory for the bitmap data structure.
+ */
+static inline int dlb2_bitmap_alloc(struct dlb2_bitmap **bitmap,
+                                   unsigned int len)
+{
+       struct dlb2_bitmap *bm;
+       void *mem;
+       uint32_t alloc_size;
+       uint32_t nbits = (uint32_t)len;
+
+       if (bitmap == NULL || nbits == 0)
+               return -EINVAL;
+
+       /* Allocate DLB2 bitmap control struct */
+       bm = rte_malloc("DLB2_PF",
+                       sizeof(struct dlb2_bitmap),
+                       RTE_CACHE_LINE_SIZE);
+
+       if (bm == NULL)
+               return -ENOMEM;
+
+       /* Allocate bitmap memory */
+       alloc_size = rte_bitmap_get_memory_footprint(nbits);
+       mem = rte_malloc("DLB2_PF_BITMAP", alloc_size, RTE_CACHE_LINE_SIZE);
+       if (mem == NULL) {
+               rte_free(bm);
+               return -ENOMEM;
+       }
+
+       bm->map = rte_bitmap_init(len, mem, alloc_size);
+       if (bm->map == NULL) {
+               rte_free(mem);
+               rte_free(bm);
+               return -ENOMEM;
+       }
+
+       bm->len = len;
+
+       *bitmap = bm;
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_free() - free a previously allocated bitmap data structure
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function frees a bitmap that was allocated with dlb2_bitmap_alloc().
+ */
+static inline void dlb2_bitmap_free(struct dlb2_bitmap *bitmap)
+{
+       if (bitmap == NULL)
+               return;
+
+       rte_free(bitmap->map);
+       rte_free(bitmap);
+}
+
+/**
+ * dlb2_bitmap_fill() - fill a bitmap with all 1s
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function sets all bitmap values to 1.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_fill(struct dlb2_bitmap *bitmap)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++)
+               rte_bitmap_set(bitmap->map, i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_fill() - fill a bitmap with all 0s
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function sets all bitmap values to 0.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_zero(struct dlb2_bitmap *bitmap)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       rte_bitmap_reset(bitmap->map);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_set() - set a bitmap entry
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: bit index.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or bit is larger than the
+ *         bitmap length.
+ */
+static inline int dlb2_bitmap_set(struct dlb2_bitmap *bitmap,
+                                 unsigned int bit)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       rte_bitmap_set(bitmap->map, bit);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_set_range() - set a range of bitmap entries
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: starting bit index.
+ * @len: length of the range.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or the range exceeds the bitmap
+ *         length.
+ */
+static inline int dlb2_bitmap_set_range(struct dlb2_bitmap *bitmap,
+                                       unsigned int bit,
+                                       unsigned int len)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       for (i = 0; i != len; i++)
+               rte_bitmap_set(bitmap->map, bit + i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_clear() - clear a bitmap entry
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: bit index.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or bit is larger than the
+ *         bitmap length.
+ */
+static inline int dlb2_bitmap_clear(struct dlb2_bitmap *bitmap,
+                                   unsigned int bit)
+{
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       rte_bitmap_clear(bitmap->map, bit);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_clear_range() - clear a range of bitmap entries
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @bit: starting bit index.
+ * @len: length of the range.
+ *
+ * Return:
+ * Returns 0 upon success, < 0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or the range exceeds the bitmap
+ *         length.
+ */
+static inline int dlb2_bitmap_clear_range(struct dlb2_bitmap *bitmap,
+                                         unsigned int bit,
+                                         unsigned int len)
+{
+       unsigned int i;
+
+       if (bitmap  == NULL || bitmap->map == NULL)
+               return -EINVAL;
+
+       if (bitmap->len <= bit)
+               return -EINVAL;
+
+       for (i = 0; i != len; i++)
+               rte_bitmap_clear(bitmap->map, bit + i);
+
+       return 0;
+}
+
+/**
+ * dlb2_bitmap_find_set_bit_range() - find an range of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ * @len: length of the range.
+ *
+ * This function looks for a range of set bits of length @len.
+ *
+ * Return:
+ * Returns the base bit index upon success, < 0 otherwise.
+ *
+ * Errors:
+ * ENOENT - unable to find a length *len* range of set bits.
+ * EINVAL - bitmap is NULL or is uninitialized, or len is invalid.
+ */
+static inline int dlb2_bitmap_find_set_bit_range(struct dlb2_bitmap *bitmap,
+                                                unsigned int len)
+{
+       unsigned int i, j = 0;
+
+       if (bitmap  == NULL || bitmap->map == NULL || len == 0)
+               return -EINVAL;
+
+       if (bitmap->len < len)
+               return -ENOENT;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i)) {
+                       if (++j == len)
+                               return i - j + 1;
+               } else {
+                       j = 0;
+               }
+       }
+
+       /* No set bit range of length len? */
+       return -ENOENT;
+}
+
+/**
+ * dlb2_bitmap_find_set_bit() - find an range of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function looks for a single set bit.
+ *
+ * Return:
+ * Returns the base bit index upon success, -1 if not found, <-1 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized, or len is invalid.
+ */
+static inline int dlb2_bitmap_find_set_bit(struct dlb2_bitmap *bitmap)
+{
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i))
+                       return i;
+       }
+
+       return -ENOENT;
+}
+
+/**
+ * dlb2_bitmap_count() - returns the number of set bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * This function looks for a single set bit.
+ *
+ * Return:
+ * Returns the number of set bits upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_count(struct dlb2_bitmap *bitmap)
+{
+       int weight = 0;
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i))
+                       weight++;
+       }
+       return weight;
+}
+
+/**
+ * dlb2_bitmap_longest_set_range() - returns longest contiguous range of set
+ *                                   bits
+ * @bitmap: pointer to dlb2_bitmap structure.
+ *
+ * Return:
+ * Returns the bitmap's longest contiguous range of of set bits upon success,
+ * <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - bitmap is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_longest_set_range(struct dlb2_bitmap *bitmap)
+{
+       int max_len = 0, len = 0;
+       unsigned int i;
+
+       if (bitmap == NULL)
+               return -EINVAL;
+
+       if (bitmap->map == NULL)
+               return -EINVAL;
+
+       for (i = 0; i != bitmap->len; i++) {
+               if  (rte_bitmap_get(bitmap->map, i)) {
+                       len++;
+               } else {
+                       if (len > max_len)
+                               max_len = len;
+                       len = 0;
+               }
+       }
+
+       if (len > max_len)
+               max_len = len;
+
+       return max_len;
+}
+
+/**
+ * dlb2_bitmap_or() - store the logical 'or' of two bitmaps into a third
+ * @dest: pointer to dlb2_bitmap structure, which will contain the results of
+ *       the 'or' of src1 and src2.
+ * @src1: pointer to dlb2_bitmap structure, will be 'or'ed with src2.
+ * @src2: pointer to dlb2_bitmap structure, will be 'or'ed with src1.
+ *
+ * This function 'or's two bitmaps together and stores the result in a third
+ * bitmap. The source and destination bitmaps can be the same.
+ *
+ * Return:
+ * Returns the number of set bits upon success, <0 otherwise.
+ *
+ * Errors:
+ * EINVAL - One of the bitmaps is NULL or is uninitialized.
+ */
+static inline int dlb2_bitmap_or(struct dlb2_bitmap *dest,
+                                struct dlb2_bitmap *src1,
+                                struct dlb2_bitmap *src2)
+{
+       unsigned int i, min;
+       int numset = 0;
+
+       if (dest  == NULL || dest->map == NULL ||
+           src1  == NULL || src1->map == NULL ||
+           src2  == NULL || src2->map == NULL)
+               return -EINVAL;
+
+       min = dest->len;
+       min = (min > src1->len) ? src1->len : min;
+       min = (min > src2->len) ? src2->len : min;
+
+       for (i = 0; i != min; i++) {
+               if  (rte_bitmap_get(src1->map, i) ||
+                    rte_bitmap_get(src2->map, i)) {
+                       rte_bitmap_set(dest->map, i);
+                       numset++;
+               } else {
+                       rte_bitmap_clear(dest->map, i);
+               }
+       }
+
+       return numset;
+}
+
+#endif /*  __DLB2_OSDEP_BITMAP_H */
drivers/event/dlb2/pf/base/dlb2_osdep_list.h new file +131 -0
new file mode 100644
index 0000000..5531739
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_LIST_H
+#define __DLB2_OSDEP_LIST_H
+
+#include <rte_tailq.h>
+
+struct dlb2_list_entry {
+       TAILQ_ENTRY(dlb2_list_entry) node;
+};
+
+/* Dummy - just a struct definition */
+TAILQ_HEAD(dlb2_list_head, dlb2_list_entry);
+
+/* =================
+ * TAILQ Supplements
+ * =================
+ */
+
+#ifndef TAILQ_FOREACH_ENTRY
+#define TAILQ_FOREACH_ENTRY(ptr, head, name, iter)             \
+       for ((iter) = TAILQ_FIRST(&head);                       \
+           (iter)                                              \
+               && (ptr = container_of(iter, typeof(*(ptr)), name)); \
+           (iter) = TAILQ_NEXT((iter), node))
+#endif
+
+#ifndef TAILQ_FOREACH_ENTRY_SAFE
+#define TAILQ_FOREACH_ENTRY_SAFE(ptr, head, name, iter, tvar)  \
+       for ((iter) = TAILQ_FIRST(&head);                       \
+           (iter) &&                                           \
+               (ptr = container_of(iter, typeof(*(ptr)), name)) &&\
+               ((tvar) = TAILQ_NEXT((iter), node), 1); \
+           (iter) = (tvar))
+#endif
+
+/***********************/
+/*** List operations ***/
+/***********************/
+
+/**
+ * dlb2_list_init_head() - initialize the head of a list
+ * @head: list head
+ */
+static inline void dlb2_list_init_head(struct dlb2_list_head *head)
+{
+       TAILQ_INIT(head);
+}
+
+/**
+ * dlb2_list_add() - add an entry to a list
+ * @head: list head
+ * @entry: new list entry
+ */
+static inline void
+dlb2_list_add(struct dlb2_list_head *head, struct dlb2_list_entry *entry)
+{
+       TAILQ_INSERT_TAIL(head, entry, node);
+}
+
+/**
+ * dlb2_list_del() - delete an entry from a list
+ * @entry: list entry
+ * @head: list head
+ */
+static inline void dlb2_list_del(struct dlb2_list_head *head,
+                                struct dlb2_list_entry *entry)
+{
+       TAILQ_REMOVE(head, entry, node);
+}
+
+/**
+ * dlb2_list_empty() - check if a list is empty
+ * @head: list head
+ *
+ * Return:
+ * Returns 1 if empty, 0 if not.
+ */
+static inline int dlb2_list_empty(struct dlb2_list_head *head)
+{
+       return TAILQ_EMPTY(head);
+}
+
+/**
+ * dlb2_list_splice() - splice a list
+ * @src_head: list to be added
+ * @ head: where src_head will be inserted
+ */
+static inline void dlb2_list_splice(struct dlb2_list_head *src_head,
+                                   struct dlb2_list_head *head)
+{
+       TAILQ_CONCAT(head, src_head, node);
+}
+
+/**
+ * DLB2_LIST_HEAD() - retrieve the head of the list
+ * @head: list head
+ * @type: type of the list variable
+ * @name: name of the list field within the containing struct
+ */
+#define DLB2_LIST_HEAD(head, type, name)                       \
+       (TAILQ_FIRST(&head) ?                                   \
+               container_of(TAILQ_FIRST(&head), type, name) :  \
+               NULL)
+
+/**
+ * DLB2_LIST_FOR_EACH() - iterate over a list
+ * @head: list head
+ * @ptr: pointer to struct containing a struct list
+ * @name: name of the list field within the containing struct
+ * @iter: iterator variable
+ */
+#define DLB2_LIST_FOR_EACH(head, ptr, name, tmp_iter) \
+       TAILQ_FOREACH_ENTRY(ptr, head, name, tmp_iter)
+
+/**
+ * DLB2_LIST_FOR_EACH_SAFE() - iterate over a list. This loop works even if
+ * an element is removed from the list while processing it.
+ * @ptr: pointer to struct containing a struct list
+ * @ptr_tmp: pointer to struct containing a struct list (temporary)
+ * @head: list head
+ * @name: name of the list field within the containing struct
+ * @iter: iterator variable
+ * @iter_tmp: iterator variable (temporary)
+ */
+#define DLB2_LIST_FOR_EACH_SAFE(head, ptr, ptr_tmp, name, tmp_iter, saf_itr) \
+       TAILQ_FOREACH_ENTRY_SAFE(ptr, head, name, tmp_iter, saf_itr)
+
+#endif /*  __DLB2_OSDEP_LIST_H */
drivers/event/dlb2/pf/base/dlb2_osdep_types.h new file +31 -0
new file mode 100644
index 0000000..0a48f7e
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_OSDEP_TYPES_H
+#define __DLB2_OSDEP_TYPES_H
+
+#include <linux/types.h>
+
+#include <inttypes.h>
+#include <ctype.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Types for user mode PF PMD */
+typedef uint8_t         u8;
+typedef int8_t          s8;
+typedef uint16_t        u16;
+typedef int16_t         s16;
+typedef uint32_t        u32;
+typedef int32_t         s32;
+typedef uint64_t        u64;
+
+#define __iomem
+
+/* END types for user mode PF PMD */
+
+#endif /* __DLB2_OSDEP_TYPES_H */
drivers/event/dlb2/pf/base/dlb2_regs.h new file +2527 -0
new file mode 100644
index 0000000..43ecad4
@@ -0,0 +1,2527 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2020 Intel Corporation
+ */
+
+#ifndef __DLB2_REGS_H
+#define __DLB2_REGS_H
+
+#include "dlb2_osdep_types.h"
+
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_BYTES 256
+#define DLB2_FUNC_PF_VF2PF_MAILBOX(vf_id, x) \
+       (0x1000 + 0x4 * (x) + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_RST 0x0
+union dlb2_func_pf_vf2pf_mailbox {
+       struct {
+               u32 msg : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_ISR(vf_id) \
+       (0x1f00 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_MAILBOX_ISR_RST 0x0
+union dlb2_func_pf_vf2pf_mailbox_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_FLR_ISR(vf_id) \
+       (0x1f04 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_FLR_ISR_RST 0x0
+union dlb2_func_pf_vf2pf_flr_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF2PF_ISR_PEND(vf_id) \
+       (0x1f10 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF2PF_ISR_PEND_RST 0x0
+union dlb2_func_pf_vf2pf_isr_pend {
+       struct {
+               u32 isr_pend : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_BYTES 64
+#define DLB2_FUNC_PF_PF2VF_MAILBOX(vf_id, x) \
+       (0x2000 + 0x4 * (x) + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_RST 0x0
+union dlb2_func_pf_pf2vf_mailbox {
+       struct {
+               u32 msg : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_ISR(vf_id) \
+       (0x2f00 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_PF2VF_MAILBOX_ISR_RST 0x0
+union dlb2_func_pf_pf2vf_mailbox_isr {
+       struct {
+               u32 vf0_isr : 1;
+               u32 vf1_isr : 1;
+               u32 vf2_isr : 1;
+               u32 vf3_isr : 1;
+               u32 vf4_isr : 1;
+               u32 vf5_isr : 1;
+               u32 vf6_isr : 1;
+               u32 vf7_isr : 1;
+               u32 vf8_isr : 1;
+               u32 vf9_isr : 1;
+               u32 vf10_isr : 1;
+               u32 vf11_isr : 1;
+               u32 vf12_isr : 1;
+               u32 vf13_isr : 1;
+               u32 vf14_isr : 1;
+               u32 vf15_isr : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_FUNC_PF_VF_RESET_IN_PROGRESS(vf_id) \
+       (0x3000 + (vf_id) * 0x10000)
+#define DLB2_FUNC_PF_VF_RESET_IN_PROGRESS_RST 0xffff
+union dlb2_func_pf_vf_reset_in_progress {
+       struct {
+               u32 vf0_reset_in_progress : 1;
+               u32 vf1_reset_in_progress : 1;
+               u32 vf2_reset_in_progress : 1;
+               u32 vf3_reset_in_progress : 1;
+               u32 vf4_reset_in_progress : 1;
+               u32 vf5_reset_in_progress : 1;
+               u32 vf6_reset_in_progress : 1;
+               u32 vf7_reset_in_progress : 1;
+               u32 vf8_reset_in_progress : 1;
+               u32 vf9_reset_in_progress : 1;
+               u32 vf10_reset_in_progress : 1;
+               u32 vf11_reset_in_progress : 1;
+               u32 vf12_reset_in_progress : 1;
+               u32 vf13_reset_in_progress : 1;
+               u32 vf14_reset_in_progress : 1;
+               u32 vf15_reset_in_progress : 1;
+               u32 rsvd0 : 16;
+       } field;
+       u32 val;
+};
+
+#define DLB2_MSIX_MEM_VECTOR_CTRL(x) \
+       (0x100000c + (x) * 0x10)
+#define DLB2_MSIX_MEM_VECTOR_CTRL_RST 0x1
+union dlb2_msix_mem_vector_ctrl {
+       struct {
+               u32 vec_mask : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_IOSF_FUNC_VF_BAR_DSBL(x) \
+       (0x20 + (x) * 0x4)
+#define DLB2_IOSF_FUNC_VF_BAR_DSBL_RST 0x0
+union dlb2_iosf_func_vf_bar_dsbl {
+       struct {
+               u32 func_vf_bar_dis : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_VAS 0x1000011c
+#define DLB2_SYS_TOTAL_VAS_RST 0x20
+union dlb2_sys_total_vas {
+       struct {
+               u32 total_vas : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_PORTS 0x10000118
+#define DLB2_SYS_TOTAL_DIR_PORTS_RST 0x40
+union dlb2_sys_total_dir_ports {
+       struct {
+               u32 total_dir_ports : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_PORTS 0x10000114
+#define DLB2_SYS_TOTAL_LDB_PORTS_RST 0x40
+union dlb2_sys_total_ldb_ports {
+       struct {
+               u32 total_ldb_ports : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_QID 0x10000110
+#define DLB2_SYS_TOTAL_DIR_QID_RST 0x40
+union dlb2_sys_total_dir_qid {
+       struct {
+               u32 total_dir_qid : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_QID 0x1000010c
+#define DLB2_SYS_TOTAL_LDB_QID_RST 0x20
+union dlb2_sys_total_ldb_qid {
+       struct {
+               u32 total_ldb_qid : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_DIR_CRDS 0x10000108
+#define DLB2_SYS_TOTAL_DIR_CRDS_RST 0x1000
+union dlb2_sys_total_dir_crds {
+       struct {
+               u32 total_dir_credits : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_TOTAL_LDB_CRDS 0x10000104
+#define DLB2_SYS_TOTAL_LDB_CRDS_RST 0x2000
+union dlb2_sys_total_ldb_crds {
+       struct {
+               u32 total_ldb_credits : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND2 0x10000508
+#define DLB2_SYS_ALARM_PF_SYND2_RST 0x0
+union dlb2_sys_alarm_pf_synd2 {
+       struct {
+               u32 lock_id : 16;
+               u32 meas : 1;
+               u32 debug : 7;
+               u32 cq_pop : 1;
+               u32 qe_uhl : 1;
+               u32 qe_orsp : 1;
+               u32 qe_valid : 1;
+               u32 cq_int_rearm : 1;
+               u32 dsi_error : 1;
+               u32 rsvd0 : 2;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND1 0x10000504
+#define DLB2_SYS_ALARM_PF_SYND1_RST 0x0
+union dlb2_sys_alarm_pf_synd1 {
+       struct {
+               u32 dsi : 16;
+               u32 qid : 8;
+               u32 qtype : 2;
+               u32 qpri : 3;
+               u32 msg_type : 3;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_PF_SYND0 0x10000500
+#define DLB2_SYS_ALARM_PF_SYND0_RST 0x0
+union dlb2_sys_alarm_pf_synd0 {
+       struct {
+               u32 syndrome : 8;
+               u32 rtype : 2;
+               u32 rsvd0 : 3;
+               u32 is_ldb : 1;
+               u32 cls : 2;
+               u32 aid : 6;
+               u32 unit : 4;
+               u32 source : 4;
+               u32 more : 1;
+               u32 valid : 1;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VPP_V(x) \
+       (0x10000f00 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VPP_V_RST 0x0
+union dlb2_sys_vf_ldb_vpp_v {
+       struct {
+               u32 vpp_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VPP2PP(x) \
+       (0x10000f04 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VPP2PP_RST 0x0
+union dlb2_sys_vf_ldb_vpp2pp {
+       struct {
+               u32 pp : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VPP_V(x) \
+       (0x10000f08 + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VPP_V_RST 0x0
+union dlb2_sys_vf_dir_vpp_v {
+       struct {
+               u32 vpp_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VPP2PP(x) \
+       (0x10000f0c + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VPP2PP_RST 0x0
+union dlb2_sys_vf_dir_vpp2pp {
+       struct {
+               u32 pp : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VQID_V(x) \
+       (0x10000f10 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VQID_V_RST 0x0
+union dlb2_sys_vf_ldb_vqid_v {
+       struct {
+               u32 vqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_LDB_VQID2QID(x) \
+       (0x10000f14 + (x) * 0x1000)
+#define DLB2_SYS_VF_LDB_VQID2QID_RST 0x0
+union dlb2_sys_vf_ldb_vqid2qid {
+       struct {
+               u32 qid : 5;
+               u32 rsvd0 : 27;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID2VQID(x) \
+       (0x10000f18 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID2VQID_RST 0x0
+union dlb2_sys_ldb_qid2vqid {
+       struct {
+               u32 vqid : 5;
+               u32 rsvd0 : 27;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VQID_V(x) \
+       (0x10000f1c + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VQID_V_RST 0x0
+union dlb2_sys_vf_dir_vqid_v {
+       struct {
+               u32 vqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_VF_DIR_VQID2QID(x) \
+       (0x10000f20 + (x) * 0x1000)
+#define DLB2_SYS_VF_DIR_VQID2QID_RST 0x0
+union dlb2_sys_vf_dir_vqid2qid {
+       struct {
+               u32 qid : 6;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_VASQID_V(x) \
+       (0x10000f24 + (x) * 0x1000)
+#define DLB2_SYS_LDB_VASQID_V_RST 0x0
+union dlb2_sys_ldb_vasqid_v {
+       struct {
+               u32 vasqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_VASQID_V(x) \
+       (0x10000f28 + (x) * 0x1000)
+#define DLB2_SYS_DIR_VASQID_V_RST 0x0
+union dlb2_sys_dir_vasqid_v {
+       struct {
+               u32 vasqid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND2(x) \
+       (0x10000f48 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND2_RST 0x0
+union dlb2_sys_alarm_vf_synd2 {
+       struct {
+               u32 lock_id : 16;
+               u32 debug : 8;
+               u32 cq_pop : 1;
+               u32 qe_uhl : 1;
+               u32 qe_orsp : 1;
+               u32 qe_valid : 1;
+               u32 isz : 1;
+               u32 dsi_error : 1;
+               u32 dlbrsvd : 2;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND1(x) \
+       (0x10000f44 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND1_RST 0x0
+union dlb2_sys_alarm_vf_synd1 {
+       struct {
+               u32 dsi : 16;
+               u32 qid : 8;
+               u32 qtype : 2;
+               u32 qpri : 3;
+               u32 msg_type : 3;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_ALARM_VF_SYND0(x) \
+       (0x10000f40 + (x) * 0x1000)
+#define DLB2_SYS_ALARM_VF_SYND0_RST 0x0
+union dlb2_sys_alarm_vf_synd0 {
+       struct {
+               u32 syndrome : 8;
+               u32 rtype : 2;
+               u32 vf_synd0_parity : 1;
+               u32 vf_synd1_parity : 1;
+               u32 vf_synd2_parity : 1;
+               u32 is_ldb : 1;
+               u32 cls : 2;
+               u32 aid : 6;
+               u32 unit : 4;
+               u32 source : 4;
+               u32 more : 1;
+               u32 valid : 1;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_CFG_V(x) \
+       (0x10000f58 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_CFG_V_RST 0x0
+union dlb2_sys_ldb_qid_cfg_v {
+       struct {
+               u32 sn_cfg_v : 1;
+               u32 fid_cfg_v : 1;
+               u32 rsvd0 : 30;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_ITS(x) \
+       (0x10000f54 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_ITS_RST 0x0
+union dlb2_sys_ldb_qid_its {
+       struct {
+               u32 qid_its : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_QID_V(x) \
+       (0x10000f50 + (x) * 0x1000)
+#define DLB2_SYS_LDB_QID_V_RST 0x0
+union dlb2_sys_ldb_qid_v {
+       struct {
+               u32 qid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_QID_ITS(x) \
+       (0x10000f64 + (x) * 0x1000)
+#define DLB2_SYS_DIR_QID_ITS_RST 0x0
+union dlb2_sys_dir_qid_its {
+       struct {
+               u32 qid_its : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_DIR_QID_V(x) \
+       (0x10000f60 + (x) * 0x1000)
+#define DLB2_SYS_DIR_QID_V_RST 0x0
+union dlb2_sys_dir_qid_v {
+       struct {
+               u32 qid_v : 1;
+               u32 rsvd0 : 31;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_AI_DATA(x) \
+       (0x10000fa8 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_AI_DATA_RST 0x0
+union dlb2_sys_ldb_cq_ai_data {
+       struct {
+               u32 cq_ai_data : 32;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_AI_ADDR(x) \
+       (0x10000fa4 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_AI_ADDR_RST 0x0
+union dlb2_sys_ldb_cq_ai_addr {
+       struct {
+               u32 rsvd1 : 2;
+               u32 cq_ai_addr : 18;
+               u32 rsvd0 : 12;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_PASID(x) \
+       (0x10000fa0 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_PASID_RST 0x0
+union dlb2_sys_ldb_cq_pasid {
+       struct {
+               u32 pasid : 20;
+               u32 exe_req : 1;
+               u32 priv_req : 1;
+               u32 fmt2 : 1;
+               u32 rsvd0 : 9;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_AT(x) \
+       (0x10000f9c + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_AT_RST 0x0
+union dlb2_sys_ldb_cq_at {
+       struct {
+               u32 cq_at : 2;
+               u32 rsvd0 : 30;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ_ISR(x) \
+       (0x10000f98 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ_ISR_RST 0x0
+/* CQ Interrupt Modes */
+#define DLB2_CQ_ISR_MODE_DIS  0
+#define DLB2_CQ_ISR_MODE_MSI  1
+#define DLB2_CQ_ISR_MODE_MSIX 2
+#define DLB2_CQ_ISR_MODE_ADI  3
+union dlb2_sys_ldb_cq_isr {
+       struct {
+               u32 vector : 6;
+               u32 vf : 4;
+               u32 en_code : 2;
+               u32 rsvd0 : 20;
+       } field;
+       u32 val;
+};
+
+#define DLB2_SYS_LDB_CQ2VF_PF_RO(x) \
+       (0x10000f94 + (x) * 0x1000)
+#define DLB2_SYS_LDB_CQ2VF_PF_RO_RST 0x0
+union dlb2_sys_ldb_cq2vf_pf_ro {
+       struct {
+               u32 vf : 4;
+               u32 is_pf : 1;
+               u32 ro : 1;
+               u32 rsvd0 : 26;
+       } field;
+       u32 val;
+};
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/base/dlb2_resource.c new file +274 -0
new file mode 100644
index 0000000..6de8b95

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/base/dlb2_resource.h new file +1913 -0
new file mode 100644
index 0000000..503fdf3

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/dlb2_main.c new file +615 -0
new file mode 100644
index 0000000..bd8590d

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/dlb2_main.h new file +106 -0
new file mode 100644
index 0000000..ec96f11

Lines of this file are not shown. View the raw message.

drivers/event/dlb2/pf/dlb2_pf.c new file +244 -1
new file mode 100644
index 0000000..7d64309

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

2.6.4

Part of the diff is not shown here. View the raw message.