Re: [net-next V3 0/2] drivers: net: virtio_net: implement
net-next is closed ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[net-next V3 0/2] drivers: net: virtio_net: implement
This series add two important features. One of them changes the .ndo_tx_timeout to include an extra parameter to identify the stuck queue. Many drivers are using a nester loop to identify which queue is stooped/stucked. This is a redundant work since dev_watchdog is doing exactly the same thing. This is so interesting for other drivers to in terms of code optimization. The second part (second commit) introduces a virtnet_tx_timeout function to reset virtio_net driver when a TX timeout happens. The main idea of this implementation is related to a QEMU device issue. So, in this case, resetting driver would be the best option to cover this scenario instead of "soft recovery". Changes from v1: - Missing net-next tag. Changes from v2: - Adding the netdev patch produced by Michael (many thanks). - Using this stucture into virtnet and remove some stupid warn messages. Julio Faracco (2): netdev: pass the stuck queue to the timeout handler drivers: net: virtio_net: Implement a dev_watchdog handler arch/m68k/emu/nfeth.c | 2 +- arch/um/drivers/net_kern.c| 2 +- arch/um/drivers/vector_kern.c | 2 +- arch/xtensa/platforms/iss/network.c | 2 +- drivers/char/pcmcia/synclink_cs.c | 2 +- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +- drivers/message/fusion/mptlan.c | 2 +- drivers/misc/sgi-xp/xpnet.c | 2 +- drivers/net/appletalk/cops.c | 4 +- drivers/net/arcnet/arcdevice.h| 2 +- drivers/net/arcnet/arcnet.c | 2 +- drivers/net/ethernet/3com/3c509.c | 4 +- drivers/net/ethernet/3com/3c515.c | 4 +- drivers/net/ethernet/3com/3c574_cs.c | 4 +- drivers/net/ethernet/3com/3c589_cs.c | 4 +- drivers/net/ethernet/3com/3c59x.c | 4 +- drivers/net/ethernet/3com/typhoon.c | 2 +- drivers/net/ethernet/8390/8390.c | 4 +- drivers/net/ethernet/8390/8390.h | 4 +- drivers/net/ethernet/8390/8390p.c | 4 +- drivers/net/ethernet/8390/axnet_cs.c | 4 +- drivers/net/ethernet/8390/lib8390.c | 2 +- drivers/net/ethernet/adaptec/starfire.c | 4 +- drivers/net/ethernet/agere/et131x.c | 2 +- drivers/net/ethernet/allwinner/sun4i-emac.c | 2 +- drivers/net/ethernet/alteon/acenic.c | 4 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +- drivers/net/ethernet/amd/7990.c | 2 +- drivers/net/ethernet/amd/7990.h | 2 +- drivers/net/ethernet/amd/a2065.c | 2 +- drivers/net/ethernet/amd/am79c961a.c | 2 +- drivers/net/ethernet/amd/amd8111e.c | 2 +- drivers/net/ethernet/amd/ariadne.c| 2 +- drivers/net/ethernet/amd/atarilance.c | 4 +- drivers/net/ethernet/amd/au1000_eth.c | 2 +- drivers/net/ethernet/amd/declance.c | 2 +- drivers/net/ethernet/amd/lance.c | 4 +- drivers/net/ethernet/amd/ni65.c | 4 +- drivers/net/ethernet/amd/nmclan_cs.c | 4 +- drivers/net/ethernet/amd/pcnet32.c| 4 +- drivers/net/ethernet/amd/sunlance.c | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/apm/xgene-v2/main.c | 2 +- .../net/ethernet/apm/xgene/xgene_enet_main.c | 2 +- drivers/net/ethernet/apple/macmace.c | 4 +- drivers/net/ethernet/atheros/ag71xx.c | 2 +- drivers/net/ethernet/atheros/alx/main.c | 2 +- .../net/ethernet/atheros/atl1c/atl1c_main.c | 2 +- .../net/ethernet/atheros/atl1e/atl1e_main.c | 2 +- drivers/net/ethernet/atheros/atlx/atl2.c | 2 +- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c| 2 +- drivers/net/ethernet/broadcom/bnx2.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- .../net/ethernet/broadcom/genet/bcmgenet.c| 2 +- drivers/net/ethernet/broadcom/sb1250-mac.c| 4 +- drivers/net/ethernet/broadcom/tg3.c | 2 +- drivers/net/ethernet/calxeda/xgmac.c | 2 +- .../net/ethernet/cavium/liquidio/lio_main.c | 2 +- .../ethernet/cavium/liquidio/lio_vf_main.c| 2 +- .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 5 +- .../net/ethernet/cavium/thunder/nicvf_main.c | 2 +- drivers/net/ethernet/cirrus/cs89x0.c | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- drivers/net/ethernet/cortina/gemini.c | 2 +- drivers/net/ethernet/davicom/dm9000.c | 2 +- drivers/net/ethernet/dec/tulip/de2104x.c | 2 +- drivers/net/ethernet/dec/tulip/tulip_core.c | 4 +- drivers/net/ethernet/dec/tulip/winbond-840.c | 4 +- drivers/net/ethernet/dlink/dl2k.c | 4 +-
[net-next V3 2/2] drivers: net: virtio_net: Implement a dev_watchdog handler
Driver virtio_net is not handling error events for TX provided by dev_watchdog. This event is reached when transmission queue is having problems to transmit packets. This could happen for any reason. To enable it, driver should have .ndo_tx_timeout implemented. This commit brings back virtnet_reset method to recover TX queues from a error state. That function is called by schedule_work method and it puts the reset function into work queue. As the error cause is unknown at this moment, it would be better to reset all queues, including RX (because we don't have control of this). Signed-off-by: Julio Faracco Signed-off-by: Daiane Mendes Cc: Jason Wang --- drivers/net/virtio_net.c | 83 +++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 4d7d5434cc5d..fbe1dfde3a4b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -75,6 +75,7 @@ struct virtnet_sq_stats { u64 xdp_tx; u64 xdp_tx_drops; u64 kicks; + u64 tx_timeouts; }; struct virtnet_rq_stats { @@ -98,6 +99,7 @@ static const struct virtnet_stat_desc virtnet_sq_stats_desc[] = { { "xdp_tx", VIRTNET_SQ_STAT(xdp_tx) }, { "xdp_tx_drops", VIRTNET_SQ_STAT(xdp_tx_drops) }, { "kicks", VIRTNET_SQ_STAT(kicks) }, + { "tx_timeouts",VIRTNET_SQ_STAT(tx_timeouts) }, }; static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = { @@ -211,6 +213,9 @@ struct virtnet_info { /* Work struct for config space updates */ struct work_struct config_work; + /* Work struct for resetting the virtio-net driver. */ + struct work_struct reset_work; + /* Does the affinity hint is set for virtqueues? */ bool affinity_hint_set; @@ -1721,7 +1726,7 @@ static void virtnet_stats(struct net_device *dev, int i; for (i = 0; i < vi->max_queue_pairs; i++) { - u64 tpackets, tbytes, rpackets, rbytes, rdrops; + u64 tpackets, tbytes, terrors, rpackets, rbytes, rdrops; struct receive_queue *rq = >rq[i]; struct send_queue *sq = >sq[i]; @@ -1729,6 +1734,7 @@ static void virtnet_stats(struct net_device *dev, start = u64_stats_fetch_begin_irq(>stats.syncp); tpackets = sq->stats.packets; tbytes = sq->stats.bytes; + terrors = sq->stats.tx_timeouts; } while (u64_stats_fetch_retry_irq(>stats.syncp, start)); do { @@ -1743,6 +1749,7 @@ static void virtnet_stats(struct net_device *dev, tot->rx_bytes += rbytes; tot->tx_bytes += tbytes; tot->rx_dropped += rdrops; + tot->tx_errors += terrors; } tot->tx_dropped = dev->stats.tx_dropped; @@ -2578,6 +2585,21 @@ static int virtnet_set_features(struct net_device *dev, return 0; } +static void virtnet_tx_timeout(struct net_device *dev, unsigned int txqueue) +{ + struct virtnet_info *vi = netdev_priv(dev); + struct send_queue *sq = >sq[txqueue]; + + netdev_warn(dev, "TX timeout on queue: %d, sq: %s, vq: %d, name: %s\n", + txqueue, sq->name, sq->vq->index, sq->vq->name); + + u64_stats_update_begin(>stats.syncp); + sq->stats.tx_timeouts++; + u64_stats_update_end(>stats.syncp); + + schedule_work(>reset_work); +} + static const struct net_device_ops virtnet_netdev = { .ndo_open= virtnet_open, .ndo_stop= virtnet_close, @@ -2593,6 +2615,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_features_check = passthru_features_check, .ndo_get_phys_port_name = virtnet_get_phys_port_name, .ndo_set_features = virtnet_set_features, + .ndo_tx_timeout = virtnet_tx_timeout, }; static void virtnet_config_changed_work(struct work_struct *work) @@ -2982,6 +3005,62 @@ static int virtnet_validate(struct virtio_device *vdev) return 0; } +static void _remove_vq_common(struct virtnet_info *vi) +{ + vi->vdev->config->reset(vi->vdev); + + /* Free unused buffers in both send and recv, if any. */ + free_unused_bufs(vi); + + _free_receive_bufs(vi); + + free_receive_page_frags(vi); + + virtnet_del_vqs(vi); +} + +static int _virtnet_reset(struct virtnet_info *vi) +{ + struct virtio_device *vdev = vi->vdev; + int ret; + + virtio_config_disable(vdev); + vdev->failed = vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_FAILED; + + virtnet_freeze_down(vdev); + _remove_vq_common(vi); + + virtio_add_status(vdev, VIRTIO_CONFIG_S_ACKNOWLEDGE); + virtio_add_status(vdev, VIRTIO_CONFIG_S_DRIVER); + + ret = virtio_finalize_features(vdev); + if (ret) +
Re: [PATCH 1/1] virtio_ring: fix return code on DMA mapping fails
On Sat, Nov 23, 2019 at 09:39:08AM -0600, Tom Lendacky wrote: > Ideally, having a pool of shared pages for DMA, outside of standard > SWIOTLB, might be a good thing. On x86, SWIOTLB really seems geared > towards devices that don't support 64-bit DMA. If a device supports 64-bit > DMA then it can use shared pages that reside anywhere to perform the DMA > and bounce buffering. I wonder if the SWIOTLB support can be enhanced to > support something like this, using today's low SWIOTLB buffers if the DMA > mask necessitates it, otherwise using a dynamically sized pool of shared > pages that can live anywhere. I think that can be done relatively easily. I've actually been thinking of multiple pool support for a whіle to replace the bounce buffering in the block layer for ISA devices (24-bit addressing). I've also been looking into a dma_alloc_pages interface to help people just allocate pages that are always dma addressable, but don't need a coherent allocation. My last version I shared is here: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma_alloc_pages But it turns out this still doesn't work with SEV as we'll always bounce. And I've been kinda lost on figuring out a way how to allocate unencrypted pages that we we can feed into the normal dma_map_page & co interfaces due to the magic encryption bit in the address. I guess we could have a fallback path in the mapping path and just unconditionally clear that bit in the dma_to_phys path. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization