]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dpaa2-eth: Add helper functions
authorIoana Radulescu <ruxandra.radulescu@nxp.com>
Sat, 30 May 2020 21:08:10 +0000 (00:08 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Jun 2020 19:04:32 +0000 (12:04 -0700)
Add convenient helper functions that determines whether Rx/Tx pause
frames are enabled based on link state flags received from firmware.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c

index 3bf5df92ecfa8764d3c77f5ac8900bb5fdff40d5..c16c8ea3a174a7abdc72fbe3714790b30657caaa 100644 (file)
@@ -1333,8 +1333,7 @@ static int link_state_update(struct dpaa2_eth_priv *priv)
         * Rx FQ taildrop configuration as well. We configure taildrop
         * only when pause frame generation is disabled.
         */
-       tx_pause = !!(state.options & DPNI_LINK_OPT_PAUSE) ^
-                  !!(state.options & DPNI_LINK_OPT_ASYM_PAUSE);
+       tx_pause = dpaa2_eth_tx_pause_enabled(state.options);
        dpaa2_eth_set_rx_taildrop(priv, !tx_pause);
 
        /* When we manage the MAC/PHY using phylink there is no need
index 7856f69bcf362882b7544585d9681cf8acfef7f3..6384f6a23349b485e8e0b68f62e9b7918ccaab6a 100644 (file)
@@ -510,6 +510,17 @@ enum dpaa2_eth_rx_dist {
        (dpaa2_eth_cmp_dpni_ver((priv), DPNI_PAUSE_VER_MAJOR,   \
                                DPNI_PAUSE_VER_MINOR) >= 0)
 
+static inline bool dpaa2_eth_tx_pause_enabled(u64 link_options)
+{
+       return !!(link_options & DPNI_LINK_OPT_PAUSE) ^
+              !!(link_options & DPNI_LINK_OPT_ASYM_PAUSE);
+}
+
+static inline bool dpaa2_eth_rx_pause_enabled(u64 link_options)
+{
+       return !!(link_options & DPNI_LINK_OPT_PAUSE);
+}
+
 static inline
 unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
                                       struct sk_buff *skb)
index 8bf169783bea772982d7858f1c2b286321eb16e3..e88269fe3de7f3ece19062b06fcf782db96dbb4f 100644 (file)
@@ -130,9 +130,8 @@ static void dpaa2_eth_get_pauseparam(struct net_device *net_dev,
                return;
        }
 
-       pause->rx_pause = !!(link_options & DPNI_LINK_OPT_PAUSE);
-       pause->tx_pause = pause->rx_pause ^
-                         !!(link_options & DPNI_LINK_OPT_ASYM_PAUSE);
+       pause->rx_pause = dpaa2_eth_rx_pause_enabled(link_options);
+       pause->tx_pause = dpaa2_eth_tx_pause_enabled(link_options);
        pause->autoneg = AUTONEG_DISABLE;
 }