Skip to content

Commit 4012e7d

Browse files
atorguedavem330
authored andcommitted
net: stmmac: handle endianness in dwmac4_get_timestamp
GMAC IP is little-endian and used on several kind of CPU (big or little endian). Main callbacks functions of the stmmac drivers take care about it. It was not the case for dwmac4_get_timestamp function. Fixes: ba1ffd7 ("stmmac: fix PTP support for GMAC4") Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 31a1b8d commit 4012e7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
241241
static int dwmac4_rx_check_timestamp(void *desc)
242242
{
243243
struct dma_desc *p = (struct dma_desc *)desc;
244+
unsigned int rdes0 = le32_to_cpu(p->des0);
245+
unsigned int rdes1 = le32_to_cpu(p->des1);
246+
unsigned int rdes3 = le32_to_cpu(p->des3);
244247
u32 own, ctxt;
245248
int ret = 1;
246249

247-
own = p->des3 & RDES3_OWN;
248-
ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR)
250+
own = rdes3 & RDES3_OWN;
251+
ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR)
249252
>> RDES3_CONTEXT_DESCRIPTOR_SHIFT);
250253

251254
if (likely(!own && ctxt)) {
252-
if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
255+
if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff))
253256
/* Corrupted value */
254257
ret = -EINVAL;
255258
else

0 commit comments

Comments
 (0)