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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(C) 2019 Marvell International Ltd.
*/
#include <rte_common.h>
#include "otx2_dev.h"
#include "otx2_ethdev.h"
int
otx2_cgx_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr)
{
struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
struct cgx_mac_addr_set_or_get *req;
struct otx2_mbox *mbox = dev->mbox;
int rc;
if (otx2_dev_is_vf_or_sdp(dev))
return -ENOTSUP;
if (otx2_dev_active_vfs(dev))
return -ENOTSUP;
req = otx2_mbox_alloc_msg_cgx_mac_addr_set(mbox);
otx2_mbox_memcpy(req->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
rc = otx2_mbox_process(mbox);
if (rc)
otx2_err("Failed to set mac address in CGX, rc=%d", rc);
return 0;
}
int
otx2_cgx_mac_max_entries_get(struct otx2_eth_dev *dev)
{
struct cgx_max_dmac_entries_get_rsp *rsp;
struct otx2_mbox *mbox = dev->mbox;
int rc;
if (otx2_dev_is_vf_or_sdp(dev))
return 0;
otx2_mbox_alloc_msg_cgx_mac_max_entries_get(mbox);
rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
if (rc)
return rc;
return rsp->max_dmac_filters;
}
int
otx2_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr,
uint32_t index __rte_unused, uint32_t pool __rte_unused)
{
struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
struct otx2_mbox *mbox = dev->mbox;
struct cgx_mac_addr_add_req *req;
struct cgx_mac_addr_add_rsp *rsp;
int rc;
if (otx2_dev_is_vf_or_sdp(dev))
return -ENOTSUP;
if (otx2_dev_active_vfs(dev))
return -ENOTSUP;
req = otx2_mbox_alloc_msg_cgx_mac_addr_add(mbox);
otx2_mbox_memcpy(req->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
if (rc) {
otx2_err("Failed to add mac address, rc=%d", rc);
goto done;
}
/* Enable promiscuous mode at NIX level */
otx2_nix_promisc_config(eth_dev, 1);
done:
return rc;
}
void
otx2_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index)
{
struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
struct otx2_mbox *mbox = dev->mbox;
struct cgx_mac_addr_del_req *req;
int rc;
if (otx2_dev_is_vf_or_sdp(dev))
return;
req = otx2_mbox_alloc_msg_cgx_mac_addr_del(mbox);
req->index = index;
rc = otx2_mbox_process(mbox);
if (rc)
otx2_err("Failed to delete mac address, rc=%d", rc);
}
int
otx2_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr)
{
struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
struct otx2_mbox *mbox = dev->mbox;
struct nix_set_mac_addr *req;
int rc;
req = otx2_mbox_alloc_msg_nix_set_mac_addr(mbox);
otx2_mbox_memcpy(req->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
rc = otx2_mbox_process(mbox);
if (rc) {
otx2_err("Failed to set mac address, rc=%d", rc);
goto done;
}
otx2_mbox_memcpy(dev->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
/* Install the same entry into CGX DMAC filter table too. */
otx2_cgx_mac_addr_set(eth_dev, addr);
done:
return rc;
}
int
otx2_nix_mac_addr_get(struct rte_eth_dev *eth_dev, uint8_t *addr)
{
struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
struct otx2_mbox *mbox = dev->mbox;
struct nix_get_mac_addr_rsp *rsp;
int rc;
otx2_mbox_alloc_msg_nix_get_mac_addr(mbox);
otx2_mbox_msg_send(mbox, 0);
rc = otx2_mbox_get_rsp(mbox, 0, (void *)&rsp);
if (rc) {
otx2_err("Failed to get mac address, rc=%d", rc);
goto done;
}
otx2_mbox_memcpy(addr, rsp->mac_addr, RTE_ETHER_ADDR_LEN);
done:
return rc;
}
|