From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 17F632BAF for ; Sun, 2 Jul 2017 14:33:19 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from vasilyf@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Jul 2017 15:32:45 +0300 Received: from hpchead.mtr.labs.mlnx. (hpchead.mtr.labs.mlnx [10.209.44.59]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v62CWj8f004329; Sun, 2 Jul 2017 15:32:45 +0300 Received: from hpchead.mtr.labs.mlnx. (localhost.localdomain [127.0.0.1]) by hpchead.mtr.labs.mlnx. (8.14.7/8.14.7) with ESMTP id v62CWj0K003737; Sun, 2 Jul 2017 15:32:45 +0300 Received: (from vasilyf@localhost) by hpchead.mtr.labs.mlnx. (8.14.7/8.14.7/Submit) id v62CWicQ003723; Sun, 2 Jul 2017 15:32:44 +0300 From: Vasily Philipov To: dev@dpdk.org Cc: Vasily Philipov , Adrien Mazarguil , Nelio Laranjeiro Date: Sun, 2 Jul 2017 15:32:37 +0300 Message-Id: <79bb8458a94231bd214cb7a379a771bed13ab6ef.1498988087.git.vasilyf@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <225679c202aa0bae5c61882aef6c8117a9074029.1498988087.git.vasilyf@mellanox.com> References: <225679c202aa0bae5c61882aef6c8117a9074029.1498988087.git.vasilyf@mellanox.com> In-Reply-To: <0dca86aa1372d6ff09d0aff01d522c580e0e24ab.1495717153.git.vasilyf@mellanox.com> References: <0dca86aa1372d6ff09d0aff01d522c580e0e24ab.1495717153.git.vasilyf@mellanox.com> Subject: [dpdk-dev] [PATCH v6 3/4] net/mlx4: implement isolated mode from flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jul 2017 12:33:20 -0000 The user must request isolated mode before device configuration, the default RSS ring isn't created in this case. Signed-off-by: Vasily Philipov --- drivers/net/mlx4/mlx4.c | 58 +++++++++++++++++++++++++++++++++++--------- drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_flow.c | 37 ++++++++++++++++++++++++++++ drivers/net/mlx4/mlx4_flow.h | 5 ++++ 4 files changed, 90 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 96f88c6..afad2be 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -666,7 +666,7 @@ void priv_unlock(struct priv *priv) } if (rxqs_n == priv->rxqs_n) return 0; - if (!rte_is_power_of_2(rxqs_n)) { + if (!rte_is_power_of_2(rxqs_n) && !priv->isolated) { unsigned n_active; n_active = rte_align32pow2(rxqs_n + 1) >> 1; @@ -710,6 +710,8 @@ void priv_unlock(struct priv *priv) priv->rss = 1; tmp = priv->rxqs_n; priv->rxqs_n = rxqs_n; + if (priv->isolated) + return 0; ret = priv_parent_create(priv, NULL, priv->rxqs_n); if (!ret) return 0; @@ -2596,6 +2598,7 @@ struct txq_mp2mr_mbuf_check_data { { unsigned int i; + assert(!priv->isolated); assert(mac_index < elemof(priv->mac)); if (!BITFIELD_ISSET(priv->mac_configured, mac_index)) return; @@ -2845,7 +2848,7 @@ struct txq_mp2mr_mbuf_check_data { rxq->if_cq, ¶ms)); } - if (rxq->qp != NULL) { + if (rxq->qp != NULL && !rxq->priv->isolated) { rxq_promiscuous_disable(rxq); rxq_allmulticast_disable(rxq); rxq_mac_addrs_del(rxq); @@ -3548,7 +3551,7 @@ struct txq_mp2mr_mbuf_check_data { return 0; } /* Remove attached flows if RSS is disabled (no parent queue). */ - if (!priv->rss) { + if (!priv->rss && !priv->isolated) { rxq_allmulticast_disable(&tmpl); rxq_promiscuous_disable(&tmpl); rxq_mac_addrs_del(&tmpl); @@ -3593,7 +3596,7 @@ struct txq_mp2mr_mbuf_check_data { return err; } /* Reconfigure flows. Do not care for errors. */ - if (!priv->rss) { + if (!priv->rss && !priv->isolated) { rxq_mac_addrs_add(&tmpl); if (priv->promisc) rxq_promiscuous_enable(&tmpl); @@ -3752,7 +3755,7 @@ struct txq_mp2mr_mbuf_check_data { strerror(ret)); return ret; } - if (parent || !priv->rss) { + if (!priv->isolated && (parent || !priv->rss)) { /* Configure MAC and broadcast addresses. */ ret = rxq_mac_addrs_add(rxq); if (ret) { @@ -4042,7 +4045,7 @@ struct txq_mp2mr_mbuf_check_data { return -ENOMEM; } } - if (priv->rss) { + if (priv->rss && !priv->isolated) { /* The list consists of the single default one. */ parent = LIST_FIRST(&priv->parents); if (idx >= rte_align32pow2(priv->rxqs_n + 1) >> 1) @@ -4138,7 +4141,10 @@ struct txq_mp2mr_mbuf_check_data { } DEBUG("%p: attaching configured flows to all RX queues", (void *)dev); priv->started = 1; - if (priv->rss) { + if (priv->isolated) { + rxq = NULL; + r = 1; + } else if (priv->rss) { rxq = LIST_FIRST(&priv->parents); r = 1; } else { @@ -4226,7 +4232,10 @@ struct txq_mp2mr_mbuf_check_data { } DEBUG("%p: detaching flows from all RX queues", (void *)dev); priv->started = 0; - if (priv->rss) { + if (priv->isolated) { + rxq = NULL; + r = 1; + } else if (priv->rss) { rxq = LIST_FIRST(&priv->parents); r = 1; } else { @@ -4658,6 +4667,8 @@ struct txq_mp2mr_mbuf_check_data { if (mlx4_is_secondary()) return; priv_lock(priv); + if (priv->isolated) + goto end; DEBUG("%p: removing MAC address from index %" PRIu32, (void *)dev, index); /* Last array entry is reserved for broadcast. */ @@ -4691,6 +4702,12 @@ struct txq_mp2mr_mbuf_check_data { return -ENOTSUP; (void)vmdq; priv_lock(priv); + if (priv->isolated) { + DEBUG("%p: cannot add MAC address, " + "device is in isolated mode", (void *)dev); + re = EPERM; + goto end; + } DEBUG("%p: adding MAC address at index %" PRIu32, (void *)dev, index); /* Last array entry is reserved for broadcast. */ @@ -4738,6 +4755,12 @@ struct txq_mp2mr_mbuf_check_data { if (mlx4_is_secondary()) return; priv_lock(priv); + if (priv->isolated) { + DEBUG("%p: cannot enable promiscuous, " + "device is in isolated mode", (void *)dev); + priv_unlock(priv); + return; + } if (priv->promisc) { priv_unlock(priv); return; @@ -4786,7 +4809,7 @@ struct txq_mp2mr_mbuf_check_data { if (mlx4_is_secondary()) return; priv_lock(priv); - if (!priv->promisc) { + if (!priv->promisc || priv->isolated) { priv_unlock(priv); return; } @@ -4818,6 +4841,12 @@ struct txq_mp2mr_mbuf_check_data { if (mlx4_is_secondary()) return; priv_lock(priv); + if (priv->isolated) { + DEBUG("%p: cannot enable allmulticast, " + "device is in isolated mode", (void *)dev); + priv_unlock(priv); + return; + } if (priv->allmulti) { priv_unlock(priv); return; @@ -4870,7 +4899,7 @@ struct txq_mp2mr_mbuf_check_data { priv_unlock(priv); return; } - if (priv->rss) { + if (priv->rss && !priv->isolated) { rxq_allmulticast_disable(LIST_FIRST(&priv->parents)); goto end; } @@ -5009,7 +5038,7 @@ struct txq_mp2mr_mbuf_check_data { } /* Reenable non-RSS queue attributes. No need to check * for errors at this stage. */ - if (!priv->rss) { + if (!priv->rss && !priv->isolated) { rxq_mac_addrs_add(rxq); if (priv->promisc) rxq_promiscuous_enable(rxq); @@ -5244,6 +5273,12 @@ struct txq_mp2mr_mbuf_check_data { if (mlx4_is_secondary()) return -E_RTE_SECONDARY; priv_lock(priv); + if (priv->isolated) { + DEBUG("%p: cannot set vlan filter, " + "device is in isolated mode", (void *)dev); + priv_unlock(priv); + return -EINVAL; + } ret = vlan_filter_set(dev, vlan_id, on); priv_unlock(priv); assert(ret >= 0); @@ -5256,6 +5291,7 @@ struct txq_mp2mr_mbuf_check_data { .destroy = mlx4_flow_destroy, .flush = mlx4_flow_flush, .query = NULL, + .isolate = mlx4_flow_isolate, }; /** diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 40e1bad..6de3484 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -340,6 +340,7 @@ struct priv { unsigned int rss:1; /* RSS is enabled. */ unsigned int vf:1; /* This is a VF device. */ unsigned int pending_alarm:1; /* An alarm is pending. */ + unsigned int isolated:1; /* Toggle isolated mode. */ #ifdef INLINE_RECV unsigned int inl_recv_size; /* Inline recv size */ #endif diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index edfac03..5ad50bd 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -957,6 +957,43 @@ struct rte_flow * } /** + * @see rte_flow_isolate() + * + * Must be done before calling dev_configure(). + * + * @param dev + * Pointer to the ethernet device structure. + * @param enable + * Nonzero to enter isolated mode, attempt to leave it otherwise. + * @param[out] error + * Perform verbose error reporting if not NULL. PMDs initialize this + * structure in case of error only. + * + * @return + * 0 on success, a negative value on error. + */ +int +mlx4_flow_isolate(struct rte_eth_dev *dev, + int enable, + struct rte_flow_error *error) +{ + struct priv *priv = dev->data->dev_private; + + priv_lock(priv); + if (priv->rxqs) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "isolated mode must be set" + " before configuring the device"); + priv_unlock(priv); + return -rte_errno; + } + priv->isolated = !!enable; + priv_unlock(priv); + return 0; +} + +/** * Destroy a flow. * * @param priv diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 12a293e..4d007da 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -90,6 +90,11 @@ struct mlx4_flow { unsigned int offset; /**< Offset in bytes in the ibv_attr buffer. */ }; +int +mlx4_flow_isolate(struct rte_eth_dev *dev, + int enable, + struct rte_flow_error *error); + struct mlx4_flow_action { uint32_t drop:1; /**< Target is a drop queue. */ uint32_t queue:1; /**< Target is a receive queue. */ -- 1.8.3.1