summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/hptmv/hptproc.c
blob: e05798f1eb740e3b3c4f1658c073d2ab9d64ed35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/*
 * Copyright (c) 2003-2004 HighPoint Technologies, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
/*
 * hptproc.c  sysctl support
 */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <machine/stdarg.h>

#include <dev/hptmv/global.h>
#include <dev/hptmv/hptintf.h>
#include <dev/hptmv/osbsd.h>
#include <contrib/dev/hptmv/access601.h>

int hpt_rescan_all(void);

/***************************************************************************/

static char hptproc_buffer[256];

#define FORMAL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
	struct sysctl_req *req
#define REAL_HANDLER_ARGS oidp, arg1, arg2, req
typedef struct sysctl_req HPT_GET_INFO;

static int hpt_set_asc_info(IAL_ADAPTER_T *pAdapter, char *buffer,int length)
{
	int orig_length = length+4;
	PVBus _vbus_p = &pAdapter->VBus;
	PVDevice	 pArray;
	PVDevice pSubArray, pVDev;
	UINT	i, iarray, ichan;
	struct cam_periph *periph = NULL;
	intrmask_t oldspl;

#ifdef SUPPORT_ARRAY	
	if (length>=8 && strncmp(buffer, "rebuild ", 8)==0) 
	{
		buffer+=8;
		length-=8;
		if (length>=5 && strncmp(buffer, "start", 5)==0) 
		{
			oldspl = lock_driver();
			for(i = 0; i < MAX_ARRAY_PER_VBUS; i++)
				if ((pArray=ArrayTables(i))->u.array.dArStamp==0)
					continue; 
				else{
					if (pArray->u.array.rf_need_rebuild && !pArray->u.array.rf_rebuilding)
	                    hpt_queue_dpc((HPT_DPC)hpt_rebuild_data_block, pAdapter, pArray, 
							(UCHAR)((pArray->u.array.CriticalMembers || pArray->VDeviceType == VD_RAID_1)? DUPLICATE : REBUILD_PARITY));
				}
			unlock_driver(oldspl);
			return orig_length;
		}
		else if (length>=4 && strncmp(buffer, "stop", 4)==0) 
		{
			oldspl = lock_driver();
			for(i = 0; i < MAX_ARRAY_PER_VBUS; i++)
				if ((pArray=ArrayTables(i))->u.array.dArStamp==0)
					continue; 
				else{
					if (pArray->u.array.rf_rebuilding)
					    pArray->u.array.rf_abort_rebuild = 1;
				}
			unlock_driver(oldspl);
			return orig_length;
		}	
		else if (length>=3 && buffer[1]==','&& buffer[0]>='1'&& buffer[2]>='1')	
		{
			iarray = buffer[0]-'1';
	        ichan = buffer[2]-'1';

            if(iarray >= MAX_VDEVICE_PER_VBUS || ichan >= MV_SATA_CHANNELS_NUM) return -EINVAL;

			pArray = _vbus_p->pVDevice[iarray];
	        if (!pArray || (pArray->vf_online == 0)) return -EINVAL;

            for (i=0;i<MV_SATA_CHANNELS_NUM;i++)
				if(i == ichan)
				    goto rebuild;

	        return -EINVAL;

rebuild:
	        pVDev = &pAdapter->VDevices[ichan];
	        if(!pVDev->u.disk.df_on_line || pVDev->pParent) return -EINVAL;

	        /* Not allow to use a mounted disk ??? test*/
			for(i = 0; i < MAX_VDEVICE_PER_VBUS; i++)
			    if(pVDev == _vbus_p->pVDevice[i])
			    {
					periph = hpt_get_periph(pAdapter->mvSataAdapter.adapterId,i);
					if (periph != NULL && periph->refcount == 1)
					{
						hpt_printk(("Can not use disk used by OS!\n"));
	                    return -EINVAL;	
					}
					/* the Mounted Disk isn't delete */
				} 
			
			switch(pArray->VDeviceType)
			{
				case VD_RAID_1:
				case VD_RAID_5:
				{
					pSubArray = pArray;
loop:
					oldspl = lock_driver();
					if(hpt_add_disk_to_array(_VBUS_P VDEV_TO_ID(pSubArray), VDEV_TO_ID(pVDev)) == -1) {
						unlock_driver(oldspl);
						return -EINVAL;
					}
					pArray->u.array.rf_auto_rebuild = 0;
					pArray->u.array.rf_abort_rebuild = 0;
					hpt_queue_dpc((HPT_DPC)hpt_rebuild_data_block, pAdapter, pArray, DUPLICATE);
					unlock_driver(oldspl);
					break;
				}
				case VD_RAID_0:
					for (i = 0; (UCHAR)i < pArray->u.array.bArnMember; i++) 
						if(pArray->u.array.pMember[i] && mIsArray(pArray->u.array.pMember[i]) &&
						   (pArray->u.array.pMember[i]->u.array.rf_broken == 1))
						{
							  pSubArray = pArray->u.array.pMember[i];
							  goto loop;
						}
				default:
					return -EINVAL;
			}
			return orig_length;
		}
	}
	else if (length>=7 && strncmp(buffer, "verify ", 7)==0)
	{
		buffer+=7;
		length-=7;
        if (length>=6 && strncmp(buffer, "start ", 6)==0) 
		{
            buffer+=6;
		    length-=6;
            if (length>=1 && *buffer>='1') 
			{
				iarray = *buffer-'1';
				if(iarray >= MAX_VDEVICE_PER_VBUS) return -EINVAL;

				pArray = _vbus_p->pVDevice[iarray];
				if (!pArray || (pArray->vf_online == 0)) return -EINVAL;
				
				if(pArray->VDeviceType != VD_RAID_1 && pArray->VDeviceType != VD_RAID_5)
					return -EINVAL;

				if (!(pArray->u.array.rf_need_rebuild ||
					pArray->u.array.rf_rebuilding ||
					pArray->u.array.rf_verifying ||
					pArray->u.array.rf_initializing))
				{
					oldspl = lock_driver();
					pArray->u.array.RebuildSectors = 0;
					hpt_queue_dpc((HPT_DPC)hpt_rebuild_data_block, pAdapter, pArray, VERIFY);
					unlock_driver(oldspl);
				}
                return orig_length;
			}
		}
		else if (length>=5 && strncmp(buffer, "stop ", 5)==0)
		{
			buffer+=5;
		    length-=5;
            if (length>=1 && *buffer>='1') 
			{
				iarray = *buffer-'1';
				if(iarray >= MAX_VDEVICE_PER_VBUS) return -EINVAL;

				pArray = _vbus_p->pVDevice[iarray];
				if (!pArray || (pArray->vf_online == 0)) return -EINVAL;
				if(pArray->u.array.rf_verifying) 
				{
					oldspl = lock_driver();
				    pArray->u.array.rf_abort_rebuild = 1;
				    unlock_driver(oldspl);
				}
			    return orig_length;
			}
		}
	}
	else
#ifdef _RAID5N_
	if (length>=10 && strncmp(buffer, "writeback ", 10)==0) {
	    	buffer+=10;
		length-=10;
		if (length>=1 && *buffer>='0' && *buffer<='1') {
			_vbus_(r5.enable_write_back) = *buffer-'0';
			if (_vbus_(r5.enable_write_back))
				hpt_printk(("RAID5 write back enabled"));
			return orig_length;
		}
	}
	else
#endif
#endif /* SUPPORT_ARRAY */
	if (0) {} /* just to compile */
#if DBGUG
	else if (length>=9 && strncmp(buffer, "dbglevel ", 9)==0) {
	    	buffer+=9;
		length-=9;
		if (length>=1 && *buffer>='0' && *buffer<='3') {
			hpt_dbg_level = *buffer-'0';
			return orig_length;
		}
	}
	else if (length>=8 && strncmp(buffer, "disable ", 8)==0) {
		/* TO DO */
	}
#endif		

	return -EINVAL;
}

