From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by dpdk.org (Postfix) with ESMTP id 589C4E5D for ; Mon, 11 Dec 2017 15:38:33 +0100 (CET) Received: by mail-wr0-f172.google.com with SMTP id o2so17824933wro.5 for ; Mon, 11 Dec 2017 06:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=4CzVWPUx6aIKC9pUn6ZmLRoLj/9lsb6vaS5oXKNgDSc=; b=afCBDrAlY8huFDfN8WYNbjB06EKQjmTUBPVNRzdXpqKx03Q1vLmSZioZ4m+iB9nIH3 c7O3DS8+FCz5M3jllkCLVuliZ+YXEEPEn7hyS+0IiBMlalCbRx9k7q04XEqh1UiusZJ+ En3l6TlU766DqFHvBo72252hgi7F9f+xnG9FzK7XPozF+myeWoyvYSbj3itGh3kJwc4p lQEHOzVXK4lo8NIUWvH5Ei6mg6Lx0D2vueowPcYG+CIhvr3qwKMQTqiVMgW+WB7KnPaJ Y+c56REpO4PxMu6XqUuT4hWEr0ZBTiBhWCqZFik22/9WS0HYtzF4fQ2wr7TLr59JZEnM Hg/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=4CzVWPUx6aIKC9pUn6ZmLRoLj/9lsb6vaS5oXKNgDSc=; b=oBnYo6VX1BC4uciVOjiwXkMC1pKQURrjpyPLrwgOstLxqLcsfzkbNTe/CTWLW7Bgy6 s08beC/RLXJYGeAiEG43d6Asm0CUjbBdpPSESfZVfchH55DzgXkJIt/fgpLSZS95zB/V rNmJi+X/ooIBcXR35b/CtTY8P24Z61BmtcwiLFjwbUc5f7nYG8IQ7PyLMHMlvtEHXw+Z vzJ7vYqEwPaD9Mb38NNt2Hfvk4uR7Bg2hXmKxvoUEf1tqFB7Zog9CSWoBCRDcokB+NnY wd8nJ1Rwdwb67cXPS1QaqpPReF8bRGb3U+Qcu6V33e3mDEJM+mU4vjCbkKeNIEnkLC+o LaTw== X-Gm-Message-State: AKGB3mIkMePV3vDyo5ceLUk0rAzJvksi05oUelSHI/W3uTX9G6cGbAUL PIQZ3MWIlLLzS19E1v6Vp47oa83K X-Google-Smtp-Source: ACJfBouTMt9qTodOsiABGU5WitN6uCjtl/oRTNxYP9yd5T6KhejnMaQtWQ0sqic6U4WVuU+hpNRb6w== X-Received: by 10.223.176.8 with SMTP id f8mr580233wra.80.1513003112777; Mon, 11 Dec 2017 06:38:32 -0800 (PST) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id s187sm8855735wmf.16.2017.12.11.06.38.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Dec 2017 06:38:31 -0800 (PST) Date: Mon, 11 Dec 2017 15:38:19 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Shreyansh Jain Cc: dev@dpdk.org Message-ID: <20171211143819.hxgyhnxiiwlegjbw@bidouze.vm.6wind.com> References: <91106540c460d22dd23a30dc2903d7e238ff9a3b.1507796085.git.gaetan.rivet@6wind.com> <088de7d2-9bd4-4a49-44ba-9df9c52b72d1@nxp.com> <20171211124359.zhyeaveywobmobef@bidouze.vm.6wind.com> <665f56dc-3cd5-e199-59b5-2021facd0bba@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <665f56dc-3cd5-e199-59b5-2021facd0bba@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v1 2/8] bus: introduce opaque control framework X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2017 14:38:33 -0000 On Mon, Dec 11, 2017 at 07:06:55PM +0530, Shreyansh Jain wrote: > On Monday 11 December 2017 06:13 PM, Gaėtan Rivet wrote: > > On Mon, Dec 11, 2017 at 05:30:16PM +0530, Shreyansh Jain wrote: > > > On Thursday 12 October 2017 01:48 PM, Gaetan Rivet wrote: > > [...] > > > > > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h > > > > index 331d954..bd3c28e 100644 > > > > --- a/lib/librte_eal/common/include/rte_bus.h > > > > +++ b/lib/librte_eal/common/include/rte_bus.h > > > > @@ -183,6 +183,51 @@ struct rte_bus_conf { > > > > enum rte_bus_probe_mode probe_mode; /**< Probe policy. */ > > > > }; > > > > +/** > > > > + * Bus configuration items. > > > > + */ > > > > +enum rte_bus_ctrl_item { > > > > + RTE_BUS_CTRL_PROBE_MODE = 0, > > > > + RTE_BUS_CTRL_ITEM_MAX, > > > > +}; > > > > > > I am assuming that a driver implementation can take more than ITEM_MAX > > > control knobs. It is opaque to the library. Are we on same page? > > > > > > For example, a bus driver can implement: > > > > > > rte_bus_XXX_ctrl_item { > > > > > > RTE_BUS_XYZ_KNOB_1 = 100, > > > RTE_BUS_XYZ_KNOB_2, > > > RTE_BUS_XYZ_KNOB_3, > > > }; > > > > > > without the library knowing or restricting the API to RTE_BUS_CTRL_ITEM_MAX. > > > > > > I see that in your code for PCI (Patch 5/8: pci_ctrl) you have restricted > > > the control knob to RTE_BUS_CTRL_ITEM_MAX. > > > I hope that such restrictions would not float to library layer. > > > > > > If we are on same page, should this be documented as a code comment > > > somewhere? > > > if not, do you think what I am stating makes sense? > > > > > > > I see what you mean, but I'm not sure it would be a good thing. > > Actually, I think proposing this ITEM_MAX was a mistake. > > > > Regarding the specific bus knobs: > > > > - If a single bus needs this knob, then it would be better for the dev > > to add it as part of the bus' public API, following the correct > > library versioning processes. This would not break this bus control > > structure ABI. > > Sorry, but can you elaborate on "...add it as part of bus' public API"? > > This is what I had in mind: > > ctrl_fn = rte_bus_control_get(busname, RTE_BUS_XYZ_KNOB_1); > > (unlike specific functions like probe_mode_get/set and iova_mode_get/set) > > Where ctrl_fn would then point to a method specific to bus for KNOB_1 > configuration parameter. > Thereafter, ctrl_fn(KNOB_1, void *arg). > > What other public API method are you hinting at? > > I was thinking that buses would simply expose a function rte_busname_xyz_knob1(void *arg); as part of their public API. This would not require an ABI break for this bus, as it would only be an API extension and would not use callbacks within the bus structure. Thus, I think that for buses tempted to propose a specific API, this would be the cleanest way. The bus proposing it as part of a custom control section would only be interesting when the operation is expected to become a standard API for other buses but was not yet accepted. Applications would be able to use the interface and the ITEM could be added later. But I doubt this is encouraging best practices as far as API evolution go. > > > > - If more than one bus implement this knob, then it should be proposed > > as part of the library API. Buses adding this new knob would break > > their ABI, other buses would be left untouched. > > Agree, if more than one bus implements same operation. > > > > > This makes me realize that proposing this ITEM_MAX value is not good to > > the intended purpose of this patchset: > > > > - If a bus implementation use a reference to ITEM_MAX, then the control > > structure ABI would be broken by any new control knob added, even if the > > bus does not implement it. Granted, it would not break the driver > > structure itself, but still. My PCI implementation is thus incorrect. > > Changes to enum wouldn't break ABI as far as I understand. Adding a new > entry only expands it to a new declaration without impacting its size or > signature. > > > > > Therefore I think that it would be best to remove this ITEM_MAX altogether, > > forcing bus developpers to use other ways that would not break their > > ABIs every other release. > > > > Removing ITEM_MAX is OK from my side. It doesn't serve much purpose. But, > not for the "ABI break" reason. Adding the enum would not break ABI indeed, but I was thinking about the way the bus control structure would be declared. However, upon second inspection on the my PCI implementation, I did not actually use ITEM_MAX: > static rte_bus_ctrl_t pci_ctrl_ops[][RTE_BUS_CTRL_OP_MAX] = { > » [RTE_BUS_CTRL_PROBE_MODE] = { > » » [RTE_BUS_CTRL_GET] = pci_probe_mode_get, > » » [RTE_BUS_CTRL_SET] = pci_probe_mode_set, > » }, > }; I just thought I had used RTE_BUS_CTRL_ITEM_MAX instead of RTE_BUS_CTRL_OP_MAX. So my line of thought was simply that if any new item was declared, the control structure would then change size. But I was mistaken, so that's actually not a problem :) Having ITEM_MAX available would still make those kind of mistakes possible however. It might be better to prevent it completely by removing it. This would however also prevent a custom control section. Do you think this would be useful enough to justify the slightly more complex maintenance and review of bus implementations? -- Gaėtan Rivet 6WIND