linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Ximing Chen <mike.ximing.chen@intel.com>
To: linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
	dan.j.williams@intel.com, pierre-louis.bossart@linux.intel.com,
	Gage Eads <gage.eads@intel.com>
Subject: [PATCH v9 17/20] dlb: add static queue map register operations
Date: Fri, 22 Jan 2021 13:01:35 -0600	[thread overview]
Message-ID: <20210122190138.7414-18-mike.ximing.chen@intel.com> (raw)
In-Reply-To: <20210122190138.7414-1-mike.ximing.chen@intel.com>

Add the register accesses that implement the static queue map operation and
handle an unmap request when a queue map operation is in progress.

If a queue map operation is requested before the domain is started, it is a
synchronous procedure on "static"/unchanging hardware. (The "dynamic"
operation, when traffic is flowing in the device, will be added in a later
commit.)

Signed-off-by: Gage Eads <gage.eads@intel.com>
Signed-off-by: Mike Ximing Chen <mike.ximing.chen@intel.com>
Reviewed-by: Björn Töpel <bjorn.topel@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/misc/dlb/dlb_resource.c | 144 +++++++++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/dlb/dlb_resource.c b/drivers/misc/dlb/dlb_resource.c
index a830b547dadf..95ccb7eddb8b 100644
--- a/drivers/misc/dlb/dlb_resource.c
+++ b/drivers/misc/dlb/dlb_resource.c
@@ -2122,19 +2122,150 @@ static int dlb_configure_dir_port(struct dlb_hw *hw, struct dlb_hw_domain *domai
 	return 0;
 }
 
