From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by dpdk.org (Postfix) with ESMTP id 1614A1B16F for ; Thu, 7 Jun 2018 11:43:37 +0200 (CEST) Received: by mail-lf0-f68.google.com with SMTP id i83-v6so13654362lfh.5 for ; Thu, 07 Jun 2018 02:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NOScEJGxKLYUxfk7aUNOJRNkEQsBOHoRyMP8mqg1xEI=; b=M/kU0DoIb+5VEnko+BhPepCQ/hb5RdnQG/A8agLYT8Ja7zza+mfYwLH6zECPlzw01h INtxxdmRrvgFeO1MWcafMfCniyRYDf3AWTZHdgrpyeYPJcE4j7+YXNaCH8rGZElZbo3c xYBE9FFnQ5uXNLM8FJ+c5jzBPFJTnVtIulAcBm0ciRdem59K463+D8kVKuU//02ruZ1O jNvwtmZ4MqmJN2Y6Mfz+NkYdB2EInIY2IdKENYpk2a6KbMKkqDTOhJLk7VYt3WBSOfJ9 hpxgQof6RIRX2530eGvDjW8KLeT/doNg96FFSA1yhinowPsUN2ATLPriYIY8I2a9HWch eIeg== 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; bh=NOScEJGxKLYUxfk7aUNOJRNkEQsBOHoRyMP8mqg1xEI=; b=NOeJtifllhmlb+hAqy2tEKvWuYQNs59oq3KZ2HuSafQv4LN77OuNaxc0rETOw3183a aZQr2f7AO9SGXC1yKdRGBFUOfEWGj1EUQWYsnImKIjflvfN7va90pTFBbhVCdR3KM12v atAVxg4KrXqosneucC58T8DI+QnuJUa5dia6u/e4Y8nAJ0OB+wfgYVBXJmvPZSs8r/NC TvGqhZAjYrkMaSFUo7ERtQ1EcmFyY4gsarAK8J6bYkHAxj6+OOVTgFXt4DBSmbyO5Uhl SjQr55+UH5Fy6WKqyqum0WSOndoSAckgSnQlfTmC1E3dQwUEdIOXni4jHFAzh95O7k0R rQjg== X-Gm-Message-State: APt69E2ben7xh4przfaT9moIujGJa/hD9TovKg0P7tQVkWwp5cy0YX8U VY8qUuScDCmm0x34tMAa/molHw== X-Google-Smtp-Source: ADUXVKJJ0ADHZtM4d8eMsAEkOtX159DLkDtGBBYQMkqRZmB0yoFdni7QGLAlU6/4byw+TCKvqXgWwQ== X-Received: by 2002:a2e:8257:: with SMTP id j23-v6mr941595ljh.1.1528364616694; Thu, 07 Jun 2018 02:43:36 -0700 (PDT) Received: from mkPC.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id p28-v6sm3612368lfh.24.2018.06.07.02.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 02:43:35 -0700 (PDT) From: Michal Krawczyk To: Marcin Wojtas , Michal Krawczyk , Guy Tzalik , Evgeny Schemeilin Cc: dev@dpdk.org, matua@amazon.com Date: Thu, 7 Jun 2018 11:43:01 +0200 Message-Id: <20180607094322.14312-6-mk@semihalf.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180607094322.14312-1-mk@semihalf.com> References: <20180607094322.14312-1-mk@semihalf.com> Subject: [dpdk-dev] [PATCH v3 06/27] net/ena: add LSC intr support and AENQ handling 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: , X-List-Received-Date: Thu, 07 Jun 2018 09:43:38 -0000 To make the LSC interrupt working, the AENQ must be configured properly in the ENA device. The AENQ interrupt is common for all maintance interrupts - the proper handler is then executed depending on the received descriptor. Signed-off-by: Michal Krawczyk --- drivers/net/ena/ena_ethdev.c | 52 ++++++++++++++++++++++++++++++++++++++------ drivers/net/ena/ena_ethdev.h | 2 ++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 4ca19c57c..a344b2573 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -201,7 +201,7 @@ static const struct rte_pci_id pci_id_ena_map[] = { { .device_id = 0 }, }; -static struct ena_aenq_handlers empty_aenq_handlers; +static struct ena_aenq_handlers aenq_handlers; static int ena_device_init(struct ena_com_dev *ena_dev, struct ena_com_dev_get_features_ctx *get_feat_ctx); @@ -732,8 +732,11 @@ static int ena_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { struct rte_eth_link *link = &dev->data->dev_link; + struct ena_adapter *adapter; + + adapter = (struct ena_adapter *)(dev->data->dev_private); - link->link_status = ETH_LINK_UP; + link->link_status = adapter->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; link->link_speed = ETH_SPEED_NUM_10G; link->link_duplex = ETH_LINK_FULL_DUPLEX; @@ -1228,6 +1231,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) static int ena_device_init(struct ena_com_dev *ena_dev, struct ena_com_dev_get_features_ctx *get_feat_ctx) { + uint32_t aenq_groups; int rc; bool readless_supported; @@ -1263,7 +1267,7 @@ static int ena_device_init(struct ena_com_dev *ena_dev, ena_dev->dma_addr_bits = ena_com_get_dma_width(ena_dev); /* ENA device administration layer init */ - rc = ena_com_admin_init(ena_dev, &empty_aenq_handlers, true); + rc = ena_com_admin_init(ena_dev, &aenq_handlers, true); if (rc) { RTE_LOG(ERR, PMD, "cannot initialize ena admin queue with device\n"); @@ -1286,6 +1290,15 @@ static int ena_device_init(struct ena_com_dev *ena_dev, goto err_admin_init; } + aenq_groups = BIT(ENA_ADMIN_LINK_CHANGE); + + aenq_groups &= get_feat_ctx->aenq.supported_groups; + rc = ena_com_set_aenq_config(ena_dev, aenq_groups); + if (rc) { + RTE_LOG(ERR, PMD, "Cannot configure aenq groups rc: %d\n", rc); + goto err_admin_init; + } + return 0; err_admin_init: @@ -1297,12 +1310,14 @@ static int ena_device_init(struct ena_com_dev *ena_dev, return rc; } -static void ena_interrupt_handler_rte(__rte_unused void *cb_arg) +static void ena_interrupt_handler_rte(void *cb_arg) { struct ena_adapter *adapter = (struct ena_adapter *)cb_arg; struct ena_com_dev *ena_dev = &adapter->ena_dev; ena_com_admin_q_comp_intr_handler(ena_dev); + if (adapter->state != ENA_ADAPTER_STATE_CLOSED) + ena_com_aenq_intr_handler(ena_dev, adapter); } static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) @@ -1405,6 +1420,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) adapter); rte_intr_enable(intr_handle); ena_com_set_admin_polling_mode(ena_dev, false); + ena_com_admin_aenq_enable(ena_dev); adapters_found++; adapter->state = ENA_ADAPTER_STATE_INIT; @@ -1842,6 +1858,9 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, return sent_idx; } +/********************************************************************* + * PMD configuration + *********************************************************************/ static int eth_ena_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { @@ -1856,7 +1875,7 @@ static int eth_ena_pci_remove(struct rte_pci_device *pci_dev) static struct rte_pci_driver rte_ena_pmd = { .id_table = pci_id_ena_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, .probe = eth_ena_pci_probe, .remove = eth_ena_pci_remove, }; @@ -1880,6 +1899,25 @@ ena_init_log(void) /****************************************************************************** ******************************** AENQ Handlers ******************************* *****************************************************************************/ +static void ena_update_on_link_change(void *adapter_data, + struct ena_admin_aenq_entry *aenq_e) +{ + struct rte_eth_dev *eth_dev; + struct ena_adapter *adapter; + struct ena_admin_aenq_link_change_desc *aenq_link_desc; + uint32_t status; + + adapter = (struct ena_adapter *)adapter_data; + aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e; + eth_dev = adapter->rte_dev; + + status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc); + adapter->link_status = status; + + ena_link_update(eth_dev, 0); + _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL); +} + /** * This handler will called for unknown event group or unimplemented handlers **/ @@ -1889,9 +1927,9 @@ static void unimplemented_aenq_handler(__rte_unused void *data, // Unimplemented handler } -static struct ena_aenq_handlers empty_aenq_handlers = { +static struct ena_aenq_handlers aenq_handlers = { .handlers = { - [ENA_ADMIN_LINK_CHANGE] = unimplemented_aenq_handler, + [ENA_ADMIN_LINK_CHANGE] = ena_update_on_link_change, [ENA_ADMIN_NOTIFICATION] = unimplemented_aenq_handler, [ENA_ADMIN_KEEP_ALIVE] = unimplemented_aenq_handler }, diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h index 79fb14aeb..16172a54a 100644 --- a/drivers/net/ena/ena_ethdev.h +++ b/drivers/net/ena/ena_ethdev.h @@ -181,6 +181,8 @@ struct ena_adapter { uint64_t tx_selected_offloads; uint64_t rx_supported_offloads; uint64_t rx_selected_offloads; + + bool link_status; }; #endif /* _ENA_ETHDEV_H_ */ -- 2.14.1