Received: by 10.213.65.68 with SMTP id h4csp122675imn; Tue, 3 Apr 2018 16:59:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/AgvzV1+s7BElhEPxWkwFWwV1rRvX3zkXRFVbOzXd0Yl6mt/bu1fZvJ+HgUTCsPJTM8TWP X-Received: by 2002:a17:902:850c:: with SMTP id bj12-v6mr16381831plb.110.1522799945484; Tue, 03 Apr 2018 16:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522799945; cv=none; d=google.com; s=arc-20160816; b=MPPbrsstGKI05iqKHt/CIhdUwIf8AGQXjang0oAljCSU4PxZo1qrrtauOavnmIk/Vx 4DAbwrq/qQkhs7HeAq9kHSB8laCr/kHLTy+KZsYQ8Uhf09WbqqvCzlCVtStMdUsuCJbM MIxzWPtdh0bxrEKD17zSsrcg/RMNDpDM4YR8WGFzH+PfaOgS9sW6f2EyphV7ookggc09 o9JgIeBsXoEOrtOFZ7VTA8HjQWUmOaprfH+FhBQ6mPf8+1EFxxnNULIvFkwkzO7oAi5A wWajmRZ3n5/alszl22eJoIxBc64kUUucqPcidVa4BgMF4lOhviH7FKTNaRTKwGkTJbe5 1Xow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HcZKPrX/cIMlRH+vCSxi4MOtfO5pO7Ui5MmDhXLmd/w=; b=UW+BXrqI71BsgIedAwgSMQcUP1ue5AlK1nGs6aXRcm46OtioiSlgh1I6Nyqntw54Ny nR/vESw45ZwrPe0hwcLZ0rsPXCfdVlSKpfN7rSGEO10t3PnrYO/t2iDeU8pvNUAgU7t9 qeMEzyYu48hjujYquNG/CeIn5p4MaxPOaygWSTWRk2ArDzdThIpUznbckfdGgiLfsr7j Xjcwj6Q0PQhEjzxdCw9SSG6bG+lO03JfZ0WWrgVW/Pts4kiyt+XqYrT+lRHLSG69c1k3 JLpQlh/nDLXF1UPE8o19B3sWrL9Jy32UdkV7fTTxPQqiNetHQqO4JhupK/NExHqt8wgt AZRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o1i2ztHf; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y184si2736370pgb.120.2018.04.03.16.58.50; Tue, 03 Apr 2018 16:59:05 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o1i2ztHf; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755345AbeDCX5s (ORCPT + 99 others); Tue, 3 Apr 2018 19:57:48 -0400 Received: from mail-ua0-f171.google.com ([209.85.217.171]:40184 "EHLO mail-ua0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753927AbeDCX5q (ORCPT ); Tue, 3 Apr 2018 19:57:46 -0400 Received: by mail-ua0-f171.google.com with SMTP id n20so12141104ual.7; Tue, 03 Apr 2018 16:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HcZKPrX/cIMlRH+vCSxi4MOtfO5pO7Ui5MmDhXLmd/w=; b=o1i2ztHfHbTdf91HQwYUm9Fb0EFNFuN2oIaaaRxAYsufDKt0P6oqvORBwGcUDhFqHu o78jKdnNlVPToSn0qD0rxkt5EQCNBESQqPKIKWDKpVZNXv+CKx2BaE9sGnbohEiMHKpl dILcqKpLVApL38CwHk8fQnqU9ww+f3x59HPFaC5vXG2BZshAAQTHS8HB3Rxl3RZ98ega 9GaZ22cu0s1e83DiAt7zlqrTV4PMkEWp8IPIU5uSZVbQtUqPnBVuUa57rvZGOgLHyaWk G2zfLPXHl+JP/kx1EzsLFVKGEDEBxRwGGtfPl2hCxC2SdrK71NKjRT6mCAfyRgVaE0vU Db4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HcZKPrX/cIMlRH+vCSxi4MOtfO5pO7Ui5MmDhXLmd/w=; b=rYq1J2DtG1EWRIS/yfxpuwza33fjs9eFjhWXCfdV7khAoNTXNipvdE2BJwrQA+FVJb wDOl/rwtQE42fQo5dkxv9clrNZLgzGQYgylyNSW1Qb0vKNVmU5c3KP/SN3B1fHTMyFvl MRjRruERAqS0SwSDQ605ASPtAXBnW1ncmN5PdVxhwtH/lq1N5pvdGEIEOjLKRavoy+Kl /bKKUzfjWuiRsL1It12Bx4YBxCJsP4AGmFB56eecJHpqI8Gy2eICrjdN43VfJXj0ZgQr DOIU0GmFjE52AlJ7MnoHlIGTs2JA7STNNtB6U4GAltXRASqGC3r9c1Z0/jIV1/E58q7o u8Kg== X-Gm-Message-State: ALQs6tAR1ycy8yc6aWhOj0MFoxJ2ddKOeSExffac55wEu2rgtGWvKDjF bh0VphzwidM8g0PdUPJdHELHOs0oueNjCJcMMTerlH3Q X-Received: by 10.176.30.138 with SMTP id o10mr498829uak.184.1522799865483; Tue, 03 Apr 2018 16:57:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.36.5 with HTTP; Tue, 3 Apr 2018 16:57:44 -0700 (PDT) In-Reply-To: References: From: Stuart Yoder Date: Tue, 3 Apr 2018 18:57:44 -0500 Message-ID: Subject: Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support To: Arnd Bergmann , Andrew Lunn Cc: Ioana Ciornei , gregkh , Laurentiu Tudor , Linux Kernel Mailing List , Ruxandra Ioana Ciocoi Radulescu , Razvan Stefanescu , Roy Pledge , Networking Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 28, 2018 at 10:43 AM, Arnd Bergmann wrote: > On Wed, Mar 28, 2018 at 4:27 PM, Ioana Ciornei wrote: >> Hi, >> >>> >>> Hi Ioana, >>> >>> So this driver is a direct passthrough to your hardware for passing fixed- >>> length command/response pairs. Have you considered using a higher-level >>> interface instead? >>> >>> Can you list some of the commands that are passed here as clarification, and >>> explain what the tradeoffs are that have led to adopting a low-level interface >>> instead of a high-level interface? >>> >>> The main downside of the direct passthrough obviously is that you tie your >>> user space to a particular hardware implementation, while a high-level >>> abstraction could in principle work across a wider range of hardware revisions >>> or even across multiple vendors implementing the same concept by different >>> means. >> >> If by "higher-level" you mean an implementation where commands are created by the kernel at userspace's request, then I believe this approach is not really viable because of the sheer number of possible commands that would bloat the driver. >> >> For example, a DPNI (Data Path Network Interface) can be created using a command that has the following structure: >> >> struct dpni_cmd_create { >> uint32_t options; >> uint8_t num_queues; >> uint8_t num_tcs; >> uint8_t mac_filter_entries; >> uint8_t pad1; >> uint8_t vlan_filter_entries; >> uint8_t pad2; >> uint8_t qos_entries; >> uint8_t pad3; >> uint16_t fs_entries; >> }; >> >> In the above structure, each field has a meaning that the end-user might want to be able to change according to their particular use-case (not much is left at its default value). >> The same level of complexity is encountered for all the commands that interact with Data Path objects such as DPBP(buffer pools), DPRC(Resource Container) etc. >> You can find more examples of commands in restool's repo: https://github.com/qoriq-open-source/restool/tree/integration/mc_v10 >> >> In my opinion, an in-kernel implementation that is equivalent in terms of flexibility will turn >> into a giant ioctl parser, all while also exposing an userspace API that is not as simple/easy to use. > > (adding the netdev list) > > The command you list there seems to be networking related, so instead of > an ioctl based interface, a high-lever interface would likely use netlink > for consistency with other drivers. Are all commands for networking > or are there some that are talking to the device to do something unrelated? > > Obviously creating a high-level interface would be a lot of work in the kernel, > and it only pays off if there are multiple independent users, we wouldn't do > that for just one driver. > > I'm still not convinced either way (high-level or low-level > interface), but I think > this needs to be discussed with the networking maintainers. Given the examples > on the github page you linked to, the high-level user space commands > based on these ioctls > > ls-addni # adds a network interface > ls-addmux # adds a dpdmux > ls-addsw # adds an l2switch > ls-listmac # lists MACs and their connections > ls-listni # lists network interfaces and their connections > > and I see that you also support the switchdev interface in > drivers/staging/fsl-dpaa2, which I think does some of the same > things, presumably by implementing the switchdev API using > fsl_mc_command low-level interfaces in the kernel. > > Is that a correct interpretation? If yes, could we extend switchdev > or other networking interfaces to fill in whatever those don't handle > yet? The wrapper scripts you referenced are not sufficient to show the scope of what the proposed user space interface is for. The command list is not just about networking related objects, as there are quite a few other types of objects as well: dprc - container object representing an fsl-mc bus instance...i.e. other objects are attached to this bus dpio - used for queuing operations towards any accelerator or network interface dpbp - buffer pool object dpmcp - command portal interface dpdmai - DMA engine dpseci - crypto accelerator dpdcei - compression/decompression accelerator dpni - network interface dprtc - real time counter dpaiop - heterogenous core complex for packet processing offload dpmac - represents an Ethernet MAC dpsw - network switch dpcon - network concentrator dpci - communication interface The proposed ioctl interface is about: A) creating and destroying all those object types B) managing the dprc containers they live in, including moving objects between containers C) where applicable establishing connections between different objects No _operational_ aspects of these object/devices is being handled through this interface. The network interface should be managed through ethtool, for example. The proposed ioctl interface is about bringing the devices into existence and getting them "wired" up. Suppose you want to create and assign a network interface to a KVM virtual machine, you would do something like the following using a user space tool like restool: -create a new (empty) dprc object -create a new dpni and assign it to the dprc -create a new dpio and assign it to the dprc -create a new dpbp and assign it to the dprc -create a new dpmcp and assign it to the dprc -create a new dpmac and assign it to the dprc -connect the dpni to the dpmac Now, at this point you have a functional set of objects that can function as a network interface. That dprc can now be assigned to a KVM VM using vfio and the guest will see a dprc that it can probe and enumerate using the fsl-mc bus infrastructure that is now upstream. There is no existing kernel <--> user space mechanism that will work to do all that, so something new was needed. As far as low-level vs high-level...we did consider a higher level interface that would expose operations on individual object such as "create dpbp", but the user space API gets complex and fragile for no obvious value. Every object needs commands to create/destroy and get attributes. There is a sizeable dprc command set. Every time an object is enhanced (with a corresponding major or minor version rev) you have to change the ioctl interface. Having a simple command passthrough interface reduces complexity in the kernel and provides an interface that should be very stable. The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't seem to be anything that can be made generic here to provide more common benefit. Thanks, Stuart