From patchwork Thu Sep 24 04:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1370276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 4Bxj994QXbz9sTN for ; Thu, 24 Sep 2020 14:43:25 +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=wP/Nff1H; 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 4Bxj991TpszDqYt for ; Thu, 24 Sep 2020 14:43:25 +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 4Bxj8X1QLhzDqV8 for ; Thu, 24 Sep 2020 14:42:52 +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=wP/Nff1H; 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 4Bxj8W6Ddbz9sTM; Thu, 24 Sep 2020 14:42:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1600922572; bh=i9QFzIJILTOznD6oJ1B5nU3Utd4s63TuOWVZp2xbCoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wP/Nff1HDh5M7mfQ6AXNkcfmpMMUtAtdFMxnaxsAnp1TOR2q1BoDgOonGhK24bAUN Lefr7dyI/XSzRE/2tpVYuK7EUCyZWwk1XlXm01OJrhLaVcHHNMaF6bLlnMXamnILfY kTElODDRQrFAVt2LSPiqIgbu/GwR0Yos4+Hwn+a1y9QOgyR4ZKv8S1FgpP+3/2hFph o1HFsVu5Cshmx+jb7bkg4YNdpWiZYpzp96y5mNjH7pfJ/0fyypdtMxoRHgfkd8RpSw tK4CmPchsFWak38JP1LSY2rVXy3jch7+aBusCADteG4MCJmIxrdaSyEsv26wig674r hrjFpPHbpz96Q== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 24 Sep 2020 14:42:25 +1000 Message-Id: <20200924044236.130586-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924044236.130586-1-amitay@ozlabs.org> References: <20200924044236.130586-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 07/18] libpdbg: Add processor type to libsbefifo implementation 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" There are few changes between P9 and P10 sbefifo api. Use proc type to implement the changes in the api. Signed-off-by: Amitay Isaacs Reviewed-by: Joel Stanley --- libpdbg/cronus.c | 18 ++++++++++++++++-- libpdbg/sbefifo.c | 18 ++++++++++++++++-- libsbefifo/connect.c | 26 ++++++++++++++++++++++++-- libsbefifo/libsbefifo.h | 8 ++++++-- libsbefifo/sbefifo_private.h | 1 + 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/libpdbg/cronus.c b/libpdbg/cronus.c index 23d555b..8966843 100644 --- a/libpdbg/cronus.c +++ b/libpdbg/cronus.c @@ -155,13 +155,27 @@ static int cronus_sbefifo_transport(uint8_t *msg, uint32_t msg_len, static int cronus_sbefifo_probe(struct pdbg_target *target) { struct sbefifo *sf = target_to_sbefifo(target); - int rc; + int rc, proc; rc = cronus_probe(target); if (rc) return rc; - rc = sbefifo_connect_transport(cronus_sbefifo_transport, sf, &sf->sf_ctx); + switch (pdbg_get_proc()) { + case PDBG_PROC_P9: + proc = SBEFIFO_PROC_P9; + break; + + case PDBG_PROC_P10: + proc = SBEFIFO_PROC_P10; + break; + + default: + PR_ERROR("SBEFIFO driver not supported\n"); + return -1; + } + + rc = sbefifo_connect_transport(proc, cronus_sbefifo_transport, sf, &sf->sf_ctx); if (rc) { PR_ERROR("Unable to initialize sbefifo driver\n"); return rc; diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index 6e45088..63a37e9 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -631,12 +631,26 @@ static int sbefifo_probe(struct pdbg_target *target) { struct sbefifo *sf = target_to_sbefifo(target); const char *sbefifo_path; - int rc; + int rc, proc; sbefifo_path = pdbg_target_property(target, "device-path", NULL); assert(sbefifo_path); - rc = sbefifo_connect(sbefifo_path, &sf->sf_ctx); + switch (pdbg_get_proc()) { + case PDBG_PROC_P9: + proc = SBEFIFO_PROC_P9; + break; + + case PDBG_PROC_P10: + proc = SBEFIFO_PROC_P10; + break; + + default: + PR_ERROR("SBEFIFO driver not supported\n"); + return -1; + } + + rc = sbefifo_connect(sbefifo_path, proc, &sf->sf_ctx); if (rc) { PR_ERROR("Unable to open sbefifo driver %s\n", sbefifo_path); return rc; diff --git a/libsbefifo/connect.c b/libsbefifo/connect.c index 1295dc5..1d23af5 100644 --- a/libsbefifo/connect.c +++ b/libsbefifo/connect.c @@ -20,15 +20,27 @@ #include #include #include +#include #include "libsbefifo.h" #include "sbefifo_private.h" -int sbefifo_connect(const char *fifo_path, struct sbefifo_context **out) +static bool proc_valid(int proc) +{ + if (proc == SBEFIFO_PROC_P9 || proc == SBEFIFO_PROC_P10) + return true; + + return false; +} + +int sbefifo_connect(const char *fifo_path, int proc, struct sbefifo_context **out) { struct sbefifo_context *sctx; int fd, rc; + if (!proc_valid(proc)) + return EINVAL; + sctx = malloc(sizeof(struct sbefifo_context)); if (!sctx) { fprintf(stderr, "Memory allocation error\n"); @@ -37,6 +49,7 @@ int sbefifo_connect(const char *fifo_path, struct sbefifo_context **out) *sctx = (struct sbefifo_context) { .fd = -1, + .proc = proc, }; fd = open(fifo_path, O_RDWR | O_SYNC); @@ -53,10 +66,13 @@ int sbefifo_connect(const char *fifo_path, struct sbefifo_context **out) return 0; } -int sbefifo_connect_transport(sbefifo_transport_fn transport, void *priv, struct sbefifo_context **out) +int sbefifo_connect_transport(int proc, sbefifo_transport_fn transport, void *priv, struct sbefifo_context **out) { struct sbefifo_context *sctx; + if (!proc_valid(proc)) + return EINVAL; + sctx = malloc(sizeof(struct sbefifo_context)); if (!sctx) { fprintf(stderr, "Memory allocation error\n"); @@ -65,6 +81,7 @@ int sbefifo_connect_transport(sbefifo_transport_fn transport, void *priv, struct *sctx = (struct sbefifo_context) { .fd = -1, + .proc = proc, .transport = transport, .priv = priv, }; @@ -84,6 +101,11 @@ void sbefifo_disconnect(struct sbefifo_context *sctx) free(sctx); } +int sbefifo_proc(struct sbefifo_context *sctx) +{ + return sctx->proc; +} + void sbefifo_debug(const char *fmt, ...) { va_list ap; diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h index cbfb76d..3af54b4 100644 --- a/libsbefifo/libsbefifo.h +++ b/libsbefifo/libsbefifo.h @@ -48,15 +48,19 @@ #define SBEFIFO_SEC_PIB_ERROR 0x0011 #define SBEFIFO_SEC_PARITY_ERROR 0x0012 +#define SBEFIFO_PROC_P9 0x01 +#define SBEFIFO_PROC_P10 0x02 + struct sbefifo_context; typedef int (*sbefifo_transport_fn)(uint8_t *msg, uint32_t msg_len, uint8_t *out, uint32_t *out_len, void *private_data); -int sbefifo_connect(const char *fifo_path, struct sbefifo_context **out); -int sbefifo_connect_transport(sbefifo_transport_fn transport, void *priv, struct sbefifo_context **out); +int sbefifo_connect(const char *fifo_path, int proc, struct sbefifo_context **out); +int sbefifo_connect_transport(int proc, sbefifo_transport_fn transport, void *priv, struct sbefifo_context **out); void sbefifo_disconnect(struct sbefifo_context *sctx); +int sbefifo_proc(struct sbefifo_context *sctx); int sbefifo_parse_output(struct sbefifo_context *sctx, uint32_t cmd, uint8_t *buf, uint32_t buflen, diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h index d94112f..6262c3e 100644 --- a/libsbefifo/sbefifo_private.h +++ b/libsbefifo/sbefifo_private.h @@ -65,6 +65,7 @@ struct sbefifo_context { int fd; + int proc; sbefifo_transport_fn transport; void *priv;