summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/drivers/net/nfb/nfb_rxmode.c
blob: 2d0b613d21edcb039bd7f5013d43fc81d4432ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2019 Cesnet
 * Copyright(c) 2019 Netcope Technologies, a.s. <info@netcope.com>
 * All rights reserved.
 */

#include "nfb_rxmode.h"
#include "nfb.h"

int
nfb_eth_promiscuous_enable(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;
	uint16_t i;

	internals->rx_filter_original = RXMAC_MAC_FILTER_PROMISCUOUS;

	for (i = 0; i < internals->max_rxmac; ++i) {
		nc_rxmac_mac_filter_enable(internals->rxmac[i],
			RXMAC_MAC_FILTER_PROMISCUOUS);
	}

	return 0;
}

int
nfb_eth_promiscuous_disable(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;
	uint16_t i;

	internals->rx_filter_original = RXMAC_MAC_FILTER_TABLE;

	/* if promisc is not enabled, do nothing */
	if (!nfb_eth_promiscuous_get(dev))
		return 0;

	for (i = 0; i < internals->max_rxmac; ++i) {
		nc_rxmac_mac_filter_enable(internals->rxmac[i],
			RXMAC_MAC_FILTER_TABLE);
	}

	return 0;
}

int
nfb_eth_promiscuous_get(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;

	struct nc_rxmac_status status;
	status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS;

	if (internals->max_rxmac > 0)
		nc_rxmac_read_status(internals->rxmac[0], &status);

	return (status.mac_filter == RXMAC_MAC_FILTER_PROMISCUOUS);
}

int
nfb_eth_allmulticast_enable(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;

	uint16_t i;
	for (i = 0; i < internals->max_rxmac; ++i) {
		nc_rxmac_mac_filter_enable(internals->rxmac[i],
			RXMAC_MAC_FILTER_TABLE_BCAST_MCAST);
	}

	return 0;
}

int
nfb_eth_allmulticast_disable(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;

	uint16_t i;

	/* if multicast is not enabled do nothing */
	if (!nfb_eth_allmulticast_get(dev))
		return 0;

	for (i = 0; i < internals->max_rxmac; ++i) {
		nc_rxmac_mac_filter_enable(internals->rxmac[i],
			internals->rx_filter_original);
	}

	return 0;
}

int
nfb_eth_allmulticast_get(struct rte_eth_dev *dev)
{
	struct pmd_internals *internals = (struct pmd_internals *)
		dev->data->dev_private;

	struct nc_rxmac_status status;
	status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS;

	if (internals->max_rxmac > 0)
		nc_rxmac_read_status(internals->rxmac[0], &status);

	return (status.mac_filter == RXMAC_MAC_FILTER_TABLE_BCAST_MCAST);
}