/*
 * Since we have only one sysctl node, add adapter ID in the command 
 * line string: e.g. "hpt 0 rebuild start"
 */
static int hpt_set_info(int length)
{
	int retval;

#ifdef SUPPORT_IOCTL
	PUCHAR ke_area;
	int err;
	DWORD dwRet;
	PHPT_IOCTL_PARAM32 piop;
#endif
	char *buffer = hptproc_buffer;
	if (length >= 6) {
		if (strncmp(buffer,"hpt ",4) == 0) {
			IAL_ADAPTER_T *pAdapter;
			retval = buffer[4]-'0';
			for (pAdapter=gIal_Adapter; pAdapter; pAdapter=pAdapter->next) {
				if (pAdapter->mvSataAdapter.adapterId==retval)
					return (retval = hpt_set_asc_info(pAdapter, buffer+6, length-6)) >= 0? retval : -EINVAL;
			}
			return -EINVAL;
		}
#ifdef SUPPORT_IOCTL	
		piop = (PHPT_IOCTL_PARAM32)buffer;
		if (piop->Magic == HPT_IOCTL_MAGIC) 	{
			KdPrintE(("ioctl=%d in=%x len=%d out=%x len=%ld\n", 
				piop->dwIoControlCode,
        			piop->lpInBuffer,
        			piop->nInBufferSize,
        			piop->lpOutBuffer,
	        		(u_long)piop->nOutBufferSize));

			/*
        	 	 * map buffer to kernel.
        	 	 */
        		if (piop->nInBufferSize+piop->nOutBufferSize > PAGE_SIZE) {
        			KdPrintE(("User buffer too large\n"));
        			return -EINVAL;
        		}
        		
        		ke_area = malloc(piop->nInBufferSize+piop->nOutBufferSize, M_DEVBUF, M_NOWAIT);
				if (ke_area == NULL) {
					KdPrintE(("Couldn't allocate kernel mem.\n"));
					return -EINVAL;
				}

			if (piop->nInBufferSize)
				copyin((void*)(ULONG_PTR)piop->lpInBuffer, ke_area, piop->nInBufferSize);

			/*
			  * call kernel handler.
			  */    
			err = Kernel_DeviceIoControl(&gIal_Adapter->VBus,
				piop->dwIoControlCode, ke_area, piop->nInBufferSize,
				ke_area + piop->nInBufferSize, piop->nOutBufferSize, &dwRet);    
			
			if (err==0) {
				if (piop->nOutBufferSize)
					copyout(ke_area + piop->nInBufferSize, (void*)(ULONG_PTR)piop->lpOutBuffer, piop->nOutBufferSize);
				
				if (piop->lpBytesReturned)
					copyout(&dwRet, (void*)(ULONG_PTR)piop->lpBytesReturned, sizeof(DWORD));
			
				free(ke_area, M_DEVBUF);
				return length;
			}
			else  KdPrintW(("Kernel_ioctl(): return %d\n", err));

			free(ke_area, M_DEVBUF);
            		return -EINVAL;
		} else 	{
    		KdPrintW(("Wrong signature: %x\n", piop->Magic));
    		return -EINVAL;
		}
#endif
	}

	return -EINVAL;
}

