[1/3] examples/ptpclient: add the check for PTP capability

Message ID 20220628133959.21381-2-liudongdong3@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series some bugfixes for PTP |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Dongdong Liu June 28, 2022, 1:39 p.m. UTC
  From: Huisong Li <lihuisong@huawei.com>

If a port doesn't support PTP, there is no need to keep running
app. So this patch adds the check for PTP capability.

Signe-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 examples/ptpclient/ptpclient.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 1f1c9c9c52..9689f42f86 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -195,6 +195,11 @@  port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 
 	if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+	else {
+		printf("port(%u) doesn't support PTP: %s\n", port,
+		       strerror(-retval));
+		return -ENOTSUP;
+	}
 
 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=