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 X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56A64C43331 for ; Wed, 13 Nov 2019 00:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C72A2196E for ; Wed, 13 Nov 2019 00:08:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="fZud3ib9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbfKMAIV (ORCPT ); Tue, 12 Nov 2019 19:08:21 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:36587 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbfKMAIV (ORCPT ); Tue, 12 Nov 2019 19:08:21 -0500 Received: by mail-qk1-f195.google.com with SMTP id d13so205403qko.3 for ; Tue, 12 Nov 2019 16:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=r4K7R0tR2iKjDwGj7h2AdFnAhKVb+PEh8hKXGhwzheo=; b=fZud3ib9ugZ1H45gqE3Ufx6TkhfidwZqwWlQe2U/+whtXNqUICQgqqYOrhI9G7ja5h 8wz4z83SrHf90CcjxE/pqx7yyuqeqCwhGO/PglcW50daiLjpDhHLPtWIatjp83enLA1i eCn9Cyh3/+6bkiKsYvohTq3vxERaDLgekZag44JZToiXvIR712sgs35f7P5IOnKrux9T 5/A7S2MFI7LRleIsmz6Z3nMdOR0RBtn0kvaVabK8o6Xbo0T11MJiJ4l+a9OV5hwhSrKI CO6qigj/t+1GvMCaBySSbYJ+NLrLbAnXsZiSCRrRr749BBN2dmr4pM9uOxk+1bx6QohQ /xig== 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:in-reply-to:user-agent; bh=r4K7R0tR2iKjDwGj7h2AdFnAhKVb+PEh8hKXGhwzheo=; b=JApYtqoXSlH/a1pFCxPdMSp8iiNTfhQc/TJPvCUIEXxqGv+Cjp5NDOEtRCoxqswyvf 2/uBOSEzWwuA/Yu9bGyxbFppd7XexfHr3TMhJadBECupjZompmGU/b9hIOgpSkb4shc2 Pc3G5xXu1Cn7fG/H/BYwFGRBPbZfF/QYNTi8TTTcWMrytbkywQF6ELOTBsBtmAiFP1+r iY8kuCML2eTxdpp/hcPGhgUORwEahB2FFwy/trpI2Pi0bLdDXTh8FLrm/KaYR2ejFNbD cIXTJ3/XGEvIRExWhv4MSE04ztK29CrM+YPpFWjdhLZGQD9GAFXyFXyUe/19lW/ocpvb RIFg== X-Gm-Message-State: APjAAAWhK1GQG/SmA/N0Fpj4HkKowjGSOzuubwhuEsowG6p+u3Z/9jFe F0RuRyfK3GZpB6CJ5jnCZZM6pQ== X-Google-Smtp-Source: APXvYqxUvDZJyIu1NzBqLzNMQJZcQEwGmA0sBjLaQeHkMjfR4xinoVbyQQ2cr4JogKuX1pAuI/x5jw== X-Received: by 2002:a05:620a:205d:: with SMTP id d29mr156309qka.152.1573603700172; Tue, 12 Nov 2019 16:08:20 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-180.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.180]) by smtp.gmail.com with ESMTPSA id m25sm309243qtc.0.2019.11.12.16.08.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Nov 2019 16:08:19 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1iUgCp-0005iu-4h; Tue, 12 Nov 2019 20:08:19 -0400 Date: Tue, 12 Nov 2019 20:08:19 -0400 From: Jason Gunthorpe To: Greg KH Cc: Jeff Kirsher , davem@davemloft.net, Dave Ertman , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com, parav@mellanox.com, Kiran Patil Subject: Re: [net-next 1/1] virtual-bus: Implementation of Virtual Bus Message-ID: <20191113000819.GB19615@ziepe.ca> References: <20191111192219.30259-1-jeffrey.t.kirsher@intel.com> <20191112212826.GA1837470@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191112212826.GA1837470@kroah.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Tue, Nov 12, 2019 at 10:28:26PM +0100, Greg KH wrote: > > + */ > > +struct virtbus_device { > > + const char *name; > > + int id; > > + const struct virtbus_dev_id *dev_id; > > + struct device dev; > > + void *data; > > +}; > > + > > +struct virtbus_driver { > > + int (*probe)(struct virtbus_device *); > > + int (*remove)(struct virtbus_device *); > > + void (*shutdown)(struct virtbus_device *); > > + int (*suspend)(struct virtbus_device *, pm_message_t state); > > + int (*resume)(struct virtbus_device *); > > + struct device_driver driver; > > + const struct virtbus_dev_id *id_table; > > +}; > > + > > +#define virtbus_get_dev_id(vdev) ((vdev)->id_entry) > > +#define virtbus_get_devdata(dev) ((dev)->devdata) > > What are these for? As far as I can see, the scheme here, using the language from the most recent discussion is: // in core or netdev module int mlx5_core_create() { struct mlx5_core_dev *core = kzalloc(..) [..] core->vdev = virtbus_dev_alloc("mlx5_core", core); } // in rdma module static int mlx5_rdma_probe(struct virtbus_device *dev) { // Get the value passed to virtbus_dev_alloc() struct mlx5_core_dev *core = virtbus_get_devdata(dev) // Use the huge API surrounding struct mlx5_core_dev qp = mlx5_core_create_qp(core, ...); } static struct virtbus_driver mlx5_rdma_driver = { .probe = mlx5_rdma_probe, .match = {"mlx5_core"} } Drivers that match "mlx5_core" know that the opaque 'virtbus_get_devdata()' is a 'struct mlx5_core_dev *' and use that access the core driver. A "ice_core" would know it is some 'struct ice_core_dev *' for Intel and uses that pointer, etc. ie it is just a way to a pass a 'void *' from one module to another while using the driver core to manage module autoloading and binding. Jason