From patchwork Tue Feb 22 18:11:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Krawczyk X-Patchwork-Id: 108014 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 676D5A034E; Tue, 22 Feb 2022 19:12:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 020584115C; Tue, 22 Feb 2022 19:12:20 +0100 (CET) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mails.dpdk.org (Postfix) with ESMTP id 5B2D141154 for ; Tue, 22 Feb 2022 19:12:17 +0100 (CET) Received: by mail-ed1-f49.google.com with SMTP id q17so39155859edd.4 for ; Tue, 22 Feb 2022 10:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q3Vs8v0DzviJaKbmyC2cPdlagzNUgAm/fkn2vY416do=; b=WJ+iqSH68Ilfeph+IrJZgUvC89UVvnfJbDNNqLKNbZ9qpVa7pY1iPd48wNpn8izh2X 75ocCuiPV5JtHSbKwf1EAaLV5yMJv1SZvw5MuaDHFX8WgBv/VBy9jlI3wIdfIA3tOBNm fvu//4stCc0cBk8mU/U6ANiGTsNzMWqlJ79GfpboNhEnZs0CpQFF2s/0n+to3HZ9Hif+ LVzmd7D1qjX1V5SQ70PVPrPi11rJdpcu7mBhSyODqcQc9n20BWX6tPeO3Moj9FoIxgGZ J6Wp/BxOS/Kflhm3OoiWu5q8fbUnScF/wrZh0tKVVya3PkbgeTienpU8oA2yJHVufsVI NGbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q3Vs8v0DzviJaKbmyC2cPdlagzNUgAm/fkn2vY416do=; b=Bl6O+8+NawkutbX3l3K9M2pLP4PrqqX6CFtt+aQaFK/kWab7PxkodlSaqbLL8358o0 7RbSimA1Mu/NEHLvRCdOc6gqcrjNIb7gL+fXnsTShhmY9YdmASC9QC7dQ+HVHZzhgS+p rU0CA7Be+1EV4fg60/oUPOJdptYBLf4MwlfXAlsiOYyAroz3+3FicWHoxVJcnvD/eTti yL9AhK1GaGc52jq6bkmbBoZdFtAPdRJMBOQWO1gfLfhgnLQRz2/84EhjoXhKLN2bc7LJ yxSWrgWm1BmtmnY01UhctTxr25GQ2FUbPVF9yM8NHv65ZqJHd7sspQISFWsdiD7zaoJg wZUw== X-Gm-Message-State: AOAM530EZ9vmA695djMymmeA8JqJw0YegNmTTyrgVrc5glyJl+sG+MU1 ssV5eV+fsvx8VVPk4nDysf2/vYiNTiD/lw== X-Google-Smtp-Source: ABdhPJxrtVd4sXb4nu0jEBigFhKuEh/NNhulpoQphbRVRMDys2l7IOiUVCFbL62zDKzZ0pP4RruBbw== X-Received: by 2002:aa7:d80f:0:b0:410:d5c3:f770 with SMTP id v15-20020aa7d80f000000b00410d5c3f770mr27769135edq.279.1645553536735; Tue, 22 Feb 2022 10:12:16 -0800 (PST) Received: from DESKTOP-U5LNN3J.localdomain (89-79-181-52.dynamic.chello.pl. [89.79.181.52]) by smtp.gmail.com with ESMTPSA id y21sm10610153eda.38.2022.02.22.10.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:12:16 -0800 (PST) From: Michal Krawczyk To: dev@dpdk.org Cc: shaibran@amazon.com, upstream@semihalf.com, Michal Krawczyk , Dawid Gorecki Subject: [PATCH v2 06/21] net/ena: make LSC configurable Date: Tue, 22 Feb 2022 19:11:31 +0100 Message-Id: <20220222181146.28882-7-mk@semihalf.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222181146.28882-1-mk@semihalf.com> References: <20220222160634.24489-1-mk@semihalf.com> <20220222181146.28882-1-mk@semihalf.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org ENA uses AENQ for notification about various events, like LSC, keep alive etc. By default it was enabling all AENQ that were supported by both the driver and the device. As a result the LSC was always processed even if the application turned it off explicitly. As the DPDK provides application with the possibility to configure the LSC, ENA should respect that. AENQ groups are now being updated upon configure step, thus LSC can be activated or disabled between ENA PMD reconfigurations. Moreover, the LSC capability for the device is being determined dynamically. Signed-off-by: Michal Krawczyk Reviewed-by: Dawid Gorecki Reviewed-by: Shai Brandes --- doc/guides/rel_notes/release_22_03.rst | 1 + drivers/net/ena/ena_ethdev.c | 66 +++++++++++++++++++------- drivers/net/ena/ena_ethdev.h | 5 +- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 6b69763f85..f803402138 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -111,6 +111,7 @@ New Features * Added new checksum related xstats: ``l3_csum_bad``, ``l4_csum_bad`` and ``l4_csum_good``. + * Added support for the link status configuration. * **Updated Cisco enic driver.** diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index d534b93749..a2793f13cd 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -160,10 +160,9 @@ static const struct rte_pci_id pci_id_ena_map[] = { static struct ena_aenq_handlers aenq_handlers; -static int ena_device_init(struct ena_com_dev *ena_dev, +static int ena_device_init(struct ena_adapter *adapter, struct rte_pci_device *pdev, - struct ena_com_dev_get_features_ctx *get_feat_ctx, - bool *wd_state); + struct ena_com_dev_get_features_ctx *get_feat_ctx); static int ena_dev_configure(struct rte_eth_dev *dev); static void ena_tx_map_mbuf(struct ena_ring *tx_ring, struct ena_tx_buffer *tx_info, @@ -249,6 +248,7 @@ static int ena_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id); static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id); +static int ena_configure_aenq(struct ena_adapter *adapter); static const struct eth_dev_ops ena_dev_ops = { .dev_configure = ena_dev_configure, @@ -1416,11 +1416,11 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) return i; } -static int ena_device_init(struct ena_com_dev *ena_dev, +static int ena_device_init(struct ena_adapter *adapter, struct rte_pci_device *pdev, - struct ena_com_dev_get_features_ctx *get_feat_ctx, - bool *wd_state) + struct ena_com_dev_get_features_ctx *get_feat_ctx) { + struct ena_com_dev *ena_dev = &adapter->ena_dev; uint32_t aenq_groups; int rc; bool readless_supported; @@ -1485,13 +1485,8 @@ static int ena_device_init(struct ena_com_dev *ena_dev, BIT(ENA_ADMIN_WARNING); aenq_groups &= get_feat_ctx->aenq.supported_groups; - rc = ena_com_set_aenq_config(ena_dev, aenq_groups); - if (rc) { - PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc: %d\n", rc); - goto err_admin_init; - } - *wd_state = !!(aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE)); + adapter->all_aenq_groups = aenq_groups; return 0; @@ -1517,7 +1512,7 @@ static void ena_interrupt_handler_rte(void *cb_arg) static void check_for_missing_keep_alive(struct ena_adapter *adapter) { - if (!adapter->wd_state) + if (!(adapter->active_aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE))) return; if (adapter->keep_alive_timeout == ENA_HW_HINTS_NO_TIMEOUT) @@ -1798,7 +1793,6 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) int rc; static int adapters_found; bool disable_meta_caching; - bool wd_state = false; eth_dev->dev_ops = &ena_dev_ops; eth_dev->rx_pkt_burst = ð_ena_recv_pkts; @@ -1850,12 +1844,15 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) } /* device specific initialization routine */ - rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state); + rc = ena_device_init(adapter, pci_dev, &get_feat_ctx); if (rc) { PMD_INIT_LOG(CRIT, "Failed to init ENA device\n"); goto err; } - adapter->wd_state = wd_state; + + /* Check if device supports LSC */ + if (!(adapter->all_aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE))) + adapter->edev_data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; set_default_llq_configurations(&llq_config, &get_feat_ctx.llq, adapter->use_large_llq_hdr); @@ -1999,6 +1996,7 @@ static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev) static int ena_dev_configure(struct rte_eth_dev *dev) { struct ena_adapter *adapter = dev->data->dev_private; + int rc; adapter->state = ENA_ADAPTER_STATE_CONFIG; @@ -2025,7 +2023,9 @@ static int ena_dev_configure(struct rte_eth_dev *dev) */ adapter->tx_cleanup_stall_delay = adapter->missing_tx_completion_to / 2; - return 0; + rc = ena_configure_aenq(adapter); + + return rc; } static void ena_init_rings(struct ena_adapter *adapter, @@ -3165,6 +3165,38 @@ static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev, return 0; } +static int ena_configure_aenq(struct ena_adapter *adapter) +{ + uint32_t aenq_groups = adapter->all_aenq_groups; + int rc; + + /* All_aenq_groups holds all AENQ functions supported by the device and + * the HW, so at first we need to be sure the LSC request is valid. + */ + if (adapter->edev_data->dev_conf.intr_conf.lsc != 0) { + if (!(aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE))) { + PMD_DRV_LOG(ERR, + "LSC requested, but it's not supported by the AENQ\n"); + return -EINVAL; + } + } else { + /* If LSC wasn't enabled by the app, let's enable all supported + * AENQ procedures except the LSC. + */ + aenq_groups &= ~BIT(ENA_ADMIN_LINK_CHANGE); + } + + rc = ena_com_set_aenq_config(&adapter->ena_dev, aenq_groups); + if (rc != 0) { + PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc=%d\n", rc); + return rc; + } + + adapter->active_aenq_groups = aenq_groups; + + return 0; +} + /********************************************************************* * PMD configuration *********************************************************************/ diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h index 42c47c9455..f660b6a7cb 100644 --- a/drivers/net/ena/ena_ethdev.h +++ b/drivers/net/ena/ena_ethdev.h @@ -291,9 +291,10 @@ struct ena_adapter { struct ena_stats_dev dev_stats; struct ena_stats_eni eni_stats; - bool trigger_reset; + uint32_t all_aenq_groups; + uint32_t active_aenq_groups; - bool wd_state; + bool trigger_reset; bool use_large_llq_hdr;