From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B4EB43CA1; Wed, 13 Mar 2024 18:01:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75045410E3; Wed, 13 Mar 2024 18:01:43 +0100 (CET) Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by mails.dpdk.org (Postfix) with ESMTP id 69A8740A84 for ; Wed, 13 Mar 2024 18:01:42 +0100 (CET) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60a0b18e52dso1120247b3.1 for ; Wed, 13 Mar 2024 10:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710349302; x=1710954102; darn=dpdk.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=csRs+72sEegmdoinpFGRSFnfUU+NBvyNSpvyfP6KdlI=; b=STtqdQ4zfqMyv6hjCOAN9LrAtagEeLB9MZ8fc2elYhzHw+KvoUOQSz/9CuMLI5e4UW naUHySrA2KGNJmz5VrL+DQdyPK5PtiLQD+MrGUhovBxtCfb4AcnzwFrWQbrxYS7V9ZaF MTQDCRNCwHeEM/wZUoBHCQiXGInGifuhfF8clk5DtDH1NFb2mgcqKhupiBHDazaFvTt1 OfY5Q07WRDdZSS6AIcwoOWg4hWF49l19KGpbZJWBUzx5LASpHfctvF5oEcNH6aMR0iTZ 1hO4B8arYl3T2SAsSccMR3/teqSqJrWzbuQkKP6vCletP5xvbq588uQi7jp9TDTm5J4f CxaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710349302; x=1710954102; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=csRs+72sEegmdoinpFGRSFnfUU+NBvyNSpvyfP6KdlI=; b=OTXIMNq6mGxrC+6vcoRlKILiahJ47kvc5/68Fb1Y2TaV/V71DEA/ORYfsMyeglwq/Y JuJFM0lYPa5ETdEJOf8wCpJMQxOpyMs/w1S7OrJvG7eQDtLQ2BFBHNJg13BFdoqcXDGn tTEfjdxjJR1YudHRl221z1XL54qOPuDGcNUO4zsf828hHD2Bru5y2PKjIO8GPKwrAaqN Lhe98ugnQaedKQPAtAjDAb3Dbc10KCXEvtEy+o1obkCnjkxaq47MUF1kFJnJoQVhFvJM RZXQ1XcoTlk0go0e255tpIOfXwztuVsSsbcXTqWrJDAe0hfDTfZUR3/eWg/e88lODZAz zGMg== X-Gm-Message-State: AOJu0Yxaga2dY11JmYevLZ/t/HHGnx1kSTQrEcLVS7lFyym5qsyVJiZh suvPo2KBPkRkki8ryT1u5UASDcEuuAlsaHp7Ij4nNhCo0SVn4cNMscwspvYzVH1CmvsnZt3rbo+ v5k0eHg== X-Google-Smtp-Source: AGHT+IH+11Fko/5sPqmMCmlJIWKOygRiSuTKK0S6bW+NFkm/bg3ehoO4XH6+yLyUzvtwkkuLaCLmW0MgsvGf X-Received: from wrushilg.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2168]) (user=rushilg job=sendgmr) by 2002:a0d:d90c:0:b0:60a:40ec:2e23 with SMTP id b12-20020a0dd90c000000b0060a40ec2e23mr702099ywe.3.1710349301823; Wed, 13 Mar 2024 10:01:41 -0700 (PDT) Date: Wed, 13 Mar 2024 17:01:38 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240313170138.2409994-1-rushilg@google.com> Subject: [PATCH] drivers/net/gve: add IPv4 checksum offloading capability From: Rushil Gupta To: junfeng.guo@intel.com, jeroendb@google.com, joshwash@google.com, ferruh.yigit@amd.com Cc: dev@dpdk.org, Rushil Gupta Content-Type: text/plain; charset="UTF-8" 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 Gvnic's DQO format allows offloading IPv4 checksum. Made changes to Tx and Rx path to translate DPDK flags to descriptor for offloading (and vice-versa). Add ptype adminq support to only add this flags for supported L3/L4 packet-types. Signed-off-by: Rushil Gupta Reviewed-by: Joshua Washington --- drivers/net/gve/gve_ethdev.c | 34 +++++++++++++++++++++++++++++++--- drivers/net/gve/gve_ethdev.h | 5 +++++ drivers/net/gve/gve_rx_dqo.c | 38 ++++++++++++++++++++++++++++++++++++-- drivers/net/gve/gve_tx_dqo.c | 2 +- 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index 3b8ec58..475745b 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -434,8 +434,14 @@ gve_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO; - if (priv->queue_format == GVE_DQO_RDA_FORMAT) - dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TCP_LRO; + if (!gve_is_gqi(priv)) { + dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM; + dev_info->rx_offload_capa |= + RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | + RTE_ETH_RX_OFFLOAD_UDP_CKSUM | + RTE_ETH_RX_OFFLOAD_TCP_CKSUM | + RTE_ETH_RX_OFFLOAD_TCP_LRO; + } dev_info->default_rxconf = (struct rte_eth_rxconf) { .rx_free_thresh = GVE_DEFAULT_RX_FREE_THRESH, @@ -938,6 +944,11 @@ gve_teardown_device_resources(struct gve_priv *priv) if (err) PMD_DRV_LOG(ERR, "Could not deconfigure device resources: err=%d", err); } + + if (!gve_is_gqi(priv)) { + rte_free(priv->ptype_lut_dqo); + priv->ptype_lut_dqo = NULL; + } gve_free_counter_array(priv); gve_free_irq_db(priv); gve_clear_device_resources_ok(priv); @@ -997,8 +1008,25 @@ gve_setup_device_resources(struct gve_priv *priv) PMD_DRV_LOG(ERR, "Could not config device resources: err=%d", err); goto free_irq_dbs; } - return 0; + if (!gve_is_gqi(priv)) { + priv->ptype_lut_dqo = rte_zmalloc("gve_ptype_lut_dqo", + sizeof(struct gve_ptype_lut), 0); + if (priv->ptype_lut_dqo == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc ptype lut."); + err = -ENOMEM; + goto free_irq_dbs; + } + err = gve_adminq_get_ptype_map_dqo(priv, priv->ptype_lut_dqo); + if (unlikely(err)) { + PMD_DRV_LOG(ERR, "Failed to get ptype map: err=%d", err); + goto free_ptype_lut; + } + } + return 0; +free_ptype_lut: + rte_free(priv->ptype_lut_dqo); + priv->ptype_lut_dqo = NULL; free_irq_dbs: gve_free_irq_db(priv); free_cnt_array: diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h index d713657..9b19fc5 100644 --- a/drivers/net/gve/gve_ethdev.h +++ b/drivers/net/gve/gve_ethdev.h @@ -36,6 +36,10 @@ RTE_MBUF_F_TX_L4_MASK | \ RTE_MBUF_F_TX_TCP_SEG) +#define GVE_TX_CKSUM_OFFLOAD_MASK_DQO ( \ + GVE_TX_CKSUM_OFFLOAD_MASK | \ + RTE_MBUF_F_TX_IP_CKSUM) + #define GVE_RTE_RSS_OFFLOAD_ALL ( \ RTE_ETH_RSS_IPV4 | \ RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ @@ -295,6 +299,7 @@ struct gve_priv { uint16_t stats_end_idx; /* end index of array of stats written by NIC */ struct gve_rss_config rss_config; + struct gve_ptype_lut *ptype_lut_dqo; }; static inline bool diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c index 7c7a8c4..1c37c54 100644 --- a/drivers/net/gve/gve_rx_dqo.c +++ b/drivers/net/gve/gve_rx_dqo.c @@ -75,6 +75,40 @@ gve_rx_refill_dqo(struct gve_rx_queue *rxq) rxq->bufq_tail = next_avail; } +static inline uint16_t +gve_parse_csum_ol_flags(volatile struct gve_rx_compl_desc_dqo *rx_desc, + struct gve_priv *priv) { + uint64_t ol_flags = 0; + struct gve_ptype ptype = + priv->ptype_lut_dqo->ptypes[rx_desc->packet_type]; + + if (!rx_desc->l3_l4_processed) + return ol_flags; + + if (ptype.l3_type == GVE_L3_TYPE_IPV4) { + if (rx_desc->csum_ip_err) + ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; + else + ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; + } + + if (rx_desc->csum_l4_err) { + ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; + return ol_flags; + } + switch (ptype.l4_type) { + case GVE_L4_TYPE_TCP: + case GVE_L4_TYPE_UDP: + case GVE_L4_TYPE_ICMP: + case GVE_L4_TYPE_SCTP: + ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; + break; + default: + break; + } + return ol_flags; +} + uint16_t gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { @@ -125,8 +159,8 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->data_len = pkt_len; rxm->port = rxq->port_id; rxm->ol_flags = 0; - - rxm->ol_flags |= RTE_MBUF_F_RX_RSS_HASH; + rxm->ol_flags |= RTE_MBUF_F_RX_RSS_HASH | + gve_parse_csum_ol_flags(rx_desc, rxq->hw); rxm->hash.rss = rte_be_to_cpu_32(rx_desc->hash); rx_pkts[nb_rx++] = rxm; diff --git a/drivers/net/gve/gve_tx_dqo.c b/drivers/net/gve/gve_tx_dqo.c index 30a1455..a65e6aa 100644 --- a/drivers/net/gve/gve_tx_dqo.c +++ b/drivers/net/gve/gve_tx_dqo.c @@ -138,7 +138,7 @@ gve_tx_burst_dqo(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* fill the last descriptor with End of Packet (EOP) bit */ txd->pkt.end_of_packet = 1; - if (ol_flags & GVE_TX_CKSUM_OFFLOAD_MASK) + if (ol_flags & GVE_TX_CKSUM_OFFLOAD_MASK_DQO) txd->pkt.checksum_offload_enable = 1; txq->nb_free -= nb_used; -- 2.44.0.278.ge034bb2e1d-goog