Commit 5ab500d6 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'sfc-implement-ndo_hwtstamp_-get-set'

Alex Austin says:

====================
sfc: Implement ndo_hwtstamp_(get|set)

Implement ndo_hwtstamp_get and ndo_hwtstamp_set for sfc and sfc-siena.
====================

Link: https://lore.kernel.org/r/20231130135826.19018-1-alex.austin@amd.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents fb70136d d82afc80
...@@ -3706,13 +3706,13 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en, ...@@ -3706,13 +3706,13 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
} }
static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx, static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx,
struct hwtstamp_config *init) struct kernel_hwtstamp_config *init)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx, static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
struct hwtstamp_config *init) struct kernel_hwtstamp_config *init)
{ {
int rc; int rc;
......
...@@ -495,11 +495,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) ...@@ -495,11 +495,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
struct efx_nic *efx = efx_netdev_priv(net_dev); struct efx_nic *efx = efx_netdev_priv(net_dev);
struct mii_ioctl_data *data = if_mii(ifr); struct mii_ioctl_data *data = if_mii(ifr);
if (cmd == SIOCSHWTSTAMP)
return efx_ptp_set_ts_config(efx, ifr);
if (cmd == SIOCGHWTSTAMP)
return efx_ptp_get_ts_config(efx, ifr);
/* Convert phy_id from older PRTAD/DEVAD format */ /* Convert phy_id from older PRTAD/DEVAD format */
if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) && if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
(data->phy_id & 0xfc00) == 0x0400) (data->phy_id & 0xfc00) == 0x0400)
...@@ -581,6 +576,23 @@ static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vi ...@@ -581,6 +576,23 @@ static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vi
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int efx_hwtstamp_set(struct net_device *net_dev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
{
struct efx_nic *efx = efx_netdev_priv(net_dev);
return efx_ptp_set_ts_config(efx, config, extack);
}
static int efx_hwtstamp_get(struct net_device *net_dev,
struct kernel_hwtstamp_config *config)
{
struct efx_nic *efx = efx_netdev_priv(net_dev);
return efx_ptp_get_ts_config(efx, config);
}
static const struct net_device_ops efx_netdev_ops = { static const struct net_device_ops efx_netdev_ops = {
.ndo_open = efx_net_open, .ndo_open = efx_net_open,
.ndo_stop = efx_net_stop, .ndo_stop = efx_net_stop,
...@@ -596,6 +608,8 @@ static const struct net_device_ops efx_netdev_ops = { ...@@ -596,6 +608,8 @@ static const struct net_device_ops efx_netdev_ops = {
.ndo_features_check = efx_features_check, .ndo_features_check = efx_features_check,
.ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid, .ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid, .ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
.ndo_hwtstamp_set = efx_hwtstamp_set,
.ndo_hwtstamp_get = efx_hwtstamp_get,
#ifdef CONFIG_SFC_SRIOV #ifdef CONFIG_SFC_SRIOV
.ndo_set_vf_mac = efx_sriov_set_vf_mac, .ndo_set_vf_mac = efx_sriov_set_vf_mac,
.ndo_set_vf_vlan = efx_sriov_set_vf_vlan, .ndo_set_vf_vlan = efx_sriov_set_vf_vlan,
......
...@@ -1473,7 +1473,7 @@ struct efx_nic_type { ...@@ -1473,7 +1473,7 @@ struct efx_nic_type {
void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time); void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp); int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
int (*ptp_set_ts_config)(struct efx_nic *efx, int (*ptp_set_ts_config)(struct efx_nic *efx,
struct hwtstamp_config *init); struct kernel_hwtstamp_config *init);
int (*sriov_configure)(struct efx_nic *efx, int num_vfs); int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid); int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid); int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
......
...@@ -301,7 +301,7 @@ struct efx_ptp_data { ...@@ -301,7 +301,7 @@ struct efx_ptp_data {
bool reset_required; bool reset_required;
struct list_head rxfilters_mcast; struct list_head rxfilters_mcast;
struct list_head rxfilters_ucast; struct list_head rxfilters_ucast;
struct hwtstamp_config config; struct kernel_hwtstamp_config config;
bool enabled; bool enabled;
unsigned int mode; unsigned int mode;
void (*ns_to_nic_time)(s64 ns, u32 *nic_major, u32 *nic_minor); void (*ns_to_nic_time)(s64 ns, u32 *nic_major, u32 *nic_minor);
...@@ -1848,7 +1848,7 @@ int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted, ...@@ -1848,7 +1848,7 @@ int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
return 0; return 0;
} }
static int efx_ptp_ts_init(struct efx_nic *efx, struct hwtstamp_config *init) static int efx_ptp_ts_init(struct efx_nic *efx, struct kernel_hwtstamp_config *init)
{ {
int rc; int rc;
...@@ -1895,33 +1895,25 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info) ...@@ -1895,33 +1895,25 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info)
ts_info->rx_filters = ptp->efx->type->hwtstamp_filters; ts_info->rx_filters = ptp->efx->type->hwtstamp_filters;
} }
int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr) int efx_ptp_set_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack __always_unused *extack)
{ {
struct hwtstamp_config config;
int rc;
/* Not a PTP enabled port */ /* Not a PTP enabled port */
if (!efx->ptp_data) if (!efx->ptp_data)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) return efx_ptp_ts_init(efx, config);
return -EFAULT;
rc = efx_ptp_ts_init(efx, &config);
if (rc != 0)
return rc;
return copy_to_user(ifr->ifr_data, &config, sizeof(config))
? -EFAULT : 0;
} }
int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr) int efx_ptp_get_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config)
{ {
/* Not a PTP enabled port */
if (!efx->ptp_data) if (!efx->ptp_data)
return -EOPNOTSUPP; return -EOPNOTSUPP;
*config = efx->ptp_data->config;
return copy_to_user(ifr->ifr_data, &efx->ptp_data->config, return 0;
sizeof(efx->ptp_data->config)) ? -EFAULT : 0;
} }
static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len) static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len)
......
...@@ -18,8 +18,11 @@ void efx_ptp_defer_probe_with_channel(struct efx_nic *efx); ...@@ -18,8 +18,11 @@ void efx_ptp_defer_probe_with_channel(struct efx_nic *efx);
struct efx_channel *efx_ptp_channel(struct efx_nic *efx); struct efx_channel *efx_ptp_channel(struct efx_nic *efx);
void efx_ptp_update_channel(struct efx_nic *efx, struct efx_channel *channel); void efx_ptp_update_channel(struct efx_nic *efx, struct efx_channel *channel);
void efx_ptp_remove(struct efx_nic *efx); void efx_ptp_remove(struct efx_nic *efx);
int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr); int efx_ptp_set_ts_config(struct efx_nic *efx,
int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr); struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
int efx_ptp_get_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config);
void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info); void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
int efx_ptp_get_mode(struct efx_nic *efx); int efx_ptp_get_mode(struct efx_nic *efx);
......
...@@ -495,11 +495,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) ...@@ -495,11 +495,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
struct mii_ioctl_data *data = if_mii(ifr); struct mii_ioctl_data *data = if_mii(ifr);
if (cmd == SIOCSHWTSTAMP)
return efx_siena_ptp_set_ts_config(efx, ifr);
if (cmd == SIOCGHWTSTAMP)
return efx_siena_ptp_get_ts_config(efx, ifr);
/* Convert phy_id from older PRTAD/DEVAD format */ /* Convert phy_id from older PRTAD/DEVAD format */
if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) && if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
(data->phy_id & 0xfc00) == 0x0400) (data->phy_id & 0xfc00) == 0x0400)
...@@ -579,6 +574,23 @@ static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vi ...@@ -579,6 +574,23 @@ static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vi
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int efx_siena_hwtstamp_set(struct net_device *net_dev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
{
struct efx_nic *efx = netdev_priv(net_dev);
return efx_siena_ptp_set_ts_config(efx, config, extack);
}
static int efx_siena_hwtstamp_get(struct net_device *net_dev,
struct kernel_hwtstamp_config *config)
{
struct efx_nic *efx = netdev_priv(net_dev);
return efx_siena_ptp_get_ts_config(efx, config);
}
static const struct net_device_ops efx_netdev_ops = { static const struct net_device_ops efx_netdev_ops = {
.ndo_open = efx_net_open, .ndo_open = efx_net_open,
.ndo_stop = efx_net_stop, .ndo_stop = efx_net_stop,
...@@ -594,6 +606,8 @@ static const struct net_device_ops efx_netdev_ops = { ...@@ -594,6 +606,8 @@ static const struct net_device_ops efx_netdev_ops = {
.ndo_features_check = efx_siena_features_check, .ndo_features_check = efx_siena_features_check,
.ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid, .ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid, .ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
.ndo_hwtstamp_set = efx_siena_hwtstamp_set,
.ndo_hwtstamp_get = efx_siena_hwtstamp_get,
#ifdef CONFIG_SFC_SIENA_SRIOV #ifdef CONFIG_SFC_SIENA_SRIOV
.ndo_set_vf_mac = efx_sriov_set_vf_mac, .ndo_set_vf_mac = efx_sriov_set_vf_mac,
.ndo_set_vf_vlan = efx_sriov_set_vf_vlan, .ndo_set_vf_vlan = efx_sriov_set_vf_vlan,
......
...@@ -1424,7 +1424,7 @@ struct efx_nic_type { ...@@ -1424,7 +1424,7 @@ struct efx_nic_type {
void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time); void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp); int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
int (*ptp_set_ts_config)(struct efx_nic *efx, int (*ptp_set_ts_config)(struct efx_nic *efx,
struct hwtstamp_config *init); struct kernel_hwtstamp_config *init);
int (*sriov_configure)(struct efx_nic *efx, int num_vfs); int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid); int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid); int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
......
...@@ -297,7 +297,7 @@ struct efx_ptp_data { ...@@ -297,7 +297,7 @@ struct efx_ptp_data {
u32 rxfilter_event; u32 rxfilter_event;
u32 rxfilter_general; u32 rxfilter_general;
bool rxfilter_installed; bool rxfilter_installed;
struct hwtstamp_config config; struct kernel_hwtstamp_config config;
bool enabled; bool enabled;
unsigned int mode; unsigned int mode;
void (*ns_to_nic_time)(s64 ns, u32 *nic_major, u32 *nic_minor); void (*ns_to_nic_time)(s64 ns, u32 *nic_major, u32 *nic_minor);
...@@ -1762,7 +1762,8 @@ int efx_siena_ptp_change_mode(struct efx_nic *efx, bool enable_wanted, ...@@ -1762,7 +1762,8 @@ int efx_siena_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
return 0; return 0;
} }
static int efx_ptp_ts_init(struct efx_nic *efx, struct hwtstamp_config *init) static int efx_ptp_ts_init(struct efx_nic *efx,
struct kernel_hwtstamp_config *init)
{ {
int rc; int rc;
...@@ -1799,33 +1800,26 @@ void efx_siena_ptp_get_ts_info(struct efx_nic *efx, ...@@ -1799,33 +1800,26 @@ void efx_siena_ptp_get_ts_info(struct efx_nic *efx,
ts_info->rx_filters = ptp->efx->type->hwtstamp_filters; ts_info->rx_filters = ptp->efx->type->hwtstamp_filters;
} }
int efx_siena_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr) int efx_siena_ptp_set_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack __always_unused *extack)
{ {
struct hwtstamp_config config;
int rc;
/* Not a PTP enabled port */ /* Not a PTP enabled port */
if (!efx->ptp_data) if (!efx->ptp_data)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) return efx_ptp_ts_init(efx, config);
return -EFAULT;
rc = efx_ptp_ts_init(efx, &config);
if (rc != 0)
return rc;
return copy_to_user(ifr->ifr_data, &config, sizeof(config))
? -EFAULT : 0;
} }
int efx_siena_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr) int efx_siena_ptp_get_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config)
{ {
/* Not a PTP enabled port */
if (!efx->ptp_data) if (!efx->ptp_data)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return copy_to_user(ifr->ifr_data, &efx->ptp_data->config, *config = efx->ptp_data->config;
sizeof(efx->ptp_data->config)) ? -EFAULT : 0; return 0;
} }
static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len) static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len)
......
...@@ -15,8 +15,11 @@ ...@@ -15,8 +15,11 @@
struct ethtool_ts_info; struct ethtool_ts_info;
void efx_siena_ptp_defer_probe_with_channel(struct efx_nic *efx); void efx_siena_ptp_defer_probe_with_channel(struct efx_nic *efx);
struct efx_channel *efx_siena_ptp_channel(struct efx_nic *efx); struct efx_channel *efx_siena_ptp_channel(struct efx_nic *efx);
int efx_siena_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr); int efx_siena_ptp_set_ts_config(struct efx_nic *efx,
int efx_siena_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr); struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
int efx_siena_ptp_get_ts_config(struct efx_nic *efx,
struct kernel_hwtstamp_config *config);
void efx_siena_ptp_get_ts_info(struct efx_nic *efx, void efx_siena_ptp_get_ts_info(struct efx_nic *efx,
struct ethtool_ts_info *ts_info); struct ethtool_ts_info *ts_info);
bool efx_siena_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); bool efx_siena_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
......
...@@ -136,7 +136,7 @@ static void siena_ptp_write_host_time(struct efx_nic *efx, u32 host_time) ...@@ -136,7 +136,7 @@ static void siena_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
} }
static int siena_ptp_set_ts_config(struct efx_nic *efx, static int siena_ptp_set_ts_config(struct efx_nic *efx,
struct hwtstamp_config *init) struct kernel_hwtstamp_config *init)
{ {
int rc; int rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment