MCPcopy Create free account
hub / github.com/F-Stack/f-stack / virtio_mac_addr_add

Function virtio_mac_addr_add

dpdk/drivers/net/virtio/virtio_ethdev.c:889–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887}
888
889static int
890virtio_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
891 uint32_t index, uint32_t vmdq __rte_unused)
892{
893 struct virtio_hw *hw = dev->data->dev_private;
894 const struct rte_ether_addr *addrs = dev->data->mac_addrs;
895 unsigned int i;
896 struct virtio_net_ctrl_mac *uc, *mc;
897
898 if (index >= VIRTIO_MAX_MAC_ADDRS) {
899 PMD_DRV_LOG(ERR, "mac address index %u out of range", index);
900 return -EINVAL;
901 }
902
903 uc = alloca(VIRTIO_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN +
904 sizeof(uc->entries));
905 uc->entries = 0;
906 mc = alloca(VIRTIO_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN +
907 sizeof(mc->entries));
908 mc->entries = 0;
909
910 for (i = 0; i < VIRTIO_MAX_MAC_ADDRS; i++) {
911 const struct rte_ether_addr *addr
912 = (i == index) ? mac_addr : addrs + i;
913 struct virtio_net_ctrl_mac *tbl
914 = rte_is_multicast_ether_addr(addr) ? mc : uc;
915
916 if (rte_is_zero_ether_addr(addr))
917 break;
918 memcpy(&tbl->macs[tbl->entries++], addr, RTE_ETHER_ADDR_LEN);
919 }
920
921 return virtio_mac_table_set(hw, uc, mc);
922}
923
924static void
925virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)

Callers

nothing calls this directly

Calls 4

rte_is_zero_ether_addrFunction · 0.85
virtio_mac_table_setFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected