Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Apr 2006 14:48:28 -0700 (PDT)
From:      Doug Ambrisko <ambrisko@ambrisko.com>
To:        freebsd-emulation@FreeBSD.ORG
Subject:   Linux emulation enhancement to emulate device nodes and some SCSI stuff
Message-ID:  <200604272148.k3RLmSOm041069@ambrisko.com>

next in thread | raw e-mail | index | archive | help
To get the LSI RAID SAS to work under Linux emulation we need to emulate
more of Linux type stuff.  I've put patches up at:
	http://www.ambrisko.com/doug/linux.patches

I've added back the proc/devices to the emulator although really emulated
since with devfs are majors are not as Linux app's expect.  So I've used a
"linux_ioctl_handle" type paradigm to add a new "linux_device_handle" thing.
Each entry is of type:
  struct linux_device_handler {
	char	*bsd_driver_name;
	char	*linux_driver_name;
	char	*bsd_device_name;
	char	*linux_device_name;
	int	linux_major;
	int	linux_minor;
	int	linux_char_device;
  };

An example of usage is:
  static struct linux_device_handler mfi_device_handler =
	{ "mfi", "megaraid_sas", "mfi0", "megaraid_sas_ioctl_node", -1, 0, 1};

  SYSINIT  (mfi_register2,   SI_SUB_KLD, SI_ORDER_MIDDLE,
	  linux_device_register_handler, &mfi_device_handler);
  SYSUNINIT(mfi_unregister2, SI_SUB_KLD, SI_ORDER_MIDDLE,
	  linux_device_unregister_handler, &mfi_device_handler);

The -1 major means allocate dynamically.  This then shows up in proc/devices
as:

  Character devices:
    1 null
  200 megaraid_sas_ioctl_node

  Block devices:

I needed a entry to /dev/null so I created a static entry for that.

In the new proc/sys there is a class & devices tree.  The devices tree
runs the PCI space sort-of like Linux and builds a tree.  The class/scsi_host
links into that tree.  It only fills in things for PCI storage classes
and fills in the "proc_name" for the driver if known like:
  %cat class/scsi_host/host0/proc_name
  megaraid_sas
  %ls -l class/scsi_host/host0
  total 0
  lr--r--r--  1 root  wheel  0 Apr 27 15:07 device -> ../../../devices/pci0000:03/0001:00.0/0002:0e.0/host0
  -r--r--r--  1 root  wheel  0 Apr 27 15:07 proc_name
  %ls -l devices/pci0000:03/0001:00.0/0002:0e.0
  total 0
  dr-xr-xr-x  1 root  wheel  0 Apr 27 15:07 host0
  %

I had to add code to linux_stat stuff to intercept and return the expected
major/minor number if a device_handler was defined.

With this and some changes to mfi(4) driver I can run the Linux MegaCli
binary from LSI on FreeBSD.

Please let me know how this patch looks.

Note this is following the Linux 2.6 style.

Doug A.



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