Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 2018 09:17:02 +0000 (UTC)
From:      Wojciech Macek <wma@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r327811 - head/sys/dev/cxgbe
Message-ID:  <201801110917.w0B9H2if024045@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wma
Date: Thu Jan 11 09:17:02 2018
New Revision: 327811
URL: https://svnweb.freebsd.org/changeset/base/327811

Log:
  CXGBE: fix get_filt to be endianness-aware
  
  Unconditional 32-bit shift is not endianness-safe.
  Modify the logic to work both on LE and BE.
  
  Submitted by:          Wojciech Macek <wma@freebsd.org>
  Reviewed by:           np
  Obtained from:         Semihalf
  Sponsored by:          IBM, QCM Technologies
  Differential revision: https://reviews.freebsd.org/D13102

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c	Thu Jan 11 07:40:06 2018	(r327810)
+++ head/sys/dev/cxgbe/t4_sge.c	Thu Jan 11 09:17:02 2018	(r327811)
@@ -4754,13 +4754,13 @@ get_flit(struct sglist_seg *segs, int nsegs, int idx)
 
 	switch (idx % 3) {
 	case 0: {
-		__be64 rc;
+		uint64_t rc;
 
-		rc = htobe32(segs[i].ss_len);
+		rc = (uint64_t)segs[i].ss_len << 32;
 		if (i + 1 < nsegs)
-			rc |= (uint64_t)htobe32(segs[i + 1].ss_len) << 32;
+			rc |= (uint64_t)(segs[i + 1].ss_len);
 
-		return (rc);
+		return (htobe64(rc));
 	}
 	case 1:
 		return (htobe64(segs[i].ss_paddr));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801110917.w0B9H2if024045>