common/mlx5: fix device list operations concurrency
[dpdk.git] / drivers / common / mlx5 / mlx5_common.h
index 83b6cfc..a772371 100644 (file)
@@ -10,6 +10,7 @@
 #include <rte_pci.h>
 #include <rte_debug.h>
 #include <rte_atomic.h>
+#include <rte_rwlock.h>
 #include <rte_log.h>
 #include <rte_kvargs.h>
 #include <rte_devargs.h>
@@ -24,6 +25,7 @@
 
 /* Reported driver name. */
 #define MLX5_PCI_DRIVER_NAME "mlx5_pci"
+#define MLX5_AUXILIARY_DRIVER_NAME "mlx5_auxiliary"
 
 /* Bit-field manipulation. */
 #define BITFIELD_DECLARE(bf, type, size) \
@@ -109,6 +111,7 @@ pmd_drv_log_basename(const char *s)
        int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \
        char name[mkstr_size_##name + 1]; \
        \
+       memset(name, 0, mkstr_size_##name + 1); \
        snprintf(name, sizeof(name), "" __VA_ARGS__)
 
 enum {
@@ -204,6 +207,20 @@ check_cqe(volatile struct mlx5_cqe *cqe, const uint16_t cqes_n,
        return MLX5_CQE_STATUS_SW_OWN;
 }
 
+/*
+ * Get PCI address <DBDF> string from EAL device.
+ *
+ * @param[out] addr
+ *     The output address buffer string
+ * @param[in] size
+ *     The output buffer size
+ * @return
+ *   - 0 on success.
+ *   - Negative value and rte_errno is set otherwise.
+ */
+__rte_internal
+int mlx5_dev_to_pci_str(const struct rte_device *dev, char *addr, size_t size);
+
 /*
  * Get PCI address from sysfs of a PCI-related device.
  *
@@ -218,7 +235,7 @@ check_cqe(volatile struct mlx5_cqe *cqe, const uint16_t cqes_n,
  *   - Negative value and rte_errno is set otherwise.
  */
 __rte_internal
-int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
+int mlx5_get_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
 
 /*
  * Get kernel network interface name from sysfs IB device path.
@@ -235,6 +252,9 @@ int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
 __rte_internal
 int mlx5_get_ifname_sysfs(const char *ibdev_path, char *ifname);
 
+__rte_internal
+int mlx5_auxiliary_get_child_name(const char *dev, const char *node,
+                                 char *child, size_t size);
 
 enum mlx5_class {
        MLX5_CLASS_INVALID,