Skip to content

Commit

Permalink
net/ice: fix Tx preparation
Browse files Browse the repository at this point in the history
[ upstream commit 2f13ba5333b06589ba0e0e307dadcfaa95daf3dc ]

1. Check nb_segs > 8 for NO TSO case
2. Check nb_segs > Tx ring size for TSO case
3. report nb_mtu_seg_max and nb_seg_max in dev_info.

Fixes: 17c7d0f ("net/ice: support basic Rx/Tx")

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
  • Loading branch information
qzhan16 authored and bluca committed Nov 8, 2023
1 parent f2d7828 commit 632656a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ice/ice_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3718,6 +3718,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
.nb_max = ICE_MAX_RING_DESC,
.nb_min = ICE_MIN_RING_DESC,
.nb_align = ICE_ALIGN_RING_DESC,
.nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
.nb_seg_max = ICE_MAX_RING_DESC,
};

dev_info->speed_capa = ETH_LINK_SPEED_10M |
Expand Down
18 changes: 16 additions & 2 deletions drivers/net/ice/ice_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,7 @@ ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
}

uint16_t
ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
{
int i, ret;
Expand All @@ -3238,9 +3238,23 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
m = tx_pkts[i];
ol_flags = m->ol_flags;

if (ol_flags & PKT_TX_TCP_SEG &&
if (!(ol_flags & PKT_TX_TCP_SEG) &&
/**
* No TSO case: nb->segs, pkt_len to not exceed
* the limites.
*/
(m->nb_segs > ICE_TX_MTU_SEG_MAX ||
m->pkt_len > ICE_FRAME_SIZE_MAX)) {
rte_errno = EINVAL;
return i;
} else if (ol_flags & PKT_TX_TCP_SEG &&
/** TSO case: tso_segsz, nb_segs, pkt_len not exceed
* the limits.
*/
(m->tso_segsz < ICE_MIN_TSO_MSS ||
m->tso_segsz > ICE_MAX_TSO_MSS ||
m->nb_segs >
((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
/**
* MSS outside the range are considered malicious
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ice/ice_rxtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
/* Max data buffer size must be 16K - 128 bytes */
#define ICE_RX_MAX_DATA_BUF_SIZE (16 * 1024 - 128)

#define ICE_TX_MTU_SEG_MAX 8

typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
Expand Down

0 comments on commit 632656a

Please sign in to comment.