+{ // Extra set up for bond interfaces:
+ // 1. Setup MACs for bond interfaces and their slave links which was set
+ // in dpdk_port_setup() but needs to be done again here to take effect.
+ // 2. Set max L3 packet size of each bond interface to the lowerst value of
+ // its slave links
+ // 3. Set up info for bond interface related CLI support.
+ 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 * bhi;
+ ethernet_interface_t * bei;
+ /* 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 */
+ bhi = vnet_get_hw_interface(
+ vnm, dm->devices[i].vlib_hw_if_index);
+ bei = pool_elt_at_index(em->interfaces, bhi->hw_instance);
+ clib_memcpy(bhi->hw_address, addr, 6);
+ clib_memcpy(bei->address, addr, 6);
+ /* Init l3 packet size allowed on bonded interface */
+ bhi->max_l3_packet_bytes[VLIB_RX] =
+ bhi->max_l3_packet_bytes[VLIB_TX] =
+ ETHERNET_MAX_PACKET_BYTES - sizeof(ethernet_header_t);
+ while (nlink >= 1) { /* for all slave links */
+ int slave = slink[--nlink];
+ dpdk_device_t * sdev = &dm->devices[slave];
+ vnet_hw_interface_t * shi;
+ vnet_sw_interface_t * ssi;
+ /* Add MAC to all slave links except the first one */
+ if (nlink) rte_eth_dev_mac_addr_add(
+ slave, (struct ether_addr *)addr, 0);
+ /* Set slaves bitmap for bonded interface */
+ bhi->bond_info = clib_bitmap_set(
+ bhi->bond_info, sdev->vlib_hw_if_index, 1);
+ /* Set slave link flags on slave interface */
+ shi = vnet_get_hw_interface(vnm, sdev->vlib_hw_if_index);
+ ssi = vnet_get_sw_interface(vnm, sdev->vlib_sw_if_index);
+ shi->bond_info = VNET_HW_INTERFACE_BOND_INFO_SLAVE;
+ ssi->flags |= VNET_SW_INTERFACE_FLAG_BOND_SLAVE;
+ /* Set l3 packet size allowed as the lowest of slave */
+ if (bhi->max_l3_packet_bytes[VLIB_RX] >
+ shi->max_l3_packet_bytes[VLIB_RX])
+ bhi->max_l3_packet_bytes[VLIB_RX] =
+ bhi->max_l3_packet_bytes[VLIB_TX] =
+ shi->max_l3_packet_bytes[VLIB_RX];
+ }
+ }
+ }
+ }
+ }
+}
+