RE: [PATCH v1 net-next 9/9] lan743x: Add PTP support

2018-07-09 Thread Bryan.Whitehead
Thanks Richard,
I'll add it in my next revision.

> -Original Message-
> From: Richard Cochran [mailto:richardcoch...@gmail.com]
> Sent: Friday, July 6, 2018 5:25 PM
> To: Bryan Whitehead - C21958 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; UNGLinuxDriver
> 
> Subject: Re: [PATCH v1 net-next 9/9] lan743x: Add PTP support
> 
> On Thu, Jul 05, 2018 at 12:39:26PM -0400, Bryan Whitehead wrote:
> > Signed-off-by: Bryan Whitehead 
> 
> 1. You forgot the commit message.
> 2. You forgot to add the PTP maintainer on CC.
> 
> Thanks,
> Richard



Re: [PATCH v1 net-next 9/9] lan743x: Add PTP support

2018-07-06 Thread Richard Cochran
On Thu, Jul 05, 2018 at 12:39:26PM -0400, Bryan Whitehead wrote:
> Signed-off-by: Bryan Whitehead 

1. You forgot the commit message.
2. You forgot to add the PTP maintainer on CC.

Thanks,
Richard



Re: [PATCH v1 net-next 9/9] lan743x: Add PTP support

2018-07-06 Thread kbuild test robot
Hi Bryan,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Bryan-Whitehead/lan743x-Add-features-to-lan743x-driver/20180706-051812
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> ERROR: "__moddi3" [drivers/net/ethernet/microchip/lan743x.ko] undefined!
>> ERROR: "__udivdi3" [drivers/net/ethernet/microchip/lan743x.ko] undefined!
>> ERROR: "__umoddi3" [drivers/net/ethernet/microchip/lan743x.ko] undefined!
>> ERROR: "__divdi3" [drivers/net/ethernet/microchip/lan743x.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH v1 net-next 9/9] lan743x: Add PTP support

2018-07-05 Thread Bryan Whitehead
Signed-off-by: Bryan Whitehead 
---
 drivers/net/ethernet/microchip/Makefile  |2 +-
 drivers/net/ethernet/microchip/lan743x_ethtool.c |   28 +
 drivers/net/ethernet/microchip/lan743x_main.c|   81 +-
 drivers/net/ethernet/microchip/lan743x_main.h|   96 +-
 drivers/net/ethernet/microchip/lan743x_ptp.c | 1194 ++
 drivers/net/ethernet/microchip/lan743x_ptp.h |   78 ++
 6 files changed, 1474 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/microchip/lan743x_ptp.c
 create mode 100644 drivers/net/ethernet/microchip/lan743x_ptp.h

diff --git a/drivers/net/ethernet/microchip/Makefile 
b/drivers/net/ethernet/microchip/Makefile
index 43f47cb..538926d 100644
--- a/drivers/net/ethernet/microchip/Makefile
+++ b/drivers/net/ethernet/microchip/Makefile
@@ -6,4 +6,4 @@ obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_ENCX24J600) += encx24j600.o encx24j600-regmap.o
 obj-$(CONFIG_LAN743X) += lan743x.o
 
-lan743x-objs := lan743x_main.o lan743x_ethtool.o
+lan743x-objs := lan743x_main.o lan743x_ethtool.o lan743x_ptp.o
diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c 
b/drivers/net/ethernet/microchip/lan743x_ethtool.c
index aa3421e..de17fdf 100644
--- a/drivers/net/ethernet/microchip/lan743x_ethtool.c
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
@@ -4,6 +4,7 @@
 #include 
 #include "lan743x_main.h"
 #include "lan743x_ethtool.h"
+#include 
 #include 
 #include 
 
@@ -544,6 +545,32 @@ static int lan743x_ethtool_set_rxfh(struct net_device 
*netdev,
return 0;
 }
 
+static int lan743x_ethtool_get_ts_info(struct net_device *netdev,
+  struct ethtool_ts_info *ts_info)
+{
+   struct lan743x_adapter *adapter = netdev_priv(netdev);
+
+   ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+  SOF_TIMESTAMPING_RX_SOFTWARE |
+  SOF_TIMESTAMPING_SOFTWARE |
+  SOF_TIMESTAMPING_TX_HARDWARE |
+  SOF_TIMESTAMPING_RX_HARDWARE |
+  SOF_TIMESTAMPING_RAW_HARDWARE;
+#ifdef CONFIG_PTP_1588_CLOCK
+   if (adapter->ptp.ptp_clock)
+   ts_info->phc_index = ptp_clock_index(adapter->ptp.ptp_clock);
+   else
+   ts_info->phc_index = -1;
+#else
+   ts_info->phc_index = -1;
+#endif
+   ts_info->tx_types = BIT(HWTSTAMP_TX_OFF) |
+   BIT(HWTSTAMP_TX_ON);
+   ts_info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
+ BIT(HWTSTAMP_FILTER_ALL);
+   return 0;
+}
+
 static int lan743x_ethtool_get_eee(struct net_device *netdev,
   struct ethtool_eee *eee)
 {
@@ -695,6 +722,7 @@ const struct ethtool_ops lan743x_ethtool_ops = {
.get_rxfh_indir_size = lan743x_ethtool_get_rxfh_indir_size,
.get_rxfh = lan743x_ethtool_get_rxfh,
.set_rxfh = lan743x_ethtool_set_rxfh,
+   .get_ts_info = lan743x_ethtool_get_ts_info,
.get_eee = lan743x_ethtool_get_eee,
.set_eee = lan743x_ethtool_set_eee,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index 01296e1..89fe9f3 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -266,6 +266,10 @@ static void lan743x_intr_shared_isr(void *context, u32 
int_sts, u32 flags)
lan743x_intr_software_isr(adapter);
int_sts &= ~INT_BIT_SW_GP_;
}
+   if (int_sts & INT_BIT_1588_) {
+   lan743x_ptp_isr(adapter);
+   int_sts &= ~INT_BIT_1588_;
+   }
}
if (int_sts)
lan743x_csr_write(adapter, INT_EN_CLR, int_sts);
@@ -975,6 +979,7 @@ static void lan743x_phy_link_status_change(struct 
net_device *netdev)
   ksettings.base.duplex,
   local_advertisement,
   remote_advertisement);
+   lan743x_ptp_update_latency(adapter, ksettings.base.speed);
}
 }
 
@@ -1255,11 +1260,29 @@ static void lan743x_tx_release_desc(struct lan743x_tx 
*tx,
buffer_info->dma_ptr = 0;
buffer_info->buffer_length = 0;
}
-   if (buffer_info->skb) {
+   if (!buffer_info->skb)
+   goto clear_active;
+
+   if (!(buffer_info->flags &
+   TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED)) {
dev_kfree_skb(buffer_info->skb);
-   buffer_info->skb = NULL;
+   goto clear_skb;
}
 
+   if (cleanup) {
+   lan743x_ptp_unrequest_tx_timestamp(tx->adapter);
+   dev_kfree_skb(buffer_info->skb);
+   } else {
+