Thread (36 messages) flat view 36 messages, 3 authors, 2021-01-25

RE: [EXT] Re: [PATCH v2 RFC net-next 13/18] net: mvpp2: add ethtool flow control configuration support

From: Stefan Chulski <hidden>
Date: 2021-01-24 12:41:13
Also in: lkml

----------------------------------------------------------------------
On Sun, Jan 24, 2021 at 01:44:02PM +0200, stefanc@marvell.com wrote:
quoted
@@ -6407,6 +6490,29 @@ static void mvpp2_mac_link_up(struct
phylink_config *config,
quoted
 			     val);
 	}

+	if (tx_pause && port->priv->global_tx_fc) {
+		port->tx_fc = true;
+		mvpp2_rxq_enable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port-
priv->bm_pools[i], true);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long,
true);
quoted
+			mvpp2_bm_pool_update_fc(port, port->pool_short,
true);
quoted
+		}
+
+	} else if (port->priv->global_tx_fc) {
+		port->tx_fc = false;
+		mvpp2_rxq_disable_fc(port);
+		if (port->priv->percpu_pools) {
+			for (i = 0; i < port->nrxqs; i++)
+				mvpp2_bm_pool_update_fc(port, &port-
priv->bm_pools[i], false);
+		} else {
+			mvpp2_bm_pool_update_fc(port, port->pool_long,
false);
quoted
+			mvpp2_bm_pool_update_fc(port, port->pool_short,
false);
quoted
+		}
+	}
+
It seems this can be written more succinctly:

	if (port->priv->global_tx_fc) {
		port->tx_fc = tx_pause;
		if (tx_pause)
			mvpp2_rxq_enable_fc(port);
		else
			mvpp2_rxq_disable_fc(port);
		if (port->priv->percpu_pools) {
			for (i = 0; i < port->nrxqs; i++)
				mvpp2_bm_pool_update_fc(port,
						&port->priv->bm_pools[i],
						tx_pause);
		} else {
			mvpp2_bm_pool_update_fc(port, port->pool_long,
						tx_pause);
			mvpp2_bm_pool_update_fc(port, port->pool_short,
						tx_pause);
		}
	}
Ok, I would update.

Thanks,
Stefan.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help