+static int dlb_ldb_port_map_qid_static(struct dlb_hw *hw, struct dlb_ldb_port *p,
+				       struct dlb_ldb_queue *q, u8 priority)
+{
+	enum dlb_qid_map_state state;
+	u32 lsp_qid2cq2;
+	u32 lsp_qid2cq;
+	u32 atm_qid2cq;
+	u32 cq2priov;
+	u32 cq2qid;
+	int i;
+
+	/* Look for a pending or already mapped slot, else an unused slot */
+	if (!dlb_port_find_slot_queue(p, DLB_QUEUE_MAP_IN_PROG, q, &i) &&
+	    !dlb_port_find_slot_queue(p, DLB_QUEUE_MAPPED, q, &i) &&
+	    !dlb_port_find_slot(p, DLB_QUEUE_UNMAPPED, &i)) {
+		DLB_HW_ERR(hw,
+			   "[%s():%d] Internal error: CQ has no available QID mapping slots\n",
+			   __func__, __LINE__);
+		return -EFAULT;
+	}
+
+	/* Read-modify-write the priority and valid bit register */
+	cq2priov = DLB_CSR_RD(hw, LSP_CQ2PRIOV(p->id.phys_id));
+
+	cq2priov |= (1U << (i + LSP_CQ2PRIOV_V_LOC)) & LSP_CQ2PRIOV_V;
+	cq2priov |= ((priority & 0x7) << (i + LSP_CQ2PRIOV_PRIO_LOC) * 3)
+		    & LSP_CQ2PRIOV_PRIO;
+
+	DLB_CSR_WR(hw, LSP_CQ2PRIOV(p->id.phys_id), cq2priov);
+
+	/* Read-modify-write the QID map register */
+	if (i < 4)
+		cq2qid = DLB_CSR_RD(hw, LSP_CQ2QID0(p->id.phys_id));
+	else
+		cq2qid = DLB_CSR_RD(hw, LSP_CQ2QID1(p->id.phys_id));
+
+	if (i == 0 || i == 4)
+		BITS_SET(cq2qid, q->id.phys_id, LSP_CQ2QID0_QID_P0);
+	if (i == 1 || i == 5)
+		BITS_SET(cq2qid, q->id.phys_id, LSP_CQ2QID0_QID_P1);
+	if (i == 2 || i == 6)
+		BITS_SET(cq2qid, q->id.phys_id, LSP_CQ2QID0_QID_P2);
+	if (i == 3 || i == 7)
+		BITS_SET(cq2qid, q->id.phys_id, LSP_CQ2QID0_QID_P3);
+
+	if (i < 4)
+		DLB_CSR_WR(hw, LSP_CQ2QID0(p->id.phys_id), cq2qid);
+	else
+		DLB_CSR_WR(hw, LSP_CQ2QID1(p->id.phys_id), cq2qid);
+
+	atm_qid2cq = DLB_CSR_RD(hw,
+				ATM_QID2CQIDIX(q->id.phys_id,
+					       p->id.phys_id / 4));
+
+	lsp_qid2cq = DLB_CSR_RD(hw,
+				LSP_QID2CQIDIX(q->id.phys_id,
+					       p->id.phys_id / 4));
+
+	lsp_qid2cq2 = DLB_CSR_RD(hw,
+				 LSP_QID2CQIDIX2(q->id.phys_id,
+						 p->id.phys_id / 4));
+
+	switch (p->id.phys_id % 4) {
+	case 0:
+		atm_qid2cq |= (1 << (i + ATM_QID2CQIDIX_00_CQ_P0_LOC));
+		lsp_qid2cq |= (1 << (i + LSP_QID2CQIDIX_00_CQ_P0_LOC));
+		lsp_qid2cq2 |= (1 << (i + LSP_QID2CQIDIX2_00_CQ_P0_LOC));
+		break;
+
+	case 1:
+		atm_qid2cq |= (1 << (i + ATM_QID2CQIDIX_00_CQ_P1_LOC));
+		lsp_qid2cq |= (1 << (i + LSP_QID2CQIDIX_00_CQ_P1_LOC));
+		lsp_qid2cq2 |= (1 << (i + LSP_QID2CQIDIX2_00_CQ_P1_LOC));
+		break;
+
+	case 2:
+		atm_qid2cq |= (1 << (i + ATM_QID2CQIDIX_00_CQ_P2_LOC));
+		lsp_qid2cq |= (1 << (i + LSP_QID2CQIDIX_00_CQ_P2_LOC));
+		lsp_qid2cq2 |= (1 << (i + LSP_QID2CQIDIX2_00_CQ_P2_LOC));
+		break;
+
+	case 3:
+		atm_qid2cq |= (1 << (i + ATM_QID2CQIDIX_00_CQ_P3_LOC));
+		lsp_qid2cq |= (1 << (i + LSP_QID2CQIDIX_00_CQ_P3_LOC));
+		lsp_qid2cq2 |= (1 << (i + LSP_QID2CQIDIX2_00_CQ_P3_LOC));
+		break;
+	}
+
+	DLB_CSR_WR(hw,
+		   ATM_QID2CQIDIX(q->id.phys_id, p->id.phys_id / 4),
+		   atm_qid2cq);
+
+	DLB_CSR_WR(hw,
+		   LSP_QID2CQIDIX(q->id.phys_id, p->id.phys_id / 4),
+		   lsp_qid2cq);
+
+	DLB_CSR_WR(hw,
+		   LSP_QID2CQIDIX2(q->id.phys_id, p->id.phys_id / 4),
+		   lsp_qid2cq2);
+
+	dlb_flush_csr(hw);
+
+	p->qid_map[i].qid = q->id.phys_id;
+	p->qid_map[i].priority = priority;
+
+	state = DLB_QUEUE_MAPPED;
+
+	return dlb_port_slot_state_transition(hw, p, q, i, state);
+}
+
 static void dlb_ldb_port_change_qid_priority(struct dlb_hw *hw,
 					     struct dlb_ldb_port *port, int slot,
 					     struct dlb_map_qid_args *args)
 {
-	/* Placeholder */
+	u32 cq2priov;
+
+	/* Read-modify-write the priority and valid bit register */
+	cq2priov = DLB_CSR_RD(hw, LSP_CQ2PRIOV(port->id.phys_id));
+
+	cq2priov |= (1 << (slot + LSP_CQ2PRIOV_V_LOC)) & LSP_CQ2PRIOV_V;
+	cq2priov |= ((args->priority & 0x7) << slot * 3) & LSP_CQ2PRIOV_PRIO;
+
+	DLB_CSR_WR(hw, LSP_CQ2PRIOV(port->id.phys_id), cq2priov);
+
+	dlb_flush_csr(hw);
+
+	port->qid_map[slot].priority = args->priority;
+}
+
+static void dlb_ldb_queue_set_inflight_limit(struct dlb_hw *hw,
+					     struct dlb_ldb_queue *queue)
+{
+	u32 infl_lim = 0;
+
+	BITS_SET(infl_lim, queue->num_qid_inflights, LSP_QID_LDB_INFL_LIM_LIMIT);
+
+	DLB_CSR_WR(hw, LSP_QID_LDB_INFL_LIM(queue->id.phys_id), infl_lim);
 }
 
 static int dlb_ldb_port_map_qid(struct dlb_hw *hw, struct dlb_hw_domain *domain,
 				struct dlb_ldb_port *port,
 				struct dlb_ldb_queue *queue, u8 prio)
 {
-	/* Placeholder */
-	return 0;
+	return dlb_ldb_port_map_qid_static(hw, port, queue, prio);
 }
 
 static void
@@ -2872,6 +3003,13 @@ int dlb_hw_unmap_qid(struct dlb_hw *hw, u32 domain_id,
 	 */
 	st = DLB_QUEUE_MAP_IN_PROG;
 	if (dlb_port_find_slot_queue(port, st, queue, &i)) {
+		/*
+		 * Since the in-progress map was aborted, re-enable the QID's
+		 * inflights.
+		 */
+		if (queue->num_pending_additions == 0)
+			dlb_ldb_queue_set_inflight_limit(hw, queue);
+
 		st = DLB_QUEUE_UNMAPPED;
 		ret = dlb_port_slot_state_transition(hw, port, queue, i, st);
 		if (ret)
-- 
2.17.1


  parent reply	other threads:[~2021-01-22 19:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 19:01 [PATCH v9 00/20] dlb: introduce DLB device driver Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 01/20] dlb: add skeleton for DLB driver Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 02/20] dlb: initialize device Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 03/20] dlb: add resource and device initialization Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen
2021-01-27  1:25   ` kernel test robot
2021-01-27 12:29   ` Greg KH
2021-01-27 13:59     ` Chen, Mike Ximing
2021-01-27 14:03       ` Greg KH
2021-01-27 23:15         ` Chen, Mike Ximing
2021-01-22 19:01 ` [PATCH v9 05/20] dlb: add scheduling domain configuration Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 06/20] dlb: add domain software reset Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 07/20] dlb: add low-level register reset operations Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 08/20] dlb: add runtime power-management support Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 09/20] dlb: add queue create, reset, get-depth ioctls Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 10/20] dlb: add register operations for queue management Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 11/20] dlb: add ioctl to configure ports and query poll mode Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 12/20] dlb: add register operations for port management Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 13/20] dlb: add port mmap support Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 14/20] dlb: add start domain ioctl Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 15/20] dlb: add queue map, unmap, and pending unmap operations Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 16/20] dlb: add port map/unmap state machine Mike Ximing Chen
2021-01-22 19:01 ` Mike Ximing Chen [this message]
2021-01-22 19:01 ` [PATCH v9 18/20] dlb: add dynamic queue map register operations Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 19/20] dlb: add queue unmap " Mike Ximing Chen
2021-01-22 19:01 ` [PATCH v9 20/20] dlb: queue map/unmap workqueue Mike Ximing Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210122190138.7414-18-mike.ximing.chen@intel.com \
    --to=mike.ximing.chen@intel.com \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=gage.eads@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).