[v8,00/10] Improve mlx5 PMD driver framework for multiple classes
mbox series

Message ID 20200723200910.376581-1-parav@mellanox.com
Headers show
Series
  • Improve mlx5 PMD driver framework for multiple classes
Related show

Message

Parav Pandit July 23, 2020, 8:09 p.m. UTC
This series introduces mlx5 bus to support multiple class of devices
for a single PCI device.

Motivation and example
----------------------
mlx5 PCI device supports multiple class of devices such as net, vdpa
and regex devices.

Currently only one pmd (either net or vdpa) can bind to this device.
This design limits use of PCI device only for single device class.

To support multiple classes simultaneously for a mlx5 PCI device,
mlx5 common module is extended as generic PCI PMD.
This PMD enables multiple class PMDS (net, regex, vdpa) to be loaded
on a single PCI Device.

Change description
------------------
Patch-1 Introduces RTE_BIT() macro
Patch-2 Fixed indentation for directory listing
Patch-3 Relax dependency order
Patch-4 Fixes compilation error
Patch-5 Fixes segmentation fault in regex probe error unwind path
Patch-6 Avoid using class constructor priority
Patch-7 Change class values as bits
Patch-8 Introduce mlx5 layer to support multiple class drivers
Patch-9 Migrates mlx5 net and vdpa driver to use mlx5 PCI driver API
instead of rte PCI bus API
Patch-10 Removed class check code from class drivers 

Design overview
---------------

 -----------    ------------    -------------
 |   mlx5  |    |   mlx5   |    |   mlx5    |
 | net pmd |    | vdpa pmd |    | regex pmd |
 -----------    ------------    -------------
      \              |                /
       \             |               /
        \       ---------------     /
         \______| mlx5 common |____/
                |    pmd      |
                --------------- 
                     |
                 ----------- 
                 |   mlx5  | 
                 | pci dev | 
                 ----------- 

- mlx5 common driver binds to mlx5 PCI devices defined by PCI
  ID table of all related mlx5 PCI devices.
- mlx5 class driver such as net, vdpa, regex PMD define their
  specific PCI ID tables. mlx5 common driver probes each
  individual class driver(s) for maching and enabled classes.
- mlx5 pci layer is cental place that validates supported
  class combinations.
- In future as code evolves, more device setup/cleanup and
  resource creation code moves to mlx5 PCI common driver.

Alternatives considered
-----------------------
1. Instead of creating mlx5 pci common PMD, a common driver is
implemented which exposes class registration API.
However, common PMD model fits better with existing DPDK design
similar to ifpga driver.
Class registration API need to create a new callbacks
and ID signature; instead it is better to utilize current
well defined methods.

2. Enhance pci core to allow multiple driver binding to
single rte PCI device.
This approach is not taken, because peer drivers using
one PCI device won't be aware of other's presence. This
requires cross-driver syncronization of who initializes
common resources (such as irq, eq and more).
This also requires refcounting common objects etc among
peer drivers.
Instead of layered approach delivers and allows putting
common resource sharing, setup code in common driver.
It also eliminates peer blind zone problem as bottom pci
layer provides necessary setup without any reference
counting.

3. In future mlx5 prefers to use RDMA MR cache of the mbuf
used between net and regex pmd so that same mbuf use across
multiple device can be possible.

Examples:
--------
A user who wish to use a specific class(es) provides list
of classes at command line such as,
./testpmd -w <PCI BDF>,class=net:vdpa
./testpmd -w <PCI BDF>,class=vdpa

Changelog:
v7->v8:
 - Instead of dedicated mlx5 bus driver, merged the PMD to common_mlx5
 - Avoided new RTE PRIORITY
 - Removed mlx5 common to use RTE_PRIORITY_CLASS
v6->v7:
 - Updated release notes
v5->v6:
 - Fixed compilation failure in parallel build for shared lib
v4->v5:
 - Squash the maintainers update path with other patch which adds the
   bus
 - Addressed comments from Morten Brørup
 - Renamed newly added macro to RTE_BIT64
 - Added doxygen comment section for the macro
v3->v4:
 - Fixed dma_map error unwinding flow to follow same order for unmap
