* This function learns the MAC address of the device and registers this along with a * vlan tag to a VMDQ. */
| 939 | * vlan tag to a VMDQ. |
| 940 | */ |
| 941 | static int |
| 942 | link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m) |
| 943 | { |
| 944 | struct rte_ether_hdr *pkt_hdr; |
| 945 | int i, ret; |
| 946 | |
| 947 | /* Learn MAC address of guest device from packet */ |
| 948 | pkt_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); |
| 949 | |
| 950 | if (find_vhost_dev(&pkt_hdr->src_addr)) { |
| 951 | RTE_LOG(ERR, VHOST_DATA, |
| 952 | "(%d) device is using a registered MAC!\n", |
| 953 | vdev->vid); |
| 954 | return -1; |
| 955 | } |
| 956 | |
| 957 | for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) |
| 958 | vdev->mac_address.addr_bytes[i] = |
| 959 | pkt_hdr->src_addr.addr_bytes[i]; |
| 960 | |
| 961 | /* vlan_tag currently uses the device_id. */ |
| 962 | vdev->vlan_tag = vlan_tags[vdev->vid]; |
| 963 | |
| 964 | /* Print out VMDQ registration info. */ |
| 965 | RTE_LOG(INFO, VHOST_DATA, |
| 966 | "(%d) mac " RTE_ETHER_ADDR_PRT_FMT " and vlan %d registered\n", |
| 967 | vdev->vid, RTE_ETHER_ADDR_BYTES(&vdev->mac_address), |
| 968 | vdev->vlan_tag); |
| 969 | |
| 970 | /* Register the MAC address. */ |
| 971 | ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address, |
| 972 | (uint32_t)vdev->vid + vmdq_pool_base); |
| 973 | if (ret) |
| 974 | RTE_LOG(ERR, VHOST_DATA, |
| 975 | "(%d) failed to add device MAC address to VMDQ\n", |
| 976 | vdev->vid); |
| 977 | |
| 978 | rte_eth_dev_set_vlan_strip_on_queue(ports[0], vdev->vmdq_rx_q, 1); |
| 979 | |
| 980 | /* Set device as ready for RX. */ |
| 981 | vdev->ready = DEVICE_RX; |
| 982 | |
| 983 | return 0; |
| 984 | } |
| 985 | |
| 986 | /* |
| 987 | * Removes MAC address and vlan tag from VMDQ. Ensures that nothing is adding buffers to the RX |
no test coverage detected