From patchwork Thu Oct 1 07:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1374881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C247V6LNmz9sVL for ; Thu, 1 Oct 2020 17:12:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=R5jRdOcZ; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C247V5fxQzDqTY for ; Thu, 1 Oct 2020 17:12:06 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C247N15SmzDqVm for ; Thu, 1 Oct 2020 17:12:00 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=R5jRdOcZ; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4C247H25g3z9sVM; Thu, 1 Oct 2020 17:11:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1601536319; bh=oGtiiefrAZoRBMHrm1UATzfoEuNbxiEGtmpygPrM+rU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R5jRdOcZADW04If0a+XG2YiQ6WIpm+7phSg41cN+Yq5jKixuEPSXdM+hO7R+tpLkH XXIcAl8XqOpuhrvRD1IsBZm3Rwlq2DaWzSMpAakGfBy/ACRA7E4+xSanOOldzE10cU JVDsevie447SeMGMR1BM26XdmHh42kGRpmUdIcCh10VuYmJk+rS7hxzCsz1olW5Kes zcPXruXaq4+blUfFjEwwSdDQa5DpfUhxShQ8q7ncBLZYbwtzD1CqutbG3IglGm7Ud3 /T/prLev2cPHDjNlPKyJyM3/7Q17NLM2RvqxQvmicdeFWLzmAcnC1DHJ/D0ApcNalU vVY2E/Y+61JtQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 1 Oct 2020 17:08:09 +1000 Message-Id: <20201001070814.102735-16-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001070814.102735-1-amitay@ozlabs.org> References: <20201001070814.102735-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 15/20] libsbefifo: Update sram get/put api X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Since occsram_{get|put} api was not used for P9, rename it as per P10 change. Signed-off-by: Amitay Isaacs Reviewed-by: Joel Stanley --- libsbefifo/cmd_memory.c | 75 ++++++++++++++++++++++-------------- libsbefifo/libsbefifo.h | 5 ++- libsbefifo/sbefifo_private.h | 4 +- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/libsbefifo/cmd_memory.c b/libsbefifo/cmd_memory.c index 47d4de7..4195a12 100644 --- a/libsbefifo/cmd_memory.c +++ b/libsbefifo/cmd_memory.c @@ -219,11 +219,11 @@ int sbefifo_mem_put(struct sbefifo_context *sctx, uint64_t addr, uint8_t *data, return rc; } -static int sbefifo_occsram_get_push(uint32_t addr, uint32_t size, uint8_t mode, uint8_t **buf, uint32_t *buflen) +static int sbefifo_sram_get_push(uint16_t chiplet_id, uint64_t addr, uint32_t size, uint8_t mode, uint8_t **buf, uint32_t *buflen) { uint32_t *msg; - uint32_t nwords, cmd; - uint32_t start_addr, end_addr; + uint32_t nwords, cmd, flags; + uint64_t start_addr, end_addr; uint32_t align, len; align = 8; @@ -233,29 +233,32 @@ static int sbefifo_occsram_get_push(uint32_t addr, uint32_t size, uint8_t mode, if (end_addr < start_addr) return EINVAL; - nwords = 5; + nwords = 6; *buflen = nwords * sizeof(uint32_t); msg = malloc(*buflen); if (!msg) return ENOMEM; - len = end_addr - start_addr; + len = (end_addr - start_addr) / 8; + + cmd = SBEFIFO_CMD_CLASS_MEMORY | SBEFIFO_CMD_GET_SRAM; - cmd = SBEFIFO_CMD_CLASS_MEMORY | SBEFIFO_CMD_GET_OCCSRAM; + flags = ((uint32_t)chiplet_id << 16 | (uint32_t)mode); msg[0] = htobe32(nwords); msg[1] = htobe32(cmd); - msg[2] = htobe32(mode); - msg[3] = htobe32(start_addr); - msg[4] = htobe32(len); + msg[2] = htobe32(flags); + msg[3] = htobe32(start_addr >> 32); + msg[4] = htobe32(start_addr & 0xffffffff); + msg[5] = htobe32(len); *buf = (uint8_t *)msg; return 0; } -static int sbefifo_occsram_get_pull(uint8_t *buf, uint32_t buflen, uint32_t addr, uint32_t size, uint8_t **data, uint32_t *data_len) +static int sbefifo_sram_get_pull(uint8_t *buf, uint32_t buflen, uint64_t addr, uint32_t size, uint8_t **data, uint32_t *data_len) { - uint32_t start_addr; + uint64_t start_addr; uint32_t align, offset; if (buflen < 4) @@ -278,19 +281,22 @@ static int sbefifo_occsram_get_pull(uint8_t *buf, uint32_t buflen, uint32_t addr return 0; } -int sbefifo_occsram_get(struct sbefifo_context *sctx, uint32_t addr, uint32_t size, uint8_t mode, uint8_t **data, uint32_t *data_len) +int sbefifo_sram_get(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t addr, uint32_t size, uint8_t mode, uint8_t **data, uint32_t *data_len) { uint8_t *msg, *out; uint32_t msg_len, out_len; uint32_t len; int rc; - rc = sbefifo_occsram_get_push(addr, size, mode, &msg, &msg_len); + if (sctx->proc == SBEFIFO_PROC_P9) + return ENOSYS; + + rc = sbefifo_sram_get_push(chiplet_id, addr, size, mode, &msg, &msg_len); if (rc) return rc; - /* length is 5th word in the request */ - len = be32toh(*(uint32_t *)(msg + 16)); + /* length is 6th word in the request */ + len = be32toh(*(uint32_t *)(msg + 20)); out_len = len + 4; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); @@ -298,18 +304,19 @@ int sbefifo_occsram_get(struct sbefifo_context *sctx, uint32_t addr, uint32_t si if (rc) return rc; - rc = sbefifo_occsram_get_pull(out, out_len, addr, size, data, data_len); + rc = sbefifo_sram_get_pull(out, out_len, addr, size, data, data_len); if (out) free(out); return rc; } -static int sbefifo_occsram_put_push(uint32_t addr, uint8_t *data, uint32_t data_len, uint8_t mode, uint8_t **buf, uint32_t *buflen) +static int sbefifo_sram_put_push(uint16_t chiplet_id, uint64_t addr, uint8_t *data, uint32_t data_len, bool multicast, uint8_t mode, uint8_t **buf, uint32_t *buflen) { uint32_t *msg; - uint32_t nwords, cmd; - uint32_t align; + uint32_t nwords, cmd, flags; + uint32_t align, len; + uint8_t multicast_bit; align = 8; @@ -319,26 +326,35 @@ static int sbefifo_occsram_put_push(uint32_t addr, uint8_t *data, uint32_t data_ if (data_len & (align-1)) return EINVAL; - nwords = 5 + data_len/4; + nwords = 6 + data_len/4; *buflen = nwords * sizeof(uint32_t); msg = malloc(*buflen); if (!msg) return ENOMEM; - cmd = SBEFIFO_CMD_CLASS_MEMORY | SBEFIFO_CMD_PUT_OCCSRAM; + multicast_bit = multicast ? 0x80 : 0x00; + + cmd = SBEFIFO_CMD_CLASS_MEMORY | SBEFIFO_CMD_PUT_SRAM; + + flags = ((uint32_t)chiplet_id << 16) | + ((uint32_t)multicast_bit << 8) | + (uint32_t)mode; + + len = data_len / 8; msg[0] = htobe32(nwords); msg[1] = htobe32(cmd); - msg[2] = htobe32(mode); - msg[3] = htobe32(addr); - msg[4] = htobe32(data_len); + msg[2] = htobe32(flags); + msg[3] = htobe32(addr >> 32); + msg[4] = htobe32(addr & 0xffffffff); + msg[5] = htobe32(len); memcpy(&msg[5], data, data_len); *buf = (uint8_t *)msg; return 0; } -static int sbefifo_occsram_put_pull(uint8_t *buf, uint32_t buflen) +static int sbefifo_sram_put_pull(uint8_t *buf, uint32_t buflen) { if (buflen != sizeof(uint32_t)) return EPROTO; @@ -346,13 +362,16 @@ static int sbefifo_occsram_put_pull(uint8_t *buf, uint32_t buflen) return 0; } -int sbefifo_occsram_put(struct sbefifo_context *sctx, uint32_t addr, uint8_t *data, uint32_t data_len, uint8_t mode) +int sbefifo_sram_put(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t addr, uint8_t *data, uint32_t data_len, bool multicast, uint8_t mode) { uint8_t *msg, *out; uint32_t msg_len, out_len; int rc; - rc = sbefifo_occsram_put_push(addr, data, data_len, mode, &msg, &msg_len); + if (sctx->proc == SBEFIFO_PROC_P9) + return ENOSYS; + + rc = sbefifo_sram_put_push(chiplet_id, addr, data, data_len, multicast, mode, &msg, &msg_len); if (rc) return rc; @@ -362,7 +381,7 @@ int sbefifo_occsram_put(struct sbefifo_context *sctx, uint32_t addr, uint8_t *da if (rc) return rc; - rc = sbefifo_occsram_put_pull(out, out_len); + rc = sbefifo_sram_put_pull(out, out_len); if (out) free(out); diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h index e149de5..7c85c25 100644 --- a/libsbefifo/libsbefifo.h +++ b/libsbefifo/libsbefifo.h @@ -18,6 +18,7 @@ #define __LIBSBEFIFO_H__ #include +#include /* * libsbefifo implements SBE interfaces available via SBEFIFO device. The @@ -152,8 +153,8 @@ int sbefifo_mem_put(struct sbefifo_context *sctx, uint64_t addr, uint8_t *data, #define SBEFIFO_MEMORY_MODE_DEBUG 0x02 #define SBEFIFO_MEMORY_MODE_CIRCULAR 0x03 -int sbefifo_occsram_get(struct sbefifo_context *sctx, uint32_t addr, uint32_t size, uint8_t mode, uint8_t **data, uint32_t *data_len); -int sbefifo_occsram_put(struct sbefifo_context *sctx, uint32_t addr, uint8_t *data, uint32_t data_len, uint8_t mode); +int sbefifo_sram_get(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t addr, uint32_t size, uint8_t mode, uint8_t **data, uint32_t *data_len); +int sbefifo_sram_put(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t addr, uint8_t *data, uint32_t data_len, bool multicast, uint8_t mode); #define SBEFIFO_REGISTER_TYPE_GPR 0x0 #define SBEFIFO_REGISTER_TYPE_SPR 0x1 diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h index 5c9b10a..d3f6a8b 100644 --- a/libsbefifo/sbefifo_private.h +++ b/libsbefifo/sbefifo_private.h @@ -39,8 +39,8 @@ #define SBEFIFO_CMD_CLASS_MEMORY 0xA400 #define SBEFIFO_CMD_GET_MEMORY 0x01 #define SBEFIFO_CMD_PUT_MEMORY 0x02 -#define SBEFIFO_CMD_GET_OCCSRAM 0x03 -#define SBEFIFO_CMD_PUT_OCCSRAM 0x04 +#define SBEFIFO_CMD_GET_SRAM 0x03 +#define SBEFIFO_CMD_PUT_SRAM 0x04 #define SBEFIFO_CMD_CLASS_REGISTER 0xA500 #define SBEFIFO_CMD_GET_REGISTER 0x01