net/bnxt: fix timesync when PTP is not supported
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 18 Mar 2021 09:35:23 +0000 (15:05 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 19 Mar 2021 19:29:55 +0000 (20:29 +0100)
Fixed to return error when PTP support is not supported on the port.
Also, removed an unnecessary check inside bnxt_get_rx_ts().

Fixes: b11cceb83a34 ("net/bnxt: support timesync")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c

index 4bdc822..646cc94 100644 (file)
@@ -3399,9 +3399,6 @@ static int bnxt_get_rx_ts(struct bnxt *bp, uint64_t *ts)
        uint16_t port_id;
        uint32_t fifo;
 
-       if (!ptp)
-               return -ENODEV;
-
        fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 +
                                ptp->rx_mapped_regs[BNXT_PTP_RX_FIFO]));
        if (!(fifo & BNXT_PTP_RX_FIFO_PENDING))
@@ -3434,7 +3431,7 @@ bnxt_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
        struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        ns = rte_timespec_to_ns(ts);
        /* Set the timecounters to a new value. */
@@ -3454,7 +3451,7 @@ bnxt_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
        int rc = 0;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        if (BNXT_CHIP_P5(bp))
                rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME,
@@ -3476,7 +3473,7 @@ bnxt_timesync_enable(struct rte_eth_dev *dev)
        int rc;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        ptp->rx_filter = 1;
        ptp->tx_tstamp_en = 1;
@@ -3517,7 +3514,7 @@ bnxt_timesync_disable(struct rte_eth_dev *dev)
        struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        ptp->rx_filter = 0;
        ptp->tx_tstamp_en = 0;
@@ -3544,7 +3541,7 @@ bnxt_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
        uint64_t ns;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        if (BNXT_CHIP_P5(bp))
                rx_tstamp_cycles = ptp->rx_timestamp;
@@ -3567,7 +3564,7 @@ bnxt_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
        int rc = 0;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        if (BNXT_CHIP_P5(bp))
                rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_PATH_TX,
@@ -3588,7 +3585,7 @@ bnxt_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
        struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
        if (!ptp)
-               return 0;
+               return -ENOTSUP;
 
        ptp->tc.nsec += delta;
        ptp->tx_tstamp_tc.nsec += delta;