Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8291068rwb; Wed, 23 Nov 2022 19:17:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4qBkG1yfZpSMhKLdwW8p82QndTu88vsUJIYU37qgiQpq+aeSN4EWSxZV9ZeSe4/8CJotMj X-Received: by 2002:a05:6402:3226:b0:461:37c2:e85c with SMTP id g38-20020a056402322600b0046137c2e85cmr19359901eda.74.1669259847444; Wed, 23 Nov 2022 19:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669259847; cv=none; d=google.com; s=arc-20160816; b=boKjT1jC9zzz/dosRoV8MXq/A8CUp/ahN7t4Y8un4slMoG+361HSGnnTsC3L289xxV 4kAIZtLmKvK0LKZ+y39tfdeBQ+SoCymIehAK44fcQPotxCswuKBOiDc9aSbaLd6QEKAb fg2fpe2ad1Mu01+BkRmYDcy5YHDm6oDA9E1FnY/CaPK/SHbmzYs5/eXLDcL96eU6aXcf SJoSoltYlT8QborEVO9HfD2I2nuLkZmCBjk6FUxs4ofCQ5UU9iJm52ZPpTgpbsbKFKQX uE4pQ4LgpbICybYwrmTDfCnwZmnTiysiCSR6G0NtUZz/4+MzT43G+75XH5X1RA2H/gun 1O3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=p782GaHYu04mIbS/dnPOAptJgGemdsqFY7CkPwbg4Vc=; b=uBBPGOnCfj92YGh8HuHO8tgRawTdfL/WEMJ7N/PYKMh6/bjppLhzhc2tmUWmeQbNRc M4TAafXitE1i8+PTHCuJ3YM9zTk1J1H3EWgm3W7clOtj4FF+0UiTmBShILNTajkCp6al 8PoQ1EvJIbEv4qyOIR4W55rft+C11OS/WKV7sK+OE3vSx+jN2A0eQUQxarwRXyxn3v7J MPI+zesn9RDVFoMWF00Jk+ZAqlhGjkfS83sUGE6TZovOZJEhOrXbWFGwizckE8btKAdJ ud+2pKsW8ZySNnAKxfFyOQDckZzIT+J82G8/01i3dj1MkNzGo+CN+6kpp+4yEAOV938b d+uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeNqZeCS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a170906039300b0078034101c0esi900914eja.978.2022.11.23.19.17.06; Wed, 23 Nov 2022 19:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeNqZeCS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiKXDG4 (ORCPT + 89 others); Wed, 23 Nov 2022 22:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiKXDGy (ORCPT ); Wed, 23 Nov 2022 22:06:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D87CCC9AAA; Wed, 23 Nov 2022 19:06:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 97A83B8265E; Thu, 24 Nov 2022 03:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 165C8C433C1; Thu, 24 Nov 2022 03:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669259210; bh=lccoEXftS+MhRN5YdTKO774+vLm0l8f8UNQdfunzQ8I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NeNqZeCSGTNBt4tWbKHXjkvHTwKyf4A4PdT4Oe+DMPTdYlhWyRKFPr2yiNAUTl8N0 PD6ePdtMbiL9Y5aWdTUgdPo0fn79xuCJTAvKUtl+xNKbAz+mniYAoop4N49A19Xsod q618iYzB+yqFiN6s+tncNmhY/0kQyemyARVEa1YoPHc+vNNFxo6PSn9l1Mk/g5xGZn EVSRXL4AADwus1aOa+sZxVHZcbJ4ZseAFUeXhgoe/bluB1SJiOlKs1Vqz5oB2bjJH/ gfAsH+5ipXb3YzEBbwwO2t1EsapbBBPV04W2XgsBSKb6tRW3ocrx7FkdwfOOR4G8xH e+hBqq4dZcy3Q== Date: Wed, 23 Nov 2022 19:06:49 -0800 From: Jakub Kicinski To: Vincent MAILHOL Cc: Jiri Pirko , netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] net: devlink: devlink_nl_info_fill: populate default information Message-ID: <20221123190649.6c35b93d@kernel.org> In-Reply-To: References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> <20221122201246.0276680f@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Nov 2022 18:42:41 +0900 Vincent MAILHOL wrote: > I see three solutions: > > 1/ Do it in the core, clean up all drivers using > devlink_info_driver_name_put() and make the function static (i.e. > forbid the drivers to set the driver name themselves). > N.B. This first solution does not work for > devlink_info_serial_number_put() because the core will not always be > able to provide a default value (e.g. my code only covers USB > devices). > > 2/ Keep track of which attribute is already set (as you suggested). > > 3/ Do a function devlink_nl_info_fill_default() and let the drivers > choose to either call that function or set the attributes themselves. > > I would tend to go with a mix of 1/ and 2/. I think 2/ is best because it will generalize to serial numbers while 1/ will likely not. 3/ is a smaller gain. Jiri already plumbed thru the struct devlink_info_req which is on the stack of the caller, per request, so we can add the bool / bitmap for already reported items there quite easily.