mlx5: disable useless flows in promiscuous mode

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 <nelio.laranjeiro@6wind.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Signed-off-by: Yaacov Hazan <yaacovh@mellanox.com>
This commit is contained in:
Nelio Laranjeiro 2015-10-30 19:55:15 +01:00 committed by Thomas Monjalon
parent f2f954a838
commit 5b45c208f8
5 changed files with 54 additions and 3 deletions

View File

@ -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)

View File

@ -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;

View File

@ -538,6 +538,35 @@ priv_destroy_hash_rxqs(struct priv *priv)
priv->ind_tables = NULL;
}
/**
* 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.
*

View File

@ -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,

View File

@ -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;