From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55683A04DB; Mon, 28 Sep 2020 18:44:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 19A8A1D6BE; Mon, 28 Sep 2020 18:43:10 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id AD72B1D6AF for ; Mon, 28 Sep 2020 18:43:05 +0200 (CEST) IronPort-SDR: gjK4s6Ah/39n95SL+rGcvN44Ih5CTvSgH9EcIe0lm6kMNRstle5qcBZ1hgVqFuWDvU7Mu+6GTS vRhbv2ecoiAg== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="223619755" X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="223619755" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 09:43:03 -0700 IronPort-SDR: gbtzWk1wlN7fBGcX+J6dT61hscfAx0WmPecHxLCX+k8jMGa4jAoRaSRfDJDxT5K/+h+zuc/U/q oVA5DPD2+ZVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="338250468" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by fmsmga004.fm.intel.com with ESMTP; 28 Sep 2020 09:43:02 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: patrick.fu@intel.com, Bruce Richardson , Kevin Laatz Date: Mon, 28 Sep 2020 17:42:24 +0100 Message-Id: <20200928164245.84997-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928164245.84997-1-bruce.richardson@intel.com> References: <20200721095140.719297-1-bruce.richardson@intel.com> <20200928164245.84997-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 04/25] raw/ioat: include extra info in error messages X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In case of any failures, include the function name and the line number of the error message in the message, to make tracking down the failure easier. Signed-off-by: Bruce Richardson Reviewed-by: Kevin Laatz --- drivers/raw/ioat/ioat_rawdev_test.c | 53 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/drivers/raw/ioat/ioat_rawdev_test.c b/drivers/raw/ioat/ioat_rawdev_test.c index c463a82ad6..8e7fd96afc 100644 --- a/drivers/raw/ioat/ioat_rawdev_test.c +++ b/drivers/raw/ioat/ioat_rawdev_test.c @@ -13,6 +13,23 @@ int ioat_rawdev_test(uint16_t dev_id); /* pre-define to keep compiler happy */ static struct rte_mempool *pool; static unsigned short expected_ring_size; +#define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__) + +static inline int +__rte_format_printf(3, 4) +print_err(const char *func, int lineno, const char *format, ...) +{ + va_list ap; + int ret; + + ret = fprintf(stderr, "In %s:%d - ", func, lineno); + va_start(ap, format); + ret += vfprintf(stderr, format, ap); + va_end(ap); + + return ret; +} + static int test_enqueue_copies(int dev_id) { @@ -42,7 +59,7 @@ test_enqueue_copies(int dev_id) (uintptr_t)src, (uintptr_t)dst, 0 /* no fence */) != 1) { - printf("Error with rte_ioat_enqueue_copy\n"); + PRINT_ERR("Error with rte_ioat_enqueue_copy\n"); return -1; } rte_ioat_do_copies(dev_id); @@ -50,18 +67,18 @@ test_enqueue_copies(int dev_id) if (rte_ioat_completed_copies(dev_id, 1, (void *)&completed[0], (void *)&completed[1]) != 1) { - printf("Error with rte_ioat_completed_copies\n"); + PRINT_ERR("Error with rte_ioat_completed_copies\n"); return -1; } if (completed[0] != src || completed[1] != dst) { - printf("Error with completions: got (%p, %p), not (%p,%p)\n", + PRINT_ERR("Error with completions: got (%p, %p), not (%p,%p)\n", completed[0], completed[1], src, dst); return -1; } for (i = 0; i < length; i++) if (dst_data[i] != src_data[i]) { - printf("Data mismatch at char %u\n", i); + PRINT_ERR("Data mismatch at char %u\n", i); return -1; } rte_pktmbuf_free(src); @@ -94,7 +111,7 @@ test_enqueue_copies(int dev_id) (uintptr_t)srcs[i], (uintptr_t)dsts[i], 0 /* nofence */) != 1) { - printf("Error with rte_ioat_enqueue_copy for buffer %u\n", + PRINT_ERR("Error with rte_ioat_enqueue_copy for buffer %u\n", i); return -1; } @@ -104,18 +121,18 @@ test_enqueue_copies(int dev_id) if (rte_ioat_completed_copies(dev_id, 64, (void *)completed_src, (void *)completed_dst) != RTE_DIM(srcs)) { - printf("Error with rte_ioat_completed_copies\n"); + PRINT_ERR("Error with rte_ioat_completed_copies\n"); return -1; } for (i = 0; i < RTE_DIM(srcs); i++) { char *src_data, *dst_data; if (completed_src[i] != srcs[i]) { - printf("Error with source pointer %u\n", i); + PRINT_ERR("Error with source pointer %u\n", i); return -1; } if (completed_dst[i] != dsts[i]) { - printf("Error with dest pointer %u\n", i); + PRINT_ERR("Error with dest pointer %u\n", i); return -1; } @@ -123,7 +140,7 @@ test_enqueue_copies(int dev_id) dst_data = rte_pktmbuf_mtod(dsts[i], char *); for (j = 0; j < length; j++) if (src_data[j] != dst_data[j]) { - printf("Error with copy of packet %u, byte %u\n", + PRINT_ERR("Error with copy of packet %u, byte %u\n", i, j); return -1; } @@ -150,26 +167,26 @@ ioat_rawdev_test(uint16_t dev_id) rte_rawdev_info_get(dev_id, &info, sizeof(p)); if (p.ring_size != expected_ring_size) { - printf("Error, initial ring size is not as expected (Actual: %d, Expected: %d)\n", + PRINT_ERR("Error, initial ring size is not as expected (Actual: %d, Expected: %d)\n", (int)p.ring_size, expected_ring_size); return -1; } p.ring_size = IOAT_TEST_RINGSIZE; if (rte_rawdev_configure(dev_id, &info, sizeof(p)) != 0) { - printf("Error with rte_rawdev_configure()\n"); + PRINT_ERR("Error with rte_rawdev_configure()\n"); return -1; } rte_rawdev_info_get(dev_id, &info, sizeof(p)); if (p.ring_size != IOAT_TEST_RINGSIZE) { - printf("Error, ring size is not %d (%d)\n", + PRINT_ERR("Error, ring size is not %d (%d)\n", IOAT_TEST_RINGSIZE, (int)p.ring_size); return -1; } expected_ring_size = p.ring_size; if (rte_rawdev_start(dev_id) != 0) { - printf("Error with rte_rawdev_start()\n"); + PRINT_ERR("Error with rte_rawdev_start()\n"); return -1; } @@ -180,7 +197,7 @@ ioat_rawdev_test(uint16_t dev_id) 2048, /* data room size */ info.socket_id); if (pool == NULL) { - printf("Error with mempool creation\n"); + PRINT_ERR("Error with mempool creation\n"); return -1; } @@ -189,14 +206,14 @@ ioat_rawdev_test(uint16_t dev_id) snames = malloc(sizeof(*snames) * nb_xstats); if (snames == NULL) { - printf("Error allocating xstat names memory\n"); + PRINT_ERR("Error allocating xstat names memory\n"); goto err; } rte_rawdev_xstats_names_get(dev_id, snames, nb_xstats); ids = malloc(sizeof(*ids) * nb_xstats); if (ids == NULL) { - printf("Error allocating xstat ids memory\n"); + PRINT_ERR("Error allocating xstat ids memory\n"); goto err; } for (i = 0; i < nb_xstats; i++) @@ -204,7 +221,7 @@ ioat_rawdev_test(uint16_t dev_id) stats = malloc(sizeof(*stats) * nb_xstats); if (stats == NULL) { - printf("Error allocating xstat memory\n"); + PRINT_ERR("Error allocating xstat memory\n"); goto err; } @@ -224,7 +241,7 @@ ioat_rawdev_test(uint16_t dev_id) rte_rawdev_stop(dev_id); if (rte_rawdev_xstats_reset(dev_id, NULL, 0) != 0) { - printf("Error resetting xstat values\n"); + PRINT_ERR("Error resetting xstat values\n"); goto err; } -- 2.25.1