diff mbox series

[net-next,12/12] ionic: advertise support for hardware timestamps

Message ID 20210401175610.44431-13-snelson@pensando.io
State New
Headers show
Series ionic: add PTP and hw clock support | expand

Commit Message

Shannon Nelson April 1, 2021, 5:56 p.m. UTC
Let the network stack know we've got support for timestamping
the packets.

Signed-off-by: Allen Hubbe <allenbh@pensando.io>
Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 .../net/ethernet/pensando/ionic/ionic_lif.c   | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Richard Cochran April 4, 2021, 11:43 p.m. UTC | #1
On Thu, Apr 01, 2021 at 10:56:10AM -0700, Shannon Nelson wrote:
> Let the network stack know we've got support for timestamping

> the packets.


Actually, you already advertised the support to user space in Patch 10,
so this present patch should go before that one (or together).

Thanks,
Richard
Shannon Nelson April 5, 2021, 4:33 p.m. UTC | #2
On 4/4/21 4:43 PM, Richard Cochran wrote:
> On Thu, Apr 01, 2021 at 10:56:10AM -0700, Shannon Nelson wrote:

>> Let the network stack know we've got support for timestamping

>> the packets.

> Actually, you already advertised the support to user space in Patch 10,

> so this present patch should go before that one (or together).

>

> Thanks,

> Richard


Yes, I supposed they could have gone together.  However, I believe that 
in a bisection this will only slightly confuse the user space tools, but 
won't cause any kernel pain.

sln
Richard Cochran April 5, 2021, 6:23 p.m. UTC | #3
On Mon, Apr 05, 2021 at 09:33:46AM -0700, Shannon Nelson wrote:
> Yes, I supposed they could have gone together.  However, I believe that in a

> bisection this will only slightly confuse the user space tools, but won't

> cause any kernel pain.


Bisection typically involves running tests from user space.  The test
failing or passing determines whether the commit will be marked GOOD
or BAD.  This use case is a real thing.

Thanks,
Richard
diff mbox series

Patch

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index e14c93fbbd68..ee56fed12e07 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -1540,6 +1540,9 @@  static int ionic_set_nic_features(struct ionic_lif *lif,
 
 	ctx.cmd.lif_setattr.features = ionic_netdev_features_to_nic(features);
 
+	if (lif->phc)
+		ctx.cmd.lif_setattr.features |= cpu_to_le64(IONIC_ETH_HW_TIMESTAMP);
+
 	err = ionic_adminq_post_wait(lif, &ctx);
 	if (err)
 		return err;
@@ -1587,6 +1590,8 @@  static int ionic_set_nic_features(struct ionic_lif *lif,
 		dev_dbg(dev, "feature ETH_HW_TSO_UDP\n");
 	if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM)
 		dev_dbg(dev, "feature ETH_HW_TSO_UDP_CSUM\n");
+	if (lif->hw_features & IONIC_ETH_HW_TIMESTAMP)
+		dev_dbg(dev, "feature ETH_HW_TIMESTAMP\n");
 
 	return 0;
 }
@@ -2260,6 +2265,20 @@  static int ionic_stop(struct net_device *netdev)
 	return 0;
 }
 
+static int ionic_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+{
+	struct ionic_lif *lif = netdev_priv(netdev);
+
+	switch (cmd) {
+	case SIOCSHWTSTAMP:
+		return ionic_lif_hwstamp_set(lif, ifr);
+	case SIOCGHWTSTAMP:
+		return ionic_lif_hwstamp_get(lif, ifr);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int ionic_get_vf_config(struct net_device *netdev,
 			       int vf, struct ifla_vf_info *ivf)
 {
@@ -2508,6 +2527,7 @@  static int ionic_set_vf_link_state(struct net_device *netdev, int vf, int set)
 static const struct net_device_ops ionic_netdev_ops = {
 	.ndo_open               = ionic_open,
 	.ndo_stop               = ionic_stop,
+	.ndo_do_ioctl		= ionic_do_ioctl,
 	.ndo_start_xmit		= ionic_start_xmit,
 	.ndo_get_stats64	= ionic_get_stats64,
 	.ndo_set_rx_mode	= ionic_ndo_set_rx_mode,
@@ -3331,6 +3351,8 @@  int ionic_lif_register(struct ionic_lif *lif)
 {
 	int err;
 
+	ionic_lif_register_phc(lif);
+
 	INIT_WORK(&lif->ionic->nb_work, ionic_lif_notify_work);
 
 	lif->ionic->nb.notifier_call = ionic_lif_notify;
@@ -3343,6 +3365,7 @@  int ionic_lif_register(struct ionic_lif *lif)
 	err = register_netdev(lif->netdev);
 	if (err) {
 		dev_err(lif->ionic->dev, "Cannot register net device, aborting\n");
+		ionic_lif_unregister_phc(lif);
 		return err;
 	}
 
@@ -3364,6 +3387,8 @@  void ionic_lif_unregister(struct ionic_lif *lif)
 	if (lif->netdev->reg_state == NETREG_REGISTERED)
 		unregister_netdev(lif->netdev);
 
+	ionic_lif_unregister_phc(lif);
+
 	lif->registered = false;
 }