From patchwork Tue May 19 16:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70451 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64B24A0093; Tue, 19 May 2020 18:52:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0205A1D62E; Tue, 19 May 2020 18:52:56 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 571BE1D604 for ; Tue, 19 May 2020 18:52:51 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id d10so114838pgn.4 for ; Tue, 19 May 2020 09:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E4K1MzKPCEk2qicqTjqJ04O3g6ZOFzGLnvgIKGmuCjs=; b=Z5dcYW3+3WsErAes2OVr/82/rztG+C2KuV+7DHKiu6sO3FXbzs0orC7EWWUcGmKQPF zWeSw06WnkL89fFpw2UdmJVERL7dyo2ZB90dVaQariOquzi450NNwtGxojOp/EbkrG7x mKtdj5X1O8Od/P7KcKI6bIrEEIHRefx4B+64PsT0quIId1wAiweSsaQzEg3HeP4ev/Ny K6p3QE98kQUuGKhW64l/+gWypLiVnuOPYUgyMh3ihM4+iAKNi41WNyte+msNc0G8IRzz C20dlNo2vqM9loFDHS5oNa7aMFlKx89d5EuZRqqpOzLcm/PkvmZZtdO1Kyg7MSO5ZeLh TxYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4K1MzKPCEk2qicqTjqJ04O3g6ZOFzGLnvgIKGmuCjs=; b=Cpj/4EVJtW6R4ORy6c9LmaItyHoNWjBv5aHt5IMnC91o1/6jyOBpW2I6YSWxHU2axw 8HCkWtRISqeVvLJlFROmbGPOmd0Blr36pZku6F9pW70H3g03tDebh3w6jzbjSYFiktXj q6m3Z6TPPOLL1IAsyZwGFyGOAANaCzFdu8Fbd7VzzZny7q9f2/n+sp737kYASjf5zrcu 2AtAqn559twFfdpTWaYXVTEfmY1jFxl7okLrtv3w7XP/qF/kfnEzyq0Hk0FKHH92xX9Z PkqTFy07OMycXPwpUh482Qgq74y2m3+r6Vj1Hf2N9JOc+QaEab32zpnL6tKvaYUc0Gvd OuFw== X-Gm-Message-State: AOAM533rXzbIe5410PHAxO4DNKw7L0ikLYNV6a1c0eNAY/EjUdGI6ftx SXw4mHw7TSgIkQub13JMX0CZWIbvlKTzKw== X-Google-Smtp-Source: ABdhPJx/NEx1X5LJJbsZiMrq7r5Cs5jE4ZZVKyisLNoRgpGg1GULHsgd8RJyxkQ6GcULs/rYyc0W4Q== X-Received: by 2002:a62:1cc9:: with SMTP id c192mr12004pfc.197.1589907170052; Tue, 19 May 2020 09:52:50 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:24 -0700 Message-Id: <20200519165230.23306-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 1/7] net/netvsc: support per-queue info requests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is not a lot of info here from this driver. But worth supporting these additional info queries. Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 2 ++ drivers/net/netvsc/hn_rxtx.c | 20 ++++++++++++++++++++ drivers/net/netvsc/hn_var.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 55b8a63804a9..b890fa3befa8 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -860,6 +860,8 @@ static const struct eth_dev_ops hn_eth_dev_ops = { .dev_stop = hn_dev_stop, .dev_close = hn_dev_close, .dev_infos_get = hn_dev_info_get, + .txq_info_get = hn_dev_tx_queue_info, + .rxq_info_get = hn_dev_rx_queue_info, .dev_supported_ptypes_get = hn_vf_supported_ptypes, .promiscuous_enable = hn_dev_promiscuous_enable, .promiscuous_disable = hn_dev_promiscuous_disable, diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 31fae5597598..668f48fcbf15 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -319,6 +319,15 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev, return err; } +void +hn_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_txq_info *qinfo) +{ + struct hn_tx_queue *txq = dev->data->tx_queues[queue_id]; + + qinfo->nb_desc = txq->txdesc_pool->size; + qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads; +} static struct hn_txdesc *hn_txd_get(struct hn_tx_queue *txq) { @@ -859,6 +868,17 @@ struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv, return rxq; } +void +hn_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_rxq_info *qinfo) +{ + struct hn_rx_queue *rxq = dev->data->rx_queues[queue_id]; + + qinfo->mp = rxq->mb_pool; + qinfo->nb_desc = rxq->rx_ring->size; + qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads; +} + int hn_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index d1d38b459601..93168d2e0102 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -178,6 +178,8 @@ int hn_dev_rx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp); +void hn_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id, + struct rte_eth_rxq_info *qinfo); void hn_dev_rx_queue_release(void *arg); void hn_dev_free_queues(struct rte_eth_dev *dev); From patchwork Tue May 19 16:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70452 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FBCCA0093; Tue, 19 May 2020 18:53:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6F9701D638; Tue, 19 May 2020 18:52:57 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 328C11D62C for ; Tue, 19 May 2020 18:52:53 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id v63so171660pfb.10 for ; Tue, 19 May 2020 09:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F7Ro+4D+/RChrVm48QmNXVHptqTiavagpbltI416tB4=; b=tfIv6IqYKlT9TCPVGRI7Hnz39QOdZO6RoIGj37KC8m1B7cjDJ4TansAMaASG+AuRWW 7X4qdyrXpS8AuO9DAY2oBVqGPzIvsIlKUoCcI3fWMkzkQDI5f5eqc9o4VmQRtc3oAPhx 5tXO/qA54TqIwXG28FMCtc3uYBpo+G5GaSib+cFs920clJK6nirK9gt7iNzwnOsBnS1H D/QuUpFdayZBKmxF44KgMVZCOJmHwNNPE2muAKKzj5gv/WQpP/QPqKp5oJeoRGMPqZm7 Fy4GRIWcRMdTscTceytUX4kOsgPzHt94J4cqXe7F8koYeuTIGnbk4FBSRscQ6hoCH9Mc 4LDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F7Ro+4D+/RChrVm48QmNXVHptqTiavagpbltI416tB4=; b=gIJaU/QdJQy3PY7VgpqsT7IyfED994UYm++0/XxamOl94S5+aoE9O90Gmyv5gXnh+E IgN3RCUjTOtVvXIIm189ip0ydnqPqw1UflfVUYlOfgFWbZPmuzyZErDBoNPZTUlgGAT4 ezrQEiu4ID0J9qh7YFj/B2giOIoLXwlYIKgOwQ6RH1z6nyCbLGozZSd3JW412QR9bmRv ulEWptz54U12H3D/c0NSluIwfu3sJ5JjYFgk8c7XSgH2/IXYo77mhfwLndLJ2B0cqc1L QhcKQdc6GOFmlQGcbk9eqD92WPyMSkLgxOM/GQUiy424xyMMbTnNrpTgELF0kdF8MiEe CFVg== X-Gm-Message-State: AOAM53090nraCuVdrWk/lRLo7BCr6JvXlFKumF4a8fd91WVO60rQMUC2 4ttSeyOkA5mg+FQhhdflgowWQwWANwJCLA== X-Google-Smtp-Source: ABdhPJyw20v1qDvtH7310X3fuqczexkdhXf/XEskgvuYKBrifbeqcJlBZH40b7srE6exFmW3ndqrWA== X-Received: by 2002:a63:5d55:: with SMTP id o21mr154584pgm.58.1589907171620; Tue, 19 May 2020 09:52:51 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:25 -0700 Message-Id: <20200519165230.23306-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 2/7] net/netvsc: implement rx/tx descriptor status functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" These functions are useful for applications and debugging. The netvsc PMD also transparently handles the rx/tx descriptor functions for underlying VF device. Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 3 ++ drivers/net/netvsc/hn_rxtx.c | 57 ++++++++++++++++++++++++++++++++++ drivers/net/netvsc/hn_var.h | 5 +++ 3 files changed, 65 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index b890fa3befa8..675a49e66a57 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -875,8 +875,11 @@ static const struct eth_dev_ops hn_eth_dev_ops = { .tx_queue_setup = hn_dev_tx_queue_setup, .tx_queue_release = hn_dev_tx_queue_release, .tx_done_cleanup = hn_dev_tx_done_cleanup, + .tx_descriptor_status = hn_dev_tx_descriptor_status, .rx_queue_setup = hn_dev_rx_queue_setup, .rx_queue_release = hn_dev_rx_queue_release, + .rx_queue_count = hn_dev_rx_queue_count, + .rx_descriptor_status = hn_dev_rx_queue_status, .link_update = hn_dev_link_update, .stats_get = hn_dev_stats_get, .stats_reset = hn_dev_stats_reset, diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index 668f48fcbf15..b22d8ea7feb0 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -369,6 +369,29 @@ hn_dev_tx_queue_release(void *arg) rte_free(txq); } +/* + * Check the status of a Tx descriptor in the queue. + * + * returns: + * - -EINVAL - offset outside of tx_descriptor pool. + * - RTE_ETH_TX_DESC_FULL - descriptor is not acknowleged by host. + * - RTE_ETH_TX_DESC_DONE - descriptor is available. + */ +int hn_dev_tx_descriptor_status(void *arg, uint16_t offset) +{ + const struct hn_tx_queue *txq = arg; + + hn_process_events(txq->hv, txq->queue_id, 0); + + if (offset >= rte_mempool_avail_count(txq->txdesc_pool)) + return -EINVAL; + + if (offset < rte_mempool_in_use_count(txq->txdesc_pool)) + return RTE_ETH_TX_DESC_FULL; + else + return RTE_ETH_TX_DESC_DONE; +} + static void hn_nvs_send_completed(struct rte_eth_dev *dev, uint16_t queue_id, unsigned long xactid, const struct hn_nvs_rndis_ack *ack) @@ -966,6 +989,40 @@ hn_dev_rx_queue_release(void *arg) hn_rx_queue_free(rxq, true); } +/* + * Get the number of used descriptor in a rx queue + * For this device that means how many packets are pending in the ring. + */ +uint32_t +hn_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_id) +{ + struct hn_rx_queue *rxq = dev->data->rx_queues[queue_id]; + + return rte_ring_count(rxq->rx_ring); +} + +/* + * Check the status of a Rx descriptor in the queue + * + * returns: + * - -EINVAL - offset outside of ring + * - RTE_ETH_RX_DESC_AVAIL - no data available yet + * - RTE_ETH_RX_DESC_DONE - data is waiting in stagin ring + */ +int hn_dev_rx_queue_status(void *arg, uint16_t offset) +{ + const struct hn_rx_queue *rxq = arg; + + hn_process_events(rxq->hv, rxq->queue_id, 0); + if (offset >= rxq->rx_ring->capacity) + return -EINVAL; + + if (offset < rte_ring_count(rxq->rx_ring)) + return RTE_ETH_RX_DESC_DONE; + else + return RTE_ETH_RX_DESC_AVAIL; +} + int hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt) { diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index 93168d2e0102..ded0d4c60a04 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -169,6 +169,7 @@ void hn_dev_tx_queue_release(void *arg); void hn_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_idx, struct rte_eth_txq_info *qinfo); int hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt); +int hn_dev_tx_descriptor_status(void *arg, uint16_t offset); struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv, uint16_t queue_id, @@ -181,6 +182,8 @@ int hn_dev_rx_queue_setup(struct rte_eth_dev *dev, void hn_dev_rx_queue_info(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo); void hn_dev_rx_queue_release(void *arg); +uint32_t hn_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_id); +int hn_dev_rx_queue_status(void *rxq, uint16_t offset); void hn_dev_free_queues(struct rte_eth_dev *dev); /* Check if VF is attached */ @@ -231,6 +234,8 @@ int hn_vf_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); void hn_vf_tx_queue_release(struct hn_data *hv, uint16_t queue_id); +int hn_vf_tx_queue_status(struct hn_data *hv, uint16_t queue_id, uint16_t offset); + int hn_vf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, From patchwork Tue May 19 16:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70453 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC0CBA0093; Tue, 19 May 2020 18:53:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D01AB1D641; Tue, 19 May 2020 18:52:58 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 69BF51D62C for ; Tue, 19 May 2020 18:52:54 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id p30so94733pgl.11 for ; Tue, 19 May 2020 09:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yqaCyvAHTAEbVJJHUdD9vqSOMIlniR+2MJYRzAMACgc=; b=QQl2mRrxKjAOgxgCr2pW11hsRDH2ceu0JJJrdMNgU0Omusw/m4tQi3XZydJAGTbgly 6LE7sZSF9oT9ouUqFHc25QI/FSNl6+HyqUtdBbNRhvsgc1Wzmb9xibQDA/wg6pljoVZE U32M+vUy5qBhLG023hLw6BJgFrYw3vNNv7DkxXtEdcmllAttvBXLEPqUvQk7OaFbW7j3 rjkLW293OhBJcLJbrl008Khiqn3dQNeQh/NGeuj1KI6QJAv8X3ckqjJzR046NXfejF3z x0NpJZfbhuuPxNwoIglHCwCeAXko+PejFtRuwp3MQyp/ZMnzOBlZMYkIQIQLAcbozwxP 4MKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yqaCyvAHTAEbVJJHUdD9vqSOMIlniR+2MJYRzAMACgc=; b=EMEFUV8fvET1WORcP4cU4UzHPFl4xznISKdLmn36nxgxVV5+CBVMDYngsdwZrPtXRv 21bHtNROnKvZ9am0FVTaGZt4DTfhmEpElXUPNOehS0wTu0k5hnrpEIRZQZlrR9AlQsJD AhcP6/y+pRTCfxWC1z1V3PamEPHnpZyv5hRYWVU7qhUI3n5kfhgb3bu40+kKZgBJyF8N zmXzmCjG3qLdb8COQ13kamOEIi+C/Ut9zUxry0BabjRO3ykLnNT7cDPM9o1aSoX5/z/T xkpdI4CAbhmql6Radl+MMfIdwS3Nbgipv7+z86/kToRkHu5eZIhNk9kBDC3jF1o+1uYl t9Tw== X-Gm-Message-State: AOAM533GPcgOXqtC5Un7q9qAT5raymyNX+8ggZeZ3V5koa1bbw42enIB ZQIXp8LRaTxjVgQSYBiQgjiqq6Uq7/9bJA== X-Google-Smtp-Source: ABdhPJzsNXi4btFlQIQo84vRdb2mm6WENLdlYybO/G3Et8Sn2ddLfufxni4mEDuHMMtAfYvu8xXwBA== X-Received: by 2002:a63:5763:: with SMTP id h35mr144082pgm.98.1589907173061; Tue, 19 May 2020 09:52:53 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:52 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:26 -0700 Message-Id: <20200519165230.23306-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 3/7] net/netvsc: change tx/rx logging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The PMD_TX_LOG and PMD_RX_LOG can hide errors since this debug log is typically disabled. Change the code to use PMD_DRV_LOG for errors. Under load, the ring buffer to the host can fill. Add some statistics to estimate the impact and see other errors. Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 1 + drivers/net/netvsc/hn_rxtx.c | 29 ++++++++++++++++++++--------- drivers/net/netvsc/hn_var.h | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 675a49e66a57..0f4827c54be4 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -58,6 +58,7 @@ static const struct hn_xstats_name_off hn_stat_strings[] = { { "good_bytes", offsetof(struct hn_stats, bytes) }, { "errors", offsetof(struct hn_stats, errors) }, { "ring full", offsetof(struct hn_stats, ring_full) }, + { "channel full", offsetof(struct hn_stats, channel_full) }, { "multicast_packets", offsetof(struct hn_stats, multicast) }, { "broadcast_packets", offsetof(struct hn_stats, broadcast) }, { "undersize_packets", offsetof(struct hn_stats, size_bins[0]) }, diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index b22d8ea7feb0..853de2daf7e7 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -412,8 +412,8 @@ hn_nvs_send_completed(struct rte_eth_dev *dev, uint16_t queue_id, txq->stats.bytes += txd->data_size; txq->stats.packets += txd->packets; } else { - PMD_TX_LOG(NOTICE, "port %u:%u complete tx %u failed status %u", - txq->port_id, txq->queue_id, txd->chim_index, ack->status); + PMD_DRV_LOG(NOTICE, "port %u:%u complete tx %u failed status %u", + txq->port_id, txq->queue_id, txd->chim_index, ack->status); ++txq->stats.errors; } @@ -438,8 +438,7 @@ hn_nvs_handle_comp(struct rte_eth_dev *dev, uint16_t queue_id, break; default: - PMD_TX_LOG(NOTICE, - "unexpected send completion type %u", + PMD_DRV_LOG(NOTICE, "unexpected send completion type %u", hdr->type); } } @@ -657,6 +656,7 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, if (unlikely(rte_ring_sp_enqueue(rxq->rx_ring, m) != 0)) { ++rxq->stats.ring_full; + PMD_RX_LOG(DEBUG, "rx ring full"); rte_pktmbuf_free(m); } } @@ -1174,10 +1174,16 @@ static int hn_flush_txagg(struct hn_tx_queue *txq, bool *need_sig) if (likely(ret == 0)) hn_reset_txagg(txq); - else - PMD_TX_LOG(NOTICE, "port %u:%u send failed: %d", - txq->port_id, txq->queue_id, ret); + else if (ret == -EAGAIN) { + PMD_TX_LOG(DEBUG, "port %u:%u channel full", + txq->port_id, txq->queue_id); + ++txq->stats.channel_full; + } else { + ++txq->stats.errors; + PMD_DRV_LOG(NOTICE, "port %u:%u send failed: %d", + txq->port_id, txq->queue_id, ret); + } return ret; } @@ -1523,8 +1529,13 @@ hn_xmit_pkts(void *ptxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) ret = hn_xmit_sg(txq, txd, m, &need_sig); if (unlikely(ret != 0)) { - PMD_TX_LOG(NOTICE, "sg send failed: %d", ret); - ++txq->stats.errors; + if (ret == -EAGAIN) { + PMD_TX_LOG(DEBUG, "sg channel full"); + ++txq->stats.channel_full; + } else { + PMD_DRV_LOG(NOTICE, "sg send failed: %d", ret); + ++txq->stats.errors; + } hn_txd_put(txq, txd); goto fail; } diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index ded0d4c60a04..20363389a0d6 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -40,6 +40,7 @@ struct hn_stats { uint64_t bytes; uint64_t errors; uint64_t ring_full; + uint64_t channel_full; uint64_t multicast; uint64_t broadcast; /* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */ From patchwork Tue May 19 16:52:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70454 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CD0D1A0093; Tue, 19 May 2020 18:53:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB9521D645; Tue, 19 May 2020 18:53:05 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 6E37D1D633 for ; Tue, 19 May 2020 18:52:56 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id k19so129525pll.9 for ; Tue, 19 May 2020 09:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GcgcNkjgnWjx2qfjFjv58XhbqbFPWASTmQkmA0Wn77A=; b=z9zL+bjYYtXHTI5e0lS9SfX7FN1c7SWbeyCyRhmJKHcn5e45MEZ3ar8WYTRausKJA/ L6qYWJsjhcdFBPY0VwTxCx7SUl2d5ZjL9dj0dZgD3WnFp1giMgXBhvXq2I4YTXc4SbP4 c7wDBwabBj19dGAbBYDnTdhav3u5iNv64Axi5m3urIL7ALtdBrRU7L5i41F0UM/aZwQ1 9cHPh/dzgb6eSFNP4ha047ZHQ3ttu++GYJ2hxujumYNo8KtZOpECAGMFsEcUjrYOrvX3 4iCMnV4PIaWZ3VdvXqCu02yKoJfXTeVBGWx4HJp/r0uFQJxMitc1aYq02EWPSog8tAVw U4/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GcgcNkjgnWjx2qfjFjv58XhbqbFPWASTmQkmA0Wn77A=; b=JOspNmSMV+FYni+XjSyZ/ETs3u+nmRvIvmo91U4D7x2rdn6kErTFl0r/qXbRvhkcUy JwQCnH9sLfja0Kj9D8XfHUVuIe9CYtN+fQ/Jez3LWyiKm+lK426L3eypP3mQlpIoG2Ur xeCg/72L4VFvyTBn026Dx9oIBgVJqMCEu6SGJp+3qwDpEbWjQ4odr0t6IpgZ74ElEqgo fairCg5NqmeINEqqEre4c7bOeJYW3mrOwqD4Xhf97PsvEg6ucdbxoRyRkKoJnAlGZvEk qVDIm/OcS+LCbWmkhkjOVVDc6oBh64Pwf9FfRuq4heEujWDVuAkm47JVvYfUbun3WARR 8TJg== X-Gm-Message-State: AOAM533WxUeRJWVKziKG2WHT2nzE25ptDejcg/V7ZydFj19Wh6yAnAxM fY3a9oLFJiyLoTk5MgPf03feVd3s/ybE0w== X-Google-Smtp-Source: ABdhPJwYOs4QuAD/ehY8g+vCey6IN/3YD9KstmCTS4yJD3IrUmbhL75Gqi9GovkwjxYA5+APTlZ9IA== X-Received: by 2002:a17:902:5588:: with SMTP id g8mr375944pli.321.1589907174596; Tue, 19 May 2020 09:52:54 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:27 -0700 Message-Id: <20200519165230.23306-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 4/7] net/netvsc: fix warning when VF is removed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The code to unset owner of VF device was changing port to invalid value before calling unset. Fixes: 4a9efcddaddd ("net/netvsc: fix VF support with secondary process") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_vf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index b7e3ba46bf63..a745c7c36ea3 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -120,11 +120,11 @@ static void hn_vf_remove(struct hn_data *hv) /* Stop incoming packets from arriving on VF */ hn_nvs_set_datapath(hv, NVS_DATAPATH_SYNTHETIC); - /* Stop transmission over VF */ - hv->vf_port = HN_INVALID_PORT; - /* Give back ownership */ rte_eth_dev_owner_unset(hv->vf_port, hv->owner.id); + + /* Stop transmission over VF */ + hv->vf_port = HN_INVALID_PORT; } } From patchwork Tue May 19 16:52:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70455 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2DBFA0093; Tue, 19 May 2020 18:53:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EAE8D1D651; Tue, 19 May 2020 18:53:06 +0200 (CEST) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id 4C3DC1D635 for ; Tue, 19 May 2020 18:52:57 +0200 (CEST) Received: by mail-pj1-f67.google.com with SMTP id ci21so1663228pjb.3 for ; Tue, 19 May 2020 09:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ifK0M3sQH3N4mHyGCMpxMUIWGBUXcEHmFaNe3FQhnU8=; b=qfs4pv+Ow0DIwYIUfJgtV717w6kOku9VG3y3M9LrxYXDuCCK3NZY9arQkpWcynwFup czHBKLyrZPxM6/+bcsCzNlLcPbdNvSHyhBvzoFK8g7VlnEq+YJzBBkrIUPbT5/2T9hql HsjA73GF9GTe18zUWCVmpg1TnsnKiaHE+MdYj+w7OovLCStFMrf5ixucpIIR5mlsuIB4 XeIYcCU6tlWmA1boimLKtzQRadjEPqX9woRJ5eFXtQYT1xniunZ8GkY4l05cNDP/bmaI I5OUUPjLZGz34QSW9TnFxl/sisQ7eTuNl62c0rJvNu44d0MoOTkcl6IRgS60ERkkPLoV 909w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ifK0M3sQH3N4mHyGCMpxMUIWGBUXcEHmFaNe3FQhnU8=; b=kKQIH1+iKeVhdlPyWR0v0/ysCyHoFKGAwY69ljTIDM3VXO9y6dtx4J6VyL7n0h1Y/Y 4H+wcDZzDiBVj+hpD6RVqBLWOT9yix8WMPIVxqJegZBg3cqSaCsW62GqjNbsFxoht26G OM4wD88Z+ALLQwGF8H6Y5EsBWawR+eVgXrFUP8T9KSwQHbnmrYxA+yoUeiANpFO20D/I p/4SqvyS+6CfKCMybXGlyNIsvyCxenJULArLWMgnG+JD7Bo5Ew+GlVqXke23iu9YdVsD 4nCovDJtvistiA+Qw+bvqrQU/kt9zX2BQdTy6EujynnHMmO2foMPprdurqaxoUbyN9I8 Wz2A== X-Gm-Message-State: AOAM530Ek70Hs4cw4rAf9eiJF97tz5Y/wRYZ+Kpr0OdIJDKG0kJBlh1f dO5YoJJWofLBOFU2UojF3mR72VU63z5IVg== X-Google-Smtp-Source: ABdhPJyk711WiBVXKprCMJibXoYaOI4Pt6Rx6hz45yDYp1SFjMk3ayuWo+JhIKTsU3XbT4QdWSjlDA== X-Received: by 2002:a17:902:59db:: with SMTP id d27mr438677plj.48.1589907175898; Tue, 19 May 2020 09:52:55 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:55 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:28 -0700 Message-Id: <20200519165230.23306-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 5/7] net/netvsc: don't query VF link state X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When the primary device link state is queried, there is no need to query the VF state as well. The application only sees the state of the synthetic device. Fixes: dc7680e8597c ("net/netvsc: support integrated VF") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 4 +- drivers/net/netvsc/hn_var.h | 3 -- drivers/net/netvsc/hn_vf.c | 98 +++++----------------------------- 3 files changed, 15 insertions(+), 90 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 0f4827c54be4..ac182a548645 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -202,7 +202,7 @@ static int hn_parse_args(const struct rte_eth_dev *dev) */ int hn_dev_link_update(struct rte_eth_dev *dev, - int wait_to_complete) + int wait_to_complete __rte_unused) { struct hn_data *hv = dev->data->dev_private; struct rte_eth_link link, old; @@ -216,8 +216,6 @@ hn_dev_link_update(struct rte_eth_dev *dev, hn_rndis_get_linkspeed(hv); - hn_vf_link_update(dev, wait_to_complete); - link = (struct rte_eth_link) { .link_duplex = ETH_LINK_FULL_DUPLEX, .link_autoneg = ETH_LINK_SPEED_FIXED, diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index 20363389a0d6..881832d85719 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -141,7 +141,6 @@ struct hn_data { uint16_t rss_ind[128]; struct rte_eth_dev_owner owner; - struct rte_intr_handle vf_intr; struct vmbus_channel *channels[HN_MAX_CHANNELS]; }; @@ -228,8 +227,6 @@ int hn_vf_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr); -int hn_vf_link_update(struct rte_eth_dev *dev, - int wait_to_complete); int hn_vf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index a745c7c36ea3..f5f15c046207 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -97,15 +97,8 @@ int hn_vf_add(struct rte_eth_dev *dev, struct hn_data *hv) } err = hn_vf_attach(hv, port); - if (err == 0) { - dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; - hv->vf_intr = (struct rte_intr_handle) { - .fd = -1, - .type = RTE_INTR_HANDLE_EXT, - }; - dev->intr_handle = &hv->vf_intr; + if (err == 0) hn_nvs_set_datapath(hv, NVS_DATAPATH_VF); - } return err; } @@ -223,80 +216,6 @@ int hn_vf_info_get(struct hn_data *hv, struct rte_eth_dev_info *info) return ret; } -int hn_vf_link_update(struct rte_eth_dev *dev, - int wait_to_complete) -{ - struct hn_data *hv = dev->data->dev_private; - struct rte_eth_dev *vf_dev; - int ret = 0; - - rte_rwlock_read_lock(&hv->vf_lock); - vf_dev = hn_get_vf_dev(hv); - if (vf_dev && vf_dev->dev_ops->link_update) - ret = (*vf_dev->dev_ops->link_update)(vf_dev, wait_to_complete); - rte_rwlock_read_unlock(&hv->vf_lock); - - return ret; -} - -/* called when VF has link state interrupts enabled */ -static int hn_vf_lsc_event(uint16_t port_id __rte_unused, - enum rte_eth_event_type event, - void *cb_arg, void *out __rte_unused) -{ - struct rte_eth_dev *dev = cb_arg; - - if (event != RTE_ETH_EVENT_INTR_LSC) - return 0; - - /* if link state has changed pass on */ - if (hn_dev_link_update(dev, 0) == 0) - return 0; /* no change */ - - return _rte_eth_dev_callback_process(dev, - RTE_ETH_EVENT_INTR_LSC, - NULL); -} - -static int _hn_vf_configure(struct rte_eth_dev *dev, - uint16_t vf_port, - const struct rte_eth_conf *dev_conf) -{ - struct rte_eth_conf vf_conf = *dev_conf; - struct rte_eth_dev *vf_dev; - int ret; - - vf_dev = &rte_eth_devices[vf_port]; - if (dev_conf->intr_conf.lsc && - (vf_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)) { - PMD_DRV_LOG(DEBUG, "enabling LSC for VF %u", - vf_port); - vf_conf.intr_conf.lsc = 1; - } else { - PMD_DRV_LOG(DEBUG, "disabling LSC for VF %u", - vf_port); - vf_conf.intr_conf.lsc = 0; - } - - ret = rte_eth_dev_configure(vf_port, - dev->data->nb_rx_queues, - dev->data->nb_tx_queues, - &vf_conf); - if (ret) { - PMD_DRV_LOG(ERR, - "VF configuration failed: %d", ret); - } else if (vf_conf.intr_conf.lsc) { - ret = rte_eth_dev_callback_register(vf_port, - RTE_ETH_DEV_INTR_LSC, - hn_vf_lsc_event, dev); - if (ret) - PMD_DRV_LOG(ERR, - "Failed to register LSC callback for VF %u", - vf_port); - } - return ret; -} - /* * Configure VF if present. * Force VF to have same number of queues as synthetic device @@ -305,11 +224,22 @@ int hn_vf_configure(struct rte_eth_dev *dev, const struct rte_eth_conf *dev_conf) { struct hn_data *hv = dev->data->dev_private; + struct rte_eth_conf vf_conf = *dev_conf; int ret = 0; + /* link state interrupt does not matter here. */ + vf_conf.intr_conf.lsc = 0; + rte_rwlock_read_lock(&hv->vf_lock); - if (hv->vf_port != HN_INVALID_PORT) - ret = _hn_vf_configure(dev, hv->vf_port, dev_conf); + if (hv->vf_port != HN_INVALID_PORT) { + ret = rte_eth_dev_configure(hv->vf_port, + dev->data->nb_rx_queues, + dev->data->nb_tx_queues, + &vf_conf); + if (ret != 0) + PMD_DRV_LOG(ERR, + "VF configuration failed: %d", ret); + } rte_rwlock_read_unlock(&hv->vf_lock); return ret; } From patchwork Tue May 19 16:52:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70456 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF84CA0093; Tue, 19 May 2020 18:53:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 34D851D658; Tue, 19 May 2020 18:53:08 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id AEC091D63E for ; Tue, 19 May 2020 18:52:58 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id s20so135527plp.6 for ; Tue, 19 May 2020 09:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IXCsz0slMlqovZXBHfrssOLx7LrJjSSaUCqSPo6j3yM=; b=J7m77ooS1J/5z9kycSatC14flzs+sMth2oeFr3wZfTgxlxP0LzXTEGKqv0orb6zptb oP8RxtlccZO37qBi8OczXzT2G2/YfK9neFBsVv1ErB9n3/MTmKTuZFpiT2LLQpfSaLGu JF33bcD5j5K8RXzz1e7AfE8oOdKeTksifHWm2qvtak/JCXUnduE+SwwyDza+wyrHax27 nkzjayP9mv2c/6ddRUqtdms1YVo0ujBZ/EAldjhNs6CSfasSCfokmPmh4NodbS9RXQuu uYzFzpxV90C0frkU+Viaa6b8SJnmLXtpJc2doYKpDJ/rpJrdTmjDZy2j8pXaQKL5XtST VBZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IXCsz0slMlqovZXBHfrssOLx7LrJjSSaUCqSPo6j3yM=; b=mSpRANPuWSmKBiP/RbP0hYpfEoeiExAfCfhur8EWqyBlCX8om/7ep6TeFCDuvBlNZn bKxlpS6bz1BSGMaZFids2iMt9Xou9ujm1w4s+C6+zCIzAlNuGHd1cICiAmk/1utUm2/Y uH1q+ixKAurE2ZqInwR2diPVyAQuZVMz0B5oqp4czVvlYPlX8/JyG8tGgvwu6Ua7jDUa 3wAtJQfD9QUztDxKxkg5LT3OubaoNVpGW9kSgEh/npqz7MpHNMmaMm1ax5Jlz9OwldCz /Xp8co3gDX+b4MokNkpt6Glihrwa3XwUlisSxN1nszFnw8bME0GDJMFE4MEztv0SAn1/ GSXw== X-Gm-Message-State: AOAM532yeesPyBbRU3WPu+0S10cEtpIquCIJyrvD7u/pNDjCAAuynxqf hxQZ11VL4jzjVcxNzLAFaNRmlfLDT1+QPA== X-Google-Smtp-Source: ABdhPJxt06B2Ru++7enkqRt3Ehdwgo4a0BdcFqJGOAQ6p4O8pzXSY0O72XuIBf8eKnf4+9jN8WRNvg== X-Received: by 2002:a17:902:9e0c:: with SMTP id d12mr419011plq.29.1589907177382; Tue, 19 May 2020 09:52:57 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:56 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:29 -0700 Message-Id: <20200519165230.23306-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 6/7] net/netvsc: process link change messages in alarm X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The original code would deadlock itself if a link change event happened with link state interrupt enabled. The problem is that the link state changed message would be seen while reading the host to guest ring (under lock) and then the driver would send a query to the host to see the new link state. The response would never be seen (stuck in a while loop) waiting for the response. The solution is to use the link change indication to trigger a DPDK alarm. The alarm will happen in a different thread and in that context it can send request for new link state and also do interrupt callback. This is similar to how the bonding driver is handling the same thing. Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_rndis.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c index 7947ca2331e2..6a850ce5f226 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,15 @@ static int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, &nvs_rndis, sizeof(nvs_rndis), 0U, NULL); } +/* + * Alarm callback to process link changed notifications. + * Can not directly since link_status is discovered while reading ring + */ +static void hn_rndis_link_alarm(void *arg) +{ + _rte_eth_dev_callback_process(arg, RTE_ETH_EVENT_INTR_LSC, NULL); +} + void hn_rndis_link_status(struct rte_eth_dev *dev, const void *msg) { const struct rndis_status_msg *indicate = msg; @@ -298,11 +308,8 @@ void hn_rndis_link_status(struct rte_eth_dev *dev, const void *msg) case RNDIS_STATUS_LINK_SPEED_CHANGE: case RNDIS_STATUS_MEDIA_CONNECT: case RNDIS_STATUS_MEDIA_DISCONNECT: - if (dev->data->dev_conf.intr_conf.lsc && - hn_dev_link_update(dev, 0) == 0) - _rte_eth_dev_callback_process(dev, - RTE_ETH_EVENT_INTR_LSC, - NULL); + if (dev->data->dev_conf.intr_conf.lsc) + rte_eal_alarm_set(10, hn_rndis_link_alarm, dev); break; default: PMD_DRV_LOG(NOTICE, "unknown RNDIS indication: %#x", @@ -1101,6 +1108,10 @@ hn_rndis_attach(struct hn_data *hv) void hn_rndis_detach(struct hn_data *hv) { + struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id]; + + rte_eal_alarm_cancel(hn_rndis_link_alarm, dev); + /* Halt the RNDIS. */ hn_rndis_halt(hv); } From patchwork Tue May 19 16:52:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 70457 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D64DA0093; Tue, 19 May 2020 18:54:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C0A6D1D65B; Tue, 19 May 2020 18:53:10 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 7AB5C1D64D for ; Tue, 19 May 2020 18:53:00 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id u5so112244pgn.5 for ; Tue, 19 May 2020 09:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s49aFewguuWIhFIT8ZYKi3gpXOPufR4QcbD6gQzpcio=; b=QfHei33HQnB6e0UBFnHguSIa8a8Fz78GH1odtbinBqE6WGFsPBVyYGr36FagbykxcX RA/VShYY0ocgc7jZ3ha/blJ7TrZwJRyy+FrgKAg2wtGCMRPIru05XVDBQ3iD8bEwJ+Xj nsgOA3/Z2ri3mrkB12EBssQD8YQOos15Bb9vR77fTOfiffOw7qsfSfWHHvQRpxlMrS5d k+Wmjl5PSxBk1v3QZ+d4CUqb9yFSzOdmC1qNMx62zWzlFhsfIZjN9HE2wGXexWmqIKrQ RQUaN1WIeUd76d2YDqjXyUkbD1GPrmGIeeR+u1yA5loSLBI+ilZ+/rsgU2o7MNcqWIne KXlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s49aFewguuWIhFIT8ZYKi3gpXOPufR4QcbD6gQzpcio=; b=RnTOXwTtUrBOF1/2eT7M+NSumHeF9l2cm4wyR0mpbpyWRiwxJ0oEC/iqWts1G6nNa0 HSUKBTa7kyVkwMFYhpPKHVNLEAVBql9xe7+oW86M/GnwbRvAZSIz/nlst7VTPxL0lHJS OaNZHch2TUa50JPHIqHq6/AxOVTjT1ucGFeM87hC08sEO0CKkK1l89Cad0P8bser6JhE p39L1DK6bXrG5LVhWn6dqWuQCmYF5pmYERbZAm56aZWfsPlNfAkFVkrpxYlVNvTqwwQc cimtdJQWBLqAKW/jeuGXCbZBofTrImVh17Ra0pnK7nfOkB+T2kZv6AkxV6o3OaCBYv+e W7og== X-Gm-Message-State: AOAM5320s17d6LIG9iQOqnnizwJu+YFZ+s2/JMAA2c+8eUyFbx6WUAQk bAabRJQtflUe+LEAqaHmYl23wchk5WSyOA== X-Google-Smtp-Source: ABdhPJzTiNCNA2GYqFSOEbJlRceN0eBqBSc5RBHXIlTPbMdUEKL2FCqXWJ+l5DeD+dVgPTGai9nFYw== X-Received: by 2002:a63:f350:: with SMTP id t16mr120008pgj.33.1589907178930; Tue, 19 May 2020 09:52:58 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c12sm107394pjm.46.2020.05.19.09.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:52:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 19 May 2020 09:52:30 -0700 Message-Id: <20200519165230.23306-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519165230.23306-1-stephen@networkplumber.org> References: <20200506192730.21613-1-stephen@networkplumber.org> <20200519165230.23306-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 7/7] net/netvsc: do not spin forever waiting for reply X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Because of bugs in driver or host a reply to a request might never occur. Better to give an error than spin forever. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_rndis.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c index 6a850ce5f226..d186ddeabda9 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,9 @@ #include "hn_rndis.h" #include "ndis.h" +#define RNDIS_TIMEOUT_SEC 5 +#define RNDIS_DELAY_MS 10 + #define HN_RNDIS_XFER_SIZE 0x4000 #define HN_NDIS_TXCSUM_CAP_IP4 \ @@ -354,7 +358,7 @@ void hn_rndis_receive_response(struct hn_data *hv, rte_smp_wmb(); if (rte_atomic32_cmpset(&hv->rndis_pending, hdr->rid, 0) == 0) { - PMD_DRV_LOG(ERR, + PMD_DRV_LOG(NOTICE, "received id %#x pending id %#x", hdr->rid, (uint32_t)hv->rndis_pending); } @@ -377,6 +381,11 @@ static int hn_rndis_exec1(struct hn_data *hv, return -EIO; } + if (rid == 0) { + PMD_DRV_LOG(ERR, "Invalid request id"); + return -EINVAL; + } + if (comp != NULL && rte_atomic32_cmpset(&hv->rndis_pending, 0, rid) == 0) { PMD_DRV_LOG(ERR, @@ -391,9 +400,26 @@ static int hn_rndis_exec1(struct hn_data *hv, } if (comp) { + time_t start = time(NULL); + /* Poll primary channel until response received */ - while (hv->rndis_pending == rid) + while (hv->rndis_pending == rid) { + if (hv->closed) + return -ENETDOWN; + + if (time(NULL) - start > RNDIS_TIMEOUT_SEC) { + PMD_DRV_LOG(ERR, + "RNDIS response timed out"); + + rte_atomic32_cmpset(&hv->rndis_pending, rid, 0); + return -ETIMEDOUT; + } + + if (rte_vmbus_chan_rx_empty(hv->primary->chan)) + rte_delay_ms(RNDIS_DELAY_MS); + hn_process_events(hv, 0, 1); + } memcpy(comp, hv->rndis_resp, comp_len); }