From nobody@FreeBSD.org  Thu Oct  7 22:37:08 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 21D9F16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Oct 2004 22:37:08 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1497D43D1D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Oct 2004 22:37:08 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i97Mb78p058956
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 7 Oct 2004 22:37:07 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i97Mb7EM058953;
	Thu, 7 Oct 2004 22:37:07 GMT
	(envelope-from nobody)
Message-Id: <200410072237.i97Mb7EM058953@www.freebsd.org>
Date: Thu, 7 Oct 2004 22:37:07 GMT
From: Henry Miller <hmiller@intradyn.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: AMR raid, amrreg.h struct amr_enquery3 ae_driveformat should be u_int8_t
X-Send-Pr-Version: www-2.3

>Number:         72433
>Category:       kern
>Synopsis:       [amr] [patch] AMR raid, amrreg.h struct amr_enquery3 ae_driveformat should be u_int8_t
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 07 22:40:32 GMT 2004
>Closed-Date:    
>Last-Modified:  Sun Oct 23 19:44:37 GMT 2005
>Originator:     Henry Miller
>Release:        4.9-release
>Organization:
Intradyn, Inc
>Environment:
uname -a    
  FreeBSD 4.9-RELEASE-p10 FreeBSD 4.9-RELEASE-p10 #0: Wed Jun 23 10:16:26 CDT 2004     root@chan.hq.intradyn.com:/usr/src/sys/compile/RV1U  i386

from adapter:
Adapter Name    = MegaRAID SATA 150-4D
The Firmware Version    = 712T
The BIOS Version        = G116
>Description:
This is seen in the source code of current as well.


in sys/dev/arm/amrreg.h
struct amr_enquiry3
the field ae_driveformat is listed as u_int16_t workign with real hardware, it appears that this field should be u_int8_t.  

>How-To-Repeat:
Wrote a simple program to send an ioctl:  
  struct amr_user_ioctl cmd;
  struct amr_enquiry3 ae;
  memset(&cmd,0,sizeof(struct amr_user_ioctl));
  memset(&ae,0,sizeof(struct amr_enquiry3));
  cmd.au_cmd[0] = AMR_CMD_CONFIG;
  cmd.au_cmd[1] = AMR_CONFIG_ENQ3;
  cmd.au_buffer = &ae; 
  cmd.au_length = sizeof(struct amr_enquiry3);
  cmd.au_direction  = AMR_IO_READ;
  open("/dev/amr0",O_RDONLY);
  ioctl(fd,AMR_IO_COMMAND,&cmd);
  printf("%x %x %x\n",ae.ae_driveformat[0],
    ae.ae_driveformat[1],ae.ae_driveformat[2]);
     
on a normal array with 4 drive (0-3) this resulted in
3333 5333 0          (note, drive 2 was failed in a previous test)
After removing drive 1:
3433 5333 0
after replacing drive
4533 5333 0

Expected results should be
33 45 53   
>Fix:
     Change the type.  However it is not known how this change will affect the overall size of the structure.  I do not have docs from LSIlogic so I do not know if there are any potential problems there.
>Release-Note:
>Audit-Trail:

From: "Henry Miller" <hmiller@intradyn.com>
To: freebsd-gnats-submit@FreeBSD.org, hmiller@intradyn.com
Cc:  
Subject: Re: kern/72433: AMR raid, amrreg.h struct amr_enquery3
  ae_driveformat should be u_int8_t
Date: Fri, 08 Oct 2004 08:07:07 -0500

 As further evidence, on my info
 machine 
 ae_driveformat[184] is 37.   (value changes from time to time, I'm not sure=
  what it represents, but clearly not a drive)
 
 also, I've since pulled drive 0 from the array, (after rebuilding drive 1)=
  and 
 ae_driveformat[0] =3D=3D 0x5334
 
>Unformatted:
