[RFC v3 3/3] examples/ptpclient: add frequency adjustment support

Ferruh Yigit ferruh.yigit at amd.com
Fri Jun 2 21:52:43 CEST 2023


On 5/22/2023 2:23 PM, Simei Su wrote:
> This patch applys PI servo algorithm to leverage frequency adjustment
> API to improve PTP timesync accuracy.
> 
> The command for starting ptpclient with PI algorithm is:
> ./build/examples/dpdk-ptpclient -a 0000:81:00.0 -c 1 -n 3 -- -T 0 -p 0x1
> --controller=pi
> 
> Signed-off-by: Simei Su <simei.su at intel.com>
> Signed-off-by: Wenjun Wu <wenjun1.wu at intel.com>
> ---
>  examples/ptpclient/ptpclient.c | 178 +++++++++++++++++++++++++++++++++++++----
>  1 file changed, 161 insertions(+), 17 deletions(-)
> 

<...>

> +
> +enum controller_mode {
> +	MODE_NONE,
> +	MODE_PI,
> +	MAX_ALL
> +} mode;
> +

Better to have 'mode' variable as 'static', can be good to split enum
and variable declaration.

<...>

> @@ -608,11 +729,14 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
>  			break;
>  		case FOLLOW_UP:
>  			parse_fup(&ptp_data);
> +			if (mode == MODE_PI)
> +				ptp_adjust_freq(&ptp_data);
>  			send_delay_request(&ptp_data);
>  			break;
>  		case DELAY_RESP:
>  			parse_drsp(&ptp_data);
> -			ptp_adjust_time(&ptp_data);
> +			if (mode == MODE_NONE)
> +				ptp_adjust_time(&ptp_data);
>  			print_clock_info(&ptp_data);
>  			break;
>  		default:
>  

Why with FOLLOW_UP PTP message only frequency adjustment done,
and with DELAY_RESP PTP message only time adjustment done?

Is this related to he PTP protocol, or your design decision?



More information about the dev mailing list