Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp612016pxb; Wed, 27 Jan 2021 16:45:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJJyj+/EjiGarrw2/K/1AdVtRRMWPdAVNG3D0HC3h1KkNfAJf+lAkz6mHLYX7722ZcqMHC X-Received: by 2002:a17:906:94ce:: with SMTP id d14mr8681369ejy.121.1611794717806; Wed, 27 Jan 2021 16:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611794717; cv=none; d=google.com; s=arc-20160816; b=lq3qXeFhQ7PF9pj7rD8lLgB7Xr1qR4wM1c3tiF/9PHqjMRcPTEfbclTu7TWvjrAuZO 6m5daL2XPj+TRP7+AVQCe9B0U213WkLbcP0Y6t0WCREWKzM2GXqg902feBlLpd+H9oRt 1agzphcHj5w2kLBk7WBrkR50A2/YttJ1g6IK8yvoH3BqzlFsd9jzTn5sl6ARBgTu0G43 FPnA5N0KTw9cHTzadypZcet7Kh73MLheNIAVTQIgWGgViewYA43O8C7fRctVAb7XpUta BjoMJTR9ioLlH2afQHhhvysG2n4dfbxZxRA5RVKCGFQwemuW8WeuxpQ9qgS3MVyetY6L meeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=KcOloCUXqOjg2ct41Np2R1UXHOVBCRPg3wDoH6l3Lo4=; b=J9B6Ifp0YGjU2yXDXsurvUT6EcL935aviHGWxH2mCt0nPnkWWHygVW9frC0HAyGZGC KVpl9+ljCjlYeCnqxig7NL9ODzPVDswCSPYAVSxD2KoPZWlqRaLfFgSR9bQDemrkd3Pb cJ38FgoqkbVfai9s2ajo0jUlWcRDBcMiZzt3LZjDoj98UdUsY4PGg+e6uV2FD8jkHrOV vzXt6mkskoSSzMu8VR0duKyke/3dlzy7WoktQ6hflqp37YDFNnFblmBN+QQMr/v+SucJ 464GUJHG23MAEhfyi8gfYg+3xAXEOQ+5p9sn3JBjQ7Hx1UFUOl3vUNqKhKu9OrfUNLv5 7C9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd11si1464369ejb.584.2021.01.27.16.44.53; Wed, 27 Jan 2021 16:45:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235560AbhA0XNZ (ORCPT + 99 others); Wed, 27 Jan 2021 18:13:25 -0500 Received: from mga12.intel.com ([192.55.52.136]:17428 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234482AbhA0XG3 (ORCPT ); Wed, 27 Jan 2021 18:06:29 -0500 IronPort-SDR: hXwB3RH6BqPgbSkPl7qeG/2rBPNB3afb5u2dDeIKLbUeV6AxsLTcpau/BTm18U45R5fx++0oLV 3IuhuhLIwa1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9877"; a="159319109" X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="159319109" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2021 14:56:53 -0800 IronPort-SDR: kVKAbLvc3lgIbrb4vwJ7HH9zBTmclaWsSNw7v+IJUL+UUvSkbQ4bstHgeQe+vaya7RjeWQAUFJ 5ANBCVV244iw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="388494341" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by orsmga008.jf.intel.com with ESMTP; 27 Jan 2021 14:56:52 -0800 From: Mike Ximing Chen 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 Subject: [PATCH v10 17/20] dlb: add static queue map register operations Date: Wed, 27 Jan 2021 16:56:38 -0600 Message-Id: <20210127225641.1342-18-mike.ximing.chen@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20210127225641.1342-1-mike.ximing.chen@intel.com> References: <20210127225641.1342-1-mike.ximing.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Mike Ximing Chen Reviewed-by: Björn Töpel Reviewed-by: Dan Williams --- 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