RE: [PATCH 3/3] net/mlx4_en: Add HW timestamping (TS) support
From: Yevgeny Petrilin <hidden>
Date: 2012-09-28 14:10:39
quoted
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index edd9cb8..10fa453 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c@@ -1517,6 +1517,60 @@ static int mlx4_en_change_mtu(struct net_device*dev, int new_mtu)quoted
return 0; } +static int mlx4_en_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + struct hwtstamp_config config; + + if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) + return -EFAULT; + + /* reserved for future extensions */ + if (config.flags) + return -EINVAL; + + /* device doesn't support time stamping */ + if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS_EN)) + return -EINVAL; + + /* TX HW timestamp */ + switch (config.tx_type) { + case HWTSTAMP_TX_OFF: + case HWTSTAMP_TX_ON: + break; + default: + return -ERANGE; + } + + /* RX HW timestamp */ + switch (config.rx_filter) { + case HWTSTAMP_FILTER_NONE: + case HWTSTAMP_FILTER_ALL: + break; + default:Instead of rejecting the HWTSTAMP_FILTER_PTP_ codes out of hand, you should just accept them, and return by promoting rx_filter to HWTSTAMP_FILTER_ALL. [ See Documentation/networking/timestamping.txt ]quoted
+ return -ERANGE; + } + + if (mlx4_en_timestamp_config(dev, config.tx_type, config.rx_filter)) { + config.tx_type = HWTSTAMP_TX_OFF; + config.rx_filter = HWTSTAMP_FILTER_NONE; + } + + return copy_to_user(ifr->ifr_data, &config, + sizeof(config)) ? -EFAULT : 0; +}...quoted
@@ -363,6 +368,9 @@ struct mlx4_en_dev { u32 priv_pdn; spinlock_t uar_lock; u8 mac_removed[MLX4_MAX_PORTS + 1]; + struct cyclecounter cycles; + struct timecounter clock; + struct timecompare compare;I am working on a patch to remove the timecompare stuff altogether (after removing it from blackfin). It is and was a bad idea, I would hate to see new drivers using it. I strongly recommend just offering raw hardware time stamps in nanosecond resolution. Also, why not expose your device as a PTP Hardware Clock? Thanks, Richard
Hello Richard, Thanks for your feedback, Will address all your comments in V1 of this patchset. Thanks, Yevgeny