net/sfc/base: report correct partition write chunk size
[dpdk.git] / drivers / net / bonding / rte_eth_bond_api.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2017 Intel Corporation
3  */
4
5 #include <string.h>
6
7 #include <rte_mbuf.h>
8 #include <rte_malloc.h>
9 #include <rte_ethdev.h>
10 #include <rte_tcp.h>
11 #include <rte_bus_vdev.h>
12 #include <rte_kvargs.h>
13
14 #include "rte_eth_bond.h"
15 #include "rte_eth_bond_private.h"
16 #include "rte_eth_bond_8023ad_private.h"
17
18 int
19 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
20 {
21         /* Check valid pointer */
22         if (eth_dev->device->driver->name == NULL)
23                 return -1;
24
25         /* return 0 if driver name matches */
26         return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
27 }
28
29 int
30 valid_bonded_port_id(uint16_t port_id)
31 {
32         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
33         return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
34 }
35
36 int
37 valid_slave_port_id(uint16_t port_id, uint8_t mode)
38 {
39         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
40
41         /* Verify that port_id refers to a non bonded port */
42         if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0 &&
43                         mode == BONDING_MODE_8023AD) {
44                 RTE_BOND_LOG(ERR, "Cannot add slave to bonded device in 802.3ad"
45                                 " mode as slave is also a bonded device, only "
46                                 "physical devices can be support in this mode.");
47                 return -1;
48         }
49
50         return 0;
51 }
52
53 void
54 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
55 {
56         struct bond_dev_private *internals = eth_dev->data->dev_private;
57         uint8_t active_count = internals->active_slave_count;
58
59         if (internals->mode == BONDING_MODE_8023AD)
60                 bond_mode_8023ad_activate_slave(eth_dev, port_id);
61
62         if (internals->mode == BONDING_MODE_TLB
63                         || internals->mode == BONDING_MODE_ALB) {
64
65                 internals->tlb_slaves_order[active_count] = port_id;
66         }
67
68         RTE_ASSERT(internals->active_slave_count <
69                         (RTE_DIM(internals->active_slaves) - 1));
70
71         internals->active_slaves[internals->active_slave_count] = port_id;
72         internals->active_slave_count++;
73
74         if (internals->mode == BONDING_MODE_TLB)
75                 bond_tlb_activate_slave(internals);
76         if (internals->mode == BONDING_MODE_ALB)
77                 bond_mode_alb_client_list_upd(eth_dev);
78 }
79
80 void
81 deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
82 {
83         uint16_t slave_pos;
84         struct bond_dev_private *internals = eth_dev->data->dev_private;
85         uint16_t active_count = internals->active_slave_count;
86
87         if (internals->mode == BONDING_MODE_8023AD) {
88                 bond_mode_8023ad_stop(eth_dev);
89                 bond_mode_8023ad_deactivate_slave(eth_dev, port_id);
90         } else if (internals->mode == BONDING_MODE_TLB
91                         || internals->mode == BONDING_MODE_ALB)
92                 bond_tlb_disable(internals);
93
94         slave_pos = find_slave_by_id(internals->active_slaves, active_count,
95                         port_id);
96
97         /* If slave was not at the end of the list
98          * shift active slaves up active array list */
99         if (slave_pos < active_count) {
100                 active_count--;
101                 memmove(internals->active_slaves + slave_pos,
102                                 internals->active_slaves + slave_pos + 1,
103                                 (active_count - slave_pos) *
104                                         sizeof(internals->active_slaves[0]));
105         }
106
107         RTE_ASSERT(active_count < RTE_DIM(internals->active_slaves));
108         internals->active_slave_count = active_count;
109
110         if (eth_dev->data->dev_started) {
111                 if (internals->mode == BONDING_MODE_8023AD) {
112                         bond_mode_8023ad_start(eth_dev);
113                 } else if (internals->mode == BONDING_MODE_TLB) {
114                         bond_tlb_enable(internals);
115                 } else if (internals->mode == BONDING_MODE_ALB) {
116                         bond_tlb_enable(internals);
117                         bond_mode_alb_client_list_upd(eth_dev);
118                 }
119         }
120 }
121
122 int
123 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
124 {
125         struct bond_dev_private *internals;
126         char devargs[52];
127         uint16_t port_id;
128         int ret;
129
130         if (name == NULL) {
131                 RTE_BOND_LOG(ERR, "Invalid name specified");
132                 return -EINVAL;
133         }
134
135         ret = snprintf(devargs, sizeof(devargs),
136                 "driver=net_bonding,mode=%d,socket_id=%d", mode, socket_id);
137         if (ret < 0 || ret >= (int)sizeof(devargs))
138                 return -ENOMEM;
139
140         ret = rte_vdev_init(name, devargs);
141         if (ret)
142                 return -ENOMEM;
143
144         ret = rte_eth_dev_get_port_by_name(name, &port_id);
145         RTE_ASSERT(!ret);
146
147         /*
148          * To make bond_ethdev_configure() happy we need to free the
149          * internals->kvlist here.
150          *
151          * Also see comment in bond_ethdev_configure().
152          */
153         internals = rte_eth_devices[port_id].data->dev_private;
154         rte_kvargs_free(internals->kvlist);
155         internals->kvlist = NULL;
156
157         return port_id;
158 }
159
160 int
161 rte_eth_bond_free(const char *name)
162 {
163         return rte_vdev_uninit(name);
164 }
165
166 static int
167 slave_vlan_filter_set(uint16_t bonded_port_id, uint16_t slave_port_id)
168 {
169         struct rte_eth_dev *bonded_eth_dev;
170         struct bond_dev_private *internals;
171         int found;
172         int res = 0;
173         uint64_t slab = 0;
174         uint32_t pos = 0;
175         uint16_t first;
176
177         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
178         if (bonded_eth_dev->data->dev_conf.rxmode.hw_vlan_filter == 0)
179                 return 0;
180
181         internals = bonded_eth_dev->data->dev_private;
182         found = rte_bitmap_scan(internals->vlan_filter_bmp, &pos, &slab);
183         first = pos;
184
185         if (!found)
186                 return 0;
187
188         do {
189                 uint32_t i;
190                 uint64_t mask;
191
192                 for (i = 0, mask = 1;
193                      i < RTE_BITMAP_SLAB_BIT_SIZE;
194                      i ++, mask <<= 1) {
195                         if (unlikely(slab & mask))
196                                 res = rte_eth_dev_vlan_filter(slave_port_id,
197                                                               (uint16_t)pos, 1);
198                 }
199                 found = rte_bitmap_scan(internals->vlan_filter_bmp,
200                                         &pos, &slab);
201         } while (found && first != pos && res == 0);
202
203         return res;
204 }
205
206 static int
207 __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
208 {
209         struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
210         struct bond_dev_private *internals;
211         struct rte_eth_link link_props;
212         struct rte_eth_dev_info dev_info;
213
214         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
215         internals = bonded_eth_dev->data->dev_private;
216
217         if (valid_slave_port_id(slave_port_id, internals->mode) != 0)
218                 return -1;
219
220         slave_eth_dev = &rte_eth_devices[slave_port_id];
221         if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
222                 RTE_BOND_LOG(ERR, "Slave device is already a slave of a bonded device");
223                 return -1;
224         }
225
226         /* Add slave details to bonded device */
227         slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
228
229         rte_eth_dev_info_get(slave_port_id, &dev_info);
230         if (dev_info.max_rx_pktlen < internals->max_rx_pktlen) {
231                 RTE_BOND_LOG(ERR, "Slave (port %u) max_rx_pktlen too small",
232                              slave_port_id);
233                 return -1;
234         }
235
236         slave_add(internals, slave_eth_dev);
237
238         /* We need to store slaves reta_size to be able to synchronize RETA for all
239          * slave devices even if its sizes are different.
240          */
241         internals->slaves[internals->slave_count].reta_size = dev_info.reta_size;
242
243         if (internals->slave_count < 1) {
244                 /* if MAC is not user defined then use MAC of first slave add to
245                  * bonded device */
246                 if (!internals->user_defined_mac)
247                         mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
248
249                 /* Inherit eth dev link properties from first slave */
250                 link_properties_set(bonded_eth_dev,
251                                 &(slave_eth_dev->data->dev_link));
252
253                 /* Make primary slave */
254                 internals->primary_port = slave_port_id;
255                 internals->current_primary_port = slave_port_id;
256
257                 /* Inherit queues settings from first slave */
258                 internals->nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
259                 internals->nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
260
261                 internals->reta_size = dev_info.reta_size;
262
263                 /* Take the first dev's offload capabilities */
264                 internals->rx_offload_capa = dev_info.rx_offload_capa;
265                 internals->tx_offload_capa = dev_info.tx_offload_capa;
266                 internals->flow_type_rss_offloads = dev_info.flow_type_rss_offloads;
267
268                 /* Inherit first slave's max rx packet size */
269                 internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
270
271         } else {
272                 internals->rx_offload_capa &= dev_info.rx_offload_capa;
273                 internals->tx_offload_capa &= dev_info.tx_offload_capa;
274                 internals->flow_type_rss_offloads &= dev_info.flow_type_rss_offloads;
275
276                 if (link_properties_valid(bonded_eth_dev,
277                                 &slave_eth_dev->data->dev_link) != 0) {
278                         RTE_BOND_LOG(ERR, "Invalid link properties for slave %d"
279                                         " in bonding mode %d", slave_port_id,
280                                         internals->mode);
281                         return -1;
282                 }
283
284                 /* RETA size is GCD of all slaves RETA sizes, so, if all sizes will be
285                  * the power of 2, the lower one is GCD
286                  */
287                 if (internals->reta_size > dev_info.reta_size)
288                         internals->reta_size = dev_info.reta_size;
289
290                 if (!internals->max_rx_pktlen &&
291                     dev_info.max_rx_pktlen < internals->candidate_max_rx_pktlen)
292                         internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
293         }
294
295         bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
296                         internals->flow_type_rss_offloads;
297
298         internals->slave_count++;
299
300         /* Update all slave devices MACs*/
301         mac_address_slaves_update(bonded_eth_dev);
302
303         if (bonded_eth_dev->data->dev_started) {
304                 if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
305                         slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
306                         RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
307                                         slave_port_id);
308                         return -1;
309                 }
310         }
311
312         /* Register link status change callback with bonded device pointer as
313          * argument*/
314         rte_eth_dev_callback_register(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
315                         bond_ethdev_lsc_event_callback, &bonded_eth_dev->data->port_id);
316
317         /* If bonded device is started then we can add the slave to our active
318          * slave array */
319         if (bonded_eth_dev->data->dev_started) {
320                 rte_eth_link_get_nowait(slave_port_id, &link_props);
321
322                  if (link_props.link_status == ETH_LINK_UP) {
323                         if (internals->active_slave_count == 0 &&
324                             !internals->user_defined_primary_port)
325                                 bond_ethdev_primary_set(internals,
326                                                         slave_port_id);
327
328                         if (find_slave_by_id(internals->active_slaves,
329                                              internals->active_slave_count,
330                                              slave_port_id) == internals->active_slave_count)
331                                 activate_slave(bonded_eth_dev, slave_port_id);
332                 }
333         }
334
335         slave_vlan_filter_set(bonded_port_id, slave_port_id);
336
337         return 0;
338
339 }
340
341 int
342 rte_eth_bond_slave_add(uint16_t bonded_port_id, uint16_t slave_port_id)
343 {
344         struct rte_eth_dev *bonded_eth_dev;
345         struct bond_dev_private *internals;
346
347         int retval;
348
349         /* Verify that port id's are valid bonded and slave ports */
350         if (valid_bonded_port_id(bonded_port_id) != 0)
351                 return -1;
352
353         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
354         internals = bonded_eth_dev->data->dev_private;
355
356         rte_spinlock_lock(&internals->lock);
357
358         retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
359
360         rte_spinlock_unlock(&internals->lock);
361
362         return retval;
363 }
364
365 static int
366 __eth_bond_slave_remove_lock_free(uint16_t bonded_port_id,
367                                    uint16_t slave_port_id)
368 {
369         struct rte_eth_dev *bonded_eth_dev;
370         struct bond_dev_private *internals;
371         struct rte_eth_dev *slave_eth_dev;
372         int i, slave_idx;
373
374         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
375         internals = bonded_eth_dev->data->dev_private;
376
377         if (valid_slave_port_id(slave_port_id, internals->mode) < 0)
378                 return -1;
379
380         /* first remove from active slave list */
381         slave_idx = find_slave_by_id(internals->active_slaves,
382                 internals->active_slave_count, slave_port_id);
383
384         if (slave_idx < internals->active_slave_count)
385                 deactivate_slave(bonded_eth_dev, slave_port_id);
386
387         slave_idx = -1;
388         /* now find in slave list */
389         for (i = 0; i < internals->slave_count; i++)
390                 if (internals->slaves[i].port_id == slave_port_id) {
391                         slave_idx = i;
392                         break;
393                 }
394
395         if (slave_idx < 0) {
396                 RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
397                                 internals->slave_count);
398                 return -1;
399         }
400
401         /* Un-register link status change callback with bonded device pointer as
402          * argument*/
403         rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
404                         bond_ethdev_lsc_event_callback,
405                         &rte_eth_devices[bonded_port_id].data->port_id);
406
407         /* Restore original MAC address of slave device */
408         mac_address_set(&rte_eth_devices[slave_port_id],
409                         &(internals->slaves[slave_idx].persisted_mac_addr));
410
411         slave_eth_dev = &rte_eth_devices[slave_port_id];
412         slave_remove(internals, slave_eth_dev);
413         slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
414
415         /*  first slave in the active list will be the primary by default,
416          *  otherwise use first device in list */
417         if (internals->current_primary_port == slave_port_id) {
418                 if (internals->active_slave_count > 0)
419                         internals->current_primary_port = internals->active_slaves[0];
420                 else if (internals->slave_count > 0)
421                         internals->current_primary_port = internals->slaves[0].port_id;
422                 else
423                         internals->primary_port = 0;
424         }
425
426         if (internals->active_slave_count < 1) {
427                 /* if no slaves are any longer attached to bonded device and MAC is not
428                  * user defined then clear MAC of bonded device as it will be reset
429                  * when a new slave is added */
430                 if (internals->slave_count < 1 && !internals->user_defined_mac)
431                         memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0,
432                                         sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs)));
433         }
434         if (internals->slave_count == 0) {
435                 internals->rx_offload_capa = 0;
436                 internals->tx_offload_capa = 0;
437                 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
438                 internals->reta_size = 0;
439                 internals->candidate_max_rx_pktlen = 0;
440                 internals->max_rx_pktlen = 0;
441         }
442         return 0;
443 }
444
445 int
446 rte_eth_bond_slave_remove(uint16_t bonded_port_id, uint16_t slave_port_id)
447 {
448         struct rte_eth_dev *bonded_eth_dev;
449         struct bond_dev_private *internals;
450         int retval;
451
452         if (valid_bonded_port_id(bonded_port_id) != 0)
453                 return -1;
454
455         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
456         internals = bonded_eth_dev->data->dev_private;
457
458         rte_spinlock_lock(&internals->lock);
459
460         retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
461
462         rte_spinlock_unlock(&internals->lock);
463
464         return retval;
465 }
466
467 int
468 rte_eth_bond_mode_set(uint16_t bonded_port_id, uint8_t mode)
469 {
470         if (valid_bonded_port_id(bonded_port_id) != 0)
471                 return -1;
472
473         return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
474 }
475
476 int
477 rte_eth_bond_mode_get(uint16_t bonded_port_id)
478 {
479         struct bond_dev_private *internals;
480
481         if (valid_bonded_port_id(bonded_port_id) != 0)
482                 return -1;
483
484         internals = rte_eth_devices[bonded_port_id].data->dev_private;
485
486         return internals->mode;
487 }
488
489 int
490 rte_eth_bond_primary_set(uint16_t bonded_port_id, uint16_t slave_port_id)
491 {
492         struct bond_dev_private *internals;
493
494         if (valid_bonded_port_id(bonded_port_id) != 0)
495                 return -1;
496
497         internals = rte_eth_devices[bonded_port_id].data->dev_private;
498
499         if (valid_slave_port_id(slave_port_id, internals->mode) != 0)
500                 return -1;
501
502         internals->user_defined_primary_port = 1;
503         internals->primary_port = slave_port_id;
504
505         bond_ethdev_primary_set(internals, slave_port_id);
506
507         return 0;
508 }
509
510 int
511 rte_eth_bond_primary_get(uint16_t bonded_port_id)
512 {
513         struct bond_dev_private *internals;
514
515         if (valid_bonded_port_id(bonded_port_id) != 0)
516                 return -1;
517
518         internals = rte_eth_devices[bonded_port_id].data->dev_private;
519
520         if (internals->slave_count < 1)
521                 return -1;
522
523         return internals->current_primary_port;
524 }
525
526 int
527 rte_eth_bond_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
528                         uint16_t len)
529 {
530         struct bond_dev_private *internals;
531         uint8_t i;
532
533         if (valid_bonded_port_id(bonded_port_id) != 0)
534                 return -1;
535
536         if (slaves == NULL)
537                 return -1;
538
539         internals = rte_eth_devices[bonded_port_id].data->dev_private;
540
541         if (internals->slave_count > len)
542                 return -1;
543
544         for (i = 0; i < internals->slave_count; i++)
545                 slaves[i] = internals->slaves[i].port_id;
546
547         return internals->slave_count;
548 }
549
550 int
551 rte_eth_bond_active_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
552                 uint16_t len)
553 {
554         struct bond_dev_private *internals;
555
556         if (valid_bonded_port_id(bonded_port_id) != 0)
557                 return -1;
558
559         if (slaves == NULL)
560                 return -1;
561
562         internals = rte_eth_devices[bonded_port_id].data->dev_private;
563
564         if (internals->active_slave_count > len)
565                 return -1;
566
567         memcpy(slaves, internals->active_slaves,
568         internals->active_slave_count * sizeof(internals->active_slaves[0]));
569
570         return internals->active_slave_count;
571 }
572
573 int
574 rte_eth_bond_mac_address_set(uint16_t bonded_port_id,
575                 struct ether_addr *mac_addr)
576 {
577         struct rte_eth_dev *bonded_eth_dev;
578         struct bond_dev_private *internals;
579
580         if (valid_bonded_port_id(bonded_port_id) != 0)
581                 return -1;
582
583         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
584         internals = bonded_eth_dev->data->dev_private;
585
586         /* Set MAC Address of Bonded Device */
587         if (mac_address_set(bonded_eth_dev, mac_addr))
588                 return -1;
589
590         internals->user_defined_mac = 1;
591
592         /* Update all slave devices MACs*/
593         if (internals->slave_count > 0)
594                 return mac_address_slaves_update(bonded_eth_dev);
595
596         return 0;
597 }
598
599 int
600 rte_eth_bond_mac_address_reset(uint16_t bonded_port_id)
601 {
602         struct rte_eth_dev *bonded_eth_dev;
603         struct bond_dev_private *internals;
604
605         if (valid_bonded_port_id(bonded_port_id) != 0)
606                 return -1;
607
608         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
609         internals = bonded_eth_dev->data->dev_private;
610
611         internals->user_defined_mac = 0;
612
613         if (internals->slave_count > 0) {
614                 /* Set MAC Address of Bonded Device */
615                 if (mac_address_set(bonded_eth_dev,
616                                 &internals->slaves[internals->primary_port].persisted_mac_addr)
617                                 != 0) {
618                         RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
619                         return -1;
620                 }
621                 /* Update all slave devices MAC addresses */
622                 return mac_address_slaves_update(bonded_eth_dev);
623         }
624         /* No need to update anything as no slaves present */
625         return 0;
626 }
627
628 int
629 rte_eth_bond_xmit_policy_set(uint16_t bonded_port_id, uint8_t policy)
630 {
631         struct bond_dev_private *internals;
632
633         if (valid_bonded_port_id(bonded_port_id) != 0)
634                 return -1;
635
636         internals = rte_eth_devices[bonded_port_id].data->dev_private;
637
638         switch (policy) {
639         case BALANCE_XMIT_POLICY_LAYER2:
640                 internals->balance_xmit_policy = policy;
641                 internals->xmit_hash = xmit_l2_hash;
642                 break;
643         case BALANCE_XMIT_POLICY_LAYER23:
644                 internals->balance_xmit_policy = policy;
645                 internals->xmit_hash = xmit_l23_hash;
646                 break;
647         case BALANCE_XMIT_POLICY_LAYER34:
648                 internals->balance_xmit_policy = policy;
649                 internals->xmit_hash = xmit_l34_hash;
650                 break;
651
652         default:
653                 return -1;
654         }
655         return 0;
656 }
657
658 int
659 rte_eth_bond_xmit_policy_get(uint16_t bonded_port_id)
660 {
661         struct bond_dev_private *internals;
662
663         if (valid_bonded_port_id(bonded_port_id) != 0)
664                 return -1;
665
666         internals = rte_eth_devices[bonded_port_id].data->dev_private;
667
668         return internals->balance_xmit_policy;
669 }
670
671 int
672 rte_eth_bond_link_monitoring_set(uint16_t bonded_port_id, uint32_t internal_ms)
673 {
674         struct bond_dev_private *internals;
675
676         if (valid_bonded_port_id(bonded_port_id) != 0)
677                 return -1;
678
679         internals = rte_eth_devices[bonded_port_id].data->dev_private;
680         internals->link_status_polling_interval_ms = internal_ms;
681
682         return 0;
683 }
684
685 int
686 rte_eth_bond_link_monitoring_get(uint16_t bonded_port_id)
687 {
688         struct bond_dev_private *internals;
689
690         if (valid_bonded_port_id(bonded_port_id) != 0)
691                 return -1;
692
693         internals = rte_eth_devices[bonded_port_id].data->dev_private;
694
695         return internals->link_status_polling_interval_ms;
696 }
697
698 int
699 rte_eth_bond_link_down_prop_delay_set(uint16_t bonded_port_id,
700                                        uint32_t delay_ms)
701
702 {
703         struct bond_dev_private *internals;
704
705         if (valid_bonded_port_id(bonded_port_id) != 0)
706                 return -1;
707
708         internals = rte_eth_devices[bonded_port_id].data->dev_private;
709         internals->link_down_delay_ms = delay_ms;
710
711         return 0;
712 }
713
714 int
715 rte_eth_bond_link_down_prop_delay_get(uint16_t bonded_port_id)
716 {
717         struct bond_dev_private *internals;
718
719         if (valid_bonded_port_id(bonded_port_id) != 0)
720                 return -1;
721
722         internals = rte_eth_devices[bonded_port_id].data->dev_private;
723
724         return internals->link_down_delay_ms;
725 }
726
727 int
728 rte_eth_bond_link_up_prop_delay_set(uint16_t bonded_port_id, uint32_t delay_ms)
729
730 {
731         struct bond_dev_private *internals;
732
733         if (valid_bonded_port_id(bonded_port_id) != 0)
734                 return -1;
735
736         internals = rte_eth_devices[bonded_port_id].data->dev_private;
737         internals->link_up_delay_ms = delay_ms;
738
739         return 0;
740 }
741
742 int
743 rte_eth_bond_link_up_prop_delay_get(uint16_t bonded_port_id)
744 {
745         struct bond_dev_private *internals;
746
747         if (valid_bonded_port_id(bonded_port_id) != 0)
748                 return -1;
749
750         internals = rte_eth_devices[bonded_port_id].data->dev_private;
751
752         return internals->link_up_delay_ms;
753 }