From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id A5F19A0471
	for <public@inbox.dpdk.org>; Mon, 17 Jun 2019 17:57:10 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 8B6CD1BF60;
	Mon, 17 Jun 2019 17:56:22 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D8D991BF37
 for <dev@dpdk.org>; Mon, 17 Jun 2019 17:56:14 +0200 (CEST)
Received: from pps.filterd (m0045851.ppops.net [127.0.0.1])
 by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id
 x5HFppxK000998 for <dev@dpdk.org>; Mon, 17 Jun 2019 08:56:14 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : subject
 : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0818;
 bh=vQ+Gi/hsSTh9p7NkkPeM45EWx0sat8qLWvifkFdnsJ0=;
 b=lRu/saQg5I4GFRhqrqbPBTcau6U5LUvXiKml+2yrJV9010xNMkPUZCTzpkrF4csFOG9w
 3ZkiM8dHhMZkOSwH05LmiJlzN0ZLw5shUrGvIK3Ns/Ezsh5wvlM2Xvp7jyCwyZXfEGLh
 hxDKE416GHSpXe24FRSZ31if5wm4GRuKdUnSs98+/8QkoiV90ejIy224t3nprvk9JMf5
 FcOOgwWhLgNAN0YcYC+gSQ9/g8FFL7NEorLnjBWwNVyLiHmLQoOLikDaMj9vbuJhzzE7
 F8JN/kxdMgW425F7qwsqxoDsEr1Uyouwc4o71t58TnOuCt9jCR1Z6xCisXXOgTAHTACW Bw== 
Received: from sc-exch04.marvell.com ([199.233.58.184])
 by mx0b-0016f401.pphosted.com with ESMTP id 2t506hyax9-6
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)
 for <dev@dpdk.org>; Mon, 17 Jun 2019 08:56:14 -0700
Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com
 (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 17 Jun
 2019 08:56:06 -0700
Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com
 (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend
 Transport; Mon, 17 Jun 2019 08:56:06 -0700
Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])
 by maili.marvell.com (Postfix) with ESMTP id 5B8AB3F703F;
 Mon, 17 Jun 2019 08:56:05 -0700 (PDT)
From: <jerinj@marvell.com>
To: <dev@dpdk.org>, Jerin Jacob <jerinj@marvell.com>, Nithin Dabilpuram
 <ndabilpuram@marvell.com>, Vamsi Attunuru <vattunuru@marvell.com>
Date: Mon, 17 Jun 2019 21:25:15 +0530
Message-ID: <20190617155537.36144-6-jerinj@marvell.com>
X-Mailer: git-send-email 2.21.0
In-Reply-To: <20190617155537.36144-1-jerinj@marvell.com>
References: <20190601014905.45531-1-jerinj@marvell.com>
 <20190617155537.36144-1-jerinj@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, ,
 definitions=2019-06-17_07:, , signatures=0
Subject: [dpdk-dev] [PATCH v3 05/27] common/octeontx2: add runtime log infra
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Jerin Jacob <jerinj@marvell.com>

Various consumers of this common code need runtime
logging infrastructure. This patch adds the same.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/common/octeontx2/Makefile             |  1 +
 drivers/common/octeontx2/meson.build          |  1 +
 drivers/common/octeontx2/otx2_common.c        | 85 +++++++++++++++++++
 drivers/common/octeontx2/otx2_common.h        | 36 ++++++++
 .../rte_common_octeontx2_version.map          | 11 +++
 5 files changed, 134 insertions(+)
 create mode 100644 drivers/common/octeontx2/otx2_common.c

diff --git a/drivers/common/octeontx2/Makefile b/drivers/common/octeontx2/Makefile
index e5737532a..3fd67f0ab 100644
--- a/drivers/common/octeontx2/Makefile
+++ b/drivers/common/octeontx2/Makefile
@@ -25,6 +25,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-y += otx2_mbox.c
+SRCS-y += otx2_common.c
 
 LDLIBS += -lrte_eal
 LDLIBS += -lrte_ethdev
