File: hba.hpp

package info (click to toggle)
raidutils 0.0.6-23
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,840 kB
  • sloc: cpp: 39,794; ansic: 22,774; sh: 8,306; makefile: 19
file content (576 lines) | stat: -rw-r--r-- 19,603 bytes parent folder | download | duplicates (9)
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
/* Copyright (c) 1996-2004, Adaptec Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * - 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.
 * - Neither the name of the Adaptec Corporation nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
 */

#ifndef        __HBA_HPP
#define        __HBA_HPP

//File - HBA.HPP
//***************************************************************************
//
//Description:
//
//    This file contains the class definitions for all the DPT HBA
//classes.
//
//Author: Doug Anderson
//Date:        3/25/93
//
//Editors:
//
//Remarks:
//
//
//***************************************************************************


//Class - dptSCSIhba_C::- start
//===========================================================================
//
//Description:
//
//    This class defines a SCSI Host Bus Adapter (HBA).
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//---------------------------------------------------------------------------

class     dptSCSIhba_C : public dptManager_C
{

// Friends............................................

	// Needs to set private data
   friend class          dptSCSIdrvr_C;
	// Needs to set private data
   friend class          dptDriver_C;

// Set Boolean flags..................................

	// Make this HBA a primary HBA
   void             setPrimary() { flags |= FLG_HBA_PRIMARY; }
	// Make this HBA a secondary HBA
   void             setSecondary() { flags &= ~FLG_HBA_PRIMARY; }

protected:

// Data...............................................

	// Miscellaneous flags - see bit definitions in get_info.h
   uSHORT      flags;

#if defined (_DPT_SOLARIS) && defined (_DPT_BIG_ENDIAN)
	// need a uSHORT here for alignment to avoid a SIGBUS.
	// Despite the fact that this class shouldn't be packed, their
	// compiler stills blows because it misaligns ioAddr.
	uSHORT		blowMeKludge;
#endif  // solaris - big_endian

	// The HBA's I/O address (EISA, ISA, or PCI)
   dptIOaddr_U      ioAddr;
	// # by which the driver references this HBA
   uSHORT      drvrRefNum;
	// DPT ID bytes (EISA ID PAL or PCI vendor & product ID)
   dptHBAid_U       id;
	// DMA channel #
   uSHORT      drqNum;
	// Interrupt Request (IRQ) #
   uSHORT      irqNum;
	// Total amount of memory on the HBA
   uLONG       totalMem;

	// Event Log control word
   uLONG       eventLogCtl;

	// Attached modules
   uSHORT      modules;

	// Host to HBA bus speed (3 char NULL terminated ASCII - Mb/sec)
   uCHAR       busSpeed[4];
	// Host to HBA bus type - see definitions in get_info.h
   uCHAR       busType;
	// SCSI bus transfer speed (5, 10, 20 Mb/sec)
   uCHAR       scsiBusSpeed;
	// CPU speed (Mhz)
   uCHAR       cpuSpeed;
	// 680XX
   uCHAR       cpuType;
	// Size of each memory bank (Mbytes)
   uCHAR       memBank[4];
	// Size of each memory bank (Mbytes)
   uLONG       extMemBank[4];
	// FW type based on HBA model (070,230...)
   uSHORT      fwType;
	// More flags - see bit definitions in get_info.h (flags2)
   uLONG      hbaFlags2;

	// Number of bytes successfully written to the flash
   uLONG       flashWriteCnt;

	// Offset of Flash region for GEN 5
   uLONG       flashRegionOffset;

	// Software selectable RAID ID # used with driver level arrays
   uCHAR       raidSWid;
	// Slot specific RAID ID # used with driver level arrays
   uCHAR       raidSlotID;

	// PCI bus #
   uCHAR       busNum;
	// PCI device/function #
   uCHAR       devFnNum;

	// SCSI channel information
   dptChanInfo_S    chanInfo[MAX_NUM_CHANS];

	// Start of the background task exclusion period
   uCHAR       excludeStart;
	// End of the background task exclusion period
   uCHAR       excludeEnd;

