f-stack/dpdk/drivers/net/mlx5/mlx5_rxmode.c

123 lines
2.6 KiB
C
Raw Normal View History

2018-12-06 14:17:51 +00:00
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2015 6WIND S.A.
* Copyright 2015 Mellanox Technologies, Ltd
2017-04-21 10:43:26 +00:00
*/
#include <stddef.h>
#include <errno.h>
#include <string.h>
/* Verbs header. */
/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <infiniband/verbs.h>
#ifdef PEDANTIC
#pragma GCC diagnostic error "-Wpedantic"
#endif
2018-12-06 14:17:51 +00:00
#include <rte_ethdev_driver.h>
2017-04-21 10:43:26 +00:00
#include "mlx5.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"
/**
* DPDK callback to enable promiscuous mode.
*
* @param dev
* Pointer to Ethernet device structure.
*/
void
mlx5_promiscuous_enable(struct rte_eth_dev *dev)
{
2018-11-21 08:34:11 +00:00
struct priv *priv = dev->data->dev_private;
int ret;
dev->data->promiscuous = 1;
2018-11-21 08:34:11 +00:00
if (priv->isolated) {
DRV_LOG(WARNING,
"port %u cannot enable promiscuous mode"
" in flow isolation mode",
dev->data->port_id);
return;
}
2018-12-06 14:17:51 +00:00
if (priv->config.vf)
mlx5_nl_promisc(dev, 1);
2018-11-21 08:34:11 +00:00
ret = mlx5_traffic_restart(dev);
if (ret)
DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
dev->data->port_id, strerror(rte_errno));
2017-04-21 10:43:26 +00:00
}
/**
* DPDK callback to disable promiscuous mode.
*
* @param dev
* Pointer to Ethernet device structure.
*/
void
mlx5_promiscuous_disable(struct rte_eth_dev *dev)
{
2018-12-06 14:17:51 +00:00
struct priv *priv = dev->data->dev_private;
2018-11-21 08:34:11 +00:00
int ret;
dev->data->promiscuous = 0;
2018-12-06 14:17:51 +00:00
if (priv->config.vf)
mlx5_nl_promisc(dev, 0);
2018-11-21 08:34:11 +00:00
ret = mlx5_traffic_restart(dev);
if (ret)
DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
dev->data->port_id, strerror(rte_errno));
2017-04-21 10:43:26 +00:00
}
/**
* DPDK callback to enable allmulti mode.
*
* @param dev
* Pointer to Ethernet device structure.
*/
void
mlx5_allmulticast_enable(struct rte_eth_dev *dev)
{
2018-11-21 08:34:11 +00:00
struct priv *priv = dev->data->dev_private;
int ret;
dev->data->all_multicast = 1;
2018-11-21 08:34:11 +00:00
if (priv->isolated) {
DRV_LOG(WARNING,
"port %u cannot enable allmulticast mode"
" in flow isolation mode",
dev->data->port_id);
return;
}
2018-12-06 14:17:51 +00:00
if (priv->config.vf)
mlx5_nl_allmulti(dev, 1);
2018-11-21 08:34:11 +00:00
ret = mlx5_traffic_restart(dev);
if (ret)
DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
dev->data->port_id, strerror(rte_errno));
2017-04-21 10:43:26 +00:00
}
/**
* DPDK callback to disable allmulti mode.
*
* @param dev
* Pointer to Ethernet device structure.
*/
void
mlx5_allmulticast_disable(struct rte_eth_dev *dev)
{
2018-12-06 14:17:51 +00:00
struct priv *priv = dev->data->dev_private;
2018-11-21 08:34:11 +00:00
int ret;
dev->data->all_multicast = 0;
2018-12-06 14:17:51 +00:00
if (priv->config.vf)
mlx5_nl_allmulti(dev, 0);
2018-11-21 08:34:11 +00:00
ret = mlx5_traffic_restart(dev);
if (ret)
DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
dev->data->port_id, strerror(rte_errno));
2017-04-21 10:43:26 +00:00
}