v2->v3:
 - Added RTE priority for common driver initialization
 - Addressed comments from Thomas and Asaf
 - Fixed compilation error in glue wrapper
 - Moved pci_driver structure instance as first in driver
 - Removed white spaces at the end of line in diagram
 - Address commnts from Matan
 - Removed CONFIG_RTE_LIBRTE_MLX5_PCI_BUS from config files
 - Renamed mlx5_valid_class_combo to mlx5_class_combinations
 - Added cross check for class drivers to support only 3 flags for now
 - Added full stop at the end of comment block
 - Using full names in function names
 - Added new line before function name in multiple functions
 - Added example string to parse for multiple classes
 - Dropped mlx5 prefix from static function
 - Removed empty lines
 - Fixed issue to remove multiple classes for a driver
 - Using define for drv_flags at multiple places
 - Deriving drv_flags based on the class drivers
 - Fixed alignment for id_table
 - Perform dma map on best effort basis for all supported drivers
 - Dynamically build pci id table
 - Using PCI to mlx5 device helper routines
v1->v2:
 - Addressed most comments from Thomas and Gaetan.
 - Symbols starting with prefix rte_bus_pci_mlx5 may be
   confusing as it may appear as it belong to rte_bus_pci module.
   Hence it is kept as rte_bus_mlx5_pci which matches with other
   modules as mlx5_vdpa, mlx5_net.
 - Dropped 2nd patch and replace with new 6th patch.
 - Avoided new file, added macro to rte_bitops.h
 - Inheriting ret_pci_driver instead of rte_driver
 - Added design and description of the mlx5_pci bus
 - Enhanced driver to honor RTE_PCI_DRV_PROBE_AGAIN drv_flag
 - Use anonymous structure for class search and code changes around it
 - Define static for class comination array
 - Use RTE_DIM to find array size
 - Added OOM check for strdup()
 - Renamed copy variable to nstr_orig
 - Returning negagive error code
 - Returning directly if match entry found
 - Use compat condition check
 - Avoided cutting error message string
 - Use uint32_t datatype instead of enum mlx5_class
 - Changed logic to parse device arguments only once during probe()
 - Added check to fail driver probe if multiple classes register with
   DMA ops
 - Renamed function to parse_class_options
 - Migreate API from rte_driver to rte_pci_driver

Parav Pandit (7):
  eal: introduce macro for bit definition
  common/mlx5: fix void parameters in glue wrappers
  regex/mlx5: fix segmentation fault during error unwinding
  common/mlx5: avoid using class constructor priority
  common/mlx5: change class values as bits
  common/mlx5: register class drivers through common layer
  common/mlx5: remove class check from class drivers

Thomas Monjalon (3):
  drivers: fix indent of directory list
  drivers: relax dependency order
  common/mlx5: introduce layer to support multiple class drivers

 drivers/Makefile                              |  10 +-
 drivers/common/Makefile                       |   4 -
 drivers/common/meson.build                    |   2 +-
 drivers/common/mlx5/Makefile                  |   1 +
 drivers/common/mlx5/linux/mlx5_glue.h         |   4 +-
 drivers/common/mlx5/meson.build               |   9 +-
 drivers/common/mlx5/mlx5_common.c             |  52 +-
 drivers/common/mlx5/mlx5_common.h             |  12 +-
 drivers/common/mlx5/mlx5_common_pci.c         | 539 ++++++++++++++++++
 drivers/common/mlx5/mlx5_common_pci.h         |  77 +++
 .../common/mlx5/rte_common_mlx5_version.map   |   4 +-
 drivers/meson.build                           |  51 +-
 drivers/net/mlx5/Makefile                     |   1 -
 drivers/net/mlx5/linux/mlx5_os.c              |   6 -
 drivers/net/mlx5/mlx5.c                       |  25 +-
 drivers/net/mlx5/mlx5.h                       |   1 -
 drivers/regex/mlx5/meson.build                |   2 +-
 drivers/regex/mlx5/mlx5_regex.c               |  29 +-
 drivers/vdpa/mlx5/Makefile                    |   3 +-
 drivers/vdpa/mlx5/meson.build                 |   2 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  29 +-
 lib/librte_eal/include/rte_bitops.h           |   8 +
 22 files changed, 748 insertions(+), 123 deletions(-)
 create mode 100644 drivers/common/mlx5/mlx5_common_pci.c
 create mode 100644 drivers/common/mlx5/mlx5_common_pci.h