Deleted Added
full compact
ips.c (119418) ips.c (122999)
1/*-
2 * Written by: David Jeffery
3 * Copyright (c) 2002 Adaptec Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Written by: David Jeffery
3 * Copyright (c) 2002 Adaptec Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/ips/ips.c 119418 2003-08-24 17:55:58Z obrien $");
29__FBSDID("$FreeBSD: head/sys/dev/ips/ips.c 122999 2003-11-27 08:37:36Z mbr $");
30
31#include <dev/ips/ips.h>
32#include <sys/stat.h>
33#include <sys/time.h>
34#include <machine/clock.h>
35
36static d_open_t ips_open;
37static d_close_t ips_close;
38static d_ioctl_t ips_ioctl;
39
40#define IPS_CDEV_MAJOR 175
41static struct cdevsw ips_cdevsw = {
42 .d_open = ips_open,
43 .d_close = ips_close,
44 .d_ioctl = ips_ioctl,
45 .d_name = "ips",
46 .d_maj = IPS_CDEV_MAJOR,
47};
48
30
31#include <dev/ips/ips.h>
32#include <sys/stat.h>
33#include <sys/time.h>
34#include <machine/clock.h>
35
36static d_open_t ips_open;
37static d_close_t ips_close;
38static d_ioctl_t ips_ioctl;
39
40#define IPS_CDEV_MAJOR 175
41static struct cdevsw ips_cdevsw = {
42 .d_open = ips_open,
43 .d_close = ips_close,
44 .d_ioctl = ips_ioctl,
45 .d_name = "ips",
46 .d_maj = IPS_CDEV_MAJOR,
47};
48
49static const char* ips_adapter_name[] = {
50 "N/A",
51 "ServeRAID (copperhead)",
52 "ServeRAID II (copperhead refresh)",
53 "ServeRAID onboard (copperhead)",
54 "ServeRAID onboard (copperhead)",
55 "ServeRAID 3H (clarinet)",
56 "ServeRAID 3L (clarinet lite)",
57 "ServeRAID 4H (trombone)",
58 "ServeRAID 4M (morpheus)",
59 "ServeRAID 4L (morpheus lite)",
60 "ServeRAID 4Mx (neo)",
61 "ServeRAID 4Lx (neo lite)",
62 "ServeRAID 5i II (sarasota)",
63 "ServeRAID 5i (sarasota)",
64 "ServeRAID 6M (marco)",
65 "ServeRAID 6i (sebring)"
66};
49
67
68
50static int ips_open(dev_t dev, int flags, int fmt, struct thread *td)
51{
52 ips_softc_t *sc = dev->si_drv1;
53 sc->state |= IPS_DEV_OPEN;
54 return 0;
55}
56
57static int ips_close(dev_t dev, int flags, int fmt, struct thread *td)

--- 177 unchanged lines hidden (view full) ---

235 intrmask_t mask;
236 mask = splbio();
237 SLIST_INSERT_HEAD(&sc->free_cmd_list, command, next);
238 (sc->used_commands)--;
239 splx(mask);
240 if(!(sc->state & IPS_TIMEOUT))
241 ips_run_waiting_command(sc);
242}
69static int ips_open(dev_t dev, int flags, int fmt, struct thread *td)
70{
71 ips_softc_t *sc = dev->si_drv1;
72 sc->state |= IPS_DEV_OPEN;
73 return 0;
74}
75
76static int ips_close(dev_t dev, int flags, int fmt, struct thread *td)

--- 177 unchanged lines hidden (view full) ---

254 intrmask_t mask;
255 mask = splbio();
256 SLIST_INSERT_HEAD(&sc->free_cmd_list, command, next);
257 (sc->used_commands)--;
258 splx(mask);
259 if(!(sc->state & IPS_TIMEOUT))
260 ips_run_waiting_command(sc);
261}
262static const char* ips_diskdev_statename(u_int8_t state)
263{
264 static char statebuf[20];
265 switch(state){
266 case IPS_LD_OFFLINE:
267 return("OFFLINE");
268 break;
269 case IPS_LD_OKAY:
270 return("OK");
271 break;
272 case IPS_LD_DEGRADED:
273 return("DEGRADED");
274 break;
275 case IPS_LD_FREE:
276 return("FREE");
277 break;
278 case IPS_LD_SYS:
279 return("SYS");
280 break;
281 case IPS_LD_CRS:
282 return("CRS");
283 break;
284 }
285 sprintf(statebuf,"UNKNOWN(0x%02x)", state);
286 return(statebuf);
287}
243
244static int ips_diskdev_init(ips_softc_t *sc)
245{
246 int i;
247 for(i=0; i < IPS_MAX_NUM_DRIVES; i++){
288
289static int ips_diskdev_init(ips_softc_t *sc)
290{
291 int i;
292 for(i=0; i < IPS_MAX_NUM_DRIVES; i++){
248 if(sc->drives[i].state & IPS_LD_OKAY){
293 if(sc->drives[i].state == IPS_LD_FREE) continue;
294 device_printf(sc->dev, "Logical Drive %d: RAID%d sectors: %u, state %s\n",
295 i, sc->drives[i].raid_lvl,
296 sc->drives[i].sector_count,
297 ips_diskdev_statename(sc->drives[i].state));
298 if(sc->drives[i].state == IPS_LD_OKAY ||
299 sc->drives[i].state == IPS_LD_DEGRADED){
249 sc->diskdev[i] = device_add_child(sc->dev, NULL, -1);
250 device_set_ivars(sc->diskdev[i],(void *)(uintptr_t) i);
251 }
252 }
253 if(bus_generic_attach(sc->dev)){
254 device_printf(sc->dev, "Attaching bus failed\n");
255 }
256 return 0;

--- 107 unchanged lines hidden (view full) ---

364 sc->max_cmds = 1;
365 ips_cmdqueue_init(sc);
366 callout_handle_init(&sc->timer);
367
368 if(sc->ips_adapter_reinit(sc, 0))
369 goto error;
370
371 mtx_init(&sc->cmd_mtx, "ips command mutex", NULL, MTX_DEF);
300 sc->diskdev[i] = device_add_child(sc->dev, NULL, -1);
301 device_set_ivars(sc->diskdev[i],(void *)(uintptr_t) i);
302 }
303 }
304 if(bus_generic_attach(sc->dev)){
305 device_printf(sc->dev, "Attaching bus failed\n");
306 }
307 return 0;

--- 107 unchanged lines hidden (view full) ---

415 sc->max_cmds = 1;
416 ips_cmdqueue_init(sc);
417 callout_handle_init(&sc->timer);
418
419 if(sc->ips_adapter_reinit(sc, 0))
420 goto error;
421
422 mtx_init(&sc->cmd_mtx, "ips command mutex", NULL, MTX_DEF);
423
424 /* initialize ffdc values */
425 microtime(&sc->ffdc_resettime);
426 sc->ffdc_resetcount = 1;
427 if ((i = ips_ffdc_reset(sc)) != 0) {
428 device_printf(sc->dev, "failed to send ffdc reset to device (%d)\n", i);
429 goto error;
430 }
372 if ((i = ips_get_adapter_info(sc)) != 0) {
373 device_printf(sc->dev, "failed to get adapter configuration data from device (%d)\n", i);
374 goto error;
375 }
431 if ((i = ips_get_adapter_info(sc)) != 0) {
432 device_printf(sc->dev, "failed to get adapter configuration data from device (%d)\n", i);
433 goto error;
434 }
435 ips_update_nvram(sc); /* no error check as failure doesn't matter */
436 if(sc->adapter_type > 0 && sc->adapter_type <= IPS_ADAPTER_MAX_T){
437 device_printf(sc->dev, "adapter type: %s\n", ips_adapter_name[sc->adapter_type]);
438 }
376 if ((i = ips_get_drive_info(sc)) != 0) {
377 device_printf(sc->dev, "failed to get drive configuration data from device (%d)\n", i);
378 goto error;
379 }
439 if ((i = ips_get_drive_info(sc)) != 0) {
440 device_printf(sc->dev, "failed to get drive configuration data from device (%d)\n", i);
441 goto error;
442 }
380 ips_update_nvram(sc); /* no error check as failure doesn't matter */
381
382 ips_cmdqueue_free(sc);
383 if(sc->adapter_info.max_concurrent_cmds)
384 sc->max_cmds = min(128, sc->adapter_info.max_concurrent_cmds);
385 else
386 sc->max_cmds = 32;
387 if(ips_cmdqueue_init(sc)){
388 device_printf(sc->dev, "failed to initialize command buffers\n");

--- 320 unchanged lines hidden ---
443
444 ips_cmdqueue_free(sc);
445 if(sc->adapter_info.max_concurrent_cmds)
446 sc->max_cmds = min(128, sc->adapter_info.max_concurrent_cmds);
447 else
448 sc->max_cmds = 32;
449 if(ips_cmdqueue_init(sc)){
450 device_printf(sc->dev, "failed to initialize command buffers\n");

--- 320 unchanged lines hidden ---