Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1944995ybi; Thu, 4 Jul 2019 02:30:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYssh6RXZPNao+pocDFU1ZU+fBy+a/qBUUT0kaQk1aDarfGIha7hSdFr8KBEkVyHxn4l6v X-Received: by 2002:a17:902:e2:: with SMTP id a89mr48551415pla.210.1562232653713; Thu, 04 Jul 2019 02:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562232653; cv=none; d=google.com; s=arc-20160816; b=zNfwNRBeljLcOx9HcSst61pAZ4grFptO5K0ZqDdJwrTjmE/fCGa8SC1CnZ1SXiA69S IAad704RM7T+xYyard7Fy4ml+JfoY7zw/dlcCUrUAShdpwxqGYpJjCq5OKwjIwXcbxoU 3gzjMnl0zYM32gLxfkzHa38b8nObniqYK1kip88yHoM6TMTfbznZBtbk1dLDP6b9p3iD YKPBYE/7y+ESufu025+NksO3OT1nHqIlYVSpr3aVAUUHl6gWlv2GiF75RwVyVCjeGbMG Q+UBONTR/xzBMh5S7IyWRY/rJgnHGxoc7wkt0hDAFrNxmbfFNRjIzD0a10UO8PqPBlX4 Wr+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=fHBkQjdoVkkOX4PYGqVD2AssSmfuvYYbMEWCNp+UMZE=; b=L0O16CGE1kshX+D3ShSCjnM843L2LCpQ/1pgZh/BXCxelyqp2ClIliOQRT4jliyRfv ICRwj8TelP3mQgkn3B2ll0BPZSefzUclAlmW2jjlM3ZSMlmeF/5+kE1LgwB+DBzO1jbu v11A1oF7js2pRSHB8wGl/CGiOFEu7mE6FHtbuLtRgOz5ne/h5WCFFgRj/dwQ6VgalXxE N6pfTboMoW+JnnkfraOpl4N+DIKrLmG0zBCNqo62U5MxOiNugSMugch3MranyV0qQBRE gucXlUiV3aI/mcbxaRA6oNDY+DBU+XDckVwsv4dqcUE+N7yV2n7WlndUpIHuA5mju1n/ B/EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si4738949pfh.178.2019.07.04.02.30.37; Thu, 04 Jul 2019 02:30:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727320AbfGDJ23 (ORCPT + 99 others); Thu, 4 Jul 2019 05:28:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:43034 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727222AbfGDJ22 (ORCPT ); Thu, 4 Jul 2019 05:28:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 85189AC8E; Thu, 4 Jul 2019 09:28:27 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id D7360E0159; Thu, 4 Jul 2019 11:28:24 +0200 (CEST) Date: Thu, 4 Jul 2019 11:28:24 +0200 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Jiri Pirko , David Miller , Jakub Kicinski , Andrew Lunn , Florian Fainelli , John Linville , Stephen Hemminger , Johannes Berg , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v6 09/15] ethtool: generic handlers for GET requests Message-ID: <20190704092824.GQ20101@unicorn.suse.cz> References: <4faa0ce52dfe02c9cde5a46012b16c9af6764c5e.1562067622.git.mkubecek@suse.cz> <20190704084913.GA18546@nanopsycho> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190704084913.GA18546@nanopsycho> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 04, 2019 at 10:49:13AM +0200, Jiri Pirko wrote: > Tue, Jul 02, 2019 at 01:50:24PM CEST, mkubecek@suse.cz wrote: > > [...] > > > >+/* The structure holding data for unified processing GET requests consists of > >+ * two parts: request info and reply data. Request info is related to client > >+ * request and for dump request it stays constant through all processing; > >+ * reply data contains data for composing a reply message. When processing > >+ * a dump request, request info is filled only once but reply data is filled > >+ * from scratch for each reply message. > >+ * > >+ * +-----------------+-----------------+------------------+-----------------+ > >+ * | common_req_info | specific info | ethnl_reply_data | specific data | > >+ * +-----------------+-----------------+------------------+-----------------+ > >+ * |<---------- request info --------->|<----------- reply data ----------->| > >+ * > >+ * Request info always starts at offset 0 with struct ethnl_req_info which > >+ * holds information from parsing the common header. It may be followed by > >+ * other members for request attributes specific for current message type. > >+ * Reply data starts with struct ethnl_reply_data which may be followed by > >+ * other members holding data needed to compose a message. > >+ */ > >+ > > [...] > > > >+/** > >+ * struct get_request_ops - unified handling of GET requests > >+ * @request_cmd: command id for request (GET) > >+ * @reply_cmd: command id for reply (GET_REPLY) > >+ * @hdr_attr: attribute type for request header > >+ * @max_attr: maximum (top level) attribute type > >+ * @data_size: total length of data structure > >+ * @repdata_offset: offset of "reply data" part (struct ethnl_reply_data) > > For example, this looks quite scarry for me. You have one big chunk of > data (according to the scheme above) specific for cmd with reply starting > at arbitrary offset. We can split it into two structures, one for request related data with struct ethnl_req_info embedded at offset 0 and one for reply related data with struct ethnl_reply_data embedded at offset 0. It would be probably more convenient to have pointer to request info from reply data then. The code would get a bit simpler in few places at the expense of an extra kmalloc(). Michal