Skip to content

Commit 39aa687

Browse files
Piotr Wejmananguy11
authored andcommitted
net: e1000e: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
Update the driver to use the new hardware timestamping API added in commit 66f7223 ("net: add NDOs for configuring hardware timestamping"). Use Netlink extack for error reporting in e1000e_config_hwtstamp. Align the indentation of net_device_ops. Reviewed-by: Vadim Fedorenko <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Vitaly Lifshits <[email protected]> Signed-off-by: Piotr Wejman <[email protected]> Tested-by: Avigail Dahan <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent f9c961e commit 39aa687

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ struct e1000_adapter {
319319
u16 tx_ring_count;
320320
u16 rx_ring_count;
321321

322-
struct hwtstamp_config hwtstamp_config;
322+
struct kernel_hwtstamp_config hwtstamp_config;
323323
struct delayed_work systim_overflow_work;
324324
struct sk_buff *tx_hwtstamp_skb;
325325
unsigned long tx_hwtstamp_start;

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,7 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
35743574
* e1000e_config_hwtstamp - configure the hwtstamp registers and enable/disable
35753575
* @adapter: board private structure
35763576
* @config: timestamp configuration
3577+
* @extack: netlink extended ACK for error report
35773578
*
35783579
* Outgoing time stamping can be enabled and disabled. Play nice and
35793580
* disable it when requested, although it shouldn't cause any overhead
@@ -3587,7 +3588,8 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
35873588
* exception of "all V2 events regardless of level 2 or 4".
35883589
**/
35893590
static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
3590-
struct hwtstamp_config *config)
3591+
struct kernel_hwtstamp_config *config,
3592+
struct netlink_ext_ack *extack)
35913593
{
35923594
struct e1000_hw *hw = &adapter->hw;
35933595
u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
@@ -3598,8 +3600,10 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
35983600
bool is_l2 = false;
35993601
u32 regval;
36003602

3601-
if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
3603+
if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) {
3604+
NL_SET_ERR_MSG(extack, "No HW timestamp support");
36023605
return -EINVAL;
3606+
}
36033607

36043608
switch (config->tx_type) {
36053609
case HWTSTAMP_TX_OFF:
@@ -3608,6 +3612,7 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
36083612
case HWTSTAMP_TX_ON:
36093613
break;
36103614
default:
3615+
NL_SET_ERR_MSG(extack, "Unsupported TX HW timestamp type");
36113616
return -ERANGE;
36123617
}
36133618

@@ -3681,6 +3686,7 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
36813686
config->rx_filter = HWTSTAMP_FILTER_ALL;
36823687
break;
36833688
default:
3689+
NL_SET_ERR_MSG(extack, "Unsupported RX HW timestamp filter");
36843690
return -ERANGE;
36853691
}
36863692

@@ -3693,7 +3699,8 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
36933699
ew32(TSYNCTXCTL, regval);
36943700
if ((er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_ENABLED) !=
36953701
(regval & E1000_TSYNCTXCTL_ENABLED)) {
3696-
e_err("Timesync Tx Control register not set as expected\n");
3702+
NL_SET_ERR_MSG(extack,
3703+
"Timesync Tx Control register not set as expected");
36973704
return -EAGAIN;
36983705
}
36993706

@@ -3706,7 +3713,8 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
37063713
E1000_TSYNCRXCTL_TYPE_MASK)) !=
37073714
(regval & (E1000_TSYNCRXCTL_ENABLED |
37083715
E1000_TSYNCRXCTL_TYPE_MASK))) {
3709-
e_err("Timesync Rx Control register not set as expected\n");
3716+
NL_SET_ERR_MSG(extack,
3717+
"Timesync Rx Control register not set as expected");
37103718
return -EAGAIN;
37113719
}
37123720

@@ -3901,6 +3909,7 @@ static void e1000e_systim_reset(struct e1000_adapter *adapter)
39013909
{
39023910
struct ptp_clock_info *info = &adapter->ptp_clock_info;
39033911
struct e1000_hw *hw = &adapter->hw;
3912+
struct netlink_ext_ack extack = {};
39043913
unsigned long flags;
39053914
u32 timinca;
39063915
s32 ret_val;
@@ -3932,7 +3941,12 @@ static void e1000e_systim_reset(struct e1000_adapter *adapter)
39323941
spin_unlock_irqrestore(&adapter->systim_lock, flags);
39333942

39343943
/* restore the previous hwtstamp configuration settings */
3935-
e1000e_config_hwtstamp(adapter, &adapter->hwtstamp_config);
3944+
ret_val = e1000e_config_hwtstamp(adapter, &adapter->hwtstamp_config,
3945+
&extack);
3946+
if (ret_val) {
3947+
if (extack._msg)
3948+
e_err("%s\n", extack._msg);
3949+
}
39363950
}
39373951

