common/mlx5: introduce layer for multiple class drivers
[dpdk.git] / drivers / common / mlx5 / mlx5_common_pci.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4
5 #ifndef _MLX5_COMMON_PCI_H_
6 #define _MLX5_COMMON_PCI_H_
7
8 /**
9  * @file
10  *
11  * RTE Mellanox PCI Driver Interface
12  * Mellanox ConnectX PCI device supports multiple class (net/vdpa/regex)
13  * devices. This layer enables creating such multiple class of devices on a
14  * single PCI device by allowing to bind multiple class specific device
15  * driver to attach to mlx5_pci driver.
16  *
17  * -----------    ------------    -------------
18  * |   mlx5  |    |   mlx5   |    |   mlx5    |
19  * | net pmd |    | vdpa pmd |    | regex pmd |
20  * -----------    ------------    -------------
21  *      \              |                 /
22  *       \             |                /
23  *        \       --------------       /
24  *         \______|   mlx5     |_____ /
25  *                | pci common |
26  *                --------------
27  *                     |
28  *                 -----------
29  *                 |   mlx5  |
30  *                 | pci dev |
31  *                 -----------
32  *
33  * - mlx5 pci driver binds to mlx5 PCI devices defined by PCI
34  *   ID table of all related mlx5 PCI devices.
35  * - mlx5 class driver such as net, vdpa, regex PMD defines its
36  *   specific PCI ID table and mlx5 bus driver probes matching
37  *   class drivers.
38  * - mlx5 pci bus driver is cental place that validates supported
39  *   class combinations.
40  */
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif /* __cplusplus */
45
46 #include <rte_pci.h>
47 #include <rte_bus_pci.h>
48
49 #include <mlx5_common.h>
50
51 void mlx5_common_pci_init(void);
52
53 /**
54  * A structure describing a mlx5 pci driver.
55  */
56 struct mlx5_pci_driver {
57         struct rte_pci_driver pci_driver;       /**< Inherit core pci driver. */
58         uint32_t driver_class;  /**< Class of this driver, enum mlx5_class */
59         TAILQ_ENTRY(mlx5_pci_driver) next;
60 };
61
62 /**
63  * Register a mlx5_pci device driver.
64  *
65  * @param driver
66  *   A pointer to a mlx5_pci_driver structure describing the driver
67  *   to be registered.
68  */
69 __rte_internal
70 void
71 mlx5_pci_driver_register(struct mlx5_pci_driver *driver);
72
73 #ifdef __cplusplus
74 }
75 #endif /* __cplusplus */
76
77 #endif /* _MLX5_COMMON_PCI_H_ */