From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8D53541C34; Wed, 8 Feb 2023 00:07:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41FA642DA5; Wed, 8 Feb 2023 00:05:29 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 559C642D73 for ; Wed, 8 Feb 2023 00:05:23 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso377997pjj.1 for ; Tue, 07 Feb 2023 15:05:23 -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=Z+wmaSSoy8aaI5pi1EkqvTqOEEno0t2lQiUQebYpykc=; b=wKrsXw01rdYPOYG9is6pG9tBWw1Vfnoj4ZD5yZhqIMk4DuWi7v/oImcIFI12YKu1F3 ACUn6WsbtwttOk5KtDwWN9fo6PMi295rZ/5XDLDeb7GPFszR4U375M5yNWElAYhJLHhj e70kSYWGAfeWKs1CPXUZ3VXAGPC/NpzMjS6quMl0Jd4PC3YmG3ccSDY7zokN5+bb1B2x 6XZdylw2yGjM3aE1YsZDaGXa51VjJg77sDXyYsHHRXxlFnuNZJoa0LKqh4OXmcMXp1Dj P/K58EFW7C5SkMFyNOn5wRgDnyDvbaHzEpcP8nQcPC6y+QZYG43IQltqvxjHp8XWhe9R yG1w== 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=Z+wmaSSoy8aaI5pi1EkqvTqOEEno0t2lQiUQebYpykc=; b=t+fNtO04Sa7nsXKprC9dSuuYIKeNHo24l5HmY94EpDZustLgjyzbQcTF1YxcL5XsUy 8EDbh+BRw9qYb4Cp6uSqeSqKbWSfPFeJkBKOSf6VDcSyvUU6Fzoq94rm/pCxehJYfCoX 0qGZg5qVnaHTWl3TUa+YEXcfRVUg7wIuaOHoiJzRd/HlTJlLnJLc8zMgEKEQBprT7Eoh pi8Mr1vuLpKf3h7I2sisvbUmzG/neAAvK54uVYV7VmDyoKLfGONI8ZDVfh+yDAqXYgMX hhI35sV8/dFaAgCsyZNIYGwSp4MYr9CwioGwDu4EYx3HoXF84/wgkjD2KPJffgU41L+P 0++w== X-Gm-Message-State: AO0yUKWvKtnG3/0GkpmpeI3dDIrpk7fI/fBrMb06yLuVtAXKoYkgoux2 dwId0HA7m+E7YoHn+ESmvEf9CXOjPx9mLf0qZAA= X-Google-Smtp-Source: AK7set/VYNYbNuVuocpnlOnpkqPoDuA3VU0mN4lXf+2fMGZ7KoOoEGW4LKp+H3LDx86YQaT5LCikHQ== X-Received: by 2002:a17:90a:1906:b0:230:7a31:b9ac with SMTP id 6-20020a17090a190600b002307a31b9acmr6009363pjg.48.1675811121792; Tue, 07 Feb 2023 15:05:21 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED with dynamic type Date: Tue, 7 Feb 2023 15:04:37 -0800 Message-Id: <20230207230438.1617331-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 297 +++++++++++++------------------- lib/sched/rte_sched_log.h | 11 ++ 5 files changed, 140 insertions(+), 190 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..fd5bd38070fa 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,8 +915,7 @@ 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", + SCHED_LOG(ERR, "Port scheduler params check failed (%d)\n", __func__, 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", 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_SUFFIX(sched_logtype, "sched", 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) -- 2.39.1