net/ngbe: support MAC filters
[dpdk.git] / drivers / net / mlx5 / mlx5_devx.c
index 6b6b9c7..7ed774e 100644 (file)
@@ -102,9 +102,9 @@ mlx5_devx_modify_rq(struct mlx5_rxq_obj *rxq_obj, uint8_t type)
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-static int
-mlx5_devx_modify_sq(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type,
-                   uint8_t dev_port)
+int
+mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type,
+                    uint8_t dev_port)
 {
        struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
        int ret;
@@ -889,6 +889,37 @@ mlx5_devx_drop_action_destroy(struct rte_eth_dev *dev)
        rte_errno = ENOTSUP;
 }
 
+/**
+ * Select TXQ TIS number.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param queue_idx
+ *   Queue index in DPDK Tx queue array.
+ *
+ * @return
+ *   > 0 on success, a negative errno value otherwise.
+ */
+static uint32_t
+mlx5_get_txq_tis_num(struct rte_eth_dev *dev, uint16_t queue_idx)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+       int tis_idx;
+
+       if (priv->sh->bond.n_port && priv->sh->lag.affinity_mode ==
+                       MLX5_LAG_MODE_TIS) {
+               tis_idx = (priv->lag_affinity_idx + queue_idx) %
+                       priv->sh->bond.n_port;
+               DRV_LOG(INFO, "port %d txq %d gets affinity %d and maps to PF %d.",
+                       dev->data->port_id, queue_idx, tis_idx + 1,
+                       priv->sh->lag.tx_remap_affinity[tis_idx]);
+       } else {
+               tis_idx = 0;
+       }
+       MLX5_ASSERT(priv->sh->tis[tis_idx]);
+       return priv->sh->tis[tis_idx]->id;
+}
+
 /**
  * Create the Tx hairpin queue object.
  *
@@ -936,7 +967,8 @@ mlx5_txq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx)
        attr.wq_attr.log_hairpin_num_packets =
                        attr.wq_attr.log_hairpin_data_sz -
                        MLX5_HAIRPIN_QUEUE_STRIDE;
-       attr.tis_num = priv->sh->tis->id;
+
+       attr.tis_num = mlx5_get_txq_tis_num(dev, idx);
        tmpl->sq = mlx5_devx_cmd_create_sq(priv->sh->cdev->ctx, &attr);
        if (!tmpl->sq) {
                DRV_LOG(ERR,
@@ -994,7 +1026,6 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx,
                .allow_swp = !!priv->config.swp,
                .cqn = txq_obj->cq_obj.cq->id,
                .tis_lst_sz = 1,
-               .tis_num = priv->sh->tis->id,
                .wq_attr = (struct mlx5_devx_wq_attr){
                        .pd = cdev->pdn,
                        .uar_page =
@@ -1002,7 +1033,9 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx,
                },
                .ts_format =
                        mlx5_ts_format_conv(cdev->config.hca_attr.sq_ts_format),
+               .tis_num = mlx5_get_txq_tis_num(dev, idx),
        };
+
        /* Create Send Queue object with DevX. */
        return mlx5_devx_sq_create(cdev->ctx, &txq_obj->sq_obj,
                                   log_desc_n, &sq_attr, priv->sh->numa_node);
@@ -1121,7 +1154,7 @@ mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
        *txq_data->qp_db = 0;
        txq_data->qp_num_8s = txq_obj->sq_obj.sq->id << 8;
        /* Change Send Queue state to Ready-to-Send. */
-       ret = mlx5_devx_modify_sq(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0);
+       ret = mlx5_txq_devx_modify(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0);
        if (ret) {
                rte_errno = errno;
                DRV_LOG(ERR,
@@ -1190,7 +1223,7 @@ struct mlx5_obj_ops devx_obj_ops = {
        .drop_action_create = mlx5_devx_drop_action_create,
        .drop_action_destroy = mlx5_devx_drop_action_destroy,
        .txq_obj_new = mlx5_txq_devx_obj_new,
-       .txq_obj_modify = mlx5_devx_modify_sq,
+       .txq_obj_modify = mlx5_txq_devx_modify,
        .txq_obj_release = mlx5_txq_devx_obj_release,
        .lb_dummy_queue_create = NULL,
        .lb_dummy_queue_release = NULL,