1
/* Copyright (c) 1996-2004, Adaptec Corporation
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* - Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
9
* - Redistributions in binary form must reproduce the above copyright notice,
10
* this list of conditions and the following disclaimer in the documentation
11
* and/or other materials provided with the distribution.
12
* - Neither the name of the Adaptec Corporation nor the names of its
13
* contributors may be used to endorse or promote products derived from this
14
* software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
* POSSIBILITY OF SUCH DAMAGE.
29
/****************************************************************************
33
*****************************************************************************
35
* File Name: Expand.cpp
37
* Contributors: Karla Summers
44
*****************************************************************************/
49
#include "intlist.hpp"
53
extern int FID_RESET_OUTBUFF;
54
extern uSHORT PHYS_LIST_SIZE;
55
extern uCHAR SMU_EXPANDING;
56
extern char* EventStrings[];
67
raidToExpandAddr (raid),
70
ENTER( "Expand::Expand(" );
74
Expand::Expand (const Expand &new_Expand):
75
raidToExpandAddr (new_Expand.raidToExpandAddr),
76
components (new_Expand.components)
78
ENTER ("Expand::Expand( const Expand &new_Expand):");
84
ENTER ("Expand::~Expand()");
88
Command::Dpt_Error Expand::RaidExpandable (void)
90
ENTER( "Command::Dpt_Error Expand::RaidExpandable (void)");
91
bool objFound = false;
92
bool getHidden = false;
94
dptID_S *idlist = new dptID_S[PHYS_LIST_SIZE];
98
raidToExpandTag = Get_Log_Dev_by_Address (raidToExpandAddr,
99
getHidden, &objFound);
101
err = engine->Send (MSG_GET_INFO, raidToExpandTag);
102
raidToExpandType = engine->devInfo_P->raidType;
106
// make sure the raid is a 0 or a 5 and not dual level
107
if ((engine->devInfo_P->raidParent == -1) &&
108
((raidToExpandType == 5) || (raidToExpandType == 0)))
110
numComps = EngineFindIDs(FID_RESET_OUTBUFF,
111
MSG_ID_COMPONENTS, raidToExpandTag,
112
idlist, PHYS_LIST_SIZE);
113
// save this for later.
114
raidStripeSize = engine->devInfo_P->maxCompStripe;
115
if (raidToExpandType == 5)
116
currStripeSize = numComps * raidStripeSize;
118
currStripeSize = engine->devInfo_P->maxCompStripe;
120
mgrTag = engine->devInfo_P->hbaTag;
121
err = engine->Send (MSG_GET_INFO, mgrTag);
123
// this value will have to be >= currStripeSize to add in the drive
126
maxStripeSize = engine->hbaInfo_P->maxMajorStripe;
129
maxStripeSize = 0x800;
131
if (raidToExpandType == 5)
132
maxStripeSize += raidStripeSize;
136
err = Dpt_Error::DPT_ERR_INVALID_RAID_TYPE;
143
Command::Dpt_Error Expand::execute( String_List **output )
145
ENTER ("Command::Dpt_Error Expand::execute (String_List **output)");
146
Dpt_Error err, temp_err;
148
raidHeader_S raid_hdr;
149
raidCompList_S comp_list;
153
*output = out = new String_List();
158
// warning to all OSs except NT (and 2000 - same define)
159
#if !defined _DPT_WIN_NT
160
out->add_Item (EventStrings[STR_WARN_ONLY_NT_2000]);
163
err = RaidExpandable();
166
bool more_Devs_Left = true;
167
bool first_time_through = true;
168
bool cluster_ON = false;
170
for(dev_Index = 0; more_Devs_Left && !err.Is_Error(); dev_Index ++){
174
hba_Tag = Get_HBA_by_Index(dev_Index, &more_Devs_Left);
176
engine->Send(MSG_GET_INFO, hba_Tag);
178
//if the cluster bit is enabled, DISABLE this feature
179
if (engine->hbaInfo_P->flags2 & FLG_HBA_CLUSTER_MODE)
184
(**output).add_Item ( EventStrings[STR_CLSTR_FEAT_DISABLE]);
186
else if (!err.Is_Error())
189
dptBuffer_S *deadBuff_P = dptBuffer_S::newBuffer(10);
190
dptBuffer_S *tempBuff_P = dptBuffer_S::newBuffer(1024);
191
smUserBuff_S *smUB_P = (smUserBuff_S *) tempBuff_P->data;
193
memset(&raid_hdr, 0, sizeof(raidHeader_S));
194
memset(&comp_list, 0, sizeof(raidCompList_S));
196
if (components->get_Num_Items())
198
raid_hdr.refNum = raidToExpandType;
199
buffSize = sizeof(DPT_TAG_T) + sizeof(uCHAR) +
200
sizeof(raidHeader_S) +
201
sizeof(raidCompList_S) * components->get_Num_Items();
202
dptBuffer_S *raidBuff_P = dptBuffer_S::newBuffer(buffSize);
203
raidBuff_P->reset ();
204
raidBuff_P->insert ((uLONG) raidToExpandTag);
205
raidBuff_P->insert ((uCHAR) 0);
206
raidBuff_P->insert (&raid_hdr, sizeof(raidHeader_S));
207
// loop on each drive to add
208
bool component_Found = true;
209
bool includeDrive = true;
210
while (component_Found && components->num_Left() &&
214
compTag = Get_Dev_by_Address_and_Type (GET_SCSI_DASD,
215
components->get_Next_Item(), &component_Found);
218
// must be unarrayed drive, but redirected okay
219
err = engine->Send (MSG_GET_INFO, compTag);
220
// if part o f a logical ...
221
if (engine->devInfo_P->flags & FLG_DEV_RAID_COMPONENT)
224
err = engine->Send (MSG_GET_INFO,
225
engine->devInfo_P->raidParent);
226
// if not redirected, get out
227
if (engine->devInfo_P->raidType != RAID_REDIRECT)
228
includeDrive = false;
232
// be sure hba has enough memory to add this drive
233
if (StripeSizeCapable (compTag))
235
comp_list.tag = compTag;
236
raidBuff_P->insert (&comp_list, sizeof(raidCompList_S));
240
err = Dpt_Error::DPT_CMD_ERR_CANT_FIND_COMPONENT;
247
err = Dpt_Error::DPT_CMD_ERR_CANT_FIND_COMPONENT;
252
err = engine->Send(MSG_RAID_CHANGE, mgrTag, deadBuff_P,
260
tempBuff_P->writeIndex = 4;
261
smUB_P->arrayFlags |= SMU_EXPANDING;
262
smUB_P->raidType = (uCHAR) 5;
263
err = engine->Send(MSG_SET_USER_BUFF, raidToExpandTag,
264
deadBuff_P, tempBuff_P);
272
engine->Insert (mgrTag);
273
engine->Send (MSG_UPDATE_ALL_STATUS);
278
out->add_Item ((char *) err);
281
err = engine->Send (MSG_RAID_HW_ENABLE);
282
if (!err.Is_Error() && !cluster_ON)
283
PrintRaidAddress(raidToExpandTag, out);
290
bool Expand::StripeSizeCapable (DPT_TAG_T compTag)
294
if (raidToExpandType == 5)
296
if ((currStripeSize + raidStripeSize) > maxStripeSize)
301
if (currStripeSize > maxStripeSize)
308
Command &Expand::Clone() const
310
ENTER ("Command &Expand::Clone() const");
312
return (*new Expand (*this));
315
/*** END OF FILE ***/