]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: rswitch: Use common defines for time stamping control
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tue, 4 Nov 2025 22:24:16 +0000 (23:24 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 7 Nov 2025 01:38:25 +0000 (17:38 -0800)
Instead of translating to/from driver specific flags for packet time
stamp control use the common flags directly. This simplifies the driver
as the translating code can be removed while at the same time making it
clear the flags are not flags written to hardware registers.

One thing to note is that the bit-wise and check in rswitch_rx() of
RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT is replaced with a not set check of
HWTSTAMP_FILTER_NONE. This is okay as the bit of device specific event
replaced was set for all modes except HWTSTAMP_FILTER_NONE.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://patch.msgid.link/20251104222420.882731-4-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/renesas/rswitch.h
drivers/net/ethernet/renesas/rswitch_main.c

index 3b348ebf6742b52b3423d3886a90a83ed0a45b41..aa605304fed051df81d695accc52871449352074 100644 (file)
@@ -1064,8 +1064,8 @@ struct rswitch_private {
        bool gwca_halt;
        struct net_device *offload_brdev;
 
-       u32 tstamp_tx_ctrl;
-       u32 tstamp_rx_ctrl;
+       enum hwtstamp_tx_types tstamp_tx_ctrl;
+       enum hwtstamp_rx_filters tstamp_rx_ctrl;
 };
 
 bool is_rdev(const struct net_device *ndev);
index 31aabc6fc462dd42aad39c14ead12780e482f441..e14b21148f27a54430a7313861505ce4c2b5df38 100644 (file)
@@ -845,7 +845,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
                if (!skb)
                        goto out;
 
-               get_ts = rdev->priv->tstamp_rx_ctrl & RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT;
+               get_ts = rdev->priv->tstamp_rx_ctrl != HWTSTAMP_FILTER_NONE;
                if (get_ts) {
                        struct skb_shared_hwtstamps *shhwtstamps;
                        struct timespec64 ts;
@@ -1802,20 +1802,8 @@ static int rswitch_hwstamp_get(struct net_device *ndev,
        struct rswitch_private *priv = rdev->priv;
 
        config->flags = 0;
-       config->tx_type =
-               priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
-
-       switch (priv->tstamp_rx_ctrl & RCAR_GEN4_RXTSTAMP_TYPE) {
-       case RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT:
-               config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
-               break;
-       case RCAR_GEN4_RXTSTAMP_TYPE_ALL:
-               config->rx_filter = HWTSTAMP_FILTER_ALL;
-               break;
-       default:
-               config->rx_filter = HWTSTAMP_FILTER_NONE;
-               break;
-       }
+       config->tx_type = priv->tstamp_tx_ctrl;
+       config->rx_filter = priv->tstamp_rx_ctrl;
 
        return 0;
 }
@@ -1825,18 +1813,16 @@ static int rswitch_hwstamp_set(struct net_device *ndev,
                               struct netlink_ext_ack *extack)
 {
        struct rswitch_device *rdev = netdev_priv(ndev);
-       u32 tstamp_rx_ctrl = RCAR_GEN4_RXTSTAMP_ENABLED;
-       u32 tstamp_tx_ctrl;
+       enum hwtstamp_rx_filters tstamp_rx_ctrl;
+       enum hwtstamp_tx_types tstamp_tx_ctrl;
 
        if (config->flags)
                return -EINVAL;
 
        switch (config->tx_type) {
        case HWTSTAMP_TX_OFF:
-               tstamp_tx_ctrl = 0;
-               break;
        case HWTSTAMP_TX_ON:
-               tstamp_tx_ctrl = RCAR_GEN4_TXTSTAMP_ENABLED;
+               tstamp_tx_ctrl = config->tx_type;
                break;
        default:
                return -ERANGE;
@@ -1844,14 +1830,12 @@ static int rswitch_hwstamp_set(struct net_device *ndev,
 
        switch (config->rx_filter) {
        case HWTSTAMP_FILTER_NONE:
-               tstamp_rx_ctrl = 0;
-               break;
        case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
-               tstamp_rx_ctrl |= RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT;
+               tstamp_rx_ctrl = config->rx_filter;
                break;
        default:
                config->rx_filter = HWTSTAMP_FILTER_ALL;
-               tstamp_rx_ctrl |= RCAR_GEN4_RXTSTAMP_TYPE_ALL;
+               tstamp_rx_ctrl = HWTSTAMP_FILTER_ALL;
                break;
        }