amrctl.c revision 1.8 1 /* $NetBSD: amrctl.c,v 1.8 2012/05/18 13:59:23 jakllsch Exp $ */
2
3 /*-
4 * Copyright (c) 2002, Pierre David <Pierre.David (at) crc.u-strasbg.fr>
5 * Copyright (c) 2006, Jung-uk Kim <jkim (at) FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice unmodified, this list of conditions, and the following
13 * disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include <sys/cdefs.h>
31 #ifndef lint
32 __RCSID("$NetBSD: amrctl.c,v 1.8 2012/05/18 13:59:23 jakllsch Exp $");
33 #endif
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <fcntl.h>
39 #include <err.h>
40 #include <errno.h>
41 #include <unistd.h>
42
43 #include <sys/ioctl.h>
44
45 #include <machine/param.h>
46
47 #include <dev/pci/amrio.h>
48 #include <dev/pci/amrreg.h>
49
50 #define NATTEMPTS 5
51 #define SLEEPTIME 100000 /* microseconds */
52
53 static int nattempts = NATTEMPTS; /* # of attempts before giving up */
54 static int sleeptime = SLEEPTIME; /* between attempts, in ms */
55
56 #define AMR_BUFSIZE 1024
57
58 static int enq_result = AMR_STATUS_FAILED;
59 static char enq_buffer[AMR_BUFSIZE];
60
61 #define AMR_MAX_NCTRLS 16
62 #define AMR_MAX_NSDEVS 16
63
64 static uint8_t nschan = 0;
65
66 /*
67 * Include lookup tables, and a function to match a code to a string.
68 *
69 * XXX Lookup tables cannot be included, since they require symbols from
70 * amrreg.h which need in turn the _KERNEL define.
71 */
72
73 /* #define AMR_DEFINE_TABLES */
74 /* #include "amr_tables.h" */
75
76 static int amr_ioctl_enquiry(int, uint8_t, uint8_t, uint8_t);
77 __dead static void usage(const char *);
78 static int describe_card(int, int, int);
79 static char * describe_property(uint8_t, char *);
80 static const char * describe_state(int, uint8_t);
81 static void describe_battery(int, int, int, int, int);
82 static void describe_one_volume(int, int, uint32_t, uint8_t, uint8_t);
83 static void describe_one_drive(int, int, uint8_t);
84 static void describe_drive(int, int, int, int, int);
85
86 /*
87 * Offsets in an amr_user_ioctl.au_cmd [] array See amrio.h
88 */
89
90 #define MB_COMMAND 0
91 #define MB_CHANNEL 1
92 #define MB_PARAM 2
93 #define MB_PAD 3
94 #define MB_DRIVE 4
95
96 #define FIRMWARE_40LD 1
97 #define FIRMWARE_8LD 2
98
99 static const struct {
100 const char *product;
101 const uint32_t signature;
102 } prodtable[] = {
103 { "Series 431", AMR_SIG_431 },
104 { "Series 438", AMR_SIG_438 },
105 { "Series 762", AMR_SIG_762 },
106 { "Integrated HP NetRAID (T5)", AMR_SIG_T5 },
107 { "Series 466", AMR_SIG_466 },
108 { "Series 467", AMR_SIG_467 },
109 { "Integrated HP NetRAID (T7)", AMR_SIG_T7 },
110 { "Series 490", AMR_SIG_490 }
111 };
112
113 static const struct {
114 const int code;
115 const char *ifyes, *ifno;
116 } proptable[] = {
117 { AMR_DRV_WRITEBACK,
118 "writeback", "write-through" },
119 { AMR_DRV_READHEAD,
120 "read-ahead", "no-read-ahead" },
121 { AMR_DRV_ADAPTIVE,
122 "adaptative-io", "no-adaptative-io" }
123 };
124
125 static const struct {
126 const int code;
127 const char *status;
128 } statetable[] = {
129 { AMR_DRV_OFFLINE, "offline" },
130 { AMR_DRV_DEGRADED, "degraded" },
131 { AMR_DRV_OPTIMAL, "optimal" },
132 { AMR_DRV_ONLINE, "online" },
133 { AMR_DRV_FAILED, "failed" },
134 { AMR_DRV_REBUILD, "rebuild" },
135 { AMR_DRV_HOTSPARE, "hotspare" }
136 };
137
138 static const struct {
139 const uint8_t code;
140 const char *status;
141 } battable[] = {
142 { AMR_BATT_MODULE_MISSING, "not present" },
143 { AMR_BATT_LOW_VOLTAGE, "low voltage" },
144 { AMR_BATT_TEMP_HIGH, "high temperature" },
145 { AMR_BATT_PACK_MISSING, "pack missing" },
146 { AMR_BATT_CYCLES_EXCEEDED, "cycle exceeded" }
147 };
148
149 static const struct {
150 const uint8_t code;
151 const char *status;
152 } bcstatble[] = {
153 { AMR_BATT_CHARGE_DONE, "charge done" },
154 { AMR_BATT_CHARGE_INPROG, "charge in progress" },
155 { AMR_BATT_CHARGE_FAIL, "charge failed" }
156 };
157
158 static int
159 amr_ioctl_enquiry(int fd, uint8_t cmd, uint8_t cmdsub, uint8_t cmdqual)
160 {
161 struct amr_user_ioctl am;
162 int r, i;
163
164 am.au_cmd[MB_COMMAND] = cmd;
165 am.au_cmd[MB_CHANNEL] = cmdsub;
166 am.au_cmd[MB_PARAM] = cmdqual;
167 am.au_cmd[MB_PAD] = 0;
168 am.au_cmd[MB_DRIVE] = 0;
169
170 am.au_buffer = enq_buffer;
171 am.au_length = AMR_BUFSIZE;
172 am.au_direction = AMR_IO_READ;
173 am.au_status = 0;
174
175 i = 0;
176 r = -1;
177 while (i < nattempts && r == -1) {
178 r = ioctl(fd, AMR_IO_COMMAND, &am);
179 if (r == -1) {
180 if (errno != EBUSY) {
181 err(EXIT_FAILURE, "ioctl enquiry");
182 } else
183 usleep(sleeptime);
184 }
185 i++;
186 }
187 return am.au_status;
188 }
189
190 static void
191 usage(const char *prog)
192 {
193 fprintf(stderr, "usage: %s stat [-a num] [-b] "
194 "[-c ctlr|-f dev] [-g] [-l vol]\n\t\t"
195 "[-p drive|-s bus[:target]] [-t usec] [-v]\n\n\t"
196 "-a num\t\tnumber of retries\n\t"
197 "-b\t\tbattery status\n\t"
198 "-c ctrl\t\tcontroller ID\n\t"
199 "-f dev\t\tdevice path\n\t"
200 "-g\t\tprint global parameters\n\t"
201 "-l vol\t\tlogical volume ID\n\t"
202 "-p drive\tphysical drive ID\n\t"
203 "-s bus[:target]\tSCSI bus (and optinal target)\n\t"
204 "-t usec\t\tsleep time between retries\n\t"
205 "-v\t\tverbose output\n",
206 prog);
207 exit(1);
208 }
209
210 /******************************************************************************
211 * Card description
212 */
213
214 static int
215 describe_card(int fd, int verbosity, int globalparam)
216 {
217 struct amr_enquiry *ae;
218 uint32_t cardtype;
219
220 /*
221 * Try the 40LD firmware interface
222 */
223
224 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG,
225 AMR_CONFIG_PRODUCT_INFO, 0);
226 if (enq_result == AMR_STATUS_SUCCESS) {
227 struct amr_prodinfo *ap;
228
229 ap = (struct amr_prodinfo *)enq_buffer;
230 nschan = ap->ap_nschan;
231 if (globalparam) {
232 printf("Product\t\t\t<%.80s>\n", ap->ap_product);
233 printf("Firmware\t\t%.16s\n", ap->ap_firmware);
234 printf("BIOS\t\t\t%.16s\n", ap->ap_bios);
235 printf("SCSI channels\t\t%d\n", ap->ap_nschan);
236 printf("Fibre loops\t\t%d\n", ap->ap_fcloops);
237 printf("Memory size\t\t%d MB\n", ap->ap_memsize);
238 if (verbosity >= 1) {
239 printf("Ioctl\t\t\t%d (%s)\n", FIRMWARE_40LD,
240 "40LD");
241 printf("Signature\t\t0x%08x\n",
242 ap->ap_signature);
243 printf("Configsig\t\t0x%08x\n",
244 ap->ap_configsig);
245 printf("Subsystem\t\t0x%04x\n",
246 ap->ap_subsystem);
247 printf("Subvendor\t\t0x%04x\n",
248 ap->ap_subvendor);
249 printf("Notify counters\t\t%d\n",
250 ap->ap_numnotifyctr);
251 }
252 }
253 return FIRMWARE_40LD;
254 }
255 /*
256 * Try the 8LD firmware interface
257 */
258
259 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_EXT_ENQUIRY2, 0, 0);
260 ae = (struct amr_enquiry *)enq_buffer;
261 if (enq_result == AMR_STATUS_SUCCESS) {
262 cardtype = ae->ae_signature;
263 } else {
264 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_ENQUIRY, 0, 0);
265 cardtype = 0;
266 }
267
268 if (enq_result == AMR_STATUS_SUCCESS) {
269
270 if (globalparam) {
271 const char *product = NULL;
272 char bios[100], firmware[100];
273 size_t i;
274
275 for (i = 0; i < __arraycount(prodtable); i++) {
276 if (cardtype == prodtable[i].signature) {
277 product = prodtable[i].product;
278 break;
279 }
280 }
281 if (product == NULL)
282 product = "unknown card signature";
283
284 /*
285 * HP NetRaid controllers have a special encoding of
286 * the firmware and BIOS versions. The AMI version
287 * seems to have it as strings whereas the HP version
288 * does it with a leading uppercase character and two
289 * binary numbers.
290 */
291
292 if (ae->ae_adapter.aa_firmware[2] >= 'A' &&
293 ae->ae_adapter.aa_firmware[2] <= 'Z' &&
294 ae->ae_adapter.aa_firmware[1] < ' ' &&
295 ae->ae_adapter.aa_firmware[0] < ' ' &&
296 ae->ae_adapter.aa_bios[2] >= 'A' &&
297 ae->ae_adapter.aa_bios[2] <= 'Z' &&
298 ae->ae_adapter.aa_bios[1] < ' ' &&
299 ae->ae_adapter.aa_bios[0] < ' ') {
300
301 /*
302 * looks like we have an HP NetRaid version
303 * of the MegaRaid
304 */
305
306 if (cardtype == AMR_SIG_438) {
307 /*
308 * the AMI 438 is a NetRaid 3si in
309 * HP-land
310 */
311 product = "HP NetRaid 3si";
312 }
313 sprintf(firmware, "%c.%02d.%02d",
314 ae->ae_adapter.aa_firmware[2],
315 ae->ae_adapter.aa_firmware[1],
316 ae->ae_adapter.aa_firmware[0]);
317 sprintf(bios, "%c.%02d.%02d",
318 ae->ae_adapter.aa_bios[2],
319 ae->ae_adapter.aa_bios[1],
320 ae->ae_adapter.aa_bios[0]);
321 } else {
322 sprintf(firmware, "%.4s",
323 ae->ae_adapter.aa_firmware);
324 sprintf(bios, "%.4s", ae->ae_adapter.aa_bios);
325 }
326
327 printf("Ioctl = %d (%s)\n", FIRMWARE_8LD, "8LD");
328 printf("Product =\t<%s>\n", product);
329 printf("Firmware =\t%s\n", firmware);
330 printf("BIOS =\t%s\n", bios);
331 /* printf ("SCSI Channels =\t%d\n", ae->ae_nschan); */
332 /* printf ("Fibre Loops =\t%d\n", ae->ae_fcloops); */
333 printf("Memory size =\t%d MB\n",
334 ae->ae_adapter.aa_memorysize);
335 /*
336 * printf ("Notify counters =\t%d\n",
337 * ae->ae_numnotifyctr) ;
338 */
339 }
340 return FIRMWARE_8LD;
341 }
342 /*
343 * Neither firmware interface succeeded. Abort.
344 */
345
346 fprintf(stderr, "Firmware interface not supported\n");
347 exit(1);
348
349 }
350
351 static char *
352 describe_property(uint8_t prop, char *buffer)
353 {
354 size_t i;
355
356 strcpy(buffer, "<");
357 for (i = 0; i < __arraycount(proptable); i++) {
358 if (i > 0)
359 strcat(buffer, ",");
360 if (prop & proptable[i].code)
361 strcat(buffer, proptable[i].ifyes);
362 else
363 strcat(buffer, proptable[i].ifno);
364 }
365 strcat(buffer, ">");
366
367 return buffer;
368 }
369
370 static const char *
371 describe_state(int verbosity, uint8_t state)
372 {
373 size_t i;
374
375 if ((AMR_DRV_PREVSTATE(state) == AMR_DRV_CURSTATE(state)) &&
376 (AMR_DRV_CURSTATE(state) == AMR_DRV_OFFLINE) && verbosity == 0)
377 return NULL;
378
379 for (i = 0; i < __arraycount(statetable); i++)
380 if (AMR_DRV_CURSTATE(state) == statetable[i].code)
381 return (statetable[i].status);
382
383 return NULL;
384 }
385
386 /******************************************************************************
387 * Battery status
388 */
389 static void
390 describe_battery(int fd, int verbosity, int fwint, int bflags, int globalparam)
391 {
392 uint8_t batt_status;
393 size_t i;
394
395 if (fwint == FIRMWARE_40LD) {
396 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG,
397 AMR_CONFIG_ENQ3, AMR_CONFIG_ENQ3_SOLICITED_FULL);
398 if (enq_result == AMR_STATUS_SUCCESS) {
399 struct amr_enquiry3 *ae3;
400
401 ae3 = (struct amr_enquiry3 *)enq_buffer;
402 if (bflags || globalparam) {
403 batt_status = ae3->ae_batterystatus;
404 printf("Battery status\t\t");
405 for (i = 0; i < __arraycount(battable); i++) {
406 if (batt_status & battable[i].code)
407 printf("%s, ", battable[i].status);
408 }
409 if (!(batt_status &
410 (AMR_BATT_MODULE_MISSING|AMR_BATT_PACK_MISSING))) {
411 for (i = 0;
412 i < __arraycount(bcstatble); i++)
413 if (bcstatble[i].code ==
414 (batt_status & AMR_BATT_CHARGE_MASK))
415 printf("%s", bcstatble[i].status);
416 } else
417 printf("charge unknown");
418 if (verbosity)
419 printf(" (0x%02x)", batt_status);
420 printf("\n");
421 }
422 }
423 } else if (fwint == FIRMWARE_8LD) {
424 /* Nothing to do here. */
425 return;
426 } else {
427 fprintf(stderr, "Firmware interface not supported.\n");
428 exit(1);
429 }
430
431 return;
432 }
433
434 /******************************************************************************
435 * Logical volumes
436 */
437
438 static void
439 describe_one_volume(int ldrv, int verbosity,
440 uint32_t size, uint8_t state, uint8_t prop)
441 {
442 float szgb;
443 int raid_level;
444 char propstr[MAXPATHLEN];
445 const char *statestr;
446
447 szgb = ((float)size) / (1024 * 1024 * 2); /* size in GB */
448
449 raid_level = prop & AMR_DRV_RAID_MASK;
450
451 printf("Logical volume %d\t", ldrv);
452 statestr = describe_state(verbosity, state);
453 printf("%s ", statestr);
454 printf("(%.2f GB, RAID%d", szgb, raid_level);
455 if (verbosity >= 1) {
456 describe_property(prop, propstr);
457 printf(" %s", propstr);
458 }
459 printf(")\n");
460 }
461
462 /******************************************************************************
463 * Physical drives
464 */
465
466 static void
467 describe_one_drive(int pdrv, int verbosity, uint8_t state)
468 {
469 const char *statestr;
470
471 statestr = describe_state(verbosity, state);
472 if (statestr) {
473 if (nschan > 0)
474 printf("Physical drive %d:%d\t%s\n",
475 pdrv / AMR_MAX_NSDEVS, pdrv % AMR_MAX_NSDEVS,
476 statestr);
477 else
478 printf("Physical drive %d:\t%s\n", pdrv, statestr);
479 }
480 }
481
482 static void
483 describe_drive(int verbosity, int fwint, int ldrv, int sbus, int sdev)
484 {
485 int drv, pdrv = -1;
486
487 if (sbus > -1 && sdev > -1)
488 pdrv = (sbus * AMR_MAX_NSDEVS) + sdev;
489 if (nschan != 0) {
490 if (sbus > -1 && sbus >= nschan) {
491 fprintf(stderr, "SCSI channel %d does not exist.\n", sbus);
492 exit(1);
493 } else if (sdev > -1 && sdev >= AMR_MAX_NSDEVS) {
494 fprintf(stderr, "SCSI device %d:%d does not exist.\n",
495 sbus, sdev);
496 exit(1);
497 }
498 }
499 if (fwint == FIRMWARE_40LD) {
500 if (enq_result == AMR_STATUS_SUCCESS) {
501 struct amr_enquiry3 *ae3;
502
503 ae3 = (struct amr_enquiry3 *)enq_buffer;
504 if ((ldrv < 0 && sbus < 0) || ldrv >= 0) {
505 if (ldrv >= ae3->ae_numldrives) {
506 fprintf(stderr, "Logical volume %d "
507 "does not exist.\n", ldrv);
508 exit(1);
509 }
510 if (ldrv < 0) {
511 for (drv = 0;
512 drv < ae3->ae_numldrives;
513 drv++)
514 describe_one_volume(drv,
515 verbosity,
516 ae3->ae_drivesize[drv],
517 ae3->ae_drivestate[drv],
518 ae3->ae_driveprop[drv]);
519 } else {
520 describe_one_volume(ldrv,
521 verbosity,
522 ae3->ae_drivesize[ldrv],
523 ae3->ae_drivestate[ldrv],
524 ae3->ae_driveprop[ldrv]);
525 }
526 }
527 if ((ldrv < 0 && sbus < 0) || sbus >= 0) {
528 if (pdrv >= AMR_40LD_MAXPHYSDRIVES ||
529 (nschan != 0 && pdrv >= (nschan * AMR_MAX_NSDEVS))) {
530 fprintf(stderr, "Physical drive %d "
531 "is out of range.\n", pdrv);
532 exit(1);
533 }
534 if (sbus < 0) {
535 for (drv = 0;
536 drv < AMR_40LD_MAXPHYSDRIVES;
537 drv++) {
538 if (nschan != 0 &&
539 drv >= (nschan * AMR_MAX_NSDEVS))
540 break;
541 describe_one_drive(drv,
542 verbosity,
543 ae3->ae_pdrivestate[drv]);
544 }
545 } else if (sdev < 0) {
546 for (drv = sbus * AMR_MAX_NSDEVS;
547 drv < ((sbus + 1) * AMR_MAX_NSDEVS);
548 drv++) {
549 if (nschan != 0 &&
550 drv >= (nschan * AMR_MAX_NSDEVS))
551 break;
552 describe_one_drive(drv,
553 verbosity,
554 ae3->ae_pdrivestate[drv]);
555 }
556 } else {
557 if (nschan != 0 &&
558 pdrv < (nschan * AMR_MAX_NSDEVS))
559 describe_one_drive(pdrv, 1,
560 ae3->ae_pdrivestate[pdrv]);
561 }
562 }
563 }
564 } else if (fwint == FIRMWARE_8LD) {
565 /* Nothing to do here. */
566 return;
567 } else {
568 fprintf(stderr, "Firmware interface not supported.\n");
569 exit(1);
570 }
571 }
572
573 /******************************************************************************
574 * Main function
575 */
576
577 int
578 main(int argc, char *argv[])
579 {
580 int i;
581 int fd = -1;
582 int globalparam = 0, verbosity = 0;
583 int bflags = 0, fflags = 0, sflags = 0;
584 int lvolno = -1, physno = -1;
585 int sbusno = -1, targetno = -1;
586 char filename[MAXPATHLEN];
587 char sdev[MAXPATHLEN];
588 char *pdev;
589
590 extern char *optarg;
591 extern int optind;
592
593 /*
594 * Parse arguments
595 */
596 if (argc < 2)
597 usage(argv[0]);
598 if (strcmp(argv[1], "stat") != 0) /* only stat implemented for now */
599 usage(argv[0]);
600
601 optind = 2;
602 while ((i = getopt(argc, argv, "a:bc:f:gl:p:s:t:v")) != -1)
603 switch (i) {
604 case 'a':
605 nattempts = atoi(optarg);
606 break;
607 case 'b':
608 bflags++;
609 break;
610 case 'f':
611 snprintf(filename, MAXPATHLEN, "%s", optarg);
612 filename[MAXPATHLEN - 1] = '\0';
613 fflags++;
614 break;
615 case 'g':
616 globalparam = 1;
617 break;
618 case 'l':
619 lvolno = atoi(optarg);
620 break;
621 case 'p':
622 physno = atoi(optarg);
623 break;
624 case 's':
625 snprintf(sdev, MAXPATHLEN, "%s", optarg);
626 sdev[MAXPATHLEN - 1] = '\0';
627 sflags++;
628 break;
629 case 't':
630 sleeptime = atoi(optarg);
631 break;
632 case 'v':
633 verbosity++;
634 break;
635 case '?':
636 default:
637 usage(argv[0]);
638 }
639 argc -= optind;
640 argv += optind;
641
642 if (argc != 0)
643 usage(argv[0]);
644
645 if (!fflags) {
646 snprintf(filename, MAXPATHLEN, "/dev/amr0");
647 }
648
649 fd = open(filename, O_RDONLY);
650 if (fd == -1) {
651 err(EXIT_FAILURE, "open");
652 }
653 if (ioctl(fd, AMR_IO_VERSION, &i) == -1) {
654 err(EXIT_FAILURE, "ioctl version");
655 }
656
657 if (sflags) {
658 if(physno > -1)
659 usage(argv[0]);
660 else {
661 sbusno = atoi(sdev);
662 if ((pdev = index(sdev, ':')))
663 targetno = atoi(++pdev);
664 }
665 } else if (physno > -1) {
666 sbusno = physno / AMR_MAX_NSDEVS;
667 targetno = physno % AMR_MAX_NSDEVS;
668 }
669
670 if (globalparam && verbosity >= 1)
671 printf("Version\t\t\t%d\n", i);
672 #if 0
673 if (i != 1) {
674 fprintf(stderr, "Driver version (%d) not supported\n", i);
675 exit(1);
676 }
677 #endif
678
679 i = describe_card(fd, verbosity, globalparam);
680 describe_battery(fd, verbosity, i, bflags, globalparam);
681 if (!bflags || lvolno > -1 || physno > -1 || sbusno > -1 || targetno > -1)
682 describe_drive(verbosity, i, lvolno, sbusno, targetno);
683
684 return 0;
685 }
686