xref: /linux/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.h (revision 91a4855d6c03e770e42f17c798a36a3c46e63de2)
10440e27eSJoe Damato /* SPDX-License-Identifier: GPL-2.0-or-later */
20440e27eSJoe Damato /*
30440e27eSJoe Damato  * Broadcom NetXtreme-C/E network driver.
40440e27eSJoe Damato  *
50440e27eSJoe Damato  * This program is free software; you can redistribute it and/or modify
60440e27eSJoe Damato  * it under the terms of the GNU General Public License as published by
70440e27eSJoe Damato  * the Free Software Foundation.
80440e27eSJoe Damato  */
90440e27eSJoe Damato 
100440e27eSJoe Damato #ifndef BNXT_GSO_H
110440e27eSJoe Damato #define BNXT_GSO_H
120440e27eSJoe Damato 
130440e27eSJoe Damato /* Maximum segments the stack may send in a single SW USO skb.
140440e27eSJoe Damato  * This caps gso_max_segs for NICs without HW USO support.
150440e27eSJoe Damato  */
160440e27eSJoe Damato #define BNXT_SW_USO_MAX_SEGS	64
170440e27eSJoe Damato 
180440e27eSJoe Damato /* Worst-case TX descriptors consumed by one SW USO packet:
190440e27eSJoe Damato  * Each segment: 1 long BD + 1 ext BD + payload BDs.
200440e27eSJoe Damato  * Total payload BDs across all segs <= num_segs + nr_frags (each frag
210440e27eSJoe Damato  * boundary crossing adds at most 1 extra BD).
220440e27eSJoe Damato  * So: 3 * max_segs + MAX_SKB_FRAGS + 1 = 3 * 64 + 17 + 1 = 210.
230440e27eSJoe Damato  */
240440e27eSJoe Damato #define BNXT_SW_USO_MAX_DESCS	(3 * BNXT_SW_USO_MAX_SEGS + MAX_SKB_FRAGS + 1)
250440e27eSJoe Damato 
26cc5d9066SJoe Damato static inline u16 bnxt_inline_avail(struct bnxt_tx_ring_info *txr)
27cc5d9066SJoe Damato {
28cc5d9066SJoe Damato 	return BNXT_SW_USO_MAX_SEGS -
29cc5d9066SJoe Damato 	       (u16)(txr->tx_inline_prod - READ_ONCE(txr->tx_inline_cons));
30cc5d9066SJoe Damato }
31cc5d9066SJoe Damato 
32*87550ba2SJoe Damato static inline int bnxt_min_tx_desc_cnt(struct bnxt *bp,
33*87550ba2SJoe Damato 				       netdev_features_t features)
34*87550ba2SJoe Damato {
35*87550ba2SJoe Damato 	if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP) &&
36*87550ba2SJoe Damato 	    (features & NETIF_F_GSO_UDP_L4))
37*87550ba2SJoe Damato 		return BNXT_SW_USO_MAX_DESCS;
38*87550ba2SJoe Damato 	return BNXT_MIN_TX_DESC_CNT;
39*87550ba2SJoe Damato }
40*87550ba2SJoe Damato 
410440e27eSJoe Damato netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
420440e27eSJoe Damato 				 struct bnxt_tx_ring_info *txr,
430440e27eSJoe Damato 				 struct netdev_queue *txq,
440440e27eSJoe Damato 				 struct sk_buff *skb);
450440e27eSJoe Damato 
460440e27eSJoe Damato #endif
47