From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id 8C0071B467 for ; Fri, 15 Feb 2019 09:37:47 +0100 (CET) Received: by mail-lf1-f68.google.com with SMTP id t14so6579664lfk.7 for ; Fri, 15 Feb 2019 00:37:47 -0800 (PST) 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; bh=wsK0XwdnXtGCXRexWG6+ABoCNd9hldLw1IQsxLhkqdM=; b=i2XF5R1FDlkFL7HoGIhlV7VF4BHAE8RFrTq/HPFkwwCdt1rx7Qu6JsWu5/tcqb13IN 8uPPgW5cXvHIITJTf1Dc+7f9k7k0qA8nm3hdfnxgLhxZtY6/AkzEZi1IQecinX64f7zz aGilQa2EjCWZfYxWH8NF/RHJkc5Mzbpr0/OF8BHUFSjafJoFjlYMVf/cjWTHyvir/xBA co2IjgPdqPja/FGz6P4Ij2jCwlWcct+HyFSagwK/jqCbEpn4aqx+UhUAbJ9/QN6aKErk I8IxI1KTcOQ9qNJhysrDOPuIy/6W7HnEOWHImwgqK3nWNk71Yne/Dw1eJ074h2eqMpKv Fzkg== 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; bh=wsK0XwdnXtGCXRexWG6+ABoCNd9hldLw1IQsxLhkqdM=; b=s8uYU/QOe0WTHm4LS6nYwI6lFkPkjYW6ab6CU+HbZA3VoZQOym+xnZvm5ToiWrglaM QEB/dhd3WrhD7xOpqXNxuuDbfHhtqYZY0bORcY+o/umRithJe2dvFucMdQ8GpY+7cPr3 UAbvqg/fyYCplJyIFVhXD9/lE8FBTfKPzVFwTVsNn1CvXH+PuvDUpeunqQloX1CJBeXI hJRBW5+jes2lae7jp1Pb1Oro+D+NcxrHJbegn0arrVuwojR1B5IjpBoOmd1ZbnKfa4tV pehMF8kO0G6mIRMK9eaCMapFp0Ebt35QW/PaukZgruHbt59rKjsR0ZvYZcm5m4m1Y3P4 j8Dg== X-Gm-Message-State: AHQUAuampKpkisgpW064xXUYwMhtOmrLTCHTzEUz7yLg4rbaaEch3ZXa TD7h5OBrhna5uHr+RxiuHGXn6A== X-Google-Smtp-Source: AHgI3Iav0Ynyfuzlz+4KLAe7LvQtrGGET090S9op0SOHuLFJKeDktD0qVhHJ5HHV5aHRZdshL1i+5Q== X-Received: by 2002:ac2:53b1:: with SMTP id j17mr4683081lfh.143.1550219866932; Fri, 15 Feb 2019 00:37:46 -0800 (PST) Received: from mkPC.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id i15sm993338ljb.48.2019.02.15.00.37.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 00:37:45 -0800 (PST) From: Michal Krawczyk To: gtzalik@amazon.com, mw@semihalf.com, matua@amazon.com Cc: dev@dpdk.org, rk@semihalf.com, Michal Krawczyk Date: Fri, 15 Feb 2019 09:36:39 +0100 Message-Id: <20190215083639.1196-1-mk@semihalf.com> X-Mailer: git-send-email 2.14.1 Subject: [dpdk-dev] [PATCH] net/ena: get device info statically 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: Fri, 15 Feb 2019 08:37:47 -0000 Whenever the app is calling rte_eth_dev_info_get(), it shouldn't use the admin command. It was causing problems, if it was called from the secondary process - the main process was crashing, and the secondary app wasn't getting any result, as the admin request couldn't be processed by the process which was requesting the data. To fix that, the data is being written to the adapter structure during device initialization routine. Signed-off-by: Michal Krawczyk --- drivers/net/ena/ena_ethdev.c | 31 ++++++++++++------------------- drivers/net/ena/ena_ethdev.h | 8 +++++++- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 8bb05caa2..08b1ab195 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -1804,9 +1804,14 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) /* Set max MTU for this device */ adapter->max_mtu = get_feat_ctx.dev_attr.max_mtu; - /* set device support for TSO */ - adapter->tso4_supported = get_feat_ctx.offload.tx & - ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK; + /* set device support for offloads */ + adapter->offloads.tso4_supported = (get_feat_ctx.offload.tx & + ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK) != 0; + adapter->offloads.tx_csum_supported = (get_feat_ctx.offload.tx & + ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK) != 0; + adapter->offloads.tx_csum_supported = + (get_feat_ctx.offload.rx_supported & + ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK) != 0; /* Copy MAC address and point DPDK to it */ eth_dev->data->mac_addrs = (struct ether_addr *)adapter->mac_addr; @@ -1939,9 +1944,7 @@ static void ena_infos_get(struct rte_eth_dev *dev, { struct ena_adapter *adapter; struct ena_com_dev *ena_dev; - struct ena_com_dev_get_features_ctx feat; uint64_t rx_feat = 0, tx_feat = 0; - int rc = 0; ena_assert_msg(dev->data != NULL, "Uninitialized device\n"); ena_assert_msg(dev->data->dev_private != NULL, "Uninitialized device\n"); @@ -1960,26 +1963,16 @@ static void ena_infos_get(struct rte_eth_dev *dev, ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G; - /* Get supported features from HW */ - rc = ena_com_get_dev_attr_feat(ena_dev, &feat); - if (unlikely(rc)) { - RTE_LOG(ERR, PMD, - "Cannot get attribute for ena device rc= %d\n", rc); - return; - } - /* Set Tx & Rx features available for device */ - if (feat.offload.tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK) + if (adapter->offloads.tso4_supported) tx_feat |= DEV_TX_OFFLOAD_TCP_TSO; - if (feat.offload.tx & - ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK) + if (adapter->offloads.tx_csum_supported) tx_feat |= DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM; - if (feat.offload.rx_supported & - ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK) + if (adapter->offloads.rx_csum_supported) rx_feat |= DEV_RX_OFFLOAD_IPV4_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM; @@ -2171,7 +2164,7 @@ eth_ena_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, /* If IPv4 header has DF flag enabled and TSO support is * disabled, partial chcecksum should not be calculated. */ - if (!tx_ring->adapter->tso4_supported) + if (!tx_ring->adapter->offloads.tso4_supported) continue; } diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h index 309b92f65..221760c62 100644 --- a/drivers/net/ena/ena_ethdev.h +++ b/drivers/net/ena/ena_ethdev.h @@ -167,6 +167,12 @@ struct ena_stats_dev { u64 dev_stop; }; +struct ena_offloads { + bool tso4_supported; + bool tx_csum_supported; + bool rx_csum_supported; +}; + /* board specific private data structure */ struct ena_adapter { /* OS defined structs */ @@ -188,7 +194,7 @@ struct ena_adapter { u16 num_queues; u16 max_mtu; - u8 tso4_supported; + struct ena_offloads offloads; int id_number; char name[ENA_NAME_MAX_LEN]; -- 2.14.1