From patchwork Fri Oct 18 10:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841547 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4BA21FF7C2 for ; Fri, 18 Oct 2024 10:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246836; cv=none; b=c4QSbCLPz1eSfd1AaZo2mpYAyaSlj1dLMQHxVyHF9+FnGtMRpsUqORFw4eHS0z8NRwk54bnCwC3+Xsk3wqwT21IMejAEZKcBGldHs093Iun8W9JBBeMDPHmZFMuiUczf9B5XiS7jp3sPiM5FNveFTeJdxjcjK7MUPXutDCfSj+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246836; c=relaxed/simple; bh=nbnliCsTZoCLLscuzndBbxa4315Oxu+nhDo0BWJN4jw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KDfRulVx+pNzxswR3k+JuyYK7GdvIGlOPmEC0sSCR1ft08aDbWqWNwrOrukdlixmmzWtJzDqf2aiKl33uChRnzO2W1c/IbuL6UH93NVHb2SG9o+n5w1yu+YfT3rbK+XxRkoTOjiM+3jtQFqqxX6tNoswEbRqlhr9P1fu7xmBvzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RnSmKr6a; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RnSmKr6a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246835; x=1760782835; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbnliCsTZoCLLscuzndBbxa4315Oxu+nhDo0BWJN4jw=; b=RnSmKr6aaU5V2IzhwVycsqUCmC3CoR++PP5SAEo1paF+kjtaGYK23ozW G6t9BnxNovhVCrwnSTWP7FJVewrBOjdE19LEk88dOHWGuviWIaOW8XfJU n9Ku3RRHiy+zIWPFZPUzqR1Efzj3Xg7tBF+c7eGtyIDVwKH7ZQyqerD4o bgj09rIFQdh81618AgD+q7kiO1l3VX9cmwdK1hRba2+Iju//Fn5iQrNh7 cRAO1d8zr1zB/40ijBSnqV36v90w8KECszo6kR4tOp5ZaWHObJ8W9VoN1 qU+po1NDgFwoIgY+Nd7LDtmJMLAbD+COMkXIqP+gM8X3oDMgLn9Xs296k Q==; X-CSE-ConnectionGUID: +cxWUju4SDKS0z1Vh6VhYw== X-CSE-MsgGUID: Y0Jrx7DnRLSLRALH5MymMA== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401219" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401219" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:34 -0700 X-CSE-ConnectionGUID: c/waX+aiSqW4h9PwldiKrA== X-CSE-MsgGUID: Z5bNS1BNRBCsD3Rj+PPtcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789303" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:32 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id A7D0C27BD1; Fri, 18 Oct 2024 11:20:30 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 1/7] devlink: introduce devlink_nl_put_u64() Date: Fri, 18 Oct 2024 12:18:30 +0200 Message-ID: <20241018102009.10124-2-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add devlink_nl_put_u64() that abstracts padding for u64 values. All u64 values are passed with the very same padding option. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- net/devlink/devl_internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index a9f064ab9ed9..14eaad9cfe35 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -181,6 +181,11 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink) return 0; } +static inline int devlink_nl_put_u64(struct sk_buff *msg, int attrtype, u64 val) +{ + return nla_put_u64_64bit(msg, attrtype, val, DEVLINK_ATTR_PAD); +} + int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net, struct devlink *devlink, int attrtype); int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info); From patchwork Fri Oct 18 10:18:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841548 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFD4020125C for ; Fri, 18 Oct 2024 10:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246837; cv=none; b=qfZdiz2wQZo/upKEyb9l3npNd8VgNnF8qo+hzGHS693EqO8OUSrQ1ilz+uo3Ub7oFe26DlGIyi0/RQla5wgeBhdXGJdNnYBhQQxrh1V/RBHKBxo0rIfFgAguMCQuDuhYxVb7EnJB1uo+27uniLCfRX9wWXDNESIsydXiXDN5+qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246837; c=relaxed/simple; bh=YwYgQITKimu8KB1x/DmCeal71HAcIrT4nSe8L03JW/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fJP243VqWpffLTw+Dbqvp0lgwnTUDwou70PRGBRXPZD6dA7SsQ/Ri1ijnBFdYTp+xQnnBEYAwBbp9M6QbI1e2V4khh1rWpyE90ny0xYVn7Zn5TYPcZh4QyhM5tDBl6bwhd87ocAGeZVMgYg6PsjbElLVuEmdfNXI7x3e4fNK+EE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FYmdeY7P; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FYmdeY7P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246836; x=1760782836; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YwYgQITKimu8KB1x/DmCeal71HAcIrT4nSe8L03JW/E=; b=FYmdeY7Ps+509RI+eK5Nl8Lja0z0qYBoq9zO9bCHWtE2F7EQ1sO2UL5d 0oPjEj1GPqv2zvvZzNO9CTDRqCJG+pwSbFewHQRgC5n0/RqssaYEgJ/yx A9TyZfmpm6BOIxxdclqmkkNJXgB4AN+6suqMSg/CPGCqjRgmxWxiew2hQ fInMOdWQA49pAyU24eBxCWe1Gevo0g7o5YYHkAvTcEgyaAsQY1Bwg7SGn RfzHsBjq7SkB7WtbYUHMSt5dXiVLA5cwrPJNu/XVZy+urDe2znOTWDvM2 Ig/4CLHNHMU1YA5eix9JW+rxCPp7cQH5w0iQnzaEzUQI6NfoaxKbKsJdg A==; X-CSE-ConnectionGUID: kV7v14M0SjCIAG4Q7bX+Lw== X-CSE-MsgGUID: LYI7WQSxTg6sH+qClFCLKQ== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401221" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401221" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:36 -0700 X-CSE-ConnectionGUID: Kh5e6qPYSU62rZ0EXFOaRQ== X-CSE-MsgGUID: ATNiBYvXSGquMoyHMBBJKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789312" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:33 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id EE24D27BD2; Fri, 18 Oct 2024 11:20:31 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 2/7] devlink: use devlink_nl_put_u64() helper Date: Fri, 18 Oct 2024 12:18:31 +0200 Message-ID: <20241018102009.10124-3-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use devlink_nl_put_u64() shortcut added by prev commit on all devlink/. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- net/devlink/dev.c | 12 ++++++------ net/devlink/dpipe.c | 18 ++++++++---------- net/devlink/health.c | 25 +++++++++++-------------- net/devlink/rate.c | 8 ++++---- net/devlink/region.c | 11 ++++------- net/devlink/resource.c | 27 ++++++++++++--------------- net/devlink/trap.c | 34 ++++++++++++++-------------------- 7 files changed, 59 insertions(+), 76 deletions(-) diff --git a/net/devlink/dev.c b/net/devlink/dev.c index 13c73f50da3d..9264bbc90d0c 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -971,14 +971,14 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg, nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, params->component)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE, - params->done, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE, + params->done)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL, - params->total, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL, + params->total)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, - params->timeout, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, + params->timeout)) goto nla_put_failure; out: diff --git a/net/devlink/dpipe.c b/net/devlink/dpipe.c index 55009b377447..e55701b007f0 100644 --- a/net/devlink/dpipe.c +++ b/net/devlink/dpipe.c @@ -165,18 +165,17 @@ static int devlink_dpipe_table_put(struct sk_buff *skb, return -EMSGSIZE; if (nla_put_string(skb, DEVLINK_ATTR_DPIPE_TABLE_NAME, table->name) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_SIZE, table_size, - DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(skb, DEVLINK_ATTR_DPIPE_TABLE_SIZE, table_size)) goto nla_put_failure; if (nla_put_u8(skb, DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, table->counters_enabled)) goto nla_put_failure; if (table->resource_valid) { - if (nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, - table->resource_id, DEVLINK_ATTR_PAD) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS, - table->resource_units, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, + table->resource_id) || + devlink_nl_put_u64(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS, + table->resource_units)) goto nla_put_failure; } if (devlink_dpipe_matches_put(table, skb)) @@ -403,12 +402,11 @@ static int devlink_dpipe_entry_put(struct sk_buff *skb, if (!entry_attr) return -EMSGSIZE; - if (nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_ENTRY_INDEX, entry->index, - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(skb, DEVLINK_ATTR_DPIPE_ENTRY_INDEX, entry->index)) goto nla_put_failure; if (entry->counter_valid) - if (nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, - entry->counter, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(skb, DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, + entry->counter)) goto nla_put_failure; matches_attr = nla_nest_start_noflag(skb, diff --git a/net/devlink/health.c b/net/devlink/health.c index acb8c0e174bb..b8d3084e6fe0 100644 --- a/net/devlink/health.c +++ b/net/devlink/health.c @@ -287,29 +287,27 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg, if (nla_put_u8(msg, DEVLINK_ATTR_HEALTH_REPORTER_STATE, reporter->health_state)) goto reporter_nest_cancel; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT, - reporter->error_count, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT, + reporter->error_count)) goto reporter_nest_cancel; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT, - reporter->recovery_count, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT, + reporter->recovery_count)) goto reporter_nest_cancel; if (reporter->ops->recover && - nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, - reporter->graceful_period, - DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(msg, DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, + reporter->graceful_period)) goto reporter_nest_cancel; if (reporter->ops->recover && nla_put_u8(msg, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER, reporter->auto_recover)) goto reporter_nest_cancel; if (reporter->dump_fmsg && - nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS, - jiffies_to_msecs(reporter->dump_ts), - DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS, + jiffies_to_msecs(reporter->dump_ts))) goto reporter_nest_cancel; if (reporter->dump_fmsg && - nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS, - reporter->dump_real_ts, DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS, + reporter->dump_real_ts)) goto reporter_nest_cancel; if (reporter->ops->dump && nla_put_u8(msg, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP, @@ -963,8 +961,7 @@ devlink_fmsg_item_fill_data(struct devlink_fmsg_item *msg, struct sk_buff *skb) case NLA_U32: return nla_put_u32(skb, attrtype, *(u32 *)msg->value); case NLA_U64: - return nla_put_u64_64bit(skb, attrtype, *(u64 *)msg->value, - DEVLINK_ATTR_PAD); + return devlink_nl_put_u64(skb, attrtype, *(u64 *)msg->value); case NLA_NUL_STRING: return nla_put_string(skb, attrtype, (char *)&msg->value); case NLA_BINARY: diff --git a/net/devlink/rate.c b/net/devlink/rate.c index 7139e67e93ae..8828ffaf6cbc 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -108,12 +108,12 @@ static int devlink_nl_rate_fill(struct sk_buff *msg, goto nla_put_failure; } - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_RATE_TX_SHARE, - devlink_rate->tx_share, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_RATE_TX_SHARE, + devlink_rate->tx_share)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_RATE_TX_MAX, - devlink_rate->tx_max, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_RATE_TX_MAX, + devlink_rate->tx_max)) goto nla_put_failure; if (nla_put_u32(msg, DEVLINK_ATTR_RATE_TX_PRIORITY, diff --git a/net/devlink/region.c b/net/devlink/region.c index 7319127c5913..0a75a2fbd4d7 100644 --- a/net/devlink/region.c +++ b/net/devlink/region.c @@ -145,9 +145,7 @@ static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink, if (err) goto nla_put_failure; - err = nla_put_u64_64bit(msg, DEVLINK_ATTR_REGION_SIZE, - region->size, - DEVLINK_ATTR_PAD); + err = devlink_nl_put_u64(msg, DEVLINK_ATTR_REGION_SIZE, region->size); if (err) goto nla_put_failure; @@ -210,8 +208,8 @@ devlink_nl_region_notify_build(struct devlink_region *region, if (err) goto out_cancel_msg; } else { - err = nla_put_u64_64bit(msg, DEVLINK_ATTR_REGION_SIZE, - region->size, DEVLINK_ATTR_PAD); + err = devlink_nl_put_u64(msg, DEVLINK_ATTR_REGION_SIZE, + region->size); if (err) goto out_cancel_msg; } @@ -773,8 +771,7 @@ static int devlink_nl_cmd_region_read_chunk_fill(struct sk_buff *msg, if (err) goto nla_put_failure; - err = nla_put_u64_64bit(msg, DEVLINK_ATTR_REGION_CHUNK_ADDR, addr, - DEVLINK_ATTR_PAD); + err = devlink_nl_put_u64(msg, DEVLINK_ATTR_REGION_CHUNK_ADDR, addr); if (err) goto nla_put_failure; diff --git a/net/devlink/resource.c b/net/devlink/resource.c index 594c8aeb3bfa..5ce05e94f484 100644 --- a/net/devlink/resource.c +++ b/net/devlink/resource.c @@ -141,12 +141,12 @@ devlink_resource_size_params_put(struct devlink_resource *resource, struct devlink_resource_size_params *size_params; size_params = &resource->size_params; - if (nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_GRAN, - size_params->size_granularity, DEVLINK_ATTR_PAD) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MAX, - size_params->size_max, DEVLINK_ATTR_PAD) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MIN, - size_params->size_min, DEVLINK_ATTR_PAD) || + if (devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE_GRAN, + size_params->size_granularity) || + devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE_MAX, + size_params->size_max) || + devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE_MIN, + size_params->size_min) || nla_put_u8(skb, DEVLINK_ATTR_RESOURCE_UNIT, size_params->unit)) return -EMSGSIZE; return 0; @@ -157,9 +157,8 @@ static int devlink_resource_occ_put(struct devlink_resource *resource, { if (!resource->occ_get) return 0; - return nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_OCC, - resource->occ_get(resource->occ_get_priv), - DEVLINK_ATTR_PAD); + return devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_OCC, + resource->occ_get(resource->occ_get_priv)); } static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb, @@ -174,14 +173,12 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb, return -EMSGSIZE; if (nla_put_string(skb, DEVLINK_ATTR_RESOURCE_NAME, resource->name) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE, resource->size, - DEVLINK_ATTR_PAD) || - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id, - DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE, resource->size) || + devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id)) goto nla_put_failure; if (resource->size != resource->size_new && - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, - resource->size_new, DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, + resource->size_new)) goto nla_put_failure; if (devlink_resource_occ_put(resource, skb)) goto nla_put_failure; diff --git a/net/devlink/trap.c b/net/devlink/trap.c index 5d18c7424df1..f36087f90db5 100644 --- a/net/devlink/trap.c +++ b/net/devlink/trap.c @@ -189,14 +189,12 @@ devlink_trap_group_stats_put(struct sk_buff *msg, if (!attr) return -EMSGSIZE; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_PACKETS, - u64_stats_read(&stats.rx_packets), - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_PACKETS, + u64_stats_read(&stats.rx_packets))) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_BYTES, - u64_stats_read(&stats.rx_bytes), - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_BYTES, + u64_stats_read(&stats.rx_bytes))) goto nla_put_failure; nla_nest_end(msg, attr); @@ -231,18 +229,15 @@ static int devlink_trap_stats_put(struct sk_buff *msg, struct devlink *devlink, return -EMSGSIZE; if (devlink->ops->trap_drop_counter_get && - nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_DROPPED, drops, - DEVLINK_ATTR_PAD)) + devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_DROPPED, drops)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_PACKETS, - u64_stats_read(&stats.rx_packets), - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_PACKETS, + u64_stats_read(&stats.rx_packets))) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_BYTES, - u64_stats_read(&stats.rx_bytes), - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_BYTES, + u64_stats_read(&stats.rx_bytes))) goto nla_put_failure; nla_nest_end(msg, attr); @@ -750,8 +745,7 @@ devlink_trap_policer_stats_put(struct sk_buff *msg, struct devlink *devlink, if (!attr) return -EMSGSIZE; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_STATS_RX_DROPPED, drops, - DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_STATS_RX_DROPPED, drops)) goto nla_put_failure; nla_nest_end(msg, attr); @@ -783,12 +777,12 @@ devlink_nl_trap_policer_fill(struct sk_buff *msg, struct devlink *devlink, policer_item->policer->id)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_TRAP_POLICER_RATE, - policer_item->rate, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_TRAP_POLICER_RATE, + policer_item->rate)) goto nla_put_failure; - if (nla_put_u64_64bit(msg, DEVLINK_ATTR_TRAP_POLICER_BURST, - policer_item->burst, DEVLINK_ATTR_PAD)) + if (devlink_nl_put_u64(msg, DEVLINK_ATTR_TRAP_POLICER_BURST, + policer_item->burst)) goto nla_put_failure; err = devlink_trap_policer_stats_put(msg, devlink, From patchwork Fri Oct 18 10:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841551 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8F8F202F70 for ; Fri, 18 Oct 2024 10:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246839; cv=none; b=VzbsC/oQWFLMlZBhSMPIfrZv+Eje3YsJ0ybQSR5VDE+bLGt5njtASzxfg9fc4IlPkp70EEZcZjX6ZpTUtRsboaLqITl3qLxyes9Riozu6bmAPUREoKZAEJGvsMntwx0iluwNB8c44RqmL0UJr3fBqbQj5n1PfHUhno7r+CNS6es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246839; c=relaxed/simple; bh=nMPjOOSaoGe4vadY3FHtlMl/7Cuyeh9Dg4UPbcKc/C8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BdzpdGrY9Fdh9t/tAfSssD5TnDkjIqbJXbAevaKMVrxQvEPh48x6gtce1HnXlObwScnvhSIZj4G7lQqzwKbKjOJMs64B1gLILh1hOi+UooOdmFX+eVWOclTP7TkBtNOO0ATOWHR3Pe3zSRrvbUrCHuJGjJjG7cTfhfL7TtcphUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AihPVWLu; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AihPVWLu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246838; x=1760782838; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nMPjOOSaoGe4vadY3FHtlMl/7Cuyeh9Dg4UPbcKc/C8=; b=AihPVWLuYf2VrUB3bhYpOYmxp1cv0rr3/ewfxo/4911rr8zAJaS0MaAV 377mNcs9mRrp/R0kf8935cBW22oAsGmlOG8KtWoQE6chok8C5kzQMt1Bh gmXBJIFLr12QjY0CVUYd7RvTtvf8/EpvE3yr/EC0WqlrO0wxQJW96VpnK VLV1VSRFw6OOTKmQUBtZ3iuBYk7cl8NwSnmmUIdU+wnrUFGUdzsrlMA78 mwpv+DJ/EJ6ZKVnd/E8p7uZKCmRMecviPPgoEFNCiWx4OExAhR+ByNvMf dTAKRPioxJAuMkRj6p6F41m2M3LC+4yMsuLZqFrnsAnPxK962EfGsqJdp Q==; X-CSE-ConnectionGUID: 2gz3KAUWRLqf0bMq95wpFQ== X-CSE-MsgGUID: EHtarxAHRIaMk93pZwqeWA== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401228" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401228" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:37 -0700 X-CSE-ConnectionGUID: qN45RSLsQiiM1y++k6Ttjw== X-CSE-MsgGUID: ZhQ6RkgmSlyP6F+WdPNaGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789317" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:35 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 0A1C627BCC; Fri, 18 Oct 2024 11:20:32 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 3/7] devlink: devl_resource_register(): differentiate error codes Date: Fri, 18 Oct 2024 12:18:32 +0200 Message-ID: <20241018102009.10124-4-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Differentiate error codes of devl_resource_register(). Replace one of -EINVAL exit paths by -EEXIST. This should aid developers introducing new resources and registering them in the wrong order. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- net/devlink/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/devlink/resource.c b/net/devlink/resource.c index 5ce05e94f484..96c0ff24b65a 100644 --- a/net/devlink/resource.c +++ b/net/devlink/resource.c @@ -345,7 +345,7 @@ int devl_resource_register(struct devlink *devlink, resource = devlink_resource_find(devlink, NULL, resource_id); if (resource) - return -EINVAL; + return -EEXIST; resource = kzalloc(sizeof(*resource), GFP_KERNEL); if (!resource) From patchwork Fri Oct 18 10:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841549 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B60C202F67 for ; Fri, 18 Oct 2024 10:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246838; cv=none; b=TbvQWYQhZ3ErM8/STMOmIY3UHeAwZs8GGqqs+ocB7I8yQ3J/nXfA5z6z3a7frHRq5/tOs0kWT9/EpIGe9hwMEIByjBvJ4B+oTdxJTQYAnj/hwXUQ9YIXu8Wg89rEcT+prCxDgyoZKen23N41UQtHvoQnEWHeOEN732+2wX6G+U4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246838; c=relaxed/simple; bh=ZW2EzSJRokQnLPyaY8mGK9xmsLMUL0YssPT38U8/Cas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DtV9XLLjBVe5mWZm4pzUN1h8656BifJ9TJCqw7/88mCJhag1Us/ESjsfq2U2JPJ/fy9c1sLYnmPKWaI+HI1nDtyNzFmotMOCiTsf+MBXv9blEL8sZaXGLZLQ77esTMvITKTBP8J2iV8WC/0Z+4nj/HHD3iXR/B1wzHSnsylt+bY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Xkd5T+Lj; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Xkd5T+Lj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246837; x=1760782837; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZW2EzSJRokQnLPyaY8mGK9xmsLMUL0YssPT38U8/Cas=; b=Xkd5T+LjUDwEaTWPOgPxLnDQ1FTDe8TIEVurGVQRHwE1POX9PqRnnQl/ WUbDC1GtP+FyGvYMnhLU5n5OKoX20fpRZBACK5ZjYPiPCdHK6RFgSKT3E UtmY4BDuyFeq+OrAl0dHjIlHk46t/RpcUpA7aUdBO4C8UlFN3kLhCHA4D IBY0TLH5Ec5SfFCGr1x2JeK9XhkTTQ0EQeEWrfb5x8qzjG1gFQHZ1yR8P q764/P3gLVdYE8b9erunWDf5xAFXZVb2sAhm+CM1Ve/g7Jy93l59KpekT C8ysjZi8qMs29zd/9OVRwRULvQ8iYlrzYmhKJ2DJIo+QMER3gN1rx1QZx Q==; X-CSE-ConnectionGUID: sHRavfCqR8aZoaszyI524g== X-CSE-MsgGUID: yBPO0b4JQeaaG2jlQ2bO8w== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401227" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401227" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:37 -0700 X-CSE-ConnectionGUID: ZafXf2ETTeqAE4EfIP8CRA== X-CSE-MsgGUID: chSulOJcQpmR9PUxGwbCDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789315" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:35 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 0259E28169; Fri, 18 Oct 2024 11:20:33 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 4/7] devlink: region: snapshot IDs: consolidate error values Date: Fri, 18 Oct 2024 12:18:33 +0200 Message-ID: <20241018102009.10124-5-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Consolidate error codes for too big message size. Current code is written to return -EINVAL when tailroom in the skb msg would be exhausted precisely when it's time to nest, and return -EMSGSIZE in all other "not enough space" conditions. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- net/devlink/region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/devlink/region.c b/net/devlink/region.c index 0a75a2fbd4d7..63fb297f6d67 100644 --- a/net/devlink/region.c +++ b/net/devlink/region.c @@ -77,7 +77,7 @@ static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg, snap_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_REGION_SNAPSHOT); if (!snap_attr) - return -EINVAL; + return -EMSGSIZE; err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id); if (err) @@ -102,7 +102,7 @@ static int devlink_nl_region_snapshots_id_put(struct sk_buff *msg, snapshots_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_REGION_SNAPSHOTS); if (!snapshots_attr) - return -EINVAL; + return -EMSGSIZE; list_for_each_entry(snapshot, ®ion->snapshot_list, list) { err = devlink_nl_region_snapshot_id_put(msg, devlink, snapshot); From patchwork Fri Oct 18 10:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841550 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 068C1202F72 for ; Fri, 18 Oct 2024 10:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246839; cv=none; b=k5w6NZmcnc8YO8tHiLA97bblMgdJrVJAeOLF823q6fUvjPlNsc0IuVZTkLFQznFZVxF13Z8WJKU5uTlOISKZiLpgmWi4IkvnaBoSoWfYG5pL0CCrJNMW52btxMkl/8hPtf7rdjDFlcAuIKWmlyn0k8X+U5QIaZjemjjbA9qo0/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246839; c=relaxed/simple; bh=4DXTv1CJFQk1suv7J7d/Rlhy6YGYnvNDamBfwpq0f3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nwCNjA3RpK/7jKpvUS36teaBCNThBkr9ol1kw+QQX91pD4qMCyilfY7TQKVcecTvXmM6HYbH8DnVcDJ6NeOL63qO4u5Dn0lQ3HfSAPstgh2BUQNLgpikVNuRptPgp7mCZ9FZS3MxqH6W0Ooai6pjXc9KfrbCwyW+GBFtlv4hhu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OFpA+nX1; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OFpA+nX1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246838; x=1760782838; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4DXTv1CJFQk1suv7J7d/Rlhy6YGYnvNDamBfwpq0f3Y=; b=OFpA+nX1ouX5Yc/atqjI9BupLBdPEmO7fEvIYak/gLaPZC90z9VWHHSJ uIibKwBvwH+LlgWhTMOfhGNBNPucAgecEJvl07aar38Phnc/HRiukhf49 hQQ1m9ZPlpjvZoAgWoEhe3fliWrxeBS/CDCkGriEwZ1KKcG4gqQSbqmho HQgQSgyHZ5sb5cBh9nk2W0HABbYWMjU6o8/o3e8cJ7LgQuuTBJh8u6EAQ QLsdt6U2RLU5Xh/WfUmnQQIercza0SKJ4yrWxoR/rZgB7BICfHkeV/+Ie KJGOWagR/NeVooumMZ4/5LmsX0BigM/c0rtfDTNTi/y1spCOkgY+71kiQ w==; X-CSE-ConnectionGUID: h+c4utkpQw2KQeW82t41IA== X-CSE-MsgGUID: r2GP01pgRc20OmwVSLNEXg== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401230" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401230" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:38 -0700 X-CSE-ConnectionGUID: u5ZmbGYuRuelYCIXQwP9Gw== X-CSE-MsgGUID: GRXcktseS5CDazj/KWcDNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789320" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:36 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id E36112816E; Fri, 18 Oct 2024 11:20:34 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 5/7] net: dsa: replace devlink resource registration calls by devl_ variants Date: Fri, 18 Oct 2024 12:18:34 +0200 Message-ID: <20241018102009.10124-6-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace devlink_resource_register(), devlink_resource_occ_get_register(), and devlink_resource_occ_get_unregister() calls by respective devl_* variants. Mentioned functions have no direct users in any drivers, and are going to be removed in subsequent patches. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- net/dsa/devlink.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/net/dsa/devlink.c b/net/dsa/devlink.c index 0aac887d0098..f41f9fc2194e 100644 --- a/net/dsa/devlink.c +++ b/net/dsa/devlink.c @@ -229,10 +229,15 @@ int dsa_devlink_resource_register(struct dsa_switch *ds, u64 parent_resource_id, const struct devlink_resource_size_params *size_params) { - return devlink_resource_register(ds->devlink, resource_name, - resource_size, resource_id, - parent_resource_id, - size_params); + int ret; + + devl_lock(ds->devlink); + ret = devl_resource_register(ds->devlink, resource_name, resource_size, + resource_id, parent_resource_id, + size_params); + devl_unlock(ds->devlink); + + return ret; } EXPORT_SYMBOL_GPL(dsa_devlink_resource_register); @@ -247,15 +252,19 @@ void dsa_devlink_resource_occ_get_register(struct dsa_switch *ds, devlink_resource_occ_get_t *occ_get, void *occ_get_priv) { - return devlink_resource_occ_get_register(ds->devlink, resource_id, - occ_get, occ_get_priv); + devl_lock(ds->devlink); + devl_resource_occ_get_register(ds->devlink, resource_id, occ_get, + occ_get_priv); + devl_unlock(ds->devlink); } EXPORT_SYMBOL_GPL(dsa_devlink_resource_occ_get_register); void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds, u64 resource_id) { - devlink_resource_occ_get_unregister(ds->devlink, resource_id); + devl_lock(ds->devlink); + devl_resource_occ_get_unregister(ds->devlink, resource_id); + devl_unlock(ds->devlink); } EXPORT_SYMBOL_GPL(dsa_devlink_resource_occ_get_unregister); From patchwork Fri Oct 18 10:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841552 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C724202F82 for ; Fri, 18 Oct 2024 10:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246841; cv=none; b=he4eItwjRJglDEjrKMwx9ySidfXxutzurB2wGK8Jkl+a1nkyG6/zlS105fO4Tas3YCnfjhPsZZLL/2IFd07vKRdaT6DRoldXg7foIvfMhXl9zoq/3GXAywO0C53ktfRipHuSeANRGLaWrhKT18YZlfw7pzcKQ3EdFpgXiakQ460= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246841; c=relaxed/simple; bh=toIiZ4XBO93qQfD79LNoPMfRAYeyGyVEuXHBg/5+yYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NRHfdNTw0yqfNAGu3h4PBvRU5oftzZE/b26Hd2cfdPiCS28LxcESfuiDWA/dWrFwbRH7izMKe8jhbx8XtJf3tXrdzgg7SqHzu6ApERm9Ly0TDYmkFlghcyftrBMo+vfKFPao9hmrT1+6/gsjcpV4THmHJHNwRFRbe5rpFGFi+Xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CjpYeC9C; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CjpYeC9C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246839; x=1760782839; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=toIiZ4XBO93qQfD79LNoPMfRAYeyGyVEuXHBg/5+yYA=; b=CjpYeC9CdzUyKOkz2Ab1feFjKFApxw7mOpZVvbX7zhN2bG3DysxuAuZo zBKNral1ONwPbsVGSYvIrHxJ3SeIf1xeT394wclcN1riVyaJHKxwhm4ZS 9d9TKzpglhcTHNVgywqgAO4ZJhFMYnXkCo93t51jnsmfaI9A8bZyFTxt5 PeEtUAOIX8P2HJ11qwpd/BQAuZH5NmfG977u4xp/JfBFr+spixo+ysqQv rL9VxTaXjKwC9x2nNrycON7/zo5MtTwKtXCm015ZVp5r5bCN/CGvX0yg2 RS8cA17PRTeBkYEvznc+C2ZoTrDYYJkM0nBNH2+r69vtnxxJBnAUwxjGK g==; X-CSE-ConnectionGUID: WmWmdC5+TQOc8RiV9n/GUw== X-CSE-MsgGUID: LGetxB/dTJWlOmkreEIF5w== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401231" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401231" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:39 -0700 X-CSE-ConnectionGUID: 7boX34nuTX61niSKtOrzIw== X-CSE-MsgGUID: IQ9trskNQY+7MIbyEVj+og== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789335" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:37 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id DD14D28195; Fri, 18 Oct 2024 11:20:35 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 6/7] devlink: remove unused devlink_resource_occ_get_register() and _unregister() Date: Fri, 18 Oct 2024 12:18:35 +0200 Message-ID: <20241018102009.10124-7-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Remove not used devlink_resource_occ_get_register() and devlink_resource_occ_get_unregister() functions; current devlink resource users are fine with devl_ variants of the two. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- include/net/devlink.h | 7 ------- net/devlink/resource.c | 39 --------------------------------------- 2 files changed, 46 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index db5eff6cb60f..fdd6a0f9891d 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1797,15 +1797,8 @@ void devl_resource_occ_get_register(struct devlink *devlink, u64 resource_id, devlink_resource_occ_get_t *occ_get, void *occ_get_priv); -void devlink_resource_occ_get_register(struct devlink *devlink, - u64 resource_id, - devlink_resource_occ_get_t *occ_get, - void *occ_get_priv); void devl_resource_occ_get_unregister(struct devlink *devlink, u64 resource_id); - -void devlink_resource_occ_get_unregister(struct devlink *devlink, - u64 resource_id); int devl_params_register(struct devlink *devlink, const struct devlink_param *params, size_t params_count); diff --git a/net/devlink/resource.c b/net/devlink/resource.c index 96c0ff24b65a..a923222bbde8 100644 --- a/net/devlink/resource.c +++ b/net/devlink/resource.c @@ -513,28 +513,6 @@ void devl_resource_occ_get_register(struct devlink *devlink, } EXPORT_SYMBOL_GPL(devl_resource_occ_get_register); -/** - * devlink_resource_occ_get_register - register occupancy getter - * - * @devlink: devlink - * @resource_id: resource id - * @occ_get: occupancy getter callback - * @occ_get_priv: occupancy getter callback priv - * - * Context: Takes and release devlink->lock . - */ -void devlink_resource_occ_get_register(struct devlink *devlink, - u64 resource_id, - devlink_resource_occ_get_t *occ_get, - void *occ_get_priv) -{ - devl_lock(devlink); - devl_resource_occ_get_register(devlink, resource_id, - occ_get, occ_get_priv); - devl_unlock(devlink); -} -EXPORT_SYMBOL_GPL(devlink_resource_occ_get_register); - /** * devl_resource_occ_get_unregister - unregister occupancy getter * @@ -557,20 +535,3 @@ void devl_resource_occ_get_unregister(struct devlink *devlink, resource->occ_get_priv = NULL; } EXPORT_SYMBOL_GPL(devl_resource_occ_get_unregister); - -/** - * devlink_resource_occ_get_unregister - unregister occupancy getter - * - * @devlink: devlink - * @resource_id: resource id - * - * Context: Takes and release devlink->lock . - */ -void devlink_resource_occ_get_unregister(struct devlink *devlink, - u64 resource_id) -{ - devl_lock(devlink); - devl_resource_occ_get_unregister(devlink, resource_id); - devl_unlock(devlink); -} -EXPORT_SYMBOL_GPL(devlink_resource_occ_get_unregister); From patchwork Fri Oct 18 10:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13841553 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A41D0202F8F for ; Fri, 18 Oct 2024 10:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246844; cv=none; b=CCF4WFmrbb6gKy06MPMb658ScpJNB5xT8Wu+yoIH6CLf7OKi4BjWUn14oTTJZkOrQyDfOHSR/79D+g8fdWBIWJZtB9fa7ig7i/w5W/oOlWcSjQj4YrADcOaiRJoPv1uzbeh4bg1+ZHxJxU6CfUa8htWvqJWhGTjoSOOp/C9rRSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729246844; c=relaxed/simple; bh=vJPsK944NJrtOQB0n80EHOxwLO+0L4GwTXAhQOqbP/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cDnEgB92mEq7qJF00YjKm6zwXRROefvcdy5zgGcP9PGPbincxyUpnfMsGmr/eCiGo3GwckN8VS+IgZf+UldvhG2vkcC2E3tm07EeHSbAryDrIfJoDZ/zXJt8ZCuBwMsPe9GhyLcxNXe8yVK/96SzZC8Xu2uDv/tbsDiVFsEsQrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ea1Rmby6; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ea1Rmby6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729246840; x=1760782840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vJPsK944NJrtOQB0n80EHOxwLO+0L4GwTXAhQOqbP/4=; b=Ea1Rmby6XMot5FUWDma3lZLi9+KgaEWb4phGx2xuEnr2UT1mLlLVmYMS ZkBw8FjsBYHeIqDEivapaZ6oweOkAhtX+44RNXrBHnyzt3Qf/I+gBULIP TkuK6PyO5tQXA/Psf2d6dHLNdQZimjf779uOX76/syKA1ix8nqIFl4+0n vX7K9fy1nSCFWcdBoizwCj96hU1FdkEfZQTmGqLe7GzJB9FgDwYTOJZEg JxxdJFuhjP9+33alp+bSRgYQL4Hkj1TcpwvHDZW1OZgYI5VNhLq5LGCLl MkPkJBhTnAe7uvR+JbksHHuiJyyNYSbnNslf3F/B4uk9FJvZT6pklnUz2 w==; X-CSE-ConnectionGUID: /tmkOKTpR1WQhQYLZDPCyg== X-CSE-MsgGUID: b+45W5tNQSeSIuEHVQDtKQ== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="39401233" X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="39401233" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 03:20:39 -0700 X-CSE-ConnectionGUID: 5xC6vYotTpKMrkCiaKCTMg== X-CSE-MsgGUID: 7LgbhV1OQrm47bCQF1hFLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,213,1725346800"; d="scan'208";a="78789341" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa010.jf.intel.com with ESMTP; 18 Oct 2024 03:20:38 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.186]) by irvmail002.ir.intel.com (Postfix) with ESMTP id D6B2D28196; Fri, 18 Oct 2024 11:20:36 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Przemek Kitszel , Wojciech Drewek Subject: [PATCH v1 7/7] devlink: remove unused devlink_resource_register() Date: Fri, 18 Oct 2024 12:18:36 +0200 Message-ID: <20241018102009.10124-8-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> References: <20241018102009.10124-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Remove unused devlink_resource_register(); all the drivers use devl_resource_register() variant instead. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel --- include/net/devlink.h | 6 ------ net/devlink/resource.c | 33 --------------------------------- 2 files changed, 39 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index fdd6a0f9891d..fbb9a2668e24 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1779,12 +1779,6 @@ int devl_resource_register(struct devlink *devlink, u64 resource_id, u64 parent_resource_id, const struct devlink_resource_size_params *size_params); -int devlink_resource_register(struct devlink *devlink, - const char *resource_name, - u64 resource_size, - u64 resource_id, - u64 parent_resource_id, - const struct devlink_resource_size_params *size_params); void devl_resources_unregister(struct devlink *devlink); void devlink_resources_unregister(struct devlink *devlink); int devl_resource_size_get(struct devlink *devlink, diff --git a/net/devlink/resource.c b/net/devlink/resource.c index a923222bbde8..2d6324f3d91f 100644 --- a/net/devlink/resource.c +++ b/net/devlink/resource.c @@ -381,39 +381,6 @@ int devl_resource_register(struct devlink *devlink, } EXPORT_SYMBOL_GPL(devl_resource_register); -/** - * devlink_resource_register - devlink resource register - * - * @devlink: devlink - * @resource_name: resource's name - * @resource_size: resource's size - * @resource_id: resource's id - * @parent_resource_id: resource's parent id - * @size_params: size parameters - * - * Generic resources should reuse the same names across drivers. - * Please see the generic resources list at: - * Documentation/networking/devlink/devlink-resource.rst - * - * Context: Takes and release devlink->lock . - */ -int devlink_resource_register(struct devlink *devlink, - const char *resource_name, - u64 resource_size, - u64 resource_id, - u64 parent_resource_id, - const struct devlink_resource_size_params *size_params) -{ - int err; - - devl_lock(devlink); - err = devl_resource_register(devlink, resource_name, resource_size, - resource_id, parent_resource_id, size_params); - devl_unlock(devlink); - return err; -} -EXPORT_SYMBOL_GPL(devlink_resource_register); - static void devlink_resource_unregister(struct devlink *devlink, struct devlink_resource *resource) {