On Mon, Jul 11, 2022 at 11:48:06AM -0700, Jakub Kicinski wrote: > On Mon, 11 Jul 2022 14:38:54 +0100 Martin Habets wrote: > > > Normally drivers rely on the PCI Vendor and Device ID to learn the > > > number of BARs and their layouts. I guess this series implies that > > > doesn't work on this device? And the user needs to manually specify > > > what kind of device this is? > > > > When a new PCI device is added (like a VF) it always starts of with > > the register layout for an EF100 network device. This is hardcoded, > > i.e. it cannot be customised. > > The layout can be changed after bootup, and only after the sfc driver has > > bound to the device. > > The PCI Vendor and Device ID do not change when the layout is changed. > > > > For vDPA specifically we return the Xilinx PCI Vendor and our device ID > > to the vDPA framework via struct vdpa_config_opts. > > So it's switching between ethernet and vdpa? Isn't there a general > problem for configuring vdpa capabilities (net vs storage etc) and > shouldn't we seek to solve your BAR format switch in a similar fashion > rather than adding PCI device attrs, which I believe is not done for > anything vDPA-related? The initial support will be for vdpa net. vdpa block and RDMA will follow later, and we also need to consider FPGA management. When it comes to vDPA there is a "vdpa" tool that we intend to support. This comes into play after we've switched a device into vdpa mode (using this new file). For a network device there is also "devlink" to consider. That could be used to switch a device into vdpa mode, but it cannot be used to switch it back (there is no netdev to operate on). My current understanding is that we won't have this issue for RDMA. For FPGA management there is no general configuration tool, just what fpga_mgr exposes (drivers/fpga). We intend to remove the special PF devices we have for this (PCI space is valuable), and use the normal network device in stead. I can give more details on this if you want. Worst case a special BAR config would be needed for this, but if needed I expect we can restrict this to the NIC provisioning stage. So there is a general problem I think. The solution here is something at lower level, which is PCI in this case. Another solution would be a proprietary tool, something we are off course keen to avoid. > > > I'm confused about how this is supposed to work. What if the driver > > > is built-in and claims a device before the user can specify the > > > register layout? > > > > The bar_config file will only exist once the sfc driver has bound to > > the device. So in fact we count on that driver getting loaded. > > When a new value is written to bar_config it is the sfc driver that > > instructs the NIC to change the register layout. > > When you say "driver bound" you mean the VF driver, right? For a VF device yes it's the VF driver. For a PF device it would be the PF driver. Martin > > > What if the user specifies the wrong layout and the > > > driver writes to the wrong registers? > > > > We have specific hardware and driver requirements for this sort of > > situation. For example, the register layouts must have some common > > registers (to ensure some compatibility). > > A layout that is too different will require a separate device ID. > > A driver that writes to the wrong register is a bug. > > > > Maybe the name "bar_config" is causing most of the confusion here. > > Internally we also talk about "function profiles" or "personalities", > > but we thought such a name would be too vague.