Page MenuHomeFreeBSD

Add the mfi(4) ioctl support to mrsas(4)
ClosedPublic

Authored by ambrisko on Aug 24 2022, 10:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 2:44 AM
Unknown Object (File)
Dec 23 2023, 12:26 AM
Unknown Object (File)
Nov 6 2023, 4:45 AM
Unknown Object (File)
Oct 31 2023, 6:59 AM
Unknown Object (File)
Oct 5 2023, 3:29 AM
Unknown Object (File)
Oct 1 2023, 3:30 AM
Unknown Object (File)
Sep 29 2023, 3:59 AM
Unknown Object (File)
Sep 11 2023, 6:57 PM
Subscribers

Details

Summary

The hardware supported by mfi(4) and mrsas(4) use the same dcmd's.
mfiutil(8) in theory could run on controlled attached to mrsas(4).
It can't since mrsas(4) doesn't have support for the FreeBSD mfi(4)
ioctl. Porting the ioctl from mfi(4) to mrsas(4) would be the first
step in making mrsasutil(8) which is an additional name for mfiutil(8)
but opens /dev/mrsasX instead of /dev/mfiX

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265794
Tested by: Dan Mahoney <freebsd@gushi.org>

Test Plan

This provides the FreeBSD mfi(4) ioctl in mrsas(4) so that mfiutil(8) can run with mrsas(4). This enables https://reviews.freebsd.org/D36343. I've tested with mrsasutil(8) on various cards over the years and others have found it useful to add to FreeBSD src.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ambrisko added reviewers: imp, emaste.
sys/dev/mrsas/mrsas.c
1453

it looks like mrsas_get_softc_instance already has logic to return dev->si_drv1 in certain cases, maybe this logic should be there instead?

static struct mrsas_softc *
mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg)
{
        struct mrsas_softc *sc = NULL;
        struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;

        if (cmd == MRSAS_IOC_GET_PCI_INFO) {
                sc = dev->si_drv1;
        } else {
...
sys/dev/mrsas/mrsas.c
1453

I could tweak mrsas_get_softc_instance to also include:

if (cmd == MRSAS_IOC_GET_PCI_INFO || cmd == MFIIO_PASSTHRU) {
         sc = dev->si_drv1;
 } else {

and then use it. I'm not sure if that is helpful or might add to more confusion. I tried to keep the MFI compat. part more localized to mrsas_ioctl. Myself, I would get rid of mrsas_get_softc_instance since this is the only usage and depends on the cmd etc. but that is what the existing code was from Broadcom. I'm not sure if they care much about the legacy HW since they have a new mpi3mr driver for newer HW.

jhb added a subscriber: jhb.
jhb added inline comments.
sys/dev/mrsas/mrsas.c
1453

I think either approach is fine. If you wanted to patch mrsas_get_softc_instance I would maybe turn the if into a switch so it is easier to add new ioctls to that case in the future with a default case for the "lookup by index" case.

This revision is now accepted and ready to land.Apr 18 2023, 10:02 PM
This revision was automatically updated to reflect the committed changes.