mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 10:41:49 +02:00
net: rswitch: Use common defines for time stamping control
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>
This commit is contained in:
parent
50ab1c6bec
commit
b314e4f7a9
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user