diff --git a/drivers/common/octeontx2/meson.build b/drivers/common/octeontx2/meson.build
index 34f8aaea7..4771b1942 100644
--- a/drivers/common/octeontx2/meson.build
+++ b/drivers/common/octeontx2/meson.build
@@ -4,6 +4,7 @@
 
 sources= files(
 		'otx2_mbox.c',
+		'otx2_common.c',
 	       )
 
 extra_flags = []
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
new file mode 100644
index 000000000..a4b91b4f1
--- /dev/null
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
+#include <rte_log.h>
+
+#include "otx2_common.h"
+
+/**
+ * @internal
+ */
+int otx2_logtype_base;
+/**
+ * @internal
+ */
+int otx2_logtype_mbox;
+/**
+ * @internal
+ */
+int otx2_logtype_npa;
+/**
+ * @internal
+ */
+int otx2_logtype_nix;
+/**
+ * @internal
+ */
+int otx2_logtype_npc;
+/**
+ * @internal
+ */
+int otx2_logtype_tm;
+/**
+ * @internal
+ */
+int otx2_logtype_sso;
+/**
+ * @internal
+ */
+int otx2_logtype_tim;
+/**
+ * @internal
+ */
+int otx2_logtype_dpi;
+
+RTE_INIT(otx2_log_init);
+static void
+otx2_log_init(void)
+{
+	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
+	if (otx2_logtype_base >= 0)
+		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
+
+	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
+	if (otx2_logtype_mbox >= 0)
+		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
+
+	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
+	if (otx2_logtype_npa >= 0)
+		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
+
+	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
+	if (otx2_logtype_nix >= 0)
+		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
+
+	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
+	if (otx2_logtype_npc >= 0)
+		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
+
+	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
+	if (otx2_logtype_tm >= 0)
+		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
+
+	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
+	if (otx2_logtype_sso >= 0)
+		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
+
+	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
+	if (otx2_logtype_tim >= 0)
+		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
+
+	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
+	if (otx2_logtype_dpi >= 0)
+		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
+}
diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
index b0c19266b..58fcf5a41 100644
--- a/drivers/common/octeontx2/otx2_common.h
+++ b/drivers/common/octeontx2/otx2_common.h
@@ -33,6 +33,42 @@
 #define __hot   __attribute__((hot))
 #endif
 
+/* Log */
+extern int otx2_logtype_base;
+extern int otx2_logtype_mbox;
+extern int otx2_logtype_npa;
+extern int otx2_logtype_nix;
+extern int otx2_logtype_sso;
+extern int otx2_logtype_npc;
+extern int otx2_logtype_tm;
+extern int otx2_logtype_tim;
+extern int otx2_logtype_dpi;
+
+#define OTX2_CLNRM  "\x1b[0m"
+#define OTX2_CLRED  "\x1b[31m"
+
+#define otx2_err(fmt, args...)						\
+	RTE_LOG(ERR, PMD, ""OTX2_CLRED"%s():%u " fmt OTX2_CLNRM"\n",	\
+				__func__, __LINE__, ## args)
+
+#define otx2_info(fmt, args...)						\
+	RTE_LOG(INFO, PMD, fmt"\n", ## args)
+
+#define otx2_dbg(subsystem, fmt, args...)				\
+	rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,		\
+		"[%s] %s():%u " fmt "\n",				\
+		 #subsystem, __func__, __LINE__, ##args)
+
+#define otx2_base_dbg(fmt, ...) otx2_dbg(base, fmt, ##__VA_ARGS__)
+#define otx2_mbox_dbg(fmt, ...) otx2_dbg(mbox, fmt, ##__VA_ARGS__)
+#define otx2_npa_dbg(fmt, ...) otx2_dbg(npa, fmt, ##__VA_ARGS__)
+#define otx2_nix_dbg(fmt, ...) otx2_dbg(nix, fmt, ##__VA_ARGS__)
+#define otx2_sso_dbg(fmt, ...) otx2_dbg(sso, fmt, ##__VA_ARGS__)
+#define otx2_npc_dbg(fmt, ...) otx2_dbg(npc, fmt, ##__VA_ARGS__)
+#define otx2_tm_dbg(fmt, ...) otx2_dbg(tm, fmt, ##__VA_ARGS__)
+#define otx2_tim_dbg(fmt, ...) otx2_dbg(tim, fmt, ##__VA_ARGS__)
+#define otx2_dpi_dbg(fmt, ...) otx2_dbg(dpi, fmt, ##__VA_ARGS__)
+
 /* IO Access */
 #define otx2_read64(addr) rte_read64_relaxed((void *)(addr))
 #define otx2_write64(val, addr) rte_write64_relaxed((val), (void *)(addr))
diff --git a/drivers/common/octeontx2/rte_common_octeontx2_version.map b/drivers/common/octeontx2/rte_common_octeontx2_version.map
index 9a61188cd..02f03e177 100644
--- a/drivers/common/octeontx2/rte_common_octeontx2_version.map
+++ b/drivers/common/octeontx2/rte_common_octeontx2_version.map
@@ -1,4 +1,15 @@
 DPDK_19.08 {
+	global:
+
+	otx2_logtype_base;
+	otx2_logtype_dpi;
+	otx2_logtype_mbox;
+	otx2_logtype_npa;
+	otx2_logtype_npc;
+	otx2_logtype_nix;
+	otx2_logtype_sso;
+	otx2_logtype_tm;
+	otx2_logtype_tim;
 
 	local: *;
 };
-- 
2.21.0