vdpa/mlx5: support queue update
[dpdk.git] / drivers / net / nfb / nfb_rxmode.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Cesnet
3  * Copyright(c) 2019 Netcope Technologies, a.s. <info@netcope.com>
4  * All rights reserved.
5  */
6
7 #include "nfb_rxmode.h"
8 #include "nfb.h"
9
10 int
11 nfb_eth_promiscuous_enable(struct rte_eth_dev *dev)
12 {
13         struct pmd_internals *internals = (struct pmd_internals *)
14                 dev->data->dev_private;
15         uint16_t i;
16
17         internals->rx_filter_original = RXMAC_MAC_FILTER_PROMISCUOUS;
18
19         for (i = 0; i < internals->max_rxmac; ++i) {
20                 nc_rxmac_mac_filter_enable(internals->rxmac[i],
21                         RXMAC_MAC_FILTER_PROMISCUOUS);
22         }
23
24         return 0;
25 }
26
27 int
28 nfb_eth_promiscuous_disable(struct rte_eth_dev *dev)
29 {
30         struct pmd_internals *internals = (struct pmd_internals *)
31                 dev->data->dev_private;
32         uint16_t i;
33
34         internals->rx_filter_original = RXMAC_MAC_FILTER_TABLE;
35
36         /* if promisc is not enabled, do nothing */
37         if (!nfb_eth_promiscuous_get(dev))
38                 return 0;
39
40         for (i = 0; i < internals->max_rxmac; ++i) {
41                 nc_rxmac_mac_filter_enable(internals->rxmac[i],
42                         RXMAC_MAC_FILTER_TABLE);
43         }
44
45         return 0;
46 }
47
48 int
49 nfb_eth_promiscuous_get(struct rte_eth_dev *dev)
50 {
51         struct pmd_internals *internals = (struct pmd_internals *)
52                 dev->data->dev_private;
53
54         struct nc_rxmac_status status;
55         status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS;
56
57         if (internals->max_rxmac > 0)
58                 nc_rxmac_read_status(internals->rxmac[0], &status);
59
60         return (status.mac_filter == RXMAC_MAC_FILTER_PROMISCUOUS);
61 }
62
63 int
64 nfb_eth_allmulticast_enable(struct rte_eth_dev *dev)
65 {
66         struct pmd_internals *internals = (struct pmd_internals *)
67                 dev->data->dev_private;
68
69         uint16_t i;
70         for (i = 0; i < internals->max_rxmac; ++i) {
71                 nc_rxmac_mac_filter_enable(internals->rxmac[i],
72                         RXMAC_MAC_FILTER_TABLE_BCAST_MCAST);
73         }
74
75         return 0;
76 }
77
78 int
79 nfb_eth_allmulticast_disable(struct rte_eth_dev *dev)
80 {
81         struct pmd_internals *internals = (struct pmd_internals *)
82                 dev->data->dev_private;
83
84         uint16_t i;
85
86         /* if multicast is not enabled do nothing */
87         if (!nfb_eth_allmulticast_get(dev))
88                 return 0;
89
90         for (i = 0; i < internals->max_rxmac; ++i) {
91                 nc_rxmac_mac_filter_enable(internals->rxmac[i],
92                         internals->rx_filter_original);
93         }
94
95         return 0;
96 }
97
98 int
99 nfb_eth_allmulticast_get(struct rte_eth_dev *dev)
100 {
101         struct pmd_internals *internals = (struct pmd_internals *)
102                 dev->data->dev_private;
103
104         struct nc_rxmac_status status;
105         status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS;
106
107         if (internals->max_rxmac > 0)
108                 nc_rxmac_read_status(internals->rxmac[0], &status);
109
110         return (status.mac_filter == RXMAC_MAC_FILTER_TABLE_BCAST_MCAST);
111 }