DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ena: get device info statically
@ 2019-02-15  8:36 Michal Krawczyk
  2019-02-18 16:34 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Krawczyk @ 2019-02-15  8:36 UTC (permalink / raw)
  To: gtzalik, mw, matua; +Cc: dev, rk, Michal Krawczyk

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 <mk@semihalf.com>
---
 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/ena: get device info statically
  2019-02-15  8:36 [dpdk-dev] [PATCH] net/ena: get device info statically Michal Krawczyk
@ 2019-02-18 16:34 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2019-02-18 16:34 UTC (permalink / raw)
  To: Michal Krawczyk, gtzalik, mw, matua; +Cc: dev, rk

On 2/15/2019 8:36 AM, Michal Krawczyk wrote:
> 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 <mk@semihalf.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-18 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15  8:36 [dpdk-dev] [PATCH] net/ena: get device info statically Michal Krawczyk
2019-02-18 16:34 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).