reset device and renegotiate features if needed */
| 1764 | #define DUPLEX_UNKNOWN 0xff |
| 1765 | /* reset device and renegotiate features if needed */ |
| 1766 | static int |
| 1767 | virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) |
| 1768 | { |
| 1769 | struct virtio_hw *hw = eth_dev->data->dev_private; |
| 1770 | struct virtio_net_config *config; |
| 1771 | struct virtio_net_config local_config; |
| 1772 | int ret; |
| 1773 | |
| 1774 | /* Reset the device although not necessary at startup */ |
| 1775 | virtio_reset(hw); |
| 1776 | |
| 1777 | if (hw->vqs) { |
| 1778 | virtio_dev_free_mbufs(eth_dev); |
| 1779 | virtio_free_queues(hw); |
| 1780 | } |
| 1781 | |
| 1782 | /* Tell the host we've noticed this device. */ |
| 1783 | virtio_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); |
| 1784 | |
| 1785 | /* Tell the host we've known how to drive the device. */ |
| 1786 | virtio_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); |
| 1787 | if (virtio_ethdev_negotiate_features(hw, req_features) < 0) |
| 1788 | return -EINVAL; |
| 1789 | |
| 1790 | hw->weak_barriers = !virtio_with_feature(hw, VIRTIO_F_ORDER_PLATFORM); |
| 1791 | |
| 1792 | /* If host does not support both status and MSI-X then disable LSC */ |
| 1793 | if (virtio_with_feature(hw, VIRTIO_NET_F_STATUS) && hw->intr_lsc) |
| 1794 | eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; |
| 1795 | else |
| 1796 | eth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; |
| 1797 | |
| 1798 | /* Setting up rx_header size for the device */ |
| 1799 | if (virtio_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF) || |
| 1800 | virtio_with_feature(hw, VIRTIO_F_VERSION_1) || |
| 1801 | virtio_with_packed_queue(hw)) |
| 1802 | hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf); |
| 1803 | else |
| 1804 | hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr); |
| 1805 | |
| 1806 | /* Copy the permanent MAC address to: virtio_hw */ |
| 1807 | virtio_get_hwaddr(hw); |
| 1808 | rte_ether_addr_copy((struct rte_ether_addr *)hw->mac_addr, |
| 1809 | ð_dev->data->mac_addrs[0]); |
| 1810 | PMD_INIT_LOG(DEBUG, |
| 1811 | "PORT MAC: " RTE_ETHER_ADDR_PRT_FMT, |
| 1812 | hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], |
| 1813 | hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); |
| 1814 | |
| 1815 | hw->get_speed_via_feat = hw->speed == RTE_ETH_SPEED_NUM_UNKNOWN && |
| 1816 | virtio_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX); |
| 1817 | if (hw->get_speed_via_feat) |
| 1818 | virtio_get_speed_duplex(eth_dev, NULL); |
| 1819 | if (hw->duplex == DUPLEX_UNKNOWN) |
| 1820 | hw->duplex = RTE_ETH_LINK_FULL_DUPLEX; |
| 1821 | PMD_INIT_LOG(DEBUG, "link speed = %d, duplex = %d", |
| 1822 | hw->speed, hw->duplex); |
| 1823 | if (virtio_with_feature(hw, VIRTIO_NET_F_CTRL_VQ)) { |
no test coverage detected