Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 603d10ef authored by Suraj Jaiswal's avatar Suraj Jaiswal Committed by Gerrit - the friendly Code Review server
Browse files

net: stmmac: Support eth type based TX intr moderation



Support eth type based TX intr moderation.

Change-Id: Ib1cb5364914092d0fdddef1cd5cfa7d4007bd7df
Signed-off-by: default avatarSuraj Jaiswal <jsuraj@codeaurora.org>
parent e1e04827
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1092,6 +1092,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
	plat_dat->bsp_priv = ethqos;
	plat_dat->fix_mac_speed = ethqos_fix_mac_speed;
	plat_dat->tx_select_queue = dwmac_qcom_select_queue;
	plat_dat->get_plat_tx_coal_frames =  dwmac_qcom_get_plat_tx_coal_frames;
	plat_dat->has_gmac4 = 1;
	plat_dat->pmt = 1;
	plat_dat->tso_en = of_property_read_bool(np, "snps,tso");
+1 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ struct stmmac_priv {
	u32 tx_coal_frames;
	u32 tx_coal_timer;
	u32 rx_coal_frames;
	bool tx_coal_timer_disable;

	int tx_coalesce;
	int hwts_tx_en;
+68 −25
Original line number Diff line number Diff line
@@ -1976,6 +1976,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
	}
	tx_q->dirty_tx = entry;

	if (!priv->tx_coal_timer_disable)
		netdev_tx_completed_queue(netdev_get_tx_queue(priv->dev, queue),
					  pkts_compl, bytes_compl);

@@ -1993,9 +1994,14 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
		mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(eee_timer));
	}

	/* We still have pending packets, let's call for a new scheduling */
	if (!priv->tx_coal_timer_disable) {
		/**
		 * We still have pending packets,
		 * let's call for a new scheduling
		 */
		if (tx_q->dirty_tx != tx_q->cur_tx)
			mod_timer(&tx_q->txtimer, STMMAC_COAL_TIMER(10));
	}

	__netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue));

@@ -2737,7 +2743,10 @@ static int stmmac_open(struct net_device *dev)
		goto init_error;
	}

	if (!priv->tx_coal_timer_disable)
		stmmac_init_coalesce(priv);
	else
		priv->rx_coal_frames = STMMAC_RX_FRAMES;

	phylink_start(priv->phylink);

@@ -2787,10 +2796,10 @@ static int stmmac_open(struct net_device *dev)
	free_irq(dev->irq, dev);
irq_error:
	phylink_stop(priv->phylink);

	if (!priv->tx_coal_timer_disable) {
		for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
			del_timer_sync(&priv->tx_queue[chan].txtimer);

	}
	stmmac_hw_teardown(dev);
init_error:
	free_dma_desc_resources(priv);
@@ -2821,8 +2830,10 @@ static int stmmac_release(struct net_device *dev)

	stmmac_disable_all_queues(priv);

	if (!priv->tx_coal_timer_disable) {
		for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
			del_timer_sync(&priv->tx_queue[chan].txtimer);
	}

	/* Free the IRQ lines */
	free_irq(dev->irq, dev);
@@ -3065,6 +3076,11 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)

	/* Manage tx mitigation */
	tx_q->tx_count_frames += nfrags + 1;
	if (likely(priv->tx_coal_timer_disable)) {
		tx_q->tx_count_frames = 0;
		stmmac_set_tx_ic(priv, desc);
		priv->xstats.tx_set_ic_bit++;
	} else {
		if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) &&
		    !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
			priv->hwts_tx_en)) {
@@ -3075,6 +3091,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
		stmmac_set_tx_ic(priv, desc);
		priv->xstats.tx_set_ic_bit++;
	}
	}

	/* We've used all descriptors we need for this skb, however,
	 * advance cur_tx so that it references a fresh descriptor.
@@ -3140,10 +3157,12 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
		print_pkt(skb->data, skb_headlen(skb));
	}

	if (!priv->tx_coal_timer_disable)
		netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);

	tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
	stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
	if (!priv->tx_coal_timer_disable)
		stmmac_tx_timer_arm(priv, queue);

	return NETDEV_TX_OK;
@@ -3177,6 +3196,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
	dma_addr_t des;
	bool has_vlan;
	int entry;
	unsigned int int_mod;

	tx_q = &priv->tx_queue[queue];

@@ -3271,6 +3291,17 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
	 * element in case of no SG.
	 */
	tx_q->tx_count_frames += nfrags + 1;
	if (likely(priv->tx_coal_timer_disable)) {
		if (priv->plat->get_plat_tx_coal_frames) {
			int_mod = priv->plat->get_plat_tx_coal_frames(skb);

			if (!(tx_q->cur_tx % int_mod)) {
				tx_q->tx_count_frames = 0;
				stmmac_set_tx_ic(priv, desc);
				priv->xstats.tx_set_ic_bit++;
			}
		}
	} else {
		if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) &&
		    !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
		    priv->hwts_tx_en)) {
@@ -3285,6 +3316,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
		stmmac_set_tx_ic(priv, desc);
		priv->xstats.tx_set_ic_bit++;
	}
	}

	/* We've used all descriptors we need for this skb, however,
	 * advance cur_tx so that it references a fresh descriptor.
@@ -3367,12 +3399,14 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
	 */
	wmb();

	if (!priv->tx_coal_timer_disable)
		netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);

	stmmac_enable_dma_transmission(priv, priv->ioaddr);

	tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
	stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
	if (!priv->tx_coal_timer_disable)
		stmmac_tx_timer_arm(priv, queue);

	return NETDEV_TX_OK;
@@ -4722,6 +4756,10 @@ int stmmac_dvr_probe(struct device *device,
		goto error_netdev_register;
	}

	/* Disable tx_coal_timer if plat provides callback */
	priv->tx_coal_timer_disable =
		plat_dat->get_plat_tx_coal_frames ? true : false;

#ifdef CONFIG_DEBUG_FS
	stmmac_init_fs(ndev);
#endif
@@ -4924,7 +4962,12 @@ int stmmac_resume(struct device *dev)
	stmmac_clear_descriptors(priv);

	stmmac_hw_setup(ndev, false);

	if (!priv->tx_coal_timer_disable)
		stmmac_init_coalesce(priv);
	else
		priv->rx_coal_frames = STMMAC_RX_FRAMES;

	stmmac_set_rx_mode(ndev);

	stmmac_enable_all_queues(priv);