diff mbox series

[net-next,v3,1/5] eth: fbnic: add software TX timestamping support

Message ID 20241003123933.2589036-2-vadfed@meta.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series eth: fbnic: add timestamping support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: mohsin.bashr@gmail.com kernel-team@meta.com horms@kernel.org edumazet@google.com
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-06--15-00 (tests: 775)

Commit Message

Vadim Fedorenko Oct. 3, 2024, 12:39 p.m. UTC
Add software TX timestamping support. RX software timestamping is
implemented in the core and there is no need to provide special flag
in the driver anymore.

Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
---
 drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 11 +++++++++++
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c    |  3 +++
 2 files changed, 14 insertions(+)

Comments

Jacob Keller Oct. 4, 2024, 10:55 p.m. UTC | #1
On 10/3/2024 5:39 AM, Vadim Fedorenko wrote:
> Add software TX timestamping support. RX software timestamping is
> implemented in the core and there is no need to provide special flag
> in the driver anymore.
> 
> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
> ---
>  drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 11 +++++++++++
>  drivers/net/ethernet/meta/fbnic/fbnic_txrx.c    |  3 +++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
> index 5d980e178941..ffc773014e0f 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
> @@ -6,6 +6,16 @@
>  #include "fbnic_netdev.h"
>  #include "fbnic_tlv.h"
>  
> +static int
> +fbnic_get_ts_info(struct net_device *netdev,
> +		  struct kernel_ethtool_ts_info *tsinfo)
> +{
> +	tsinfo->so_timestamping =
> +		SOF_TIMESTAMPING_TX_SOFTWARE;
> +
> +	return 0;
> +}
> +

You could use ethtool_op_get_ts_info(), but I imagine future patches
will update this for hardware timestamping, so I don't think thats a big
deal.

I think you *do* still want to report SOF_TIMESTAMPING_RX_SOFTWARE and
SOF_TIMESTAMPING_SOFTWARE to get the API correct... Perhaps that could
be improved in the core stack though.... Or did that already get changed
recently?

You should also set phc_index to -1 until you have a PTP clock device.

