Re: [PATCH v8 net-next 2/3] netdevsim: Implement basic ptp support
Vadim Fedorenko <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
On 12.08.2026 19:37, Maciek Machnikowski wrote: > Add support for virtual timestamping inside the netdevsim driver. > The implementation uses two attached ptp_mock clocks, reads the timestamps > of the ones attached either to the netdevsim or its peer and returns > timestamps using standard timestamps APIs. > > This implementation enables running ptp4l on netdevsim adapters and > introduces a new ptp selftest. > > Co-developed-by: Milena Olech <[email protected]> > Signed-off-by: Milena Olech <[email protected]> > Signed-off-by: Maciek Machnikowski <[email protected]> [...] > > +static int nsim_set_ts_config(struct net_device *netdev, > + struct kernel_hwtstamp_config *config, > + struct netlink_ext_ack *extack) > +{ > + struct netdevsim *ns = netdev_priv(netdev); > + int rx_filter; > + > + if (!ns->phc) > + return -EOPNOTSUPP; > + > + switch (config->tx_type) { > + case HWTSTAMP_TX_OFF: > + WRITE_ONCE(ns->tstamp_config.tx_type, HWTSTAMP_TX_OFF); > + break; > + case HWTSTAMP_TX_ON: > + WRITE_ONCE(ns->tstamp_config.tx_type, HWTSTAMP_TX_ON); > + break; > + default: > + return -ERANGE; > + } > + > + switch (config->rx_filter) { > + case HWTSTAMP_FILTER_NONE: > + rx_filter = HWTSTAMP_FILTER_NONE; > + break; > + case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: > + case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: > + case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: > + case HWTSTAMP_FILTER_PTP_V2_EVENT: > + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: > + case HWTSTAMP_FILTER_PTP_V2_SYNC: > + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: > + case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: > + case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: > + case HWTSTAMP_FILTER_NTP_ALL: > + case HWTSTAMP_FILTER_ALL: > + rx_filter = HWTSTAMP_FILTER_ALL; > + break; > + default: > + return -ERANGE; > + } nit: technically, you can make sashiko silent in this case by simply swapping switch statments order :) Reviewed-by: Vadim Fedorenko <[email protected]>