Skip to content

Commit 7efc369

Browse files
alexaust-xlnxNipaLocal
authored andcommitted
sfc-siena: 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 c4b1c01 commit 7efc369

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

drivers/net/ethernet/sfc/siena/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 = netdev_priv(net_dev);
496496
struct mii_ioctl_data *data = if_mii(ifr);
497497

498-
if (cmd == SIOCSHWTSTAMP)
499-
return efx_siena_ptp_set_ts_config(efx, ifr);
500-
if (cmd == SIOCGHWTSTAMP)
501-
return efx_siena_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)
@@ -579,6 +574,23 @@ static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vi
579574
return -EOPNOTSUPP;
580575
}
581576

577+
static int efx_siena_hwtstamp_set(struct net_device *net_dev,
578+
struct kernel_hwtstamp_config *config,
579+
struct netlink_ext_ack *extack)
580+
{
581+
struct efx_nic *efx = netdev_priv(net_dev);
582+
583+
return efx_siena_ptp_set_ts_config(efx, config, extack);
584+
}
585+
586+
static int efx_siena_hwtstamp_get(struct net_device *net_dev,
587+
struct kernel_hwtstamp_config *config)
588+
{
589+
struct efx_nic *efx = netdev_priv(net_dev);
590+
591+
return efx_siena_ptp_get_ts_config(efx, config);
592+
}
593+
582594
static const struct net_device_ops efx_netdev_ops = {
583595
.ndo_open = efx_net_open,
584596
.ndo_stop = efx_net_stop,
@@ -594,6 +606,8 @@ static const struct net_device_ops efx_netdev_ops = {
594606
.ndo_features_check = efx_siena_features_check,
595607
.ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
596608
.ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
609+
.ndo_hwtstamp_set = efx_siena_hwtstamp_set,
610+
.ndo_hwtstamp_get = efx_siena_hwtstamp_get,
597611
#ifdef CONFIG_SFC_SIENA_SRIOV
598612
.ndo_set_vf_mac = efx_sriov_set_vf_mac,
599613
.ndo_set_vf_vlan = efx_sriov_set_vf_vlan,

drivers/net/ethernet/sfc/siena/net_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ struct efx_nic_type {
14241424
void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
14251425
int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
14261426
int (*ptp_set_ts_config)(struct efx_nic *efx,
1427-
struct hwtstamp_config *init);
1427+
struct kernel_hwtstamp_config *init);
14281428
int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
14291429
int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
14301430
int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);

drivers/net/ethernet/sfc/siena/ptp.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ struct efx_ptp_data {
297297
u32 rxfilter_event;
298298
u32 rxfilter_general;
299299
bool rxfilter_installed;
300-
struct hwtstamp_config config;
300+
struct kernel_hwtstamp_config config;
301301
bool enabled;
302302
unsigned int mode;
303303
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,
17621762
return 0;
17631763
}
17641764

1765-
static int efx_ptp_ts_init(struct efx_nic *efx, struct hwtstamp_config *init)
1765+
static int efx_ptp_ts_init(struct efx_nic *efx,
1766+
struct kernel_hwtstamp_config *init)
17661767
{
17671768
int rc;
17681769

@@ -1799,33 +1800,26 @@ void efx_siena_ptp_get_ts_info(struct efx_nic *efx,
17991800
ts_info->rx_filters = ptp->efx->type->hwtstamp_filters;
18001801
}
18011802

1802-
int efx_siena_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr)
1803+
int efx_siena_ptp_set_ts_config(struct efx_nic *efx,
1804+
struct kernel_hwtstamp_config *config,
1805+
struct netlink_ext_ack __always_unused *extack)
18031806
{
1804-
struct hwtstamp_config config;
1805-
int rc;
1806-
18071807
/* Not a PTP enabled port */
18081808
if (!efx->ptp_data)
18091809
return -EOPNOTSUPP;
18101810

1811-
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
1812-
return -EFAULT;
1813-
1814-
rc = efx_ptp_ts_init(efx, &config);
1815-
if (rc != 0)
1816-
return rc;
1817-
1818-
return copy_to_user(ifr->ifr_data, &config, sizeof(config))
1819-
? -EFAULT : 0;
1811+
return efx_ptp_ts_init(efx, config);
18201812
}
18211813

1822-
int efx_siena_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr)
1814+
int efx_siena_ptp_get_ts_config(struct efx_nic *efx,
1815+
struct kernel_hwtstamp_config *config)
18231816
{
1817+
/* Not a PTP enabled port */
18241818
if (!efx->ptp_data)
18251819
return -EOPNOTSUPP;
18261820

1827-
return copy_to_user(ifr->ifr_data, &efx->ptp_data->config,
1828-
sizeof(efx->ptp_data->config)) ? -EFAULT : 0;
1821+
*config = efx->ptp_data->config;
1822+
return 0;
18291823
}
18301824

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

drivers/net/ethernet/sfc/siena/ptp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
struct ethtool_ts_info;
1616
void efx_siena_ptp_defer_probe_with_channel(struct efx_nic *efx);
1717
struct efx_channel *efx_siena_ptp_channel(struct efx_nic *efx);
18-
int efx_siena_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr);
19-
int efx_siena_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr);
18+
int efx_siena_ptp_set_ts_config(struct efx_nic *efx,
19+
struct kernel_hwtstamp_config *config,
20+
struct netlink_ext_ack *extack);
21+
int efx_siena_ptp_get_ts_config(struct efx_nic *efx,
22+
struct kernel_hwtstamp_config *config);
2023
void efx_siena_ptp_get_ts_info(struct efx_nic *efx,
2124
struct ethtool_ts_info *ts_info);
2225
bool efx_siena_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);

drivers/net/ethernet/sfc/siena/siena.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void siena_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
136136
}
137137

138138
static int siena_ptp_set_ts_config(struct efx_nic *efx,
139-
struct hwtstamp_config *init)
139+
struct kernel_hwtstamp_config *init)
140140
{
141141
int rc;
142142

0 commit comments

Comments
 (0)