From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7525C433FE for ; Thu, 24 Nov 2022 03:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbiKXDGz (ORCPT ); Wed, 23 Nov 2022 22:06:55 -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 Precedence: bulk List-ID: X-Mailing-List: netdev@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.