Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Richard Cochran
On Mon, Dec 05, 2016 at 12:25:57PM -0600, Grygorii Strashko wrote:
> >> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
> >> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> >> @@ -113,6 +113,15 @@ Optional properties:
> >>will only initialize these ports and attach PHY
> >>driver to them if needed.
> >>  
> >> + Properties related to cpts configurations.
> >> +  - cpts_clock_mult/cpts_clock_shift:
> > 
> > Needs vendor prefix. Don't use '_'.
>
> This module is used as part of OMAP and Keystone SoCs, so names for
> this props is ABI already :(

Your automatic calculation makes these unnecessary, and so you can
drop these altogether.

Also, maybe you should mark them as deprecated in cpsw.txt?

(The underscores were my fault, sorry)

Thanks,
Richard


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Richard Cochran
On Mon, Dec 05, 2016 at 12:25:57PM -0600, Grygorii Strashko wrote:
> >> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
> >> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> >> @@ -113,6 +113,15 @@ Optional properties:
> >>will only initialize these ports and attach PHY
> >>driver to them if needed.
> >>  
> >> + Properties related to cpts configurations.
> >> +  - cpts_clock_mult/cpts_clock_shift:
> > 
> > Needs vendor prefix. Don't use '_'.
>
> This module is used as part of OMAP and Keystone SoCs, so names for
> this props is ABI already :(

Your automatic calculation makes these unnecessary, and so you can
drop these altogether.

Also, maybe you should mark them as deprecated in cpsw.txt?

(The underscores were my fault, sorry)

Thanks,
Richard


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Grygorii Strashko


On 12/05/2016 08:49 AM, Rob Herring wrote:
> On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
>> From: WingMan Kwok 
>>
>> This patch adds support of the cpts device found in the
>> gbe and 10gbe ethernet switches on the keystone 2 SoCs
>> (66AK2E/L/Hx, 66AK2Gx).
>>
>> Signed-off-by: WingMan Kwok 
>> Signed-off-by: Grygorii Strashko 
>> ---
>>  .../devicetree/bindings/net/keystone-netcp.txt |   9 +
>>  drivers/net/ethernet/ti/Kconfig|   7 +-
>>  drivers/net/ethernet/ti/netcp.h|   2 +-
>>  drivers/net/ethernet/ti/netcp_core.c   |  18 +-
>>  drivers/net/ethernet/ti/netcp_ethss.c  | 437 
>> -
>>  5 files changed, 459 insertions(+), 14 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
>> b/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> index 04ba1dc..c37b54e 100644
>> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> @@ -113,6 +113,15 @@ Optional properties:
>>  will only initialize these ports and attach PHY
>>  driver to them if needed.
>>  
>> + Properties related to cpts configurations.
>> +- cpts_clock_mult/cpts_clock_shift:
> 
> Needs vendor prefix. Don't use '_'.

This module is used as part of OMAP and Keystone SoCs, so names for
this props is ABI already :(

> 
>> +used for converting time counter cycles to ns as in
>> +
>> +ns = (cycles * clock_mult) >> _shift
>> +
>> +Defaults: clock_mult, clock_shift = calculated from
>> +CPTS refclk
> 
> What does this mean?
> 

I'll add more description here.

>> +
>>  NetCP interface properties: Interface specification for NetCP sub-modules.
>>  Required properties:
>>  - rx-channel:   the navigator packet dma channel name for rx.

-- 
regards,
-grygorii


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Grygorii Strashko


On 12/05/2016 08:49 AM, Rob Herring wrote:
> On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
>> From: WingMan Kwok 
>>
>> This patch adds support of the cpts device found in the
>> gbe and 10gbe ethernet switches on the keystone 2 SoCs
>> (66AK2E/L/Hx, 66AK2Gx).
>>
>> Signed-off-by: WingMan Kwok 
>> Signed-off-by: Grygorii Strashko 
>> ---
>>  .../devicetree/bindings/net/keystone-netcp.txt |   9 +
>>  drivers/net/ethernet/ti/Kconfig|   7 +-
>>  drivers/net/ethernet/ti/netcp.h|   2 +-
>>  drivers/net/ethernet/ti/netcp_core.c   |  18 +-
>>  drivers/net/ethernet/ti/netcp_ethss.c  | 437 
>> -
>>  5 files changed, 459 insertions(+), 14 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
>> b/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> index 04ba1dc..c37b54e 100644
>> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
>> @@ -113,6 +113,15 @@ Optional properties:
>>  will only initialize these ports and attach PHY
>>  driver to them if needed.
>>  
>> + Properties related to cpts configurations.
>> +- cpts_clock_mult/cpts_clock_shift:
> 
> Needs vendor prefix. Don't use '_'.

This module is used as part of OMAP and Keystone SoCs, so names for
this props is ABI already :(

> 
>> +used for converting time counter cycles to ns as in
>> +
>> +ns = (cycles * clock_mult) >> _shift
>> +
>> +Defaults: clock_mult, clock_shift = calculated from
>> +CPTS refclk
> 
> What does this mean?
> 

I'll add more description here.

>> +
>>  NetCP interface properties: Interface specification for NetCP sub-modules.
>>  Required properties:
>>  - rx-channel:   the navigator packet dma channel name for rx.

-- 
regards,
-grygorii


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Rob Herring
On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
> From: WingMan Kwok 
> 
> This patch adds support of the cpts device found in the
> gbe and 10gbe ethernet switches on the keystone 2 SoCs
> (66AK2E/L/Hx, 66AK2Gx).
> 
> Signed-off-by: WingMan Kwok 
> Signed-off-by: Grygorii Strashko 
> ---
>  .../devicetree/bindings/net/keystone-netcp.txt |   9 +
>  drivers/net/ethernet/ti/Kconfig|   7 +-
>  drivers/net/ethernet/ti/netcp.h|   2 +-
>  drivers/net/ethernet/ti/netcp_core.c   |  18 +-
>  drivers/net/ethernet/ti/netcp_ethss.c  | 437 
> -
>  5 files changed, 459 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
> b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> index 04ba1dc..c37b54e 100644
> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> @@ -113,6 +113,15 @@ Optional properties:
>   will only initialize these ports and attach PHY
>   driver to them if needed.
>  
> + Properties related to cpts configurations.
> + - cpts_clock_mult/cpts_clock_shift:

Needs vendor prefix. Don't use '_'.

> + used for converting time counter cycles to ns as in
> +
> + ns = (cycles * clock_mult) >> _shift
> +
> + Defaults: clock_mult, clock_shift = calculated from
> + CPTS refclk

What does this mean?

> +
>  NetCP interface properties: Interface specification for NetCP sub-modules.
>  Required properties:
>  - rx-channel:the navigator packet dma channel name for rx.


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-12-05 Thread Rob Herring
On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
> From: WingMan Kwok 
> 
> This patch adds support of the cpts device found in the
> gbe and 10gbe ethernet switches on the keystone 2 SoCs
> (66AK2E/L/Hx, 66AK2Gx).
> 
> Signed-off-by: WingMan Kwok 
> Signed-off-by: Grygorii Strashko 
> ---
>  .../devicetree/bindings/net/keystone-netcp.txt |   9 +
>  drivers/net/ethernet/ti/Kconfig|   7 +-
>  drivers/net/ethernet/ti/netcp.h|   2 +-
>  drivers/net/ethernet/ti/netcp_core.c   |  18 +-
>  drivers/net/ethernet/ti/netcp_ethss.c  | 437 
> -
>  5 files changed, 459 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
> b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> index 04ba1dc..c37b54e 100644
> --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
> +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
> @@ -113,6 +113,15 @@ Optional properties:
>   will only initialize these ports and attach PHY
>   driver to them if needed.
>  
> + Properties related to cpts configurations.
> + - cpts_clock_mult/cpts_clock_shift:

Needs vendor prefix. Don't use '_'.

> + used for converting time counter cycles to ns as in
> +
> + ns = (cycles * clock_mult) >> _shift
> +
> + Defaults: clock_mult, clock_shift = calculated from
> + CPTS refclk

What does this mean?

> +
>  NetCP interface properties: Interface specification for NetCP sub-modules.
>  Required properties:
>  - rx-channel:the navigator packet dma channel name for rx.


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Richard Cochran
On Wed, Nov 30, 2016 at 11:31:56AM -0600, Grygorii Strashko wrote:

> ok. Seems my assumption that ndo_open/ndo_close serialized by
> rtnl_lock is incorrect. Right?

No, you were right in the first place.  The open/close are indeed
serialized by the rtnl lock.

Sorry for the noise,
Richard


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Richard Cochran
On Wed, Nov 30, 2016 at 11:31:56AM -0600, Grygorii Strashko wrote:

> ok. Seems my assumption that ndo_open/ndo_close serialized by
> rtnl_lock is incorrect. Right?

No, you were right in the first place.  The open/close are indeed
serialized by the rtnl lock.

Sorry for the noise,
Richard


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Grygorii Strashko


On 11/30/2016 03:44 AM, Richard Cochran wrote:
> On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
>> @@ -678,6 +744,9 @@ struct gbe_priv {
>>  int num_et_stats;
>>  /*  Lock for updating the hwstats */
>>  spinlock_t  hw_stats_lock;
>> +
>> +int cpts_registered;
> 
> The usage of this counter is racy.
> 
>> +struct cpts *cpts;
>>  };
> 
> This ++ and -- business ...
> 
>> +static void gbe_register_cpts(struct gbe_priv *gbe_dev)
>> +{
>> +if (!gbe_dev->cpts)
>> +return;
>> +
>> +if (gbe_dev->cpts_registered > 0)
>> +goto done;
>> +
>> +if (cpts_register(gbe_dev->cpts)) {
>> +dev_err(gbe_dev->dev, "error registering cpts device\n");
>> +return;
>> +}
>> +
>> +done:
>> +++gbe_dev->cpts_registered;
>> +}
>> +
>> +static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
>> +{
>> +if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
>> +return;
>> +
>> +if (--gbe_dev->cpts_registered)
>> +return;
>> +
>> +cpts_unregister(gbe_dev->cpts);
>> +}
> 
> is invoked from your open() and close() methods, but those methods
> are not serialized among multiple ports.
> 

ok. Seems my assumption that ndo_open/ndo_close serialized by rtnl_lock is 
incorrect. Right?
net_device_ops.ndo_open ->
 netcp_ndo_open
 gbe_open
 gbe_register_cpts

-- 
regards,
-grygorii


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Grygorii Strashko


On 11/30/2016 03:44 AM, Richard Cochran wrote:
> On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
>> @@ -678,6 +744,9 @@ struct gbe_priv {
>>  int num_et_stats;
>>  /*  Lock for updating the hwstats */
>>  spinlock_t  hw_stats_lock;
>> +
>> +int cpts_registered;
> 
> The usage of this counter is racy.
> 
>> +struct cpts *cpts;
>>  };
> 
> This ++ and -- business ...
> 
>> +static void gbe_register_cpts(struct gbe_priv *gbe_dev)
>> +{
>> +if (!gbe_dev->cpts)
>> +return;
>> +
>> +if (gbe_dev->cpts_registered > 0)
>> +goto done;
>> +
>> +if (cpts_register(gbe_dev->cpts)) {
>> +dev_err(gbe_dev->dev, "error registering cpts device\n");
>> +return;
>> +}
>> +
>> +done:
>> +++gbe_dev->cpts_registered;
>> +}
>> +
>> +static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
>> +{
>> +if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
>> +return;
>> +
>> +if (--gbe_dev->cpts_registered)
>> +return;
>> +
>> +cpts_unregister(gbe_dev->cpts);
>> +}
> 
> is invoked from your open() and close() methods, but those methods
> are not serialized among multiple ports.
> 

ok. Seems my assumption that ndo_open/ndo_close serialized by rtnl_lock is 
incorrect. Right?
net_device_ops.ndo_open ->
 netcp_ndo_open
 gbe_open
 gbe_register_cpts

-- 
regards,
-grygorii


Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Richard Cochran
On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
> @@ -678,6 +744,9 @@ struct gbe_priv {
>   int num_et_stats;
>   /*  Lock for updating the hwstats */
>   spinlock_t  hw_stats_lock;
> +
> + int cpts_registered;

The usage of this counter is racy.

> + struct cpts *cpts;
>  };

This ++ and -- business ...

> +static void gbe_register_cpts(struct gbe_priv *gbe_dev)
> +{
> + if (!gbe_dev->cpts)
> + return;
> +
> + if (gbe_dev->cpts_registered > 0)
> + goto done;
> +
> + if (cpts_register(gbe_dev->cpts)) {
> + dev_err(gbe_dev->dev, "error registering cpts device\n");
> + return;
> + }
> +
> +done:
> + ++gbe_dev->cpts_registered;
> +}
> +
> +static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
> +{
> + if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
> + return;
> +
> + if (--gbe_dev->cpts_registered)
> + return;
> +
> + cpts_unregister(gbe_dev->cpts);
> +}

is invoked from your open() and close() methods, but those methods
are not serialized among multiple ports.

Thanks,
Richard




Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-30 Thread Richard Cochran
On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote:
> @@ -678,6 +744,9 @@ struct gbe_priv {
>   int num_et_stats;
>   /*  Lock for updating the hwstats */
>   spinlock_t  hw_stats_lock;
> +
> + int cpts_registered;

The usage of this counter is racy.

> + struct cpts *cpts;
>  };

This ++ and -- business ...

> +static void gbe_register_cpts(struct gbe_priv *gbe_dev)
> +{
> + if (!gbe_dev->cpts)
> + return;
> +
> + if (gbe_dev->cpts_registered > 0)
> + goto done;
> +
> + if (cpts_register(gbe_dev->cpts)) {
> + dev_err(gbe_dev->dev, "error registering cpts device\n");
> + return;
> + }
> +
> +done:
> + ++gbe_dev->cpts_registered;
> +}
> +
> +static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
> +{
> + if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
> + return;
> +
> + if (--gbe_dev->cpts_registered)
> + return;
> +
> + cpts_unregister(gbe_dev->cpts);
> +}

is invoked from your open() and close() methods, but those methods
are not serialized among multiple ports.

Thanks,
Richard




[PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-28 Thread Grygorii Strashko
From: WingMan Kwok 

This patch adds support of the cpts device found in the
gbe and 10gbe ethernet switches on the keystone 2 SoCs
(66AK2E/L/Hx, 66AK2Gx).

Signed-off-by: WingMan Kwok 
Signed-off-by: Grygorii Strashko 
---
 .../devicetree/bindings/net/keystone-netcp.txt |   9 +
 drivers/net/ethernet/ti/Kconfig|   7 +-
 drivers/net/ethernet/ti/netcp.h|   2 +-
 drivers/net/ethernet/ti/netcp_core.c   |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c  | 437 -
 5 files changed, 459 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
b/Documentation/devicetree/bindings/net/keystone-netcp.txt
index 04ba1dc..c37b54e 100644
--- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
+++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
@@ -113,6 +113,15 @@ Optional properties:
will only initialize these ports and attach PHY
driver to them if needed.
 
+ Properties related to cpts configurations.
+   - cpts_clock_mult/cpts_clock_shift:
+   used for converting time counter cycles to ns as in
+
+   ns = (cycles * clock_mult) >> _shift
+
+   Defaults: clock_mult, clock_shift = calculated from
+   CPTS refclk
+
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
 - rx-channel:  the navigator packet dma channel name for rx.
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index ff7f518..dc217fd 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -75,12 +75,13 @@ config TI_CPSW
 
 config TI_CPTS
tristate "TI Common Platform Time Sync (CPTS) Support"
-   depends on TI_CPSW
+   depends on TI_CPSW || TI_KEYSTONE_NETCP
select PTP_1588_CLOCK
---help---
  This driver supports the Common Platform Time Sync unit of
- the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
- and Layer 2 packets, and the driver offers a PTP Hardware Clock.
+ the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
+ The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the
+ driver offers a PTP Hardware Clock.
 
 config TI_KEYSTONE_NETCP
tristate "TI Keystone NETCP Core Support"
diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index 17a26a4..0f58c58 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -121,7 +121,7 @@ struct netcp_packet {
boolrxtstamp_complete;
void*ts_context;
 
-   int (*txtstamp_complete)(void *ctx, struct netcp_packet *pkt);
+   void (*txtstamp)(void *ctx, struct sk_buff *skb);
 };
 
 static inline u32 *netcp_push_psdata(struct netcp_packet *p_info,
diff --git a/drivers/net/ethernet/ti/netcp_core.c 
b/drivers/net/ethernet/ti/netcp_core.c
index 3251666..a740e60 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -100,6 +100,11 @@ struct netcp_intf_modpriv {
void*module_priv;
 };
 
+struct netcp_tx_cb {
+   void*ts_context;
+   void(*txtstamp)(void *context, struct sk_buff *skb);
+};
+
 static LIST_HEAD(netcp_devices);
 static LIST_HEAD(netcp_modules);
 static DEFINE_MUTEX(netcp_modules_lock);
@@ -730,6 +735,7 @@ static int netcp_process_one_rx_packet(struct netcp_intf 
*netcp)
 
/* Call each of the RX hooks */
p_info.skb = skb;
+   skb->dev = netcp->ndev;
p_info.rxtstamp_complete = false;
list_for_each_entry(rx_hook, >rxhook_list_head, list) {
int ret;
@@ -987,6 +993,7 @@ static int netcp_process_tx_compl_packets(struct netcp_intf 
*netcp,
  unsigned int budget)
 {
struct knav_dma_desc *desc;
+   struct netcp_tx_cb *tx_cb;
struct sk_buff *skb;
unsigned int dma_sz;
dma_addr_t dma;
@@ -1014,6 +1021,10 @@ static int netcp_process_tx_compl_packets(struct 
netcp_intf *netcp,
continue;
}
 
+   tx_cb = (struct netcp_tx_cb *)skb->cb;
+   if (tx_cb->txtstamp)
+   tx_cb->txtstamp(tx_cb->ts_context, skb);
+
if (netif_subqueue_stopped(netcp->ndev, skb) &&
netif_running(netcp->ndev) &&
(knav_pool_count(netcp->tx_pool) >
@@ -1154,6 +1165,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
struct netcp_tx_pipe *tx_pipe = NULL;
struct netcp_hook_list *tx_hook;
struct netcp_packet p_info;
+   struct netcp_tx_cb *tx_cb;
unsigned int dma_sz;
dma_addr_t dma;
u32 tmp = 0;
@@ 

[PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

2016-11-28 Thread Grygorii Strashko
From: WingMan Kwok 

This patch adds support of the cpts device found in the
gbe and 10gbe ethernet switches on the keystone 2 SoCs
(66AK2E/L/Hx, 66AK2Gx).

Signed-off-by: WingMan Kwok 
Signed-off-by: Grygorii Strashko 
---
 .../devicetree/bindings/net/keystone-netcp.txt |   9 +
 drivers/net/ethernet/ti/Kconfig|   7 +-
 drivers/net/ethernet/ti/netcp.h|   2 +-
 drivers/net/ethernet/ti/netcp_core.c   |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c  | 437 -
 5 files changed, 459 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt 
b/Documentation/devicetree/bindings/net/keystone-netcp.txt
index 04ba1dc..c37b54e 100644
--- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
+++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
@@ -113,6 +113,15 @@ Optional properties:
will only initialize these ports and attach PHY
driver to them if needed.
 
+ Properties related to cpts configurations.
+   - cpts_clock_mult/cpts_clock_shift:
+   used for converting time counter cycles to ns as in
+
+   ns = (cycles * clock_mult) >> _shift
+
+   Defaults: clock_mult, clock_shift = calculated from
+   CPTS refclk
+
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
 - rx-channel:  the navigator packet dma channel name for rx.
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index ff7f518..dc217fd 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -75,12 +75,13 @@ config TI_CPSW
 
 config TI_CPTS
tristate "TI Common Platform Time Sync (CPTS) Support"
-   depends on TI_CPSW
+   depends on TI_CPSW || TI_KEYSTONE_NETCP
select PTP_1588_CLOCK
---help---
  This driver supports the Common Platform Time Sync unit of
- the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
- and Layer 2 packets, and the driver offers a PTP Hardware Clock.
+ the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
+ The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the
+ driver offers a PTP Hardware Clock.
 
 config TI_KEYSTONE_NETCP
tristate "TI Keystone NETCP Core Support"
diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index 17a26a4..0f58c58 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -121,7 +121,7 @@ struct netcp_packet {
boolrxtstamp_complete;
void*ts_context;
 
-   int (*txtstamp_complete)(void *ctx, struct netcp_packet *pkt);
+   void (*txtstamp)(void *ctx, struct sk_buff *skb);
 };
 
 static inline u32 *netcp_push_psdata(struct netcp_packet *p_info,
diff --git a/drivers/net/ethernet/ti/netcp_core.c 
b/drivers/net/ethernet/ti/netcp_core.c
index 3251666..a740e60 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -100,6 +100,11 @@ struct netcp_intf_modpriv {
void*module_priv;
 };
 
+struct netcp_tx_cb {
+   void*ts_context;
+   void(*txtstamp)(void *context, struct sk_buff *skb);
+};
+
 static LIST_HEAD(netcp_devices);
 static LIST_HEAD(netcp_modules);
 static DEFINE_MUTEX(netcp_modules_lock);
@@ -730,6 +735,7 @@ static int netcp_process_one_rx_packet(struct netcp_intf 
*netcp)
 
/* Call each of the RX hooks */
p_info.skb = skb;
+   skb->dev = netcp->ndev;
p_info.rxtstamp_complete = false;
list_for_each_entry(rx_hook, >rxhook_list_head, list) {
int ret;
@@ -987,6 +993,7 @@ static int netcp_process_tx_compl_packets(struct netcp_intf 
*netcp,
  unsigned int budget)
 {
struct knav_dma_desc *desc;
+   struct netcp_tx_cb *tx_cb;
struct sk_buff *skb;
unsigned int dma_sz;
dma_addr_t dma;
@@ -1014,6 +1021,10 @@ static int netcp_process_tx_compl_packets(struct 
netcp_intf *netcp,
continue;
}
 
+   tx_cb = (struct netcp_tx_cb *)skb->cb;
+   if (tx_cb->txtstamp)
+   tx_cb->txtstamp(tx_cb->ts_context, skb);
+
if (netif_subqueue_stopped(netcp->ndev, skb) &&
netif_running(netcp->ndev) &&
(knav_pool_count(netcp->tx_pool) >
@@ -1154,6 +1165,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
struct netcp_tx_pipe *tx_pipe = NULL;
struct netcp_hook_list *tx_hook;
struct netcp_packet p_info;
+   struct netcp_tx_cb *tx_cb;
unsigned int dma_sz;
dma_addr_t dma;
u32 tmp = 0;
@@ -1164,7 +1176,7 @@ static int netcp_tx_submit_skb(struct