#define shortswap(w) ((WORD)((w)>>8 | ((w) & 0xFF)<<8))

static void get_disk_name(char *name, PDevice pDev)
{
	int i;
	MV_SATA_CHANNEL *pMvSataChannel = pDev->mv;
	IDENTIFY_DATA2 *pIdentifyData = (IDENTIFY_DATA2 *)pMvSataChannel->identifyDevice;
	
	for (i = 0; i < 10; i++) 
		((WORD*)name)[i] = shortswap(pIdentifyData->ModelNumber[i]);
	name[20] = '\0';
}

static int hpt_copy_info(HPT_GET_INFO *pinfo, char *fmt, ...) 
{
	int printfretval;
	va_list ap;
	
	if(fmt == NULL) {
		*hptproc_buffer = 0;
		return (SYSCTL_OUT(pinfo, hptproc_buffer, 1));
	}
	else 
	{
		va_start(ap, fmt);
		printfretval = vsnprintf(hptproc_buffer, sizeof(hptproc_buffer), fmt, ap);
		va_end(ap);
		return(SYSCTL_OUT(pinfo, hptproc_buffer, strlen(hptproc_buffer)));
	}
}

static void hpt_copy_disk_info(HPT_GET_INFO *pinfo, PVDevice pVDev, UINT iChan)
{
	char name[32], arrayname[16];
	
	get_disk_name(name, &pVDev->u.disk);

#ifdef SUPPORT_ARRAY	
	if(pVDev->pParent) 
		memcpy(arrayname, pVDev->pParent->u.array.ArrayName, MAX_ARRAY_NAME);
	else
#endif
	    arrayname[0]=0;
	
	hpt_copy_info(pinfo, "Channel %d  %s  %5dMB  %s %s\n",
		iChan+1, 
		name, pVDev->VDeviceCapacity>>11, 
		((!pVDev->u.disk.df_on_line)? "Disabled" : 
		((pVDev->VDeviceType != VD_SPARE)?"Normal  ":"Spare   ")), arrayname);
}

