bond: support link status polling
[dpdk.git] / lib / librte_pmd_bond / rte_eth_bond_api.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <rte_mbuf.h>
35 #include <rte_malloc.h>
36 #include <rte_ethdev.h>
37 #include <rte_tcp.h>
38
39 #include "rte_eth_bond.h"
40 #include "rte_eth_bond_private.h"
41
42 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
43
44 int
45 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
46 {
47         size_t len;
48
49         /* Check valid pointer */
50         if (eth_dev->driver->pci_drv.name == NULL || driver_name == NULL)
51                 return -1;
52
53         /* Check string lengths are equal */
54         len = strlen(driver_name);
55         if (strlen(eth_dev->driver->pci_drv.name) != len)
56                 return -1;
57
58         /* Compare strings */
59         return strncmp(eth_dev->driver->pci_drv.name, driver_name, len);
60 }
61
62 int
63 valid_port_id(uint8_t port_id)
64 {
65         /* Verify that port id is valid */
66         int ethdev_count = rte_eth_dev_count();
67         if (port_id >= ethdev_count) {
68                 RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
69                                 port_id, ethdev_count);
70                 return -1;
71         }
72
73         return 0;
74 }
75
76 int
77 valid_bonded_port_id(uint8_t port_id)
78 {
79         /* Verify that port id's are valid */
80         if (valid_port_id(port_id))
81                 return -1;
82
83         /* Verify that bonded_port_id refers to a bonded port */
84         if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
85                 RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
86                                 port_id);
87                 return -1;
88         }
89
90         return 0;
91 }
92
93 int
94 valid_slave_port_id(uint8_t port_id)
95 {
96         /* Verify that port id's are valid */
97         if (valid_port_id(port_id))
98                 return -1;
99
100         /* Verify that port_id refers to a non bonded port */
101         if (!valid_bonded_ethdev(&rte_eth_devices[port_id]))
102                 return -1;
103
104         return 0;
105 }
106
107 uint8_t
108 number_of_sockets(void)
109 {
110         int sockets = 0;
111         int i;
112         const struct rte_memseg *ms = rte_eal_get_physmem_layout();
113
114         for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
115                 if (sockets < ms[i].socket_id)
116                         sockets = ms[i].socket_id;
117         }
118
119         /* Number of sockets = maximum socket_id + 1 */
120         return ++sockets;
121 }
122
123 const char *driver_name = "Link Bonding PMD";
124
125 int
126 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
127 {
128         struct rte_pci_device *pci_dev = NULL;
129         struct bond_dev_private *internals = NULL;
130         struct rte_eth_dev *eth_dev = NULL;
131         struct eth_driver *eth_drv = NULL;
132         struct rte_pci_driver *pci_drv = NULL;
133         struct rte_pci_id *pci_id_table = NULL;
134         /* now do all data allocation - for eth_dev structure, dummy pci driver
135          * and internal (private) data
136          */
137
138         if (name == NULL) {
139                 RTE_BOND_LOG(ERR, "Invalid name specified");
140                 goto err;
141         }
142
143         if (socket_id >= number_of_sockets()) {
144                 RTE_BOND_LOG(ERR,
145                                 "Invalid socket id specified to create bonded device on.");
146                 goto err;
147         }
148
149         pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
150         if (pci_dev == NULL) {
151                 RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
152                 goto err;
153         }
154
155         eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
156         if (eth_drv == NULL) {
157                 RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
158                 goto err;
159         }
160
161         pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
162         if (pci_drv == NULL) {
163                 RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
164                 goto err;
165         }
166         pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
167         if (pci_drv == NULL) {
168                 RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
169                 goto err;
170         }
171
172         pci_drv->id_table = pci_id_table;
173
174         pci_drv->id_table->device_id = PCI_ANY_ID;
175         pci_drv->id_table->subsystem_device_id = PCI_ANY_ID;
176         pci_drv->id_table->vendor_id = PCI_ANY_ID;
177         pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
178
179         pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
180
181         internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
182         if (internals == NULL) {
183                 RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
184                 goto err;
185         }
186
187         /* reserve an ethdev entry */
188         eth_dev = rte_eth_dev_allocate(name);
189         if (eth_dev == NULL) {
190                 RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
191                 goto err;
192         }
193
194         pci_dev->numa_node = socket_id;
195         pci_drv->name = driver_name;
196
197         eth_drv->pci_drv = (struct rte_pci_driver)(*pci_drv);
198         eth_dev->driver = eth_drv;
199
200         eth_dev->data->dev_private = internals;
201         eth_dev->data->nb_rx_queues = (uint16_t)1;
202         eth_dev->data->nb_tx_queues = (uint16_t)1;
203
204         TAILQ_INIT(&(eth_dev->callbacks));
205
206         eth_dev->data->dev_link.link_status = 0;
207
208         eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
209                         socket_id);
210
211         eth_dev->data->dev_started = 0;
212         eth_dev->data->promiscuous = 0;
213         eth_dev->data->scattered_rx = 0;
214         eth_dev->data->all_multicast = 0;
215
216         eth_dev->dev_ops = &default_dev_ops;
217         eth_dev->pci_dev = pci_dev;
218
219         if (bond_ethdev_mode_set(eth_dev, mode)) {
220                 RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
221                                  eth_dev->data->port_id, mode);
222                 goto err;
223         }
224
225         rte_spinlock_init(&internals->lock);
226
227         internals->port_id = eth_dev->data->port_id;
228         internals->current_primary_port = 0;
229         internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
230         internals->user_defined_mac = 0;
231         internals->link_props_set = 0;
232
233         internals->link_status_polling_enabled = 0;
234
235         internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
236         internals->link_down_delay_ms = 0;
237         internals->link_up_delay_ms = 0;
238
239         internals->slave_count = 0;
240         internals->active_slave_count = 0;
241
242         memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
243         memset(internals->slaves, 0, sizeof(internals->slaves));
244
245         return eth_dev->data->port_id;
246
247 err:
248         if (pci_dev)
249                 rte_free(pci_dev);
250         if (pci_drv)
251                 rte_free(pci_drv);
252         if (pci_id_table)
253                 rte_free(pci_id_table);
254         if (eth_drv)
255                 rte_free(eth_drv);
256         if (internals)
257                 rte_free(internals);
258         return -1;
259 }
260
261 static int
262 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
263 {
264         struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
265         struct bond_dev_private *internals;
266         struct bond_dev_private *temp_internals;
267         struct rte_eth_link link_props;
268
269         int i, j;
270
271         if (valid_slave_port_id(slave_port_id) != 0)
272                 return -1;
273
274         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
275         internals = bonded_eth_dev->data->dev_private;
276
277         /* Verify that new slave device is not already a slave of another
278          * bonded device */
279         for (i = rte_eth_dev_count()-1; i >= 0; i--) {
280                 if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
281                         temp_internals = rte_eth_devices[i].data->dev_private;
282
283                         for (j = 0; j < temp_internals->slave_count; j++) {
284                                 /* Device already a slave of a bonded device */
285                                 if (temp_internals->slaves[j].port_id == slave_port_id) {
286                                         RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
287                                                         slave_port_id);
288                                         return -1;
289                                 }
290                         }
291                 }
292         }
293
294         slave_eth_dev = &rte_eth_devices[slave_port_id];
295
296         /* Add slave details to bonded device */
297         slave_add(internals, slave_eth_dev);
298
299         if (internals->slave_count < 1) {
300                 /* if MAC is not user defined then use MAC of first slave add to
301                  * bonded device */
302                 if (!internals->user_defined_mac)
303                         mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
304
305                 /* Inherit eth dev link properties from first slave */
306                 link_properties_set(bonded_eth_dev,
307                                 &(slave_eth_dev->data->dev_link));
308
309                 /* Make primary slave */
310                 internals->primary_port = slave_port_id;
311         } else {
312                 /* Check slave link properties are supported if props are set,
313                  * all slaves must be the same */
314                 if (internals->link_props_set) {
315                         if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
316                                                                           &(slave_eth_dev->data->dev_link))) {
317                                 RTE_BOND_LOG(ERR,
318                                                 "Slave port %d link speed/duplex not supported",
319                                                 slave_port_id);
320                                 return -1;
321                         }
322                 } else {
323                         link_properties_set(bonded_eth_dev,
324                                         &(slave_eth_dev->data->dev_link));
325                 }
326         }
327
328         internals->slave_count++;
329
330         /* Update all slave devices MACs*/
331         mac_address_slaves_update(bonded_eth_dev);
332
333         if (bonded_eth_dev->data->dev_started) {
334                 if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
335                         RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
336                                         slave_port_id);
337                         return -1;
338                 }
339         }
340
341         /* Register link status change callback with bonded device pointer as
342          * argument*/
343         rte_eth_dev_callback_register(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
344                         bond_ethdev_lsc_event_callback, &bonded_eth_dev->data->port_id);
345
346         /* If bonded device is started then we can add the slave to our active
347          * slave array */
348         if (bonded_eth_dev->data->dev_started) {
349                 rte_eth_link_get_nowait(slave_port_id, &link_props);
350
351                  if (link_props.link_status == 1)
352                         internals->active_slaves[internals->active_slave_count++] =
353                                         slave_port_id;
354         }
355         return 0;
356
357 }
358
359
360 int
361 rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
362 {
363         struct rte_eth_dev *bonded_eth_dev;
364         struct bond_dev_private *internals;
365
366         int retval;
367
368         /* Verify that port id's are valid bonded and slave ports */
369         if (valid_bonded_port_id(bonded_port_id) != 0)
370                 return -1;
371
372         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
373         internals = bonded_eth_dev->data->dev_private;
374
375         rte_spinlock_lock(&internals->lock);
376
377         retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
378
379         rte_spinlock_unlock(&internals->lock);
380
381         return retval;
382 }
383
384
385 static int
386 __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
387 {
388         struct bond_dev_private *internals;
389
390         int i, slave_idx = -1;
391
392         if (valid_slave_port_id(slave_port_id) != 0)
393                 return -1;
394
395         internals = rte_eth_devices[bonded_port_id].data->dev_private;
396
397         /* first remove from active slave list */
398         for (i = 0; i < internals->active_slave_count; i++) {
399                 if (internals->active_slaves[i] == slave_port_id)
400                         slave_idx = i;
401
402                 /* shift active slaves up active array list */
403                 if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
404                         internals->active_slaves[i] = internals->active_slaves[i+1];
405         }
406
407         if (slave_idx >= 0)
408                 internals->active_slave_count--;
409
410         slave_idx = -1;
411         /* now find in slave list */
412         for (i = 0; i < internals->slave_count; i++)
413                 if (internals->slaves[i].port_id == slave_port_id) {
414                         slave_idx = i;
415                         break;
416                 }
417
418         if (slave_idx < 0) {
419                 RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
420                                 internals->slave_count);
421                 return -1;
422         }
423
424         /* Un-register link status change callback with bonded device pointer as
425          * argument*/
426         rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
427                         bond_ethdev_lsc_event_callback,
428                         &rte_eth_devices[bonded_port_id].data->port_id);
429
430         /* Restore original MAC address of slave device */
431         mac_address_set(&rte_eth_devices[slave_port_id],
432                         &(internals->slaves[slave_idx].persisted_mac_addr));
433
434         slave_remove(internals, &rte_eth_devices[slave_port_id]);
435
436         /*  first slave in the active list will be the primary by default,
437          *  otherwise use first device in list */
438         if (internals->current_primary_port == slave_port_id) {
439                 if (internals->active_slave_count > 0)
440                         internals->current_primary_port = internals->active_slaves[0];
441                 else if (internals->slave_count > 0)
442                         internals->current_primary_port = internals->slaves[0].port_id;
443                 else
444                         internals->primary_port = 0;
445         }
446
447         if (internals->active_slave_count < 1) {
448                 /* reset device link properties as no slaves are active */
449                 link_properties_reset(&rte_eth_devices[bonded_port_id]);
450
451                 /* if no slaves are any longer attached to bonded device and MAC is not
452                  * user defined then clear MAC of bonded device as it will be reset
453                  * when a new slave is added */
454                 if (internals->slave_count < 1 && !internals->user_defined_mac)
455                         memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0,
456                                         sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs)));
457         }
458
459         return 0;
460 }
461
462 int
463 rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
464 {
465         struct rte_eth_dev *bonded_eth_dev;
466         struct bond_dev_private *internals;
467         int retval;
468
469         if (valid_bonded_port_id(bonded_port_id) != 0)
470                 return -1;
471
472         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
473         internals = bonded_eth_dev->data->dev_private;
474
475         rte_spinlock_lock(&internals->lock);
476
477         retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
478
479         rte_spinlock_unlock(&internals->lock);
480
481         return retval;
482 }
483
484 int
485 rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode)
486 {
487         if (valid_bonded_port_id(bonded_port_id) != 0)
488                 return -1;
489
490         return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
491 }
492
493 int
494 rte_eth_bond_mode_get(uint8_t bonded_port_id)
495 {
496         struct bond_dev_private *internals;
497
498         if (valid_bonded_port_id(bonded_port_id) != 0)
499                 return -1;
500
501         internals = rte_eth_devices[bonded_port_id].data->dev_private;
502
503         return internals->mode;
504 }
505
506 int
507 rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id)
508 {
509         struct bond_dev_private *internals;
510
511         if (valid_bonded_port_id(bonded_port_id) != 0)
512                 return -1;
513
514         if (valid_slave_port_id(slave_port_id) != 0)
515                 return -1;
516
517         internals =  rte_eth_devices[bonded_port_id].data->dev_private;
518
519         internals->user_defined_primary_port = 1;
520         internals->primary_port = slave_port_id;
521
522         bond_ethdev_primary_set(internals, slave_port_id);
523
524         return 0;
525 }
526
527 int
528 rte_eth_bond_primary_get(uint8_t bonded_port_id)
529 {
530         struct bond_dev_private *internals;
531
532         if (valid_bonded_port_id(bonded_port_id) != 0)
533                 return -1;
534
535         internals = rte_eth_devices[bonded_port_id].data->dev_private;
536
537         if (internals->slave_count < 1)
538                 return -1;
539
540         return internals->current_primary_port;
541 }
542 int
543 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
544 {
545         struct bond_dev_private *internals;
546         int i;
547
548         if (valid_bonded_port_id(bonded_port_id) != 0)
549                 return -1;
550
551         if (slaves == NULL)
552                 return -1;
553
554         internals = rte_eth_devices[bonded_port_id].data->dev_private;
555
556         if (internals->slave_count > len)
557                 return -1;
558
559         for (i = 0; i < internals->slave_count; i++)
560                 slaves[i] = internals->slaves[i].port_id;
561
562         return internals->slave_count;
563 }
564
565 int
566 rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
567                 uint8_t len)
568 {
569         struct bond_dev_private *internals;
570
571         if (valid_bonded_port_id(bonded_port_id) != 0)
572                 return -1;
573
574         if (slaves == NULL)
575                 return -1;
576
577         internals = rte_eth_devices[bonded_port_id].data->dev_private;
578
579         if (internals->active_slave_count > len)
580                 return -1;
581
582         memcpy(slaves, internals->active_slaves, internals->active_slave_count);
583
584         return internals->active_slave_count;
585 }
586
587 int
588 rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
589                 struct ether_addr *mac_addr)
590 {
591         struct rte_eth_dev *bonded_eth_dev;
592         struct bond_dev_private *internals;
593
594         if (valid_bonded_port_id(bonded_port_id) != 0)
595                 return -1;
596
597         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
598         internals = bonded_eth_dev->data->dev_private;
599
600         /* Set MAC Address of Bonded Device */
601         if (mac_address_set(bonded_eth_dev, mac_addr))
602                 return -1;
603
604         internals->user_defined_mac = 1;
605
606         /* Update all slave devices MACs*/
607         if (internals->slave_count > 0)
608                 return mac_address_slaves_update(bonded_eth_dev);
609
610         return 0;
611 }
612
613 int
614 rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
615 {
616         struct rte_eth_dev *bonded_eth_dev;
617         struct bond_dev_private *internals;
618
619         if (valid_bonded_port_id(bonded_port_id) != 0)
620                 return -1;
621
622         bonded_eth_dev = &rte_eth_devices[bonded_port_id];
623         internals = bonded_eth_dev->data->dev_private;
624
625         internals->user_defined_mac = 0;
626
627         if (internals->slave_count > 0) {
628                 /* Set MAC Address of Bonded Device */
629                 if (mac_address_set(bonded_eth_dev,
630                                 &internals->slaves[internals->primary_port].persisted_mac_addr)
631                                 != 0) {
632                         RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
633                         return -1;
634                 }
635                 /* Update all slave devices MAC addresses */
636                 return mac_address_slaves_update(bonded_eth_dev);
637         }
638         /* No need to update anything as no slaves present */
639         return 0;
640 }
641
642 int
643 rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy)
644 {
645         struct bond_dev_private *internals;
646
647         if (valid_bonded_port_id(bonded_port_id) != 0)
648                 return -1;
649
650         internals = rte_eth_devices[bonded_port_id].data->dev_private;
651
652         switch (policy) {
653         case BALANCE_XMIT_POLICY_LAYER2:
654         case BALANCE_XMIT_POLICY_LAYER23:
655         case BALANCE_XMIT_POLICY_LAYER34:
656                 internals->balance_xmit_policy = policy;
657                 break;
658
659         default:
660                 return -1;
661         }
662         return 0;
663 }
664
665 int
666 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
667 {
668         struct bond_dev_private *internals;
669
670         if (valid_bonded_port_id(bonded_port_id) != 0)
671                 return -1;
672
673         internals = rte_eth_devices[bonded_port_id].data->dev_private;
674
675         return internals->balance_xmit_policy;
676 }
677
678
679 int
680 rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
681 {
682         struct bond_dev_private *internals;
683
684         if (valid_bonded_port_id(bonded_port_id) != 0)
685                 return -1;
686
687         internals = rte_eth_devices[bonded_port_id].data->dev_private;
688         internals->link_status_polling_interval_ms = internal_ms;
689
690         return 0;
691 }
692
693 int
694 rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
695 {
696         struct bond_dev_private *internals;
697
698         if (valid_bonded_port_id(bonded_port_id) != 0)
699                 return -1;
700
701         internals = rte_eth_devices[bonded_port_id].data->dev_private;
702
703         return internals->link_status_polling_interval_ms;
704 }
705
706 int
707 rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
708
709 {
710         struct bond_dev_private *internals;
711
712         if (valid_bonded_port_id(bonded_port_id) != 0)
713                 return -1;
714
715         internals = rte_eth_devices[bonded_port_id].data->dev_private;
716         internals->link_down_delay_ms = delay_ms;
717
718         return 0;
719 }
720
721 int
722 rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
723 {
724         struct bond_dev_private *internals;
725
726         if (valid_bonded_port_id(bonded_port_id) != 0)
727                 return -1;
728
729         internals = rte_eth_devices[bonded_port_id].data->dev_private;
730
731         return internals->link_down_delay_ms;
732 }
733
734
735 int
736 rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
737
738 {
739         struct bond_dev_private *internals;
740
741         if (valid_bonded_port_id(bonded_port_id) != 0)
742                 return -1;
743
744         internals = rte_eth_devices[bonded_port_id].data->dev_private;
745         internals->link_up_delay_ms = delay_ms;
746
747         return 0;
748 }
749
750 int
751 rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
752 {
753         struct bond_dev_private *internals;
754
755         if (valid_bonded_port_id(bonded_port_id) != 0)
756                 return -1;
757
758         internals = rte_eth_devices[bonded_port_id].data->dev_private;
759
760         return internals->link_up_delay_ms;
761 }