From ba3826a63a89a9efd73c984cc633bca4bdc2434c Mon Sep 17 00:00:00 2001 From: Shengzhou Liu Date: Tue, 9 Apr 2013 16:04:25 +0800 Subject: powerpc/dpaa_1588: optimization for 1588 performance In case of overloading the slaves, the performace will get worse since there are more and more outdated timestamps accumulated in Tx buffer, so we introduce a way to remove those older timestamps between the current matched one and the tail if they are more than TS_ACCUMULATION_THRESHOLD. In addition, we update the buffer size to 256 which is enough according to stress tests. Signed-off-by: Shengzhou Liu Change-Id: I761dcabf71f27d47627ca835daf28562bfa37319 Reviewed-on: http://git.am.freescale.net:8181/1146 Reviewed-by: Fleming Andrew-AFLEMING Tested-by: Fleming Andrew-AFLEMING diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_1588.c b/drivers/net/ethernet/freescale/dpa/dpaa_1588.c index 8413b1e..89c7f15 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_1588.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_1588.c @@ -147,6 +147,11 @@ static int dpa_ptp_find_and_remove(struct dpa_ptp_circ_buf *ptp_buf, ts->nsec = tmp->ts.nsec; if (idx != tail) { + if (CIRC_CNT(idx, tail, size) > TS_ACCUMULATION_THRESHOLD) { + tail = circ_buf->tail = + (idx - TS_ACCUMULATION_THRESHOLD) & (size - 1); + } + while (CIRC_CNT(idx, tail, size) > 0) { tmp = (struct dpa_ptp_data *)(circ_buf->buf) + idx; idx = (idx - 1) & (size - 1); @@ -584,7 +589,6 @@ int dpa_ptp_init(struct dpa_priv_s *priv) if (!tsu) return -ENOMEM; - memset(tsu, 0, sizeof(*tsu)); tsu->valid = TRUE; tsu->dpa_priv = priv; diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_1588.h b/drivers/net/ethernet/freescale/dpa/dpaa_1588.h index eda0e3a..85e2629 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_1588.h +++ b/drivers/net/ethernet/freescale/dpa/dpaa_1588.h @@ -26,8 +26,8 @@ #include #include -#define DEFAULT_PTP_RX_BUF_SZ 2048 -#define DEFAULT_PTP_TX_BUF_SZ 1024 +#define DEFAULT_PTP_RX_BUF_SZ 256 +#define DEFAULT_PTP_TX_BUF_SZ 256 /* 1588 private ioctl calls */ #define PTP_ENBL_TXTS_IOCTL SIOCDEVPRIVATE @@ -92,6 +92,9 @@ enum { #define DPA_PTP_NOMINAL_FREQ_PERIOD 5 /* 5ns -> 200M */ #define NANOSEC_PER_SECOND 1000000000 +/* The threshold between the current found one and the oldest one */ +#define TS_ACCUMULATION_THRESHOLD 50 + /* Struct needed to identify a timestamp */ struct dpa_ptp_ident { u8 version; -- cgit v0.10.2