#ifdef SUPPORT_ARRAY
static void hpt_copy_array_info(HPT_GET_INFO *pinfo, int nld, PVDevice pArray)
{
	int i;
	char *sType=0, *sStatus=0;
	char buf[32];
    PVDevice pTmpArray;

	switch (pArray->VDeviceType) {
		case VD_RAID_0:
			for (i = 0; (UCHAR)i < pArray->u.array.bArnMember; i++) 
		  		if(pArray->u.array.pMember[i])	{
			  		if(mIsArray(pArray->u.array.pMember[i]))
				 		sType = "RAID 1/0   ";
			  			/* TO DO */
			  		else
				 		sType = "RAID 0     ";
			  		break;
		  		}
			break;
			
		case VD_RAID_1:
			sType = "RAID 1     ";
			break;
			
		case VD_JBOD:
			sType = "JBOD       ";
			break;
			
		case VD_RAID_5:
       		sType = "RAID 5     ";
			break;
			
		default:
			sType = "N/A        ";
			break;
	}
	
	if (pArray->vf_online == 0)
		sStatus = "Disabled";
	else if (pArray->u.array.rf_broken)
		sStatus = "Critical";
	for (i = 0; (UCHAR)i < pArray->u.array.bArnMember; i++)
	{
		if (!sStatus) 
		{
			if(mIsArray(pArray->u.array.pMember[i]))
                		pTmpArray = pArray->u.array.pMember[i];
			else
			   	pTmpArray = pArray;
			
			if (pTmpArray->u.array.rf_rebuilding) {
#ifdef DEBUG
				sprintf(buf, "Rebuilding %dMB", (pTmpArray->u.array.RebuildSectors>>11));
#else
				sprintf(buf, "Rebuilding %d%%", (pTmpArray->u.array.RebuildSectors>>11)*100/((pTmpArray->VDeviceCapacity/(pTmpArray->u.array.bArnMember-1))>>11));
#endif
				sStatus = buf;
			}
			else if (pTmpArray->u.array.rf_verifying) {
				sprintf(buf, "Verifying %d%%", (pTmpArray->u.array.RebuildSectors>>11)*100/((pTmpArray->VDeviceCapacity/(pTmpArray->u.array.bArnMember-1))>>11));
				sStatus = buf;
			}
			else if (pTmpArray->u.array.rf_need_rebuild)
				sStatus = "Critical";
			else if (pTmpArray->u.array.rf_broken)
				sStatus = "Critical";
			
			if(pTmpArray == pArray) goto out;
		}
		else
			goto out;
	}
out:	
	if (!sStatus) sStatus = "Normal";
	hpt_copy_info(pinfo, "%2d  %11s  %-20s  %5dMB  %-16s", nld, sType, pArray->u.array.ArrayName, pArray->VDeviceCapacity>>11, sStatus);
}
#endif

