Page MenuHomeFreeBSD

[aacraid] Port driver to big-endian

Authored by luporl on Feb 28 2020, 7:37 PM.



Port aacraid driver to big-endian (BE) hosts.

The immediate goal of this change is to make it possible to use the
aacraid driver on PowerPC64 machines that have Adaptec Series 8 SAS

Adapters supported by this driver expect FIB contents in little-endian
(LE) byte order. All FIBs have a fixed header part as well as a data
part that depends on the command being issued to the controller.

In this way, on BE hosts, the FIB header and all FIB data structures
used in aacraid.c and aacraid_cam.c need to be converted to LE before
being sent to the adapter and converted to BE when coming from it.

The functions to convert each struct are on aacraid_be.c.
For little-endian (LE) targets, they are macros that expand
to nothing.
In some cases, when only a few fields of a large structure are used,
the fields are converted inline, by the code using them.

Test Plan

This change, along with D23667, D23668, and D23859, was tested on FreeBSD's power9-devref machine, that has an Adaptec Series 8 SAS controller attached.
The plan is to also test this on Talos II machines, such as the one in PR 237463 was discovered.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

luporl created this revision.Feb 28 2020, 7:37 PM
luporl edited the summary of this revision. (Show Details)Feb 28 2020, 7:38 PM
emaste added a subscriber: emaste.Mar 1 2020, 8:00 PM
luporl updated this revision to Diff 69067.Mar 2 2020, 1:54 PM
  • enable aacraid module for powerpc
  • add aacraid_be.c in aacraid module's src list
jhibbits added inline comments.
1 ↗(On Diff #69067)

I would name this aacraid_endian.h, or aacraid_fib_endian.h, or similar, along with the accompanying .c file.

10 ↗(On Diff #69067)

I think aacraid_be.c is only needed for big endian platforms, so can be guarded with a MACHINE_CPUARCH == powerpc check (could add mips, too, but who uses mips with aacraid...)

luporl updated this revision to Diff 69164.Mar 4 2020, 5:29 PM
luporl added a reviewer: jhibbits.

Address review's comments

  • renamed aacraid_be.[ch] to aacraid_endian.[ch]
  • moved aacraid_endian.c to conf/files.powerpc
  • moved aacraid device from amd64/conf/NOTES to conf/NOTES
  • include aacraid_endian.c in aacraid.ko for powerpc only
  • added device aacraid to powerpc/conf/GENERIC64, to be able to boot PowerNV machines from aacraid attached disks
luporl marked 2 inline comments as done.Mar 4 2020, 5:32 PM
jhibbits accepted this revision.Mar 4 2020, 9:16 PM
This revision is now accepted and ready to land.Mar 4 2020, 9:16 PM

I did not review in detail but no objection from me, and the approach seems reasonable.

This revision was automatically updated to reflect the committed changes.