From: Harman Kalra Date: Mon, 10 Aug 2020 10:55:45 +0000 (+0530) Subject: net/octeontx2: fix multi segment mode for jumbo packets X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=27e27ec62999fa91b2a4865d6909ccbb5118eb26;p=dpdk.git net/octeontx2: fix multi segment mode for jumbo packets Scatter gather mode should get enabled: - If mbuf size is less than max received packet length. - MTU is reconfigured greater than mbuf size. Fixes: 0e2efd02db58 ("net/octeontx2: add MTU set operation") Cc: stable@dpdk.org Signed-off-by: Harman Kalra Acked-by: Jerin Jacob --- diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index c06e32f26b..3ad50d7cfe 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -657,6 +657,9 @@ otx2_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t rq, } } + /* Setup scatter mode if needed by jumbo */ + otx2_nix_enable_mseg_on_jumbo(rxq); + return 0; free_rxq: @@ -878,6 +881,33 @@ nix_sqb_unlock(struct rte_mempool *mp) return 0; } +void +otx2_nix_enable_mseg_on_jumbo(struct otx2_eth_rxq *rxq) +{ + struct rte_pktmbuf_pool_private *mbp_priv; + struct rte_eth_dev *eth_dev; + struct otx2_eth_dev *dev; + uint32_t buffsz; + + eth_dev = rxq->eth_dev; + dev = otx2_eth_pmd_priv(eth_dev); + + /* Get rx buffer size */ + mbp_priv = rte_mempool_get_priv(rxq->pool); + buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM; + + if (eth_dev->data->dev_conf.rxmode.max_rx_pkt_len > buffsz) { + dev->rx_offloads |= DEV_RX_OFFLOAD_SCATTER; + dev->tx_offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; + + /* Setting up the rx[tx]_offload_flags due to change + * in rx[tx]_offloads. + */ + dev->rx_offload_flags |= nix_rx_offload_flags(eth_dev); + dev->tx_offload_flags |= nix_tx_offload_flags(eth_dev); + } +} + static int nix_sq_init(struct otx2_eth_txq *txq) { diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index a114112391..8e6e70d452 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -437,6 +437,8 @@ int otx2_nix_set_mc_addr_list(struct rte_eth_dev *eth_dev, /* MTU */ int otx2_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu); int otx2_nix_recalc_mtu(struct rte_eth_dev *eth_dev); +void otx2_nix_enable_mseg_on_jumbo(struct otx2_eth_rxq *rxq); + /* Link */ void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set); diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index faecf216c1..b36d37b9f7 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -72,22 +72,15 @@ otx2_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) int otx2_nix_recalc_mtu(struct rte_eth_dev *eth_dev) { - struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); struct rte_eth_dev_data *data = eth_dev->data; - struct rte_pktmbuf_pool_private *mbp_priv; struct otx2_eth_rxq *rxq; - uint32_t buffsz; uint16_t mtu; int rc; - /* Get rx buffer size */ rxq = data->rx_queues[0]; - mbp_priv = rte_mempool_get_priv(rxq->pool); - buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM; /* Setup scatter mode if needed by jumbo */ - if (data->dev_conf.rxmode.max_rx_pkt_len > buffsz) - dev->rx_offloads |= DEV_RX_OFFLOAD_SCATTER; + otx2_nix_enable_mseg_on_jumbo(rxq); /* Setup MTU based on max_rx_pkt_len */ mtu = data->dev_conf.rxmode.max_rx_pkt_len - NIX_L2_OVERHEAD;