	// Current Voltage
   uSHORT      currVoltage;
	// Current Temperature (celcius - low bit is .5)
   uSHORT      currTemperature;

   // Maximum major stripe size as returned by firmware
   uSHORT	maxMajorStripe;
   // Maximum number of components in an array
   uSHORT	maxRaidComponents;
   // Maximum number of RAID table entries that can be stored on disk
   uSHORT	maxRaidDiskEntries;
   // Maximum number of RAID table entries firmware can hold in memory
   uSHORT	maxRaidMemEntries;
   // Current number of RAID table entries
   uSHORT	numRaidEntriesUsed;

   // Battery status
   uSHORT		batteryStatus;
   uCHAR		batteryFlags;
   uCHAR		batteryReserved;

	  // Host bus info from log page 0x33 parameter code 0x07
	uCHAR		hostBusInfo;
	  // Flags from log page 0x33 parameter code 0x02
	uCHAR		fwFlags;

// Functions..................................

	DPT_RTN_T   rtnMembankCapacities(dptBuffer_S *fromEng_P);

// Virtual Functions..................................

	// Return object information in the specified output buffer
   virtual DPT_RTN_T     rtnInfo(dptBuffer_S *);

	// Determine if the specified object type can be created
   virtual uSHORT   isValidAbsentObj(uSHORT);
	// Set the various object flags
   virtual void          setObjFlags(uSHORT,uSHORT);
	// Set absent object information from the specified input buffer
   virtual DPT_RTN_T     setInfo(dptBuffer_S *,uSHORT);

public:

// Constructor/Destructor.............................

			dptSCSIhba_C();

// Virtual Functions..................................

	// Return the size of this object's information structure
   virtual uLONG    infoSize() {
			   return (sizeof(dptHBAinfo_S));
			}
	// Get this object's flags
   virtual void          getObjFlags(uSHORT &flg);

// Boolean Functions..................................

	// Detremines if the HBA is primary
   uSHORT      isPrimary() { return (flags & FLG_HBA_PRIMARY); }
	// Determines if the HBA is secondary
   uSHORT      isSecondary() { return (!(flags & FLG_HBA_PRIMARY)); }
	// Determines if there is a RAID module attached
   uSHORT      isRAIDmodule() {
			   return (modules & (FLG_MOD_DM401X | FLG_MOD_DM4000 | FLG_MOD_DMI | FLG_MOD_RC4040 | FLG_MOD_RC4041));
			}
	// Determines if there is a Cache module attached
   uSHORT      isCacheModule() {
			   return (modules & (FLG_MOD_CM401X | FLG_MOD_CM4000 | FLG_MOD_CMI | FLG_MOD_RC4040 | FLG_MOD_RC4041));
			}
	// Determines if there is at least 512k of cache on the HBA
   uSHORT      is512kCache() {
			   return (totalMem >= 0x80000L);
			}
	// Determines if this HBA has an edge triggered interrupt
   uSHORT      isEdge() {
			   return (!(irqNum & 0x100));
			}
	// Determines if DPT's ECC algorithm is supported
   uSHORT      isECCenabled() {
			   return (flags & FLG_HBA_ECC_ENABLED);
			}
	// Determines if the "Interpret Format" command is supported by F/W
   uLONG      isInterpretFormat() {
			   return (hbaFlags2 & FLG_HBA_INTERPRET_FMT);
			}
	// Determines if the "Interpret Format" command is supported by F/W
   uLONG      isECCsizeErr() {
			   return (hbaFlags2 & FLG_HBA_ECC_SIZE_ERR);
			}
	// Determines if F/W based diagnostics are supported
   uLONG      isFWdiagCapable() {
			   return (hbaFlags2 & FLG_HBA_DIAGNOSTICS);
			}
	// Determines if the HBA is an I2O HBA
   uLONG      isI2O() {
			   return (hbaFlags2 & FLG_HBA_I2O);
			}
	// Determines if the HBA has a backup battery capability
    // (this bit should be set even is a battery isn't installed)
   uLONG      isBatteryUnit() {
			   return (modules & FLG_MOD_BBU);
			}
	// Determines if the second release of I2O HBA
    //	- Determine log page 0x36 format
    //	- Determines physical array page format
    //	- Determines if fibre SCSI ID packing is supported
   uLONG      isI2OVer2() {
			   return (hbaFlags2 & FLG_HBA_I2O_VER2);
		}
	// Determine if manual JBOD is active
   uLONG      isManualJBODactive() {
			   return (hbaFlags2 & FLG_HBA_MANUAL_JBOD_ACTIVE);
			}
     // Return the maximum channel number
   uCHAR	getNumChans() { return phyRange.getMaxChan() + 1; }

