net/virtio: support LRO
[dpdk.git] / drivers / net / virtio / virtio_ethdev.c
index 7048f84..157e44c 100644 (file)
@@ -1280,7 +1280,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->data->dev_flags = dev_flags;
 
        /* reset device and negotiate default features */
-       ret = virtio_init_device(eth_dev, VIRTIO_PMD_GUEST_FEATURES);
+       ret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES);
        if (ret < 0)
                return ret;
 
@@ -1366,13 +1366,14 @@ virtio_dev_configure(struct rte_eth_dev *dev)
        int ret;
 
        PMD_INIT_LOG(DEBUG, "configure");
+       req_features = VIRTIO_PMD_DEFAULT_GUEST_FEATURES;
+       if (rxmode->hw_ip_checksum)
+               req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
+       if (rxmode->enable_lro)
+               req_features |=
+                       (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
+                       (1ULL << VIRTIO_NET_F_GUEST_TSO6);
 
-       if (rxmode->hw_ip_checksum) {
-               PMD_DRV_LOG(ERR, "HW IP checksum not supported");
-               return -EINVAL;
-       }
-
-       req_features = VIRTIO_PMD_GUEST_FEATURES;
        /* if request features changed, reinit the device */
        if (req_features != hw->req_guest_features) {
                ret = virtio_init_device(dev, req_features);
@@ -1380,6 +1381,21 @@ virtio_dev_configure(struct rte_eth_dev *dev)
                        return ret;
        }
 
+       if (rxmode->hw_ip_checksum &&
+               !vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM)) {
+               PMD_DRV_LOG(NOTICE,
+                       "rx ip checksum not available on this host");
+               return -ENOTSUP;
+       }
+
+       if (rxmode->enable_lro &&
+               (!vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4) ||
+                       !vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4))) {
+               PMD_DRV_LOG(NOTICE,
+                       "lro not available on this host");
+               return -ENOTSUP;
+       }
+
        /* Setup and start control queue */
        if (vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VQ)) {
                ret = virtio_dev_cq_queue_setup(dev,
@@ -1593,6 +1609,17 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->default_txconf = (struct rte_eth_txconf) {
                .txq_flags = ETH_TXQ_FLAGS_NOOFFLOADS
        };
+       dev_info->rx_offload_capa =
+               DEV_RX_OFFLOAD_TCP_CKSUM |
+               DEV_RX_OFFLOAD_UDP_CKSUM |
+               DEV_RX_OFFLOAD_TCP_LRO;
+       dev_info->tx_offload_capa = 0;
+
+       if (hw->guest_features & (1ULL << VIRTIO_NET_F_CSUM)) {
+               dev_info->tx_offload_capa |=
+                       DEV_TX_OFFLOAD_UDP_CKSUM |
+                       DEV_TX_OFFLOAD_TCP_CKSUM;
+       }
 }
 
 /*