+{ // Setup MACs for bond interfaces and their links which was initialized in
+ // dpdk_port_setup() but needs to be done again here to take effect.
+ int nports = rte_eth_dev_count();
+ if (nports > 0) {
+ for (i = 0; i < nports; i++) {
+ struct rte_eth_dev_info dev_info;
+ rte_eth_dev_info_get(i, &dev_info);
+ if (!dev_info.driver_name)
+ dev_info.driver_name = dev_info.pci_dev->driver->name;
+ ASSERT(dev_info.driver_name);
+ if (strncmp(dev_info.driver_name, "rte_bond_pmd", 12) == 0) {
+ u8 addr[6];
+ u8 slink[16];
+ int nlink = rte_eth_bond_slaves_get(i, slink, 16);
+ if (nlink > 0) {
+ vnet_hw_interface_t * hi;
+ ethernet_interface_t * ei;
+ /* Get MAC of 1st slave link */
+ rte_eth_macaddr_get(slink[0], (struct ether_addr *)addr);
+ /* Set MAC of bounded interface to that of 1st slave link */
+ rte_eth_bond_mac_address_set(i, (struct ether_addr *)addr);
+ /* Populate MAC of bonded interface in VPP hw tables */
+ hi = vnet_get_hw_interface (
+ vnm, dm->devices[i].vlib_hw_if_index);
+ ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
+ memcpy (hi->hw_address, addr, 6);
+ memcpy (ei->address, addr, 6);
+ /* Add MAC to other slave links */
+ while (nlink > 1) {
+ nlink--;
+ rte_eth_dev_mac_addr_add(
+ slink[nlink], (struct ether_addr *)addr, 0);
+ }
+ }
+ }
+ }
+ }
+}
+