From: Jasper Tran O'Leary <[email protected]> Add scattered RX offload support for the DQO descriptor format.
When a received frame exceeds the size of a single RX buffer in DQO mode, the device slices the packet across multiple RX buffers and clears the end-of-packet indicator on all but the final completion descriptor. - Advertise scattered RX for DQO and allow RX buffers smaller than the device maximum frame size when scatter RX is enabled, while still rejecting them at queue setup, port start, and MTU updates when scatter is disabled. - Chain segments across burst boundaries on the RX queue context, apply packet type, checksum, RSS hash, and hardware timestamp metadata from the end-of-packet completion descriptor, and free partial chains on error or queue teardown. - Update the GVE feature matrix and documentation for scattered RX. Signed-off-by: Jasper Tran O'Leary <[email protected]> Signed-off-by: Joshua Washington <[email protected]> --- doc/guides/nics/features/gve.ini | 2 +- doc/guides/nics/gve.rst | 18 ++++++ doc/guides/rel_notes/release_27_03.rst | 4 ++ drivers/net/gve/gve_ethdev.c | 30 +++++---- drivers/net/gve/gve_rx_dqo.c | 85 +++++++++++++++++++------- 5 files changed, 104 insertions(+), 35 deletions(-) diff --git a/doc/guides/nics/features/gve.ini b/doc/guides/nics/features/gve.ini index 909858d8f0..3a746d73ef 100644 --- a/doc/guides/nics/features/gve.ini +++ b/doc/guides/nics/features/gve.ini @@ -6,7 +6,7 @@ [Features] Speed capabilities = Y MTU update = Y -Scattered Rx = P +Scattered Rx = Y TSO = Y RSS hash = Y RSS key update = Y diff --git a/doc/guides/nics/gve.rst b/doc/guides/nics/gve.rst index 5a1efad05b..13634a178c 100644 --- a/doc/guides/nics/gve.rst +++ b/doc/guides/nics/gve.rst @@ -68,6 +68,7 @@ Supported features of the GVE PMD are: - Multiple queues for Tx and Rx - TSO offload - Link state information +- Rx multi-segments (Scattered Rx) - Tx multi-segments (Scatter Tx) - Tx UDP/TCP/SCTP Checksum - RSS hash configuration @@ -80,6 +81,23 @@ It'll be added in a future DPDK release. Also, only GQI_QPL queue format is in use on GCP since GQI_RDA hasn't been released in production. +Scattered Rx +^^^^^^^^^^^^ + +The driver supports receiving a frame into multiple chained mbufs +via the standard ``RTE_ETH_RX_OFFLOAD_SCATTER`` offload capability. + +**Limitations** + +- The device delivers frames up to its maximum MTU + (``max_mtu`` reported by ``rte_eth_dev_info_get()``), + regardless of the MTU configured on the port. +- With the DQO queue format, + if ``RTE_ETH_RX_OFFLOAD_SCATTER`` is not enabled, + each Rx buffer must be large enough to hold a frame of the device maximum MTU, + i.e. ``max_mtu`` plus the 14-byte Ethernet header. + Rx queue setup, port start, and MTU update fail otherwise. + RSS ^^^ diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst index 114a71f1ec..d8352ab095 100644 --- a/doc/guides/rel_notes/release_27_03.rst +++ b/doc/guides/rel_notes/release_27_03.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Google gve driver.** + + Added scattered Rx support on DQO queues. + * **Updated Huawei hinic3 ethernet driver.** * Added vport statistics, including CIR drop, and VF link diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index dcb270d269..866a3bba7b 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -462,25 +462,34 @@ gve_start_queues(struct rte_eth_dev *dev) return ret; } -/* GQI chains a frame larger than one Rx buffer into a multi-segment - * mbuf. No Rx offload is per-queue here, so check the port offloads. +/* A frame larger than one Rx buffer is chained into a multi-segment + * mbuf, which requires Rx scatter to be enabled. No Rx offload is + * per-queue here, so check the port offloads. */ static int gve_rx_check_scatter(struct rte_eth_dev *dev, uint16_t mtu) { struct gve_priv *priv = dev->data->dev_private; + uint16_t check_mtu; uint16_t i; - if (!gve_is_gqi(priv) || - (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SCATTER)) + if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SCATTER) return 0; + check_mtu = gve_is_gqi(priv) ? mtu : RTE_MAX(mtu, priv->max_mtu); for (i = 0; i < dev->data->nb_rx_queues; i++) { struct gve_rx_queue *rxq = dev->data->rx_queues[i]; + bool needs_scatter; - if (rxq != NULL && gve_rx_gqi_needs_scatter(mtu, rxq->rx_buf_len)) { + if (rxq == NULL) + continue; + + needs_scatter = gve_is_gqi(priv) ? + gve_rx_gqi_needs_scatter(check_mtu, rxq->rx_buf_len) : + gve_rx_dqo_needs_scatter(check_mtu, rxq->rx_buf_len); + if (needs_scatter) { PMD_DRV_LOG(ERR, "MTU %u needs Rx scatter with %u byte Rx buffers", - mtu, rxq->rx_buf_len); + check_mtu, rxq->rx_buf_len); return -EINVAL; } } @@ -950,12 +959,9 @@ gve_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_mtu = priv->max_mtu; dev_info->min_mtu = RTE_ETHER_MIN_MTU; - dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_RSS_HASH; - /* GQI receives a frame larger than one Rx buffer as a chain of - * buffers (gve_rx_burst follows GVE_RXF_PKT_CONT). - */ - if (gve_is_gqi(priv)) - dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SCATTER; + dev_info->rx_offload_capa = + RTE_ETH_RX_OFFLOAD_RSS_HASH | + RTE_ETH_RX_OFFLOAD_SCATTER; if (priv->clk_read_type != GVE_DEV_CLK_UNSUPPORTED && priv->nic_ts_report_mz != NULL) dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c index c4fe9692a7..c2431b6d88 100644 --- a/drivers/net/gve/gve_rx_dqo.c +++ b/drivers/net/gve/gve_rx_dqo.c @@ -155,6 +155,18 @@ gve_rx_set_mbuf_ptype(struct gve_priv *priv, struct rte_mbuf *rx_mbuf, } } +static inline bool +gve_rx_seg_invalid_dqo(volatile struct gve_rx_compl_desc_dqo *rx_desc, + struct gve_rx_queue *rxq, bool is_eop) +{ + bool is_first_seg = (rxq->ctx.mbuf_head == NULL); + bool unexpected_multiseg = is_first_seg && !is_eop && !rxq->scatter; + bool max_segs_exceeded = rxq->ctx.mbuf_head != NULL && + rxq->ctx.mbuf_head->nb_segs >= RTE_MBUF_MAX_NB_SEGS; + + return rx_desc->rx_error != 0 || unexpected_multiseg || max_segs_exceeded; +} + uint16_t gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { @@ -162,9 +174,10 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) struct gve_rx_queue *rxq; uint64_t last_sync = 0; struct gve_priv *priv; + struct rte_mbuf *pkt; struct rte_mbuf *rxm; uint16_t rx_buf_id; - uint16_t pkt_len; + uint16_t frag_len; uint16_t rx_id; uint16_t nb_rx; uint64_t bytes; @@ -218,7 +231,7 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) } if (!rxq->ctx.drop_pkt && - unlikely(rx_desc->rx_error != 0 || !is_eop)) { + unlikely(gve_rx_seg_invalid_dqo(rx_desc, rxq, is_eop))) { rxq->stats.errors++; rxq->ctx.drop_pkt = true; } @@ -226,19 +239,39 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) if (unlikely(rxq->ctx.drop_pkt)) { if (rxm != NULL) rte_pktmbuf_free(rxm); + if (rxq->ctx.mbuf_head != NULL) { + rte_pktmbuf_free(rxq->ctx.mbuf_head); + rxq->ctx.mbuf_head = NULL; + rxq->ctx.mbuf_tail = NULL; + } if (is_eop) gve_rx_ctx_clear(&rxq->ctx); continue; } - pkt_len = rte_le_to_cpu_16(rx_desc->packet_len); - rxm->pkt_len = pkt_len; - rxm->data_len = pkt_len; - rxm->port = rxq->port_id; - gve_rx_set_mbuf_ptype(rxq->hw, rxm, rx_desc); - rxm->ol_flags = RTE_MBUF_F_RX_RSS_HASH; - gve_parse_csum_ol_flags(rxm, rx_desc); - rxm->hash.rss = rte_le_to_cpu_32(rx_desc->hash); + frag_len = rte_le_to_cpu_16(rx_desc->packet_len); + rxm->data_len = frag_len; + if (rxq->ctx.mbuf_head == NULL) { + rxq->ctx.mbuf_head = rxm; + rxq->ctx.mbuf_tail = rxm; + rxm->nb_segs = 1; + rxm->pkt_len = frag_len; + rxm->port = rxq->port_id; + } else { + rxq->ctx.mbuf_head->nb_segs++; + rxq->ctx.mbuf_head->pkt_len += frag_len; + rxq->ctx.mbuf_tail->next = rxm; + rxq->ctx.mbuf_tail = rxm; + } + + if (!is_eop) + continue; + + pkt = rxq->ctx.mbuf_head; + gve_rx_set_mbuf_ptype(priv, pkt, rx_desc); + pkt->ol_flags = RTE_MBUF_F_RX_RSS_HASH; + gve_parse_csum_ol_flags(pkt, rx_desc); + pkt->hash.rss = rte_le_to_cpu_32(rx_desc->hash); if (last_sync != 0 && (rx_desc->ts_sub_nsecs_low & GVE_DQO_RX_HWTSTAMP_VALID) && @@ -246,12 +279,14 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) uint32_t ts = rte_le_to_cpu_32(rx_desc->ts); uint64_t full_ts = gve_reconstruct_ts(last_sync, ts); - *RTE_MBUF_DYNFIELD(rxm, priv->mbuf_timestamp_offset, uint64_t *) = full_ts; - rxm->ol_flags |= priv->mbuf_timestamp_mask; + *RTE_MBUF_DYNFIELD(pkt, priv->mbuf_timestamp_offset, + uint64_t *) = full_ts; + pkt->ol_flags |= priv->mbuf_timestamp_mask; } - rx_pkts[nb_rx++] = rxm; - bytes += pkt_len; + rx_pkts[nb_rx++] = pkt; + bytes += pkt->pkt_len; + gve_rx_ctx_clear(&rxq->ctx); } rxq->rx_tail = rx_id; @@ -276,6 +311,8 @@ gve_release_rxq_mbufs_dqo(struct gve_rx_queue *rxq) } } + if (rxq->ctx.mbuf_head != NULL) + rte_pktmbuf_free(rxq->ctx.mbuf_head); gve_rx_ctx_clear(&rxq->ctx); rxq->nb_avail = rxq->nb_rx_desc; @@ -356,6 +393,7 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id, struct gve_rx_queue *rxq; uint16_t free_thresh; uint16_t rx_buf_len; + uint64_t offloads; int err = 0; /* Ring size is required to be a power of two. */ @@ -365,15 +403,16 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id, return -EINVAL; } - /* Without Rx scatter support on DQO, each Rx buffer must fit any + /* Without Rx scatter enabled, each DQO Rx buffer must fit any * incoming frame up to the device maximum MTU. */ + offloads = dev->data->dev_conf.rxmode.offloads | conf->offloads; rx_buf_len = gve_rx_buf_len_dqo(pool); - if (gve_rx_dqo_needs_scatter(hw->max_mtu, rx_buf_len)) { + if (!(offloads & RTE_ETH_RX_OFFLOAD_SCATTER) && + gve_rx_dqo_needs_scatter(hw->max_mtu, rx_buf_len)) { PMD_DRV_LOG(ERR, - "Max MTU %u needs at least %u byte Rx buffers (got %u)", - hw->max_mtu, hw->max_mtu + RTE_ETHER_HDR_LEN, - rx_buf_len); + "Max MTU %u needs Rx scatter with %u byte Rx buffers", + hw->max_mtu, rx_buf_len); return -EINVAL; } @@ -394,8 +433,7 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id, } /* Setup hardware timestamping if enabled */ - if ((conf->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) || - (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) + if (offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) rxq->timestamp_enabled = true; /* check free_thresh here */ @@ -403,7 +441,7 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id, conf->rx_free_thresh : GVE_DEFAULT_RX_FREE_THRESH; if (free_thresh >= nb_desc) { PMD_DRV_LOG(ERR, "rx_free_thresh (%u) must be less than nb_desc (%u).", - free_thresh, rxq->nb_rx_desc); + free_thresh, nb_desc); err = -EINVAL; goto free_rxq; } @@ -413,6 +451,9 @@ gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id, rxq->queue_id = queue_id; rxq->port_id = dev->data->port_id; rxq->ntfy_id = hw->num_ntfy_blks / 2 + queue_id; + rxq->scatter = !!(offloads & RTE_ETH_RX_OFFLOAD_SCATTER); + if (rxq->scatter) + dev->data->scattered_rx = 1; rxq->mpool = pool; rxq->hw = hw; -- 2.56.1.915.g69d5ec7298-goog

