Commit d429b66e authored by Jose Abreu's avatar Jose Abreu Committed by David S. Miller

net: stmmac: Implement RX Coalesce Frames setting

Add support for coalescing RX path by specifying number of frames which
don't need to have interrupt on completion bit set.

This is only available when RX Watchdog is enabled.
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 12479f62
...@@ -252,6 +252,7 @@ struct stmmac_safety_stats { ...@@ -252,6 +252,7 @@ struct stmmac_safety_stats {
#define STMMAC_MAX_COAL_TX_TICK 100000 #define STMMAC_MAX_COAL_TX_TICK 100000
#define STMMAC_TX_MAX_FRAMES 256 #define STMMAC_TX_MAX_FRAMES 256
#define STMMAC_TX_FRAMES 1 #define STMMAC_TX_FRAMES 1
#define STMMAC_RX_FRAMES 25
/* Packets types */ /* Packets types */
enum packets_types { enum packets_types {
......
...@@ -55,6 +55,7 @@ struct stmmac_tx_queue { ...@@ -55,6 +55,7 @@ struct stmmac_tx_queue {
}; };
struct stmmac_rx_queue { struct stmmac_rx_queue {
u32 rx_count_frames;
u32 queue_index; u32 queue_index;
struct stmmac_priv *priv_data; struct stmmac_priv *priv_data;
struct dma_extended_desc *dma_erx; struct dma_extended_desc *dma_erx;
...@@ -110,6 +111,7 @@ struct stmmac_priv { ...@@ -110,6 +111,7 @@ struct stmmac_priv {
/* Frequently used values are kept adjacent for cache effect */ /* Frequently used values are kept adjacent for cache effect */
u32 tx_coal_frames; u32 tx_coal_frames;
u32 tx_coal_timer; u32 tx_coal_timer;
u32 rx_coal_frames;
int tx_coalesce; int tx_coalesce;
int hwts_tx_en; int hwts_tx_en;
......
...@@ -701,8 +701,10 @@ static int stmmac_get_coalesce(struct net_device *dev, ...@@ -701,8 +701,10 @@ static int stmmac_get_coalesce(struct net_device *dev,
ec->tx_coalesce_usecs = priv->tx_coal_timer; ec->tx_coalesce_usecs = priv->tx_coal_timer;
ec->tx_max_coalesced_frames = priv->tx_coal_frames; ec->tx_max_coalesced_frames = priv->tx_coal_frames;
if (priv->use_riwt) if (priv->use_riwt) {
ec->rx_max_coalesced_frames = priv->rx_coal_frames;
ec->rx_coalesce_usecs = stmmac_riwt2usec(priv->rx_riwt, priv); ec->rx_coalesce_usecs = stmmac_riwt2usec(priv->rx_riwt, priv);
}
return 0; return 0;
} }
...@@ -715,7 +717,7 @@ static int stmmac_set_coalesce(struct net_device *dev, ...@@ -715,7 +717,7 @@ static int stmmac_set_coalesce(struct net_device *dev,
unsigned int rx_riwt; unsigned int rx_riwt;
/* Check not supported parameters */ /* Check not supported parameters */
if ((ec->rx_max_coalesced_frames) || (ec->rx_coalesce_usecs_irq) || if ((ec->rx_coalesce_usecs_irq) ||
(ec->rx_max_coalesced_frames_irq) || (ec->tx_coalesce_usecs_irq) || (ec->rx_max_coalesced_frames_irq) || (ec->tx_coalesce_usecs_irq) ||
(ec->use_adaptive_rx_coalesce) || (ec->use_adaptive_tx_coalesce) || (ec->use_adaptive_rx_coalesce) || (ec->use_adaptive_tx_coalesce) ||
(ec->pkt_rate_low) || (ec->rx_coalesce_usecs_low) || (ec->pkt_rate_low) || (ec->rx_coalesce_usecs_low) ||
...@@ -749,6 +751,7 @@ static int stmmac_set_coalesce(struct net_device *dev, ...@@ -749,6 +751,7 @@ static int stmmac_set_coalesce(struct net_device *dev,
/* Only copy relevant parameters, ignore all others. */ /* Only copy relevant parameters, ignore all others. */
priv->tx_coal_frames = ec->tx_max_coalesced_frames; priv->tx_coal_frames = ec->tx_max_coalesced_frames;
priv->tx_coal_timer = ec->tx_coalesce_usecs; priv->tx_coal_timer = ec->tx_coalesce_usecs;
priv->rx_coal_frames = ec->rx_max_coalesced_frames;
priv->rx_riwt = rx_riwt; priv->rx_riwt = rx_riwt;
stmmac_rx_watchdog(priv, priv->ioaddr, priv->rx_riwt, rx_cnt); stmmac_rx_watchdog(priv, priv->ioaddr, priv->rx_riwt, rx_cnt);
......
...@@ -2268,20 +2268,21 @@ static void stmmac_tx_timer(struct timer_list *t) ...@@ -2268,20 +2268,21 @@ static void stmmac_tx_timer(struct timer_list *t)
} }
/** /**
* stmmac_init_tx_coalesce - init tx mitigation options. * stmmac_init_coalesce - init mitigation options.
* @priv: driver private structure * @priv: driver private structure
* Description: * Description:
* This inits the transmit coalesce parameters: i.e. timer rate, * This inits the coalesce parameters: i.e. timer rate,
* timer handler and default threshold used for enabling the * timer handler and default threshold used for enabling the
* interrupt on completion bit. * interrupt on completion bit.
*/ */
static void stmmac_init_tx_coalesce(struct stmmac_priv *priv) static void stmmac_init_coalesce(struct stmmac_priv *priv)
{ {
u32 tx_channel_count = priv->plat->tx_queues_to_use; u32 tx_channel_count = priv->plat->tx_queues_to_use;
u32 chan; u32 chan;
priv->tx_coal_frames = STMMAC_TX_FRAMES; priv->tx_coal_frames = STMMAC_TX_FRAMES;
priv->tx_coal_timer = STMMAC_COAL_TX_TIMER; priv->tx_coal_timer = STMMAC_COAL_TX_TIMER;
priv->rx_coal_frames = STMMAC_RX_FRAMES;
for (chan = 0; chan < tx_channel_count; chan++) { for (chan = 0; chan < tx_channel_count; chan++) {
struct stmmac_tx_queue *tx_q = &priv->tx_queue[chan]; struct stmmac_tx_queue *tx_q = &priv->tx_queue[chan];
...@@ -2651,7 +2652,7 @@ static int stmmac_open(struct net_device *dev) ...@@ -2651,7 +2652,7 @@ static int stmmac_open(struct net_device *dev)
goto init_error; goto init_error;
} }
stmmac_init_tx_coalesce(priv); stmmac_init_coalesce(priv);
phylink_start(priv->phylink); phylink_start(priv->phylink);
...@@ -3289,6 +3290,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) ...@@ -3289,6 +3290,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
while (dirty-- > 0) { while (dirty-- > 0) {
struct dma_desc *p; struct dma_desc *p;
bool use_rx_wd;
if (priv->extend_desc) if (priv->extend_desc)
p = (struct dma_desc *)(rx_q->dma_erx + entry); p = (struct dma_desc *)(rx_q->dma_erx + entry);
...@@ -3331,7 +3333,11 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) ...@@ -3331,7 +3333,11 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
} }
dma_wmb(); dma_wmb();
stmmac_set_rx_owner(priv, p, priv->use_riwt); rx_q->rx_count_frames++;
rx_q->rx_count_frames %= priv->rx_coal_frames;
use_rx_wd = priv->use_riwt && rx_q->rx_count_frames;
stmmac_set_rx_owner(priv, p, use_rx_wd);
dma_wmb(); dma_wmb();
...@@ -4631,7 +4637,7 @@ int stmmac_resume(struct device *dev) ...@@ -4631,7 +4637,7 @@ int stmmac_resume(struct device *dev)
stmmac_clear_descriptors(priv); stmmac_clear_descriptors(priv);
stmmac_hw_setup(ndev, false); stmmac_hw_setup(ndev, false);
stmmac_init_tx_coalesce(priv); stmmac_init_coalesce(priv);
stmmac_set_rx_mode(ndev); stmmac_set_rx_mode(ndev);
stmmac_enable_all_queues(priv); stmmac_enable_all_queues(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment