From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id C353A926B for ; Fri, 30 Oct 2015 19:56:16 +0100 (CET) Received: by wmec75 with SMTP id c75so19176293wme.1 for ; Fri, 30 Oct 2015 11:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GjUn00skyISRXltTmxp5IIYaNCC+HNBALdNOvpHb+ZA=; b=tNkdjnoVaufhjwSLta9+x8SOImy0m2LK0mvZp3TZMnJVgZgj7OsxgntmLoz3Dutfd9 dhXZWrLvp4d6FONXpZ/iXrZVxVXKkclCpedAIE8TJUKfCIXJ/ydRwmrUZIsIBpf2iogP xL0tzkIGtVmKcJP8kdJo2bJFOW1A05bED6W9hoKLG+npogFbbHRP0l/Mhy3k6AQhuvzM /pvs2Nxz27WIH5Jr7AeYY9Vb1sQ/TfczDTwltJg+a010LQ+haHbuRhj/XE+ufwSFz2F2 rsKedOVdZmQC8K14saNrdsoM7f14vaukoYieK+qb4wB4TBTMFnboos5qNOQztZtqpjll eogw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GjUn00skyISRXltTmxp5IIYaNCC+HNBALdNOvpHb+ZA=; b=i6fRR0TOOhWZ700faadKJnUlGcgHY+e1ItgZGdM+IR2gwA1Dktp2TecrMy6ecEl6io S7llfA+07ekpC1F+8PYamIn51nVwWJYhK49uPkhB5B4t17+rHvS58f9BffkQV5abUkKT sXn9P3PMb7Cw4sU16X2c0Wqs2w0jqLhqgP4fVxwKNsaud6WJc/CSTfadoQ1m8LTvVuuf MBMBASlUgg0BSFrATTwGxVyRVPtW+qpngRneN18GwS9fJeAaosMGSWrn4dVh6+iK8GYN LpOp+GV9ouly5osyDlv4TCyyj+kMGV12MVLbjotFEmat3C0YqaPt4YQjx2fybIKRmtfP KTGg== X-Gm-Message-State: ALoCoQm7U3HkpIN6/FyWN069Jfkp8l/axIhZE89jsm2g65JHHa2l7sIQXlFg3ORyp6vw+d3B8i7w X-Received: by 10.28.87.67 with SMTP id l64mr4911542wmb.72.1446231376643; Fri, 30 Oct 2015 11:56:16 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id b12sm4227328wma.6.2015.10.30.11.56.15 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 30 Oct 2015 11:56:16 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 30 Oct 2015 19:55:15 +0100 Message-Id: <1446231319-8185-13-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446231319-8185-1-git-send-email-adrien.mazarguil@6wind.com> References: <1444067692-29645-1-git-send-email-adrien.mazarguil@6wind.com> <1446231319-8185-1-git-send-email-adrien.mazarguil@6wind.com> Cc: Yaacov Hazan Subject: [dpdk-dev] [PATCH v2 12/16] mlx5: disable useless flows in promiscuous mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2015 18:56:16 -0000 From: Nelio Laranjeiro Only a single flow per hash RX queue is needed in promiscuous mode. Disable others to free up hardware resources. Signed-off-by: Nelio Laranjeiro Signed-off-by: Adrien Mazarguil Signed-off-by: Yaacov Hazan --- drivers/net/mlx5/mlx5_mac.c | 5 +++++ drivers/net/mlx5/mlx5_rxmode.c | 10 ++++++++++ drivers/net/mlx5/mlx5_rxq.c | 29 +++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.h | 7 +++++++ drivers/net/mlx5/mlx5_trigger.c | 6 +++--- 5 files changed, 54 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index d3ab5b9..c7927c1 100644 --- a/drivers/net/mlx5/mlx5_mac.c +++ b/drivers/net/mlx5/mlx5_mac.c @@ -410,6 +410,8 @@ priv_mac_addr_add(struct priv *priv, unsigned int mac_index, (*mac)[3], (*mac)[4], (*mac)[5] } }; + if (!priv_allow_flow_type(priv, HASH_RXQ_FLOW_TYPE_MAC)) + goto end; for (i = 0; (i != priv->hash_rxqs_n); ++i) { ret = hash_rxq_mac_addr_add(&(*priv->hash_rxqs)[i], mac_index); if (!ret) @@ -420,6 +422,7 @@ priv_mac_addr_add(struct priv *priv, unsigned int mac_index, mac_index); return ret; } +end: BITFIELD_SET(priv->mac_configured, mac_index); return 0; } @@ -439,6 +442,8 @@ priv_mac_addrs_enable(struct priv *priv) unsigned int i; int ret; + if (!priv_allow_flow_type(priv, HASH_RXQ_FLOW_TYPE_MAC)) + return 0; for (i = 0; (i != priv->hash_rxqs_n); ++i) { ret = hash_rxq_mac_addrs_add(&(*priv->hash_rxqs)[i]); if (!ret) diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 7794608..f7de1b8 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -113,6 +113,8 @@ priv_promiscuous_enable(struct priv *priv) { unsigned int i; + if (!priv_allow_flow_type(priv, HASH_RXQ_FLOW_TYPE_PROMISC)) + return 0; for (i = 0; (i != priv->hash_rxqs_n); ++i) { struct hash_rxq *hash_rxq = &(*priv->hash_rxqs)[i]; int ret; @@ -147,6 +149,10 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev) ret = priv_promiscuous_enable(priv); if (ret) ERROR("cannot enable promiscuous mode: %s", strerror(ret)); + else { + priv_mac_addrs_disable(priv); + priv_allmulticast_disable(priv); + } priv_unlock(priv); } @@ -196,6 +202,8 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev) priv_lock(priv); priv->promisc_req = 0; priv_promiscuous_disable(priv); + priv_mac_addrs_enable(priv); + priv_allmulticast_enable(priv); priv_unlock(priv); } @@ -266,6 +274,8 @@ priv_allmulticast_enable(struct priv *priv) { unsigned int i; + if (!priv_allow_flow_type(priv, HASH_RXQ_FLOW_TYPE_ALLMULTI)) + return 0; for (i = 0; (i != priv->hash_rxqs_n); ++i) { struct hash_rxq *hash_rxq = &(*priv->hash_rxqs)[i]; int ret; diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index d46fc13..bdd5429 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -539,6 +539,35 @@ priv_destroy_hash_rxqs(struct priv *priv) } /** + * Check whether a given flow type is allowed. + * + * @param priv + * Pointer to private structure. + * @param type + * Flow type to check. + * + * @return + * Nonzero if the given flow type is allowed. + */ +int +priv_allow_flow_type(struct priv *priv, enum hash_rxq_flow_type type) +{ + /* Only FLOW_TYPE_PROMISC is allowed when promiscuous mode + * has been requested. */ + if (priv->promisc_req) + return (type == HASH_RXQ_FLOW_TYPE_PROMISC); + switch (type) { + case HASH_RXQ_FLOW_TYPE_PROMISC: + return !!priv->promisc_req; + case HASH_RXQ_FLOW_TYPE_ALLMULTI: + return !!priv->allmulti_req; + case HASH_RXQ_FLOW_TYPE_MAC: + return 1; + } + return 0; +} + +/** * Allocate RX queue elements with scattered packets support. * * @param rxq diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 651eb95..dc23f4f 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -159,6 +159,12 @@ struct ind_table_init { unsigned int hash_types_n; }; +enum hash_rxq_flow_type { + HASH_RXQ_FLOW_TYPE_MAC, + HASH_RXQ_FLOW_TYPE_PROMISC, + HASH_RXQ_FLOW_TYPE_ALLMULTI, +}; + struct hash_rxq { struct priv *priv; /* Back pointer to private data. */ struct ibv_qp *qp; /* Hash RX QP. */ @@ -223,6 +229,7 @@ size_t hash_rxq_flow_attr(const struct hash_rxq *, struct ibv_flow_attr *, size_t); int priv_create_hash_rxqs(struct priv *); void priv_destroy_hash_rxqs(struct priv *); +int priv_allow_flow_type(struct priv *, enum hash_rxq_flow_type); void rxq_cleanup(struct rxq *); int rxq_rehash(struct rte_eth_dev *, struct rxq *); int rxq_setup(struct rte_eth_dev *, struct rxq *, uint16_t, unsigned int, diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 233c0d8..68e00a0 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -70,10 +70,10 @@ mlx5_dev_start(struct rte_eth_dev *dev) DEBUG("%p: allocating and configuring hash RX queues", (void *)dev); err = priv_create_hash_rxqs(priv); if (!err) - err = priv_mac_addrs_enable(priv); - if (!err && priv->promisc_req) err = priv_promiscuous_enable(priv); - if (!err && priv->allmulti_req) + if (!err) + err = priv_mac_addrs_enable(priv); + if (!err) err = priv_allmulticast_enable(priv); if (!err) priv->started = 1; -- 2.1.0