39383952
/**
@@ -6079,8 +6093,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
60796093
return 0;
60806094
}
60816095

6082-
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
6083-
int cmd)
6096+
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
60846097
{
60856098
struct e1000_adapter *adapter = netdev_priv(netdev);
60866099
struct mii_ioctl_data *data = if_mii(ifr);
@@ -6140,7 +6153,8 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
61406153
/**
61416154
* e1000e_hwtstamp_set - control hardware time stamping
61426155
* @netdev: network interface device structure
6143-
* @ifr: interface request
6156+
* @config: timestamp configuration
6157+
* @extack: netlink extended ACK report
61446158
*
61456159
* Outgoing time stamping can be enabled and disabled. Play nice and
61466160
* disable it when requested, although it shouldn't cause any overhead
@@ -6153,20 +6167,18 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
61536167
* specified. Matching the kind of event packet is not supported, with the
61546168
* exception of "all V2 events regardless of level 2 or 4".
61556169
**/
6156-
static int e1000e_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
6170+
static int e1000e_hwtstamp_set(struct net_device *netdev,
6171+
struct kernel_hwtstamp_config *config,
6172+
struct netlink_ext_ack *extack)
61576173
{
61586174
struct e1000_adapter *adapter = netdev_priv(netdev);
6159-
struct hwtstamp_config config;
61606175
int ret_val;
61616176

6162-
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
6163-
return -EFAULT;
6164-
6165-
ret_val = e1000e_config_hwtstamp(adapter, &config);
6177+
ret_val = e1000e_config_hwtstamp(adapter, config, extack);
61666178
if (ret_val)
61676179
return ret_val;
61686180

6169-
switch (config.rx_filter) {
6181+
switch (config->rx_filter) {
61706182
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
61716183
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
61726184
case HWTSTAMP_FILTER_PTP_V2_SYNC:
@@ -6178,38 +6190,23 @@ static int e1000e_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
61786190
* by hardware so notify the caller the requested packets plus
61796191
* some others are time stamped.
61806192
*/
6181-
config.rx_filter = HWTSTAMP_FILTER_SOME;
6193+
config->rx_filter = HWTSTAMP_FILTER_SOME;
61826194
break;
61836195
default:
61846196
break;
61856197
}
61866198

6187-
return copy_to_user(ifr->ifr_data, &config,
6188-
sizeof(config)) ? -EFAULT : 0;
6199+
return 0;
61896200
}
61906201

6191-
static int e1000e_hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
6202+
static int e1000e_hwtstamp_get(struct net_device *netdev,
6203+
struct kernel_hwtstamp_config *kernel_config)
61926204
{
61936205
struct e1000_adapter *adapter = netdev_priv(netdev);
61946206

6195-
return copy_to_user(ifr->ifr_data, &adapter->hwtstamp_config,
6196-
sizeof(adapter->hwtstamp_config)) ? -EFAULT : 0;
6197-
}
6207+
*kernel_config = adapter->hwtstamp_config;
61986208

6199-
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
6200-
{
6201-
switch (cmd) {
6202-
case SIOCGMIIPHY:
6203-
case SIOCGMIIREG:
6204-
case SIOCSMIIREG:
6205-
return e1000_mii_ioctl(netdev, ifr, cmd);
6206-
case SIOCSHWTSTAMP:
6207-
return e1000e_hwtstamp_set(netdev, ifr);
6208-
case SIOCGHWTSTAMP:
6209-
return e1000e_hwtstamp_get(netdev, ifr);
6210-
default:
6211-
return -EOPNOTSUPP;
6212-
}
6209+
return 0;
62136210
}
62146211

62156212
static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
@@ -7346,9 +7343,11 @@ static const struct net_device_ops e1000e_netdev_ops = {
73467343
#ifdef CONFIG_NET_POLL_CONTROLLER
73477344
.ndo_poll_controller = e1000_netpoll,
73487345
#endif
7349-
.ndo_set_features = e1000_set_features,
7350-
.ndo_fix_features = e1000_fix_features,
7346+
.ndo_set_features = e1000_set_features,
7347+
.ndo_fix_features = e1000_fix_features,
73517348
.ndo_features_check = passthru_features_check,
7349+
.ndo_hwtstamp_get = e1000e_hwtstamp_get,
7350+
.ndo_hwtstamp_set = e1000e_hwtstamp_set,
73527351
};
73537352

73547353
/**

0 commit comments

Comments
 (0)