2018-01-29 13:11:30 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright 2015 6WIND S.A.
|
2018-03-20 19:20:35 +00:00
|
|
|
* Copyright 2015 Mellanox Technologies, Ltd
|
2015-10-30 18:52:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2021-01-29 16:48:19 +00:00
|
|
|
#include <ethdev_driver.h>
|
2015-10-30 18:52:37 +00:00
|
|
|
|
2020-07-19 10:18:16 +00:00
|
|
|
#include <mlx5_glue.h>
|
2015-10-30 18:52:37 +00:00
|
|
|
#include "mlx5.h"
|
|
|
|
#include "mlx5_utils.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DPDK callback to enable promiscuous mode.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
2019-09-14 11:37:24 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:37 +00:00
|
|
|
*/
|
2019-09-14 11:37:24 +00:00
|
|
|
int
|
2015-10-30 18:52:37 +00:00
|
|
|
mlx5_promiscuous_enable(struct rte_eth_dev *dev)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-03-05 12:21:06 +00:00
|
|
|
int ret;
|
|
|
|
|
2017-10-09 14:44:53 +00:00
|
|
|
dev->data->promiscuous = 1;
|
2018-08-02 21:06:31 +00:00
|
|
|
if (priv->isolated) {
|
|
|
|
DRV_LOG(WARNING,
|
|
|
|
"port %u cannot enable promiscuous mode"
|
|
|
|
" in flow isolation mode",
|
|
|
|
dev->data->port_id);
|
2019-09-14 11:37:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-02-14 09:35:06 +00:00
|
|
|
if (priv->sh->dev_cap.vf || priv->sh->dev_cap.sf) {
|
2020-07-19 10:18:12 +00:00
|
|
|
ret = mlx5_os_set_promisc(dev, 1);
|
2019-09-14 11:37:24 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-08-02 21:06:31 +00:00
|
|
|
}
|
2018-03-05 12:21:06 +00:00
|
|
|
ret = mlx5_traffic_restart(dev);
|
|
|
|
if (ret)
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
|
|
|
|
dev->data->port_id, strerror(rte_errno));
|
2019-09-14 11:37:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rte_eth_dev_promiscuous_enable() rollback
|
|
|
|
* dev->data->promiscuous in the case of failure.
|
|
|
|
*/
|
|
|
|
return ret;
|
2015-10-30 18:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DPDK callback to disable promiscuous mode.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
2019-09-14 11:37:24 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:37 +00:00
|
|
|
*/
|
2019-09-14 11:37:24 +00:00
|
|
|
int
|
2015-10-30 18:52:37 +00:00
|
|
|
mlx5_promiscuous_disable(struct rte_eth_dev *dev)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-03-05 12:21:06 +00:00
|
|
|
int ret;
|
|
|
|
|
2017-10-09 14:44:53 +00:00
|
|
|
dev->data->promiscuous = 0;
|
2022-02-14 09:35:06 +00:00
|
|
|
if (priv->sh->dev_cap.vf || priv->sh->dev_cap.sf) {
|
2020-07-19 10:18:12 +00:00
|
|
|
ret = mlx5_os_set_promisc(dev, 0);
|
2019-09-14 11:37:24 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2018-03-05 12:21:06 +00:00
|
|
|
ret = mlx5_traffic_restart(dev);
|
|
|
|
if (ret)
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
|
|
|
|
dev->data->port_id, strerror(rte_errno));
|
2019-09-14 11:37:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rte_eth_dev_promiscuous_disable() rollback
|
|
|
|
* dev->data->promiscuous in the case of failure.
|
|
|
|
*/
|
|
|
|
return ret;
|
2015-10-30 18:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DPDK callback to enable allmulti mode.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
2019-09-24 12:56:10 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:37 +00:00
|
|
|
*/
|
2019-09-24 12:56:10 +00:00
|
|
|
int
|
2015-10-30 18:52:37 +00:00
|
|
|
mlx5_allmulticast_enable(struct rte_eth_dev *dev)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-03-05 12:21:06 +00:00
|
|
|
int ret;
|
|
|
|
|
2017-10-09 14:44:54 +00:00
|
|
|
dev->data->all_multicast = 1;
|
2018-08-02 21:06:32 +00:00
|
|
|
if (priv->isolated) {
|
|
|
|
DRV_LOG(WARNING,
|
|
|
|
"port %u cannot enable allmulticast mode"
|
|
|
|
" in flow isolation mode",
|
|
|
|
dev->data->port_id);
|
2019-09-24 12:56:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-02-14 09:35:06 +00:00
|
|
|
if (priv->sh->dev_cap.vf || priv->sh->dev_cap.sf) {
|
2020-07-19 10:18:12 +00:00
|
|
|
ret = mlx5_os_set_allmulti(dev, 1);
|
2019-09-24 12:56:10 +00:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
2018-08-02 21:06:32 +00:00
|
|
|
}
|
2018-03-05 12:21:06 +00:00
|
|
|
ret = mlx5_traffic_restart(dev);
|
|
|
|
if (ret)
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
|
|
|
|
dev->data->port_id, strerror(rte_errno));
|
2019-09-24 12:56:10 +00:00
|
|
|
error:
|
|
|
|
/*
|
|
|
|
* rte_eth_allmulticast_enable() rollback
|
|
|
|
* dev->data->all_multicast in the case of failure.
|
|
|
|
*/
|
|
|
|
return ret;
|
2015-10-30 18:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DPDK callback to disable allmulti mode.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
2019-09-24 12:56:10 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:37 +00:00
|
|
|
*/
|
2019-09-24 12:56:10 +00:00
|
|
|
int
|
2015-10-30 18:52:37 +00:00
|
|
|
mlx5_allmulticast_disable(struct rte_eth_dev *dev)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-03-05 12:21:06 +00:00
|
|
|
int ret;
|
|
|
|
|
2017-10-09 14:44:54 +00:00
|
|
|
dev->data->all_multicast = 0;
|
2022-02-14 09:35:06 +00:00
|
|
|
if (priv->sh->dev_cap.vf || priv->sh->dev_cap.sf) {
|
2020-07-19 10:18:12 +00:00
|
|
|
ret = mlx5_os_set_allmulti(dev, 0);
|
2019-09-24 12:56:10 +00:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2018-03-05 12:21:06 +00:00
|
|
|
ret = mlx5_traffic_restart(dev);
|
|
|
|
if (ret)
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
|
|
|
|
dev->data->port_id, strerror(rte_errno));
|
2019-09-24 12:56:10 +00:00
|
|
|
error:
|
|
|
|
/*
|
|
|
|
* rte_eth_allmulticast_disable() rollback
|
|
|
|
* dev->data->all_multicast in the case of failure.
|
|
|
|
*/
|
|
|
|
return ret;
|
2015-10-30 18:52:37 +00:00
|
|
|
}
|