>  static void
>  fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
>  {
> @@ -66,6 +76,7 @@ fbnic_get_eth_mac_stats(struct net_device *netdev,
>  
>  static const struct ethtool_ops fbnic_ethtool_ops = {
>  	.get_drvinfo		= fbnic_get_drvinfo,
> +	.get_ts_info		= fbnic_get_ts_info,
>  	.get_eth_mac_stats	= fbnic_get_eth_mac_stats,
>  };
>  
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> index 6a6d7e22f1a7..8337d49bad0b 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> @@ -205,6 +205,9 @@ fbnic_tx_map(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta)
>  
>  	ring->tail = tail;
>  
> +	/* Record SW timestamp */
> +	skb_tx_timestamp(skb);
> +
>  	/* Verify there is room for another packet */
>  	fbnic_maybe_stop_tx(skb->dev, ring, FBNIC_MAX_SKB_DESC);
>
Jacob Keller Oct. 4, 2024, 11:18 p.m. UTC | #2
On 10/4/2024 3:55 PM, Jacob Keller wrote:
> I think you *do* still want to report SOF_TIMESTAMPING_RX_SOFTWARE and
> SOF_TIMESTAMPING_SOFTWARE to get the API correct... Perhaps that could
> be improved in the core stack though.... Or did that already get changed
> recently?
> 

Ah, this did change recently, but the helper ethtool_op_get_ts_info()
was not updated to do the same. :D

For other reviewers who weren't aware, this is true since 12d337339d9f
("ethtool: RX software timestamp for all")
Vadim Fedorenko Oct. 7, 2024, 9:56 a.m. UTC | #3
On 04/10/2024 23:55, Jacob Keller wrote:
> 
> 
> On 10/3/2024 5:39 AM, Vadim Fedorenko wrote:
>> Add software TX timestamping support. RX software timestamping is
>> implemented in the core and there is no need to provide special flag
>> in the driver anymore.
>>
>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>> ---
>>   drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 11 +++++++++++
>>   drivers/net/ethernet/meta/fbnic/fbnic_txrx.c    |  3 +++
>>   2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>> index 5d980e178941..ffc773014e0f 100644
>> --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>> @@ -6,6 +6,16 @@
>>   #include "fbnic_netdev.h"
>>   #include "fbnic_tlv.h"
>>   
>> +static int
>> +fbnic_get_ts_info(struct net_device *netdev,
>> +		  struct kernel_ethtool_ts_info *tsinfo)
>> +{
>> +	tsinfo->so_timestamping =
>> +		SOF_TIMESTAMPING_TX_SOFTWARE;
>> +
>> +	return 0;
>> +}
>> +
> 
> You could use ethtool_op_get_ts_info(), but I imagine future patches
> will update this for hardware timestamping, so I don't think thats a big
> deal.
> 
> I think you *do* still want to report SOF_TIMESTAMPING_RX_SOFTWARE and
> SOF_TIMESTAMPING_SOFTWARE to get the API correct... Perhaps that could
> be improved in the core stack though.... Or did that already get changed
> recently?

Yeah, as you found in the next mail, software RX timestamping was moved
to the core recently.

> You should also set phc_index to -1 until you have a PTP clock device.

That's definitely missing, thanks! I'll add it to the next version.

> 
>>   static void
>>   fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
>>   {
>> @@ -66,6 +76,7 @@ fbnic_get_eth_mac_stats(struct net_device *netdev,
>>   
>>   static const struct ethtool_ops fbnic_ethtool_ops = {
>>   	.get_drvinfo		= fbnic_get_drvinfo,
>> +	.get_ts_info		= fbnic_get_ts_info,
>>   	.get_eth_mac_stats	= fbnic_get_eth_mac_stats,
>>   };
>>   
>> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
>> index 6a6d7e22f1a7..8337d49bad0b 100644
>> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
>> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
>> @@ -205,6 +205,9 @@ fbnic_tx_map(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta)
>>   
>>   	ring->tail = tail;
>>   
>> +	/* Record SW timestamp */
>> +	skb_tx_timestamp(skb);
>> +
>>   	/* Verify there is room for another packet */
>>   	fbnic_maybe_stop_tx(skb->dev, ring, FBNIC_MAX_SKB_DESC);
>>   
>
Jacob Keller Oct. 7, 2024, 11:52 p.m. UTC | #4
On 10/7/2024 2:56 AM, Vadim Fedorenko wrote:
> On 04/10/2024 23:55, Jacob Keller wrote:
>>
>>
>> On 10/3/2024 5:39 AM, Vadim Fedorenko wrote:
>>> Add software TX timestamping support. RX software timestamping is
>>> implemented in the core and there is no need to provide special flag
>>> in the driver anymore.
>>>
>>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>>> ---
>>>   drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 11 +++++++++++
>>>   drivers/net/ethernet/meta/fbnic/fbnic_txrx.c    |  3 +++
>>>   2 files changed, 14 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>>> index 5d980e178941..ffc773014e0f 100644
>>> --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>>> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
>>> @@ -6,6 +6,16 @@
>>>   #include "fbnic_netdev.h"
>>>   #include "fbnic_tlv.h"
>>>   
>>> +static int
>>> +fbnic_get_ts_info(struct net_device *netdev,
>>> +		  struct kernel_ethtool_ts_info *tsinfo)
>>> +{
>>> +	tsinfo->so_timestamping =
>>> +		SOF_TIMESTAMPING_TX_SOFTWARE;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>
>> You could use ethtool_op_get_ts_info(), but I imagine future patches
>> will update this for hardware timestamping, so I don't think thats a big
>> deal.
>>
>> I think you *do* still want to report SOF_TIMESTAMPING_RX_SOFTWARE and
>> SOF_TIMESTAMPING_SOFTWARE to get the API correct... Perhaps that could
>> be improved in the core stack though.... Or did that already get changed
>> recently?
> 
> Yeah, as you found in the next mail, software RX timestamping was moved
> to the core recently.
> 
>> You should also set phc_index to -1 until you have a PTP clock device.
> 
> That's definitely missing, thanks! I'll add it to the next version.
> 

Since I had missed this, I reviewed the patch that changed Rx timestamp
to the core. It also initialized PHC index to -1 automatically so it
shouldn't be necessary.

Apologies for the misleading comment.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 5d980e178941..ffc773014e0f 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -6,6 +6,16 @@ 
 #include "fbnic_netdev.h"
 #include "fbnic_tlv.h"
 
+static int
+fbnic_get_ts_info(struct net_device *netdev,
+		  struct kernel_ethtool_ts_info *tsinfo)
+{
+	tsinfo->so_timestamping =
+		SOF_TIMESTAMPING_TX_SOFTWARE;
+
+	return 0;
+}
+
 static void
 fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 {
@@ -66,6 +76,7 @@  fbnic_get_eth_mac_stats(struct net_device *netdev,
 
 static const struct ethtool_ops fbnic_ethtool_ops = {
 	.get_drvinfo		= fbnic_get_drvinfo,
+	.get_ts_info		= fbnic_get_ts_info,
 	.get_eth_mac_stats	= fbnic_get_eth_mac_stats,
 };
 
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 6a6d7e22f1a7..8337d49bad0b 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -205,6 +205,9 @@  fbnic_tx_map(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta)
 
 	ring->tail = tail;
 
+	/* Record SW timestamp */
+	skb_tx_timestamp(skb);
+
 	/* Verify there is room for another packet */
 	fbnic_maybe_stop_tx(skb->dev, ring, FBNIC_MAX_SKB_DESC);