static int hpt_get_info(IAL_ADAPTER_T *pAdapter, HPT_GET_INFO *pinfo)
{
	PVBus _vbus_p = &pAdapter->VBus;
	struct cam_periph *periph = NULL;
	UINT channel,j,i;
	PVDevice pVDev;

#ifndef FOR_DEMO
	if (pAdapter->beeping) {
		intrmask_t oldspl = lock_driver();
		pAdapter->beeping = 0;
		BeepOff(pAdapter->mvSataAdapter.adapterIoBaseAddress);
		unlock_driver(oldspl);
	}
#endif

	hpt_copy_info(pinfo, "Controller #%d:\n\n", pAdapter->mvSataAdapter.adapterId);
	
	hpt_copy_info(pinfo, "Physical device list\n");
	hpt_copy_info(pinfo, "Channel    Model                Capacity  Status   Array\n");
	hpt_copy_info(pinfo, "-------------------------------------------------------------------\n");

    for (channel = 0; channel < MV_SATA_CHANNELS_NUM; channel++)
	{
		pVDev = &(pAdapter->VDevices[channel]);
		if(pVDev->u.disk.df_on_line)
			 hpt_copy_disk_info(pinfo, pVDev, channel);
	}
	
	hpt_copy_info(pinfo, "\nLogical device list\n");
	hpt_copy_info(pinfo, "No. Type         Name                 Capacity  Status            OsDisk\n");
	hpt_copy_info(pinfo, "--------------------------------------------------------------------------\n");

	j=1;
	for(i = 0; i < MAX_VDEVICE_PER_VBUS; i++){
        pVDev = _vbus_p->pVDevice[i];
		if(pVDev){
			j=i+1;
#ifdef SUPPORT_ARRAY
			if (mIsArray(pVDev))
			{
		is_array:
				hpt_copy_array_info(pinfo, j, pVDev);
			}
			else
#endif
			{
				char name[32];
				/* it may be add to an array after driver loaded, check it */
#ifdef SUPPORT_ARRAY
				if (pVDev->pParent)
					/* in this case, pVDev can only be a RAID 1 source disk. */
					if (pVDev->pParent->VDeviceType==VD_RAID_1 && pVDev==pVDev->pParent->u.array.pMember[0]) 
						goto is_array;
#endif
				get_disk_name(name, &pVDev->u.disk);
				
				hpt_copy_info(pinfo, "%2d  %s  %s  %5dMB  %-16s",
					j, "Single disk", name, pVDev->VDeviceCapacity>>11, 
					/* gmm 2001-6-19: Check if pDev has been added to an array. */
					((pVDev->pParent) ? "Unavailable" : "Normal"));
			}
			periph = hpt_get_periph(pAdapter->mvSataAdapter.adapterId, i);
			if (periph == NULL)
				hpt_copy_info(pinfo,"  %s\n","not registered");
			else
				hpt_copy_info(pinfo,"  %s%d\n", periph->periph_name, periph->unit_number);
		 }
	}
	return 0;
}

static inline int hpt_proc_in(FORMAL_HANDLER_ARGS, int *len)
{
	int i, error=0;

	*len = 0;
	if ((req->newlen - req->newidx) >= sizeof(hptproc_buffer)) {
		error = EINVAL;
	} else {
		i = (req->newlen - req->newidx);
		error = SYSCTL_IN(req, hptproc_buffer, i);
		if (!error)
			*len = i;
		(hptproc_buffer)[i] = '\0';
	}
	return (error);
}

static int hpt_status(FORMAL_HANDLER_ARGS)
{
	int length, error=0, retval=0;
	IAL_ADAPTER_T *pAdapter;

	error = hpt_proc_in(REAL_HANDLER_ARGS, &length);
	
    if (req->newptr != NULL) 	
	{
		if (error || length == 0) 	
		{
    		KdPrint(("error!\n"));
    		retval = EINVAL;
    		goto out;
		}
    		
		if (hpt_set_info(length) >= 0)
			retval = 0;
		else
			retval = EINVAL;
		goto out;
    }

	hpt_copy_info(req, "%s Version %s\n", DRIVER_NAME, DRIVER_VERSION);
	for (pAdapter=gIal_Adapter; pAdapter; pAdapter=pAdapter->next) {
		if (hpt_get_info(pAdapter, req) < 0) {
			retval = EINVAL;
			break;
		}
	}
	
	hpt_copy_info(req, NULL);
	goto out;

out:
	return (retval);
}


#define xhptregister_node(name) hptregister_node(name)

#if (__FreeBSD_version < 500043)
#define hptregister_node(name) \
	SYSCTL_NODE(, OID_AUTO,	name, CTLFLAG_RW, 0, "Get/Set " #name " state root node") \
	SYSCTL_OID(_ ## name, OID_AUTO, status, CTLTYPE_STRING|CTLFLAG_RW, \
	NULL, 0, hpt_status, "A", "Get/Set " #name " state")
#else
#define hptregister_node(name) \
	SYSCTL_NODE(, OID_AUTO,	name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \
	SYSCTL_OID(_ ## name, OID_AUTO, status, CTLTYPE_STRING|CTLFLAG_RW, \
	NULL, 0, hpt_status, "A", "Get/Set " #name " state");
#endif
	
xhptregister_node(PROC_DIR_NAME);
OpenPOWER on IntegriCloud