summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2022-11-08 12:39:04 +0100
committerPaolo Abeni <pabeni@redhat.com>2022-11-08 12:39:04 +0100
commitee1bfbcc71cfac3b570365558cf38cb70f6ca971 (patch)
treeb9c9c03e984d52ed7a24496a39396fe45c5a015f /drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
parentb2140e971309511074933da3edd5bbfcb6d394e5 (diff)
parent85036aee1938d65da4be6ae1bc7e5e7e30b567b9 (diff)
downloadlinux-stable-ee1bfbcc71cfac3b570365558cf38cb70f6ca971.tar.gz
linux-stable-ee1bfbcc71cfac3b570365558cf38cb70f6ca971.tar.bz2
linux-stable-ee1bfbcc71cfac3b570365558cf38cb70f6ca971.zip
Merge branch 'bnxt_en-updates'
Michael Chan says: ==================== bnxt_en: Updates This small patchset adds an improvement to the configuration of ethtool RSS tuple hash and a PTP improvement when running in a multi-host environment. ==================== Link: https://lore.kernel.org/r/1667780192-3700-1-git-send-email-michael.chan@broadcom.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c')
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
index 2132ce63193c..460cb20599f6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
@@ -14,6 +14,7 @@
#include <linux/net_tstamp.h>
#include <linux/timekeeping.h>
#include <linux/ptp_classify.h>
+#include <linux/clocksource.h>
#include "bnxt_hsi.h"
#include "bnxt.h"
#include "bnxt_hwrm.h"
@@ -210,18 +211,37 @@ static int bnxt_ptp_adjfreq(struct ptp_clock_info *ptp_info, s32 ppb)
ptp_info);
struct hwrm_port_mac_cfg_input *req;
struct bnxt *bp = ptp->bp;
- int rc;
+ int rc = 0;
- rc = hwrm_req_init(bp, req, HWRM_PORT_MAC_CFG);
- if (rc)
- return rc;
+ if (!(ptp->bp->fw_cap & BNXT_FW_CAP_PTP_RTC)) {
+ int neg_adj = 0;
+ u32 diff;
+ u64 adj;
- req->ptp_freq_adj_ppb = cpu_to_le32(ppb);
- req->enables = cpu_to_le32(PORT_MAC_CFG_REQ_ENABLES_PTP_FREQ_ADJ_PPB);
- rc = hwrm_req_send(ptp->bp, req);
- if (rc)
- netdev_err(ptp->bp->dev,
- "ptp adjfreq failed. rc = %d\n", rc);
+ if (ppb < 0) {
+ neg_adj = 1;
+ ppb = -ppb;
+ }
+ adj = ptp->cmult;
+ adj *= ppb;
+ diff = div_u64(adj, 1000000000ULL);
+
+ spin_lock_bh(&ptp->ptp_lock);
+ timecounter_read(&ptp->tc);
+ ptp->cc.mult = neg_adj ? ptp->cmult - diff : ptp->cmult + diff;
+ spin_unlock_bh(&ptp->ptp_lock);
+ } else {
+ rc = hwrm_req_init(bp, req, HWRM_PORT_MAC_CFG);
+ if (rc)
+ return rc;
+
+ req->ptp_freq_adj_ppb = cpu_to_le32(ppb);
+ req->enables = cpu_to_le32(PORT_MAC_CFG_REQ_ENABLES_PTP_FREQ_ADJ_PPB);
+ rc = hwrm_req_send(ptp->bp, req);
+ if (rc)
+ netdev_err(ptp->bp->dev,
+ "ptp adjfreq failed. rc = %d\n", rc);
+ }
return rc;
}
@@ -846,8 +866,9 @@ static void bnxt_ptp_timecounter_init(struct bnxt *bp, bool init_tc)
memset(&ptp->cc, 0, sizeof(ptp->cc));
ptp->cc.read = bnxt_cc_read;
ptp->cc.mask = CYCLECOUNTER_MASK(48);
- ptp->cc.shift = 0;
- ptp->cc.mult = 1;
+ ptp->cc.shift = BNXT_CYCLES_SHIFT;
+ ptp->cc.mult = clocksource_khz2mult(BNXT_DEVCLK_FREQ, ptp->cc.shift);
+ ptp->cmult = ptp->cc.mult;
ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
}
if (init_tc)