	// Determines if the HBA is an I2O HBA
   uSHORT     isUDMA() {
			   return (chanInfo[0].flags & FLG_CHAN_UDMA);
			}

	// Determines if the HBA is an I2O HBA
   uLONG    isClusterMode() {
			   return (hbaFlags2 & FLG_HBA_CLUSTER_MODE);
			}

// Return private data................................

	// Return this HBA's ISA address
   uSHORT      getISAaddr() { return (ioAddr.std.isa); }
	// Return this HBA's EISA address
   uSHORT      getEISAaddr() { return (ioAddr.std.eisa); }

	// Return this HBA's PCI address
   uLONG       getPCIaddr() { return (ioAddr.pci); }

	// Return this HBA's EISA slot number
   uSHORT      getEISAslot() { return (ioAddr.std.eisa>>12); }
	// Return the # by which the driver references this HBA
   uSHORT      getDrvrNum() { return (drvrRefNum); }
	// Return the IRQ #
   uSHORT      getIRQnum() { return (irqNum & 0xff); }
	// Return the active RAID ID #
   uSHORT      getRAIDid() {
			   if (raidSWid) return (raidSWid);
			   else return (raidSlotID);
			}
	// Return the software selectable RAID ID #
   uSHORT      getSWid() { return ((uSHORT)raidSWid); }
	// Return the slot specific RAID ID #
   uSHORT      getSlotID() { return ((uSHORT)raidSlotID); }

   // Decrement the number of RAID table entries used (numRaidEntriesUsed)
   void		decRaidEntries();
   // Increment the number of RAID table entries used (numRaidEntriesUsed)
   void		incRaidEntries();

// Set Private Data...................................

	// Sets the base address based upon the specified RAID ID #
   void             setBaseFromRAIDid(uSHORT);

};

//dptSCSIhba_C - end


//Class - dptRAIDhba_C - start
//===========================================================================
//
//Description:
//
//    This class defines a RAID HBA.
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//---------------------------------------------------------------------------

class     dptRAIDhba_C : public dptSCSIhba_C
{

	// Sets up default RAID definitions
   void             setDefRAID();

protected:

// Data...............................................

	// The logical array page to be used
   uSHORT      lapPage;

   // Miscellaneous flags for internal engine use
   uSHORT		privateEngFlags;

// Virtual Functions..................................

	// Called after a device has been added to the logical device
	// list.  Can be used to update device flags...
   virtual void          postAddLog(dptCoreDev_C *);

	// Performs post delete operations
	// (Called prior to the object actually being deleted from memory)
   virtual void          postDelete(dptCoreObj_C *);

	// Handles message processing for this class
   virtual DPT_RTN_T     handleMessage(DPT_MSG_T,dptBuffer_S *,dptBuffer_S *);

public:

// Constructor/Destructor.............................

			dptRAIDhba_C();

// Virtual Functions..................................

	// Get this object's flags
   virtual void          getObjFlags(uSHORT &flg);

// Internal flags.....................................

   uSHORT				isBusResetDesired() { return (privateEngFlags & 0x01); }
   void					setBusResetDesired() { privateEngFlags |= 0x01; }
   void					clrBusResetDesired() { privateEngFlags &= ~0x01; }

// Other Functions....................................

	// Updates the Hot Spare protection status for RAID drives attached
	// to this HBA.
   void             updateHSprotection();

	// Determines if this HBA is capable of configuring RAID devices
   virtual uSHORT   isRAIDcapable();
	// Determines if this HBA can configure RAID devices
   uSHORT      isRAIDready();

};

