net/mlx5: fix allocation when no memory on device NUMA node
[dpdk.git] / drivers / net / mlx5 / mlx5.h
index 04f0b25..a7ec607 100644 (file)
@@ -53,7 +53,7 @@
 
 #include <rte_pci.h>
 #include <rte_ether.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_spinlock.h>
 #include <rte_interrupts.h>
 #include <rte_errno.h>
@@ -110,9 +110,9 @@ struct mlx5_dev_config {
        unsigned int sriov:1; /* This is a VF or PF with VF devices. */
        unsigned int mps:2; /* Multi-packet send supported mode. */
        unsigned int tunnel_en:1; /* Whether tunnel is supported. */
-       unsigned int counter_set_supported:1; /* Counter set is supported. */
+       unsigned int flow_counter_en:1; /* Whether flow counter is supported. */
        unsigned int cqe_comp:1; /* CQE compression is enabled. */
-       unsigned int tso:1; /* Whether TSO is enabled. */
+       unsigned int tso:1; /* Whether TSO is supported. */
        unsigned int tx_vec_en:1; /* Tx vector is enabled. */
        unsigned int rx_vec_en:1; /* Rx vector is enabled. */
        unsigned int mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
@@ -123,6 +123,24 @@ struct mlx5_dev_config {
        int inline_max_packet_sz; /* Max packet size for inlining. */
 };
 
+/**
+ * Type of objet being allocated.
+ */
+enum mlx5_verbs_alloc_type {
+       MLX5_VERBS_ALLOC_TYPE_NONE,
+       MLX5_VERBS_ALLOC_TYPE_TX_QUEUE,
+       MLX5_VERBS_ALLOC_TYPE_RX_QUEUE,
+};
+
+/**
+ * Verbs allocator needs a context to know in the callback which kind of
+ * resources it is allocating.
+ */
+struct mlx5_verbs_alloc_ctx {
+       enum mlx5_verbs_alloc_type type; /* Kind of object being allocated. */
+       const void *obj; /* Pointer to the DPDK object. */
+};
+
 struct priv {
        struct rte_eth_dev *dev; /* Ethernet device of master process. */
        struct ibv_context *ctx; /* Verbs context. */
@@ -164,6 +182,8 @@ struct priv {
        int primary_socket; /* Unix socket for primary process. */
        struct rte_intr_handle intr_handle_socket; /* Interrupt handler. */
        struct mlx5_dev_config config; /* Device configuration. */
+       struct mlx5_verbs_alloc_ctx verbs_alloc_ctx;
+       /* Context for Verbs allocator. */
 };
 
 /**
@@ -179,6 +199,22 @@ priv_lock(struct priv *priv)
        rte_spinlock_lock(&priv->lock);
 }
 
+/**
+ * Try to lock private structure to protect it from concurrent access in the
+ * control path.
+ *
+ * @param priv
+ *   Pointer to private structure.
+ *
+ * @return
+ *   1 if the lock is successfully taken; 0 otherwise.
+ */
+static inline int
+priv_trylock(struct priv *priv)
+{
+       return rte_spinlock_trylock(&priv->lock);
+}
+
 /**
  * Unlock private structure.
  *
@@ -209,6 +245,7 @@ int priv_set_flags(struct priv *, unsigned int, unsigned int);
 int mlx5_dev_configure(struct rte_eth_dev *);
 void mlx5_dev_infos_get(struct rte_eth_dev *, struct rte_eth_dev_info *);
 const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+int priv_link_update(struct priv *, int);
 int mlx5_link_update(struct rte_eth_dev *, int);
 int mlx5_dev_set_mtu(struct rte_eth_dev *, uint16_t);
 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *);
@@ -221,6 +258,7 @@ void priv_dev_interrupt_handler_uninstall(struct priv *, struct rte_eth_dev *);
 void priv_dev_interrupt_handler_install(struct priv *, struct rte_eth_dev *);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
+int mlx5_is_removed(struct rte_eth_dev *dev);
 eth_tx_burst_t priv_select_tx_function(struct priv *, struct rte_eth_dev *);
 eth_rx_burst_t priv_select_rx_function(struct priv *, struct rte_eth_dev *);