xref: /linux/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.h (revision 91a4855d6c03e770e42f17c798a36a3c46e63de2)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Broadcom NetXtreme-C/E network driver.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation.
8  */
9 
10 #ifndef BNXT_GSO_H
11 #define BNXT_GSO_H
12 
13 /* Maximum segments the stack may send in a single SW USO skb.
14  * This caps gso_max_segs for NICs without HW USO support.
15  */
16 #define BNXT_SW_USO_MAX_SEGS	64
17 
18 /* Worst-case TX descriptors consumed by one SW USO packet:
19  * Each segment: 1 long BD + 1 ext BD + payload BDs.
20  * Total payload BDs across all segs <= num_segs + nr_frags (each frag
21  * boundary crossing adds at most 1 extra BD).
22  * So: 3 * max_segs + MAX_SKB_FRAGS + 1 = 3 * 64 + 17 + 1 = 210.
23  */
24 #define BNXT_SW_USO_MAX_DESCS	(3 * BNXT_SW_USO_MAX_SEGS + MAX_SKB_FRAGS + 1)
25 
26 static inline u16 bnxt_inline_avail(struct bnxt_tx_ring_info *txr)
27 {
28 	return BNXT_SW_USO_MAX_SEGS -
29 	       (u16)(txr->tx_inline_prod - READ_ONCE(txr->tx_inline_cons));
30 }
31 
32 static inline int bnxt_min_tx_desc_cnt(struct bnxt *bp,
33 				       netdev_features_t features)
34 {
35 	if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP) &&
36 	    (features & NETIF_F_GSO_UDP_L4))
37 		return BNXT_SW_USO_MAX_DESCS;
38 	return BNXT_MIN_TX_DESC_CNT;
39 }
40 
41 netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
42 				 struct bnxt_tx_ring_info *txr,
43 				 struct netdev_queue *txq,
44 				 struct sk_buff *skb);
45 
46 #endif
47