From patchwork Fri Feb 10 01:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123626 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 469C941C58; Fri, 10 Feb 2023 02:08:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 312D9410D0; Fri, 10 Feb 2023 02:08:05 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id E683940EDB for ; Fri, 10 Feb 2023 02:08:03 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id u9so4909581plf.3 for ; Thu, 09 Feb 2023 17:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xEjvKrBAUqZeBvyRL0ll8ue+hM/7XowkxMi6ngrjkWo=; b=50XX/QySJTKolTOu8WsFFMZtvwvzAwYjVKuibp6A/fKeGEqOvLSzjFarPMh3zrToq3 zJo2f1rTcwo4kd4uPuCFtkhxuPZilA6sdRRJfosXhejULUYQJFtSw9OHympLZnCnd2g9 ejplc9KXaO2yVfuam/ZEH4v4WD9bKkyk9cTAbaP8aIeiYpyydQMKo9fI6C/5PqSG7jNN YXDVggxG32kTfDZVwIUDoeyUWaJnvaf2ppRGgXYrIQRpEP5eCh6ooSMscm9EGAf53EIV qkT6JUi6qk0+SFjHrhD7YNkkw2pjvCcYc+khuOzlpws6ythnh6nj5uyAFHA73F6Q7AW7 Nahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xEjvKrBAUqZeBvyRL0ll8ue+hM/7XowkxMi6ngrjkWo=; b=wgemMnvzqwC0dbdR9sqiwyD8X64x3QwUZi4wwqSoI3spHdRk0J+z9Oi6HSUOu7MeR9 +TgB+SzaI7dzl5xUa83IOZelYfJYJ9oWmDQ+s3YqHBUifOH6nKcQjsHufqmu7pt8SI9u zWInyqLrEVPqhkqnny1loTY6QIsxU/HvI0KHQY+ldnIjzl5cEgF6NR76Quus83/NabeO 7qOYu5AA8zge+dVmIwUhqYHxy3NOvTFYsozI9vs/V4PJSkWtWrfUeQl6iUDrhgWCNZCc 9scVrzpvcVBftdSAkYu7Ra0wS2x/Uhzq6iDy2BB3RYfPeTu3gscgbCUU1++alE9bsfsF /g/w== X-Gm-Message-State: AO0yUKXMd4tW67cbNJ3QzrsfKSFXIRVYgtqjRLaA2k7zLmkP9yDWBzAF U+Sxw36iKFlbsZrc6rcBHANOjE55i2gWyBIJ1QI= X-Google-Smtp-Source: AK7set+CpXzmpOxTxPUved+y8nTuTBDb53etkuZ7bIbVNp/RfDpNhlx1Js2dljkLRkxGOmuFw58niA== X-Received: by 2002:a17:902:f20b:b0:199:aae:7569 with SMTP id m11-20020a170902f20b00b001990aae7569mr10019916plc.28.1675991282901; Thu, 09 Feb 2023 17:08:02 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:02 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jiayu.hu@intel.com, Konstantin Ananyev , Mark Kavanagh Subject: [PATCH v3 01/16] gso: remove logtype Date: Thu, 9 Feb 2023 17:07:09 -0800 Message-Id: <20230210010724.890413-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If a large packet is passed into GSO routines of unknown protocol then library would log a message and pass it through. This is incorrect behaviour on many levels: - it allows oversize packet to get passed on to NIC driver - no direct return is visible to applications - if it happens once, many more will follow and log will fill. - bonus it is only log message with GSO type. The fix is to just return -EINVAL which is what this library does in many other places when looking at headers. Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO") Cc: jiayu.hu@intel.com Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 2 +- lib/eal/include/rte_log.h | 1 - lib/gso/rte_gso.c | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, - {RTE_LOGTYPE_GSO, "lib.gso"}, + {RTE_LOGTYPE_USER1, "user1"}, {RTE_LOGTYPE_USER2, "user2"}, {RTE_LOGTYPE_USER3, "user3"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 6d2b0856a565..97d6b26a9967 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -46,7 +46,6 @@ extern "C" { #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ #define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ -#define RTE_LOGTYPE_GSO 20 /**< Log related to GSO. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 24 /**< User-defined log type 1. */ diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index 4b59217c16ee..19c351769fcc 100644 --- a/lib/gso/rte_gso.c +++ b/lib/gso/rte_gso.c @@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt, indirect_pool, pkts_out, nb_pkts_out); } else { /* unsupported packet, skip */ - RTE_LOG(DEBUG, GSO, "Unsupported packet type\n"); - ret = 0; + ret = -EINVAL; } if (ret < 0) { From patchwork Fri Feb 10 01:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123627 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61D6A41C58; Fri, 10 Feb 2023 02:08:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65007427F2; Fri, 10 Feb 2023 02:08:07 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 0E44D40EDB for ; Fri, 10 Feb 2023 02:08:04 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id b5so4904047plz.5 for ; Thu, 09 Feb 2023 17:08:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UPtCDG0D5nzLcLmm+TqbH2Ry/IqpvLKXmxojNPcvGac=; b=xhr8M+x9Xq531RzhVvuemj7ut6p30idShzqRPbwfUBYZOS2O7WPh0UwYI7cLWLMzIK Ky58y0h/KH+vi/8bsjycu+BVl1j9AbCFESJEtkl7c4kmGtP7Rz0LtZb4lGTdmZbFnuV1 C8anp27I0qQEY3xc0LM5z2Ol73z477kUa5vzViYc2FtOHFyhyUdZwg1ipkcEr6PtRphX ACsR1c8HTPzmuJaxssPI5FKVKLYyR6+pbVL/nUrPKMaC6/mkD86afkH54eULgxswFoA2 XoPwdEwmP0rmURQaFyBhfFS0o7Q3r6/mNhCLs45yn79t9vQ8TQE1ABI0LcGQ3bJpUuYX 4QSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UPtCDG0D5nzLcLmm+TqbH2Ry/IqpvLKXmxojNPcvGac=; b=ejFy6RMHpom2kqUaZAn2mmNtu3OQB2oPLvz4KM+7JpKK8eVAMmupA9ty/ppORHP0sp rwKowx6XnGQVjUXh83npqJSEtmV+By9rKPUipET2+HBsWsIOFNrI+b12PcqQ5B7Cs1dz jHRBKnMb3G7agVe6f5AwKhmnBjJn1/hgQreBIlTSp3qW3esq11iSS0Xt50umA2sbucCA F7aVHbtIjBqQ7athr2bkhrxS3waKNEnBhrD+opke4Ti2u3qIQEKmDv1PDBpLjspuQO3d 76Nxb5zLA9//RglemqMIWZVdUk2lnDBFCQdC/acdMVztXIU2eZCSCZMGpQ0KoY4xkIHC N9qg== X-Gm-Message-State: AO0yUKWSrFH71L53iic1hTQrg5CIksRtBTFBJ7YCA3BTzWj2NJFqZEFC Ne/9NaytZScJBS49VB+O6n5aucuYEfAyiJSynj8= X-Google-Smtp-Source: AK7set9pvCJsoBHOhrXSE8hwDbIlketvQzGpxv6Sg0xFRookxe2px1vcK3O1vgP0D9Qe+5eL/ISovQ== X-Received: by 2002:a17:902:e843:b0:199:2a89:f912 with SMTP id t3-20020a170902e84300b001992a89f912mr15083671plg.20.1675991283904; Thu, 09 Feb 2023 17:08:03 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:03 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 02/16] log: drop unused RTE_LOGTYPE_TIMER Date: Thu, 9 Feb 2023 17:07:10 -0800 Message-Id: <20230210010724.890413-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The timer code does not use rte_log. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index c369154cb1ea..e7ccde1c9ccd 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_MALLOC, "lib.malloc"}, {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, - {RTE_LOGTYPE_TIMER, "lib.timer"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 97d6b26a9967..361d1ad96299 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -30,7 +30,7 @@ extern "C" { #define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ #define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ -#define RTE_LOGTYPE_TIMER 4 /**< Log related to timers. */ + /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ From patchwork Fri Feb 10 01:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123628 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E16641C58; Fri, 10 Feb 2023 02:08:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73C1A42BD9; Fri, 10 Feb 2023 02:08:08 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 066BB410F9 for ; Fri, 10 Feb 2023 02:08:06 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so7725129pjb.4 for ; Thu, 09 Feb 2023 17:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=rRaHEcgKhr6f4ZEp/eogfoncJCoRyi1Nzc9ZoQvpvSPBzzkUbX8W7YhdYCxws8fuTS 9qgXHWqMt32GnihBE6fNgYtiuNTTSPm9FPQUGI92KwdumuG5I6/zgFgqEpjX6EmuxqtI r4xB/ay5FAhy9XM++g8ufuS6R4649Paf3EpUyJTRBI2jzcE94mVqFpnvEBvQ+1bvCel0 5KseLvwReHn4UVd6YsQqiUdROCP+QvB70YsxT2Ps0MiOzayMIAnwTTMvn/AnMcG41MNa VGP7mF1GRiHo5mbpZDeGJryglS9jbmv60xv2oyPdvVcXATBegvx/ih7zbTXs6W7fIf4+ oEyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=dlrJ7CHwTS0DvadVWxWk7n0ZxPfnoDhlaKsENvASLylBoGyX2ihh9VMH4jMsHF61D+ P4GqwDnO379iypYa63WjTQLsN1W4KA2Y6yeAmcK78AIab5nreKeAVqZLTcakTP1ZyDh5 ryWWpZIK7qdJathhcUx2ku5Jl/AKcCZDZcgMafQ0PPsK5K6zAbga7IFi2gQRNiPCtog6 FM3DPmIIgn7Lo84DnNQdNGHRPt3HQvhWzesT+O1R5F2+/tcq2lIL4Ov1l523+rSILshj O6+Mk3vEvo2tYG3yYFWG0Gkp0QGLWDUx/WjTy8OW1W9YcUP8ZJ06intBLqGK5p7w9azs N2mw== X-Gm-Message-State: AO0yUKUjlF/QlNCfY/0b4YAdcr5KCDqew2OZoZdjyiMnvrb+8pYXihVG yzyo3WQ5/8aDxS62DNFTWV8DXyFNojgxfood7vY= X-Google-Smtp-Source: AK7set/NOibVje4H96h5pkeMyG8qVfCzbkinzlha2J6nYx+RYfGsXsGPrGXBM1MdaY4vRMrSsp6dIw== X-Received: by 2002:a17:903:1206:b0:196:15af:e6de with SMTP id l6-20020a170903120600b0019615afe6demr15519708plh.68.1675991284935; Thu, 09 Feb 2023 17:08:04 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Byron Marohn , Yipeng Wang Subject: [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type Date: Thu, 9 Feb 2023 17:07:11 -0800 Message-Id: <20230210010724.890413-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace all uses of global logtype with a local log type. Do not break message formats across source lines. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/efd/rte_efd.c | 106 +++++++++++++++----------------- 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index e7ccde1c9ccd..675f3d07bbe3 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_MBUF, "lib.mbuf"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, - {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_USER1, "user1"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 361d1ad96299..a90fa629168d 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -44,7 +44,7 @@ extern "C" { #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ #define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ -#define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ + /* was RTE_LOGTYPE_EFD */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ /* these log types can be used in an application */ diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index 686a13775742..23316ef7300f 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = { }; EAL_REGISTER_TAILQ(rte_efd_tailq); +RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO); + +#define EFD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args) + /** Internal permutation array used to shuffle bins into pseudorandom groups */ const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = { { @@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); if (online_cpu_socket_bitmask == 0) { - RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled " - "in the bitmask\n"); + EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask"); return NULL; } if (max_num_rules == 0) { - RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n"); + EFD_LOG(ERR, "Max num rules must be higher than 0"); return NULL; } @@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, EFD, "tailq entry allocation failed\n"); + EFD_LOG(ERR, "tailq entry allocation failed"); goto error_unlock_exit; } @@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD table management structure" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD table management structureon socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure " - "on socket %u\n", offline_cpu_socket); + EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u", + offline_cpu_socket); table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES; table->num_rules = 0; @@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (key_array == NULL) { - RTE_LOG(ERR, EFD, "Allocating key array" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating key array on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } table->keys = key_array; strlcpy(table->name, name, sizeof(table->name)); - RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks," - " which potentially supports %u entries\n", - num_chunks, table->max_num_rules); + EFD_LOG(DEBUG, + "Creating an EFD table with %u chunks, which potentially supports %u entries", + num_chunks, table->max_num_rules); /* Make sure all the allocatable table pointers are NULL initially */ for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++) @@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, socket_id); if (table->chunks[socket_id] == NULL) { - RTE_LOG(ERR, EFD, - "Allocating EFD online table on " - "socket %u failed\n", - socket_id); + EFD_LOG(ERR, + "Allocating EFD online table on socket %u failed", + socket_id); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD online table of size " - "%"PRIu64" bytes (%.2f MB) on socket %u\n", - online_table_size, - (float) online_table_size / - (1024.0F * 1024.0F), - socket_id); + EFD_LOG(DEBUG, + "Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + online_table_size, + (float) online_table_size / (1024.0F * 1024.0F), + socket_id); } } @@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table->offline_chunks == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u " - "failed\n", offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD offline table on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD offline table of size %"PRIu64" bytes " - " (%.2f MB) on socket %u\n", offline_table_size, - (float) offline_table_size / (1024.0F * 1024.0F), - offline_cpu_socket); + EFD_LOG(DEBUG, + "Allocated EFD offline table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + offline_table_size, + (float) offline_table_size / (1024.0F * 1024.0F), + offline_cpu_socket); te->data = (void *) table; TAILQ_INSERT_TAIL(efd_list, te, next); @@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules), offline_cpu_socket, 0); if (r == NULL) { - RTE_LOG(ERR, EFD, "memory allocation failed\n"); + EFD_LOG(ERR, "ring memory allocation failed"); rte_efd_free(table); return NULL; } @@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table, if (found == 0) { /* Key does not exist. Insert the rule into the bin/group */ if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) { - RTE_LOG(ERR, EFD, - "Fatal: No room remaining for insert into " - "chunk %u group %u bin %u\n", - *chunk_id, - current_group_id, *bin_id); + EFD_LOG(ERR, + "Fatal: No room remaining for insert into chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); return RTE_EFD_UPDATE_FAILED; } if (unlikely(current_group->num_rules == (EFD_MAX_GROUP_NUM_RULES - 1))) { - RTE_LOG(INFO, EFD, "Warn: Insert into last " - "available slot in chunk %u " - "group %u bin %u\n", *chunk_id, - current_group_id, *bin_id); + EFD_LOG(NOTICE, + "Insert into last available slot in chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); status = RTE_EFD_UPDATE_WARN_GROUP_FULL; } @@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table, uint8_t choice = 0; for (;;) { if (current_group != new_group && - new_group->num_rules + bin_size > - EFD_MAX_GROUP_NUM_RULES) { - RTE_LOG(DEBUG, EFD, - "Unable to move_groups to dest group " - "containing %u entries." - "bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, - choice - 1); + new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) { + EFD_LOG(DEBUG, + "Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, + choice - 1); goto next_choice; } move_groups(*bin_id, bin_size, new_group, current_group); @@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table, if (!ret) return status; - RTE_LOG(DEBUG, EFD, - "Failed to find perfect hash for group " - "containing %u entries. bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, choice - 1); + EFD_LOG(DEBUG, + "Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, choice - 1); + /* Restore groups modified to their previous state */ revert_groups(current_group, new_group, bin_size); From patchwork Fri Feb 10 01:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123629 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0537241C58; Fri, 10 Feb 2023 02:08:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A135E42D0D; Fri, 10 Feb 2023 02:08:10 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 5D963410F9 for ; Fri, 10 Feb 2023 02:08:07 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id nn4-20020a17090b38c400b00233a6f118d0so1155289pjb.2 for ; Thu, 09 Feb 2023 17:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UpTet1GyA1n7NMsLggHkgFdnQKwxWl7iUtPSJR1Vmn0=; b=OSQDuQXZjiwf74N3cX4RHjDky0pqgEUWCRA7Jr6l9BLTMvKsD2H6rdJC8tZbRb8eQG rOspcgYfXBRsGAVrnGvYk59PnD5uIPeBY0G2Q3h1I79zhqswKzWP4e1OtvmJbfJHMVEP VIs5nJPuaqn58jKv+8WH6I4UB6irgZz3p3Ljd6+ma3fr6McxxvowrGrC/SB0gEhsBK/S /NmoFe+oTa7Y+W7CVdUQK9iQTqKbBiYeHCQUjLiEQvjYSpXCRCyAerL91flpMH4QhvPa AaZ8rnBTkmd0Q4BH0Xp4jKrqq0Hb7EfCm/+Z68B0UwHMM6KGJmy2Seg1akOC4Ho+gCPP QcLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UpTet1GyA1n7NMsLggHkgFdnQKwxWl7iUtPSJR1Vmn0=; b=Ef0d91mBjCpdRRv4omMvr7gCDudN73gTLcZHxgT6MSg09pbj8/1n1Un878oOb9Z+TV 0IKtXwoC3NOkQvBp3llqPKDHHaY062/sMJG2McKILuXiitAEwWvUOSzKPICJko4wKMl+ sKPvGR/F4T9O47NZPd++7KbXPMP86ZZv4x4kJmeOyFnsb4HQSABecceat21k8PYOq+qW BnJojI0I0okdHDK+CTFnrWS01N4qSi/uRcVUhyWxPTML3u+z/8mPTcyGnUbr7m8uxnw0 yKbr+gIFdC8y7AtJziwQijC2qzCeLJYQR1OPoVZw3nefyxobElujuuc5NEIEIRwKphVC bArQ== X-Gm-Message-State: AO0yUKXU6izAicpgPFo5wNMfpeT7hiPIloe2PH50FntXqauC6S4ZGJX5 4D8eqlXgDOa9rP5TaxY+Tc9D+uKyad5Ot3lTmL4= X-Google-Smtp-Source: AK7set8N0S10T7UFFy0vwPU1J53h+Hw3Blp6TznOB6m4TIVPOcTg+M0rFmtQNZWNbu7KgUOtZU8NEQ== X-Received: by 2002:a17:902:c94e:b0:19a:7217:32be with SMTP id i14-20020a170902c94e00b0019a721732bemr452711pla.1.1675991286182; Thu, 09 Feb 2023 17:08:06 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [PATCH v3 04/16] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Date: Thu, 9 Feb 2023 17:07:12 -0800 Message-Id: <20230210010724.890413-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Introduce a new dynamic logtype for mbuf related messages. Since this is used in multiple files put one macro in mbuf_log.h Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/mbuf/mbuf_log.h | 10 ++++++++++ lib/mbuf/rte_mbuf.c | 20 ++++++++++++-------- lib/mbuf/rte_mbuf_dyn.c | 15 ++++++++------- lib/mbuf/rte_mbuf_pool_ops.c | 5 +++-- 6 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 lib/mbuf/mbuf_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 675f3d07bbe3..128bfabd94e1 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, - {RTE_LOGTYPE_MBUF, "lib.mbuf"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a90fa629168d..1f259b2abc5a 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -42,7 +42,7 @@ extern "C" { #define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ -#define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ + /* was RTE_LOGTYPE_MBUF */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ /* was RTE_LOGTYPE_EFD */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h new file mode 100644 index 000000000000..fe97f338c9b7 --- /dev/null +++ b/lib/mbuf/mbuf_log.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation. + * Copyright 2014 6WIND S.A. + */ + +extern int mbuf_logtype; + +#define MBUF_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, mbuf_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c index cfd8062f1e6a..133fd3ba55be 100644 --- a/lib/mbuf/rte_mbuf.c +++ b/lib/mbuf/rte_mbuf.c @@ -20,6 +20,8 @@ #include #include +#include "mbuf_log.h" + /* * pktmbuf pool constructor, given as a callback function to * rte_mempool_create(), or called directly if using @@ -227,8 +229,8 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, int ret; if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { - RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", - priv_size); + MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned", + priv_size); rte_errno = EINVAL; return NULL; } @@ -247,7 +249,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, mp_ops_name = rte_mbuf_best_mempool_ops(); ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL); if (ret != 0) { - RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); + MBUF_LOG(ERR, "error setting mempool handler"); rte_mempool_free(mp); rte_errno = -ret; return NULL; @@ -293,7 +295,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, int ret; if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { - RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", + MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned", priv_size); rte_errno = EINVAL; return NULL; @@ -303,12 +305,12 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, const struct rte_pktmbuf_extmem *extm = ext_mem + i; if (!extm->elt_size || !extm->buf_len || !extm->buf_ptr) { - RTE_LOG(ERR, MBUF, "invalid extmem descriptor\n"); + MBUF_LOG(ERR, "invalid extmem descriptor"); rte_errno = EINVAL; return NULL; } if (data_room_size > extm->elt_size) { - RTE_LOG(ERR, MBUF, "ext elt_size=%u is too small\n", + MBUF_LOG(ERR, "ext elt_size=%u is too small", priv_size); rte_errno = EINVAL; return NULL; @@ -317,7 +319,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, } /* Check whether enough external memory provided. */ if (n_elts < n) { - RTE_LOG(ERR, MBUF, "not enough extmem\n"); + MBUF_LOG(ERR, "not enough extmem"); rte_errno = ENOMEM; return NULL; } @@ -338,7 +340,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, mp_ops_name = rte_mbuf_best_mempool_ops(); ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL); if (ret != 0) { - RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); + MBUF_LOG(ERR, "error setting mempool handler"); rte_mempool_free(mp); rte_errno = -ret; return NULL; @@ -936,3 +938,5 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) return 0; } + +RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO); diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c index 35839e938cc5..ef8d6069b37a 100644 --- a/lib/mbuf/rte_mbuf_dyn.c +++ b/lib/mbuf/rte_mbuf_dyn.c @@ -17,6 +17,8 @@ #include #include +#include "mbuf_log.h" + #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn" struct mbuf_dynfield_elt { @@ -116,7 +118,7 @@ init_shared_mem(void) mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME); } if (mz == NULL) { - RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n"); + MBUF_LOG(ERR, "Failed to get mbuf dyn shared memory"); return -1; } @@ -315,7 +317,8 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params, shm->free_space[i] = 0; process_score(); - RTE_LOG(DEBUG, MBUF, "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd\n", + MBUF_LOG(DEBUG, + "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd", params->name, params->size, params->align, params->flags, offset); @@ -489,7 +492,7 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params, shm->free_flags &= ~(1ULL << bitnum); - RTE_LOG(DEBUG, MBUF, "Registered dynamic flag %s (fl=0x%x) -> %u\n", + MBUF_LOG(DEBUG, "Registered dynamic flag %s (fl=0x%x) -> %u", params->name, params->flags, bitnum); return bitnum; @@ -590,8 +593,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag, offset = rte_mbuf_dynfield_register(&field_desc); if (offset < 0) { - RTE_LOG(ERR, MBUF, - "Failed to register mbuf field for timestamp\n"); + MBUF_LOG(ERR, "Failed to register mbuf field for timestamp"); return -1; } if (field_offset != NULL) @@ -600,8 +602,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag, strlcpy(flag_desc.name, flag_name, sizeof(flag_desc.name)); offset = rte_mbuf_dynflag_register(&flag_desc); if (offset < 0) { - RTE_LOG(ERR, MBUF, - "Failed to register mbuf flag for %s timestamp\n", + MBUF_LOG(ERR, "Failed to register mbuf flag for %s timestamp", direction); return -1; } diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c index 4c91f4ce8569..8ec2710dc86d 100644 --- a/lib/mbuf/rte_mbuf_pool_ops.c +++ b/lib/mbuf/rte_mbuf_pool_ops.c @@ -8,6 +8,8 @@ #include #include +#include "mbuf_log.h" + int rte_mbuf_set_platform_mempool_ops(const char *ops_name) { @@ -31,8 +33,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name) return 0; } - RTE_LOG(ERR, MBUF, - "%s is already registered as platform mbuf pool ops\n", + MBUF_LOG(ERR, "%s is already registered as platform mbuf pool ops", (char *)mz->addr); return -EEXIST; } From patchwork Fri Feb 10 01:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123630 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52C4A41C58; Fri, 10 Feb 2023 02:08:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C74CE42D13; Fri, 10 Feb 2023 02:08:11 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 7F54E42C4D for ; Fri, 10 Feb 2023 02:08:08 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id w5so4874377plg.8 for ; Thu, 09 Feb 2023 17:08:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eVSpNaCMpdSLcdDy2JPj4FQ20idLaspbXmJCNoYTWJU=; b=yWy9xs79b4wucU4tb3cYF0YfKGHGGutNicRILqBecEu4JJAHq1zZi3vDSVBCNhlfBZ qBpBYYmIe0n5S9PnkBfPrHbmcwWvSlKD6rtY6v4/QSHjIY5P1P8moLlbnydPbyOBEqtc xIUB1fEyZHiaRDPOa33i9qEB+DWBlbP26Zd4SKAKczaeBQjD3QQHWtiAJZ4G2UCYkF1P lOAO4BO1ckuz/Hc6ZlGQl0031Uo+tiUEjyTAsUVaFTU1RwZcELKozfUjF9HegoE7luuX SP1dybU8g7ZMLNoYEbmjjQI1TT24e/1T4yaCwwaAwz0lke4nLFf6yTarBuzOVxb/pdrn hVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eVSpNaCMpdSLcdDy2JPj4FQ20idLaspbXmJCNoYTWJU=; b=UoPrffD9Zry5AFJ8TI4/xv1QAhkyPPXoBu2t+xcgW0lJr2NsubUky7OPrgrv60UIjJ wlFkDokjG9jaxlKzVwBmrVHGe8GF2zKbnMcY8q/KUGuKyakdWK5M1XSTASt9Fep2RB0R qNF6sdKSyI+LCF916FXakR5L9wRS1bG1R9XAemOQyW+y0XHimENmZJKfXcnvCYCzF65V 0fOxzZPb92caNPTzK7GZdN49dXWDVJEwdcBAkGuiJCJf30gds94OQ2l8JR85LOXQMV95 YqsB8o9sUPneUA+ABZnmj6Nh9NvSFARZhw+MbQE9lmtWVdYiSolVqR9hM8k7ewGT9t5X MTTQ== X-Gm-Message-State: AO0yUKWigStlRniI29mVL6hjAw58SpSJvnmYGvLCJpVAAx+FIBeCLFEX chhadU9D7CwoNnjZM24F+m1zsVQEKiC12VFb8+A= X-Google-Smtp-Source: AK7set+rgrTh4MnYTtVItpj2GP1VXeOF9vBGfbZN76SJKA7NnxJkRQpGFJwArRbDNVr/JNZ4bM3gjw== X-Received: by 2002:a17:902:ced1:b0:19a:593c:f385 with SMTP id d17-20020a170902ced100b0019a593cf385mr5132410plg.25.1675991287290; Thu, 09 Feb 2023 17:08:07 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev Subject: [PATCH v3 05/16] acl: replace LOGTYPE_ACL with dynamic type Date: Thu, 9 Feb 2023 17:07:13 -0800 Message-Id: <20230210010724.890413-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC. For ACL library use a dynamic type. The one message using RTE_LOGTYPE_MALLOC should have been under the ACL logtype anyway. The test code should not have been using fixed log type so just change that to stderr. Signed-off-by: Stephen Hemminger --- app/test/test_acl.c | 3 ++- lib/acl/acl_bld.c | 35 +++++++++++++++++---------------- lib/acl/acl_gen.c | 20 ++++++++++--------- lib/acl/acl_log.h | 13 ++++++++++++ lib/acl/rte_acl.c | 14 ++++++++----- lib/acl/tb_mem.c | 8 ++++++-- lib/eal/common/eal_common_log.c | 2 -- lib/eal/include/rte_log.h | 4 ++-- 8 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 lib/acl/acl_log.h diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 623f34682e69..75588978a720 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx, for (i = 0; i != num; i++) { rc = acl_ipv4vlan_check_rule(rules + i); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n", + fprintf(stderr, + "%s: rule #%u is invalid\n", __func__, i + 1); return rc; } diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c index 2816632803bd..143564151e29 100644 --- a/lib/acl/acl_bld.c +++ b/lib/acl/acl_bld.c @@ -5,6 +5,7 @@ #include #include "tb_mem.h" #include "acl.h" +#include "acl_log.h" #define ACL_POOL_ALIGN 8 #define ACL_POOL_ALLOC_MIN 0x800000 @@ -1014,8 +1015,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head, break; default: - RTE_LOG(ERR, ACL, - "Error in rule[%u] type - %hhu\n", + ACL_LOG(ERR, + "Error in rule[%u] type - %hhu", rule->f->data.userdata, rule->config->defs[n].type); return NULL; @@ -1371,7 +1372,7 @@ acl_build_tries(struct acl_build_context *context, last = build_one_trie(context, rule_sets, n, context->node_max); if (context->bld_tries[n].trie == NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1380,8 +1381,7 @@ acl_build_tries(struct acl_build_context *context, break; if (num_tries == RTE_DIM(context->tries)) { - RTE_LOG(ERR, ACL, - "Exceeded max number of tries: %u\n", + ACL_LOG(ERR, "Exceeded max number of tries: %u", num_tries); return -ENOMEM; } @@ -1406,7 +1406,7 @@ acl_build_tries(struct acl_build_context *context, */ last = build_one_trie(context, rule_sets, n, INT32_MAX); if (context->bld_tries[n].trie == NULL || last != NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1421,10 +1421,11 @@ acl_build_log(const struct acl_build_context *ctx) { uint32_t n; - RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Build phase for ACL \"%s\":\n" "node limit for tree split: %u\n" "nodes created: %u\n" - "memory consumed: %zu\n", + "memory consumed: %zu", ctx->acx->name, ctx->node_max, ctx->num_nodes, @@ -1432,7 +1433,7 @@ acl_build_log(const struct acl_build_context *ctx) for (n = 0; n < RTE_DIM(ctx->tries); n++) { if (ctx->tries[n].count != 0) - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "trie %u: number of rules: %u, indexes: %u\n", n, ctx->tries[n].count, ctx->tries[n].num_data_indexes); @@ -1523,8 +1524,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx, /* build phase runs out of memory. */ if (rc != 0) { - RTE_LOG(ERR, ACL, - "ACL context: %s, %s() failed with error code: %d\n", + ACL_LOG(ERR, + "ACL context: %s, %s() failed with error code: %d", bcx->acx->name, __func__, rc); return rc; } @@ -1565,9 +1566,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) for (i = 0; i != cfg->num_fields; i++) { if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid type: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].type, i); + ACL_LOG(ERR, + "ACL context: %s, invalid type: %hhu for %u-th field", + ctx->name, cfg->defs[i].type, i); return -EINVAL; } for (j = 0; @@ -1577,9 +1578,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) ; if (j == RTE_DIM(field_sizes)) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid size: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].size, i); + ACL_LOG(ERR, + "ACL context: %s, invalid size: %hhu for %u-th field\n", + ctx->name, cfg->defs[i].size, i); return -EINVAL; } } diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c index e759a2ca1598..84369b103947 100644 --- a/lib/acl/acl_gen.c +++ b/lib/acl/acl_gen.c @@ -4,6 +4,7 @@ #include #include "acl.h" +#include "acl_log.h" #define QRANGE_MIN ((uint8_t)INT8_MIN) @@ -32,18 +33,19 @@ struct rte_acl_indices { static void acl_gen_log_stats(const struct rte_acl_ctx *ctx, - const struct acl_node_counters *counts, - const struct rte_acl_indices *indices, - size_t max_size) + const struct acl_node_counters *counts, + const struct rte_acl_indices *indices, + size_t max_size) { - RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Gen phase for ACL \"%s\":\n" "runtime memory footprint on socket %d:\n" "single nodes/bytes used: %d/%zu\n" "quad nodes/vectors/bytes used: %d/%d/%zu\n" "DFA nodes/group64/bytes used: %d/%d/%zu\n" "match nodes/bytes used: %d/%zu\n" "total: %zu bytes\n" - "max limit: %zu bytes\n", + "max limit: %zu bytes", ctx->name, ctx->socket_id, counts->single, counts->single * sizeof(uint64_t), counts->quad, counts->quad_vectors, @@ -470,9 +472,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, XMM_SIZE; if (total_size > max_size) { - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "Gen phase for ACL ctx \"%s\" exceeds max_size limit, " - "bytes required: %zu, allowed: %zu\n", + "bytes required: %zu, allowed: %zu", ctx->name, total_size, max_size); return -ERANGE; } @@ -480,8 +482,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE, ctx->socket_id); if (mem == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", total_size, ctx->socket_id, ctx->name); return -ENOMEM; } diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h new file mode 100644 index 000000000000..4d5adf965cd2 --- /dev/null +++ b/lib/acl/acl_log.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#ifndef _ACL_LOG_H_ +#define _ACL_LOG_H_ + +extern int acl_logtype; +#define ACL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, acl_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + +#endif /* _ACL_LOG_H_ */ diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c index a61c3ba188da..5c8a9cd2f693 100644 --- a/lib/acl/rte_acl.c +++ b/lib/acl/rte_acl.c @@ -6,8 +6,10 @@ #include #include #include +#include #include "acl.h" +#include "acl_log.h" TAILQ_HEAD(rte_acl_list, rte_tailq_entry); @@ -400,15 +402,15 @@ rte_acl_create(const struct rte_acl_param *param) te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n"); + ACL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit; } ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id); if (ctx == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", sz, param->socket_id, name); rte_free(te); goto exit; @@ -474,8 +476,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules, ((uintptr_t)rules + i * ctx->rule_sz); rc = acl_check_rule(&rv->data); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n", - __func__, ctx->name, i + 1); + ACL_LOG(ERR, "%s: rule #%u is invalid", + ctx->name, i + 1); return rc; } } @@ -544,3 +546,5 @@ rte_acl_list_dump(void) } rte_mcfg_tailq_read_unlock(); } + +RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO); diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c index f14d7b4fa26e..74a12159b868 100644 --- a/lib/acl/tb_mem.c +++ b/lib/acl/tb_mem.c @@ -3,6 +3,9 @@ */ #include "tb_mem.h" +#include "acl_log.h" + +#include /* * Memory management routines for temporary memory. @@ -25,8 +28,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz) size = sz + pool->alignment - 1; block = calloc(1, size + sizeof(*pool->block)); if (block == NULL) { - RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated " - "by pool: %zu bytes\n", __func__, sz, pool->alloc); + ACL_LOG(ERR, + "allocation size %zu failed, currently allocated by pool: %zu bytes\n", + sz, pool->alloc); siglongjmp(pool->fail, -ENOMEM); return NULL; } diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 128bfabd94e1..871f2c38298c 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,14 +349,12 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MALLOC, "lib.malloc"}, {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_ACL, "lib.acl"}, {RTE_LOGTYPE_POWER, "lib.power"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 1f259b2abc5a..d707098b6359 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -27,7 +27,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ -#define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ + /* was RTE_LOGTYPE_MALLOC */ #define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ @@ -35,7 +35,7 @@ extern "C" { #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ -#define RTE_LOGTYPE_ACL 9 /**< Log related to ACL. */ + /* was RTE_LOGTYPE_ACL */ #define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ #define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ From patchwork Fri Feb 10 01:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123631 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73C5C41C58; Fri, 10 Feb 2023 02:08:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 526C142D2F; Fri, 10 Feb 2023 02:08:14 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 6186B40EE3 for ; Fri, 10 Feb 2023 02:08:10 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id w5so4874461plg.8 for ; Thu, 09 Feb 2023 17:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DcX7CLL5YNKDf43G1sbnUBI338OeT436Lvk7BVnMGQo=; b=yhq+7XwuryatAQDtif74+j9at/eD7fqaJ8Uzzvqbe1hGW+OI9pFYs4088dmFvVkDfz soHrBLoNIotPdgyCFTU1zm7uNz0Qw2lRj2tWEHNjplRvZbi1Sj4x4FAhKCX+BbFDjT70 vYSeXRjGDJRqsjDOwA0nIq4jZCoCJrRHTTmsSnopC66CpHDm8WNawNaPd2bsa1xZHY64 AxY+WVtu771CN8yO43lCsZg6sa0EER6WYkgQVE+3lUFcr4kpKmWtkYnaGC3ApG/6pIvl 0Q7pS+Kv5F50SaRKvtlE8Mq73JKcjqS+JB9wGDIO83NcbZCgyw43EsKstYpajjuWHiBT 1E4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DcX7CLL5YNKDf43G1sbnUBI338OeT436Lvk7BVnMGQo=; b=Y+aAkVksKp0E1MmdIZTlT1E3AKiLenNommEu33Lmn0u/gFZMIeqTc+mDywRaIAejL7 fFW/BX7HuMkc+gjOBh/+oWvqZuroW/cr6HLUv3aAz7cIwLw4cn7hS44sNpZPwgNRz+b3 nXA9jk6pKHjNObG3mMCPovJeUpOoydRU82X379GMtRC6ZpxNVkRl3b/8GEzDt6nG4XPS 3iaV5jpnLojzXFEVULJ6rjZXPqXWIIKzz/p6i87cLj3IQWA7fbgOnJ6vdqX74YSLW47Q 4zbyGOVO0ARwZkmc1yBqcS14Hs/og9AsYk7x/u+hS4oaBTUhCMGKcmCVGvGXxdaPnxga l+fw== X-Gm-Message-State: AO0yUKVoEiq5vEBQj09Odcb6gWWw9egXEar4wfKV2zB7HP9PMeMmew9w iwgaKZzRKoHU48x7nLFNpgfOcmqyYinv7vkjZlg= X-Google-Smtp-Source: AK7set8kSjFkVrTjZHRkXiPiBJnUWpuxAgWAzNi+UQGabeOw7Y+w9xgDcjXa3GSMpiHidb44VbZQxA== X-Received: by 2002:a17:902:eccf:b0:19a:5f47:9dcb with SMTP id a15-20020a170902eccf00b0019a5f479dcbmr4012876plh.51.1675991288377; Thu, 09 Feb 2023 17:08:08 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , David Hunt Subject: [PATCH v3 06/16] power: replace RTE_LOGTYPE_POWER with dynamic type Date: Thu, 9 Feb 2023 17:07:14 -0800 Message-Id: <20230210010724.890413-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use dynamic log type for power library. Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/power/guest_channel.c | 48 +++++---- lib/power/power_acpi_cpufreq.c | 118 ++++++++++---------- lib/power/power_common.c | 11 +- lib/power/power_common.h | 7 +- lib/power/power_cppc_cpufreq.c | 129 +++++++++++----------- lib/power/power_kvm_vm.c | 24 +++-- lib/power/power_pstate_cpufreq.c | 166 ++++++++++++++++------------- lib/power/rte_power.c | 25 +++-- lib/power/rte_power_empty_poll.c | 36 +++---- lib/power/rte_power_intel_uncore.c | 75 ++++++------- lib/power/rte_power_pmd_mgmt.c | 37 ++++--- 13 files changed, 365 insertions(+), 314 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 871f2c38298c..7dbf1df3b979 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_POWER, "lib.power"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index d707098b6359..5b7850af4e2b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -36,7 +36,7 @@ extern "C" { #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ /* was RTE_LOGTYPE_ACL */ -#define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ + /* was RTE_LOGTYPE_POWER */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ #define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ #define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c index 969a9e5aaa06..ad59d60f5d94 100644 --- a/lib/power/guest_channel.c +++ b/lib/power/guest_channel.c @@ -17,7 +17,11 @@ #include "guest_channel.h" -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO); + +#define GUEST_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, guest_channel_logtype, \ + "%s(): " fmt "\n", __func__, ## args) /* Timeout for incoming message in milliseconds. */ #define TIMEOUT 10 @@ -58,38 +62,38 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) int fd = -1; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } /* check if path is already open */ if (global_fds[lcore_id] != -1) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n", + GUEST_LOG(ERR, "Channel(%u) is already open with fd %d", lcore_id, global_fds[lcore_id]); return -1; } snprintf(fd_path, PATH_MAX, "%s.%u", path, lcore_id); - RTE_LOG(INFO, GUEST_CHANNEL, "Opening channel '%s' for lcore %u\n", + GUEST_LOG(INFO, "Opening channel '%s' for lcore %u", fd_path, lcore_id); fd = open(fd_path, O_RDWR); if (fd < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Unable to to connect to '%s' with error " - "%s\n", fd_path, strerror(errno)); + GUEST_LOG(ERR, "Unable to connect to '%s' with error %s", + fd_path, strerror(errno)); return -1; } flags = fcntl(fd, F_GETFL, 0); if (flags < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Failed on fcntl get flags for file %s\n", + GUEST_LOG(ERR, "Failed on fcntl get flags for file %s", fd_path); goto error; } flags |= O_NONBLOCK; if (fcntl(fd, F_SETFL, flags) < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Failed on setting non-blocking mode for " - "file %s", fd_path); + GUEST_LOG(ERR, "Failed on setting non-blocking mode for file %s", + fd_path); goto error; } /* QEMU needs a delay after connection */ @@ -102,13 +106,13 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) global_fds[lcore_id] = fd; ret = guest_channel_send_msg(&pkt, lcore_id); if (ret != 0) { - RTE_LOG(ERR, GUEST_CHANNEL, - "Error on channel '%s' communications test: %s\n", - fd_path, ret > 0 ? strerror(ret) : - "channel not connected"); + GUEST_LOG(ERR, + "Error on channel '%s' communications test: %s", + fd_path, ret > 0 ? strerror(ret) : + "channel not connected"); goto error; } - RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path); + GUEST_LOG(INFO, "Channel '%s' is now connected", fd_path); return 0; error: close(fd); @@ -124,13 +128,13 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt, void *buffer = pkt; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } if (global_fds[lcore_id] < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n"); + GUEST_LOG(ERR, "Channel is not connected"); return -1; } while (buffer_len > 0) { @@ -165,13 +169,13 @@ int power_guest_channel_read_msg(void *pkt, return -1; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } if (global_fds[lcore_id] < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n"); + GUEST_LOG(ERR, "Channel is not connected"); return -1; } @@ -180,10 +184,10 @@ int power_guest_channel_read_msg(void *pkt, ret = poll(&fds, 1, TIMEOUT); if (ret == 0) { - RTE_LOG(DEBUG, GUEST_CHANNEL, "Timeout occurred during poll function.\n"); + GUEST_LOG(DEBUG, "Timeout occurred during poll function."); return -1; } else if (ret < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n", + GUEST_LOG(ERR, "Error occurred during poll function: %s", strerror(errno)); return -1; } @@ -199,7 +203,7 @@ int power_guest_channel_read_msg(void *pkt, } if (ret == 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n"); + GUEST_LOG(ERR, "Expected more data, but connection has been closed."); return -1; } pkt = (char *)pkt + ret; @@ -220,7 +224,7 @@ void guest_channel_host_disconnect(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return; } diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c index 6e57aca53513..3643044d9ef0 100644 --- a/lib/power/power_acpi_cpufreq.c +++ b/lib/power/power_acpi_cpufreq.c @@ -62,8 +62,9 @@ static int set_freq_internal(struct acpi_power_info *pi, uint32_t idx) { if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -74,13 +75,15 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx) POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n", idx, pi->freqs[idx], pi->lcore_id); if (fseek(pi->f, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } fflush(pi->f); @@ -126,14 +129,14 @@ power_get_available_freqs(struct acpi_power_info *pi) open_core_sysfs_file(&f, "r", POWER_SYSFILE_AVAIL_FREQ, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_AVAIL_FREQ); goto out; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if ((ret) < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_AVAIL_FREQ); goto out; } @@ -142,12 +145,13 @@ power_get_available_freqs(struct acpi_power_info *pi) count = rte_strsplit(buf, sizeof(buf), freqs, RTE_MAX_LCORE_FREQS, ' '); if (count <= 0) { - RTE_LOG(ERR, POWER, "No available frequency in " - ""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id); + POWER_LOG(ERR, + "No available frequency in " POWER_SYSFILE_AVAIL_FREQ, + pi->lcore_id); goto out; } if (count >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + POWER_LOG(ERR, "Too many available frequencies : %d", count); goto out; } @@ -195,14 +199,14 @@ power_init_for_setting_freq(struct acpi_power_info *pi) open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "Failed to open %s\n", + POWER_LOG(ERR, "Failed to open %s", POWER_SYSFILE_SETSPEED); goto err; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if ((ret) < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SETSPEED); goto err; } @@ -236,7 +240,7 @@ power_acpi_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -252,42 +256,47 @@ power_acpi_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "userspace\n", lcore_id); + POWER_LOG(ERR, + "Cannot set governor of lcore %u to userspace", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -309,7 +318,7 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -324,8 +333,8 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", lcore_id); return -1; } @@ -335,14 +344,15 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'userspace' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'userspace' mode and been set back to the original", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -363,18 +373,18 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -386,7 +396,7 @@ uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -397,7 +407,7 @@ int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -410,7 +420,7 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -428,7 +438,7 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -445,7 +455,7 @@ int power_acpi_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -469,7 +479,7 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -486,7 +496,7 @@ power_acpi_turbo_status(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -502,7 +512,7 @@ power_acpi_enable_turbo(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -512,16 +522,16 @@ power_acpi_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", lcore_id); return -1; } /* Max may have changed, so call to max function */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -535,7 +545,7 @@ power_acpi_disable_turbo(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -546,8 +556,8 @@ power_acpi_disable_turbo(unsigned int lcore_id) if ((pi->turbo_available) && (pi->curr_idx <= 1)) { /* Try to set freq to max by default coming out of turbo */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -562,11 +572,11 @@ int power_acpi_get_capabilities(unsigned int lcore_id, struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/power_common.c b/lib/power/power_common.c index 1e09facb863f..3a374f6b8431 100644 --- a/lib/power/power_common.c +++ b/lib/power/power_common.c @@ -161,14 +161,14 @@ power_set_governor(unsigned int lcore_id, const char *new_governor, open_core_sysfs_file(&f_governor, "rw+", POWER_SYSFILE_GOVERNOR, lcore_id); if (f_governor == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_GOVERNOR); goto out; } ret = read_core_sysfs_s(f_governor, buf, sizeof(buf)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_GOVERNOR); goto out; } @@ -188,14 +188,15 @@ power_set_governor(unsigned int lcore_id, const char *new_governor, /* Write the new governor */ ret = write_core_sysfs_s(f_governor, new_governor); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to write %s\n", + POWER_LOG(ERR, "Failed to write %s", POWER_SYSFILE_GOVERNOR); goto out; } ret = 0; - RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been " - "set to '%s' successfully\n", lcore_id, new_governor); + POWER_LOG(INFO, + "Power management governor of lcore %u has been set to '%s' successfully", + lcore_id, new_governor); out: if (f_governor != NULL) fclose(f_governor); diff --git a/lib/power/power_common.h b/lib/power/power_common.h index c1c713927621..8e5309bbbaff 100644 --- a/lib/power/power_common.h +++ b/lib/power/power_common.h @@ -10,10 +10,15 @@ #define RTE_POWER_INVALID_FREQ_INDEX (~0) +extern int power_logtype; + +#define POWER_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, power_logtype, \ + "%s(): " fmt "\n", __func__, ## args) #ifdef RTE_LIBRTE_POWER_DEBUG #define POWER_DEBUG_TRACE(fmt, args...) \ - RTE_LOG(ERR, POWER, "%s: " fmt, __func__, ## args) + POWER_LOG(ERR, fmt, ## args) #else #define POWER_DEBUG_TRACE(fmt, args...) #endif diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index fc9cffef91a8..7ffda90ce7a7 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -72,8 +72,9 @@ static int set_freq_internal(struct cppc_power_info *pi, uint32_t idx) { if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -84,13 +85,15 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx) POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n", idx, pi->freqs[idx], pi->lcore_id); if (fseek(pi->f, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } fflush(pi->f); @@ -121,7 +124,7 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_HIGHEST_PERF); goto err; } @@ -129,7 +132,7 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF, pi->lcore_id); if (f_nom == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_NOMINAL_PERF); goto err; } @@ -137,28 +140,28 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX, pi->lcore_id); if (f_cmax == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SYS_MAX); goto err; } ret = read_core_sysfs_u32(f_max, &highest_perf); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_HIGHEST_PERF); goto err; } ret = read_core_sysfs_u32(f_nom, &nominal_perf); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_NOMINAL_PERF); goto err; } ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SYS_MAX); goto err; } @@ -208,7 +211,7 @@ power_get_available_freqs(struct cppc_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SCALING_MAX_FREQ); goto out; } @@ -216,21 +219,21 @@ power_get_available_freqs(struct cppc_power_info *pi) open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SCALING_MIN_FREQ); goto out; } ret = read_core_sysfs_u32(f_max, &scaling_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SCALING_MAX_FREQ); goto out; } ret = read_core_sysfs_u32(f_min, &scaling_min_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SCALING_MIN_FREQ); goto out; } @@ -248,7 +251,7 @@ power_get_available_freqs(struct cppc_power_info *pi) num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 + pi->turbo_available; if (num_freqs >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n", + POWER_LOG(ERR, "Too many available frequencies: %d", num_freqs); goto out; } @@ -289,14 +292,14 @@ power_init_for_setting_freq(struct cppc_power_info *pi) open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SETSPEED); goto err; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SETSPEED); goto err; } @@ -340,7 +343,7 @@ power_cppc_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -356,42 +359,46 @@ power_cppc_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "userspace\n", lcore_id); + POWER_LOG(ERR, "Cannot set governor of lcore %u to userspace", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); __atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE); @@ -419,7 +426,7 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -434,8 +441,9 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", + lcore_id); return -1; } @@ -445,14 +453,15 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'userspace' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'userspace' mode and been set back to the original", + lcore_id); __atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE); return 0; @@ -469,18 +478,18 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -492,7 +501,7 @@ uint32_t power_cppc_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -503,7 +512,7 @@ int power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -516,7 +525,7 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -534,7 +543,7 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -551,7 +560,7 @@ int power_cppc_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -575,7 +584,7 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -591,7 +600,7 @@ power_cppc_turbo_status(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -606,7 +615,7 @@ power_cppc_enable_turbo(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -616,8 +625,8 @@ power_cppc_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", lcore_id); return -1; } @@ -627,8 +636,8 @@ power_cppc_enable_turbo(unsigned int lcore_id) */ /* Max may have changed, so call to max function */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -642,7 +651,7 @@ power_cppc_disable_turbo(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -653,8 +662,8 @@ power_cppc_disable_turbo(unsigned int lcore_id) if ((pi->turbo_available) && (pi->curr_idx <= 1)) { /* Try to set freq to max by default coming out of turbo */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -670,11 +679,11 @@ power_cppc_get_capabilities(unsigned int lcore_id, struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c index 6a8109d44959..74a1094ffaa0 100644 --- a/lib/power/power_kvm_vm.c +++ b/lib/power/power_kvm_vm.c @@ -8,6 +8,7 @@ #include "rte_power_guest_channel.h" #include "guest_channel.h" +#include "power_common.h" #include "power_kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent" @@ -24,7 +25,7 @@ int power_kvm_vm_init(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n", + POWER_LOG(ERR, "Core(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } @@ -45,16 +46,16 @@ power_kvm_vm_freqs(__rte_unused unsigned int lcore_id, __rte_unused uint32_t *freqs, __rte_unused uint32_t num) { - RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } uint32_t power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id) { - RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -62,8 +63,8 @@ int power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id, __rte_unused uint32_t index) { - RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -73,7 +74,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) int ret; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n", + POWER_LOG(ERR, "Core(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } @@ -81,7 +82,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id); if (ret == 0) return 1; - RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", + POWER_LOG(DEBUG, "Error sending message: %s", ret > 0 ? strerror(ret) : "channel not connected"); return -1; } @@ -113,7 +114,7 @@ power_kvm_vm_freq_min(unsigned int lcore_id) int power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id) { - RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n"); + POWER_LOG(ERR, "rte_power_turbo_status is not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -133,6 +134,7 @@ struct rte_power_core_capabilities; int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id, __rte_unused struct rte_power_core_capabilities *caps) { - RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "rte_power_get_capabilities is not implemented for Virtual Machine Power Management"); return -ENOTSUP; } diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 52aa64510e21..c6869bbd3c59 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -81,7 +81,7 @@ power_read_turbo_pct(uint64_t *outVal) fd = open(POWER_SYSFILE_TURBO_PCT, O_RDONLY); if (fd < 0) { - RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT, + POWER_LOG(ERR, "Error opening '%s': %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); return fd; } @@ -89,7 +89,7 @@ power_read_turbo_pct(uint64_t *outVal) ret = read(fd, val, sizeof(val)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT, + POWER_LOG(ERR, "Error reading '%s': %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); goto out; } @@ -97,7 +97,7 @@ power_read_turbo_pct(uint64_t *outVal) errno = 0; *outVal = (uint64_t) strtol(val, &endptr, 10); if (errno != 0 || (*endptr != 0 && *endptr != '\n')) { - RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n", + POWER_LOG(ERR, "Error converting str to digits, read from %s: %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); ret = -1; goto out; @@ -125,7 +125,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_base_max, "r", POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id); if (f_base_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -133,7 +133,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_base_min, "r", POWER_SYSFILE_BASE_MIN_FREQ, pi->lcore_id); if (f_base_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -141,7 +141,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_min, "rw+", POWER_SYSFILE_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_MIN_FREQ); goto err; } @@ -149,7 +149,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_max, "rw+", POWER_SYSFILE_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_MAX_FREQ); goto err; } @@ -161,7 +161,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* read base max ratio */ ret = read_core_sysfs_u32(f_base_max, &base_max_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -169,7 +169,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* read base min ratio */ ret = read_core_sysfs_u32(f_base_min, &base_min_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -178,7 +178,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) if (f_base != NULL) { ret = read_core_sysfs_u32(f_base, &base_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_FREQ); goto err; } @@ -256,8 +256,9 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) uint32_t target_freq = 0; if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -269,16 +270,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) * User need change the min/max as same value. */ if (fseek(pi->f_cur_min, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", - pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fseek(pi->f_cur_max, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", - pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } @@ -287,7 +288,8 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (pi->turbo_enable) target_freq = pi->sys_max_freq; else { - RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be scaled up more %u\n", + POWER_LOG(ERR, + "Turbo is off, frequency can't be scaled up more %u", pi->lcore_id); return -1; } @@ -298,14 +300,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (idx > pi->curr_idx) { if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } @@ -321,14 +325,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (idx < pi->curr_idx) { if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } @@ -383,7 +389,7 @@ power_get_available_freqs(struct pstate_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MAX_FREQ); goto out; } @@ -391,7 +397,7 @@ power_get_available_freqs(struct pstate_power_info *pi) open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_BASE_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MIN_FREQ); goto out; } @@ -399,14 +405,14 @@ power_get_available_freqs(struct pstate_power_info *pi) /* read base ratios */ ret = read_core_sysfs_u32(f_max, &sys_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MAX_FREQ); goto out; } ret = read_core_sysfs_u32(f_min, &sys_min_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MIN_FREQ); goto out; } @@ -449,7 +455,7 @@ power_get_available_freqs(struct pstate_power_info *pi) num_freqs = (RTE_MIN(base_max_freq, sys_max_freq) - sys_min_freq) / BUS_FREQ + 1 + pi->turbo_available; if (num_freqs >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n", + POWER_LOG(ERR, "Too many available frequencies: %d", num_freqs); goto out; } @@ -493,14 +499,14 @@ power_get_cur_idx(struct pstate_power_info *pi) open_core_sysfs_file(&f_cur, "r", POWER_SYSFILE_CUR_FREQ, pi->lcore_id); if (f_cur == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_CUR_FREQ); goto fail; } ret = read_core_sysfs_u32(f_cur, &sys_cur_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_CUR_FREQ); goto fail; } @@ -542,7 +548,7 @@ power_pstate_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceed %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceed %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -558,47 +564,52 @@ power_pstate_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_performance(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "performance\n", lcore_id); + POWER_LOG(ERR, + "Cannot set governor of lcore %u to performance", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } if (power_get_cur_idx(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get current frequency " - "index of lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get current frequency index of lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -620,7 +631,7 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -636,8 +647,8 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", lcore_id); return -1; } @@ -649,14 +660,15 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'performance' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'performance' mode and been set back to the original", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -678,18 +690,18 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -701,7 +713,7 @@ uint32_t power_pstate_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -713,7 +725,7 @@ int power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -726,7 +738,7 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -745,7 +757,7 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -761,7 +773,7 @@ int power_pstate_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -786,7 +798,7 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -803,7 +815,7 @@ power_pstate_turbo_status(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -818,7 +830,7 @@ power_pstate_enable_turbo(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -828,10 +840,10 @@ power_pstate_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", - lcore_id); - return -1; + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", + lcore_id); + return -1; } return 0; @@ -844,7 +856,7 @@ power_pstate_disable_turbo(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -855,8 +867,8 @@ power_pstate_disable_turbo(unsigned int lcore_id) if (pi->turbo_available && pi->curr_idx <= 1) { /* Try to set freq to max by default coming out of turbo */ if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -872,11 +884,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id, struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c index 63a43bd8f5ae..23a97fa77f53 100644 --- a/lib/power/rte_power.c +++ b/lib/power/rte_power.c @@ -10,6 +10,7 @@ #include "rte_power.h" #include "power_acpi_cpufreq.h" #include "power_cppc_cpufreq.h" +#include "power_common.h" #include "power_kvm_vm.h" #include "power_pstate_cpufreq.h" @@ -70,7 +71,7 @@ rte_power_set_env(enum power_management_env env) rte_spinlock_lock(&global_env_cfg_lock); if (global_default_env != PM_ENV_NOT_SET) { - RTE_LOG(ERR, POWER, "Power Management Environment already set.\n"); + POWER_LOG(ERR, "Power Management Environment already set."); rte_spinlock_unlock(&global_env_cfg_lock); return -1; } @@ -127,7 +128,7 @@ rte_power_set_env(enum power_management_env env) rte_power_freq_disable_turbo = power_cppc_disable_turbo; rte_power_get_capabilities = power_cppc_get_capabilities; } else { - RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n", + POWER_LOG(ERR, "Invalid Power Management Environment(%d) set", env); ret = -1; } @@ -172,39 +173,40 @@ rte_power_init(unsigned int lcore_id) case PM_ENV_CPPC_CPUFREQ: return power_cppc_cpufreq_init(lcore_id); default: - RTE_LOG(INFO, POWER, "Env isn't set yet!\n"); + POWER_LOG(INFO, "Env isn't set yet!"); } /* Auto detect Environment */ - RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power management...\n"); + POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management..."); ret = power_acpi_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_ACPI_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise PSTAT power management...\n"); + POWER_LOG(INFO, "Attempting to initialise PSTAT power management..."); ret = power_pstate_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_PSTATE_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise CPPC power management...\n"); + POWER_LOG(INFO, "Attempting to initialise CPPC power management..."); ret = power_cppc_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_CPPC_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n"); + POWER_LOG(INFO, "Attempting to initialise VM power management..."); ret = power_kvm_vm_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_KVM_VM); goto out; } - RTE_LOG(ERR, POWER, "Unable to set Power Management Environment for lcore " - "%u\n", lcore_id); + POWER_LOG(ERR, + "Unable to set Power Management Environment for lcore %u", + lcore_id); out: return ret; } @@ -222,9 +224,12 @@ rte_power_exit(unsigned int lcore_id) case PM_ENV_CPPC_CPUFREQ: return power_cppc_cpufreq_exit(lcore_id); default: - RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit gracefully\n"); + POWER_LOG(ERR, + "Environment has not been set, unable to exit gracefully"); } return -1; } + +RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO); diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c index 4a4db512474e..da4b1ec3068a 100644 --- a/lib/power/rte_power_empty_poll.c +++ b/lib/power/rte_power_empty_poll.c @@ -10,6 +10,7 @@ #include "rte_power.h" #include "rte_power_empty_poll.h" +#include "power_common.h" #define INTERVALS_PER_SECOND 100 /* (10ms) */ #define SECONDS_TO_TRAIN_FOR 2 @@ -75,7 +76,7 @@ enter_normal_state(struct priority_worker *poll_stats) poll_stats->iter_counter = 0; poll_stats->threshold_ctr = 0; poll_stats->queue_state = MED_NORMAL; - RTE_LOG(INFO, POWER, "Set the power freq to MED\n"); + POWER_LOG(INFO, "Set the power freq to MED"); set_power_freq(poll_stats->lcore_id, MED, false); poll_stats->thresh[MED].threshold_percent = med_to_high_threshold; @@ -213,11 +214,9 @@ update_stats(struct priority_worker *poll_stats) if (s->thresh[s->cur_freq].base_edpi < cur_edpi) { /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cur_edpi is too large " - "cur edpi %"PRId64" " - "base edpi %"PRId64"\n", - cur_edpi, - s->thresh[s->cur_freq].base_edpi); + POWER_LOG(DEBUG, + "cur_edpi is too large cur edpi %"PRId64" base edpi %"PRId64, + cur_edpi, s->thresh[s->cur_freq].base_edpi); /* Value to make us fail need debug log*/ return 1000UL; } @@ -247,7 +246,7 @@ update_stats_normal(struct priority_worker *poll_stats) enum freq_val cur_freq = poll_stats->cur_freq; /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n", + POWER_LOG(DEBUG, "cure freq is %d, edpi is %"PRIu64"", cur_freq, poll_stats->thresh[cur_freq].base_edpi); return; @@ -257,12 +256,12 @@ update_stats_normal(struct priority_worker *poll_stats) if (percent > 100) { /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n"); + POWER_LOG(DEBUG, "Edpi is bigger than threshold"); return; } if (poll_stats->cur_freq == LOW) - RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n"); + POWER_LOG(INFO, "Purge Mode is not currently supported"); else if (poll_stats->cur_freq == MED) { if (percent > @@ -272,7 +271,7 @@ update_stats_normal(struct priority_worker *poll_stats) poll_stats->threshold_ctr++; else { set_state(poll_stats, HGH_BUSY); - RTE_LOG(INFO, POWER, "MOVE to HGH\n"); + POWER_LOG(INFO, "MOVE to HGH"); } } else { @@ -289,7 +288,7 @@ update_stats_normal(struct priority_worker *poll_stats) poll_stats->threshold_ctr++; else { set_state(poll_stats, MED_NORMAL); - RTE_LOG(INFO, POWER, "MOVE to MED\n"); + POWER_LOG(INFO, "MOVE to MED"); } } else { /* reset */ @@ -332,17 +331,17 @@ empty_poll_training(struct priority_worker *poll_stats, set_state(poll_stats, MED_NORMAL); - RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n", + POWER_LOG(INFO, "LOW threshold is %"PRIu64"", poll_stats->thresh[LOW].base_edpi); - RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n", + POWER_LOG(INFO, "MED threshold is %"PRIu64"", poll_stats->thresh[MED].base_edpi); - RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n", + POWER_LOG(INFO, "HIGH threshold is %"PRIu64"", poll_stats->thresh[HGH].base_edpi); - RTE_LOG(INFO, POWER, "Training is Complete for %d\n", + POWER_LOG(INFO, "Training is Complete for %d", poll_stats->lcore_id); } @@ -414,7 +413,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, freq_index[HGH] = freq_tlb[HGH]; } - RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n"); + POWER_LOG(INFO, "Initialize the Empty Poll"); /* Train for pre-defined period */ ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR; @@ -433,7 +432,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, avail_freqs[i], NUM_FREQS); - RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n", + POWER_LOG(INFO, "total avail freq is %d , lcoreid %d", total_avail_freqs[i], i); @@ -452,8 +451,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, void rte_power_empty_poll_stat_free(void) { - - RTE_LOG(INFO, POWER, "Close the Empty Poll\n"); + POWER_LOG(INFO, "Close the Empty Poll"); rte_free(ep_params); } diff --git a/lib/power/rte_power_intel_uncore.c b/lib/power/rte_power_intel_uncore.c index 3b8724385fb7..ee6412a3ed34 100644 --- a/lib/power/rte_power_intel_uncore.c +++ b/lib/power/rte_power_intel_uncore.c @@ -52,8 +52,9 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) int ret; if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { - RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which " - "should be less than %u\n", idx, ui->nb_freqs); + POWER_LOG(DEBUG, + "Invalid uncore frequency index %u, which should be less than %u", + idx, ui->nb_freqs); return -1; } @@ -65,13 +66,13 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, ui->pkg, ui->die); if (ui->f_cur_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); return -1; } ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); fclose(ui->f_cur_max); return -1; @@ -79,14 +80,16 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) /* check this value first before fprintf value to f_cur_max, so value isn't overwritten */ if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write new uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write new uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } @@ -121,13 +124,13 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ, ui->pkg, ui->die); if (f_base_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); goto err; } ret = read_core_sysfs_u32(f_base_max, &base_max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -136,14 +139,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ, ui->pkg, ui->die); if (f_base_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); goto err; } if (f_base_min != NULL) { ret = read_core_sysfs_u32(f_base_min, &base_min_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -153,14 +156,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ, ui->pkg, ui->die); if (f_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); goto err; } if (f_min != NULL) { ret = read_core_sysfs_u32(f_min, &min_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); goto err; } @@ -170,14 +173,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, ui->pkg, ui->die); if (f_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); goto err; } if (f_max != NULL) { ret = read_core_sysfs_u32(f_max, &max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); goto err; } @@ -222,7 +225,7 @@ power_get_available_uncore_freqs(struct uncore_power_info *ui) num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1; if (num_uncore_freqs >= MAX_UNCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n", + POWER_LOG(ERR, "Too many available uncore frequencies: %d", num_uncore_freqs); goto out; } @@ -250,7 +253,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die) if (max_pkgs == 0) return -1; if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n", + POWER_LOG(DEBUG, "Package number %02u can not exceed %u", pkg, max_pkgs); return -1; } @@ -259,7 +262,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die) if (max_dies == 0) return -1; if (die >= max_dies) { - RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n", + POWER_LOG(DEBUG, "Die number %02u can not exceed %u", die, max_dies); return -1; } @@ -282,15 +285,17 @@ rte_power_uncore_init(unsigned int pkg, unsigned int die) /* Init for setting uncore die frequency */ if (power_init_for_setting_uncore_freq(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for " - "pkg %02u die %02u\n", pkg, die); + POWER_LOG(DEBUG, + "Cannot init for setting uncore frequency for pkg %02u die %02u", + pkg, die); return -1; } /* Get the available frequencies */ if (power_get_available_uncore_freqs(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of " - "pkg %02u die %02u\n", pkg, die); + POWER_LOG(DEBUG, + "Cannot get available uncore frequencies of pkg %02u die %02u", + pkg, die); return -1; } @@ -309,14 +314,16 @@ rte_power_uncore_exit(unsigned int pkg, unsigned int die) ui = &uncore_info[pkg][die]; if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write original uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write original uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } @@ -395,10 +402,8 @@ rte_power_uncore_get_num_pkgs(void) d = opendir(INTEL_UNCORE_FREQUENCY_DIR); if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); + POWER_LOG(ERR, + "Uncore frequency management not supported/enabled on this kernel"); return 0; } @@ -427,16 +432,14 @@ rte_power_uncore_get_num_dies(unsigned int pkg) if (max_pkgs == 0) return 0; if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Invalid package number\n"); + POWER_LOG(DEBUG, "Invalid package number"); return 0; } d = opendir(INTEL_UNCORE_FREQUENCY_DIR); if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); + POWER_LOG(ERR, + "Uncore frequency management not supported/enabled on this kernel"); return 0; } diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index ca1840387c74..e691e754ccb0 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -146,7 +146,7 @@ get_monitor_addresses(struct pmd_core_cfg *cfg, /* attempted out of bounds access */ if (i >= len) { - RTE_LOG(ERR, POWER, "Too many queues being monitored\n"); + POWER_LOG(ERR, "Too many queues being monitored"); return -1; } @@ -422,7 +422,7 @@ check_scale(unsigned int lcore) /* only PSTATE and ACPI modes are supported */ if (!rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ) && !rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) { - RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes are supported\n"); + POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes are supported"); return -ENOTSUP; } /* ensure we could initialize the power library */ @@ -432,7 +432,7 @@ check_scale(unsigned int lcore) /* ensure we initialized the correct env */ env = rte_power_get_env(); if (env != PM_ENV_ACPI_CPUFREQ && env != PM_ENV_PSTATE_CPUFREQ) { - RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes were initialized\n"); + POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes were initialized"); return -ENOTSUP; } @@ -448,7 +448,7 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata) /* check if rte_power_monitor is supported */ if (!global_data.intrinsics_support.power_monitor) { - RTE_LOG(DEBUG, POWER, "Monitoring intrinsics are not supported\n"); + POWER_LOG(DEBUG, "Monitoring intrinsics are not supported"); return -ENOTSUP; } /* check if multi-monitor is supported */ @@ -457,14 +457,14 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata) /* if we're adding a new queue, do we support multiple queues? */ if (cfg->n_queues > 0 && !multimonitor_supported) { - RTE_LOG(DEBUG, POWER, "Monitoring multiple queues is not supported\n"); + POWER_LOG(DEBUG, "Monitoring multiple queues is not supported"); return -ENOTSUP; } /* check if the device supports the necessary PMD API */ if (rte_eth_get_monitor_addr(qdata->portid, qdata->qid, &dummy) == -ENOTSUP) { - RTE_LOG(DEBUG, POWER, "The device does not support rte_eth_get_monitor_addr\n"); + POWER_LOG(DEBUG, "The device does not support rte_eth_get_monitor_addr"); return -ENOTSUP; } @@ -564,14 +564,14 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, clb = clb_pause; break; default: - RTE_LOG(DEBUG, POWER, "Invalid power management type\n"); + POWER_LOG(DEBUG, "Invalid power management type"); ret = -EINVAL; goto end; } /* add this queue to the list */ ret = queue_list_add(lcore_cfg, &qdata); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n", + POWER_LOG(DEBUG, "Failed to add queue to list: %s", strerror(-ret)); goto end; } @@ -684,7 +684,8 @@ int rte_power_pmd_mgmt_set_pause_duration(unsigned int duration) { if (duration == 0) { - RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged"); + POWER_LOG(ERR, + "Pause duration must be greater than 0, value unchanged"); return -EINVAL; } pause_duration = duration; @@ -702,12 +703,13 @@ int rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (min > scale_freq_max[lcore]) { - RTE_LOG(ERR, POWER, "Invalid min frequency: Cannot be greater than max frequency"); + POWER_LOG(ERR, + "Invalid min frequency: Cannot be greater than max frequency"); return -EINVAL; } scale_freq_min[lcore] = min; @@ -719,7 +721,7 @@ int rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } @@ -727,7 +729,8 @@ rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max) if (max == 0) max = UINT32_MAX; if (max < scale_freq_min[lcore]) { - RTE_LOG(ERR, POWER, "Invalid max frequency: Cannot be less than min frequency"); + POWER_LOG(ERR, + "Invalid max frequency: Cannot be less than min frequency"); return -EINVAL; } @@ -740,12 +743,12 @@ int rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (scale_freq_max[lcore] == 0) - RTE_LOG(DEBUG, POWER, "Scaling freq min config not set. Using sysfs min freq.\n"); + POWER_LOG(DEBUG, "Scaling freq min config not set. Using sysfs min freq."); return scale_freq_min[lcore]; } @@ -754,12 +757,12 @@ int rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (scale_freq_max[lcore] == UINT32_MAX) { - RTE_LOG(DEBUG, POWER, "Scaling freq max config not set. Using sysfs max freq.\n"); + POWER_LOG(DEBUG, "Scaling freq max config not set. Using sysfs max freq."); return 0; } From patchwork Fri Feb 10 01:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123632 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8D12241C58; Fri, 10 Feb 2023 02:08:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C36442D32; Fri, 10 Feb 2023 02:08:15 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 4726142BC9 for ; Fri, 10 Feb 2023 02:08:10 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id mi9so3717038pjb.4 for ; Thu, 09 Feb 2023 17:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=MVB1ny/eBuG0kTLB38PU7gYex/gj53ulFRuTKhjloOXHSLtjoTy6PVDqtP/qQEpgMD ADIb4DUmM7jVvrmnj/QXWo/NX6kgOVzHGv6RPfaMyZIYQSE7P2v0/JQZXjlqyExIkeiD ai7Tj55MU+ocWm3JK43YSA4lvs6UEs439XtFSU0ge01wxEd8ZT+uYIfx2lkFwknczXNx mnHdPa9YeQuwLddxc4LL2LZn5qvLGlDZtElMDiTTP66SA6rbhkqTc6MLWfVjE7RoC9dC qFmCkPNQpiy4zJ9NavKUHshDcHbIPOhJzinMNAen1ByUutnQIzFLMa1vC+rj7vWTcAKq 9P3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=K2/6WBwMC1dz/wa6sT3OIT/H3d28l1gtRmhHg+ZtglZqS81eFA555+Opt1Luo47zDu AYV13BscD1e2RMrfbnogylSUyGeZtcFBSGOlxnO6uBiI79TZBN4Wxm6jL6YXv6paIYwT e9l/NBh1hI5xebF4djLfvlAiES7IsSYXu+e12UvJxqYzjIM8C17NUIfCYKlZfJDGRV+B vXJV4pz2j5+KIUvfEoGSZvFIJ4NctH9FtrdqOOiH1dH6+SgGEaIK32kQIMNzzjroUwe6 EuriRa5OzYNFzMfsNffNCJz7wwgrZipvSh/klAVCKw3M5OUoa+c+kqzCflfogeVub31W gBRg== X-Gm-Message-State: AO0yUKVpV7B919bBcGjDI0IQs48hr7m++g+i4kHHO0Sg46WL8p+PLjLh HLpvKfP9zGpKN20OJmmbGG7X5tLTsvBY0G04N+k= X-Google-Smtp-Source: AK7set8KIMlrQh4z667t+qg0ESX2H8URtn+ZI8g//vnX3oG/PdKY0GGW1fj59kS/aDnMVdSky7Jjhg== X-Received: by 2002:a17:902:ec90:b0:198:dae9:5f58 with SMTP id x16-20020a170902ec9000b00198dae95f58mr7997508plg.14.1675991289350; Thu, 09 Feb 2023 17:08:09 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING with dynamic type Date: Thu, 9 Feb 2023 17:07:15 -0800 Message-Id: <20230210010724.890413-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The logtype for ring only used in library. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/ring/rte_ring.c | 31 +++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 7dbf1df3b979..04c9d43351da 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 5b7850af4e2b..a99fe383c89b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -28,7 +28,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ -#define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ + /* was RTE_LOGTYPE_RING */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index cddaf6b2876f..1b4633468a2a 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -26,6 +26,13 @@ #include "rte_ring.h" #include "rte_ring_elem.h" +RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO); + +#define RING_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ring_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + + TAILQ_HEAD(rte_ring_list, rte_tailq_entry); static struct rte_tailq_elem rte_ring_tailq = { @@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count) /* Check if element size is a multiple of 4B */ if (esize % 4 != 0) { - RTE_LOG(ERR, RING, "element size is not a multiple of 4\n"); + RING_LOG(ERR, "element size is not a multiple of 4"); return -EINVAL; } /* count must be a power of 2 */ if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) { - RTE_LOG(ERR, RING, - "Requested number of elements is invalid, must be power of 2, and not exceed %u\n", + RING_LOG(ERR, + "Requested number of elements is invalid, must be power of 2, and not exceed %u", RTE_RING_SZ_MASK); return -EINVAL; @@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, /* future proof flags, only allow supported values */ if (flags & ~RING_F_MASK) { - RTE_LOG(ERR, RING, - "Unsupported flags requested %#x\n", flags); + RING_LOG(ERR, + "Unsupported flags requested %#x", flags); return -EINVAL; } @@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, r->capacity = count; } else { if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) { - RTE_LOG(ERR, RING, - "Requested size is invalid, must be power of 2, and not exceed the size limit %u\n", + RING_LOG(ERR, + "Requested size is invalid, must be power of 2, and not exceed the size limit %u", RTE_RING_SZ_MASK); return -EINVAL; } @@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n"); + RING_LOG(ERR, "Cannot reserve memory for tailq"); rte_errno = ENOMEM; return NULL; } @@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, TAILQ_INSERT_TAIL(ring_list, te, next); } else { r = NULL; - RTE_LOG(ERR, RING, "Cannot reserve memory\n"); + RING_LOG(ERR, "Cannot reserve memory"); rte_free(te); } rte_mcfg_tailq_write_unlock(); @@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r) * therefore, there is no memzone to free. */ if (r->memzone == NULL) { - RTE_LOG(ERR, RING, - "Cannot free ring, not created with rte_ring_create()\n"); + RING_LOG(ERR, + "Cannot free ring, not created with rte_ring_create()"); return; } if (rte_memzone_free(r->memzone) != 0) { - RTE_LOG(ERR, RING, "Cannot free memory\n"); + RING_LOG(ERR, "Cannot free memory"); return; } From patchwork Fri Feb 10 01:07:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123633 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE4B441C58; Fri, 10 Feb 2023 02:08:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3D6342D39; Fri, 10 Feb 2023 02:08:16 +0100 (CET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id BAC7342D10 for ; Fri, 10 Feb 2023 02:08:11 +0100 (CET) Received: by mail-pj1-f46.google.com with SMTP id o13so3754421pjg.2 for ; Thu, 09 Feb 2023 17:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=u5PmRTXPSIIaxxLBFryN+KpAXMIzHlpRzpcU+NO0W+krADo+hmYKmIpUJ1wHkDarTP 0hP2KE4nv0e12m3XKPKTpmUDo8dVCqPAMNaexAGcmAesptX1J/k3hA0C342jaPh3XwCK oQnEQD6FalZyFzwICZCMJ5GOBoArBAr+0x3YaLkO3NWQDVKqrTCTPaoeNDt05UgOjyGD 6ld/qHm8l/GBg4Fv5+EFwzdFuPBJIcy+ApPSLGu+16DuhQ7unneBUXIRuS6FJ4w/M/mG 6zY5a/aZbWffHSvf7KF5AlL3mHx4Lvp+Vkto99Un9UKgEnFL3mf++73jcfC7kH2KxRc2 OtAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=6kIRO7jMf9gB90YStmfSDFWQKqkdQn+sQpGoOhv7ErXiViz+n0Q5nGO/Bq+WJZmqb7 RKM5+QVKq8Vqah1Ylyk+IGm+ECoHdVOeATGKO5lJ5x8fhrlxCEwXeZNLm+u16rJ7F4ds 2rfz+roKur3FeKua2BEi4Y6QF3xrPe+XYyy11/7JVmSjFOugS5YYHS94/LiYp3IDO3T0 toQKXX8JoN8wzUlhovtYdxzGRpEP/QUU+2bqyviJQcoQZniQEHP5532AdqTvr4gPUN2l tT+mDoZV1iLLM3JV31+NgaVz1w6kNoKmNAEhnXUXABtNlGO4hDle3xe0fnWYm3XbBl8D TpAg== X-Gm-Message-State: AO0yUKUoXkiD8+Q6ZNZCTN6m6ZqVhRnAZB1JfuckksOC57gadvgkQNuj 9dFsOPRdzqqMV0j54vQhJBMRPX7OUR2sU1A6c1g= X-Google-Smtp-Source: AK7set8tGN70N9zMRRfSbk60ZelGuKeOU2qe9OZtlFRFMzkD/6wVIV/UOF1jfqs1VSP5CZWl4q9olw== X-Received: by 2002:a17:902:cecf:b0:196:89bc:70fe with SMTP id d15-20020a170902cecf00b0019689bc70femr14123735plg.34.1675991290642; Thu, 09 Feb 2023 17:08:10 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:10 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Andrew Rybchenko Subject: [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type Date: Thu, 9 Feb 2023 17:07:16 -0800 Message-Id: <20230210010724.890413-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/mempool/rte_mempool.c | 33 ++++++++++++++++++--------------- lib/mempool/rte_mempool_log.h | 10 ++++++++++ lib/mempool/rte_mempool_ops.c | 12 ++++++------ 5 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 lib/mempool/rte_mempool_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 04c9d43351da..90d388192712 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a99fe383c89b..f583352ec1ea 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -29,7 +29,7 @@ extern "C" { #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ /* was RTE_LOGTYPE_RING */ -#define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ + /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 45b5df6199b0..911a2b4dd850 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -30,6 +30,7 @@ #include "rte_mempool.h" #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" TAILQ_HEAD(rte_mempool_list, rte_tailq_entry); @@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id) cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache), RTE_CACHE_LINE_SIZE, socket_id); if (cache == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n"); + MEMPOOL_LOG(ERR, "Cannot allocate mempool cache."); rte_errno = ENOMEM; return NULL; } @@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* try to allocate tailq entry */ te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit_unlock; } @@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, if (free == 0) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (put)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2; } else if (free == 1) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (get)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1; } else if (free == 2) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 && cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (audit)\n"); } @@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, tlr = rte_mempool_get_trailer(obj); cookie = tlr->cookie; if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad trailer cookie\n"); } } @@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp) const struct rte_mempool_cache *cache; cache = &mp->local_cache[lcore_id]; if (cache->len > RTE_DIM(cache->objs)) { - RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n", + MEMPOOL_LOG(CRIT, "badness on cache[%u]", lcore_id); rte_panic("MEMPOOL: invalid cache len\n"); } @@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func, cb = calloc(1, sizeof(*cb)); if (cb == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate event callback!"); ret = -ENOMEM; goto exit; } @@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry) rte_telemetry_register_cmd("/mempool/info", mempool_handle_info, "Returns mempool info. Parameters: pool_name"); } + +RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO); diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h new file mode 100644 index 000000000000..3d252f761408 --- /dev/null +++ b/lib/mempool/rte_mempool_log.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation. + * Copyright 2014 6WIND S.A. + */ + +extern int mempool_logtype; + +#define MEMPOOL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, mempool_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c index 3b43edc548a0..e04e75b91ba6 100644 --- a/lib/mempool/rte_mempool_ops.c +++ b/lib/mempool/rte_mempool_ops.c @@ -12,6 +12,7 @@ #include #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" /* indirect jump table to support external memory pools. */ struct rte_mempool_ops_table rte_mempool_ops_table = { @@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) if (rte_mempool_ops_table.num_ops >= RTE_MEMPOOL_MAX_OPS_IDX) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Maximum number of mempool ops structs exceeded\n"); + MEMPOOL_LOG(ERR, + "Maximum number of mempool ops structs exceeded"); return -ENOSPC; } if (h->alloc == NULL || h->enqueue == NULL || h->dequeue == NULL || h->get_count == NULL) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Missing callback while registering mempool ops\n"); + MEMPOOL_LOG(ERR, + "Missing callback while registering mempool ops"); return -EINVAL; } if (strlen(h->name) >= sizeof(ops->name) - 1) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n", - __func__, h->name); + MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name); rte_errno = EEXIST; return -EEXIST; } From patchwork Fri Feb 10 01:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123634 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A3E5A41C58; Fri, 10 Feb 2023 02:08:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDFC642D44; Fri, 10 Feb 2023 02:08:17 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id F145242D20 for ; Fri, 10 Feb 2023 02:08:12 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id s89-20020a17090a2f6200b0023125ebb4b1so4034289pjd.3 for ; Thu, 09 Feb 2023 17:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gSoCAtoXa3lVXPecot8lDND+Mic9r6lp8okfjNGezdU=; b=lJZxPkIdY+FA86b6DmElnpouD+C9vjIDbtgaRRFcaedNY+7E+wfUZNhOHmfCBvSieC Q67Oi/rGsHiqa6/p+jmb/GqbnQU6ZEwjvZY4zOGqgzhuvKcmzZoU3MXsbKewexSoncsm Re1kD54HGH/LsEmWCuPdMrUVkklokMwSghw4tKvKV4hf4T9QzZKnRvQCScMtLUo1R1kE Z5MzL5kS5vR5XrkDxophh5nBsq1nnUpTNhU5CoiKMYJkXNjJWa0f5AtgtzUi3TPwrxsF zqV1e0JBQsfKh9OWKwWIzSvUSBzMHslamujDVcAjYApdKTUsfup+3JqZo87O2IKfck2G ZEEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gSoCAtoXa3lVXPecot8lDND+Mic9r6lp8okfjNGezdU=; b=dCuidmmtKpL7zE5tVpKKjwBww8FvWsnJylv+ObJENiGi+IaUW8zAUYv4fo4JuHSrSK pcbZFPq6n5l3rAdKCjE5dLnVlAa5Fv5wWZ9pN7RkiEyKFNG3P+jkqi/tpm5irSLb/0I6 1FjplNi2TUmiFrS/PCNrUfEtvAIpKdc5WUhfABJNr35CNQDT79oWXxTqSX6nHTOVeWSn dnWxF+TDbbYeEO/acPJVNr6cg1xsNUy82mByTPajBTLxxXB92ueDAk7Plb5+r06Q1rnc jwvkAtUGTw/GNUoCI4lbVoakYd7Nz5LRKiWKieUIfOLLXNntuUWFrW1eVGwrFrqmnv+d G0gg== X-Gm-Message-State: AO0yUKWiC/DRWBuF4werIRuFiMqxLmQEV764/9Z0vyOkDbgcLuzf6z9R 8PAU0zazeP/ohZNB201iwbUB/YOVvlPxIfRSoBo= X-Google-Smtp-Source: AK7set/luJ9O2ZB67d8sKyyU3ekaGqUQCPJAgpKBuIMX2rFxLDfMaSdehcA5Xpv25sWLrou1MDvRFw== X-Received: by 2002:a17:903:1c1:b0:196:5ede:af8a with SMTP id e1-20020a17090301c100b001965edeaf8amr3716668plh.29.1675991291688; Thu, 09 Feb 2023 17:08:11 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:11 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin , Bruce Richardson Subject: [PATCH v3 09/16] lpm: replace RTE_LOGTYPE_LPM with dynamic types Date: Thu, 9 Feb 2023 17:07:17 -0800 Message-Id: <20230210010724.890413-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Split lpm and lpm6 into separate log types since they are in different files and user may want to change log levels for IPv4 vs IPv6. For rib and fib libraries give them own types as well. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/fib/fib_log.h | 10 ++++++++++ lib/fib/rte_fib.c | 20 ++++++++++++-------- lib/fib/rte_fib6.c | 16 +++++++++------- lib/lpm/lpm_log.h | 9 +++++++++ lib/lpm/rte_lpm.c | 15 +++++++++------ lib/lpm/rte_lpm6.c | 20 ++++++++++++-------- lib/rib/rib_log.h | 9 +++++++++ lib/rib/rte_rib.c | 12 +++++++----- lib/rib/rte_rib6.c | 12 +++++++----- 11 files changed, 85 insertions(+), 41 deletions(-) create mode 100644 lib/fib/fib_log.h create mode 100644 lib/lpm/lpm_log.h create mode 100644 lib/rib/rib_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 90d388192712..ff250b9a6d56 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index f583352ec1ea..55067efb0a84 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -33,7 +33,7 @@ extern "C" { /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ -#define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ + /* was RTE_LOGTYPE_LPM */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h new file mode 100644 index 000000000000..bf2fa88c7451 --- /dev/null +++ b/lib/fib/fib_log.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Vladimir Medvedkin + * Copyright(c) 2019 Intel Corporation + */ + +extern int fib_logtype; + +#define FIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fib_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c index 8af4c4091908..aa2ba735771a 100644 --- a/lib/fib/rte_fib.c +++ b/lib/fib/rte_fib.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,8 +16,11 @@ #include #include +#include "fib_log.h" #include "dir24_8.h" +RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO); + TAILQ_HEAD(rte_fib_list, rte_tailq_entry); static struct rte_tailq_elem rte_fib_tailq = { .name = "RTE_FIB", @@ -167,8 +171,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) rib = rte_rib_create(name, socket_id, &rib_conf); if (rib == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate RIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate RIB %s", name); return NULL; } @@ -192,8 +196,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for FIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate tailq entry for FIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -202,7 +206,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) fib = rte_zmalloc_socket(mem_name, sizeof(struct rte_fib), RTE_CACHE_LINE_SIZE, socket_id); if (fib == NULL) { - RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name); + FIB_LOG(ERR, "FIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } @@ -213,9 +217,9 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) fib->def_nh = conf->default_nh; ret = init_dataplane(fib, socket_id, conf); if (ret < 0) { - RTE_LOG(ERR, LPM, - "FIB dataplane struct %s memory allocation failed " - "with err %d\n", name, ret); + FIB_LOG(ERR, + "FIB dataplane struct %s memory allocation failed with err %d", + name, ret); rte_errno = -ret; goto free_fib; } diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c index 4b8e22b142b9..4ce641f9dcd8 100644 --- a/lib/fib/rte_fib6.c +++ b/lib/fib/rte_fib6.c @@ -9,12 +9,14 @@ #include #include #include +#include #include #include #include #include +#include "fib_log.h" #include "trie.h" TAILQ_HEAD(rte_fib6_list, rte_tailq_entry); @@ -168,8 +170,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) rib = rte_rib6_create(name, socket_id, &rib_conf); if (rib == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate RIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate RIB %s", name); return NULL; } @@ -193,8 +195,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for FIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate tailq entry for FIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -203,7 +205,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) fib = rte_zmalloc_socket(mem_name, sizeof(struct rte_fib6), RTE_CACHE_LINE_SIZE, socket_id); if (fib == NULL) { - RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name); + FIB_LOG(ERR, "FIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } @@ -214,8 +216,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) fib->def_nh = conf->default_nh; ret = init_dataplane(fib, socket_id, conf); if (ret < 0) { - RTE_LOG(ERR, LPM, - "FIB dataplane struct %s memory allocation failed\n", + FIB_LOG(ERR, + "FIB dataplane struct %s memory allocation failed", name); rte_errno = -ret; goto free_fib; diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h new file mode 100644 index 000000000000..b4101cfbe238 --- /dev/null +++ b/lib/lpm/lpm_log.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2020 Arm Limited + */ + +extern int lpm_logtype; +#define LPM_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, lpm_logtype, \ + "%s(): " fmt "\n", __func__, ## args) diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c index cdcd1b7f9e47..363058e118c0 100644 --- a/lib/lpm/rte_lpm.c +++ b/lib/lpm/rte_lpm.c @@ -18,6 +18,9 @@ #include #include "rte_lpm.h" +#include "lpm_log.h" + +RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO); TAILQ_HEAD(rte_lpm_list, rte_tailq_entry); @@ -189,7 +192,7 @@ rte_lpm_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, "Failed to allocate tailq entry\n"); + LPM_LOG(ERR, "Failed to allocate tailq entry"); rte_errno = ENOMEM; goto exit; } @@ -198,7 +201,7 @@ rte_lpm_create(const char *name, int socket_id, i_lpm = rte_zmalloc_socket(mem_name, mem_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm == NULL) { - RTE_LOG(ERR, LPM, "LPM memory allocation failed\n"); + LPM_LOG(ERR, "LPM memory allocation failed"); rte_free(te); rte_errno = ENOMEM; goto exit; @@ -208,7 +211,7 @@ rte_lpm_create(const char *name, int socket_id, (size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm->rules_tbl == NULL) { - RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n"); + LPM_LOG(ERR, "LPM rules_tbl memory allocation failed"); rte_free(i_lpm); i_lpm = NULL; rte_free(te); @@ -220,7 +223,7 @@ rte_lpm_create(const char *name, int socket_id, (size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm->lpm.tbl8 == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n"); + LPM_LOG(ERR, "LPM tbl8 memory allocation failed"); rte_free(i_lpm->rules_tbl); rte_free(i_lpm); i_lpm = NULL; @@ -335,7 +338,7 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg) params.v = cfg->v; i_lpm->dq = rte_rcu_qsbr_dq_create(¶ms); if (i_lpm->dq == NULL) { - RTE_LOG(ERR, LPM, "LPM defer queue creation failed\n"); + LPM_LOG(ERR, "LPM defer queue creation failed"); return 1; } } else { @@ -562,7 +565,7 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start) status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq, (void *)&tbl8_group_start); if (status == 1) { - RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n"); + LPM_LOG(ERR, "Failed to push QSBR FIFO"); return -rte_errno; } } diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c index 8d21aeddb83c..6c36a637322e 100644 --- a/lib/lpm/rte_lpm6.c +++ b/lib/lpm/rte_lpm6.c @@ -20,6 +20,7 @@ #include #include "rte_lpm6.h" +#include "lpm_log.h" #define RTE_LPM6_TBL24_NUM_ENTRIES (1 << 24) #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES 256 @@ -279,8 +280,9 @@ rte_lpm6_create(const char *name, int socket_id, rules_tbl = rte_hash_create(&rule_hash_tbl_params); if (rules_tbl == NULL) { - RTE_LOG(ERR, LPM, "LPM rules hash table allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM rules hash table allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); goto fail_wo_unlock; } @@ -289,8 +291,9 @@ rte_lpm6_create(const char *name, int socket_id, sizeof(uint32_t) * config->number_tbl8s, RTE_CACHE_LINE_SIZE); if (tbl8_pool == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 pool allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM tbl8 pool allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); rte_errno = ENOMEM; goto fail_wo_unlock; } @@ -300,8 +303,9 @@ rte_lpm6_create(const char *name, int socket_id, sizeof(struct rte_lpm_tbl8_hdr) * config->number_tbl8s, RTE_CACHE_LINE_SIZE); if (tbl8_hdrs == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 headers allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM tbl8 headers allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); rte_errno = ENOMEM; goto fail_wo_unlock; } @@ -329,7 +333,7 @@ rte_lpm6_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, "Failed to allocate tailq entry!\n"); + LPM_LOG(ERR, "Failed to allocate tailq entry!"); rte_errno = ENOMEM; goto fail; } @@ -339,7 +343,7 @@ rte_lpm6_create(const char *name, int socket_id, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, LPM, "LPM memory allocation failed\n"); + LPM_LOG(ERR, "LPM memory allocation failed"); rte_free(te); rte_errno = ENOMEM; goto fail; diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h new file mode 100644 index 000000000000..520f4083c0a8 --- /dev/null +++ b/lib/rib/rib_log.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Vladimir Medvedkin + * Copyright(c) 2019 Intel Corporation + */ + +extern int rib_logtype; +#define RIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rib_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c index b0794edf66f5..c667e8cfe964 100644 --- a/lib/rib/rte_rib.c +++ b/lib/rib/rte_rib.c @@ -15,6 +15,10 @@ #include +#include "rib_log.h" + +RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO); + TAILQ_HEAD(rte_rib_list, rte_tailq_entry); static struct rte_tailq_elem rte_rib_tailq = { .name = "RTE_RIB", @@ -412,8 +416,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) NULL, NULL, NULL, NULL, socket_id, 0); if (node_pool == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate mempool for RIB %s\n", name); + RIB_LOG(ERR, "Can not allocate mempool for RIB %s", name); return NULL; } @@ -437,8 +440,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0); if (unlikely(te == NULL)) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for RIB %s\n", name); + RIB_LOG(ERR, "Can not allocate tailq entry for RIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -447,7 +449,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) rib = rte_zmalloc_socket(mem_name, sizeof(struct rte_rib), RTE_CACHE_LINE_SIZE, socket_id); if (unlikely(rib == NULL)) { - RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name); + RIB_LOG(ERR, "RIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c index 19e4ff97c479..4e171d4208d9 100644 --- a/lib/rib/rte_rib6.c +++ b/lib/rib/rte_rib6.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,6 +16,8 @@ #include +#include "rib_log.h" + #define RTE_RIB_VALID_NODE 1 #define RIB6_MAXDEPTH 128 /* Maximum length of a RIB6 name. */ @@ -481,8 +484,7 @@ rte_rib6_create(const char *name, int socket_id, NULL, NULL, NULL, NULL, socket_id, 0); if (node_pool == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate mempool for RIB6 %s\n", name); + RIB_LOG(ERR, "Can not allocate mempool for RIB6 %s", name); return NULL; } @@ -506,8 +508,8 @@ rte_rib6_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0); if (unlikely(te == NULL)) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for RIB6 %s\n", name); + RIB_LOG(ERR, + "Can not allocate tailq entry for RIB6 %s", name); rte_errno = ENOMEM; goto exit; } @@ -516,7 +518,7 @@ rte_rib6_create(const char *name, int socket_id, rib = rte_zmalloc_socket(mem_name, sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id); if (unlikely(rib == NULL)) { - RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name); + RIB_LOG(ERR, "RIB6 %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } From patchwork Fri Feb 10 01:07:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123635 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B30FF41C58; Fri, 10 Feb 2023 02:09:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C873642D5D; Fri, 10 Feb 2023 02:08:19 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 26D5242D20 for ; Fri, 10 Feb 2023 02:08:14 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso7505452pju.0 for ; Thu, 09 Feb 2023 17:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qnKdfj+fOpVFlnE0xwWcwjQ/fObrrSNzzUnVGCC7FFo=; b=dNbusazKY1CDq/0Ezc2ymddkbE20leMdwUlPoNgtG3hi8BqYKj6WWiSV8HcIqAFpNd Hf+g4LB6vWWy6EtcdfB1P/Y1LX+ONllJdlFEG+Yf1SPMavM4iwlTOvG3/tVi5y4u6K99 jW6Jtnckm5ph9bJH8/8ID7bkYCrIyf5SDPzt9WLVCJyPLXOT7FBLJYXWT3QVjMBvNmgd cqTrKoVb4ipO2AiHy1yE7NvsQneRqmcLBmhq2jobGf9h0fmNomZ6+rcWM9BT5yrqP5WO UdoPAtco3auJlQMR9kj6piXkDQjfl9rzoA1MfbdYY6cFThBgzBPLjteXZAyB0VVRnth3 8N5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qnKdfj+fOpVFlnE0xwWcwjQ/fObrrSNzzUnVGCC7FFo=; b=Ouvoqlv69yrWCxwlyLLPnWh9P+tzGg/G3pn2tlzIyubWTG9Hz6jLDgTtQPUR8BizLp 750M0b/tMoOn8Whwi2NSwo/a2gfPzwM0M4GFPYxUvOVJ+I/qM65+Wp0AE99Vuy819vUD z6uUgxNvE6ej+NQxEtnGdHuBvd8RSkC4V68SF5CFP5lI/uv+Zbwad3g1CnYfF2K8RlXE JEK2uR3NXQhzGyfoByCd8vD/RHtKb2otoA1FVXKfJKN3btMEx/1aODCSdBRhezlxAPxx Dg7wzS2uZ+f+OmwxnXAx2xOdb5gtADXZTDOmuayjAtqUXJVl+MaISwuQ1DyM1KkAkz+K W+SQ== X-Gm-Message-State: AO0yUKV2rsUYo1hhdxjVVQfOV3aoX5NQ1vdV29P7ZgngWfn+9LsV64gQ B2e6ujlDdkSfAK6bmJa1TeABiuAorSax4McH7k4= X-Google-Smtp-Source: AK7set+Nz+QxXaBfWoHftnpTu+zxdj1XYaK27jFuJkyjlFHd/xWmlsDD4xeuUmIXCYgGjtcejdrilw== X-Received: by 2002:a17:902:d506:b0:196:5bac:e319 with SMTP id b6-20020a170902d50600b001965bace319mr14634340plg.35.1675991293033; Thu, 09 Feb 2023 17:08:13 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:12 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type Date: Thu, 9 Feb 2023 17:07:18 -0800 Message-Id: <20230210010724.890413-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Even though KNI will eventually disappear, fix the logtype now. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/kni/rte_kni.c | 63 ++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index ff250b9a6d56..b0c625a02cdf 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_KNI, "lib.kni"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 55067efb0a84..69d3d07252ec 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -34,7 +34,7 @@ extern "C" { #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ /* was RTE_LOGTYPE_LPM */ -#define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ + /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 8ab6c4715314..6645c2a239cb 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni); static volatile int kni_fd = -1; +RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO); + +#define KNI_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, kni_logtype, fmt, ## args) + /* Shall be called before any allocation happens */ int rte_kni_init(unsigned int max_kni_ifaces __rte_unused) { - RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); + KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) if (rte_eal_iova_mode() != RTE_IOVA_PA) { - RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n"); + KNI_LOG(ERR, "KNI requires IOVA as PA\n"); return -1; } #endif @@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused) if (kni_fd < 0) { kni_fd = open("/dev/" KNI_DEVICE, O_RDWR); if (kni_fd < 0) { - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Can not open /dev/%s\n", KNI_DEVICE); return -1; } @@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, /* Check if KNI subsystem has been initialized */ if (kni_fd < 0) { - RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); + KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); return NULL; } @@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, kni = __rte_kni_get(conf->name); if (kni != NULL) { - RTE_LOG(ERR, KNI, "KNI already exists\n"); + KNI_LOG(ERR, "KNI already exists\n"); goto unlock; } te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n"); + KNI_LOG(ERR, "Failed to allocate tailq entry\n"); goto unlock; } kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE); if (kni == NULL) { - RTE_LOG(ERR, KNI, "KNI memory allocation failed\n"); + KNI_LOG(ERR, "KNI memory allocation failed\n"); goto kni_fail; } @@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni) strlcpy(dev_info.name, kni->name, sizeof(dev_info.name)); if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) { - RTE_LOG(ERR, KNI, "Fail to release kni device\n"); + KNI_LOG(ERR, "Fail to release kni device\n"); goto unlock; } @@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni) usleep(1000); if (kni_fifo_count(kni->rx_q)) - RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); + KNI_LOG(ERR, "Fail to free all Rx-q items\n"); kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); kni_free_fifo(kni->tx_q); @@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) int ret = 0; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id); + KNI_LOG(INFO, "Configure mac address of %d", port_id); ret = rte_eth_dev_default_mac_addr_set(port_id, (struct rte_ether_addr *)mac_addr); if (ret < 0) - RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n", + KNI_LOG(ERR, "Failed to config mac_addr for port %d\n", port_id); return ret; @@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", + KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n", port_id, to_on); if (to_on) @@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) ret = rte_eth_promiscuous_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s promiscuous mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n", + KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n", port_id, to_on); if (to_on) @@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) else ret = rte_eth_allmulticast_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s allmulticast mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni) return 0; /* It is OK of can not getting the request mbuf */ if (req != kni->sync_addr) { - RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req); + KNI_LOG(ERR, "Wrong req pointer %p\n", req); return -1; } @@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni) kni->ops.port_id, req->allmulti); break; default: - RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); + KNI_LOG(ERR, "Unknown request id %u\n", req->req_id); req->result = -EINVAL; break; } @@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni) else ret = 1; if (ret != 1) { - RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n"); + KNI_LOG(ERR, "Fail to put the muf back to resp_q\n"); return -1; /* It is an error of can't putting the mbuf back */ } @@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni) /* Check if pktmbuf pool has been configured */ if (kni->pktmbuf_pool == NULL) { - RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n"); + KNI_LOG(ERR, "No valid mempool for allocating mbufs\n"); return; } @@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni) pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); if (unlikely(pkts[i] == NULL)) { /* Out of memory */ - RTE_LOG(ERR, KNI, "Out of memory\n"); + KNI_LOG(ERR, "Out of memory\n"); break; } phys[i] = va2pa(pkts[i]); @@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops) enum kni_ops_status req_status; if (ops == NULL) { - RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n"); + KNI_LOG(ERR, "Invalid KNI request operation.\n"); return -1; } if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } req_status = kni_check_request_register(&kni->ops); if (req_status == KNI_REQ_REGISTERED) { - RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n"); + KNI_LOG(ERR, "The KNI request operation has already registered.\n"); return -1; } @@ -780,7 +785,7 @@ int rte_kni_unregister_handlers(struct rte_kni *kni) { if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } @@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) fd = open(path, O_RDWR); if (fd == -1) { - RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path); + KNI_LOG(ERR, "Failed to open file: %s.\n", path); return -1; } @@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) new_carrier = linkup ? "1" : "0"; ret = write(fd, new_carrier, 1); if (ret < 1) { - RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path); + KNI_LOG(ERR, "Failed to write file: %s.\n", path); close(fd); return -1; } From patchwork Fri Feb 10 01:07:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123636 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3691241C58; Fri, 10 Feb 2023 02:09:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 060F642D61; Fri, 10 Feb 2023 02:08:21 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 7A13642D20 for ; Fri, 10 Feb 2023 02:08:15 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id pj3so3756004pjb.1 for ; Thu, 09 Feb 2023 17:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AQAJJTqjTskC+oEt/E/VEGrTfvC38UgFYNoSiBgmG8Y=; b=EFBay0K8hOh2iTpj+9+6pDWf/C8poua1hQ8iqgJIvCuFn3zl+qY6G86CZB5M6Y1pYA xsrHrptq2MZ336tFOQkPDgAhtvG4MtJsz/lsypZWE250iKEGDmGus9CCysfRvOiDb+bQ y3D49pewC89+V/izOScMmfcqZXVT5PE1zSV0FkZVtY71901qwSrJeY6PFGacTd+wdcFY 4BcMVbfNcCuY/EotIDsRN7DU7nOdGRSZELoRBD/wexIZbz3KXzKV7s5WyVlCQoIPSgS8 yRwtMU33E39buBd2l4ir8OEzuH3GFO+3MnCGQujAwMmPKzEKeX9Fpu1qORhdkfQDG9Sw eE7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AQAJJTqjTskC+oEt/E/VEGrTfvC38UgFYNoSiBgmG8Y=; b=ne6kgEAOuS1hqiQAcT8qqjx63gm53tgZurLBjB4EOvCf1hUACpQfg5PteA3IS+Dk8o zn3QKCQPMMVuCNR8XShW1mDJYnjgDVj7+oERqbfA6F0tjqbFgUseatzITGPUvVp3nVzW cSEVibdsl0XbUSmV3nTG9KfcWNCDp6DU21FIHb/xq/wk6rR22xeODAzXu555sc7YqNLp R8dAlvwpviLPVaKo469aadShK4p4ud0Ac7jTyzebAMFgEull3SFcV8ES9cJ2ay1C3rgC xqYOcMS5IZyM7ipOsN8qgvETcyDTsvkMGVNJX3gsoKwI9T6ABIe497UazmDaAucf54Ix iAlw== X-Gm-Message-State: AO0yUKU3ZtNFFxTTcxfMQ2sRhISvhBT5JAhRLslGaNXDYdDs/hklNjAY FSxw/qnxfiHCp82AgcO4RkJP5MHa6guhGv4JBOs= X-Google-Smtp-Source: AK7set9DLjYs1FDQvUe9c2hBksmwlmFqOse8nseaRg+MCSrF/MwqIT2AyZreg0gyhl6wB1DjcjTNuw== X-Received: by 2002:a17:903:110e:b0:19a:7217:32a9 with SMTP id n14-20020a170903110e00b0019a721732a9mr369177plh.26.1675991294214; Thu, 09 Feb 2023 17:08:14 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:13 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v3 11/16] hash: replace RTE_LOGTYPE_HASH with dynamic type Date: Thu, 9 Feb 2023 17:07:19 -0800 Message-Id: <20230210010724.890413-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org A little more complex here since the one hash library actually has multiple routines in it. Split up the logtypes for hash and toeplitz. The hash crc file has another issue around logging. It is calling RTE_LOG during a constructor which is maybe problematic because this will all run before the DPDK library has finished initializing logging. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/hash/rte_cuckoo_hash.c | 60 ++++++++++++++++++--------------- lib/hash/rte_fbk_hash.c | 10 ++++-- lib/hash/rte_hash_crc.h | 6 ++-- lib/hash/rte_thash.c | 53 ++++++++++++++++++++++------- lib/hash/rte_thash_gfni.h | 24 ++++--------- lib/hash/version.map | 4 +++ 8 files changed, 95 insertions(+), 65 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index b0c625a02cdf..97120543d808 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 69d3d07252ec..afbd67d55b45 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -32,7 +32,7 @@ extern "C" { /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ -#define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ + /* was RTE_LOGTYPE_HASH */ /* was RTE_LOGTYPE_LPM */ /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 829b79c89a27..a5ca21b74e2a 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -26,6 +26,12 @@ #include "rte_hash.h" #include "rte_cuckoo_hash.h" +RTE_LOG_REGISTER_SUFFIX(hash_logtype, cuckoo, INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + /* Mask of all flags supported by this version */ #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \ RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \ @@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params) hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); if (params == NULL) { - RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n"); + HASH_LOG(ERR, "null parameters"); return NULL; } @@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params) (params->entries < RTE_HASH_BUCKET_ENTRIES) || (params->key_len == 0)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n"); + HASH_LOG(ERR, "invalid parameters"); return NULL; } if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n"); + HASH_LOG(ERR, "unsupported extra flags"); return NULL; } @@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params) if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) && (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or " - "rw concurrency lock free\n"); + HASH_LOG(ERR, + "choose rw concurrency or rw concurrency lock free"); return NULL; } @@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params) r = rte_ring_create_elem(ring_name, sizeof(uint32_t), rte_align32pow2(num_key_slots), params->socket_id, 0); if (r == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err; } @@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params) params->socket_id, 0); if (r_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err; } } @@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params) te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "tailq entry allocation failed\n"); + HASH_LOG(ERR, "tailq entry allocation failed"); goto err_unlock; } @@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (h == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets == NULL) { - RTE_LOG(ERR, HASH, "buckets memory allocation failed\n"); + HASH_LOG(ERR, "buckets memory allocation failed"); goto err_unlock; } @@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params) num_buckets * sizeof(struct rte_hash_bucket), RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err_unlock; } /* Populate ext bkt ring. We reserve 0 similar to the @@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params) ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) * num_key_slots, 0); if (ext_bkt_to_free == NULL) { - RTE_LOG(ERR, HASH, "ext bkt to free memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext bkt to free memory allocation failed"); goto err_unlock; } } @@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (k == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (tbl_chng_cnt == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params) sizeof(struct lcore_cache) * RTE_MAX_LCORE, RTE_CACHE_LINE_SIZE, params->socket_id); if (local_free_slots == NULL) { - RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n"); + HASH_LOG(ERR, "local free slots memory allocation failed"); goto err_unlock; } } @@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h) /* Reclaim all the resources */ rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL); if (pending != 0) - RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n"); + HASH_LOG(ERR, "RCU reclaim all resources failed"); } memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket)); @@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n) /* Return key indexes to free slot ring */ ret = free_slot(h, rcu_dq_entry.key_idx); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0); if (hash_rcu_cfg == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); return 1; } @@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) h->dq = rte_rcu_qsbr_dq_create(¶ms); if (h->dq == NULL) { rte_free(hash_rcu_cfg); - RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n"); + HASH_LOG(ERR, "HASH defer queue creation failed"); return 1; } } else { @@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, int ret = free_slot(h, bkt->key_idx[i]); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, } else if (h->dq) /* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */ if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0) - RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n"); + HASH_LOG(ERR, "Failed to push QSBR FIFO"); } __hash_rw_writer_unlock(h); return ret; diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c index 538b23a4030a..37edb5e2c7fe 100644 --- a/lib/hash/rte_fbk_hash.c +++ b/lib/hash/rte_fbk_hash.c @@ -18,6 +18,12 @@ #include "rte_fbk_hash.h" +RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fbk_hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry); static struct rte_tailq_elem rte_fbk_hash_tailq = { @@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n"); + HASH_LOG(ERR, "Failed to allocate tailq entry"); goto exit; } @@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) ht = rte_zmalloc_socket(hash_name, mem_size, 0, params->socket_id); if (ht == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n"); + HASH_LOG(ERR, "Failed to allocate fbk hash table"); rte_free(te); goto exit; } diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h index 0249ad16c5b6..3bb38880c4ea 100644 --- a/lib/hash/rte_hash_crc.h +++ b/lib/hash/rte_hash_crc.h @@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_X86 if (!(alg & CRC32_SSE42_x64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n"); if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42) crc32_alg = CRC32_SSE42; @@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_ARM64 if (!(alg & CRC32_ARM64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_ARM64\n"); if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32)) crc32_alg = CRC32_ARM64; #endif if (crc32_alg == CRC32_SW) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_SW\n"); } diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 0249883b8d07..fddc14e57588 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -13,6 +13,12 @@ #include #include +RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, thash, INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rte_thash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + #define THASH_NAME_LEN 64 #define TOEPLITZ_HASH_LEN 32 @@ -104,6 +110,28 @@ rte_thash_gfni_supported(void) return 0; }; +#ifndef RTE_THASH_GFNI_DEFINED +uint32_t +rte_thash_gfni(const uint64_t *mtrx __rte_unused, + const uint8_t *key __rte_unused, int len __rte_unused) +{ + HASH_LOG(ERR, "is undefined under given arch"); + return 0; +} + +void +rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, + int len __rte_unused, uint8_t *tuple[] __rte_unused, + uint32_t val[], uint32_t num) +{ + unsigned int i; + + HASH_LOG(ERR, "is undefined under given arch"); + for (i = 0; i < num; i++) + val[i] = 0; +} +#endif + void rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size) { @@ -240,8 +268,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, /* allocate tailq entry */ te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, - "Can not allocate tailq entry for thash context %s\n", + HASH_LOG(ERR, + "Can not allocate tailq entry for thash context %s", name); rte_errno = ENOMEM; goto exit; @@ -249,7 +277,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0); if (ctx == NULL) { - RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n", + HASH_LOG(ERR, + "thash ctx %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; @@ -272,7 +301,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t), RTE_CACHE_LINE_SIZE); if (ctx->matrices == NULL) { - RTE_LOG(ERR, HASH, "Cannot allocate matrices\n"); + HASH_LOG(ERR, "Cannot allocate matrices"); rte_errno = ENOMEM; goto free_ctx; } @@ -387,8 +416,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr, if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) && ((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) != RTE_THASH_IGNORE_PERIOD_OVERFLOW)) { - RTE_LOG(ERR, HASH, - "Can't generate m-sequence due to period overflow\n"); + HASH_LOG(ERR, + "Can't generate m-sequence due to period overflow"); return -ENOSPC; } @@ -467,9 +496,9 @@ insert_before(struct rte_thash_ctx *ctx, return ret; } } else if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -ENOSPC; } @@ -516,9 +545,9 @@ insert_after(struct rte_thash_ctx *ctx, int ret; if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -EEXIST; } diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h index ef90faa302d1..c3a5cf7e7b2d 100644 --- a/lib/hash/rte_thash_gfni.h +++ b/lib/hash/rte_thash_gfni.h @@ -38,13 +38,8 @@ extern "C" { * Calculated Toeplitz hash value. */ __rte_experimental -static inline uint32_t -rte_thash_gfni(const uint64_t *mtrx __rte_unused, - const uint8_t *key __rte_unused, int len __rte_unused) -{ - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - return 0; -} +uint32_t +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len); /** * Bulk implementation for Toeplitz hash. @@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused, * Number of tuples to hash. */ __rte_experimental -static inline void -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, - int len __rte_unused, uint8_t *tuple[] __rte_unused, - uint32_t val[], uint32_t num) -{ - unsigned int i; - - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - for (i = 0; i < num; i++) - val[i] = 0; -} +void +rte_thash_gfni_bulk(const uint64_t *mtrx, + int len, uint8_t *tuple[], + uint32_t val[], uint32_t num); #endif /* RTE_THASH_GFNI_DEFINED */ diff --git a/lib/hash/version.map b/lib/hash/version.map index bdcebd19c29b..c30ac81307a7 100644 --- a/lib/hash/version.map +++ b/lib/hash/version.map @@ -51,4 +51,8 @@ EXPERIMENTAL { rte_thash_complete_matrix; rte_thash_get_gfni_matrices; rte_thash_gfni_supported; + + # added in 23.07 + rte_thash_gfni; + rte_thash_gfni_bulk; }; From patchwork Fri Feb 10 01:07:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123637 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 824B741C58; Fri, 10 Feb 2023 02:09:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7167242D75; Fri, 10 Feb 2023 02:08:22 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id C11B142D3E for ; Fri, 10 Feb 2023 02:08:16 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id f16-20020a17090a9b1000b0023058bbd7b2so4091541pjp.0 for ; Thu, 09 Feb 2023 17:08:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vPmr83XeB2ihRrIG2WjbZl9fLzSJtL07U/NwDVV81mw=; b=uykGtM2OgNmD3BF/2TH6PbJZpwCpak9UU+xBYG4R/3vOTm+5ym6W56AXoHh5fwoFKF 242grpUbME0UMCXWd3LpFthEsKHL8zuXmcsZRV3KTZ3K7qPuE22k7WmyT0mqa6JBrHPj I8CBBKQqfvdLNhufkaa5wcGQaCr/xcCrGkZyWGNtdVrQzc9eXW+cobtMaIuKSE9FLmcP Y2OYjBjfY5Q1n7wRxvbqqWu/xx++vmM4hgHsqzSefLJ26gsAAAVdl7eRqoCZalR5oywc I57JM7DzGoC/gVPIQgB2DRqto2V+gpuW/++MZQGNC8IE+tO82Qeq6CMH762FCLryicmj Mycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vPmr83XeB2ihRrIG2WjbZl9fLzSJtL07U/NwDVV81mw=; b=ofJwhjXI6YHjOydKPZqoQWrkwEptXb3066HXlFn9rznlRP0eduSaoO409m/FZixlPR mBR6CQPvwFVkqSxFS3QqKMJNVuHg7b+vyqDx9DNr1jL9Q9d24u0teHHyeKa7D+GmBf+K BWeauziZ92oni35C4cpO0z4PbZG+wS/6L/Xou4fufDHjMBaOhvEgljrh2jyrIkGUGlsy oxV5A6mQnqNwuV2KKnSUk2VGhrcqZPGRT2b9SkkM7hyNvrt8fcElXQF0eKJIPsk+Z0hS TCa/tbgI+YKrfqu+8tu0P33fU82fPdEflUEudIxUL/TvC98++wgBgE+jYLB281K+VGQV RYgg== X-Gm-Message-State: AO0yUKUK5x3ab/RN7UpV/U6WPwc0j3530sIdjAlkx8x6fBjlnMT7ZP1p UKWj0uVyIrpXW71eOGGKZbs+ZKoFNQtXKpm76RM= X-Google-Smtp-Source: AK7set/YY1YEY2AY7UqDVQeS0eMaWkoRfkFMCm86Ufz8AQnzvHvveVjT3NaALJ44M8nEEkYtr/hozA== X-Received: by 2002:a17:902:e3c4:b0:189:6f76:9b61 with SMTP id r4-20020a170902e3c400b001896f769b61mr10878182ple.39.1675991295323; Thu, 09 Feb 2023 17:08:15 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:14 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 12/16] sched: replace RTE_LOGTYPE_SCHED with dynamic type Date: Thu, 9 Feb 2023 17:07:20 -0800 Message-Id: <20230210010724.890413-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Also can remove unused RTE_LOGTYPE_METER Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 2 - lib/eal/include/rte_log.h | 4 +- lib/sched/rte_pie.c | 16 +- lib/sched/rte_sched.c | 299 +++++++++++++------------------- lib/sched/rte_sched_log.h | 11 ++ 5 files changed, 141 insertions(+), 191 deletions(-) create mode 100644 lib/sched/rte_sched_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 97120543d808..212ccda0a6e8 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,8 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_METER, "lib.meter"}, - {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index afbd67d55b45..a1549b372767 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -37,8 +37,8 @@ extern "C" { /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ -#define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ -#define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ + /* was RTE_LOGTYPE_METER */ + /* was RTE_LOGTYPE_SCHED */ #define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c index 947e2a059f6f..28ed01e8f11d 100644 --- a/lib/sched/rte_pie.c +++ b/lib/sched/rte_pie.c @@ -6,6 +6,8 @@ #include #include +#include "rte_sched_log.h" + #include "rte_pie.h" #ifdef __INTEL_COMPILER @@ -16,7 +18,7 @@ int rte_pie_rt_data_init(struct rte_pie *pie) { if (pie == NULL) { - RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__); + SCHED_LOG(ERR, "Invalid addr for pie"); return -EINVAL; } @@ -38,26 +40,22 @@ rte_pie_config_init(struct rte_pie_config *pie_cfg, return -1; if (qdelay_ref <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qdelay_ref\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qdelay_ref"); return -EINVAL; } if (dp_update_interval <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for dp_update_interval\n", __func__); + SCHED_LOG(ERR, "Incorrect value for dp_update_interval"); return -EINVAL; } if (max_burst <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for max_burst\n", __func__); + SCHED_LOG(ERR, "Incorrect value for max_burst"); return -EINVAL; } if (tailq_th <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tailq_th\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tailq_th"); return -EINVAL; } diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c index c91697131d3e..b74792f72c56 100644 --- a/lib/sched/rte_sched.c +++ b/lib/sched/rte_sched.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -17,6 +16,7 @@ #include "rte_sched.h" #include "rte_sched_common.h" +#include "rte_sched_log.h" #include "rte_approx.h" #ifdef __INTEL_COMPILER @@ -324,23 +324,20 @@ pipe_profile_check(struct rte_sched_pipe_params *params, /* Pipe parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } /* TB rate: non-zero, not greater than port rate */ if (params->tb_rate == 0 || params->tb_rate > rate) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb rate"); return -EINVAL; } /* TB size: non-zero */ if (params->tb_size == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb size\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb size"); return -EINVAL; } @@ -349,38 +346,33 @@ pipe_profile_check(struct rte_sched_pipe_params *params, if ((qsize[i] == 0 && params->tc_rate[i] != 0) || (qsize[i] != 0 && (params->tc_rate[i] == 0 || params->tc_rate[i] > params->tb_rate))) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qsize or tc_rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qsize or tc_rate"); return -EINVAL; } } if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 || qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for be traffic class rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for be traffic class rate"); return -EINVAL; } /* TC period: non-zero */ if (params->tc_period == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc period\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc period"); return -EINVAL; } /* Best effort tc oversubscription weight: non-zero */ if (params->tc_ov_weight == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc ov weight\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc ov weight"); return -EINVAL; } /* Queue WRR weights: non-zero */ for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) { if (params->wrr_weights[i] == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for wrr weight\n", __func__); + SCHED_LOG(ERR, "Incorrect value for wrr weight"); return -EINVAL; } } @@ -396,20 +388,17 @@ subport_profile_check(struct rte_sched_subport_profile_params *params, /* Check user parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } if (params->tb_rate == 0 || params->tb_rate > rate) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tb rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb rate"); return -EINVAL; } if (params->tb_size == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tb size\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb size"); return -EINVAL; } @@ -417,21 +406,18 @@ subport_profile_check(struct rte_sched_subport_profile_params *params, uint64_t tc_rate = params->tc_rate[i]; if (tc_rate == 0 || (tc_rate > params->tb_rate)) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tc rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc rate"); return -EINVAL; } } if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect tc rate(best effort)\n", __func__); + SCHED_LOG(ERR, "Incorrect tc rate(best effort)"); return -EINVAL; } if (params->tc_period == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tc period\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc period"); return -EINVAL; } @@ -444,29 +430,25 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) uint32_t i; if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } /* socket */ if (params->socket < 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for socket id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for socket id"); return -EINVAL; } /* rate */ if (params->rate == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for rate"); return -EINVAL; } /* mtu */ if (params->mtu == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for mtu\n", __func__); + SCHED_LOG(ERR, "Incorrect value for mtu"); return -EINVAL; } @@ -474,8 +456,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) if (params->n_subports_per_port == 0 || params->n_subports_per_port > 1u << 16 || !rte_is_power_of_2(params->n_subports_per_port)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for number of subports\n", __func__); + SCHED_LOG(ERR, "Incorrect value for number of subports"); return -EINVAL; } @@ -483,8 +464,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) params->n_subport_profiles == 0 || params->n_max_subport_profiles == 0 || params->n_subport_profiles > params->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport profiles\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport profiles"); return -EINVAL; } @@ -495,9 +475,8 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) status = subport_profile_check(p, params->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile check failed(%d)\n", - __func__, status); + SCHED_LOG(ERR, "subport profile check failed(%d)", + status); return -EINVAL; } } @@ -505,8 +484,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) /* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport == 0 || !rte_is_power_of_2(params->n_pipes_per_subport)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for maximum pipes number\n", __func__); + SCHED_LOG(ERR, "Incorrect value for maximum pipes number"); return -EINVAL; } @@ -605,14 +583,15 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) { struct rte_sched_pipe_profile *p = subport->pipe_profiles + i; - RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n" + SCHED_LOG(DEBUG, + "Low level config for pipe profile %u:\n" " Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n" " Traffic classes: period = %"PRIu64",\n" " credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 ", %"PRIu64", %"PRIu64", %"PRIu64"]\n" " Best-effort traffic class oversubscription: weight = %hhu\n" - " WRR cost: [%hhu, %hhu, %hhu, %hhu]\n", + " WRR cost: [%hhu, %hhu, %hhu, %hhu]", i, /* Token bucket */ @@ -648,35 +627,36 @@ rte_sched_port_log_subport_profile(struct rte_sched_port *port, uint32_t i) { struct rte_sched_subport_profile *p = port->subport_profiles + i; - RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n" - "Token bucket: period = %"PRIu64", credits per period = %"PRIu64"," - "size = %"PRIu64"\n" - "Traffic classes: period = %"PRIu64",\n" - "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - " %"PRIu64", %"PRIu64", %"PRIu64"]\n", - i, - - /* Token bucket */ - p->tb_period, - p->tb_credits_per_period, - p->tb_size, - - /* Traffic classes */ - p->tc_period, - p->tc_credits_per_period[0], - p->tc_credits_per_period[1], - p->tc_credits_per_period[2], - p->tc_credits_per_period[3], - p->tc_credits_per_period[4], - p->tc_credits_per_period[5], - p->tc_credits_per_period[6], - p->tc_credits_per_period[7], - p->tc_credits_per_period[8], - p->tc_credits_per_period[9], - p->tc_credits_per_period[10], - p->tc_credits_per_period[11], - p->tc_credits_per_period[12]); + SCHED_LOG(DEBUG, + "Low level config for subport profile %u:\n" + "Token bucket: period = %"PRIu64", credits per period = %"PRIu64"," + "size = %"PRIu64"\n" + "Traffic classes: period = %"PRIu64",\n" + "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 + " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 + " %"PRIu64", %"PRIu64", %"PRIu64"]", + i, + + /* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + + /* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0], + p->tc_credits_per_period[1], + p->tc_credits_per_period[2], + p->tc_credits_per_period[3], + p->tc_credits_per_period[4], + p->tc_credits_per_period[5], + p->tc_credits_per_period[6], + p->tc_credits_per_period[7], + p->tc_credits_per_period[8], + p->tc_credits_per_period[9], + p->tc_credits_per_period[10], + p->tc_credits_per_period[11], + p->tc_credits_per_period[12]); } static inline uint64_t @@ -829,8 +809,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, /* Check user parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } @@ -841,14 +820,13 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint16_t qsize = params->qsize[i]; if (qsize != 0 && !rte_is_power_of_2(qsize)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qsize\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qsize"); return -EINVAL; } } if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, "%s: Incorrect qsize\n", __func__); + SCHED_LOG(ERR, "Incorrect qsize"); return -EINVAL; } @@ -856,8 +834,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, if (params->n_pipes_per_subport_enabled == 0 || params->n_pipes_per_subport_enabled > n_max_pipes_per_subport || !rte_is_power_of_2(params->n_pipes_per_subport_enabled)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for pipes number\n", __func__); + SCHED_LOG(ERR, "Incorrect value for pipes number"); return -EINVAL; } @@ -866,8 +843,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, params->n_pipe_profiles == 0 || params->n_max_pipe_profiles == 0 || params->n_pipe_profiles > params->n_max_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for pipe profiles\n", __func__); + SCHED_LOG(ERR, "Incorrect value for pipe profiles"); return -EINVAL; } @@ -877,8 +853,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, status = pipe_profile_check(p, rate, ¶ms->qsize[0]); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "Pipe profile check failed(%d)", status); return -EINVAL; } } @@ -895,9 +870,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, status = rte_sched_port_check_params(port_params); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler port params check failed (%d)\n", - __func__, status); + SCHED_LOG(ERR, + "Port scheduler port params check failed (%d)", + status); return 0; } @@ -909,9 +884,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, port_params->n_pipes_per_subport, port_params->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler subport params check failed (%d)\n", - __func__, status); + SCHED_LOG(ERR, + "Port scheduler subport params check failed (%d)", + status); return 0; } @@ -940,9 +915,8 @@ rte_sched_port_config(struct rte_sched_port_params *params) status = rte_sched_port_check_params(params); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler params check failed (%d)\n", - __func__, status); + SCHED_LOG(ERR, "Port scheduler params check failed (%d)", + status); return NULL; } @@ -955,7 +929,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) port = rte_zmalloc_socket("qos_params", size0 + size1, RTE_CACHE_LINE_SIZE, params->socket); if (port == NULL) { - RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); return NULL; } @@ -964,7 +938,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->subport_profiles = rte_zmalloc_socket("subport_profile", size2, RTE_CACHE_LINE_SIZE, params->socket); if (port->subport_profiles == NULL) { - RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); rte_free(port); return NULL; } @@ -1106,8 +1080,7 @@ rte_sched_red_config(struct rte_sched_port *port, params->cman_params->red_params[i][j].maxp_inv) != 0) { rte_sched_free_memory(port, n_subports); - RTE_LOG(NOTICE, SCHED, - "%s: RED configuration init fails\n", __func__); + SCHED_LOG(NOTICE, "RED configuration init fails"); return -EINVAL; } } @@ -1126,8 +1099,7 @@ rte_sched_pie_config(struct rte_sched_port *port, for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) { if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) { - RTE_LOG(NOTICE, SCHED, - "%s: PIE tailq threshold incorrect\n", __func__); + SCHED_LOG(NOTICE, "PIE tailq threshold incorrect"); return -EINVAL; } @@ -1138,8 +1110,7 @@ rte_sched_pie_config(struct rte_sched_port *port, params->cman_params->pie_params[i].tailq_th) != 0) { rte_sched_free_memory(port, n_subports); - RTE_LOG(NOTICE, SCHED, - "%s: PIE configuration init fails\n", __func__); + SCHED_LOG(NOTICE, "PIE configuration init fails"); return -EINVAL; } } @@ -1170,14 +1141,12 @@ rte_sched_subport_tc_ov_config(struct rte_sched_port *port, struct rte_sched_subport *s; if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter subport id"); return -EINVAL; } @@ -1203,22 +1172,19 @@ rte_sched_subport_config(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return 0; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); ret = -EINVAL; goto out; } if (subport_profile_id >= port->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, "%s: " - "Number of subport profile exceeds the max limit\n", - __func__); + SCHED_LOG(ERR, + "Number of subport profile exceeds the max limit"); ret = -EINVAL; goto out; } @@ -1233,9 +1199,9 @@ rte_sched_subport_config(struct rte_sched_port *port, port->n_pipes_per_subport, port->rate); if (status != 0) { - RTE_LOG(NOTICE, SCHED, - "%s: Port scheduler params check failed (%d)\n", - __func__, status); + SCHED_LOG(NOTICE, + "Port scheduler params check failed (%d)", + status); ret = -EINVAL; goto out; } @@ -1249,8 +1215,7 @@ rte_sched_subport_config(struct rte_sched_port *port, s = rte_zmalloc_socket("subport_params", size0 + size1, RTE_CACHE_LINE_SIZE, port->socket); if (s == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); ret = -ENOMEM; goto out; } @@ -1281,8 +1246,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->cman_enabled = true; status = rte_sched_cman_config(port, s, params, n_subports); if (status) { - RTE_LOG(NOTICE, SCHED, - "%s: CMAN configuration fails\n", __func__); + SCHED_LOG(NOTICE, + "CMAN configuration fails"); return status; } } else { @@ -1329,8 +1294,7 @@ rte_sched_subport_config(struct rte_sched_port *port, s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array, bmp_mem_size); if (s->bmp == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Subport bitmap init error\n", __func__); + SCHED_LOG(ERR, "Subport bitmap init error"); ret = -EINVAL; goto out; } @@ -1399,29 +1363,25 @@ rte_sched_pipe_config(struct rte_sched_port *port, deactivate = (pipe_profile < 0); if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter subport id"); ret = -EINVAL; goto out; } s = port->subports[subport_id]; if (pipe_id >= s->n_pipes_per_subport_enabled) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter pipe id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter pipe id"); ret = -EINVAL; goto out; } if (!deactivate && profile >= s->n_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter pipe profile\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter pipe profile"); ret = -EINVAL; goto out; } @@ -1446,9 +1406,9 @@ rte_sched_pipe_config(struct rte_sched_port *port, s->tc_ov = s->tc_ov_rate > subport_tc_be_rate; if (s->tc_ov != tc_be_ov) { - RTE_LOG(DEBUG, SCHED, - "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n", - subport_id, subport_tc_be_rate, s->tc_ov_rate); + SCHED_LOG(DEBUG, + "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)", + subport_id, subport_tc_be_rate, s->tc_ov_rate); } /* Reset the pipe */ @@ -1488,8 +1448,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, s->tc_ov = s->tc_ov_rate > subport_tc_be_rate; if (s->tc_ov != tc_be_ov) { - RTE_LOG(DEBUG, SCHED, - "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n", + SCHED_LOG(DEBUG, + "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)", subport_id, subport_tc_be_rate, s->tc_ov_rate); } p->tc_ov_period_id = s->tc_ov_period_id; @@ -1517,15 +1477,13 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Port */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } /* Subport id not exceeds the max limit */ if (subport_id > port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); return -EINVAL; } @@ -1533,16 +1491,14 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Pipe profiles exceeds the max limit */ if (s->n_pipe_profiles >= s->n_max_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Number of pipe profiles exceeds the max limit\n", __func__); + SCHED_LOG(ERR, "Number of pipe profiles exceeds the max limit"); return -EINVAL; } /* Pipe params */ status = pipe_profile_check(params, port->rate, &s->qsize[0]); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "Pipe profile check failed(%d)", status); return -EINVAL; } @@ -1552,8 +1508,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Pipe profile should not exists */ for (i = 0; i < s->n_pipe_profiles; i++) if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile exists\n", __func__); + SCHED_LOG(ERR, "Pipe profile exists"); return -EINVAL; } @@ -1580,21 +1535,18 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, /* Port */ if (port == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (params == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter profile\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter profile"); return -EINVAL; } if (subport_profile_id == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter subport_profile_id\n", - __func__); + SCHED_LOG(ERR, + "Incorrect value for parameter subport_profile_id"); return -EINVAL; } @@ -1602,16 +1554,14 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, /* Subport profiles exceeds the max limit */ if (port->n_subport_profiles >= port->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, "%s: " - "Number of subport profiles exceeds the max limit\n", - __func__); + SCHED_LOG(ERR, + "Number of subport profiles exceeds the max limit"); return -EINVAL; } status = subport_profile_check(params, port->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "subport profile check failed (%d)", status); return -EINVAL; } @@ -1621,8 +1571,7 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, for (i = 0; i < port->n_subport_profiles; i++) if (memcmp(port->subport_profiles + i, dst, sizeof(*dst)) == 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile exists\n", __func__); + SCHED_LOG(ERR, "subport profile exists"); return -EINVAL; } @@ -1694,26 +1643,22 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); return -EINVAL; } if (stats == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter stats\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter stats"); return -EINVAL; } if (tc_ov == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc_ov\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc_ov"); return -EINVAL; } @@ -1742,26 +1687,22 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (queue_id >= rte_sched_port_queues_per_port(port)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for queue id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for queue id"); return -EINVAL; } if (stats == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter stats\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter stats"); return -EINVAL; } if (qlen == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter qlen\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter qlen"); return -EINVAL; } subport_qmask = port->n_pipes_per_subport_log2 + 4; @@ -3002,3 +2943,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint return count; } + +RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO); diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h new file mode 100644 index 000000000000..cbf577faf2cb --- /dev/null +++ b/lib/sched/rte_sched_log.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#include + +extern int sched_logtype; + +#define SCHED_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, sched_logtype, \ + "%s(): " fmt "\n", __func__, ##args) From patchwork Fri Feb 10 01:07:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123638 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A10641C58; Fri, 10 Feb 2023 02:09:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABCAD42D7C; Fri, 10 Feb 2023 02:08:23 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 4A41142D38 for ; Fri, 10 Feb 2023 02:08:18 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id d2so3716405pjd.5 for ; Thu, 09 Feb 2023 17:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z9BCwu8weDVH8jq59sHj+klnzxjX7MgVx87YMWoC43I=; b=742BwS1s1Q81guZl165+4l/kF5NzVotyVPmNlyevCIcMEZaaqSkWQ6JXj3gdwrvSF9 e3+qE1Se/93V93pGAK9vZPlNPMtSqX+ljtvszlPH1JWRRQWIv/fotCMCx26pzEYFdbuA T8oj+5LYK5L+CRL+RDaRYvLf+6EqtdgYu4VhJ9iSa/zcfbtl1HlTx1fBtYqX9o3n+eLY 1PsDSVkQMVUXRVuu6kIHyIVb7kjCL5Dr27c8oi/dkSN2ct0HG9pOlU2oVA4MGE/4P5tV v+XwO2+liCe7GqZAl1s6e51+9Oqw5SjyGfGEwwMBFJ4WBAap7sR7eFK/xhOw2TiF3nq7 0Bow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z9BCwu8weDVH8jq59sHj+klnzxjX7MgVx87YMWoC43I=; b=XVdx2TGEoDCvTmIR34Po+UWpOgCkknkSIU03zle11xj5rjs17xlceW2mgHDGnybFPG WeBqlB52KCQz6YMkr2iPAa/ZrA8jyNZIYGgusZ6So06BlTXOTKA4ruv09is1Ja3++yfS ltk/8fd1ClXvq5x4frkZ51wLOlst7R4UWRxvOL/L81cIRxc/0oiScr2bLUb/k1BtFvK7 MF0iqtPaq8Gxzmfsdm06dixkPDV8X3e1geAKwJKoVINRmzXDzAEVxEm3yzCCmEce29XY g6e09m2zDcXN2mt63HZR4YtER9h48koyXWXQMB5vVQRJi0DqahMumuZKmtbHdcX1h3O8 i/rw== X-Gm-Message-State: AO0yUKW8dtvWT4k3uwppT8nPfuNGxxDYeo+guXR3Qsq+KtoCrocvWszO JvfZ/BCRCh/E2H9eUj6fBUygBWj4j60kD2QodRg= X-Google-Smtp-Source: AK7set9da4OqDpVEjgTQ2+GEdUcgMlcQMMx0tI1WKicIrB+IV67agqwdgh9s3tJKQI4ZYVzWrmdD1Q== X-Received: by 2002:a17:902:e205:b0:198:68b1:624f with SMTP id u5-20020a170902e20500b0019868b1624fmr10723444plb.66.1675991296680; Thu, 09 Feb 2023 17:08:16 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:15 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 13/16] port: replace RTE_LOGTYPE_PORT with dynamic type Date: Thu, 9 Feb 2023 17:07:21 -0800 Message-Id: <20230210010724.890413-14-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Split up the single static RTE_LOGTYPE_PORT into separate sub types for each component: port.ethdev, port.evendev, ... Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/port/rte_port_ethdev.c | 23 +++++---- lib/port/rte_port_eventdev.c | 23 +++++---- lib/port/rte_port_fd.c | 28 ++++++----- lib/port/rte_port_frag.c | 21 +++++---- lib/port/rte_port_kni.c | 22 +++++---- lib/port/rte_port_ras.c | 19 ++++---- lib/port/rte_port_ring.c | 22 +++++---- lib/port/rte_port_sched.c | 16 ++++--- lib/port/rte_port_source_sink.c | 82 +++++++++++++++++++-------------- lib/port/rte_port_sym_crypto.c | 22 +++++---- 12 files changed, 164 insertions(+), 117 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 212ccda0a6e8..7002e267be37 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a1549b372767..ff714a703be7 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -39,7 +39,7 @@ extern "C" { /* was RTE_LOGTYPE_POWER */ /* was RTE_LOGTYPE_METER */ /* was RTE_LOGTYPE_SCHED */ -#define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ + /* was RTE_LOGTYPE_PORT */ #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ /* was RTE_LOGTYPE_MBUF */ diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c index 0da7890261e9..1ce0e7b3d396 100644 --- a/lib/port/rte_port_ethdev.c +++ b/lib/port/rte_port_ethdev.c @@ -5,11 +5,16 @@ #include #include +#include #include #include #include "rte_port_ethdev.h" +RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO); +#define RTE_PORT_ETHDEV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ethdev_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port ETHDEV Reader */ @@ -43,7 +48,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "params is NULL"); return NULL; } @@ -51,7 +56,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -78,7 +83,7 @@ static int rte_port_ethdev_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -142,7 +147,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -150,7 +155,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -257,7 +262,7 @@ static int rte_port_ethdev_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -323,7 +328,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -331,7 +336,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -470,7 +475,7 @@ static int rte_port_ethdev_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c index fd7dac9a5661..9331bd9a8e52 100644 --- a/lib/port/rte_port_eventdev.c +++ b/lib/port/rte_port_eventdev.c @@ -5,11 +5,16 @@ #include #include +#include #include #include #include "rte_port_eventdev.h" +RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO); +#define RTE_PORT_EVENTDEV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_eventdev_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port EVENTDEV Reader */ @@ -45,7 +50,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "params is NULL"); return NULL; } @@ -53,7 +58,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -85,7 +90,7 @@ static int rte_port_eventdev_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -155,7 +160,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id) (conf->enq_burst_sz == 0) || (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->enq_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -163,7 +168,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -290,7 +295,7 @@ static int rte_port_eventdev_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -362,7 +367,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) (conf->enq_burst_sz == 0) || (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->enq_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -370,7 +375,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -530,7 +535,7 @@ static int rte_port_eventdev_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c index 932ecd324e05..78a65d4ad582 100644 --- a/lib/port/rte_port_fd.c +++ b/lib/port/rte_port_fd.c @@ -10,6 +10,10 @@ #include "rte_port_fd.h" +RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO); +#define RTE_PORT_FD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_fd_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port FD Reader */ @@ -43,19 +47,19 @@ rte_port_fd_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "params is NULL"); return NULL; } if (conf->fd < 0) { - RTE_LOG(ERR, PORT, "%s: Invalid file descriptor\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid file descriptor"); return NULL; } if (conf->mtu == 0) { - RTE_LOG(ERR, PORT, "%s: Invalid MTU\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid MTU"); return NULL; } if (conf->mempool == NULL) { - RTE_LOG(ERR, PORT, "%s: Invalid mempool\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid mempool"); return NULL; } @@ -63,7 +67,7 @@ rte_port_fd_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -109,7 +113,7 @@ static int rte_port_fd_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -171,7 +175,7 @@ rte_port_fd_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -179,7 +183,7 @@ rte_port_fd_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -279,7 +283,7 @@ static int rte_port_fd_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -344,7 +348,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -352,7 +356,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -464,7 +468,7 @@ static int rte_port_fd_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c index e1f1892176c4..1a6d88cceb84 100644 --- a/lib/port/rte_port_frag.c +++ b/lib/port/rte_port_frag.c @@ -7,6 +7,11 @@ #include "rte_port_frag.h" +RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO); +#define RTE_PORT_FRAG_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_frag_logtype, \ + "%s: " fmt "\n", __func__, ## args) + /* Max number of fragments per packet allowed */ #define RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80 @@ -62,25 +67,23 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter conf is NULL"); return NULL; } if (conf->ring == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter ring is NULL"); return NULL; } if (conf->mtu == 0) { - RTE_LOG(ERR, PORT, "%s: Parameter mtu is invalid\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter mtu is invalid"); return NULL; } if (conf->pool_direct == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter pool_direct is NULL\n", - __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter pool_direct is NULL"); return NULL; } if (conf->pool_indirect == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter pool_indirect is NULL\n", - __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter pool_indirect is NULL"); return NULL; } @@ -88,7 +91,7 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "port is NULL"); return NULL; } @@ -232,7 +235,7 @@ static int rte_port_ring_reader_frag_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter port is NULL"); return -1; } diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c index 1c7a6cb200ea..3f4d1dcb5882 100644 --- a/lib/port/rte_port_kni.c +++ b/lib/port/rte_port_kni.c @@ -9,6 +9,10 @@ #include "rte_port_kni.h" +RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO); +#define RTE_PORT_KNI_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_kni_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port KNI Reader */ @@ -41,7 +45,7 @@ rte_port_kni_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "params is NULL"); return NULL; } @@ -49,7 +53,7 @@ rte_port_kni_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -75,7 +79,7 @@ static int rte_port_kni_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -138,7 +142,7 @@ rte_port_kni_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -146,7 +150,7 @@ rte_port_kni_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -250,7 +254,7 @@ static int rte_port_kni_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -315,7 +319,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -323,7 +327,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -460,7 +464,7 @@ static int rte_port_kni_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c index e5de57da42ea..6cc1c19fc971 100644 --- a/lib/port/rte_port_ras.c +++ b/lib/port/rte_port_ras.c @@ -21,6 +21,11 @@ #define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET) #endif +RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO); +#define RTE_PORT_RAS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ras_logtype, \ + "%s: " fmt "\n", __func__, ## args) + #ifdef RTE_PORT_STATS_COLLECT #define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \ @@ -69,17 +74,16 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter conf is NULL"); return NULL; } if (conf->ring == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter ring is NULL"); return NULL; } if ((conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Parameter tx_burst_sz is invalid\n", - __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter tx_burst_sz is invalid"); return NULL; } @@ -87,7 +91,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate socket\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Failed to allocate socket"); return NULL; } @@ -103,8 +107,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) socket_id); if (port->frag_tbl == NULL) { - RTE_LOG(ERR, PORT, "%s: rte_ip_frag_table_create failed\n", - __func__); + RTE_PORT_RAS_LOG(ERR, "rte_ip_frag_table_create failed"); rte_free(port); return NULL; } @@ -282,7 +285,7 @@ rte_port_ring_writer_ras_free(void *port) port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter port is NULL"); return -1; } diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c index 52b2d8e557f0..bc9cb4f72b15 100644 --- a/lib/port/rte_port_ring.c +++ b/lib/port/rte_port_ring.c @@ -10,6 +10,10 @@ #include "rte_port_ring.h" +RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO); +#define RTE_PORT_RING_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ring_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port RING Reader */ @@ -46,7 +50,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id, (conf->ring == NULL) || (rte_ring_is_cons_single(conf->ring) && is_multi) || (!rte_ring_is_cons_single(conf->ring) && !is_multi)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -54,7 +58,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -107,7 +111,7 @@ static int rte_port_ring_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -174,7 +178,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id, (rte_ring_is_prod_single(conf->ring) && is_multi) || (!rte_ring_is_prod_single(conf->ring) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -182,7 +186,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -370,7 +374,7 @@ rte_port_ring_writer_free(void *port) struct rte_port_ring_writer *p = port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -443,7 +447,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, (rte_ring_is_prod_single(conf->ring) && is_multi) || (!rte_ring_is_prod_single(conf->ring) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -451,7 +455,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -703,7 +707,7 @@ rte_port_ring_writer_nodrop_free(void *port) port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c index 8a7d815ef323..8a421855f7e2 100644 --- a/lib/port/rte_port_sched.c +++ b/lib/port/rte_port_sched.c @@ -7,6 +7,10 @@ #include "rte_port_sched.h" +RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO); +#define RTE_PORT_SCHED_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_sched_logtype, \ + "%s: " fmt "\n", __func__, ##args) /* * Reader */ @@ -40,7 +44,7 @@ rte_port_sched_reader_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || (conf->sched == NULL)) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Invalid params"); return NULL; } @@ -48,7 +52,7 @@ rte_port_sched_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -74,7 +78,7 @@ static int rte_port_sched_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -139,7 +143,7 @@ rte_port_sched_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Invalid params"); return NULL; } @@ -147,7 +151,7 @@ rte_port_sched_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -247,7 +251,7 @@ static int rte_port_sched_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c index 7d73adc1e79e..80c31d6cee6a 100644 --- a/lib/port/rte_port_source_sink.c +++ b/lib/port/rte_port_source_sink.c @@ -15,6 +15,12 @@ #include "rte_port_source_sink.h" +RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO); + +#define RTE_PORT_SOURCE_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_source_logtype, \ + "%s: " fmt "\n", __func__, ##args) + /* * Port SOURCE */ @@ -49,9 +55,9 @@ struct rte_port_source { static int pcap_source_load(struct rte_port_source *port, - const char *file_name, - uint32_t n_bytes_per_pkt, - int socket_id) + const char *file_name, + uint32_t n_bytes_per_pkt, + int socket_id) { uint32_t n_pkts = 0; uint32_t i; @@ -64,8 +70,8 @@ pcap_source_load(struct rte_port_source *port, const uint8_t *pkt; uint8_t *buff = NULL; uint32_t pktmbuf_maxlen = (uint32_t) - (rte_pktmbuf_data_room_size(port->mempool) - - RTE_PKTMBUF_HEADROOM); + (rte_pktmbuf_data_room_size(port->mempool) - + RTE_PKTMBUF_HEADROOM); if (n_bytes_per_pkt == 0) max_len = pktmbuf_maxlen; @@ -75,8 +81,9 @@ pcap_source_load(struct rte_port_source *port, /* first time open, get packet number */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -86,31 +93,32 @@ pcap_source_load(struct rte_port_source *port, pcap_close(pcap_handle); port->pkt_len = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkt_len) * n_pkts), 0, socket_id); + (sizeof(*port->pkt_len) * n_pkts), 0, socket_id); if (port->pkt_len == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } pkt_len_aligns = rte_malloc("PCAP", - (sizeof(*pkt_len_aligns) * n_pkts), 0); + (sizeof(*pkt_len_aligns) * n_pkts), 0); if (pkt_len_aligns == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } port->pkts = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkts) * n_pkts), 0, socket_id); + (sizeof(*port->pkts) * n_pkts), 0, socket_id); if (port->pkts == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } /* open 2nd time, get pkt_len */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -126,9 +134,9 @@ pcap_source_load(struct rte_port_source *port, /* allocate a big trunk of data for pcap file load */ buff = rte_zmalloc_socket("PCAP", - total_buff_len, 0, socket_id); + total_buff_len, 0, socket_id); if (buff == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } @@ -137,8 +145,9 @@ pcap_source_load(struct rte_port_source *port, /* open file one last time to copy the pkt content */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -155,9 +164,9 @@ pcap_source_load(struct rte_port_source *port, rte_free(pkt_len_aligns); - RTE_LOG(INFO, PORT, "Successfully load pcap file " - "'%s' with %u pkts\n", - file_name, port->n_pkts); + RTE_PORT_SOURCE_LOG(INFO, + "Successfully load pcap file '%s' with %u pkts", + file_name, port->n_pkts); return 0; @@ -180,8 +189,8 @@ pcap_source_load(struct rte_port_source *port, int _ret = 0; \ \ if (file_name) { \ - RTE_LOG(ERR, PORT, "Source port field " \ - "\"file_name\" is not NULL.\n"); \ + RTE_PORT_SOURCE_LOG(ERR, "Source port field " \ + "\"file_name\" is not NULL."); \ _ret = -1; \ } \ \ @@ -199,7 +208,7 @@ rte_port_source_create(void *params, int socket_id) /* Check input arguments*/ if ((p == NULL) || (p->mempool == NULL)) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Invalid params"); return NULL; } @@ -207,7 +216,7 @@ rte_port_source_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -332,15 +341,16 @@ pcap_sink_open(struct rte_port_sink *port, /** Open a dead pcap handler for opening dumper file */ tx_pcap = pcap_open_dead(DLT_EN10MB, 65535); if (tx_pcap == NULL) { - RTE_LOG(ERR, PORT, "Cannot open pcap dead handler\n"); + RTE_PORT_SOURCE_LOG(ERR, "Cannot open pcap dead handler"); return -1; } /* The dumper is created using the previous pcap_t reference */ pcap_dumper = pcap_dump_open(tx_pcap, file_name); if (pcap_dumper == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "\"%s\" for writing\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file \"%s\" for writing", + file_name); return -1; } @@ -349,8 +359,9 @@ pcap_sink_open(struct rte_port_sink *port, port->pkt_index = 0; port->dump_finish = 0; - RTE_LOG(INFO, PORT, "Ready to dump packets to file \"%s\"\n", - file_name); + RTE_PORT_SOURCE_LOG(INFO, + "Ready to dump packets to file \"%s\"", + file_name); return 0; } @@ -402,8 +413,9 @@ pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf) if ((port->max_pkts != 0) && (port->pkt_index >= port->max_pkts)) { port->dump_finish = 1; - RTE_LOG(INFO, PORT, "Dumped %u packets to file\n", - port->pkt_index); + RTE_PORT_SOURCE_LOG(INFO, + "Dumped %u packets to file", + port->pkt_index); } } @@ -433,7 +445,7 @@ do { \ int _ret = 0; \ \ if (file_name) { \ - RTE_LOG(ERR, PORT, "Sink port field " \ + RTE_PORT_SOURCE_LOG(ERR, "Sink port field " \ "\"file_name\" is not NULL.\n"); \ _ret = -1; \ } \ @@ -459,7 +471,7 @@ rte_port_sink_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port"); return NULL; } diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c index 295984d025cb..3a55a5fde6fb 100644 --- a/lib/port/rte_port_sym_crypto.c +++ b/lib/port/rte_port_sym_crypto.c @@ -8,6 +8,10 @@ #include "rte_port_sym_crypto.h" +RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO); +#define RTE_PORT_CRYPTO_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_crypto_logtype, \ + "%s: " fmt "\n", __func__, ##args) /* * Port Crypto Reader */ @@ -44,7 +48,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "params is NULL"); return NULL; } @@ -52,7 +56,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -100,7 +104,7 @@ static int rte_port_sym_crypto_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -167,7 +171,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -175,7 +179,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -285,7 +289,7 @@ static int rte_port_sym_crypto_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -353,7 +357,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -361,7 +365,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -497,7 +501,7 @@ static int rte_port_sym_crypto_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL"); return -EINVAL; } From patchwork Fri Feb 10 01:07:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123639 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E98E041C58; Fri, 10 Feb 2023 02:09:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CA1E42D9B; Fri, 10 Feb 2023 02:08:25 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 534D842D3E for ; Fri, 10 Feb 2023 02:08:19 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id pj3so3756135pjb.1 for ; Thu, 09 Feb 2023 17:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oUD4untaWq9ClN/tsZ8toVOkAn+YUUKEAaJT0knWzqU=; b=SFwBNMohg7kMH9vq3FaOBo6xnoyfVxfchNYOxIhDZWvB3hJda+1c/HjMCSD/6QMlEx SJeFjiy/Z3ahix9+I9Wtfw/09n+VjQxd2YJVVQaXjjMTwg7i0LbQKgjCqTgugzDMsIQ7 mQVhuaLqkhpatcROAOInuvkm1f9P1YYif3nW2dAnnBZ7rY7CqPa380/cpJh7u6nt5Bo6 34BZjMmBpxUVs8kWQWniRRhdAsQpJUC23yS6RBCBqrWQWbAeGO8wtD+m9K3pAC+uGDLn +lANWJzfRY+6FKg6pIBwef1/1x+5xaeKb27989m/sp4MB2bKo886nvtSTVSEQ6WXVGYm lchw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oUD4untaWq9ClN/tsZ8toVOkAn+YUUKEAaJT0knWzqU=; b=iE9Y12Gq9dbnqea/uEZt62m49m7LKJlK58nWhuvSAowa9mSEYlH7WkpaSMsHhR9wtC 0aFREnNAnwzaRabXNcfQBs63W3BJVhsURIv8RzYj8cn8Y1rli8Dgf9p2qkytckYnG1Du a+RaTn8kza9IvKMK9NWj0Pr9OVxpRoUCKuptRE039qf32o4xtAI6eFLHysfJEjix7ffS aGt5d2AZp354aDGa2+L9c0jJTThx4lcypn8XdDXQxjUHAInGdHPQzPZlpwNTuibx0Q2B CvHOLjBh+uwskqhUCC2XZlcSfJWJRuHC5S9yYhZegYl0lL6JTWXCBeH6BWkf2OCNfBXk V9sA== X-Gm-Message-State: AO0yUKVxXE4hBO0eGpdWDcyCy9/gOQRDx79x3TOlA4o3V00YS6BDHX6H eYCscP/CNmLFZ0A0EoOa9MaMv7TDGYQPk7io+XI= X-Google-Smtp-Source: AK7set9dv/mS8Cm/XCU8o8VSdsftskP7N2lywP1vEFzfEVt8gjByj1OaeWtXWG7nmXGbjhc47qu6UA== X-Received: by 2002:a17:902:f54f:b0:199:1769:48dc with SMTP id h15-20020a170902f54f00b00199176948dcmr13745806plf.65.1675991297662; Thu, 09 Feb 2023 17:08:17 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Date: Thu, 9 Feb 2023 17:07:22 -0800 Message-Id: <20230210010724.890413-15-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use logtype suffixes for various components of this library. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/table/rte_table_acl.c | 90 +++++++++++++------------------ lib/table/rte_table_array.c | 23 ++++---- lib/table/rte_table_hash_cuckoo.c | 30 ++++++----- lib/table/rte_table_hash_ext.c | 34 +++++++----- lib/table/rte_table_hash_key16.c | 56 ++++++++++--------- lib/table/rte_table_hash_key32.c | 62 ++++++++++----------- lib/table/rte_table_hash_key8.c | 59 ++++++++++---------- lib/table/rte_table_hash_lru.c | 35 ++++++------ lib/table/rte_table_lpm.c | 54 +++++++++---------- lib/table/rte_table_lpm_ipv6.c | 56 +++++++++---------- lib/table/rte_table_stub.c | 9 ++-- 13 files changed, 257 insertions(+), 254 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 7002e267be37..a4e718e51d12 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index ff714a703be7..af87eb42ddb3 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -40,7 +40,7 @@ extern "C" { /* was RTE_LOGTYPE_METER */ /* was RTE_LOGTYPE_SCHED */ /* was RTE_LOGTYPE_PORT */ -#define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ + /* was RTE_LOGTYPE_TABLE */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ /* was RTE_LOGTYPE_MBUF */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c index 53fd5c66adb5..87081f183862 100644 --- a/lib/table/rte_table_acl.c +++ b/lib/table/rte_table_acl.c @@ -11,6 +11,11 @@ #include "rte_table_acl.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_acl, acl, INFO); +#define TABLE_ACL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_acl, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \ @@ -65,22 +70,20 @@ rte_table_acl_create( /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for params\n", __func__); + TABLE_ACL_LOG(ERR, "Invalid value for params"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for name\n", __func__); + TABLE_ACL_LOG(ERR, "Invalid value for name"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rules\n", - __func__); + TABLE_ACL_LOG(ERR, "Invalid value for n_rules"); return NULL; } if ((p->n_rule_fields == 0) || (p->n_rule_fields > RTE_ACL_MAX_FIELDS)) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rule_fields\n", - __func__); + TABLE_ACL_LOG(ERR, "Invalid value for n_rule_fields"); return NULL; } @@ -98,9 +101,7 @@ rte_table_acl_create( acl = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (acl == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for ACL table\n", - __func__, total_size); + TABLE_ACL_LOG(ERR,"Cannot allocate %u bytes for ACL table", total_size); return NULL; } @@ -140,7 +141,7 @@ rte_table_acl_free(void *table) /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -164,8 +165,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) /* Create low level ACL table */ ctx = rte_acl_create(&acl->acl_params); if (ctx == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot create low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot create low level ACL table"); return -1; } @@ -176,9 +176,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) status = rte_acl_add_rules(ctx, acl->acl_rule_list[i], 1); if (status != 0) { - RTE_LOG(ERR, TABLE, - "%s: Cannot add rule to low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot add rule to low level ACL table"); rte_acl_free(ctx); return -1; } @@ -196,9 +194,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) /* Build low level ACl table */ status = rte_acl_build(ctx, &acl->cfg); if (status != 0) { - RTE_LOG(ERR, TABLE, - "%s: Cannot build the low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot build the low level ACL table"); rte_acl_free(ctx); return -1; } @@ -226,29 +222,27 @@ rte_table_acl_entry_add( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entry_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "entry_ptr parameter is NULL"); return -EINVAL; } if (rule->priority > RTE_ACL_MAX_PRIORITY) { - RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__); + TABLE_ACL_LOG(ERR, "Priority is too high"); return -EINVAL; } @@ -291,8 +285,7 @@ rte_table_acl_entry_add( /* Return if max rules */ if (free_pos_valid == 0) { - RTE_LOG(ERR, TABLE, "%s: Max number of rules reached\n", - __func__); + TABLE_ACL_LOG(ERR, "Max number of rules reached"); return -ENOSPC; } @@ -342,16 +335,15 @@ rte_table_acl_entry_delete( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } @@ -424,29 +416,27 @@ rte_table_acl_entry_add_bulk( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "keys parameter is NULL"); return -EINVAL; } if (entries == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "entries parameter is NULL"); return -EINVAL; } if (n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: 0 rules to add\n", __func__); + TABLE_ACL_LOG(ERR, "0 rules to add"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entries_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries_ptr parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "entries_ptr parameter is NULL"); return -EINVAL; } @@ -455,20 +445,18 @@ rte_table_acl_entry_add_bulk( struct rte_table_acl_rule_add_params *rule; if (keys[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL\n", i); return -EINVAL; } if (entries[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "entries[%" PRIu32 "] parameter is NULL\n", i); return -EINVAL; } rule = keys[i]; if (rule->priority > RTE_ACL_MAX_PRIORITY) { - RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__); + TABLE_ACL_LOG(ERR, "Priority is too high"); return -EINVAL; } } @@ -604,27 +592,25 @@ rte_table_acl_entry_delete_bulk( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: 0 rules to delete\n", __func__); + TABLE_ACL_LOG(ERR, "0 rules to delete"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } for (i = 0; i < n_keys; i++) { if (keys[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL", i); return -EINVAL; } } diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c index 54a0c42f7dd2..47b5a2b15b2b 100644 --- a/lib/table/rte_table_array.c +++ b/lib/table/rte_table_array.c @@ -11,6 +11,11 @@ #include "rte_table_array.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_array, array, INFO); +#define TABLE_ARRAY_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_array, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \ @@ -61,9 +66,7 @@ rte_table_array_create(void *params, int socket_id, uint32_t entry_size) total_size = total_cl_size * RTE_CACHE_LINE_SIZE; t = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for array table\n", - __func__, total_size); + TABLE_ARRAY_LOG(ERR, "Cannot allocate %u bytes for array table\n", total_size); return NULL; } @@ -83,7 +86,7 @@ rte_table_array_free(void *table) /* Check input parameters */ if (t == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -107,25 +110,23 @@ rte_table_array_entry_add( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ARRAY_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entry_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n", - __func__); + TABLE_ARRAY_LOG(ERR, "entry_ptr parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c index c77eccf52722..7b1f1575e564 100644 --- a/lib/table/rte_table_hash_cuckoo.c +++ b/lib/table/rte_table_hash_cuckoo.c @@ -10,6 +10,11 @@ #include "rte_table_hash_cuckoo.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash, hash, INFO); +#define TABLE_HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \ @@ -47,27 +52,27 @@ static int check_params_create_hash_cuckoo(struct rte_table_hash_cuckoo_params *params) { if (params == NULL) { - RTE_LOG(ERR, TABLE, "NULL Input Parameters.\n"); + TABLE_HASH_LOG(ERR, "NULL Input Parameters."); return -EINVAL; } if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "Table name is NULL.\n"); + TABLE_HASH_LOG(ERR, "Table name is NULL."); return -EINVAL; } if (params->key_size == 0) { - RTE_LOG(ERR, TABLE, "Invalid key_size.\n"); + TABLE_HASH_LOG(ERR, "Invalid key_size."); return -EINVAL; } if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "Invalid n_keys.\n"); + TABLE_HASH_LOG(ERR, "Invalid n_keys."); return -EINVAL; } if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "f_hash is NULL.\n"); + TABLE_HASH_LOG(ERR, "f_hash is NULL."); return -EINVAL; } @@ -94,9 +99,8 @@ rte_table_hash_cuckoo_create(void *params, t = rte_zmalloc_socket(p->name, total_size, RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for cuckoo hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LOG(ERR, "Cannot allocate %u bytes for cuckoo hash table %s", + total_size, p->name); return NULL; } @@ -114,9 +118,8 @@ rte_table_hash_cuckoo_create(void *params, if (h_table == NULL) { h_table = rte_hash_create(&hash_cuckoo_params); if (h_table == NULL) { - RTE_LOG(ERR, TABLE, - "%s: failed to create cuckoo hash table %s\n", - __func__, p->name); + TABLE_HASH_LOG(ERR, "failed to create cuckoo hash table %s", + p->name); rte_free(t); return NULL; } @@ -131,9 +134,8 @@ rte_table_hash_cuckoo_create(void *params, t->key_offset = p->key_offset; t->h_table = h_table; - RTE_LOG(INFO, TABLE, - "%s: Cuckoo hash table %s memory footprint is %u bytes\n", - __func__, p->name, total_size); + TABLE_HASH_LOG(INFO, "Cuckoo hash table %s memory footprint is %u bytes", + p->name, total_size); return t; } diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c index 70ea84fa2e51..ca16328c1612 100644 --- a/lib/table/rte_table_hash_ext.c +++ b/lib/table/rte_table_hash_ext.c @@ -11,6 +11,11 @@ #include "rte_table_hash.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_ext, hash.ext, INFO); +#define TABLE_HASH_EXT_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash_ext, \ + "%s(): " fmt "\n", __func__, ##args) + #define KEYS_PER_BUCKET 4 struct bucket { @@ -128,33 +133,33 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if ((params->key_size < sizeof(uint64_t)) || (!rte_is_power_of_2(params->key_size))) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "n_keys invalid value"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "f_hash invalid value"); return -EINVAL; } @@ -211,9 +216,9 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size) key_sz + key_stack_sz + bkt_ext_stack_sz + data_sz; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_EXT_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -222,14 +227,15 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_EXT_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory " - "footprint is %" PRIu64 " bytes\n", - __func__, p->key_size, p->name, total_size); + + TABLE_HASH_EXT_LOG(INFO, + "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes", + p->key_size, p->name, total_size); /* Memory initialization */ t->key_size = p->key_size; diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c index 04d7fd64bd97..5501a9c5fc54 100644 --- a/lib/table/rte_table_hash_key16.c +++ b/lib/table/rte_table_hash_key16.c @@ -11,6 +11,11 @@ #include "rte_table_hash.h" #include "rte_lru.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash16, hash16, INFO); +#define TABLE_HASH16_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash16, \ + "%s(): " fmt "\n", __func__, ##args) + #define KEY_SIZE 16 #define KEYS_PER_BUCKET 4 @@ -107,33 +112,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH16_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH16_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -181,9 +185,9 @@ rte_table_hash_create_key16_lru(void *params, total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -192,14 +196,14 @@ rte_table_hash_create_key16_lru(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH16_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -236,7 +240,7 @@ rte_table_hash_free_key16_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH16_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -391,9 +395,9 @@ rte_table_hash_create_key16_ext(void *params, total_size = sizeof(struct rte_table_hash) + (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -402,14 +406,14 @@ rte_table_hash_create_key16_ext(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH16_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -446,7 +450,7 @@ rte_table_hash_free_key16_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH16_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c index 88d8f69c72ed..d830c6b3784a 100644 --- a/lib/table/rte_table_hash_key32.c +++ b/lib/table/rte_table_hash_key32.c @@ -11,11 +11,16 @@ #include "rte_table_hash.h" #include "rte_lru.h" -#define KEY_SIZE 32 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash32, hash32, INFO); +#define TABLE_HASH32_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash32, \ + "%s(): " fmt "\n", __func__, ##args) + +#define KEY_SIZE 32 #define KEYS_PER_BUCKET 4 -#define RTE_BUCKET_ENTRY_VALID 0x1LLU +#define RTE_BUCKET_ENTRY_VALID 0x1LLU #ifdef RTE_TABLE_STATS_COLLECT @@ -111,33 +116,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH32_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH32_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -184,9 +188,9 @@ rte_table_hash_create_key32_lru(void *params, KEYS_PER_BUCKET * entry_size); total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -195,15 +199,14 @@ rte_table_hash_create_key32_lru(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, - "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH32_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -244,7 +247,7 @@ rte_table_hash_free_key32_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH32_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -400,9 +403,9 @@ rte_table_hash_create_key32_ext(void *params, total_size = sizeof(struct rte_table_hash) + (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -411,15 +414,14 @@ rte_table_hash_create_key32_ext(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, - "%s: Hash table %s memory footprint " - "is %" PRIu64" bytes\n", - __func__, p->name, total_size); + TABLE_HASH32_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64" bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -460,7 +462,7 @@ rte_table_hash_free_key32_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH32_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c index 035d24276946..9678ee0741e5 100644 --- a/lib/table/rte_table_hash_key8.c +++ b/lib/table/rte_table_hash_key8.c @@ -11,7 +11,12 @@ #include "rte_table_hash.h" #include "rte_lru.h" -#define KEY_SIZE 8 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash8, hash8, INFO); +#define TABLE_HASH8_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash8, \ + "%s(): " fmt "\n", __func__, ##args) + +#define KEY_SIZE 8 #define KEYS_PER_BUCKET 4 @@ -101,33 +106,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH8_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH8_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -173,9 +177,9 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size) total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -184,15 +188,15 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH8_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -226,7 +230,7 @@ rte_table_hash_free_key8_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH8_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -377,9 +381,9 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size) (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -388,15 +392,14 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH8_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -430,7 +433,7 @@ rte_table_hash_free_key8_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH8_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c index c31acc11cf23..9bc64f74c922 100644 --- a/lib/table/rte_table_hash_lru.c +++ b/lib/table/rte_table_hash_lru.c @@ -14,6 +14,11 @@ #define KEYS_PER_BUCKET 4 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_lru, hash.lru, INFO); +#define TABLE_HASH_LRU_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash_lru, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \ @@ -105,33 +110,33 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if ((params->key_size < sizeof(uint64_t)) || (!rte_is_power_of_2(params->key_size))) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "n_keys invalid value"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "f_hash invalid value"); return -EINVAL; } @@ -187,10 +192,9 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) key_stack_sz + data_sz; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes for hash " - "table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LRU_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -199,15 +203,14 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes for hash " - "table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LRU_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory footprint" - " is %" PRIu64 " bytes\n", - __func__, p->key_size, p->name, total_size); + TABLE_HASH_LRU_LOG(INFO, + "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes", + p->key_size, p->name, total_size); /* Memory initialization */ t->key_size = p->key_size; diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c index 9de9e8a20d77..653e2604fd34 100644 --- a/lib/table/rte_table_lpm.c +++ b/lib/table/rte_table_lpm.c @@ -13,6 +13,11 @@ #include "rte_table_lpm.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm, lpm, INFO); +#define TABLE_LPM_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_lpm, \ + "%s(): " fmt "\n", __func__, ##args) + #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS #define RTE_TABLE_LPM_MAX_NEXT_HOPS 65536 #endif @@ -59,30 +64,27 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__); + TABLE_LPM_LOG(ERR, "NULL input parameters"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->number_tbl8s == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid number_tbl8s\n", __func__); + TABLE_LPM_LOG(ERR, "Invalid number_tbl8s"); return NULL; } if (p->entry_unique_size == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->entry_unique_size > entry_size) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "Table name is NULL"); return NULL; } entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t)); @@ -93,9 +95,8 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for LPM table\n", - __func__, total_size); + TABLE_LPM_LOG(ERR, "Cannot allocate %u bytes for LPM table", + total_size); return NULL; } @@ -107,7 +108,7 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) if (lpm->lpm == NULL) { rte_free(lpm); - RTE_LOG(ERR, TABLE, "Unable to create low-level LPM table\n"); + TABLE_LPM_LOG(ERR, "Unable to create low-level LPM table"); return NULL; } @@ -127,7 +128,7 @@ rte_table_lpm_free(void *table) /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -187,22 +188,20 @@ rte_table_lpm_entry_add( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", - __func__, ip_prefix->depth); + TABLE_LPM_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -216,7 +215,7 @@ rte_table_lpm_entry_add( uint8_t *nht_entry; if (nht_find_free(lpm, &nht_pos) == 0) { - RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__); + TABLE_LPM_LOG(ERR, "NHT full"); return -1; } @@ -226,7 +225,7 @@ rte_table_lpm_entry_add( /* Add rule to low level LPM table */ if (rte_lpm_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth, nht_pos) < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM rule add failed\n", __func__); + TABLE_LPM_LOG(ERR, "LPM rule add failed"); return -1; } @@ -253,16 +252,15 @@ rte_table_lpm_entry_delete( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -271,7 +269,7 @@ rte_table_lpm_entry_delete( status = rte_lpm_is_rule_present(lpm->lpm, ip_prefix->ip, ip_prefix->depth, &nht_pos); if (status < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM algorithmic error\n", __func__); + TABLE_LPM_LOG(ERR, "LPM algorithmic error"); return -1; } if (status == 0) { @@ -282,7 +280,7 @@ rte_table_lpm_entry_delete( /* Delete rule from the low-level LPM table */ status = rte_lpm_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth); if (status) { - RTE_LOG(ERR, TABLE, "%s: LPM rule delete failed\n", __func__); + TABLE_LPM_LOG(ERR, "LPM rule delete failed"); return -1; } diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c index 8fde2c012f7c..9f87832ca8f0 100644 --- a/lib/table/rte_table_lpm_ipv6.c +++ b/lib/table/rte_table_lpm_ipv6.c @@ -12,6 +12,11 @@ #include "rte_table_lpm_ipv6.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm6, lpm6, INFO); +#define TABLE_LPM6_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_lpm6, \ + "%s(): " fmt "\n", __func__, ##args) + #define RTE_TABLE_LPM_MAX_NEXT_HOPS 256 #ifdef RTE_TABLE_STATS_COLLECT @@ -56,30 +61,27 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__); + TABLE_LPM6_LOG(ERR, "NULL input parameters"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM6_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->number_tbl8s == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM6_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->entry_unique_size == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->entry_unique_size > entry_size) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "Table name is NULL"); return NULL; } entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t)); @@ -90,9 +92,8 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for LPM IPv6 table\n", - __func__, total_size); + TABLE_LPM6_LOG(ERR, "Cannot allocate %u bytes for LPM IPv6 table", + total_size); return NULL; } @@ -103,8 +104,7 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) lpm->lpm = rte_lpm6_create(p->name, socket_id, &lpm6_config); if (lpm->lpm == NULL) { rte_free(lpm); - RTE_LOG(ERR, TABLE, - "Unable to create low-level LPM IPv6 table\n"); + TABLE_LPM6_LOG(ERR, "Unable to create low-level LPM IPv6 table\n"); return NULL; } @@ -124,7 +124,7 @@ rte_table_lpm_ipv6_free(void *table) /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -184,21 +184,20 @@ rte_table_lpm_ipv6_entry_add( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM6_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -213,7 +212,7 @@ rte_table_lpm_ipv6_entry_add( uint8_t *nht_entry; if (nht_find_free(lpm, &nht_pos) == 0) { - RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__); + TABLE_LPM6_LOG(ERR, "NHT full"); return -1; } @@ -224,7 +223,7 @@ rte_table_lpm_ipv6_entry_add( /* Add rule to low level LPM table */ if (rte_lpm6_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth, nht_pos) < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule add failed\n", __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 rule add failed"); return -1; } @@ -252,16 +251,15 @@ rte_table_lpm_ipv6_entry_delete( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM6_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -270,8 +268,7 @@ rte_table_lpm_ipv6_entry_delete( status = rte_lpm6_is_rule_present(lpm->lpm, ip_prefix->ip, ip_prefix->depth, &nht_pos); if (status < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 algorithmic error\n", - __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 algorithmic error"); return -1; } if (status == 0) { @@ -282,8 +279,7 @@ rte_table_lpm_ipv6_entry_delete( /* Delete rule from the low-level LPM table */ status = rte_lpm6_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth); if (status) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule delete failed\n", - __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 rule delete failed"); return -1; } diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c index 23d0de5c79b0..6ea978adfe80 100644 --- a/lib/table/rte_table_stub.c +++ b/lib/table/rte_table_stub.c @@ -8,6 +8,11 @@ #include "rte_table_stub.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_stub, stub, INFO); +#define TABLE_STUB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_stub, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \ @@ -38,9 +43,7 @@ rte_table_stub_create(__rte_unused void *params, stub = rte_zmalloc_socket("TABLE", size, RTE_CACHE_LINE_SIZE, socket_id); if (stub == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for stub table\n", - __func__, size); + TABLE_STUB_LOG(ERR, "Cannot allocate %u bytes for stub table", size); return NULL; } From patchwork Fri Feb 10 01:07:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123640 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 164A541C58; Fri, 10 Feb 2023 02:09:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D5F2842DA2; Fri, 10 Feb 2023 02:08:26 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id 7ED0A42D5A for ; Fri, 10 Feb 2023 02:08:19 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id s89-20020a17090a2f6200b0023125ebb4b1so4034495pjd.3 for ; Thu, 09 Feb 2023 17:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d4mpg7EHU1GKkOQjzVZUElKNmEdc7NTwiOoyGC3ebHU=; b=MBa6PdHrsg2TZ5PlpDk8o0xnahM976c48BUC/ESdvf/hmv2xRd2JFyZpzNJm0CZxsL //1TQXoyzA4igfftVWUzAWQsjdU0e+cdxChHY6W3WrhBhcv7N3SYsNVf2vLXW8hbUiVi WYZIeBaI3IdoPFdii4AzyZ4mSz70cUR4onjSfmhnZdS40DSkGIM+Wp50aD3Jix+QyBQX vhLJnzGAAipFWGqsBBQzPFpWsieKTWiSG5g8TwUfKzOGobbDO2vPXBcjtYKMa8wO//34 MiqrnK07V8KUdEP2rEnb5F82lJ4Ue+POFF0v9QfdN13UbyCgAOZjxLvp44yuy737jVhH aUhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d4mpg7EHU1GKkOQjzVZUElKNmEdc7NTwiOoyGC3ebHU=; b=7418bVx6SR55JbCGv+niHaoFlKZG7TsX3zHJ7sQaRGoZ8XrCFyTTpohotCLXW/5S5Z fqusNA7xCxVGzGp4+U9aEjgpRMG9Xm1SvQQ1bi5LI+PPyvHgIWVy0anSA6BUn284M9IZ jkCMS2RIgS6sITkVHrnP84OBf4llW5yeOyW6/XtqMADsrwdeU+TiLyCe1/s5GsF5WbnB DOP6vteE6Q+s+4X8bgsHkBDAQcBpKMtWfm++JmJ4JxmR9EtK3tq3k4Ac7KQu0cICCRgg K3Nx6igPVFdj/12W21OP+OXPtm+0dyK1tn+G7HIT14mprWSj7T59RQ9L0DwNrBqdX+hz dJIA== X-Gm-Message-State: AO0yUKVLTsmdEK8ly6T5NUGTXuNAZxWSiNNdILAYgnXzuVMJKea7arre Z3Ih0Vf7FMMLIsRhVSPPIpeXqYevlFps/cBzt2c= X-Google-Smtp-Source: AK7set/8pgO9d6XuKtRNqGmS8RWhIgC2sRqSvHpZyuJ3dsKohG9AavSgO8JIT8JzgHaCvStlRnv2eQ== X-Received: by 2002:a17:902:d4c2:b0:198:e63d:9a4f with SMTP id o2-20020a170902d4c200b00198e63d9a4fmr14702906plg.47.1675991298603; Thu, 09 Feb 2023 17:08:18 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 15/16] app/test: remove use of RTE_LOGTYPE_PIPELINE Date: Thu, 9 Feb 2023 17:07:23 -0800 Message-Id: <20230210010724.890413-16-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Instead of using static type PIPELINE for logging in test application use stderr instead. If not testing RTE_LOG() better to not use it since log also goes to syslog. Signed-off-by: Stephen Hemminger --- app/test/test_table_acl.c | 50 ++++++++++++++++------------------ app/test/test_table_pipeline.c | 40 +++++++++++++-------------- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c index e66f06b84d0a..dff9bddfb948 100644 --- a/app/test/test_table_acl.c +++ b/app/test/test_table_acl.c @@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v) &v->field_value[SRC_FIELD_IPV4].value.u32, &v->field_value[SRC_FIELD_IPV4].mask_range.u32); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n", + fprintf(stderr, "failed to read src address/mask: %s\n", in[CB_FLD_SRC_ADDR]); return rc; } @@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v) &v->field_value[DST_FIELD_IPV4].value.u32, &v->field_value[DST_FIELD_IPV4].mask_range.u32); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n", + fprintf(stderr, "failed to read dest address/mask: %s\n", in[CB_FLD_DST_ADDR]); return rc; } @@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v) &v->field_value[SRCP_FIELD_IPV4].value.u16, &v->field_value[SRCP_FIELD_IPV4].mask_range.u16); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n", + fprintf(stderr, "failed to read source port range: %s\n", in[CB_FLD_SRC_PORT_RANGE]); return rc; } @@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v) &v->field_value[DSTP_FIELD_IPV4].value.u16, &v->field_value[DSTP_FIELD_IPV4].mask_range.u16); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n", + fprintf(stderr, "failed to read dest port range: %s\n", in[CB_FLD_DST_PORT_RANGE]); return rc; } @@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v) &v->field_value[SRC_FIELD_IPV4].value.u32, &v->field_value[SRC_FIELD_IPV4].mask_range.u32); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n", + fprintf(stderr, "failed to read src address/mask: %s\n", in[CB_FLD_SRC_ADDR]); return rc; } @@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v) &v->field_value[DST_FIELD_IPV4].value.u32, &v->field_value[DST_FIELD_IPV4].mask_range.u32); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n", + fprintf(stderr, "failed to read dest address/mask: %s\n", in[CB_FLD_DST_ADDR]); return rc; } @@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v) &v->field_value[SRCP_FIELD_IPV4].value.u16, &v->field_value[SRCP_FIELD_IPV4].mask_range.u16); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n", + fprintf(stderr, "failed to read source port range: %s\n", in[CB_FLD_SRC_PORT_RANGE]); return rc; } @@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v) &v->field_value[DSTP_FIELD_IPV4].value.u16, &v->field_value[DSTP_FIELD_IPV4].mask_range.u16); if (rc != 0) { - RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n", + fprintf(stderr, "failed to read dest port range: %s\n", in[CB_FLD_DST_PORT_RANGE]); return rc; } @@ -346,7 +346,7 @@ setup_acl_pipeline(void) /* Pipeline configuration */ p = rte_pipeline_create(&pipeline_params); if (p == NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n", + fprintf(stderr, "%s: Failed to configure pipeline\n", __func__); goto fail; } @@ -410,7 +410,7 @@ setup_acl_pipeline(void) table_params.f_action_miss = NULL; table_params.action_data_size = 0; - RTE_LOG(INFO, PIPELINE, "miss_action=%x\n", + printf("miss_action=%x\n", table_entry_miss_action); printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs), @@ -471,9 +471,8 @@ setup_acl_pipeline(void) ret = parser(line, &keys[n]); if (ret != 0) { - RTE_LOG(ERR, PIPELINE, - "line %u: parse_cb_ipv4vlan_rule" - " failed, error code: %d (%s)\n", + fprintf(stderr, + "line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n", n, ret, strerror(-ret)); return ret; } @@ -513,9 +512,8 @@ setup_acl_pipeline(void) ret = parse_cb_ipv4_rule_del(line, &keys[n]); if (ret != 0) { - RTE_LOG(ERR, PIPELINE, - "line %u: parse_cb_ipv4vlan_rule" - " failed, error code: %d (%s)\n", + fprintf(stderr, + "line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n", n, ret, strerror(-ret)); return ret; } @@ -549,9 +547,8 @@ setup_acl_pipeline(void) ret = parser(line, &rule_params); if (ret != 0) { - RTE_LOG(ERR, PIPELINE, - "line %u: parse_cb_ipv4vlan_rule" - " failed, error code: %d (%s)\n", + fprintf(stderr, + "line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n", n, ret, strerror(-ret)); return ret; } @@ -575,8 +572,8 @@ setup_acl_pipeline(void) ret = parser(line, &rule_params); if (ret != 0) { - RTE_LOG(ERR, PIPELINE, "line %u: parse rule " - " failed, error code: %d (%s)\n", + fprintf(stderr, + "line %u: parse rule failed, error code: %d (%s)\n", n, ret, strerror(-ret)); return ret; } @@ -602,8 +599,8 @@ setup_acl_pipeline(void) ret = parser(line, &rule_params); if (ret != 0) { - RTE_LOG(ERR, PIPELINE, "line %u: parse rule" - " failed, error code: %d (%s)\n", + fprintf(stderr, + "line %u: parse rule failed, error code: %d (%s)\n", n, ret, strerror(-ret)); return ret; } @@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count) memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple, sizeof(struct ipv4_5tuple)); - RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n", + printf("%s: Enqueue onto ring %d\n", __func__, i); rte_ring_enqueue(rings_rx[i], mbuf); } @@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count) } if (tx_count != expected_count) { - RTE_LOG(INFO, PIPELINE, - "%s: Unexpected packets for ACL test, " - "expected %d, got %d\n", + fprintf(stderr, + "%s: Unexpected packets for ACL test, expected %d, got %d\n", __func__, expected_count, tx_count); goto fail; } diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c index 7adbbffbf55d..960f730cf20d 100644 --- a/app/test/test_table_pipeline.c +++ b/app/test/test_table_pipeline.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include "test_table.h" @@ -173,30 +172,31 @@ check_pipeline_invalid_params(void) p = rte_pipeline_create(NULL); if (p != NULL) { - RTE_LOG(INFO, PIPELINE, + fprintf(stderr, "%s: configured pipeline with null params\n", __func__); goto fail; } p = rte_pipeline_create(&pipeline_params_1); if (p != NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL " - "name\n", __func__); + fprintf(stderr, + "%s: Configure pipeline with NULL name\n", __func__); goto fail; } p = rte_pipeline_create(&pipeline_params_2); if (p != NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid " - "socket\n", __func__); + fprintf(stderr, + "%s: Configure pipeline with invalid socket\n", __func__); goto fail; } if (rte_eal_has_hugepages()) { p = rte_pipeline_create(&pipeline_params_3); if (p != NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with " - "invalid socket\n", __func__); + fprintf(stderr, + "%s: Configure pipeline with invalid socket\n", + __func__); goto fail; } } @@ -224,20 +224,20 @@ setup_pipeline(int test_type) .socket_id = 0, }; - RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n", + fprintf(stderr, "%s: **** Setting up %s test\n", __func__, pipeline_test_names[test_type]); /* Pipeline configuration */ p = rte_pipeline_create(&pipeline_params); if (p == NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n", + fprintf(stderr, "%s: Failed to configure pipeline\n", __func__); goto fail; } ret = rte_pipeline_free(p); if (ret != 0) { - RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n", + fprintf(stderr, "%s: Failed to free pipeline\n", __func__); goto fail; } @@ -245,7 +245,7 @@ setup_pipeline(int test_type) /* Pipeline configuration */ p = rte_pipeline_create(&pipeline_params); if (p == NULL) { - RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n", + fprintf(stderr, "%s: Failed to configure pipeline\n", __func__); goto fail; } @@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count) int ret; int tx_count; - RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n", + fprintf(stderr, "%s: **** Running %s test\n", __func__, pipeline_test_names[test_type]); /* Run pipeline once */ for (i = 0; i < N_PORTS; i++) @@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count) ret = rte_pipeline_flush(NULL); if (ret != -EINVAL) { - RTE_LOG(INFO, PIPELINE, + fprintf(stderr, "%s: No pipeline flush error NULL pipeline (%d)\n", __func__, ret); goto fail; @@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count) k32 = (uint32_t *) key; k32[0] = 0xadadadad >> (j % 2); - RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n", + fprintf(stderr, "%s: Enqueue onto ring %d\n", __func__, i); rte_ring_enqueue(rings_rx[i], m); } @@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count) } if (tx_count != expected_count) { - RTE_LOG(INFO, PIPELINE, - "%s: Unexpected packets out for %s test, expected %d, " - "got %d\n", __func__, pipeline_test_names[test_type], + fprintf(stderr, + "%s: Unexpected packets out for %s test, expected %d, got %d\n", + __func__, pipeline_test_names[test_type], expected_count, tx_count); goto fail; } @@ -564,8 +564,8 @@ test_table_pipeline(void) connect_miss_action_to_table = 0; if (check_pipeline_invalid_params()) { - RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params " - "failed.\n", __func__); + fprintf(stderr, "%s: Check pipeline invalid params failed.\n", + __func__); return -1; } From patchwork Fri Feb 10 01:07:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123641 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E265041C58; Fri, 10 Feb 2023 02:09:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0725242D69; Fri, 10 Feb 2023 02:08:28 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 12D3A42D65 for ; Fri, 10 Feb 2023 02:08:21 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id v23so4911871plo.1 for ; Thu, 09 Feb 2023 17:08:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=clf/jqv8wr39P/1rDP3iaIi7ECa5RQJd5A1SPvUnlhg=; b=icDNGEu50qykOGHoPdWjo+69US1tPT2FQy6NiQN6scg5meMB1KaZKoUsXsq71S4p07 8ZAgZWg3elG18RmbBsZjbaP9PdzAOJYoOVFh3W1MQcwrx6GgYb9uKringhywsmz1fUGF orUY25LZEd311PeG+mQg39WwVR100pP/pElA5kjdyzb6d64hJuNfwKXruWBO0TfL6lrf 955oB5BmWKCtP/ln/73B9zwCdqGnocd81DghEXzVUFOzDoiJc2MeM1weCLO/5pG7Mr3X 2MDxaECdYMm6z6c0vH8EquqbdiX+IivU6sT46iYIEp5mjbUAOzUNOjzZShz5rCJPqD4f U8Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=clf/jqv8wr39P/1rDP3iaIi7ECa5RQJd5A1SPvUnlhg=; b=Va7jK/lAyixw0obr4ddjldH2wR9u8TyPr/O2XauZUDeR6RTGeqS93KOVHgjEnTMlrU L5YecCcAlLezXnDFzPaU/2cCYWxF8GG2pjTFwAaZqd/cvWhIDbtEo9CkS9kFshz98wC8 nGiz3E7T5HLJ9vBLvkj2Ih0iaDum/GzuR8CF4ZSpltKkdHd81GRwlZr1pPy5fPFXYzRZ jHC2jRHSzswuPX7xifNGe6iFS8hBxF++C6Ot7DsXDRTAEYOOd69OEdxaYNF23uuUcSvY 0oad5b6itvkhKP1JUjeK0qCOZ+9uenbiChBJSBNGetsEs3zcrw/5DVrhEV2DJWLAv/eO XKYw== X-Gm-Message-State: AO0yUKUG3e5k75FkKlj32wVHJ2UpFuf5PgXljwAJ1jEvLWAA5sdNygi/ pNEWbIChXnwpLQXu8WaUw/x8aTj6XIoRTYhhK+0= X-Google-Smtp-Source: AK7set/IE9k74+ds2/xW4FFyE1SDgppCX2pI7SVKAts6Qam6SR7W3e+uEhjc/27tC7qJLVGk9jh9fg== X-Received: by 2002:a17:902:ec90:b0:199:12d5:5b9b with SMTP id x16-20020a170902ec9000b0019912d55b9bmr15134941plg.25.1675991299739; Thu, 09 Feb 2023 17:08:19 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:19 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 16/16] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type Date: Thu, 9 Feb 2023 17:07:24 -0800 Message-Id: <20230210010724.890413-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Split the static global PIPELINE log type into multiple suffix log types (by stage). Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/pipeline/rte_pipeline.c | 242 ++++++++++++-------------------- 3 files changed, 87 insertions(+), 158 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index a4e718e51d12..e4a4f7812bde 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index af87eb42ddb3..e2c11ad45c7f 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -41,7 +41,7 @@ extern "C" { /* was RTE_LOGTYPE_SCHED */ /* was RTE_LOGTYPE_PORT */ /* was RTE_LOGTYPE_TABLE */ -#define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ + /* was RTE_LOGTYPE_PIPELINE */ /* was RTE_LOGTYPE_MBUF */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ /* was RTE_LOGTYPE_EFD */ diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c index ff86c7cf96bf..19597d4e0f1e 100644 --- a/lib/pipeline/rte_pipeline.c +++ b/lib/pipeline/rte_pipeline.c @@ -12,6 +12,12 @@ #include "rte_pipeline.h" +RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO); + +#define PIPELINE_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, pipeline_logtype, \ + "%s(): " fmt "\n", __func__, ## args) + #define RTE_TABLE_INVALID UINT32_MAX #ifdef RTE_PIPELINE_STATS_COLLECT @@ -161,23 +167,19 @@ static int rte_pipeline_check_params(struct rte_pipeline_params *params) { if (params == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: Incorrect value for parameter params\n", __func__); + PIPELINE_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } /* name */ if (params->name == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: Incorrect value for parameter name\n", __func__); + PIPELINE_LOG(ERR, "Incorrect value for parameter name"); return -EINVAL; } /* socket */ if (params->socket_id < 0) { - RTE_LOG(ERR, PIPELINE, - "%s: Incorrect value for parameter socket_id\n", - __func__); + PIPELINE_LOG(ERR, "Incorrect value for parameter socket_id"); return -EINVAL; } @@ -193,9 +195,8 @@ rte_pipeline_create(struct rte_pipeline_params *params) /* Check input parameters */ status = rte_pipeline_check_params(params); if (status != 0) { - RTE_LOG(ERR, PIPELINE, - "%s: Pipeline params check failed (%d)\n", - __func__, status); + PIPELINE_LOG(ERR, "Pipeline params check failed (%d)", + status); return NULL; } @@ -204,8 +205,7 @@ rte_pipeline_create(struct rte_pipeline_params *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (p == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: Pipeline memory allocation failed\n", __func__); + PIPELINE_LOG(ERR, "Pipeline memory allocation failed"); return NULL; } @@ -233,8 +233,7 @@ rte_pipeline_free(struct rte_pipeline *p) /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: rte_pipeline parameter is NULL\n", __func__); + PIPELINE_LOG(ERR, "rte_pipeline parameter is NULL"); return -EINVAL; } @@ -275,45 +274,37 @@ rte_table_check_params(struct rte_pipeline *p, uint32_t *table_id) { if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter is NULL"); return -EINVAL; } if (params == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "params parameter is NULL"); return -EINVAL; } if (table_id == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: table_id parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "table_id parameter is NULL"); return -EINVAL; } /* ops */ if (params->ops == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params->ops is NULL\n", - __func__); + PIPELINE_LOG(ERR, "params->ops is NULL"); return -EINVAL; } if (params->ops->f_create == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_create function pointer is NULL\n", __func__); + PIPELINE_LOG(ERR, "f_create function pointer is NULL"); return -EINVAL; } if (params->ops->f_lookup == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_lookup function pointer is NULL\n", __func__); + PIPELINE_LOG(ERR, "f_lookup function pointer is NULL"); return -EINVAL; } /* De we have room for one more table? */ if (p->num_tables == RTE_PIPELINE_TABLE_MAX) { - RTE_LOG(ERR, PIPELINE, - "%s: Incorrect value for num_tables parameter\n", - __func__); + PIPELINE_LOG(ERR, "Incorrect value for num_tables parameter"); return -EINVAL; } @@ -345,8 +336,7 @@ rte_pipeline_table_create(struct rte_pipeline *p, default_entry = rte_zmalloc_socket( "PIPELINE", entry_size, RTE_CACHE_LINE_SIZE, p->socket_id); if (default_entry == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: Failed to allocate default entry\n", __func__); + PIPELINE_LOG(ERR, "Failed to allocate default entry"); return -EINVAL; } @@ -355,7 +345,7 @@ rte_pipeline_table_create(struct rte_pipeline *p, entry_size); if (h_table == NULL) { rte_free(default_entry); - RTE_LOG(ERR, PIPELINE, "%s: Table creation failed\n", __func__); + PIPELINE_LOG(ERR, "Table creation failed"); return -EINVAL; } @@ -401,20 +391,17 @@ rte_pipeline_table_default_entry_add(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter is NULL"); return -EINVAL; } if (default_entry == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: default_entry parameter is NULL\n", __func__); + PIPELINE_LOG(ERR, "default_entry parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } @@ -423,8 +410,7 @@ rte_pipeline_table_default_entry_add(struct rte_pipeline *p, if ((default_entry->action == RTE_PIPELINE_ACTION_TABLE) && table->table_next_id_valid && (default_entry->table_id != table->table_next_id)) { - RTE_LOG(ERR, PIPELINE, - "%s: Tree-like topologies not allowed\n", __func__); + PIPELINE_LOG(ERR, "Tree-like topologies not allowed"); return -EINVAL; } @@ -450,14 +436,12 @@ rte_pipeline_table_default_entry_delete(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: pipeline parameter is NULL\n", __func__); + PIPELINE_LOG(ERR, "pipeline parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } @@ -486,41 +470,36 @@ rte_pipeline_table_entry_add(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n", __func__); + PIPELINE_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: entry parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } table = &p->tables[table_id]; if (table->ops.f_add == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: f_add function pointer NULL\n", - __func__); + PIPELINE_LOG(ERR, "f_add function pointer NULL"); return -EINVAL; } if ((entry->action == RTE_PIPELINE_ACTION_TABLE) && table->table_next_id_valid && (entry->table_id != table->table_next_id)) { - RTE_LOG(ERR, PIPELINE, - "%s: Tree-like topologies not allowed\n", __func__); + PIPELINE_LOG(ERR, "Tree-like topologies not allowed"); return -EINVAL; } @@ -546,28 +525,24 @@ rte_pipeline_table_entry_delete(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } table = &p->tables[table_id]; if (table->ops.f_delete == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_delete function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_delete function pointer NULL"); return -EINVAL; } @@ -587,33 +562,29 @@ int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter is NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: keys parameter is NULL\n", __func__); + PIPELINE_LOG(ERR, "keys parameter is NULL"); return -EINVAL; } if (entries == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: entries parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "entries parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } table = &p->tables[table_id]; if (table->ops.f_add_bulk == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: f_add_bulk function pointer NULL\n", - __func__); + PIPELINE_LOG(ERR, "f_add_bulk function pointer NULL"); return -EINVAL; } @@ -621,8 +592,7 @@ int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p, if ((entries[i]->action == RTE_PIPELINE_ACTION_TABLE) && table->table_next_id_valid && (entries[i]->table_id != table->table_next_id)) { - RTE_LOG(ERR, PIPELINE, - "%s: Tree-like topologies not allowed\n", __func__); + PIPELINE_LOG(ERR, "Tree-like topologies not allowed"); return -EINVAL; } } @@ -651,28 +621,24 @@ int rte_pipeline_table_entry_delete_bulk(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n", - __func__); + PIPELINE_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table_id %d out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table_id %d out of range", table_id); return -EINVAL; } table = &p->tables[table_id]; if (table->ops.f_delete_bulk == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_delete function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_delete function pointer NULL"); return -EINVAL; } @@ -690,51 +656,44 @@ rte_pipeline_port_in_check_params(struct rte_pipeline *p, uint32_t *port_id) { if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (params == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params parameter NULL\n", __func__); + PIPELINE_LOG(ERR, "params parameter NULL"); return -EINVAL; } if (port_id == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: port_id parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "port_id parameter NULL"); return -EINVAL; } /* ops */ if (params->ops == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params->ops parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "params->ops parameter NULL"); return -EINVAL; } if (params->ops->f_create == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_create function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_create function pointer NULL"); return -EINVAL; } if (params->ops->f_rx == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: f_rx function pointer NULL\n", - __func__); + PIPELINE_LOG(ERR, "f_rx function pointer NULL"); return -EINVAL; } /* burst_size */ if ((params->burst_size == 0) || (params->burst_size > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PIPELINE, "%s: invalid value for burst_size\n", - __func__); + PIPELINE_LOG(ERR, "invalid value for burst_size"); return -EINVAL; } /* Do we have room for one more port? */ if (p->num_ports_in == RTE_PIPELINE_PORT_IN_MAX) { - RTE_LOG(ERR, PIPELINE, - "%s: invalid value for num_ports_in\n", __func__); + PIPELINE_LOG(ERR, "invalid value for num_ports_in"); return -EINVAL; } @@ -747,51 +706,44 @@ rte_pipeline_port_out_check_params(struct rte_pipeline *p, uint32_t *port_id) { if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (params == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params parameter NULL\n", __func__); + PIPELINE_LOG(ERR, "params parameter NULL"); return -EINVAL; } if (port_id == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: port_id parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "port_id parameter NULL"); return -EINVAL; } /* ops */ if (params->ops == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: params->ops parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "params->ops parameter NULL"); return -EINVAL; } if (params->ops->f_create == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_create function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_create function pointer NULL"); return -EINVAL; } if (params->ops->f_tx == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_tx function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_tx function pointer NULL"); return -EINVAL; } if (params->ops->f_tx_bulk == NULL) { - RTE_LOG(ERR, PIPELINE, - "%s: f_tx_bulk function pointer NULL\n", __func__); + PIPELINE_LOG(ERR, "f_tx_bulk function pointer NULL"); return -EINVAL; } /* Do we have room for one more port? */ if (p->num_ports_out == RTE_PIPELINE_PORT_OUT_MAX) { - RTE_LOG(ERR, PIPELINE, - "%s: invalid value for num_ports_out\n", __func__); + PIPELINE_LOG(ERR, "invalid value for num_ports_out"); return -EINVAL; } @@ -819,7 +771,7 @@ rte_pipeline_port_in_create(struct rte_pipeline *p, /* Create the port */ h_port = params->ops->f_create(params->arg_create, p->socket_id); if (h_port == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: Port creation failed\n", __func__); + PIPELINE_LOG(ERR, "Port creation failed"); return -EINVAL; } @@ -869,7 +821,7 @@ rte_pipeline_port_out_create(struct rte_pipeline *p, /* Create the port */ h_port = params->ops->f_create(params->arg_create, p->socket_id); if (h_port == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: Port creation failed\n", __func__); + PIPELINE_LOG(ERR, "Port creation failed"); return -EINVAL; } @@ -904,22 +856,17 @@ rte_pipeline_port_in_connect_to_table(struct rte_pipeline *p, /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (port_id >= p->num_ports_in) { - RTE_LOG(ERR, PIPELINE, - "%s: port IN ID %u is out of range\n", - __func__, port_id); + PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: Table ID %u is out of range\n", - __func__, table_id); + PIPELINE_LOG(ERR, "Table ID %u is out of range", table_id); return -EINVAL; } @@ -938,15 +885,12 @@ rte_pipeline_port_in_enable(struct rte_pipeline *p, uint32_t port_id) /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (port_id >= p->num_ports_in) { - RTE_LOG(ERR, PIPELINE, - "%s: port IN ID %u is out of range\n", - __func__, port_id); + PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id); return -EINVAL; } @@ -985,14 +929,12 @@ rte_pipeline_port_in_disable(struct rte_pipeline *p, uint32_t port_id) /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (port_id >= p->num_ports_in) { - RTE_LOG(ERR, PIPELINE, "%s: port IN ID %u is out of range\n", - __func__, port_id); + PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id); return -EINVAL; } @@ -1039,26 +981,22 @@ rte_pipeline_check(struct rte_pipeline *p) /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } /* Check that pipeline has at least one input port, one table and one output port */ if (p->num_ports_in == 0) { - RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 input port\n", - __func__); + PIPELINE_LOG(ERR, "must have at least 1 input port"); return -EINVAL; } if (p->num_tables == 0) { - RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 table\n", - __func__); + PIPELINE_LOG(ERR, "must have at least 1 table"); return -EINVAL; } if (p->num_ports_out == 0) { - RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 output port\n", - __func__); + PIPELINE_LOG(ERR, "must have at least 1 output port"); return -EINVAL; } @@ -1067,9 +1005,8 @@ rte_pipeline_check(struct rte_pipeline *p) struct rte_port_in *port_in = &p->ports_in[port_in_id]; if (port_in->table_id == RTE_TABLE_INVALID) { - RTE_LOG(ERR, PIPELINE, - "%s: Port IN ID %u is not connected\n", - __func__, port_in_id); + PIPELINE_LOG(ERR, "Port IN ID %u is not connected", + port_in_id); return -EINVAL; } } @@ -1451,8 +1388,7 @@ rte_pipeline_flush(struct rte_pipeline *p) /* Check input arguments */ if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } @@ -1504,15 +1440,12 @@ int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id, int retval; if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (port_id >= p->num_ports_in) { - RTE_LOG(ERR, PIPELINE, - "%s: port IN ID %u is out of range\n", - __func__, port_id); + PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id); return -EINVAL; } @@ -1541,13 +1474,12 @@ int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id, int retval; if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (port_id >= p->num_ports_out) { - RTE_LOG(ERR, PIPELINE, - "%s: port OUT ID %u is out of range\n", __func__, port_id); + PIPELINE_LOG(ERR, "port OUT ID %u is out of range", port_id); return -EINVAL; } @@ -1575,14 +1507,12 @@ int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id, int retval; if (p == NULL) { - RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", - __func__); + PIPELINE_LOG(ERR, "pipeline parameter NULL"); return -EINVAL; } if (table_id >= p->num_tables) { - RTE_LOG(ERR, PIPELINE, - "%s: table %u is out of range\n", __func__, table_id); + PIPELINE_LOG(ERR, "table %u is out of range\n", table_id); return -EINVAL; }