//dptRAIDhba_C - end


//Class - dptHBA_C - start
//===========================================================================
//
//Description:
//
//    This class is the highest level DPT HBA class.
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//---------------------------------------------------------------------------

class     dptHBA_C : public dptRAIDhba_C
{

	// Determines if the target device is an "NCR" type RAID BCD
   uSHORT      isRAIDbcd();

protected:

// Virtual Functions..................................

	// Finds this manager's physical objects
   virtual uSHORT   findMyPhysicals();
	// Finds this manager's logical objects
   virtual uSHORT   findMyLogicals();
	// Return the logical array page used
   virtual uSHORT   getLAPpage() { return (lapPage); }
	// Finds a component device
   virtual dptDevice_C * findComponent(dptAddr_S,uSHORT=0,uLONG=0, dptCoreList_C *list_P=NULL);
	// Performs initialization of a real object (SCSI Inquiry...)
   virtual void          realInit();

	// Perform initialization after all this manager's devices
	// have been initialized
   virtual void          scanPostInit() {
			   if (isRAIDcapable())
				 updateHSprotection();
			}
	// Updates the logical array page (LAP) parameters
   virtual DPT_RTN_T     updateLAPparams();

	// Get HBA hardware information
   void             getHWinfo();
	// Get NV RAM information
   void             getNVinfo();
	// Get HBA hardware information
   void             updateChannelInfo(dptSCSIlog_C *);
	// Determines if FW responds to RAID commands
   void             checkForRAID();
	// Check for emulated drives
   void             checkForEmul();
	// Get the event log control word
   void             getEventCtl();

   // Read the drive size table from the controller
   DPT_RTN_T		readDriveSizeTable();
   // Write the drive size table to the controller
   DPT_RTN_T		writeDriveSizeTable();
   // Use the specified drive size table
   void				useDriveSizeTable(driveSizeTable_S *ds_P);

	// Handles message processing for this class
   virtual DPT_RTN_T     handleMessage(DPT_MSG_T,dptBuffer_S *,dptBuffer_S *);

	// Set the HBA's background exclusion period
   DPT_RTN_T        setExclusion(dptBuffer_S *);
	// Send a DPT multi-function command to the HBA
   DPT_RTN_T        sendMFC(uCHAR,uCHAR=0,uCHAR=0);
	// Send an extended DPT multi-function command to the HBA
   DPT_RTN_T        sendExtMFC(uCHAR,uCHAR=0,uLONG=0,uSHORT=0,uCHAR=0);
	// Updates this HBA's status
   DPT_RTN_T        updateStatus(dptBuffer_S *fromEng_P=NULL);
	// Get the HBA's time
   DPT_RTN_T        getTime(dptBuffer_S *);
	// Set the HBA's time
   DPT_RTN_T        setTime(dptBuffer_S *);
	// Non-destructively reads the HBA's event log
   DPT_RTN_T        rtnEventLog(dptBuffer_S *,dptBuffer_S *);
	// Clear the HBA event log
   DPT_RTN_T        clearEventLog();
	// Set the HBA event log control word
   DPT_RTN_T        setEventCtl(dptBuffer_S *);
	// Return the global HBA statistics information
   DPT_RTN_T        rtnHBAstats(dptBuffer_S *,uCHAR);
	// Return the global HBA statistics information
   DPT_RTN_T        rtnIOstats(dptBuffer_S *,uCHAR);
	// Return the HBA's array limits
   DPT_RTN_T        getArrayLimits(dptBuffer_S *);

