2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <interface.h>
19 extern interface_main_t ifm;
20 extern uint8_t ifm_debug;
21 extern int USE_RTM_LOCKS;
22 extern rte_rwlock_t rwlock;
24 int ifm_bond_port_create(const char *name, int mode, port_config_t * portconf)
27 l2_phy_interface_t *bond_port;
28 if (ifm_debug && IFM_DEBUG_CONFIG)
29 RTE_LOG(INFO, IFM, "%s: i/p name %p, mode %d\n\r", __FUNCTION__,
32 RTE_LOG(ERR, IFM, "%s: Param name cannot be NULL\n\r",
36 if (mode < 0 || mode > 6) {
37 RTE_LOG(ERR, IFM, "%s: Param mode should be withing 0 to 6\n\r",
41 if (portconf == NULL) {
42 RTE_LOG(ERR, IFM, "%s: Param portconf cannot be NULL\n\r",
46 bond_port = ifm_get_port_by_name(name);
47 if (bond_port == NULL) {
48 if (ifm_debug && IFM_DEBUG_CONFIG)
49 RTE_LOG(INFO, IFM, "Call ifm_port_setup %s\n\r", name);
50 port_id = rte_eth_bond_create(name, mode, 0);
53 "%s: Failed to create bond port %s with mode %u\n\r",
54 __FUNCTION__, name, mode);
58 "%s: Created bond port %s(%u) on socket %u with "
59 "mode %u.\n\r", __FUNCTION__, name, port_id,
60 rte_eth_dev_socket_id(port_id), mode);
62 bond_port = (l2_phy_interface_t *) rte_zmalloc(NULL,
66 bond_port->pmdid = port_id;
67 strncpy(bond_port->ifname, name, IFM_IFNAME_LEN);
68 memcpy(&bond_port->port_config, portconf,
69 sizeof(port_config_t));
70 bond_port->flags |= IFM_MASTER;
71 struct bond_port *bond_info;
72 bond_info = (struct bond_port *)rte_zmalloc(NULL,
76 bond_info->socket_id = rte_eth_dev_socket_id(port_id);
77 bond_info->mode = mode;
78 bond_info->bond_portid = port_id;
79 bond_port->bond_config = bond_info;
80 if (mode == IFM_BONDING_MODE_8023AD)
81 bond_port->tx_buf_len =
82 (2 * RTE_ETH_TX_BUFFER_SIZE(IFM_BURST_SIZE)) *
84 //ifm_add_port_to_port_list(bond_port);
85 ifm.port_list[port_id] = bond_port;
86 if (ifm_debug && IFM_DEBUG_CONFIG)
88 "%s: Added bond port %s(%u) to port list\n\r",
89 __FUNCTION__, name, port_id);
91 RTE_LOG(INFO, IFM, "%s: Port %s already exists in the"
92 " port list\n\r", __FUNCTION__, name);
93 if (ifm_debug & IFM_DEBUG_LOCKS)
94 RTE_LOG(INFO, IFM, "%s: Acquiring lock @ %d\n\r",
95 __FUNCTION__, __LINE__);
99 rte_rwlock_write_lock(&rwlock);
101 if (!(bond_port->flags & IFM_MASTER)) {
102 RTE_LOG(ERR, IFM, "%s: Previously port %s was not "
103 "configured as Bond port\n\r", __FUNCTION__,
105 if (ifm_debug & IFM_DEBUG_LOCKS)
107 "%s: Releasing lock @ %d\n\r",
108 __FUNCTION__, __LINE__);
112 rte_rwlock_write_unlock(&rwlock);
115 if (bond_port->bond_config->mode != mode) {
116 if (rte_eth_bond_mode_set(bond_port->pmdid, mode) < 0) {
117 RTE_LOG(ERR, IFM, "%s: rte_eth_bond_mode_set "
118 "failed\n\r", __FUNCTION__);
119 if (ifm_debug & IFM_DEBUG_LOCKS)
121 "%s: Releasing lock @ %d\n\r",
122 __FUNCTION__, __LINE__);
126 rte_rwlock_write_unlock(&rwlock);
130 bond_port->bond_config->mode =
131 rte_eth_bond_mode_get(bond_port->pmdid);
132 /* xmit policy may change for based on mode */
133 bond_port->bond_config->xmit_policy =
134 rte_eth_bond_xmit_policy_get(bond_port->pmdid);
135 if (ifm_debug && IFM_DEBUG_CONFIG)
137 "%s: Bond port %u mode is updated. Mode %u xmit_policy %u."
138 "\n\r", __FUNCTION__, bond_port->pmdid,
139 bond_port->bond_config->mode,
140 bond_port->bond_config->xmit_policy);
142 port_id = bond_port->pmdid;
143 if (ifm_debug & IFM_DEBUG_LOCKS)
144 RTE_LOG(INFO, IFM, "%s: Acquiring lock @ %d\n\r",
145 __FUNCTION__, __LINE__);
149 rte_rwlock_write_unlock(&rwlock);
154 int ifm_bond_port_delete(const char *name)
156 l2_phy_interface_t *bond_port;
158 RTE_LOG(ERR, IFM, "%s: Param name cannot be NULL\n\r",
162 bond_port = ifm_get_port_by_name(name);
163 if (ifm_debug & IFM_DEBUG_LOCKS)
164 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
165 __FUNCTION__, __LINE__);
169 rte_rwlock_write_lock(&rwlock);
170 if (bond_port == NULL) {
171 RTE_LOG(ERR, IFM, "%s: Given bond port with name %s not"
172 " found in the list\n\r", __FUNCTION__, name);
175 if (!(bond_port->flags & IFM_MASTER)) {
176 RTE_LOG(ERR, IFM, "%s: Given bond port %s is not "
177 "configured is not bond port\n\r", __FUNCTION__, name);
178 if (ifm_debug & IFM_DEBUG_LOCKS)
179 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
180 __FUNCTION__, __LINE__);
184 rte_rwlock_write_unlock(&rwlock);
188 if (bond_port->bond_config && bond_port->bond_config->slave_count > 0) {
189 RTE_LOG(ERR, IFM, "%s: First unbind all slave "
190 "ports from the bond port %s\n\r", __FUNCTION__, name);
191 if (ifm_debug & IFM_DEBUG_LOCKS)
192 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
193 __FUNCTION__, __LINE__);
197 rte_rwlock_write_unlock(&rwlock);
202 ret = rte_eth_bond_free(name);
204 RTE_LOG(ERR, IFM, "%s: Failed to delete "
205 "bond port %s\n\r", __FUNCTION__, name);
206 if (ifm_debug & IFM_DEBUG_LOCKS)
207 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
208 __FUNCTION__, __LINE__);
212 rte_rwlock_write_unlock(&rwlock);
216 if (ifm_debug & IFM_DEBUG_CONFIG)
217 RTE_LOG(INFO, IFM, "%s: Bond port %s deleted successfully\n\r",
220 if (bond_port && bond_port->bond_config != NULL) {
221 rte_free(bond_port->bond_config);
222 bond_port->bond_config = NULL;
224 if (ifm_debug & IFM_DEBUG_LOCKS)
225 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
226 __FUNCTION__, __LINE__);
230 rte_rwlock_write_unlock(&rwlock);
231 ifm_remove_port_details(bond_port->pmdid);
232 //ifm.port_list[bond_port->pmdid] = NULL;
236 int ifm_add_slave_port(uint8_t bonded_port_id, uint8_t slave_port_id)
238 l2_phy_interface_t *bond_port, *slave_port;
239 bond_port = ifm_get_port(bonded_port_id);
240 // bond_port = ifm.port_list[bonded_port_id];
241 slave_port = ifm_get_port(slave_port_id);
242 // slave_port = ifm.port_list[slave_port_id];
243 if (ifm_debug & IFM_DEBUG)
244 RTE_LOG(INFO, IFM, "%s: i/p bond id %u, slave id %u\n\r",
245 __FUNCTION__, bonded_port_id, slave_port_id);
246 if (ifm_debug & IFM_DEBUG_LOCKS)
247 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
248 __FUNCTION__, __LINE__);
252 rte_rwlock_write_lock(&rwlock);
254 if (bond_port == NULL) {
255 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
256 " port list.\n\r", __FUNCTION__, bonded_port_id);
257 if (ifm_debug & IFM_DEBUG_LOCKS)
258 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
259 __FUNCTION__, __LINE__);
263 rte_rwlock_write_unlock(&rwlock);
267 if (slave_port == NULL) {
268 RTE_LOG(ERR, IFM, "%s: Given slave port %u is not available in "
269 "port list.\n\r", __FUNCTION__, slave_port_id);
270 if (ifm_debug & IFM_DEBUG_LOCKS)
271 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
272 __FUNCTION__, __LINE__);
276 rte_rwlock_write_unlock(&rwlock);
280 if (bond_port && !(bond_port->flags & IFM_MASTER)) {
281 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not configured "
282 "as Master port. %u\n\r", __FUNCTION__, bonded_port_id,
283 bond_port->flags & IFM_MASTER);
284 if (ifm_debug & IFM_DEBUG_LOCKS)
285 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
286 __FUNCTION__, __LINE__);
290 rte_rwlock_write_unlock(&rwlock);
294 if (bond_port && bond_port->bond_config
295 && bond_port->bond_config->slave_count == RTE_MAX_ETHPORTS) {
297 "%s: Failed to bind.Already %u ports are bonded to master port...\n\r ",
298 __FUNCTION__, RTE_MAX_ETHPORTS);
299 if (ifm_debug & IFM_DEBUG_LOCKS)
300 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
301 __FUNCTION__, __LINE__);
305 rte_rwlock_write_unlock(&rwlock);
309 if (slave_port && slave_port->flags & IFM_SLAVE) {
310 /* Have to check whether the port is already part of someother bond port */
311 if (slave_port->bond_config != NULL) {
312 if (bonded_port_id !=
313 slave_port->bond_config->bond_portid) {
315 "%s: Slave port %u is already part"
316 " of other bond port %u.\n\r",
317 __FUNCTION__, slave_port_id,
318 slave_port->bond_config->bond_portid);
319 if (ifm_debug & IFM_DEBUG_LOCKS)
321 "%s: Releasing WR lock @ %d\n\r",
322 __FUNCTION__, __LINE__);
326 rte_rwlock_write_unlock(&rwlock);
330 if (ifm_debug & IFM_DEBUG)
332 "%s: Slave port %u is already bounded to %u\n\r",
333 __FUNCTION__, slave_port_id,
335 if (ifm_debug & IFM_DEBUG_LOCKS)
337 "%s: Releasing WR lock @ %d\n\r",
338 __FUNCTION__, __LINE__);
342 rte_rwlock_write_unlock(&rwlock);
348 if (bond_port->bond_config && bond_port->bond_config->slave_count &&
349 bond_port->link_speed != slave_port->link_speed
350 && bond_port->link_duplex != slave_port->link_duplex) {
352 "%s: Error in adding slave port to bond port. Reason speed mismatch\n\r",
354 if (ifm_debug & IFM_DEBUG_LOCKS)
355 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
356 __FUNCTION__, __LINE__);
360 rte_rwlock_write_unlock(&rwlock);
364 if (ifm_debug & IFM_DEBUG)
365 RTE_LOG(INFO, IFM, "%s: Slave port %u Master port %u\n\r",
366 __FUNCTION__, slave_port_id, bonded_port_id);
368 ret = rte_eth_bond_slave_add(bond_port->pmdid, slave_port->pmdid);
370 RTE_LOG(ERR, IFM, "%s: Failed to add slave port %u to bond "
371 "port %u.\n\r", __FUNCTION__, slave_port->pmdid,
373 if (ifm_debug & IFM_DEBUG_LOCKS)
374 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
375 __FUNCTION__, __LINE__);
379 rte_rwlock_write_unlock(&rwlock);
383 slave_port->flags |= IFM_SLAVE;
384 /* Populate bond config information */
385 if (bond_port->bond_config) {
386 bond_port->bond_config->xmit_policy =
387 rte_eth_bond_xmit_policy_get(bond_port->pmdid);
388 bond_port->bond_config->internal_ms =
389 rte_eth_bond_link_monitoring_get(bond_port->pmdid);
390 bond_port->bond_config->link_up_delay_ms =
391 rte_eth_bond_link_up_prop_delay_get(bond_port->pmdid);
392 bond_port->bond_config->link_down_delay_ms =
393 rte_eth_bond_link_down_prop_delay_get(bond_port->pmdid);
394 bond_port->bond_config->primary =
395 rte_eth_bond_primary_get(bond_port->pmdid);
396 bond_port->bond_config->slave_count =
397 rte_eth_bond_slaves_get(bond_port->pmdid,
398 bond_port->bond_config->slaves,
400 bond_port->bond_config->active_slave_count =
401 rte_eth_bond_active_slaves_get(bond_port->pmdid,
402 bond_port->bond_config->
405 slave_port->bond_config = bond_port->bond_config;
406 if (ifm_debug & IFM_DEBUG)
407 RTE_LOG(INFO, IFM, "%s: Slave count is %u\n\r",
409 bond_port->bond_config->slave_count);
410 if (bond_port->bond_config->slave_count == 1) {
412 ifm_port_setup(bond_port->pmdid,
413 &(bond_port->port_config));
416 "%s: Failed to start bond port %u.\n\r",
417 __FUNCTION__, bond_port->pmdid);
418 if (ifm_debug & IFM_DEBUG_LOCKS)
420 "%s: Releasing WR lock @ %d\n\r",
421 __FUNCTION__, __LINE__);
425 rte_rwlock_write_unlock(&rwlock);
430 if (ifm_debug & IFM_DEBUG)
431 RTE_LOG(INFO, IFM, "%s: Skipping"
432 " port setup\n\r", __FUNCTION__);
435 if (ifm_debug & IFM_DEBUG_LOCKS)
436 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
437 __FUNCTION__, __LINE__);
441 rte_rwlock_write_unlock(&rwlock);
446 int ifm_remove_slave_port(uint8_t bonded_port_id, uint8_t slave_port_id)
448 l2_phy_interface_t *bond_port, *slave_port;
450 bond_port = ifm_get_port(bonded_port_id);
451 //bond_port = ifm.port_list[bonded_port_id];
452 slave_port = ifm_get_port(slave_port_id);
453 //slave_port = ifm.port_list[slave_port_id];
455 if (ifm_debug & IFM_DEBUG_LOCKS)
456 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
457 __FUNCTION__, __LINE__);
461 rte_rwlock_write_lock(&rwlock);
463 if (bond_port == NULL) {
464 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available "
465 "in port list.\n\r", __FUNCTION__, bonded_port_id);
466 if (ifm_debug & IFM_DEBUG_LOCKS)
467 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
468 __FUNCTION__, __LINE__);
472 rte_rwlock_write_unlock(&rwlock);
475 if (slave_port == NULL) {
476 RTE_LOG(ERR, IFM, "%s: Given slave port %u is not available "
477 "in port list.\n\r", __FUNCTION__, slave_port_id);
478 if (ifm_debug & IFM_DEBUG_LOCKS)
479 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
480 __FUNCTION__, __LINE__);
484 rte_rwlock_write_unlock(&rwlock);
487 if (bond_port && !(bond_port->flags & IFM_MASTER)) {
488 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not configured "
489 "as Master port.\n\r", __FUNCTION__, bonded_port_id);
490 if (ifm_debug & IFM_DEBUG_LOCKS)
491 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
492 __FUNCTION__, __LINE__);
496 rte_rwlock_write_unlock(&rwlock);
499 if (slave_port && !(slave_port->flags & IFM_SLAVE)) {
500 RTE_LOG(ERR, IFM, "%s: Given slave port %u is not configured"
501 " as slave port.\n\r", __FUNCTION__, slave_port_id);
502 if (ifm_debug & IFM_DEBUG_LOCKS)
503 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
504 __FUNCTION__, __LINE__);
508 rte_rwlock_write_unlock(&rwlock);
513 for (i = 0; i < bond_port->bond_config->slave_count; i++) {
514 if (slave_port_id == bond_port->bond_config->slaves[i]) {
520 RTE_LOG(ERR, IFM, "%s: Given slave port %u is not binded "
521 "with bond port %u\n\r", __FUNCTION__, slave_port_id,
523 if (ifm_debug & IFM_DEBUG_LOCKS)
524 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
525 __FUNCTION__, __LINE__);
529 rte_rwlock_write_unlock(&rwlock);
532 if (rte_eth_bond_slave_remove(bonded_port_id, slave_port_id) < 0) {
533 RTE_LOG(ERR, IFM, "%s: Failed to unbind slave port %u"
534 " from bond port %u\n\r", __FUNCTION__, slave_port_id,
536 if (ifm_debug & IFM_DEBUG_LOCKS)
537 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
538 __FUNCTION__, __LINE__);
542 rte_rwlock_write_unlock(&rwlock);
545 slave_port->flags &= ~IFM_SLAVE;
546 slave_port->bond_config = NULL;
547 bond_port->bond_config->primary =
548 rte_eth_bond_primary_get(bond_port->pmdid);
549 bond_port->bond_config->slave_count =
550 rte_eth_bond_slaves_get(bond_port->pmdid,
551 bond_port->bond_config->slaves,
553 bond_port->bond_config->active_slave_count =
554 rte_eth_bond_active_slaves_get(bond_port->pmdid,
555 bond_port->bond_config->
556 active_slaves, RTE_MAX_ETHPORTS);
558 if (ifm_debug & IFM_DEBUG)
559 RTE_LOG(ERR, IFM, "%s: Unbinded slave port %u from the bond "
560 "port %u %d\n\r", __FUNCTION__, slave_port_id,
562 rte_eth_bond_primary_get(bond_port->pmdid));
563 if (ifm_debug & IFM_DEBUG_LOCKS)
564 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
565 __FUNCTION__, __LINE__);
569 rte_rwlock_write_unlock(&rwlock);
573 int set_bond_mode(uint8_t bonded_port_id, uint8_t mode)
575 l2_phy_interface_t *bond_port;
576 bond_port = ifm_get_port(bonded_port_id);
577 //bond_port = ifm.port_list[bonded_port_id];
579 if (ifm_debug & IFM_DEBUG_LOCKS)
580 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
581 __FUNCTION__, __LINE__);
585 rte_rwlock_write_lock(&rwlock);
587 ifm_remove_port_details(bond_port->pmdid);
588 if (bond_port == NULL) {
589 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
590 " port list.\n\r", __FUNCTION__, bonded_port_id);
593 if (bond_port && bond_port->bond_config->mode == mode) {
594 if (ifm_debug & IFM_DEBUG)
596 "%s: Already bond port is set with the given"
597 " mode %u\n\r.", __FUNCTION__, mode);
598 if (ifm_debug & IFM_DEBUG_LOCKS)
599 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
600 __FUNCTION__, __LINE__);
604 rte_rwlock_write_unlock(&rwlock);
605 ifm_remove_port_details(bond_port->pmdid);
609 if (rte_eth_bond_mode_set(bond_port->pmdid, mode) < 0) {
611 "%s: Failed to set bond mode %u for port id %u\n\r.",
612 __FUNCTION__, mode, bond_port->pmdid);
613 if (ifm_debug & IFM_DEBUG_LOCKS)
614 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
615 __FUNCTION__, __LINE__);
619 rte_rwlock_write_unlock(&rwlock);
620 ifm_remove_port_details(bond_port->pmdid);
624 bond_port->bond_config->mode = rte_eth_bond_mode_get(bond_port->pmdid);
625 /* xmit policy may change for based on mode */
626 bond_port->bond_config->xmit_policy =
627 rte_eth_bond_xmit_policy_get(bond_port->pmdid);
628 if (ifm_debug & IFM_DEBUG)
630 "%s: Bond port %u mode is updated. Mode %u xmit_policy %u."
631 "\n\r.", __FUNCTION__, bond_port->pmdid,
632 bond_port->bond_config->mode,
633 bond_port->bond_config->xmit_policy);
634 if (ifm_debug & IFM_DEBUG_LOCKS)
635 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
636 __FUNCTION__, __LINE__);
640 rte_rwlock_write_unlock(&rwlock);
641 ifm_remove_port_details(bond_port->pmdid);
645 int get_bond_mode(uint8_t bonded_port_id)
647 l2_phy_interface_t *bond_port;
648 bond_port = ifm_get_port(bonded_port_id);
649 //bond_port = ifm.port_list[bonded_port_id];
651 if (ifm_debug & IFM_DEBUG_LOCKS)
652 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
653 __FUNCTION__, __LINE__);
657 rte_rwlock_read_lock(&rwlock);
659 if (bond_port == NULL) {
660 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
661 " port list.\n\r", __FUNCTION__, bonded_port_id);
662 if (ifm_debug & IFM_DEBUG_LOCKS)
663 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
664 __FUNCTION__, __LINE__);
668 rte_rwlock_read_unlock(&rwlock);
672 uint8_t mode = bond_port->bond_config->mode;
673 if (ifm_debug & IFM_DEBUG_LOCKS)
674 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
675 __FUNCTION__, __LINE__);
679 rte_rwlock_read_unlock(&rwlock);
684 int set_bond_primary(uint8_t bonded_port_id, uint8_t slave_port_id)
686 l2_phy_interface_t *bond_port;
687 l2_phy_interface_t *slave_port;
688 bond_port = ifm_get_port(bonded_port_id);
689 // bond_port = ifm.port_list[bonded_port_id];
690 slave_port = ifm_get_port(slave_port_id);
691 // slave_port = ifm.port_list[slave_port_id];
693 if (ifm_debug & IFM_DEBUG_LOCKS)
694 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
695 __FUNCTION__, __LINE__);
699 rte_rwlock_write_lock(&rwlock);
700 if (bond_port == NULL) {
701 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
702 " port list.\n\r", __FUNCTION__, bonded_port_id);
703 if (ifm_debug & IFM_DEBUG_LOCKS)
704 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
705 __FUNCTION__, __LINE__);
709 rte_rwlock_write_unlock(&rwlock);
712 if (slave_port == NULL) {
713 RTE_LOG(ERR, IFM, "%s: Given slave port %u is not available in"
714 " port list.\n\r", __FUNCTION__, bonded_port_id);
715 if (ifm_debug & IFM_DEBUG_LOCKS)
716 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
717 __FUNCTION__, __LINE__);
721 rte_rwlock_write_unlock(&rwlock);
726 for (i = 0; i < bond_port->bond_config->slave_count; i++) {
727 if (slave_port_id == bond_port->bond_config->slaves[i]) {
733 RTE_LOG(ERR, IFM, "%s: Slave port %u is not binded "
734 "with bond port %u. Slave port should be binded first\n\r",
735 __FUNCTION__, slave_port_id, bonded_port_id);
736 if (ifm_debug & IFM_DEBUG_LOCKS)
737 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
738 __FUNCTION__, __LINE__);
742 rte_rwlock_write_unlock(&rwlock);
746 if (bond_port->bond_config->primary == slave_port_id) {
747 if (ifm_debug & IFM_DEBUG)
749 "%s: Already slave port %u is primary for bond port"
750 "%u\n\r.", __FUNCTION__, bonded_port_id,
752 if (ifm_debug & IFM_DEBUG_LOCKS)
753 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
754 __FUNCTION__, __LINE__);
758 rte_rwlock_write_unlock(&rwlock);
762 if (rte_eth_bond_primary_set(bond_port->pmdid, slave_port->pmdid) < 0) {
764 "%s:Failed to set slave %u as primary for bond port %u\n\r.",
765 __FUNCTION__, slave_port->pmdid, bond_port->pmdid);
766 if (ifm_debug & IFM_DEBUG_LOCKS)
767 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
768 __FUNCTION__, __LINE__);
772 rte_rwlock_write_unlock(&rwlock);
776 bond_port->bond_config->primary =
777 rte_eth_bond_primary_get(bond_port->pmdid);
778 if (ifm_debug & IFM_DEBUG)
780 "%s: Primary port is updated as %u for bond port %u",
781 __FUNCTION__, bond_port->bond_config->primary,
783 if (ifm_debug & IFM_DEBUG_LOCKS)
784 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
785 __FUNCTION__, __LINE__);
789 rte_rwlock_write_unlock(&rwlock);
793 int get_bond_primary_port(uint8_t bonded_port_id)
795 l2_phy_interface_t *bond_port;
796 bond_port = ifm_get_port(bonded_port_id);
797 //bond_port = ifm.port_list[bonded_port_id];
799 if (ifm_debug & IFM_DEBUG_LOCKS)
800 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
801 __FUNCTION__, __LINE__);
805 rte_rwlock_read_lock(&rwlock);
807 if (bond_port == NULL) {
808 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
809 " port list.\n\r", __FUNCTION__, bonded_port_id);
810 if (ifm_debug & IFM_DEBUG_LOCKS)
811 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
812 __FUNCTION__, __LINE__);
816 rte_rwlock_read_unlock(&rwlock);
820 uint8_t primary = bond_port->bond_config->primary;
821 if (ifm_debug & IFM_DEBUG_LOCKS)
822 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
823 __FUNCTION__, __LINE__);
827 rte_rwlock_read_unlock(&rwlock);
832 int get_bond_slave_count(uint8_t bonded_port_id)
834 l2_phy_interface_t *bond_port;
835 bond_port = ifm_get_port(bonded_port_id);
836 // bond_port = ifm.port_list[bonded_port_id];
838 if (ifm_debug & IFM_DEBUG_LOCKS)
839 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
840 __FUNCTION__, __LINE__);
844 rte_rwlock_read_lock(&rwlock);
846 if (bond_port == NULL) {
847 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
848 " port list.\n\r", __FUNCTION__, bonded_port_id);
849 if (ifm_debug & IFM_DEBUG_LOCKS)
850 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
851 __FUNCTION__, __LINE__);
855 rte_rwlock_read_unlock(&rwlock);
859 uint32_t slave_count = bond_port->bond_config->slave_count;
860 if (ifm_debug & IFM_DEBUG_LOCKS)
861 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
862 __FUNCTION__, __LINE__);
866 rte_rwlock_read_unlock(&rwlock);
871 int get_bond_active_slave_count(uint8_t bonded_port_id)
873 l2_phy_interface_t *bond_port;
874 bond_port = ifm_get_port(bonded_port_id);
875 //bond_port = ifm.port_list[bonded_port_id];
877 if (ifm_debug & IFM_DEBUG_LOCKS)
878 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
879 __FUNCTION__, __LINE__);
883 rte_rwlock_read_lock(&rwlock);
885 if (bond_port == NULL) {
886 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
887 " port list.\n\r", __FUNCTION__, bonded_port_id);
888 if (ifm_debug & IFM_DEBUG_LOCKS)
889 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
890 __FUNCTION__, __LINE__);
894 rte_rwlock_read_unlock(&rwlock);
898 uint32_t slave_count = bond_port->bond_config->active_slave_count;
899 if (ifm_debug & IFM_DEBUG_LOCKS)
900 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
901 __FUNCTION__, __LINE__);
905 rte_rwlock_read_unlock(&rwlock);
910 int get_bond_slaves(uint8_t bonded_port_id, uint8_t slaves[RTE_MAX_ETHPORTS])
912 l2_phy_interface_t *bond_port;
913 bond_port = ifm_get_port(bonded_port_id);
914 //bond_port = ifm.port_list[bonded_port_id];
916 if (ifm_debug & IFM_DEBUG_LOCKS)
917 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
918 __FUNCTION__, __LINE__);
922 rte_rwlock_read_lock(&rwlock);
924 if (bond_port == NULL) {
925 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
926 " port list.\n\r", __FUNCTION__, bonded_port_id);
929 memcpy(slaves, bond_port->bond_config->slaves,
930 bond_port->bond_config->slave_count);
931 if (ifm_debug & IFM_DEBUG_LOCKS)
932 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
933 __FUNCTION__, __LINE__);
937 rte_rwlock_read_unlock(&rwlock);
942 int get_bond_active_slaves(uint8_t bonded_port_id,
943 uint8_t active_slaves[RTE_MAX_ETHPORTS])
945 l2_phy_interface_t *bond_port;
946 bond_port = ifm_get_port(bonded_port_id);
947 //bond_port = ifm.port_list[bonded_port_id];
949 if (ifm_debug & IFM_DEBUG_LOCKS)
950 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
951 __FUNCTION__, __LINE__);
955 rte_rwlock_read_lock(&rwlock);
957 if (bond_port == NULL) {
958 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
959 " port list.\n\r", __FUNCTION__, bonded_port_id);
962 memcpy(active_slaves, bond_port->bond_config->active_slaves,
963 bond_port->bond_config->active_slave_count);
964 if (ifm_debug & IFM_DEBUG_LOCKS)
965 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
966 __FUNCTION__, __LINE__);
970 rte_rwlock_read_unlock(&rwlock);
975 int set_bond_mac_address(uint8_t bonded_port_id, struct ether_addr *mac_addr)
977 l2_phy_interface_t *bond_port;
978 bond_port = ifm_get_port(bonded_port_id);
979 //bond_port = ifm.port_list[bonded_port_id];
981 if (ifm_debug & IFM_DEBUG_LOCKS)
982 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
983 __FUNCTION__, __LINE__);
987 rte_rwlock_write_lock(&rwlock);
989 if (mac_addr == NULL) {
990 RTE_LOG(ERR, IFM, "%s: MAC address cannot be NULL.\n\r",
992 if (ifm_debug & IFM_DEBUG_LOCKS)
993 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
994 __FUNCTION__, __LINE__);
998 rte_rwlock_write_unlock(&rwlock);
1003 if (bond_port == NULL) {
1004 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1005 " port list.\n\r", __FUNCTION__, bonded_port_id);
1006 if (ifm_debug & IFM_DEBUG_LOCKS)
1007 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1008 __FUNCTION__, __LINE__);
1009 if (USE_RTM_LOCKS) {
1012 rte_rwlock_write_unlock(&rwlock);
1016 if (rte_eth_bond_mac_address_set(bond_port->pmdid, mac_addr) < 0) {
1017 RTE_LOG(ERR, IFM, "%s: Failed to set MAC addr for port %u\n\r",
1018 __FUNCTION__, bond_port->pmdid);
1019 if (ifm_debug & IFM_DEBUG_LOCKS)
1020 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1021 __FUNCTION__, __LINE__);
1022 if (USE_RTM_LOCKS) {
1025 rte_rwlock_write_unlock(&rwlock);
1029 rte_eth_macaddr_get(bond_port->pmdid,
1030 (struct ether_addr *)bond_port->macaddr);
1031 if (ifm_debug & IFM_DEBUG_LOCKS)
1032 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1033 __FUNCTION__, __LINE__);
1034 if (USE_RTM_LOCKS) {
1037 rte_rwlock_write_unlock(&rwlock);
1042 int reset_bond_mac_addr(uint8_t bonded_port_id)
1044 l2_phy_interface_t *bond_port;
1045 bond_port = ifm_get_port(bonded_port_id);
1046 // bond_port = ifm.port_list[bonded_port_id];
1048 if (ifm_debug & IFM_DEBUG_LOCKS)
1049 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
1050 __FUNCTION__, __LINE__);
1051 if (USE_RTM_LOCKS) {
1054 rte_rwlock_write_lock(&rwlock);
1056 if (bond_port == NULL) {
1057 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1058 " port list.\n\r", __FUNCTION__, bonded_port_id);
1059 if (ifm_debug & IFM_DEBUG_LOCKS)
1060 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1061 __FUNCTION__, __LINE__);
1062 if (USE_RTM_LOCKS) {
1065 rte_rwlock_write_unlock(&rwlock);
1069 if (rte_eth_bond_mac_address_reset(bond_port->pmdid) < 0) {
1071 "%s: Failed to reset MAC addr for port %u\n\r",
1072 __FUNCTION__, bond_port->pmdid);
1073 if (ifm_debug & IFM_DEBUG_LOCKS)
1074 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1075 __FUNCTION__, __LINE__);
1076 if (USE_RTM_LOCKS) {
1079 rte_rwlock_write_unlock(&rwlock);
1083 rte_eth_macaddr_get(bond_port->pmdid,
1084 (struct ether_addr *)bond_port->macaddr);
1085 if (ifm_debug & IFM_DEBUG_LOCKS)
1086 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1087 __FUNCTION__, __LINE__);
1088 if (USE_RTM_LOCKS) {
1091 rte_rwlock_write_unlock(&rwlock);
1096 int set_bond_xmitpolicy(uint8_t bonded_port_id, uint8_t policy)
1099 l2_phy_interface_t *bond_port;
1100 bond_port = ifm_get_port(bonded_port_id);
1101 //bond_port = ifm.port_list[bonded_port_id];
1104 if (ifm_debug & IFM_DEBUG_LOCKS)
1105 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
1106 __FUNCTION__, __LINE__);
1107 if (USE_RTM_LOCKS) {
1110 rte_rwlock_write_lock(&rwlock);
1112 if (bond_port == NULL) {
1113 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1114 " port list.\n\r", __FUNCTION__, bonded_port_id);
1115 if (ifm_debug & IFM_DEBUG_LOCKS)
1116 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1117 __FUNCTION__, __LINE__);
1118 if (USE_RTM_LOCKS) {
1121 rte_rwlock_write_unlock(&rwlock);
1125 if (bond_port->bond_config->xmit_policy == policy) {
1126 if (ifm_debug & IFM_DEBUG)
1128 "%s: For port %u, old policy value and new value are same\n\r",
1129 __FUNCTION__, bonded_port_id);
1130 if (ifm_debug & IFM_DEBUG_LOCKS)
1131 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1132 __FUNCTION__, __LINE__);
1133 if (USE_RTM_LOCKS) {
1136 rte_rwlock_write_unlock(&rwlock);
1140 if (rte_eth_bond_xmit_policy_set(bond_port->pmdid, policy) < 0) {
1141 RTE_LOG(ERR, IFM, "%s: Failed to set policy for port %u\n\r",
1142 __FUNCTION__, bond_port->pmdid);
1143 if (ifm_debug & IFM_DEBUG_LOCKS)
1144 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1145 __FUNCTION__, __LINE__);
1146 if (USE_RTM_LOCKS) {
1149 rte_rwlock_write_unlock(&rwlock);
1153 ret = rte_eth_bond_xmit_policy_get(bond_port->pmdid);
1155 if (ifm_debug & IFM_DEBUG)
1157 "%s: rte_eth_bond_xmit_policy_set failed\n\r",
1159 if (ifm_debug & IFM_DEBUG_LOCKS)
1160 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1161 __FUNCTION__, __LINE__);
1162 if (USE_RTM_LOCKS) {
1165 rte_rwlock_write_unlock(&rwlock);
1169 bond_port->bond_config->xmit_policy = policy;
1170 if (ifm_debug & IFM_DEBUG_LOCKS)
1171 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1172 __FUNCTION__, __LINE__);
1173 if (USE_RTM_LOCKS) {
1176 rte_rwlock_write_unlock(&rwlock);
1181 int get_bond_xmitpolicy(uint8_t bonded_port_id)
1183 l2_phy_interface_t *bond_port;
1185 bond_port = ifm_get_port(bonded_port_id);
1187 if (ifm_debug & IFM_DEBUG_LOCKS)
1188 RTE_LOG(INFO, IFM, "%s: RD Acquiring lock @ %d\n\r",
1189 __FUNCTION__, __LINE__);
1190 if (USE_RTM_LOCKS) {
1193 rte_rwlock_read_lock(&rwlock);
1195 if (bond_port == NULL) {
1196 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1197 " port list.\n\r", __FUNCTION__, bonded_port_id);
1198 if (ifm_debug & IFM_DEBUG_LOCKS)
1199 RTE_LOG(INFO, IFM, "%s:Releasing RD lock @ %d\n\r",
1200 __FUNCTION__, __LINE__);
1201 if (USE_RTM_LOCKS) {
1204 rte_rwlock_read_unlock(&rwlock);
1208 uint8_t policy = bond_port->bond_config->xmit_policy;
1209 if (ifm_debug & IFM_DEBUG_LOCKS)
1210 RTE_LOG(INFO, IFM, "%s:Releasing RD lock @ %d\n\r",
1211 __FUNCTION__, __LINE__);
1212 if (USE_RTM_LOCKS) {
1215 rte_rwlock_read_unlock(&rwlock);
1220 int set_bond_link_montitor_frequency(uint8_t bonded_port_id,
1221 uint32_t internal_ms)
1223 l2_phy_interface_t *bond_port;
1224 if (ifm_debug & IFM_DEBUG_LOCKS)
1225 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
1226 __FUNCTION__, __LINE__);
1227 if (USE_RTM_LOCKS) {
1230 rte_rwlock_write_lock(&rwlock);
1232 // bond_port = ifm.port_list[bonded_port_id];
1233 bond_port = ifm_get_port(bonded_port_id);
1236 if (bond_port == NULL) {
1237 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1238 " port list.\n\r", __FUNCTION__, bonded_port_id);
1239 if (ifm_debug & IFM_DEBUG_LOCKS)
1240 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1241 __FUNCTION__, __LINE__);
1242 if (USE_RTM_LOCKS) {
1245 rte_rwlock_write_unlock(&rwlock);
1249 if (bond_port->bond_config->internal_ms == internal_ms) {
1250 if (ifm_debug & IFM_DEBUG)
1252 "%s: For port %u, old frequency value and new value are same\n\r",
1253 __FUNCTION__, bonded_port_id);
1254 if (ifm_debug & IFM_DEBUG_LOCKS)
1255 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1256 __FUNCTION__, __LINE__);
1257 if (USE_RTM_LOCKS) {
1260 rte_rwlock_write_unlock(&rwlock);
1264 if (rte_eth_bond_link_monitoring_set(bond_port->pmdid, internal_ms) < 0) {
1266 "%s: Failed to set link monitor frequency for port %u\n\r",
1267 __FUNCTION__, bond_port->pmdid);
1268 if (ifm_debug & IFM_DEBUG_LOCKS)
1269 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1270 __FUNCTION__, __LINE__);
1271 if (USE_RTM_LOCKS) {
1274 rte_rwlock_write_unlock(&rwlock);
1278 ret = rte_eth_bond_link_monitoring_get(bond_port->pmdid);
1280 if (ifm_debug & IFM_DEBUG)
1282 "%s: rte_eth_bond_link_monitoring_get failed\n\r",
1284 if (ifm_debug & IFM_DEBUG_LOCKS)
1285 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1286 __FUNCTION__, __LINE__);
1287 if (USE_RTM_LOCKS) {
1290 rte_rwlock_write_unlock(&rwlock);
1294 bond_port->bond_config->internal_ms = internal_ms;
1295 if (ifm_debug & IFM_DEBUG_LOCKS)
1296 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1297 __FUNCTION__, __LINE__);
1298 if (USE_RTM_LOCKS) {
1301 rte_rwlock_write_unlock(&rwlock);
1306 int get_bond_link_monitor_frequency(uint8_t bonded_port_id)
1308 l2_phy_interface_t *bond_port;
1309 // bond_port = ifm.port_list[bonded_port_id];
1310 bond_port = ifm_get_port(bonded_port_id);
1312 if (ifm_debug & IFM_DEBUG_LOCKS)
1313 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
1314 __FUNCTION__, __LINE__);
1315 if (USE_RTM_LOCKS) {
1318 rte_rwlock_read_lock(&rwlock);
1320 if (bond_port == NULL) {
1321 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1322 " port list.\n\r", __FUNCTION__, bonded_port_id);
1323 if (ifm_debug & IFM_DEBUG_LOCKS)
1324 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1325 __FUNCTION__, __LINE__);
1326 if (USE_RTM_LOCKS) {
1329 rte_rwlock_read_unlock(&rwlock);
1333 uint32_t internal_ms = bond_port->bond_config->internal_ms;
1334 if (ifm_debug & IFM_DEBUG_LOCKS)
1335 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1336 __FUNCTION__, __LINE__);
1337 if (USE_RTM_LOCKS) {
1340 rte_rwlock_read_unlock(&rwlock);
1345 int set_bond_linkdown_delay(uint8_t bonded_port_id, uint32_t delay_ms)
1347 l2_phy_interface_t *bond_port;
1348 if (ifm_debug & IFM_DEBUG_LOCKS)
1349 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
1350 __FUNCTION__, __LINE__);
1352 if (USE_RTM_LOCKS) {
1355 rte_rwlock_write_lock(&rwlock);
1357 // bond_port = ifm.port_list[bonded_port_id];
1358 bond_port = ifm_get_port(bonded_port_id);
1361 if (bond_port == NULL) {
1362 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1363 " port list.\n\r", __FUNCTION__, bonded_port_id);
1364 if (ifm_debug & IFM_DEBUG_LOCKS)
1365 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1366 __FUNCTION__, __LINE__);
1368 if (USE_RTM_LOCKS) {
1371 rte_rwlock_write_unlock(&rwlock);
1375 if (bond_port->bond_config->link_down_delay_ms == delay_ms) {
1376 if (ifm_debug & IFM_DEBUG)
1378 "%s: For port %u, old delay value and new value are same\n\r",
1379 __FUNCTION__, bonded_port_id);
1380 if (ifm_debug & IFM_DEBUG_LOCKS)
1381 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1382 __FUNCTION__, __LINE__);
1384 if (USE_RTM_LOCKS) {
1387 rte_rwlock_write_unlock(&rwlock);
1391 if (rte_eth_bond_link_down_prop_delay_set(bond_port->pmdid, delay_ms) <
1393 RTE_LOG(ERR, IFM, "%s: Failed to set delay for port %u\n\r",
1394 __FUNCTION__, bond_port->pmdid);
1395 if (ifm_debug & IFM_DEBUG_LOCKS)
1396 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1397 __FUNCTION__, __LINE__);
1399 if (USE_RTM_LOCKS) {
1402 rte_rwlock_write_unlock(&rwlock);
1406 delay = rte_eth_bond_link_down_prop_delay_get(bond_port->pmdid);
1408 if (ifm_debug & IFM_DEBUG)
1410 "%s: rte_eth_bond_link_down_prop_delay_get failed\n\r",
1412 if (ifm_debug & IFM_DEBUG_LOCKS)
1413 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1414 __FUNCTION__, __LINE__);
1416 if (USE_RTM_LOCKS) {
1419 rte_rwlock_write_unlock(&rwlock);
1423 bond_port->bond_config->link_down_delay_ms = delay;
1424 if (ifm_debug & IFM_DEBUG_LOCKS)
1425 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1426 __FUNCTION__, __LINE__);
1428 if (USE_RTM_LOCKS) {
1431 rte_rwlock_write_unlock(&rwlock);
1436 int get_bond_link_down_delay(uint8_t bonded_port_id)
1438 l2_phy_interface_t *bond_port;
1439 //bond_port = ifm.port_list[bonded_port_id];
1440 bond_port = ifm_get_port(bonded_port_id);
1441 if (ifm_debug & IFM_DEBUG_LOCKS)
1442 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
1443 __FUNCTION__, __LINE__);
1447 rte_rwlock_read_lock(&rwlock);
1449 if (bond_port == NULL) {
1450 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1451 " port list.\n\r", __FUNCTION__, bonded_port_id);
1452 if (ifm_debug & IFM_DEBUG_LOCKS)
1453 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1454 __FUNCTION__, __LINE__);
1455 if (USE_RTM_LOCKS) {
1458 rte_rwlock_read_unlock(&rwlock);
1462 uint32_t delay_ms = bond_port->bond_config->link_down_delay_ms;
1463 if (ifm_debug & IFM_DEBUG_LOCKS)
1464 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1465 __FUNCTION__, __LINE__);
1466 if (USE_RTM_LOCKS) {
1469 rte_rwlock_read_unlock(&rwlock);
1475 int set_bond_linkup_delay(uint8_t bonded_port_id, uint32_t delay_ms)
1477 l2_phy_interface_t *bond_port;
1479 bond_port = ifm_get_port(bonded_port_id);
1481 if (ifm_debug & IFM_DEBUG_LOCKS)
1482 RTE_LOG(INFO, IFM, "%s: Acquiring WR lock @ %d\n\r",
1483 __FUNCTION__, __LINE__);
1487 rte_rwlock_write_unlock(&rwlock);
1489 if (bond_port == NULL) {
1490 RTE_LOG(ERR, IFM, "%s: Given bond port %u is not available in"
1491 " port list.\n\r", __FUNCTION__, bonded_port_id);
1492 if (ifm_debug & IFM_DEBUG_LOCKS)
1493 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1494 __FUNCTION__, __LINE__);
1498 rte_rwlock_write_unlock(&rwlock);
1501 if (bond_port->bond_config->link_up_delay_ms == delay_ms) {
1502 if (ifm_debug & IFM_DEBUG)
1504 "%s: For port %u, old delay value and new value are same\n\r",
1505 __FUNCTION__, bonded_port_id);
1506 if (ifm_debug & IFM_DEBUG_LOCKS)
1507 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1508 __FUNCTION__, __LINE__);
1512 rte_rwlock_write_unlock(&rwlock);
1515 if (rte_eth_bond_link_up_prop_delay_set(bond_port->pmdid, delay_ms) < 0) {
1516 RTE_LOG(ERR, IFM, "%s: Failed to set delay for port %u\n\r",
1517 __FUNCTION__, bond_port->pmdid);
1518 if (ifm_debug & IFM_DEBUG_LOCKS)
1519 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1520 __FUNCTION__, __LINE__);
1525 rte_rwlock_write_unlock(&rwlock);
1528 delay = rte_eth_bond_link_up_prop_delay_get(bond_port->pmdid);
1531 "%s: rte_eth_bond_link_up_prop_delay_get failed\n\r",
1533 if (ifm_debug & IFM_DEBUG_LOCKS)
1534 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1535 __FUNCTION__, __LINE__);
1540 rte_rwlock_write_unlock(&rwlock);
1543 bond_port->bond_config->link_up_delay_ms = delay;
1544 if (ifm_debug & IFM_DEBUG_LOCKS)
1545 RTE_LOG(INFO, IFM, "%s: Releasing WR lock @ %d\n\r",
1546 __FUNCTION__, __LINE__);
1551 rte_rwlock_write_unlock(&rwlock);
1555 int get_bond_link_up_delay(uint8_t bonded_port_id)
1557 l2_phy_interface_t *bond_port;
1560 bond_port = ifm_get_port(bonded_port_id);
1562 if (ifm_debug & IFM_DEBUG_LOCKS)
1563 RTE_LOG(INFO, IFM, "%s: Acquiring RD lock @ %d\n\r",
1564 __FUNCTION__, __LINE__);
1568 rte_rwlock_read_lock(&rwlock);
1569 if (bond_port == NULL) {
1570 if (ifm_debug & IFM_DEBUG) {
1572 "%s: Given bond port %u is not available in"
1573 " port list.\n\r", __FUNCTION__,
1576 if (ifm_debug & IFM_DEBUG_LOCKS)
1577 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1578 __FUNCTION__, __LINE__);
1582 rte_rwlock_read_unlock(&rwlock);
1585 delay_ms = bond_port->bond_config->link_up_delay_ms;
1587 if (ifm_debug & IFM_DEBUG_LOCKS)
1588 RTE_LOG(INFO, IFM, "%s: Releasing RD lock @ %d\n\r",
1589 __FUNCTION__, __LINE__);
1593 rte_rwlock_read_unlock(&rwlock);