@@ -2605,9 +2605,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
26052605 priv -> tx_lpi_timer = STMMAC_DEFAULT_TWT_LS ;
26062606
26072607 if (priv -> use_riwt ) {
2608- ret = stmmac_rx_watchdog (priv , priv -> ioaddr , MIN_DMA_RIWT , rx_cnt );
2609- if (!ret )
2610- priv -> rx_riwt = MIN_DMA_RIWT ;
2608+ if (!priv -> rx_riwt )
2609+ priv -> rx_riwt = DEF_DMA_RIWT ;
2610+
2611+ ret = stmmac_rx_watchdog (priv , priv -> ioaddr , priv -> rx_riwt , rx_cnt );
26112612 }
26122613
26132614 if (priv -> hw -> pcs )
@@ -2915,16 +2916,17 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
29152916 struct stmmac_priv * priv = netdev_priv (dev );
29162917 int nfrags = skb_shinfo (skb )-> nr_frags ;
29172918 u32 queue = skb_get_queue_mapping (skb );
2919+ unsigned int first_entry , tx_packets ;
2920+ int tmp_pay_len = 0 , first_tx ;
29182921 struct stmmac_tx_queue * tx_q ;
2919- unsigned int first_entry ;
29202922 u8 proto_hdr_len , hdr ;
2921- int tmp_pay_len = 0 ;
2923+ bool has_vlan , set_ic ;
29222924 u32 pay_len , mss ;
29232925 dma_addr_t des ;
2924- bool has_vlan ;
29252926 int i ;
29262927
29272928 tx_q = & priv -> tx_queue [queue ];
2929+ first_tx = tx_q -> cur_tx ;
29282930
29292931 /* Compute header lengths */
29302932 if (skb_shinfo (skb )-> gso_type & SKB_GSO_UDP_L4 ) {
@@ -3032,16 +3034,27 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
30323034 tx_q -> tx_skbuff [tx_q -> cur_tx ] = skb ;
30333035
30343036 /* Manage tx mitigation */
3035- tx_q -> tx_count_frames += nfrags + 1 ;
3036- if (likely (priv -> tx_coal_frames > tx_q -> tx_count_frames ) &&
3037- !((skb_shinfo (skb )-> tx_flags & SKBTX_HW_TSTAMP ) &&
3038- priv -> hwts_tx_en )) {
3039- stmmac_tx_timer_arm (priv , queue );
3040- } else {
3037+ tx_packets = (tx_q -> cur_tx + 1 ) - first_tx ;
3038+ tx_q -> tx_count_frames += tx_packets ;
3039+
3040+ if ((skb_shinfo (skb )-> tx_flags & SKBTX_HW_TSTAMP ) && priv -> hwts_tx_en )
3041+ set_ic = true;
3042+ else if (!priv -> tx_coal_frames )
3043+ set_ic = false;
3044+ else if (tx_packets > priv -> tx_coal_frames )
3045+ set_ic = true;
3046+ else if ((tx_q -> tx_count_frames % priv -> tx_coal_frames ) < tx_packets )
3047+ set_ic = true;
3048+ else
3049+ set_ic = false;
3050+
3051+ if (set_ic ) {
30413052 desc = & tx_q -> dma_tx [tx_q -> cur_tx ];
30423053 tx_q -> tx_count_frames = 0 ;
30433054 stmmac_set_tx_ic (priv , desc );
30443055 priv -> xstats .tx_set_ic_bit ++ ;
3056+ } else {
3057+ stmmac_tx_timer_arm (priv , queue );
30453058 }
30463059
30473060 /* We've used all descriptors we need for this skb, however,
@@ -3132,6 +3145,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
31323145 */
31333146static netdev_tx_t stmmac_xmit (struct sk_buff * skb , struct net_device * dev )
31343147{
3148+ unsigned int first_entry , tx_packets , enh_desc ;
31353149 struct stmmac_priv * priv = netdev_priv (dev );
31363150 unsigned int nopaged_len = skb_headlen (skb );
31373151 int i , csum_insertion = 0 , is_jumbo = 0 ;
@@ -3140,13 +3154,12 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
31403154 int gso = skb_shinfo (skb )-> gso_type ;
31413155 struct dma_desc * desc , * first ;
31423156 struct stmmac_tx_queue * tx_q ;
3143- unsigned int first_entry ;
3144- unsigned int enh_desc ;
3157+ bool has_vlan , set_ic ;
3158+ int entry , first_tx ;
31453159 dma_addr_t des ;
3146- bool has_vlan ;
3147- int entry ;
31483160
31493161 tx_q = & priv -> tx_queue [queue ];
3162+ first_tx = tx_q -> cur_tx ;
31503163
31513164 if (priv -> tx_path_in_lpi_mode )
31523165 stmmac_disable_eee_mode (priv );
@@ -3240,12 +3253,21 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
32403253 * This approach takes care about the fragments: desc is the first
32413254 * element in case of no SG.
32423255 */
3243- tx_q -> tx_count_frames += nfrags + 1 ;
3244- if (likely (priv -> tx_coal_frames > tx_q -> tx_count_frames ) &&
3245- !((skb_shinfo (skb )-> tx_flags & SKBTX_HW_TSTAMP ) &&
3246- priv -> hwts_tx_en )) {
3247- stmmac_tx_timer_arm (priv , queue );
3248- } else {
3256+ tx_packets = (entry + 1 ) - first_tx ;
3257+ tx_q -> tx_count_frames += tx_packets ;
3258+
3259+ if ((skb_shinfo (skb )-> tx_flags & SKBTX_HW_TSTAMP ) && priv -> hwts_tx_en )
3260+ set_ic = true;
3261+ else if (!priv -> tx_coal_frames )
3262+ set_ic = false;
3263+ else if (tx_packets > priv -> tx_coal_frames )
3264+ set_ic = true;
3265+ else if ((tx_q -> tx_count_frames % priv -> tx_coal_frames ) < tx_packets )
3266+ set_ic = true;
3267+ else
3268+ set_ic = false;
3269+
3270+ if (set_ic ) {
32493271 if (likely (priv -> extend_desc ))
32503272 desc = & tx_q -> dma_etx [entry ].basic ;
32513273 else
@@ -3254,6 +3276,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
32543276 tx_q -> tx_count_frames = 0 ;
32553277 stmmac_set_tx_ic (priv , desc );
32563278 priv -> xstats .tx_set_ic_bit ++ ;
3279+ } else {
3280+ stmmac_tx_timer_arm (priv , queue );
32573281 }
32583282
32593283 /* We've used all descriptors we need for this skb, however,
@@ -3440,7 +3464,11 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
34403464 rx_q -> rx_count_frames += priv -> rx_coal_frames ;
34413465 if (rx_q -> rx_count_frames > priv -> rx_coal_frames )
34423466 rx_q -> rx_count_frames = 0 ;
3443- use_rx_wd = priv -> use_riwt && rx_q -> rx_count_frames ;
3467+
3468+ use_rx_wd = !priv -> rx_coal_frames ;
3469+ use_rx_wd |= rx_q -> rx_count_frames > 0 ;
3470+ if (!priv -> use_riwt )
3471+ use_rx_wd = false;
34443472
34453473 dma_wmb ();
34463474 stmmac_set_rx_owner (priv , p , use_rx_wd );
0 commit comments