From patchwork Wed Oct 23 13:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847055 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 23B311B4F15; Wed, 23 Oct 2024 13:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689210; cv=none; b=LLmb0ITVC2SK708omfNo5oMSEFdMehvZHoTcjAw8WZQYzQWRecP5klmEx8RQXZqTC5dGDuyYkF4914gUexEyd3JTGy6bm7ZYTUso/O80IzU2VIbMe02zUG2CEqYnNIlriWvVRmztvMMWPOdEQkeEl/TUaaxGTXCM+K1yauQA+3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689210; c=relaxed/simple; bh=7EmwuiM3f/QMecNc5zEFCtkKNTUIFtSE0tIsB2pTxRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WtsopKEqsMisOpzSC6ui/X6/OIcW9/LoD3dHKaDbQUmps4d8h+OVDzYbIwPGMvTzFPaifw2eR9iFZMiAseRq7D3Paett7YEN1AzvJiWPkxGf5bS91NM8gzZdpCv4WBrqGv1s4Eq+4UIiLY6fCz23oAzwlgTztWCnBc3PuczccoM= 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=OYZNZtIq; arc=none smtp.client-ip=192.198.163.8 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="OYZNZtIq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689209; x=1761225209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7EmwuiM3f/QMecNc5zEFCtkKNTUIFtSE0tIsB2pTxRs=; b=OYZNZtIqpri7ZC7+ziy287rMjYaH838Exss/JKV611debX/ppLbjKlIn 6ZIGnxFa5H77T2KUHS7g6kTZbcYVE9oxTv4xbI33WQRnxFFMnmJBpajBe RPYO7jvV73RfsI/3ziyQ4QqvxkbvdeRmn0k3llSEAm7XHsKqAPIWghdmt jxTXQxoBbK6fApuE5NOTxwgdrlOh+bzE126ORwCPCOoTUL40/pOR5miU2 T4HIBw8/5a+IoywLehWgoC6kn+55jg7/X/LpTIFwch1dKWnHqE52o0fVe Fo20H2Xb3xyABh994KFs3OS0Wh7xvYgZNvoohDJ8r2D03/JdqKnILhqH9 g==; X-CSE-ConnectionGUID: gETGohGAQcaBrLgXjJsj7g== X-CSE-MsgGUID: 9Cim0ptjRv6dq8OaMe2OdQ== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758548" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758548" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:26 -0700 X-CSE-ConnectionGUID: +XL2ZYzpSJe8sV3NvOlogA== X-CSE-MsgGUID: FtFcw6sVSA6JbzXd52HDxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820106" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:23 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 765D92877D; Wed, 23 Oct 2024 14:13:20 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 1/7] devlink: introduce devlink_nl_put_u64() Date: Wed, 23 Oct 2024 15:09:01 +0200 Message-ID: <20241023131248.27192-2-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847056 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 35B691B4F1C; Wed, 23 Oct 2024 13:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689211; cv=none; b=np6YuH/9gX4IwfT+YETXrknqCiqjGVvv811lydcsDXJW+S3ogPVHLcjshBG4yXQTbHBRwmf39FYLZTbfQmNEyr0zuD8zKEqL9ZWxSB2tky+K2LyEzD6bN7KSqhgH5jyupBTiI29xi/YHdwzX/sWLdMBXMt5zPCrg6hmI7v2guBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689211; c=relaxed/simple; bh=+ENG1Q6se/g95ObfM9cT829ggwKpeIy8owXEPD5w9Xg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u0SE8YHTzrAoqB2LyhGC1k88FpCuYrGiRmJadnQd0ElCxxl/nIBAaQwpL/O10YsRmqgjgpIq7dIPAs435WsLKAIEmoF0O5ZQUCfmlkWSuQx8Z+HSXoaptxL9bergdR8uOsHxatKDFGp+Q42ZZ3l8RU3X6GNWNhrnS4imLsLC2RY= 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=LuN5cwH0; arc=none smtp.client-ip=192.198.163.8 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="LuN5cwH0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689209; x=1761225209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+ENG1Q6se/g95ObfM9cT829ggwKpeIy8owXEPD5w9Xg=; b=LuN5cwH0R4Z7SRyzvn03BNMC422349+zPjNKu0rPcXPNK+veycEA1JJ0 CIfdmiYD9+bGqGrQqGDRr+FRzrBpeFNuHEUHSZUy141Ne7HsV8NUqUWaJ xtXMVh88IAqOhxn6lzZSStdqUooSm8m3HCXqGAgFudj5lJesk5Q45M9wz qIaoTXf/28qx7C5ddAwV9Vb8MH0srVfX8/2aZKt+IxYvRLU6G5ExoUMTe mAzzv0Q8NLtH6/UJZoGT5nvvrcRw5y/eZCVnOGQV9d5oc4Phk6XBxAALY mPC5nZqlHZ32NNy3j0iQCFypBQpQbKWWlaYlmMP4cTTBkZNYFTHQFOd9B w==; X-CSE-ConnectionGUID: e8PWWLHUQAK0fMVX39ol5w== X-CSE-MsgGUID: cjg7tyobS/Og8HZFhqoXjg== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758560" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758560" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:29 -0700 X-CSE-ConnectionGUID: tmx1yQ3uTjCy7gsibVdRGQ== X-CSE-MsgGUID: NuubCLdNQ0yzEHtfCZUyqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820113" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:25 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 7B25C2877E; Wed, 23 Oct 2024 14:13:22 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 2/7] devlink: use devlink_nl_put_u64() helper Date: Wed, 23 Oct 2024 15:09:02 +0200 Message-ID: <20241023131248.27192-3-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847057 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 DAF6F1B4F32; Wed, 23 Oct 2024 13:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689212; cv=none; b=r1BDe2Mrm5QKdF39F9U0pVbzQVjlkjs/qeyBqXvUfIl3RPyp2o/6p8faHQVmxSMegXWcMB3utHjJgtFLlYhb67D348x/e0rss2foun8ivWrHQAwDuAqDzfrlc7MiKdtvCIXVhlvMt5NCkuviIL0SBIxjrybVSm1vg5buftqyKiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689212; c=relaxed/simple; bh=KGwSHGv8HieFGzkcSZoeMcMWGvtOAqrT72PXLT1HkhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hZN/e72+kkGBbGINdlfdN1PfmItYMyAa8/CBcwnGmar409ulKT1atziu1bLZeGOQoQkcJ62jZwTNKesbwMEVx9Aea4zKlyCzdZSTZg8e6zaMWzKGSeMOl2SI9hJJipNT9dQRABhz88zqzkjBSarSPFmX+3MqeQNdtCZJfmmYcXk= 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=m5oHv4jx; arc=none smtp.client-ip=192.198.163.8 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="m5oHv4jx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689211; x=1761225211; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KGwSHGv8HieFGzkcSZoeMcMWGvtOAqrT72PXLT1HkhY=; b=m5oHv4jxJ/RWa7aJjQbUIFXfZadiffjNjs1zcOZdVuWPNYDuLryjdBmU uQPEgtGrTpJqfU21D/IGWl8v4UIAmuH9DK8wXAF6WSZXsC7ATBh7I/tbR yOxv14q9wFyo8HaQUh9zwVU5t73DvktsnDHYtTK5KX3KpPz99Kv1TOe6Q ELf+byznzVcMahQQ6TP1KksnBrbwamqQqb/V7MoaEBonxH7/pZGTSMJVl OJlDrFEgKLCA6F/CbNFIYkNKzI432uIHmtTAkCWa1udsFj68f7xR/o6nj x7oyz/tVfNYWV618VixktEjIaQEBV6p4dN/2EEbhkphx//CRU6eL1oF6h g==; X-CSE-ConnectionGUID: 7CriG2/tRUW8nE66o3BpgA== X-CSE-MsgGUID: XGfZxaywRNCYg6EgdVEJ4A== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758571" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758571" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:30 -0700 X-CSE-ConnectionGUID: syDjI5m5RKCnpDCP8tXtGg== X-CSE-MsgGUID: E5BDJ9oJQvuF4PfIa0MSvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820116" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:27 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 998292877A; Wed, 23 Oct 2024 14:13:24 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 3/7] devlink: devl_resource_register(): differentiate error codes Date: Wed, 23 Oct 2024 15:09:03 +0200 Message-ID: <20241023131248.27192-4-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847058 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 DE0B31BD004; Wed, 23 Oct 2024 13:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689214; cv=none; b=gUajNyTh9a/BpAHjnpvApx862fbzy0EOelgEIUt0VpEKXK+SKiC8SkhyrjDic6j53Oq2BUZmh/v4JbIopgMqdG0CWFYySpvKxDTnPp75KhHt2+WiJBhKwvAJj7/2t63Vouhp+csnyZk9VGU+oKz2G/XOdee0zNhbzTxHpL2QsdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689214; c=relaxed/simple; bh=unRzvrZVN7bDLtZgI9ZhS6/GXEaHrzbC4SBPnYwEXx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EEu0rb39SKeZRqmhDkRY65PqDj4iT3GS7HcrWUcwsWg8bEuJoFyQr1DpcKO6GlzQXojavHuA0FJYSAmSzrk2/YlyjmcV1mj2m8QOeYqMoPzEvb3L+hH+c/4b/G22waeUWAuJHBoFd7a+LUEXvuoubIgTbj5UfdJv/+M3yvxMFQM= 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=bkghVTV8; arc=none smtp.client-ip=192.198.163.8 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="bkghVTV8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689213; x=1761225213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=unRzvrZVN7bDLtZgI9ZhS6/GXEaHrzbC4SBPnYwEXx4=; b=bkghVTV8RakkAQdOTuWfGlQVD2GV1PW/P4suowYQRGJ485Jy0AYYBkqD NiBFfNjfe6+ClIw+eNPdAhcNbSpfKL2/avdl8Ui+Gvljnn+Svez2Enjw7 gIgILqZSkDQgC6ghvq0nHWIUkION64jeritXntxlmN5XtlHK8U80U9lcx JRRSo+LfSl8pac1uzCKjLS1/uWKzQa+5RROBhvNpi/59DY//XTwJUY3gx OJBB2twP94MCrFViv5T5Y6qEXYG/XR8zItw1cGw4vs2NsIfnbAc+pUxZ+ WV8JkQnWGz4Btig8+TUE+/sUTwSMlAelmag0ZpayL1z+1Ue5rpGLGsi+N Q==; X-CSE-ConnectionGUID: RnD+v+yyT2a6wIN6Rzav0w== X-CSE-MsgGUID: ZeFcjIg4SXithTpmSWaWaA== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758583" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758583" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:32 -0700 X-CSE-ConnectionGUID: +HMFn9NdRLiv9YYZShutOg== X-CSE-MsgGUID: fWg2WaUtSbuNLBo3+yFOgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820121" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:29 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 9883A2877D; Wed, 23 Oct 2024 14:13:26 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 4/7] devlink: region: snapshot IDs: consolidate error values Date: Wed, 23 Oct 2024 15:09:04 +0200 Message-ID: <20241023131248.27192-5-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847059 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 8DC491BFE0C; Wed, 23 Oct 2024 13:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689216; cv=none; b=XWnLm+XLCTibMUzAr67eH6XXIMjJ2TQtu2DYzF7qG1lYvYekQ5fOdDvdBogdW2m2XGBK/Xo/b0AU9P+9xpOlh5Wimm2eNP4skLJwq/Ns7tJ27oCSg7KwKzmiVDGR8WhPcwy5aDFbEraOCvssg/lyTtnr0KqQ4KSYxCQU9G/4OuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689216; c=relaxed/simple; bh=+mPa/jPAUkkjBYJVCw5ckmn4CgLVWcvx8RKEOZEn7wY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZrVy5cu1DiZqsoZYHR80icp4l6rCuj6Ahg2uc1vodCNHCKFU6aQoyM1oCWWkzX3c/YvQjkuwIvqn6H379GWuWdYuhQZbl+wwfvSFLN5Osd9LoMcvwS+iU/2wGa2G2Dy+0GG2izq9XRbnRnQ+3UGoJPyH4LDJ288dM+HLwSEpeA= 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=X+990/1i; arc=none smtp.client-ip=192.198.163.8 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="X+990/1i" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689214; x=1761225214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+mPa/jPAUkkjBYJVCw5ckmn4CgLVWcvx8RKEOZEn7wY=; b=X+990/1i2PzMwrBAyc54+w8EDrD5ukgN5ZU8j33NE/cDtr2voLkgxKW3 EOCQwRS+te2PBCD8EGiqwVMTBAr3Mslg4+TJHKdvTlz28debIYaVTrrQw LdJqIrJmlDSyEBKmLKp2n+XC45s8gfM+cEmeIYnumbXGf/D9POUWbtEe3 AzuGab4Af+eYekoomDmhlaS8a3RfpVcI7HdBpxzB5UnhOUICMpLiXt4eY 6U/WLJJvUkXUGy9O3PTh/aY5O+ZX6gYQnIvTJVOzXqHzvRidOJy6gB9FV 4YKDSuZWeytRe00vMX5VY9vdaBV3XznWP0VJKTpg9aod0N9jaTus9Uh2P Q==; X-CSE-ConnectionGUID: Z+Rl9n4YS32CW1A0yrtI3Q== X-CSE-MsgGUID: mC2icEmSTE2UDQlwa4S6sA== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758594" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758594" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:34 -0700 X-CSE-ConnectionGUID: yLB7w7/lTgu/d9N2m2QBwA== X-CSE-MsgGUID: /YHoKApITNClP71o8EAOSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820125" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:30 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 8ABFE28780; Wed, 23 Oct 2024 14:13:28 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 5/7] net: dsa: replace devlink resource registration calls by devl_ variants Date: Wed, 23 Oct 2024 15:09:05 +0200 Message-ID: <20241023131248.27192-6-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847060 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 392F21C3F26; Wed, 23 Oct 2024 13:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689218; cv=none; b=CYncUuMhXd9g4hZ+oLe68E3h7hVu/gpnoh+RFUlS3PwGcgC+j+j2+6J/oZXA0LyR1hi7DpwREkM3TR/FsFP64GMobNVoQ+tHd99jbSyQCXNPizcnbncpGrUh85iUc9pqVxyyvbpP+dxbARkkszOnLTs4MGGOQ7Stxc0jh0Vequ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689218; c=relaxed/simple; bh=lD1NtL7Hk81JQJLAmJRDC3Ndm3BotD4JGmSHT1DrU0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uDfNhvdpAJDZm87c6N4KPxLcpQiX9ixjYL82zgtbLxlybf13ugN2CT1JYVD17jYwpWt3/RtMSrDzIt0nHS1ruVaal54PeZdHIiKLt+1gXUmFtUeevXx4ZiKdIDrc6bgSwS5YXO9iQ8FIj5WrnXy8w+PZdJ3w5d9H0srUtqzl7sE= 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=MJuuHUia; arc=none smtp.client-ip=192.198.163.8 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="MJuuHUia" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689217; x=1761225217; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lD1NtL7Hk81JQJLAmJRDC3Ndm3BotD4JGmSHT1DrU0M=; b=MJuuHUiasi0WaYAGperzECkBPAYbzmjAzQxLUqK9C/NPJPdoJ5IeovxT osnj0n6TtuuT7sYb9T9bM9UyQt3siQTZDr+BZA1+MRi9noJZqudbJdJfE a5gNThDoXA4Qh+PgDLHfdB2eJSi6jnl+1w2LEege1AK+xGJm1KlXdXYm9 fv0hFgF8yip1MgOW0PSN6ui0NdHeQ9lnJusMqA+CiJn8tsSMfLZWHUUMl DHiMIT3b3E9dUSzum+WIATPdMJ5zXzRa3tz0/7Nog7FxnPMqgtdAqiI+a p81qdZankqtUUuxU0Wq+SRJNp9GsBk9C4eXif6H2mMbswxx0tZoGVX5Bt Q==; X-CSE-ConnectionGUID: F5QPXEsZQBuBCyoNsWh9+A== X-CSE-MsgGUID: bdN9+DjYS1ikGHa9gFp88w== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758605" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758605" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:36 -0700 X-CSE-ConnectionGUID: 8FZMuWqUQdSDJhtoiuGoJg== X-CSE-MsgGUID: 533S3WnjT8CdmTnpRZ3oLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820130" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:33 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 6D15C2877A; Wed, 23 Oct 2024 14:13:30 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 6/7] devlink: remove unused devlink_resource_occ_get_register() and _unregister() Date: Wed, 23 Oct 2024 15:09:06 +0200 Message-ID: <20241023131248.27192-7-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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 Wed Oct 23 13:09:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13847061 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 EFAAD1C727F; Wed, 23 Oct 2024 13:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689220; cv=none; b=mfTbj8EWDuQMHky9etfrytOCB4ZDGrAdPKoWnsEtkaD7LX+KZiW/Gu6c5UB1R4WhzEZ8tVlUYbQisSXt44kjMJL+bvEezvazrr/JbuhZyhS/pFLL67m/eN6Iz504wVM2w9SBJYXIO5bVcYOTYTuIl2XSz1AOmg0zdSMsY6zYsqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729689220; c=relaxed/simple; bh=jlr9PKPb+PVipw4Vu1aww5E0P8JdXjTuJjzC5cVxEh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OByq+Cwkip6L8FV89FzN1TonRr1dPWQvBZ3TtgBVDzzeQwHQ+lYuKRUNxgYS9ht/fgfXUARSCTYWdi2pDKrEPU3iMBWoiu1cuS1EK9hqhK7z0XrmonsjUnARqBfDDO92zjtgP4nsF/71wNCBDczETf4X0/3EDua8uzaysY1Wr10= 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=RPT05Tc3; arc=none smtp.client-ip=192.198.163.8 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="RPT05Tc3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729689219; x=1761225219; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jlr9PKPb+PVipw4Vu1aww5E0P8JdXjTuJjzC5cVxEh4=; b=RPT05Tc3lEuyYU0R+qVMr+S6xcw2bj0XhLo1PX22b4epGwHdcdjT8+0s lj8Yr1e4io74JIhLeg5cZPtpRTkCwWYNQDrAC/Nm4+rsRebF37kw9OZIy R1aPRWxxryH6DPwI4gZJ06ihqGS/TFXMToJeOg+60MecvyyCGKKxBflOL zkzra/t93jUAjOvyHV+f0UFQ8LyaPpaNBLJu9s8aaNqM/JJh7F9fNFfLS +iNlgBq3M4IZ1k4Fy9HFqwfNEwLPHnItjHXqc2tymNX4DBH+BEhldixVC rxZjfdUeJ4g9IUiXVUrXimMWFQwiSTUC5rg+3NMkgwl3SrynzRZZbhUwg Q==; X-CSE-ConnectionGUID: VBO0tRciTMWCnkfp85DJsw== X-CSE-MsgGUID: HEbQ+vDaQvmtAG4s5r+U2w== X-IronPort-AV: E=McAfee;i="6700,10204,11234"; a="46758617" X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="46758617" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2024 06:13:38 -0700 X-CSE-ConnectionGUID: pyWXoMVJTZKZNLSotEYmxw== X-CSE-MsgGUID: WmZKZxVVRRmjdLMC1AZn7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,226,1725346800"; d="scan'208";a="84820134" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 23 Oct 2024 06:13:35 -0700 Received: from pkitszel-desk.tendawifi.com (unknown [10.245.246.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 63CA22877E; Wed, 23 Oct 2024 14:13:32 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org Cc: Tony Nguyen , nex.sw.ncis.osdt.itp.upstreaming@intel.com, Marcin Szycik , Jiri Pirko , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Przemek Kitszel , Wojciech Drewek , Jiri Pirko , Joe Damato Subject: [PATCH net-next v2 7/7] devlink: remove unused devlink_resource_register() Date: Wed, 23 Oct 2024 15:09:07 +0200 Message-ID: <20241023131248.27192-8-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241023131248.27192-1-przemyslaw.kitszel@intel.com> References: <20241023131248.27192-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 Reviewed-by: Jiri Pirko Reviewed-by: Joe Damato 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) {