	// Prepares the HBA's flash memory for programming
   DPT_RTN_T        flashWriteInit(engCCB_C *);
	// Writes to the flash memory in 512 byte chunks
   DPT_RTN_T        flashWrite(dptBuffer_S *,uINT=1);
	// Commands the flash F/W to compute & write the flash checksums
   DPT_RTN_T        flashWriteDone(uCHAR sendToHW);
	// Reads a specified number of bytes from a specified location
	// in the flash memory.
   DPT_RTN_T        flashRead(dptBuffer_S *,dptBuffer_S *);
	// Returns detailed information about the status of the flash memory
   DPT_RTN_T        flashStatus(dptBuffer_S *);
	// Attempts to switch from operational mode into flash mode
   DPT_RTN_T        flashSwitchInto();
	// Attempts to switch from flash mode into operational mode
   DPT_RTN_T        flashSwitchOutOf(uINT=0);
	// Attempts to switch the firmware into flash command mode
   DPT_RTN_T        switchToFlashMode(engCCB_C *);
	// Sets the region to flash for GEN 5 boards
   DPT_RTN_T        flashSetRegion(dptBuffer_S *);
	// called after a flash ommand completes ok
	// used to wait for older flash code to write the
	// bled code out
   void             flashStablize();

	// Set the specified data field to the specified value
	virtual DPT_RTN_T     setDataField(dptBuffer_S *);
	// Reads tehe contents of the HBA's NV RAM
   DPT_RTN_T        readNV_RAM(dptBuffer_S *);
	// Writes the contents of the HBA's NV RAM
   DPT_RTN_T        writeNV_RAM(dptBuffer_S *);
	// Quiet the SCSI bus
   DPT_RTN_T        quietBus(dptBuffer_S *);

	// get and set access rights for existing devices
   DPT_RTN_T		SetAccessRights(dptBuffer_S *, dptBuffer_S *);
   DPT_RTN_T		GetAccessRights(dptBuffer_S *);

	// whatd going on with the space in/around the hba?
   DPT_RTN_T		GetEnvironInfo(dptBuffer_S *fromEng_P);
   DPT_RTN_T		SetEnvironInfo(dptBuffer_S *fromEng_P);

	// Backup battery functions
   DPT_RTN_T		getBatteryInfo(dptBuffer_S *toEng_P, dptBuffer_S *fromEng_P);		// Return the battery info structure
   DPT_RTN_T		setBatteryThresholds(dptBuffer_S *toEng_P);	// Set the battery threshold value
   DPT_RTN_T		calibrateBattery(dptBuffer_S *toEng_P);		// Calibrate the battery
   DPT_RTN_T		getBatteryStatus(); // Updated the HBA's battery status variables

	// I2O controller diagnostic functions
   DPT_RTN_T		i2oDiagTest(dptBuffer_S *toEng_P, dptBuffer_S *fromEng_P, uSHORT fnCode=0); // Perform a commanded diagnostic
   void				i2oInitPrivateScsi(char *, uLONG, uLONG, char *);
   void				i2oInitDmaTest(char *, char *, char *);

   DPT_RTN_T		initBusyLogic(dptBuffer_S *fromEng_P); // Initialize device busy logic

	// Set the array drive size table
   DPT_RTN_T        setArrayDriveSizeTable(dptBuffer_S *);
	// Return the array drive size table
   DPT_RTN_T        getArrayDriveSizeTable(dptBuffer_S *);

	// Reset the HBA (IOP reset)
	DPT_RTN_T		resetHba(dptBuffer_S *toEng_P);

	// Send an I2O pass-through message
	DPT_RTN_T		sendI2OMessage(dptBuffer_S *fromEng_P, dptBuffer_S *toEng_P);

	DPT_RTN_T       getChanInfo(dptBuffer_S *fromEng_P);
public:

	// Adjust a CCB as necessary and pass it on to the next manager
   virtual DPT_RTN_T     passCCB(engCCB_C *);
	// Delete all emulated drives associated with this HBA
   DPT_RTN_T        delEmulation();
	// Determines if the HBA is in blink LED mode
   uSHORT      isBlinkLED() {
			   return (status.main==SMAIN_BLINK_LED);
			}
	// Determines if the HBA is in flash command mode
   uSHORT      isFlashMode() {
			   if (status.main==SMAIN_FLASH_MODE)
				 return (status.sub);
			   else
				 return (0);
			}
	// Set the RAID magic number of all unarrayed physical DASD devices
   void             setPhyMagicNums();
};

//dptHBA_C - end


#endif