Skip to content

Commit c4b1c01

Browse files
alexaust-xlnxNipaLocal
authored andcommitted
sfc: Implement ndo_hwtstamp_(get|set)
Update efx->ptp_data to use kernel_hwtstamp_config and implement ndo_hwtstamp_(get|set). Remove SIOCGHWTSTAMP and SIOCSHWTSTAMP from efx_ioctl. Signed-off-by: Alex Austin <alex.austin@amd.com> Acked-by: Martin Habets <habetsm.xilinx@gmail.com> Reviewed-by: Edward Cree <ecree.xilinx@gmail.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 5e02c7d commit c4b1c01

File tree

5 files changed

+38
-29
lines changed

5 files changed

+38
-29
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,13 +3706,13 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
37063706
}
37073707

37083708
static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx,
3709-
struct hwtstamp_config *init)
3709+
struct kernel_hwtstamp_config *init)
37103710
{
37113711
return -EOPNOTSUPP;
37123712
}
37133713

37143714
static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
3715-
struct hwtstamp_config *init)
3715+
struct kernel_hwtstamp_config *init)
37163716
{
37173717
int rc;
37183718

drivers/net/ethernet/sfc/efx.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
495495
struct efx_nic *efx = efx_netdev_priv(net_dev);
496496
struct mii_ioctl_data *data = if_mii(ifr);
497497

498-
if (cmd == SIOCSHWTSTAMP)
499-
return efx_ptp_set_ts_config(efx, ifr);
500-
if (cmd == SIOCGHWTSTAMP)
501-
return efx_ptp_get_ts_config(efx, ifr);
502-
503498
/* Convert phy_id from older PRTAD/DEVAD format */
504499
if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
505500
(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
581576
return -EOPNOTSUPP;
582577
}
583578

579+
static int efx_hwtstamp_set(struct net_device *net_dev,
580+
struct kernel_hwtstamp_config *config,
581+
struct netlink_ext_ack *extack)
582+
{
583+
struct efx_nic *efx = efx_netdev_priv(net_dev);
584+
585+
return efx_ptp_set_ts_config(efx, config, extack);
586+
}
587+
588+
static int efx_hwtstamp_get(struct net_device *net_dev,
589+
struct kernel_hwtstamp_config *config)
590+
{
591+
struct efx_nic *efx = efx_netdev_priv(net_dev);
592+
593+
return efx_ptp_get_ts_config(efx, config);
594+
}
595+
584596
static const struct net_device_ops efx_netdev_ops = {
585597
.ndo_open = efx_net_open,
586598
.ndo_stop = efx_net_stop,
@@ -596,6 +608,8 @@ static const struct net_device_ops efx_netdev_ops = {
596608
.ndo_features_check = efx_features_check,
597609
.ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
598610
.ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
611+
.ndo_hwtstamp_set = efx_hwtstamp_set,
612+
.ndo_hwtstamp_get = efx_hwtstamp_get,
599613
#ifdef CONFIG_SFC_SRIOV
600614
.ndo_set_vf_mac = efx_sriov_set_vf_mac,
601615
.ndo_set_vf_vlan = efx_sriov_set_vf_vlan,

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ struct efx_nic_type {
14731473
void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
14741474
int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
14751475
int (*ptp_set_ts_config)(struct efx_nic *efx,
1476-
struct hwtstamp_config *init);
1476+
struct kernel_hwtstamp_config *init);
14771477
int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
14781478
int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
14791479
int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);

drivers/net/ethernet/sfc/ptp.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct efx_ptp_data {
301301
bool reset_required;
302302
struct list_head rxfilters_mcast;
303303
struct list_head rxfilters_ucast;
304-
struct hwtstamp_config config;
304+
struct kernel_hwtstamp_config config;
305305
bool enabled;
306306
unsigned int mode;
307307
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,
18481848
return 0;
18491849
}
18501850

1851-
static int efx_ptp_ts_init(struct efx_nic *efx, struct hwtstamp_config *init)
1851+
static int efx_ptp_ts_init(struct efx_nic *efx, struct kernel_hwtstamp_config *init)
18521852
{
18531853
int rc;
18541854

@@ -1895,33 +1895,25 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info)
18951895
ts_info->rx_filters = ptp->efx->type->hwtstamp_filters;
18961896
}
18971897

1898-
int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr)
1898+
int efx_ptp_set_ts_config(struct efx_nic *efx,
1899+
struct kernel_hwtstamp_config *config,
1900+
struct netlink_ext_ack __always_unused *extack)
18991901
{
1900-
struct hwtstamp_config config;
1901-
int rc;
1902-
19031902
/* Not a PTP enabled port */
19041903
if (!efx->ptp_data)
19051904
return -EOPNOTSUPP;
19061905

1907-
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
1908-
return -EFAULT;
1909-
1910-
rc = efx_ptp_ts_init(efx, &config);
1911-
if (rc != 0)
1912-
return rc;
1913-
1914-
return copy_to_user(ifr->ifr_data, &config, sizeof(config))
1915-
? -EFAULT : 0;
1906+
return efx_ptp_ts_init(efx, config);
19161907
}
19171908

1918-
int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr)
1909+
int efx_ptp_get_ts_config(struct efx_nic *efx,
1910+
struct kernel_hwtstamp_config *config)
19191911
{
1912+
/* Not a PTP enabled port */
19201913
if (!efx->ptp_data)
19211914
return -EOPNOTSUPP;
1922-
1923-
return copy_to_user(ifr->ifr_data, &efx->ptp_data->config,
1924-
sizeof(efx->ptp_data->config)) ? -EFAULT : 0;
1915+
*config = efx->ptp_data->config;
1916+
return 0;
19251917
}
19261918

19271919
static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len)

drivers/net/ethernet/sfc/ptp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ void efx_ptp_defer_probe_with_channel(struct efx_nic *efx);
1818
struct efx_channel *efx_ptp_channel(struct efx_nic *efx);
1919
void efx_ptp_update_channel(struct efx_nic *efx, struct efx_channel *channel);
2020
void efx_ptp_remove(struct efx_nic *efx);
21-
int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr);
22-
int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr);
21+
int efx_ptp_set_ts_config(struct efx_nic *efx,
22+
struct kernel_hwtstamp_config *config,
23+
struct netlink_ext_ack *extack);
24+
int efx_ptp_get_ts_config(struct efx_nic *efx,
25+
struct kernel_hwtstamp_config *config);
2326
void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
2427
bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
2528
int efx_ptp_get_mode(struct efx_nic *efx);

0 commit comments

Comments
 (0)