Skip to content
Snippets Groups Projects
  1. Dec 03, 2020
  2. Aug 24, 2020
  3. Jul 29, 2020
  4. Jul 15, 2020
  5. Aug 08, 2019
  6. Jul 10, 2019
  7. May 30, 2019
  8. May 24, 2019
  9. May 02, 2019
  10. Mar 17, 2019
  11. Jul 02, 2018
  12. Jun 03, 2018
  13. Jan 24, 2018
    • Frederic Barrat's avatar
      ocxl: Add a kernel API for other opencapi drivers · 280b983c
      Frederic Barrat authored
      
      Some of the functions done by the generic driver should also be needed
      by other opencapi drivers: attaching a context to an adapter,
      translation fault handling, AFU interrupt allocation...
      
      So to avoid code duplication, the driver provides a kernel API that
      other drivers can use, similar to calling a in-kernel library.
      
      It is still a bit theoretical, for lack of real hardware, and will
      likely need adjustements down the road. But we used the cxlflash
      driver as a guinea pig.
      
      Signed-off-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      280b983c
    • Frederic Barrat's avatar
      powerpc/powernv: Capture actag information for the device · 2cb3d64b
      Frederic Barrat authored
      
      In the opencapi protocol, host memory contexts are referenced by a
      'actag'. During setup, a driver must tell the device how many actags
      it can used, and what values are acceptable.
      
      On POWER9, the NPU can handle 64 actags per link, so they must be
      shared between all the PCI functions of the link. To get a global
      picture of how many actags are used by each AFU of every function, we
      capture some data at the end of PCI enumeration, so that actags can be
      shared fairly if needed.
      
      This is not powernv specific per say, but rather a consequence of the
      opencapi configuration specification being quite general. The number
      of available actags on POWER9 makes it more likely to be hit. This is
      somewhat mitigated by the fact that existing AFUs are coded by
      requesting a reasonable count of actags and existing devices carry
      only one AFU.
      
      Signed-off-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      2cb3d64b
  14. Nov 28, 2017
  15. Jul 03, 2017
  16. Mar 17, 2017
  17. Jul 14, 2016
    • Andrew Donnellan's avatar
      cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards · b0b5e591
      Andrew Donnellan authored
      
      Add a new API, cxl_check_and_switch_mode() to allow for switching of
      bi-modal CAPI cards, such as the Mellanox CX-4 network card.
      
      When a driver requests to switch a card to CAPI mode, use PCI hotplug
      infrastructure to remove all PCI devices underneath the slot. We then write
      an updated mode control register to the CAPI VSEC, hot reset the card, and
      reprobe the card.
      
      As the card may present a different set of PCI devices after the mode
      switch, use the infrastructure provided by the pnv_php driver and the OPAL
      PCI slot management facilities to ensure that:
      
        * the old devices are removed from both the OPAL and Linux device trees
        * the new devices are probed by OPAL and added to the OPAL device tree
        * the new devices are added to the Linux device tree and probed through
          the regular PCI device probe path
      
      As such, introduce a new option, CONFIG_CXL_BIMODAL, with a dependency on
      the pnv_php driver.
      
      Refactor existing code that touches the mode control register in the
      regular single mode case into a new function, setup_cxl_protocol_area().
      
      Co-authored-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      b0b5e591
    • Ian Munsie's avatar
      cxl: Add support for interrupts on the Mellanox CX4 · a2f67d5e
      Ian Munsie authored
      
      The Mellanox CX4 in cxl mode uses a hybrid interrupt model, where
      interrupts are routed from the networking hardware to the XSL using the
      MSIX table, and from there will be transformed back into an MSIX
      interrupt using the cxl style interrupts (i.e. using IVTE entries and
      ranges to map a PE and AFU interrupt number to an MSIX address).
      
      We want to hide the implementation details of cxl interrupts as much as
      possible. To this end, we use a special version of the MSI setup &
      teardown routines in the PHB while in cxl mode to allocate the cxl
      interrupts and configure the IVTE entries in the process element.
      
      This function does not configure the MSIX table - the CX4 card uses a
      custom format in that table and it would not be appropriate to fill that
      out in generic code. The rest of the functionality is similar to the
      "Full MSI-X mode" described in the CAIA, and this could be easily
      extended to support other adapters that use that mode in the future.
      
      The interrupts will be associated with the default context. If the
      maximum number of interrupts per context has been limited (e.g. by the
      mlx5 driver), it will automatically allocate additional kernel contexts
      to associate extra interrupts as required. These contexts will be
      started using the same WED that was used to start the default context.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a2f67d5e
    • Ian Munsie's avatar
      cxl: Add preliminary workaround for CX4 interrupt limitation · cbce0917
      Ian Munsie authored
      
      The Mellanox CX4 has a hardware limitation where only 4 bits of the
      AFU interrupt number can be passed to the XSL when sending an interrupt,
      limiting it to only 15 interrupts per context (AFU interrupt number 0 is
      invalid).
      
      In order to overcome this, we will allocate additional contexts linked
      to the default context as extra address space for the extra interrupts -
      this will be implemented in the next patch.
      
      This patch adds the preliminary support to allow this, by way of adding
      a linked list in the context structure that we use to keep track of the
      contexts dedicated to interrupts, and an API to simultaneously iterate
      over the related context structures, AFU interrupt numbers and hardware
      interrupt numbers. The point of using a single API to iterate these is
      to hide some of the details of the iteration from external code, and to
      reduce the number of APIs that need to be exported via base.c to allow
      built in code to call.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      cbce0917
    • Ian Munsie's avatar
      cxl: Add kernel APIs to get & set the max irqs per context · 79384e4b
      Ian Munsie authored
      
      These APIs will be used by the Mellanox CX4 support. While they function
      standalone to configure existing behaviour, their primary purpose is to
      allow the Mellanox driver to inform the cxl driver of a hardware
      limitation, which will be used in a future patch.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      79384e4b
    • Ian Munsie's avatar
      cxl: Allow a default context to be associated with an external pci_dev · a19bd79e
      Ian Munsie authored
      
      The cxl kernel API has a concept of a default context associated with
      each PCI device under the virtual PHB. The Mellanox CX4 will also use
      the cxl kernel API, but it does not use a virtual PHB - rather, the AFU
      appears as a physical function as a peer to the networking functions.
      
      In order to allow the kernel API to work with those networking
      functions, we will need to associate a default context with them as
      well. To this end, refactor the corresponding code to do this in vphb.c
      and export it so that it can be called from the PHB code.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a19bd79e
    • Ian Munsie's avatar
      cxl: Move cxl_afu_get / cxl_afu_put to base · 62ccf2d2
      Ian Munsie authored
      
      The Mellanox CX4 uses a model where the AFU is one physical function of
      the device, and is used by other peer physical functions of the same
      device. This will require those other devices to grab a reference on the
      AFU when they are initialised to make sure that it does not go away
      during their lifetime.
      
      Move the AFU refcount functions to base.c so they can be called from
      the PHB code.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      62ccf2d2
    • Ian Munsie's avatar
      cxl: Add cxl_slot_is_supported API · 4e56f858
      Ian Munsie authored
      
      This extends the check that the adapter is in a CAPI capable slot so
      that it may be called by external users in the kernel API. This will be
      used by the upcoming Mellanox CX4 support, which needs to know ahead of
      time if the card can be switched to cxl mode so that it can leave it in
      PCI mode if it is not.
      
      This API takes a parameter to check if CAPP DMA mode is supported, which
      it currently only allows on P8NVL systems, since that mode currently has
      issues accessing memory < 4GB on P8, and we cannot realistically avoid
      that.
      
      This API does not currently check if a CAPP unit is available (i.e. not
      already assigned to another PHB) on P8. Doing so would be racy since it
      is assigned on a first come first serve basis, and so long as CAPP DMA
      mode is not supported on P8 we don't need this, since the only
      anticipated user of this API requires CAPP DMA mode.
      
      Cc: Philippe Bergheaud <felix@linux.vnet.ibm.com>
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      4e56f858
  18. Jun 28, 2016
    • Michael Neuling's avatar
      cxl: Add set and get private data to context struct · ad42de85
      Michael Neuling authored
      
      This provides AFU drivers a means to associate private data with a cxl
      context. This is particularly intended for make the new callbacks for
      driver specific events easier for AFU drivers to use, as they can easily
      get back to any private data structures they may use.
      
      Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: default avatarPhilippe Bergheaud <felix@linux.vnet.ibm.com>
      Reviewed-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
      Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ad42de85
    • Philippe Bergheaud's avatar
      cxl: Add mechanism for delivering AFU driver specific events · b810253b
      Philippe Bergheaud authored
      
      This adds an afu_driver_ops structure with fetch_event() and
      event_delivered() callbacks. An AFU driver such as cxlflash can fill
      this out and associate it with a context to enable passing custom AFU
      specific events to userspace.
      
      This also adds a new kernel API function cxl_context_pending_events(),
      that the AFU driver can use to notify the cxl driver that new specific
      events are ready to be delivered, and wake up anyone waiting on the
      context wait queue.
      
      The current count of AFU driver specific events is stored in the field
      afu_driver_events of the context structure.
      
      The cxl driver checks the afu_driver_events count during poll, select,
      read, etc. calls to check if an AFU driver specific event is pending,
      and calls fetch_event() to obtain and deliver that event. This way, the
      cxl driver takes care of all the usual locking semantics around these
      calls and handles all the generic cxl events, so that the AFU driver
      only needs to worry about it's own events.
      
      fetch_event() return a struct cxl_event_afu_driver_reserved, allocated
      by the AFU driver, and filled in with the specific event information and
      size. Total event size (header + data) should not be greater than
      CXL_READ_MIN_SIZE (4K).
      
      Th cxl driver prepends an appropriate cxl event header, copies the event
      to userspace, and finally calls event_delivered() to return the status of
      the operation to the AFU driver. The event is identified by the context
      and cxl_event_afu_driver_reserved pointers.
      
      Since AFU drivers provide their own means for userspace to obtain the
      AFU file descriptor (i.e. cxlflash uses an ioctl on their scsi file
      descriptor to obtain the AFU file descriptor) and the generic cxl driver
      will never use this event, the ABI of the event is up to each individual
      AFU driver.
      
      Signed-off-by: default avatarPhilippe Bergheaud <felix@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      b810253b
  19. May 11, 2016
    • Ian Munsie's avatar
      cxl: Add kernel API to allow a context to operate with relocate disabled · 7a0d85d3
      Ian Munsie authored
      
      cxl devices typically access memory using an MMU in much the same way as
      the CPU, and each context includes a state register much like the MSR in
      the CPU. Like the CPU, the state register includes a bit to enable
      relocation, which we currently always enable.
      
      In some cases, it may be desirable to allow a device to access memory
      using real addresses instead of effective addresses, so this adds a new
      API, cxl_set_translation_mode, that can be used to disable relocation
      on a given kernel context. This can allow for the creation of a special
      privileged context that the device can use if it needs relocation
      disabled, and can use regular contexts at times when it needs relocation
      enabled.
      
      This interface is only available to users of the kernel API for obvious
      reasons, and will never be supported in a virtualised environment.
      
      This will be used by the upcoming cxl support in the mlx5 driver.
      
      Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      7a0d85d3
  20. Mar 09, 2016
Loading