]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: spectrum: PTP: Support ethtool get_ts_info
authorPetr Machata <petrm@mellanox.com>
Sun, 30 Jun 2019 06:05:00 +0000 (09:05 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jul 2019 01:58:35 +0000 (18:58 -0700)
The get_ts_info callback is used for obtaining information about
timestamping capabilities of a network device. On Spectrum-1, implement
it to advertise the PHC and the capability to do HW timestamping, and
the supported RX and TX filters.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.h

index aeb6462f4d626a1e14afe04705dbb4ef6669e680..755b14b82c8f01533363c79f2fdff0fd4f6a3071 100644 (file)
@@ -171,6 +171,8 @@ struct mlxsw_sp_ptp_ops {
                            struct hwtstamp_config *config);
        int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port,
                            struct hwtstamp_config *config);
+       int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp,
+                          struct ethtool_ts_info *info);
 };
 
 static int mlxsw_sp_component_query(struct mlxfw_dev *mlxfw_dev,
@@ -3316,6 +3318,15 @@ static int mlxsw_sp_get_module_eeprom(struct net_device *netdev,
        return err;
 }
 
+static int
+mlxsw_sp_get_ts_info(struct net_device *netdev, struct ethtool_ts_info *info)
+{
+       struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev);
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+
+       return mlxsw_sp->ptp_ops->get_ts_info(mlxsw_sp, info);
+}
+
 static const struct ethtool_ops mlxsw_sp_port_ethtool_ops = {
        .get_drvinfo            = mlxsw_sp_port_get_drvinfo,
        .get_link               = ethtool_op_get_link,
@@ -3329,6 +3340,7 @@ static const struct ethtool_ops mlxsw_sp_port_ethtool_ops = {
        .set_link_ksettings     = mlxsw_sp_port_set_link_ksettings,
        .get_module_info        = mlxsw_sp_get_module_info,
        .get_module_eeprom      = mlxsw_sp_get_module_eeprom,
+       .get_ts_info            = mlxsw_sp_get_ts_info,
 };
 
 static int
@@ -4547,6 +4559,7 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp1_ptp_ops = {
        .transmitted    = mlxsw_sp1_ptp_transmitted,
        .hwtstamp_get   = mlxsw_sp1_ptp_hwtstamp_get,
        .hwtstamp_set   = mlxsw_sp1_ptp_hwtstamp_set,
+       .get_ts_info    = mlxsw_sp1_ptp_get_ts_info,
 };
 
 static const struct mlxsw_sp_ptp_ops mlxsw_sp2_ptp_ops = {
@@ -4558,6 +4571,7 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp2_ptp_ops = {
        .transmitted    = mlxsw_sp2_ptp_transmitted,
        .hwtstamp_get   = mlxsw_sp2_ptp_hwtstamp_get,
        .hwtstamp_set   = mlxsw_sp2_ptp_hwtstamp_set,
+       .get_ts_info    = mlxsw_sp2_ptp_get_ts_info,
 };
 
 static int mlxsw_sp_netdevice_event(struct notifier_block *unused,
index 950ee489c2229b3d5b2a0b612261b85a9d7a0296..7d42f86237cd19d2e756d364e6a80e9c238a1e39 100644 (file)
@@ -933,3 +933,21 @@ int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
 
        return 0;
 }
+
+int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
+                             struct ethtool_ts_info *info)
+{
+       info->phc_index = ptp_clock_index(mlxsw_sp->clock->ptp);
+
+       info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
+                               SOF_TIMESTAMPING_RX_HARDWARE |
+                               SOF_TIMESTAMPING_RAW_HARDWARE;
+
+       info->tx_types = BIT(HWTSTAMP_TX_OFF) |
+                        BIT(HWTSTAMP_TX_ON);
+
+       info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
+                          BIT(HWTSTAMP_FILTER_ALL);
+
+       return 0;
+}
index 27b4fa8e361d667d0503571985f4112c4f35d8de..b23abfc0bd76f037fb0118f3b034ca27101922dc 100644 (file)
@@ -18,6 +18,14 @@ enum {
        MLXSW_SP_PTP_MESSAGE_TYPE_PDELAY_RESP,
 };
 
+static inline int mlxsw_sp_ptp_get_ts_info_noptp(struct ethtool_ts_info *info)
+{
+       info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
+                               SOF_TIMESTAMPING_SOFTWARE;
+       info->phc_index = -1;
+       return 0;
+}
+
 #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
 
 struct mlxsw_sp_ptp_clock *
@@ -46,6 +54,9 @@ int mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
 int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
                               struct hwtstamp_config *config);
 
+int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
+                             struct ethtool_ts_info *info);
+
 #else
 
 static inline struct mlxsw_sp_ptp_clock *
@@ -102,6 +113,12 @@ mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
        return -EOPNOTSUPP;
 }
 
+static inline int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
+                                           struct ethtool_ts_info *info)
+{
+       return mlxsw_sp_ptp_get_ts_info_noptp(info);
+}
+
 #endif
 
 static inline struct mlxsw_sp_ptp_clock *
@@ -150,4 +167,10 @@ mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
        return -EOPNOTSUPP;
 }
 
+static inline int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
+                                           struct ethtool_ts_info *info)
+{
+       return mlxsw_sp_ptp_get_ts_info_noptp(info);
+}
+
 #endif