Skip to content

Commit 97085cd

Browse files
brettcreeleydavem330
authored andcommitted
ionic: Shorten a Tx hotpath
Perf was showing some hot spots in ionic_tx_descs_needed() for TSO traffic. Rework the function to return sooner where possible. Signed-off-by: Brett Creeley <[email protected]> Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4d14040 commit 97085cd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/ethernet/pensando/ionic/ionic_txrx.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
16691669

16701670
static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
16711671
{
1672-
struct ionic_tx_stats *stats = q_to_tx_stats(q);
1672+
int nr_frags = skb_shinfo(skb)->nr_frags;
16731673
bool too_many_frags = false;
16741674
skb_frag_t *frag;
16751675
int desc_bufs;
@@ -1685,17 +1685,20 @@ static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
16851685
/* Each desc is mss long max, so a descriptor for each gso_seg */
16861686
if (skb_is_gso(skb)) {
16871687
ndescs = skb_shinfo(skb)->gso_segs;
1688+
if (!nr_frags)
1689+
return ndescs;
16881690
} else {
16891691
ndescs = 1;
1690-
if (skb_shinfo(skb)->nr_frags > q->max_sg_elems) {
1692+
if (!nr_frags)
1693+
return ndescs;
1694+
1695+
if (unlikely(nr_frags > q->max_sg_elems)) {
16911696
too_many_frags = true;
16921697
goto linearize;
16931698
}
1694-
}
16951699

1696-
/* If non-TSO, or no frags to check, we're done */
1697-
if (!skb_is_gso(skb) || !skb_shinfo(skb)->nr_frags)
16981700
return ndescs;
1701+
}
16991702

17001703
/* We need to scan the skb to be sure that none of the MTU sized
17011704
* packets in the TSO will require more sgs per descriptor than we
@@ -1743,6 +1746,8 @@ static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb)
17431746

17441747
linearize:
17451748
if (too_many_frags) {
1749+
struct ionic_tx_stats *stats = q_to_tx_stats(q);
1750+
17461751
err = skb_linearize(skb);
17471752
if (err)
17481753
return err;

0 commit comments

Comments
 (0)