Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <errno.h>
7 : : #include <stdint.h>
8 : : #include <stdlib.h>
9 : : #include <unistd.h>
10 : : #include <stdarg.h>
11 : : #include <inttypes.h>
12 : :
13 : : #include <rte_interrupts.h>
14 : : #include <rte_log.h>
15 : : #include <rte_debug.h>
16 : : #include <rte_eal.h>
17 : : #include <rte_ether.h>
18 : : #include <ethdev_driver.h>
19 : : #include <rte_malloc.h>
20 : : #include <rte_random.h>
21 : :
22 : : #include "base/ixgbe_common.h"
23 : : #include "ixgbe_ethdev.h"
24 : : #include "rte_pmd_ixgbe.h"
25 : :
26 : : #define IXGBE_MAX_VFTA (128)
27 : : #define IXGBE_VF_MSG_SIZE_DEFAULT 1
28 : : #define IXGBE_VF_GET_QUEUE_MSG_SIZE 5
29 : : #define IXGBE_ETHERTYPE_FLOW_CTRL 0x8808
30 : :
31 : : static inline uint16_t
32 : : dev_num_vf(struct rte_eth_dev *eth_dev)
33 : : {
34 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
35 : :
36 : 0 : return pci_dev->max_vfs;
37 : : }
38 : :
39 : : static inline
40 : 0 : int ixgbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
41 : : {
42 : : unsigned char vf_mac_addr[RTE_ETHER_ADDR_LEN];
43 : 0 : struct ixgbe_vf_info *vfinfo =
44 : 0 : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
45 : : uint16_t vfn;
46 : :
47 [ # # ]: 0 : for (vfn = 0; vfn < vf_num; vfn++) {
48 : 0 : rte_eth_random_addr(vf_mac_addr);
49 : : /* keep the random address as default */
50 : 0 : memcpy(vfinfo[vfn].vf_mac_addresses, vf_mac_addr,
51 : : RTE_ETHER_ADDR_LEN);
52 : : }
53 : :
54 : 0 : return 0;
55 : : }
56 : :
57 : : static inline int
58 : : ixgbe_mb_intr_setup(struct rte_eth_dev *dev)
59 : : {
60 : : struct ixgbe_interrupt *intr =
61 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
62 : :
63 : 0 : intr->mask |= IXGBE_EICR_MAILBOX;
64 : :
65 : : return 0;
66 : : }
67 : :
68 : 0 : int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
69 : : {
70 : : struct ixgbe_vf_info **vfinfo =
71 : 0 : IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
72 : 0 : struct ixgbe_uta_info *uta_info =
73 : : IXGBE_DEV_PRIVATE_TO_UTA(eth_dev->data->dev_private);
74 : 0 : struct ixgbe_hw *hw =
75 : : IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
76 : : uint16_t vf_num;
77 : : uint8_t nb_queue;
78 : : int ret = 0;
79 : : size_t i;
80 : :
81 : 0 : PMD_INIT_FUNC_TRACE();
82 : :
83 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
84 : : vf_num = dev_num_vf(eth_dev);
85 [ # # ]: 0 : if (vf_num == 0)
86 : : return ret;
87 : :
88 : 0 : *vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
89 [ # # ]: 0 : if (*vfinfo == NULL) {
90 : 0 : PMD_INIT_LOG(ERR,
91 : : "Cannot allocate memory for private VF data");
92 : 0 : return -ENOMEM;
93 : : }
94 : :
95 : 0 : ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
96 [ # # ]: 0 : if (ret) {
97 : 0 : PMD_INIT_LOG(ERR,
98 : : "failed to allocate switch domain for device %d", ret);
99 : 0 : rte_free(*vfinfo);
100 : 0 : *vfinfo = NULL;
101 : 0 : return ret;
102 : : }
103 : :
104 : : memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
105 : 0 : hw->mac.mc_filter_type = 0;
106 : :
107 [ # # ]: 0 : if (vf_num >= RTE_ETH_32_POOLS) {
108 : : nb_queue = 2;
109 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).active = RTE_ETH_64_POOLS;
110 [ # # ]: 0 : } else if (vf_num >= RTE_ETH_16_POOLS) {
111 : : nb_queue = 4;
112 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).active = RTE_ETH_32_POOLS;
113 : : } else {
114 : : nb_queue = 8;
115 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).active = RTE_ETH_16_POOLS;
116 : : }
117 : :
118 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
119 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = vf_num;
120 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = (uint16_t)(vf_num * nb_queue);
121 : :
122 : 0 : ixgbe_vf_perm_addr_gen(eth_dev, vf_num);
123 : :
124 : : /* init_mailbox_params */
125 [ # # ]: 0 : for (i = 0; i < vf_num; i++)
126 : 0 : hw->mbx.ops[i].init_params(hw);
127 : :
128 : : /* set mb interrupt mask */
129 : : ixgbe_mb_intr_setup(eth_dev);
130 : :
131 : 0 : return ret;
132 : : }
133 : :
134 : 0 : void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
135 : : {
136 : : struct ixgbe_vf_info **vfinfo;
137 : : uint16_t vf_num;
138 : : int ret;
139 : :
140 : 0 : PMD_INIT_FUNC_TRACE();
141 : :
142 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
143 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = 0;
144 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = 0;
145 : 0 : RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = 0;
146 : :
147 : : vf_num = dev_num_vf(eth_dev);
148 [ # # ]: 0 : if (vf_num == 0)
149 : : return;
150 : :
151 : 0 : vfinfo = IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
152 [ # # ]: 0 : if (*vfinfo == NULL)
153 : : return;
154 : :
155 : 0 : ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id);
156 [ # # ]: 0 : if (ret)
157 : 0 : PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
158 : :
159 : 0 : rte_free(*vfinfo);
160 : 0 : *vfinfo = NULL;
161 : : }
162 : :
163 : : static void
164 : 0 : ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)
165 : : {
166 : 0 : struct ixgbe_hw *hw =
167 : 0 : IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
168 : : struct ixgbe_filter_info *filter_info =
169 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
170 : : uint16_t vf_num;
171 : : int i;
172 : : struct ixgbe_ethertype_filter ethertype_filter;
173 : :
174 [ # # ]: 0 : if (!hw->mac.ops.set_ethertype_anti_spoofing) {
175 : 0 : PMD_DRV_LOG(INFO, "ether type anti-spoofing is not supported.");
176 : 0 : return;
177 : : }
178 : :
179 : : i = ixgbe_ethertype_filter_lookup(filter_info,
180 : : IXGBE_ETHERTYPE_FLOW_CTRL);
181 [ # # ]: 0 : if (i >= 0) {
182 : 0 : PMD_DRV_LOG(ERR, "A ether type filter entity for flow control already exists!");
183 : 0 : return;
184 : : }
185 : :
186 : : ethertype_filter.ethertype = IXGBE_ETHERTYPE_FLOW_CTRL;
187 : : ethertype_filter.etqf = IXGBE_ETQF_FILTER_EN |
188 : : IXGBE_ETQF_TX_ANTISPOOF |
189 : : IXGBE_ETHERTYPE_FLOW_CTRL;
190 : : ethertype_filter.etqs = 0;
191 : : ethertype_filter.conf = TRUE;
192 : : i = ixgbe_ethertype_filter_insert(filter_info,
193 : : ðertype_filter);
194 [ # # ]: 0 : if (i < 0) {
195 : 0 : PMD_DRV_LOG(ERR, "Cannot find an unused ether type filter entity for flow control.");
196 : 0 : return;
197 : : }
198 : :
199 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
200 : : (IXGBE_ETQF_FILTER_EN |
201 : : IXGBE_ETQF_TX_ANTISPOOF |
202 : : IXGBE_ETHERTYPE_FLOW_CTRL));
203 : :
204 : : vf_num = dev_num_vf(eth_dev);
205 [ # # ]: 0 : for (i = 0; i < vf_num; i++)
206 : 0 : hw->mac.ops.set_ethertype_anti_spoofing(hw, true, i);
207 : : }
208 : :
209 : 0 : int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
210 : : {
211 : : uint32_t vtctl, fcrth;
212 : : uint32_t vfre_slot, vfre_offset;
213 : : uint16_t vf_num;
214 : : const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
215 : : const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
216 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
217 : : uint32_t gpie, gcr_ext;
218 : : uint32_t vlanctrl;
219 : : int i;
220 : :
221 : : vf_num = dev_num_vf(eth_dev);
222 [ # # ]: 0 : if (vf_num == 0)
223 : : return -1;
224 : :
225 : : /* enable VMDq and set the default pool for PF */
226 : 0 : vtctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
227 : : vtctl |= IXGBE_VMD_CTL_VMDQ_EN;
228 : 0 : vtctl &= ~IXGBE_VT_CTL_POOL_MASK;
229 : 0 : vtctl |= RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx
230 : 0 : << IXGBE_VT_CTL_POOL_SHIFT;
231 : 0 : vtctl |= IXGBE_VT_CTL_REPLEN;
232 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vtctl);
233 : :
234 : 0 : vfre_offset = vf_num & VFRE_MASK;
235 : 0 : vfre_slot = (vf_num >> VFRE_SHIFT) > 0 ? 1 : 0;
236 : :
237 : : /* Enable pools reserved to PF only */
238 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0U) << vfre_offset);
239 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot ^ 1), vfre_slot - 1);
240 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0U) << vfre_offset);
241 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot ^ 1), vfre_slot - 1);
242 : :
243 : : /* PFDMA Tx General Switch Control Enables VMDQ loopback */
244 : 0 : IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
245 : :
246 : : /* clear VMDq map to permanent rar 0 */
247 : 0 : hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
248 : :
249 : : /* clear VMDq map to scan rar 127 */
250 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(hw->mac.num_rar_entries), 0);
251 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(hw->mac.num_rar_entries), 0);
252 : :
253 : : /* set VMDq map to default PF pool */
254 : 0 : hw->mac.ops.set_vmdq(hw, 0, RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx);
255 : :
256 : : /*
257 : : * SW msut set GCR_EXT.VT_Mode the same as GPIE.VT_Mode
258 : : */
259 : 0 : gcr_ext = IXGBE_READ_REG(hw, IXGBE_GCR_EXT);
260 : 0 : gcr_ext &= ~IXGBE_GCR_EXT_VT_MODE_MASK;
261 : :
262 : 0 : gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
263 : 0 : gpie &= ~IXGBE_GPIE_VTMODE_MASK;
264 : 0 : gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT;
265 : :
266 [ # # # # ]: 0 : switch (RTE_ETH_DEV_SRIOV(eth_dev).active) {
267 : 0 : case RTE_ETH_64_POOLS:
268 : 0 : gcr_ext |= IXGBE_GCR_EXT_VT_MODE_64;
269 : 0 : gpie |= IXGBE_GPIE_VTMODE_64;
270 : 0 : break;
271 : 0 : case RTE_ETH_32_POOLS:
272 : 0 : gcr_ext |= IXGBE_GCR_EXT_VT_MODE_32;
273 : 0 : gpie |= IXGBE_GPIE_VTMODE_32;
274 : 0 : break;
275 : 0 : case RTE_ETH_16_POOLS:
276 : 0 : gcr_ext |= IXGBE_GCR_EXT_VT_MODE_16;
277 : 0 : gpie |= IXGBE_GPIE_VTMODE_16;
278 : 0 : break;
279 : : }
280 : :
281 : 0 : IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr_ext);
282 : 0 : IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
283 : :
284 : : /*
285 : : * enable vlan filtering and allow all vlan tags through
286 : : */
287 : 0 : vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
288 : 0 : vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
289 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
290 : :
291 : : /* VFTA - enable all vlan filters */
292 [ # # ]: 0 : for (i = 0; i < IXGBE_MAX_VFTA; i++)
293 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), 0xFFFFFFFF);
294 : :
295 : : /* Enable MAC Anti-Spoofing */
296 : 0 : hw->mac.ops.set_mac_anti_spoofing(hw, FALSE, vf_num);
297 : :
298 : : /* set flow control threshold to max to avoid tx switch hang */
299 [ # # ]: 0 : for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
300 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
301 : 0 : fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 32;
302 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), fcrth);
303 : : }
304 : :
305 : 0 : ixgbe_add_tx_flow_control_drop_filter(eth_dev);
306 : :
307 : 0 : return 0;
308 : : }
309 : :
310 : : static void
311 : 0 : set_rx_mode(struct rte_eth_dev *dev)
312 : : {
313 : 0 : struct rte_eth_dev_data *dev_data = dev->data;
314 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
315 : : u32 fctrl, vmolr = IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE;
316 : : uint16_t vfn = dev_num_vf(dev);
317 : :
318 : : /* Check for Promiscuous and All Multicast modes */
319 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
320 : :
321 : : /* set all bits that we expect to always be set */
322 : : fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */
323 : : fctrl |= IXGBE_FCTRL_BAM;
324 : :
325 : : /* clear the bits we are changing the status of */
326 : 0 : fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
327 : :
328 [ # # ]: 0 : if (dev_data->promiscuous) {
329 : 0 : fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
330 : : vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_MPE);
331 : : } else {
332 [ # # ]: 0 : if (dev_data->all_multicast) {
333 : 0 : fctrl |= IXGBE_FCTRL_MPE;
334 : : vmolr |= IXGBE_VMOLR_MPE;
335 : : } else {
336 : : vmolr |= IXGBE_VMOLR_ROMPE;
337 : : }
338 : : }
339 : :
340 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
341 : 0 : vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(vfn)) &
342 : : ~(IXGBE_VMOLR_MPE | IXGBE_VMOLR_ROMPE |
343 : : IXGBE_VMOLR_ROPE);
344 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vfn), vmolr);
345 : : }
346 : :
347 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
348 : :
349 : 0 : ixgbe_vlan_hw_strip_config(dev);
350 : 0 : }
351 : :
352 : : static inline void
353 : 0 : ixgbe_vf_reset_event(struct rte_eth_dev *dev, uint16_t vf)
354 : : {
355 : 0 : struct ixgbe_hw *hw =
356 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
357 : 0 : struct ixgbe_vf_info *vfinfo =
358 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
359 : 0 : int rar_entry = hw->mac.num_rar_entries - (vf + 1);
360 : 0 : uint32_t vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
361 : :
362 : 0 : vmolr |= (IXGBE_VMOLR_ROPE |
363 : : IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE);
364 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
365 : :
366 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), 0);
367 : :
368 : : /* reset multicast table array for vf */
369 : 0 : vfinfo[vf].num_vf_mc_hashes = 0;
370 : :
371 : : /* reset rx mode */
372 : 0 : set_rx_mode(dev);
373 : :
374 : 0 : hw->mac.ops.clear_rar(hw, rar_entry);
375 : 0 : }
376 : :
377 : : static inline void
378 : 0 : ixgbe_vf_reset_msg(struct rte_eth_dev *dev, uint16_t vf)
379 : : {
380 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
381 : : uint32_t reg;
382 : : uint32_t reg_offset, vf_shift;
383 : : const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
384 : : const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
385 : : uint8_t nb_q_per_pool;
386 : : int i;
387 : :
388 : 0 : vf_shift = vf & VFRE_MASK;
389 : 0 : reg_offset = (vf >> VFRE_SHIFT) > 0 ? 1 : 0;
390 : :
391 : : /* enable transmit for vf */
392 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VFTE(reg_offset));
393 : 0 : reg |= (reg | (1 << vf_shift));
394 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), reg);
395 : :
396 : : /* enable all queue drop for IOV */
397 : 0 : nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
398 [ # # ]: 0 : for (i = vf * nb_q_per_pool; i < (vf + 1) * nb_q_per_pool; i++) {
399 : 0 : IXGBE_WRITE_FLUSH(hw);
400 : : reg = IXGBE_QDE_ENABLE | IXGBE_QDE_WRITE;
401 : 0 : reg |= i << IXGBE_QDE_IDX_SHIFT;
402 : 0 : IXGBE_WRITE_REG(hw, IXGBE_QDE, reg);
403 : : }
404 : :
405 : : /* enable receive for vf */
406 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VFRE(reg_offset));
407 : 0 : reg |= (reg | (1 << vf_shift));
408 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), reg);
409 : :
410 : : /* Enable counting of spoofed packets in the SSVPC register */
411 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VMECM(reg_offset));
412 : 0 : reg |= (1 << vf_shift);
413 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMECM(reg_offset), reg);
414 : :
415 : 0 : ixgbe_vf_reset_event(dev, vf);
416 : 0 : }
417 : :
418 : : static int
419 : 0 : ixgbe_disable_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf)
420 : : {
421 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
422 : : uint32_t vmolr;
423 : :
424 : 0 : vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
425 : :
426 : 0 : PMD_DRV_LOG(INFO, "VF %u: disabling multicast promiscuous", vf);
427 : :
428 : 0 : vmolr &= ~IXGBE_VMOLR_MPE;
429 : :
430 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
431 : :
432 : 0 : return 0;
433 : : }
434 : :
435 : : static int
436 : 0 : ixgbe_vf_reset(struct rte_eth_dev *dev, uint16_t vf, uint32_t *msgbuf)
437 : : {
438 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
439 : 0 : struct ixgbe_vf_info *vfinfo =
440 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
441 : 0 : unsigned char *vf_mac = vfinfo[vf].vf_mac_addresses;
442 : 0 : int rar_entry = hw->mac.num_rar_entries - (vf + 1);
443 : 0 : uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
444 : :
445 : 0 : ixgbe_vf_reset_msg(dev, vf);
446 : :
447 : 0 : hw->mac.ops.set_rar(hw, rar_entry, vf_mac, vf, IXGBE_RAH_AV);
448 : :
449 : : /* Disable multicast promiscuous at reset */
450 : 0 : ixgbe_disable_vf_mc_promisc(dev, vf);
451 : :
452 : : /* reply to reset with success and vf mac address */
453 : 0 : msgbuf[0] = IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_SUCCESS;
454 : : memcpy(new_mac, vf_mac, RTE_ETHER_ADDR_LEN);
455 : : /*
456 : : * Piggyback the multicast filter type so VF can compute the
457 : : * correct vectors
458 : : */
459 : 0 : msgbuf[3] = hw->mac.mc_filter_type;
460 : 0 : ixgbe_write_mbx(hw, msgbuf, IXGBE_VF_PERMADDR_MSG_LEN, vf);
461 : :
462 : 0 : return 0;
463 : : }
464 : :
465 : : static int
466 : 0 : ixgbe_vf_set_mac_addr(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
467 : : {
468 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
469 : 0 : struct ixgbe_vf_info *vfinfo =
470 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
471 : 0 : int rar_entry = hw->mac.num_rar_entries - (vf + 1);
472 [ # # ]: 0 : uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
473 : :
474 : : if (rte_is_valid_assigned_ether_addr(
475 : : (struct rte_ether_addr *)new_mac)) {
476 : 0 : memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);
477 : 0 : return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, IXGBE_RAH_AV);
478 : : }
479 : : return -1;
480 : : }
481 : :
482 : : static int
483 : 0 : ixgbe_vf_set_multicast(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
484 : : {
485 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
486 : 0 : struct ixgbe_vf_info *vfinfo =
487 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
488 : 0 : int nb_entries = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
489 : : IXGBE_VT_MSGINFO_SHIFT;
490 : : uint16_t *hash_list = (uint16_t *)&msgbuf[1];
491 : : uint32_t mta_idx;
492 : : uint32_t mta_shift;
493 : : const uint32_t IXGBE_MTA_INDEX_MASK = 0x7F;
494 : : const uint32_t IXGBE_MTA_BIT_SHIFT = 5;
495 : : const uint32_t IXGBE_MTA_BIT_MASK = (0x1 << IXGBE_MTA_BIT_SHIFT) - 1;
496 : : uint32_t reg_val;
497 : : int i;
498 : 0 : u32 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
499 : :
500 : : /* Disable multicast promiscuous first */
501 : 0 : ixgbe_disable_vf_mc_promisc(dev, vf);
502 : :
503 : : /* only so many hash values supported */
504 : 0 : nb_entries = RTE_MIN(nb_entries, IXGBE_MAX_VF_MC_ENTRIES);
505 : :
506 : : /* store the mc entries */
507 : 0 : vfinfo->num_vf_mc_hashes = (uint16_t)nb_entries;
508 [ # # ]: 0 : for (i = 0; i < nb_entries; i++) {
509 : 0 : vfinfo->vf_mc_hashes[i] = hash_list[i];
510 : : }
511 : :
512 [ # # ]: 0 : if (nb_entries == 0) {
513 : 0 : vmolr &= ~IXGBE_VMOLR_ROMPE;
514 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
515 : 0 : return 0;
516 : : }
517 : :
518 [ # # ]: 0 : for (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {
519 : 0 : mta_idx = (vfinfo->vf_mc_hashes[i] >> IXGBE_MTA_BIT_SHIFT)
520 : : & IXGBE_MTA_INDEX_MASK;
521 : 0 : mta_shift = vfinfo->vf_mc_hashes[i] & IXGBE_MTA_BIT_MASK;
522 : 0 : reg_val = IXGBE_READ_REG(hw, IXGBE_MTA(mta_idx));
523 : 0 : reg_val |= (1 << mta_shift);
524 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MTA(mta_idx), reg_val);
525 : : }
526 : :
527 : 0 : vmolr |= IXGBE_VMOLR_ROMPE;
528 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
529 : :
530 : 0 : return 0;
531 : : }
532 : :
533 : : static int
534 : 0 : ixgbe_vf_set_vlan(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
535 : : {
536 : : int add, vid;
537 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
538 : 0 : struct ixgbe_vf_info *vfinfo =
539 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
540 : :
541 : 0 : add = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK)
542 : 0 : >> IXGBE_VT_MSGINFO_SHIFT;
543 : 0 : vid = (msgbuf[1] & IXGBE_VLVF_VLANID_MASK);
544 : :
545 [ # # ]: 0 : if (add)
546 : 0 : vfinfo[vf].vlan_count++;
547 [ # # ]: 0 : else if (vfinfo[vf].vlan_count)
548 : 0 : vfinfo[vf].vlan_count--;
549 : 0 : return hw->mac.ops.set_vfta(hw, vid, vf, (bool)add, false);
550 : : }
551 : :
552 : : static int
553 : 0 : ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
554 : : {
555 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
556 : 0 : uint32_t max_frame = msgbuf[1];
557 : : uint32_t max_frs;
558 : : uint32_t hlreg0;
559 : :
560 : : /* X540, X550, and E610 support jumbo frames in IOV mode */
561 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_X540 &&
562 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550 &&
563 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
564 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_a &&
565 : : hw->mac.type != ixgbe_mac_E610) {
566 : 0 : struct ixgbe_vf_info *vfinfo =
567 : : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
568 : :
569 [ # # ]: 0 : switch (vfinfo[vf].api_version) {
570 : 0 : case ixgbe_mbox_api_11:
571 : : case ixgbe_mbox_api_12:
572 : : case ixgbe_mbox_api_13:
573 : : /**
574 : : * Version 1.1&1.2&1.3 supports jumbo frames on VFs
575 : : * if PF has jumbo frames enabled which means legacy
576 : : * VFs are disabled.
577 : : */
578 [ # # ]: 0 : if (dev->data->mtu > RTE_ETHER_MTU)
579 : : break;
580 : : /* fall through */
581 : : default:
582 : : /**
583 : : * If the PF or VF are running w/ jumbo frames enabled,
584 : : * we return -1 as we cannot support jumbo frames on
585 : : * legacy VFs.
586 : : */
587 [ # # ]: 0 : if (max_frame > IXGBE_ETH_MAX_LEN ||
588 [ # # ]: 0 : dev->data->mtu > RTE_ETHER_MTU)
589 : : return -1;
590 : : break;
591 : : }
592 : : }
593 : :
594 [ # # ]: 0 : if (max_frame < RTE_ETHER_MIN_LEN ||
595 : : max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
596 : : return -1;
597 : :
598 : 0 : max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
599 : 0 : IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
600 [ # # ]: 0 : if (max_frs < max_frame) {
601 : 0 : hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
602 [ # # ]: 0 : if (max_frame > IXGBE_ETH_MAX_LEN)
603 : 0 : hlreg0 |= IXGBE_HLREG0_JUMBOEN;
604 : : else
605 : 0 : hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
606 : 0 : IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
607 : :
608 : 0 : max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
609 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
610 : : }
611 : :
612 : : return 0;
613 : : }
614 : :
615 : : static int
616 : 0 : ixgbe_negotiate_vf_api(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
617 : : {
618 : 0 : uint32_t api_version = msgbuf[1];
619 : 0 : struct ixgbe_vf_info *vfinfo =
620 : 0 : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
621 : :
622 [ # # ]: 0 : switch (api_version) {
623 : 0 : case ixgbe_mbox_api_10:
624 : : case ixgbe_mbox_api_11:
625 : : case ixgbe_mbox_api_12:
626 : : case ixgbe_mbox_api_13:
627 : 0 : vfinfo[vf].api_version = (uint8_t)api_version;
628 : 0 : return 0;
629 : : default:
630 : : break;
631 : : }
632 : :
633 : 0 : PMD_DRV_LOG(ERR, "Negotiate invalid api version %u from VF %d",
634 : : api_version, vf);
635 : :
636 : 0 : return -1;
637 : : }
638 : :
639 : : static int
640 : 0 : ixgbe_get_vf_queues(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
641 : : {
642 : 0 : struct ixgbe_vf_info *vfinfo =
643 : 0 : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
644 : 0 : uint32_t default_q = vf * RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
645 : : struct rte_eth_conf *eth_conf;
646 : : struct rte_eth_vmdq_dcb_tx_conf *vmdq_dcb_tx_conf;
647 : : u8 num_tcs;
648 : : struct ixgbe_hw *hw;
649 : : u32 vmvir;
650 : : #define IXGBE_VMVIR_VLANA_MASK 0xC0000000
651 : : #define IXGBE_VMVIR_VLAN_VID_MASK 0x00000FFF
652 : : #define IXGBE_VMVIR_VLAN_UP_MASK 0x0000E000
653 : : #define VLAN_PRIO_SHIFT 13
654 : : u32 vlana;
655 : : u32 vid;
656 : : u32 user_priority;
657 : :
658 : : /* Verify if the PF supports the mbox APIs version or not */
659 [ # # ]: 0 : switch (vfinfo[vf].api_version) {
660 : : case ixgbe_mbox_api_20:
661 : : case ixgbe_mbox_api_11:
662 : : case ixgbe_mbox_api_12:
663 : : case ixgbe_mbox_api_13:
664 : : break;
665 : : default:
666 : : return -1;
667 : : }
668 : :
669 : : /* Notify VF of Rx and Tx queue number */
670 : 0 : msgbuf[IXGBE_VF_RX_QUEUES] = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
671 : 0 : msgbuf[IXGBE_VF_TX_QUEUES] = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
672 : :
673 : : /* Notify VF of default queue */
674 : 0 : msgbuf[IXGBE_VF_DEF_QUEUE] = default_q;
675 : :
676 : : /* Notify VF of number of DCB traffic classes */
677 : : eth_conf = &dev->data->dev_conf;
678 [ # # # # ]: 0 : switch (eth_conf->txmode.mq_mode) {
679 : 0 : case RTE_ETH_MQ_TX_NONE:
680 : : case RTE_ETH_MQ_TX_DCB:
681 : 0 : PMD_DRV_LOG(ERR, "PF must work with virtualization for VF %u"
682 : : ", but its tx mode = %d", vf,
683 : : eth_conf->txmode.mq_mode);
684 : 0 : return -1;
685 : :
686 : 0 : case RTE_ETH_MQ_TX_VMDQ_DCB:
687 : : vmdq_dcb_tx_conf = ð_conf->tx_adv_conf.vmdq_dcb_tx_conf;
688 [ # # # ]: 0 : switch (vmdq_dcb_tx_conf->nb_queue_pools) {
689 : : case RTE_ETH_16_POOLS:
690 : : num_tcs = RTE_ETH_8_TCS;
691 : : break;
692 : 0 : case RTE_ETH_32_POOLS:
693 : : num_tcs = RTE_ETH_4_TCS;
694 : 0 : break;
695 : : default:
696 : : return -1;
697 : : }
698 : : break;
699 : :
700 : : /* RTE_ETH_MQ_TX_VMDQ_ONLY, DCB not enabled */
701 : 0 : case RTE_ETH_MQ_TX_VMDQ_ONLY:
702 : : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
703 : 0 : vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf));
704 : 0 : vlana = vmvir & IXGBE_VMVIR_VLANA_MASK;
705 : 0 : vid = vmvir & IXGBE_VMVIR_VLAN_VID_MASK;
706 : 0 : user_priority =
707 : 0 : (vmvir & IXGBE_VMVIR_VLAN_UP_MASK) >> VLAN_PRIO_SHIFT;
708 [ # # ]: 0 : if ((vlana == IXGBE_VMVIR_VLANA_DEFAULT) &&
709 [ # # ]: 0 : ((vid != 0) || (user_priority != 0)))
710 : : num_tcs = 1;
711 : : else
712 : : num_tcs = 0;
713 : : break;
714 : :
715 : 0 : default:
716 : 0 : PMD_DRV_LOG(ERR, "PF work with invalid mode = %d",
717 : : eth_conf->txmode.mq_mode);
718 : 0 : return -1;
719 : : }
720 : 0 : msgbuf[IXGBE_VF_TRANS_VLAN] = num_tcs;
721 : :
722 : 0 : return 0;
723 : : }
724 : :
725 : : static int
726 : 0 : ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
727 : : {
728 : 0 : struct ixgbe_vf_info *vfinfo =
729 : 0 : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
730 : : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
731 : 0 : int xcast_mode = msgbuf[1]; /* msgbuf contains the flag to enable */
732 : : u32 vmolr, fctrl, disable, enable;
733 : :
734 [ # # # ]: 0 : switch (vfinfo[vf].api_version) {
735 : 0 : case ixgbe_mbox_api_12:
736 : : /* promisc introduced in 1.3 version */
737 [ # # ]: 0 : if (xcast_mode == IXGBEVF_XCAST_MODE_PROMISC)
738 : : return -EOPNOTSUPP;
739 : : break;
740 : : /* Fall threw */
741 : : case ixgbe_mbox_api_13:
742 : : break;
743 : : default:
744 : : return -1;
745 : : }
746 : :
747 [ # # ]: 0 : if (vfinfo[vf].xcast_mode == xcast_mode)
748 : 0 : goto out;
749 : :
750 [ # # # # : 0 : switch (xcast_mode) {
# ]
751 : : case IXGBEVF_XCAST_MODE_NONE:
752 : : disable = IXGBE_VMOLR_ROMPE |
753 : : IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
754 : : enable = IXGBE_VMOLR_BAM;
755 : : break;
756 : 0 : case IXGBEVF_XCAST_MODE_MULTI:
757 : : disable = IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
758 : : enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE;
759 : 0 : break;
760 : 0 : case IXGBEVF_XCAST_MODE_ALLMULTI:
761 : : disable = IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
762 : : enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE | IXGBE_VMOLR_MPE;
763 : 0 : break;
764 : 0 : case IXGBEVF_XCAST_MODE_PROMISC:
765 [ # # ]: 0 : if (hw->mac.type <= ixgbe_mac_82599EB)
766 : : return -1;
767 : :
768 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
769 [ # # ]: 0 : if (!(fctrl & IXGBE_FCTRL_UPE)) {
770 : : /* VF promisc requires PF in promisc */
771 : 0 : PMD_DRV_LOG(ERR,
772 : : "Enabling VF promisc requires PF in promisc");
773 : 0 : return -1;
774 : : }
775 : :
776 : : disable = IXGBE_VMOLR_VPE;
777 : : enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE |
778 : : IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE;
779 : : break;
780 : : default:
781 : : return -1;
782 : : }
783 : :
784 : 0 : vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
785 : 0 : vmolr &= ~disable;
786 : 0 : vmolr |= enable;
787 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
788 : 0 : vfinfo[vf].xcast_mode = xcast_mode;
789 : :
790 : 0 : out:
791 : 0 : msgbuf[1] = xcast_mode;
792 : :
793 : 0 : return 0;
794 : : }
795 : :
796 : : static int
797 : 0 : ixgbe_set_vf_macvlan_msg(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
798 : : {
799 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
800 : 0 : struct ixgbe_vf_info *vf_info =
801 : : *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
802 : 0 : uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
803 : 0 : int index = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
804 : : IXGBE_VT_MSGINFO_SHIFT;
805 : :
806 [ # # ]: 0 : if (index) {
807 : : if (!rte_is_valid_assigned_ether_addr(
808 : : (struct rte_ether_addr *)new_mac)) {
809 : 0 : PMD_DRV_LOG(ERR, "set invalid mac vf:%d", vf);
810 : 0 : return -1;
811 : : }
812 : :
813 : 0 : vf_info[vf].mac_count++;
814 : :
815 : 0 : hw->mac.ops.set_rar(hw, vf_info[vf].mac_count,
816 : : new_mac, vf, IXGBE_RAH_AV);
817 : : } else {
818 [ # # ]: 0 : if (vf_info[vf].mac_count) {
819 : 0 : hw->mac.ops.clear_rar(hw, vf_info[vf].mac_count);
820 : 0 : vf_info[vf].mac_count = 0;
821 : : }
822 : : }
823 : : return 0;
824 : : }
825 : :
826 : : static int
827 : 0 : ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
828 : : {
829 : : uint16_t mbx_size = IXGBE_VFMAILBOX_SIZE;
830 : : uint16_t msg_size = IXGBE_VF_MSG_SIZE_DEFAULT;
831 : : uint32_t msgbuf[IXGBE_VFMAILBOX_SIZE];
832 : : int32_t retval;
833 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
834 : 0 : struct ixgbe_vf_info *vfinfo =
835 : : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
836 : : struct rte_pmd_ixgbe_mb_event_param ret_param;
837 : :
838 : 0 : retval = ixgbe_read_mbx(hw, msgbuf, mbx_size, vf);
839 [ # # ]: 0 : if (retval) {
840 : 0 : PMD_DRV_LOG(ERR, "Error mbx recv msg from VF %d", vf);
841 : 0 : return retval;
842 : : }
843 : :
844 : : /* do nothing with the message already been processed */
845 [ # # ]: 0 : if (msgbuf[0] & (IXGBE_VT_MSGTYPE_SUCCESS | IXGBE_VT_MSGTYPE_FAILURE))
846 : : return retval;
847 : :
848 : : /* flush the ack before we write any messages back */
849 : 0 : IXGBE_WRITE_FLUSH(hw);
850 : :
851 : : /**
852 : : * initialise structure to send to user application
853 : : * will return response from user in retval field
854 : : */
855 : 0 : ret_param.retval = RTE_PMD_IXGBE_MB_EVENT_PROCEED;
856 : 0 : ret_param.vfid = vf;
857 : 0 : ret_param.msg_type = msgbuf[0] & 0xFFFF;
858 : 0 : ret_param.msg = (void *)msgbuf;
859 : :
860 : : /* perform VF reset */
861 [ # # ]: 0 : if (msgbuf[0] == IXGBE_VF_RESET) {
862 : 0 : int ret = ixgbe_vf_reset(dev, vf, msgbuf);
863 : :
864 : 0 : vfinfo[vf].clear_to_send = true;
865 : :
866 : : /* notify application about VF reset */
867 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
868 : : &ret_param);
869 : 0 : return ret;
870 : : }
871 : :
872 : : /**
873 : : * ask user application if we allowed to perform those functions
874 : : * if we get ret_param.retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED
875 : : * then business as usual,
876 : : * if 0, do nothing and send ACK to VF
877 : : * if ret_param.retval > 1, do nothing and send NAK to VF
878 : : */
879 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &ret_param);
880 : :
881 : 0 : retval = ret_param.retval;
882 : :
883 : : /* check & process VF to PF mailbox message */
884 [ # # # # : 0 : switch ((msgbuf[0] & 0xFFFF)) {
# # # #
# ]
885 : 0 : case IXGBE_VF_SET_MAC_ADDR:
886 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
887 : 0 : retval = ixgbe_vf_set_mac_addr(dev, vf, msgbuf);
888 : : break;
889 : 0 : case IXGBE_VF_SET_MULTICAST:
890 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
891 : 0 : retval = ixgbe_vf_set_multicast(dev, vf, msgbuf);
892 : : break;
893 : 0 : case IXGBE_VF_SET_LPE:
894 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
895 : 0 : retval = ixgbe_set_vf_lpe(dev, vf, msgbuf);
896 : : break;
897 : 0 : case IXGBE_VF_SET_VLAN:
898 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
899 : 0 : retval = ixgbe_vf_set_vlan(dev, vf, msgbuf);
900 : : break;
901 : 0 : case IXGBE_VF_API_NEGOTIATE:
902 : 0 : retval = ixgbe_negotiate_vf_api(dev, vf, msgbuf);
903 : 0 : break;
904 : 0 : case IXGBE_VF_GET_QUEUES:
905 : 0 : retval = ixgbe_get_vf_queues(dev, vf, msgbuf);
906 : : msg_size = IXGBE_VF_GET_QUEUE_MSG_SIZE;
907 : 0 : break;
908 : 0 : case IXGBE_VF_UPDATE_XCAST_MODE:
909 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
910 : 0 : retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf);
911 : : break;
912 : 0 : case IXGBE_VF_SET_MACVLAN:
913 [ # # ]: 0 : if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
914 : 0 : retval = ixgbe_set_vf_macvlan_msg(dev, vf, msgbuf);
915 : : break;
916 : 0 : default:
917 : 0 : PMD_DRV_LOG(DEBUG, "Unhandled Msg %8.8x", (unsigned)msgbuf[0]);
918 : : retval = IXGBE_ERR_MBX;
919 : : break;
920 : : }
921 : :
922 : : /* response the VF according to the message process result */
923 [ # # ]: 0 : if (retval)
924 : 0 : msgbuf[0] |= IXGBE_VT_MSGTYPE_FAILURE;
925 : : else
926 : 0 : msgbuf[0] |= IXGBE_VT_MSGTYPE_SUCCESS;
927 : :
928 : 0 : msgbuf[0] |= IXGBE_VT_MSGTYPE_CTS;
929 : :
930 : 0 : ixgbe_write_mbx(hw, msgbuf, msg_size, vf);
931 : :
932 : 0 : return retval;
933 : : }
934 : :
935 : : static inline void
936 : 0 : ixgbe_rcv_ack_from_vf(struct rte_eth_dev *dev, uint16_t vf)
937 : : {
938 : 0 : uint32_t msg = IXGBE_VT_MSGTYPE_FAILURE;
939 : 0 : struct ixgbe_hw *hw =
940 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
941 : 0 : struct ixgbe_vf_info *vfinfo =
942 : : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
943 : :
944 [ # # ]: 0 : if (!vfinfo[vf].clear_to_send)
945 : 0 : ixgbe_write_mbx(hw, &msg, 1, vf);
946 : 0 : }
947 : :
948 : 0 : void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev)
949 : : {
950 : : uint16_t vf;
951 : 0 : struct ixgbe_hw *hw =
952 : 0 : IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
953 : :
954 [ # # ]: 0 : for (vf = 0; vf < dev_num_vf(eth_dev); vf++) {
955 : : /* check & process vf function level reset */
956 [ # # ]: 0 : if (!ixgbe_check_for_rst(hw, vf))
957 : 0 : ixgbe_vf_reset_event(eth_dev, vf);
958 : :
959 : : /* check & process vf mailbox messages */
960 [ # # ]: 0 : if (!ixgbe_check_for_msg(hw, vf))
961 : 0 : ixgbe_rcv_msg_from_vf(eth_dev, vf);
962 : :
963 : : /* check & process acks from vf */
964 [ # # ]: 0 : if (!ixgbe_check_for_ack(hw, vf))
965 : 0 : ixgbe_rcv_ack_from_vf(eth_dev, vf);
966 : : }
967 : 0 : }
|