1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20
21 ********************************************************************************/
22 /*******************************************************************************/
23 /** \file
24 *
25 *
26 * This file contains Management IOCTL APIs
27 *
28 */
29 #include <sys/cdefs.h>
30 #include <dev/pms/config.h>
31
32 #include <dev/pms/freebsd/driver/common/osenv.h>
33 #include <dev/pms/freebsd/driver/common/ostypes.h>
34 #include <dev/pms/freebsd/driver/common/osdebug.h>
35
36 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
37 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
38 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
39
40 #include <dev/pms/RefTisa/tisa/api/titypes.h>
41 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
42 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
43 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
44
45 #ifdef FDS_SM
46 #include <dev/pms/RefTisa/sat/api/sm.h>
47 #include <dev/pms/RefTisa/sat/api/smapi.h>
48 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
49 #endif
50
51 #ifdef FDS_DM
52 #include <dev/pms/RefTisa/discovery/api/dm.h>
53 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
54 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
55 #endif
56
57 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
58 #include <dev/pms/freebsd/driver/common/osstring.h>
59 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
60 #include <dev/pms/RefTisa/sallsdk/spc/mpidebug.h>
61
62 #ifdef INITIATOR_DRIVER
63 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
66 #endif
67
68 #ifdef TARGET_DRIVER
69 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
72 #endif
73
74 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
76 #include <dev/pms/RefTisa/tisa/sassata/common/tdioctl.h>
77
78 #include <dev/pms/RefTisa/sallsdk/spc/sadefs.h>
79 #include <dev/pms/RefTisa/sallsdk/spc/spcdefs.h>
80 #include <dev/pms/RefTisa/sallsdk/spc/mpi.h>
81 #include <dev/pms/RefTisa/sallsdk/spc/sallist.h>
82 #include <dev/pms/RefTisa/sallsdk/spc/satypes.h>
83
84
85 #define agFieldOffset(baseType,fieldName) \
86 /*lint -e545 */ \
87 ((bit32)((bitptr)(&(((baseType *)0)->fieldName)))) \
88
89 #ifdef SA_LL_API_TEST
90 osGLOBAL bit32 tdLlApiTestIoctl(tiRoot_t *tiRoot,
91 tiIOCTLPayload_t *agIOCTLPayload,
92 void *agParam1,
93 void *agParam2,
94 void *agParam3);
95 #endif /* SA_LL_API_TEST */
96
97
98 extern bit32 volatile sgpioResponseSet;
99
100 #ifdef SPC_ENABLE_PROFILE
101 /*****************************************************************************
102 *
103 * tdipFWProfileIoctl
104 *
105 * Purpose: This routine is called to process the FW Profile IOCTL function.
106 * This function is used for both target and initiator.
107 *
108 * Parameters:
109 * tiRoot: Pointer to driver instance
110 * agIOCTLPayload: Pointer to the IOCTL payload.
111 * agParam1: Pointer to pass context handle for IOCTL DMA operation
112 * agParam2: Pointer to pass context handle for IOCTL DMA operation
113 * agParam3: Pointer to pass context handle for IOCTL DMA operation
114 *
115 * Return:
116 *
117 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
118 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
119 * Detail error code is function specific and
120 * defined by the specific IOCTL function.
121 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
122 *
123 *
124 *****************************************************************************/
tdipFWProfileIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)125 osGLOBAL bit32 tdipFWProfileIoctl(
126 tiRoot_t *tiRoot,
127 tiIOCTLPayload_t *agIOCTLPayload,
128 void *agParam1,
129 void *agParam2,
130 void *agParam3
131 )
132 {
133
134 bit32 status = IOCTL_CALL_SUCCESS;
135 bit32 bufAddrUpper = 0;
136 bit32 bufAddrLower = 0;
137 tdFWProfile_t *fwProfile;
138
139 void *osMemHandle = agNULL;
140 void *buffer = agNULL;
141 agsaFwProfile_t fwProfileInfo = {0};
142
143 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
144 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
145 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
146
147 fwProfile = (tdFWProfile_t *)&agIOCTLPayload->FunctionSpecificArea[0];
148
149
150 fwProfileInfo.processor = fwProfile->processor;
151 fwProfileInfo.cmd = fwProfile->cmd;
152 fwProfileInfo.len = fwProfile->len;
153 fwProfileInfo.tcid = fwProfile->tcid;
154 if(fwProfile->cmd == START_CODE_PROFILE)
155 {
156 fwProfileInfo.codeStartAdd = fwProfile->codeStartAdd;
157 fwProfileInfo.codeEndAdd = fwProfile->codeEndAdd;
158 }
159 if((fwProfile->cmd == STOP_TIMER_PROFILE) || (fwProfile->cmd == STOP_CODE_PROFILE))
160 {
161 if(fwProfile->len != 0)
162 {
163 if(ostiAllocMemory( tiRoot,
164 &osMemHandle,
165 (void **)&buffer,
166 &bufAddrUpper,
167 &bufAddrLower,
168 8,
169 fwProfile->len,
170 agFALSE))
171 {
172 return IOCTL_CALL_FAIL;
173 }
174 osti_memset((void *)buffer, 0, fwProfile->len);
175 }
176 fwProfileInfo.agSgl.sgLower = bufAddrLower;
177 fwProfileInfo.agSgl.sgUpper = bufAddrUpper;
178 fwProfileInfo.agSgl.len = fwProfile->len;
179 fwProfileInfo.agSgl.extReserved = 0;
180 tdsaAllShared->tdFWProfileEx.buffer = osMemHandle;
181 tdsaAllShared->tdFWProfileEx.virtAddr = buffer;
182 tdsaAllShared->tdFWProfileEx.len = fwProfile->len;
183 }
184 tdsaAllShared->tdFWProfileEx.tdFWProfile = fwProfile;
185 tdsaAllShared->tdFWProfileEx.param1 = agParam1;
186 tdsaAllShared->tdFWProfileEx.param2 = agParam2;
187 tdsaAllShared->tdFWProfileEx.payload = agIOCTLPayload;
188 tdsaAllShared->tdFWProfileEx.inProgress = 1;
189 status = saFwProfile(agRoot,
190 agNULL,
191 0,
192 &fwProfileInfo
193 );
194 if(status)
195 {
196 if((fwProfile->cmd == STOP_TIMER_PROFILE) || (fwProfile->cmd == STOP_CODE_PROFILE))
197 ostiFreeMemory(tiRoot, osMemHandle, fwProfile->len);
198 status = IOCTL_CALL_FAIL;
199 }
200 else
201 status = IOCTL_CALL_PENDING;
202 return status;
203 }
204
205
206 #endif
207
208 /*****************************************************************************
209 *
210 * tdipFWControlIoctl
211 *
212 * Purpose: This routine is called to process the FW control IOCTL function.
213 * This function is used for both target and initiator.
214 *
215 * Parameters:
216 * tiRoot: Pointer to driver instance
217 * agIOCTLPayload: Pointer to the IOCTL payload.
218 * agParam1: Pointer to pass context handle for IOCTL DMA operation
219 * agParam2: Pointer to pass context handle for IOCTL DMA operation
220 * agParam3: Pointer to pass context handle for IOCTL DMA operation
221 *
222 * Return:
223 *
224 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
225 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
226 * Detail error code is function specific and
227 * defined by the specific IOCTL function.
228 * IOCTL_CALL_PENDING This request is asynchronous and completed
229 * in some other context.
230 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
231 *
232 *
233 *****************************************************************************/
tdipFWControlIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)234 osGLOBAL bit32 tdipFWControlIoctl(
235 tiRoot_t *tiRoot,
236 tiIOCTLPayload_t *agIOCTLPayload,
237 void *agParam1,
238 void *agParam2,
239 void *agParam3
240 ) {
241
242 bit32 status = IOCTL_CALL_PENDING;
243 bit32 bufAddrUpper = 0;
244 bit32 bufAddrLower = 0;
245 tdFWControl_t *fwControl;
246 void *osMemHandle = agNULL;
247 void *buffer = agNULL;
248 agsaUpdateFwFlash_t flashUpdateInfo;
249 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
250 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
251 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
252
253 if( agIOCTLPayload->Length <
254 ( agFieldOffset(tiIOCTLPayload_t, FunctionSpecificArea) +
255 sizeof(tdFWControl_t) ) ) {
256 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
257 status = IOCTL_CALL_FAIL;
258 return status;
259 }
260 fwControl = (tdFWControl_t *)&agIOCTLPayload->FunctionSpecificArea[0];
261
262 if(fwControl->len != 0)
263 {
264 if(ostiAllocMemory( tiRoot,
265 &osMemHandle,
266 (void **)&buffer,
267 &bufAddrUpper,
268 &bufAddrLower,
269 8,
270 fwControl->len,
271 agFALSE) )
272 return IOCTL_CALL_FAIL;
273 }
274 osti_memset( (void *)buffer, 0, fwControl->len );
275 osti_memcpy( (void *)buffer,
276 fwControl->buffer,
277 fwControl->len );
278 flashUpdateInfo.agSgl.sgLower = bufAddrLower;
279 flashUpdateInfo.agSgl.sgUpper = bufAddrUpper;
280 flashUpdateInfo.agSgl.len = fwControl->len;
281 flashUpdateInfo.agSgl.extReserved = 0;
282 flashUpdateInfo.currentImageOffset = fwControl->offset;
283 flashUpdateInfo.currentImageLen = fwControl->len;
284 flashUpdateInfo.totalImageLen = fwControl->size;
285 switch (agIOCTLPayload->MinorFunction)
286 {
287 case IOCTL_MN_FW_DOWNLOAD_DATA:
288 {
289 TI_DBG6(("tdipFWControlIoctl: calling saFwFlashUpdate\n"));
290 tdsaAllShared->tdFWControlEx.tdFWControl = fwControl;
291 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
292 tdsaAllShared->tdFWControlEx.param1 = agParam1;
293 tdsaAllShared->tdFWControlEx.param2 = agParam2;
294 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
295 tdsaAllShared->tdFWControlEx.inProgress = 1;
296 status = saFwFlashUpdate( agRoot,
297 agNULL,
298 0,
299 &flashUpdateInfo );
300 if(status) {
301 status = IOCTL_CALL_FAIL;
302 fwControl->retcode = IOCTL_CALL_TIMEOUT;
303 }
304 else {
305 status = IOCTL_CALL_PENDING;
306 }
307 break;
308 }
309 default:
310 status = IOCTL_CALL_INVALID_CODE;
311 TI_DBG1( ("tdipFWControlIoctl: ERROR: Wrong IOCTL code %d\n",
312 agIOCTLPayload->MinorFunction) );
313 ostiFreeMemory(tiRoot, osMemHandle, fwControl->len);
314 return status;
315 } /* end IOCTL switch */
316 return status;
317 } /* tdipFWControlIoctl */
318
319
320 /*****************************************************************************
321 *
322 * tiCOMMgntIOCTL
323 *
324 * Purpose: This routine is a TISA API for processing the PMC specific
325 * IOCTL function.
326 *
327 * Each IOCTL function is identified by the IOCTL header
328 * specified in the data payload as the following:
329 * Field Description
330 * ----- -----------
331 * Signature PMC IOCTL signature.
332 * #define PMC_IOCTL_SIGNATURE 0x1234
333 * MajorFunction Major function number.
334 * MinorFunction Minor function number.
335 * Length Length of this structure in bytes.
336 * Status Return status for this IOCTL function.
337 * FunctionSpecificArea Variable length function specific area.
338 *
339 * Parameters:
340 * tiRoot: Pointer to driver instance
341 * agIOCTLPayload: Pointer to the IOCTL payload.
342 * agParam1: Pointer to pass context handle for IOCTL DMA operation
343 * agParam2: Pointer to pass context handle for IOCTL DMA operation
344 * agParam3: Pointer to pass context handle for IOCTL DMA operation
345 *
346 * Return:
347 *
348 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
349 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
350 * Detail error code is function specific and
351 * defined by the specific IOCTL function.
352 * IOCTL_CALL_PENDING This request is asynchronous and completed
353 * in some other context.
354 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
355 * IOCTL_CALL_INVALID_DEVICE Invalid target or destination device.
356 *
357 * Note:
358 * Used ostiAllocMemory() OS layer callback function to allocate memory
359 * for DMA operaion. Then use ostiFreeMemory() to deallocate the memory.
360 *
361 *****************************************************************************/
362 osGLOBAL bit32
tiCOMMgntIOCTL(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)363 tiCOMMgntIOCTL(
364 tiRoot_t *tiRoot,
365 tiIOCTLPayload_t *agIOCTLPayload,
366 void *agParam1,
367 void *agParam2,
368 void *agParam3
369 )
370 {
371 bit32 status = IOCTL_CALL_INVALID_CODE;
372 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
373 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
374 agsaRoot_t *agRoot = &(tdsaAllShared->agRootNonInt);
375 bit32 EventLogLength = 0;
376 bit32 EventLogOption;
377 bit32 ReadLength = 0;
378 bit32 Offset = 0;
379 bit32 RequestLength = 0; /* user request on how much data to pass to application */
380 agsaContext_t *agContext = NULL;
381 bit8 *loc = NULL;
382
383 TI_DBG3(("tiCOMMgntIOCTL: start\n"));
384
385 TI_DBG3(("tiCOMMgntIOCTL: tiRoot %p agIOCTLPayload %p agParam1 %p agParam2 %p agParam3 %p\n",
386 tiRoot,agIOCTLPayload,agParam1,agParam2,agParam3 ));
387
388 TI_DBG3(("tiCOMMgntIOCTL: Signature %X\ntiCOMMgntIOCTL: MajorFunction 0x%X\ntiCOMMgntIOCTL: MinorFunction 0x%X\ntiCOMMgntIOCTL: Length 0x%X\ntiCOMMgntIOCTL: Status 0x%X\ntiCOMMgntIOCTL: Reserved 0x%X\ntiCOMMgntIOCTL: FunctionSpecificArea 0x%X\n",
389 agIOCTLPayload->Signature,
390 agIOCTLPayload->MajorFunction,
391 agIOCTLPayload->MinorFunction,
392 agIOCTLPayload->Length,
393 agIOCTLPayload->Status,
394 agIOCTLPayload->Reserved,
395 agIOCTLPayload->FunctionSpecificArea[0] ));
396
397 /* PMC IOCTL signatures matched ? */
398 if(agIOCTLPayload->Signature != PMC_IOCTL_SIGNATURE)
399 {
400 TI_DBG1(("tiCOMMgntIOCTL:agIOCTLPayload->Signature %x IOCTL_CALL_INVALID_CODE\n",agIOCTLPayload->Signature ));
401 status = IOCTL_CALL_INVALID_CODE;
402 return (status);
403 }
404
405 switch (agIOCTLPayload->MajorFunction)
406 {
407 //TODO: make the card identification more robust. For now - just to keep going with FW download
408 #ifdef IOCTL_INTERRUPT_TIME_CONFIG
409 case IOCTL_MJ_CARD_PARAMETER:
410 {
411 switch( agIOCTLPayload->MinorFunction )
412 {
413 case IOCTL_MN_CARD_GET_INTERRUPT_CONFIG:
414 {
415 agsaInterruptConfigPage_t *pInterruptConfig = (agsaInterruptConfigPage_t *)&agIOCTLPayload->FunctionSpecificArea[0];
416 status = saGetControllerConfig(agRoot,
417 0,
418 AGSA_INTERRUPT_CONFIGURATION_PAGE,
419 pInterruptConfig->vectorMask0,
420 pInterruptConfig->vectorMask1,
421 agParam2);
422 if(status == AGSA_RC_SUCCESS) {
423 status = IOCTL_CALL_PENDING;
424 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
425 } else {
426 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
427 }
428 break;
429 }
430 case IOCTL_MN_CARD_GET_TIMER_CONFIG:
431 status = saGetControllerConfig(agRoot, 0, AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE, 0, 0, agParam2);
432 if(status == AGSA_RC_SUCCESS) {
433 status = IOCTL_CALL_PENDING;
434 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
435 } else {
436 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
437 }
438 break;
439 }
440 break;
441 }
442 #endif /* IOCTL_INTERRUPT_TIME_CONFIG */
443 case IOCTL_MJ_INI_DRIVER_IDENTIFY:
444 {
445 status=IOCTL_CALL_SUCCESS;
446 break;
447 }
448 case IOCTL_MJ_GET_DEVICE_LUN:
449 status = tdsaGetNumOfLUNIOCTL(tiRoot,agIOCTLPayload, agParam1, agParam2, agParam3);
450 if(status == IOCTL_CALL_SUCCESS)
451 {
452 status = IOCTL_CALL_PENDING;
453 }
454 break;
455 case IOCTL_MJ_SMP_REQUEST:
456 status = tdsaSendSMPIoctl(tiRoot, agIOCTLPayload,
457 agParam1,agParam2,agParam3);
458 break;
459
460 case IOCTL_MJ_FW_CONTROL:
461 {
462 //ostiIOCTLClearSignal (tiRoot, &agParam1, &agParam2, &agParam3);
463 status = tdipFWControlIoctl( tiRoot, agIOCTLPayload,
464 agParam1, agParam2, agParam3);
465
466 break;
467 }
468 //#ifdef EVENT_LOG_INFO_TESTING
469 /* Reserved field in tiIOCTLPayload_t is used as offset */
470 case IOCTL_MJ_GET_EVENT_LOG1:
471 {
472 switch (agIOCTLPayload->MinorFunction)
473 {
474 case IOCTL_MN_FW_GET_TRACE_BUFFER:
475 {
476 agsaControllerEventLog_t EventLog;
477 saGetControllerEventLogInfo(agRoot, &EventLog);
478 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_GET_EVENT_LOG1 Length %d\n", agIOCTLPayload->Length));
479 RequestLength = agIOCTLPayload->Length;
480 Offset = agIOCTLPayload->Reserved;
481 EventLogLength = EventLog.eventLog1.totalLength;
482 EventLogOption = EventLog.eventLog1Option;
483 if (EventLogLength <= Offset)
484 {
485 TI_DBG1(("tiCOMMgntIOCTL: 1 out of range Requestlength %d Offset %d event log length %d\n", RequestLength, Offset, EventLogLength));
486 // out of range
487 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
488 agIOCTLPayload->Length = 0;
489 if(EventLogOption == 0)
490 {
491 agIOCTLPayload->Status = IOCTL_ERR_FW_EVENTLOG_DISABLED;
492 }
493 status=IOCTL_CALL_SUCCESS;
494 return status;
495 }
496 ReadLength = MIN(EventLogLength - Offset, RequestLength);
497 loc = (bit8 *)EventLog.eventLog1.virtPtr + Offset;
498 osti_memcpy(&(agIOCTLPayload->FunctionSpecificArea), loc, ReadLength);
499 // tdhexdump("IOCTL_MJ_GET_EVENT_LOG1 first 32bytes", (bit8 *)&(agIOCTLPayload->FunctionSpecificArea), 32);
500 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
501 agIOCTLPayload->Length = (bit16)ReadLength;
502 status=IOCTL_CALL_SUCCESS;
503 break;
504 }
505 case IOCTL_MN_FW_GET_EVENT_FLASH_LOG1:
506 {
507 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MN_FW_GET_EVENT_FLASH_LOG1\n"));
508 status = tdsaRegDumpGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
509 break;
510 }
511 }
512 break;
513 }
514
515 case IOCTL_MJ_GET_EVENT_LOG2:
516 {
517 switch (agIOCTLPayload->MinorFunction)
518 {
519 case IOCTL_MN_FW_GET_TRACE_BUFFER:
520 {
521 agsaControllerEventLog_t EventLog;
522 saGetControllerEventLogInfo(agRoot, &EventLog);
523 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_GET_EVENT_LOG2 Length %d\n", agIOCTLPayload->Length));
524 RequestLength = agIOCTLPayload->Length;
525 Offset = agIOCTLPayload->Reserved;
526 EventLogLength = EventLog.eventLog2.totalLength;
527 EventLogOption = EventLog.eventLog2Option;
528 if (EventLogLength <= Offset)
529 {
530 TI_DBG1(("tiCOMMgntIOCTL: 2 out of range Requestlength %d Offset %d event log length %d\n", RequestLength, Offset, EventLogLength));
531 /* out of range */
532 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
533 agIOCTLPayload->Length = 0;
534 if(EventLogOption == 0)
535 {
536 agIOCTLPayload->Status = IOCTL_ERR_FW_EVENTLOG_DISABLED;
537 }
538 status=IOCTL_CALL_SUCCESS;
539 return status;
540 }
541 ReadLength = MIN(EventLogLength - Offset, RequestLength);
542 loc = (bit8 *)EventLog.eventLog2.virtPtr + Offset;
543 osti_memcpy(&(agIOCTLPayload->FunctionSpecificArea), loc, ReadLength);
544 // tdhexdump("IOCTL_MJ_GET_EVENT_LOG2 first 32bytes", (bit8 *)&(agIOCTLPayload->FunctionSpecificArea), 32);
545 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
546 agIOCTLPayload->Length = (bit16)ReadLength;
547 status=IOCTL_CALL_SUCCESS;
548 break;
549 }
550 case IOCTL_MN_FW_GET_EVENT_FLASH_LOG2:
551 {
552 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MN_FW_GET_EVENT_FLASH_LOG2\n"));
553 status = tdsaRegDumpGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
554 break;
555 }
556 }
557 break;
558 }
559
560
561 case IOCTL_MJ_FW_INFO:
562 {
563 agsaControllerInfo_t ControllerInfo;
564 saGetControllerInfo(agRoot, &ControllerInfo);
565 TI_DBG1(("tiCOMMgntIOCTL: IOCTL_MJ_FW_INFO Length %d\n", agIOCTLPayload->Length));
566 RequestLength = agIOCTLPayload->Length;
567 Offset = agIOCTLPayload->Reserved;
568 if (RequestLength == 0)
569 {
570 TI_DBG1(("tiCOMMgntIOCTL: IOCTL_MJ_FW_INFO: No more Data!\n"));
571 /* out of range */
572 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
573 agIOCTLPayload->Length = 0;
574 status=IOCTL_CALL_SUCCESS;
575 return status;
576 }
577
578 osti_memcpy((bit8*)&(agIOCTLPayload->FunctionSpecificArea), (bit8*)&ControllerInfo, sizeof(agsaControllerInfo_t));
579
580 TI_DBG1(("tiCOMMgntIOCTL:IOCTL_MJ_FW_INFO ControllerInfo signature 0x%X\n",ControllerInfo.signature));
581 TI_DBG1(("tiCOMMgntIOCTL:IOCTL_MJ_FW_INFO ControllerInfo PCILinkRate 0x%X\n",ControllerInfo.PCILinkRate));
582 TI_DBG1(("tiCOMMgntIOCTL:IOCTL_MJ_FW_INFO ControllerInfo PCIWidth 0x%X\n",ControllerInfo.PCIWidth));
583 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
584 status=IOCTL_CALL_SUCCESS;
585 break;
586
587 }
588
589 case IOCTL_MJ_GET_FW_REV:
590 {
591 agsaControllerInfo_t ControllerInfo;
592 saGetControllerInfo(agRoot, &ControllerInfo);
593 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_GET_FW_REV Length %d\n", agIOCTLPayload->Length));
594 RequestLength = agIOCTLPayload->Length;
595 Offset = agIOCTLPayload->Reserved;
596 if (RequestLength == 0)
597 {
598 TI_DBG1(("tiCOMMgntIOCTL: IOCTL_MJ_GET_FW_REV: No more Data!\n"));
599 /* out of range */
600 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
601 agIOCTLPayload->Length = 0;
602 status=IOCTL_CALL_SUCCESS;
603 return status;
604 }
605
606 osti_memcpy((bit8*)&(agIOCTLPayload->FunctionSpecificArea), (bit8*)&ControllerInfo.fwRevision, sizeof(bit32));
607 loc = (bit8 *)&(agIOCTLPayload->FunctionSpecificArea)+ sizeof(bit32);
608 osti_memcpy(loc, (bit8*)&ControllerInfo.sdkRevision, sizeof(bit32));
609
610 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
611 status=IOCTL_CALL_SUCCESS;
612 break;
613
614 }
615
616 #ifdef SPC_ENABLE_PROFILE
617 case IOCTL_MJ_FW_PROFILE:
618 {
619 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_FW_PROFILE\n"));
620 status = tdipFWProfileIoctl( tiRoot, agIOCTLPayload,
621 agParam1, agParam2, agParam3);
622 break;
623 }
624 #endif /* SPC_ENABLE_PROFILE */
625
626 case IOCTL_MJ_GET_CORE_DUMP:
627 {
628 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_GET_CORE_DUMP\n"));
629 if (tiIS_SPC(agRoot))
630 {
631 status = tdsaRegDumpGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
632 }
633 else
634 {
635 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NOT_SUPPORTED;
636 status = IOCTL_CALL_SUCCESS;
637 }
638 break;
639 }
640 //#endif
641 case IOCTL_MJ_NVMD_SET:
642 {
643 bit8 nvmDev;
644 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_NVMD_SET\n"));
645 nvmDev = (bit8) agIOCTLPayload->Status;
646 agIOCTLPayload->Status = 0;
647 status = tdsaNVMDSetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, &nvmDev);
648 break;
649 }
650 #if 0
651 case IOCTL_MJ_GPIO:
652 {
653 bit32 sVid =0;
654 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_GPIO\n"));
655
656 /* Get Subsystem vendor */
657 sVid = ostiChipConfigReadBit32(tiRoot,0x2C);
658 sVid = sVid & 0xFFFF;
659
660 /* GPIO is only intended for chip down design
661 * therefore it's only applies to 8H/SPCv product family
662 */
663 if(sVid == 0x9005)
664 return IOCTL_CALL_INVALID_DEVICE;
665
666 status = tdsaGpioSetup(tiRoot, agContext, agIOCTLPayload, agParam1, agParam2);
667 if(status == IOCTL_CALL_SUCCESS)
668 status = IOCTL_CALL_PENDING; /* Wait for response from the Controller */
669 else
670 return status;
671
672 break;
673 }
674 #endif
675
676 case IOCTL_MJ_SGPIO:
677 {
678 TI_DBG6(("tiCOMMgntIOCTL: IOCTL_MJ_SGPIO\n"));
679 status = tdsaSGpioIoctlSetup(tiRoot, agContext, agIOCTLPayload, agParam1, agParam2);
680 break;
681 }
682
683 case IOCTL_MJ_NVMD_GET:
684 {
685 bit8 nvmDev;
686 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_NVMD_GET\n"));
687 nvmDev = (bit8) agIOCTLPayload->Status;
688 agIOCTLPayload->Status = 0;
689 status = tdsaNVMDGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, &nvmDev);
690 break;
691 }
692
693 case IOCTL_MJ_GET_FORENSIC_DATA:
694 {
695 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_GET_FORENSIC_DATA\n"));
696 status = tdsaForensicDataGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
697 break;
698 }
699 case IOCTL_MJ_GET_DEVICE_INFO:
700 {
701 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_GET_DEVICE_INFO\n"));
702 status = tdsaDeviceInfoGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
703 break;
704 }
705
706 case IOCTL_MJ_GET_IO_ERROR_STATISTIC:
707 {
708 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_GET_IO_ERROR_STATISTIC\n"));
709 status = tdsaIoErrorStatisticGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
710 break;
711 }
712
713 case IOCTL_MJ_GET_IO_EVENT_STATISTIC:
714 {
715 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_GET_IO_EVENT_STATISTIC\n"));
716 status = tdsaIoEventStatisticGetIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
717 break;
718 }
719
720 case IOCTL_MJ_SEND_BIST:
721 {
722 TI_DBG1(("tiCOMMgntIOCTL: IOCTL_MJ_SEND_BIST\n"));
723 status = tdsaSendBISTIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
724 break;
725 }
726
727 #if 0
728 case IOCTL_MJ_SET_OR_GET_REGISTER:
729 {
730 TI_DBG3(("tiCOMMgntIOCTL: IOCTL_MJ_SET_OR_GET_REGISTER\n"));
731 status = tdsaRegisterIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
732 break;
733 }
734
735 #endif
736 case IOCTL_MJ_PHY_DETAILS:
737 {
738 PhyDetails_t *PhyDetails = (PhyDetails_t*)&agIOCTLPayload->FunctionSpecificArea;
739 agsaRoot_t *agRoot = &(tdsaAllShared->agRootNonInt);
740 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
741 bit8 *sasAddressHi;
742 bit8 *sasAddressLo;
743 bit8 sas_dev_type;
744 int i = 0;
745
746 tiIniGetDirectSataSasAddr(tiRoot, i , &sasAddressHi, &sasAddressLo);
747 for( i = 0; i < saRoot->phyCount ; i++)
748 {
749 PhyDetails[i].attached_phy = saRoot->phys[i].sasIdentify.phyIdentifier;
750 /* deice types
751 * SAS
752 * 0x01 - Sas end device
753 * 0x02 - Expander device
754 * SATA
755 * 0x11 - Sata
756 * NO DEVICE 0x00
757 */
758 sas_dev_type = (saRoot->phys[i].sasIdentify.deviceType_addressFrameType & 0x70 ) >> 4 ;
759 if ((saRoot->phys[i].status == 1) && (sas_dev_type == 0)){ //status 1 - Phy Up
760 //Sata phy
761 PhyDetails[i].attached_dev_type = SAS_PHY_SATA_DEVICE;//0x11 for sata end device
762 osti_memcpy(&PhyDetails[i].attached_sasAddressHi, tdsaAllShared->Ports[i].SASID.sasAddressHi, sizeof(bit32));
763 osti_memcpy(&PhyDetails[i].attached_sasAddressLo, tdsaAllShared->Ports[i].SASID.sasAddressLo, sizeof(bit32));
764 PhyDetails[i].attached_sasAddressLo[3] += i + 16;
765 }
766 else {
767 PhyDetails[i].attached_dev_type = sas_dev_type;
768 osti_memcpy(&PhyDetails[i].attached_sasAddressHi, saRoot->phys[i].sasIdentify.sasAddressHi, sizeof(bit32));
769 osti_memcpy(&PhyDetails[i].attached_sasAddressLo, saRoot->phys[i].sasIdentify.sasAddressLo, sizeof(bit32));
770 }
771 osti_memcpy(&PhyDetails[i].sasAddressLo,&(tdsaAllShared->Ports[i].SASID.sasAddressLo), sizeof(bit32));
772 osti_memcpy(&PhyDetails[i].sasAddressHi,&(tdsaAllShared->Ports[i].SASID.sasAddressHi), sizeof(bit32));
773 }
774
775 // osti_memcpy(&agIoctlPayload->FunctionSpecificArea,&PhyInfo, sizeof(agsaSGpioReqResponse_t));
776 // printk("Ioctl success\n");
777 return IOCTL_CALL_SUCCESS;
778 }
779
780 case IOCTL_MJ_PHY_GENERAL_STATUS:
781 {
782 agsaPhyGeneralState_t *PhyData=NULL;
783 bit32 ret = AGSA_RC_FAILURE;
784 PhyData = (agsaPhyGeneralState_t*) &agIOCTLPayload->FunctionSpecificArea[0];
785
786 PhyData->Reserved2 = 0;
787 /* Validate the length */
788 if (agIOCTLPayload->Length < sizeof(agsaPhyGeneralState_t))
789 {
790 status = IOCTL_CALL_FAIL;
791 break;
792 }
793
794 tdsaAllShared->tdFWControlEx.param1 = agParam1;
795 tdsaAllShared->tdFWControlEx.param2 = agParam2;
796 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
797 tdsaAllShared->tdFWControlEx.inProgress = 1;
798 //tdsaAllShared->tdFWControlEx.usrAddr = PhyData;
799
800 ret = tdsaGetPhyGeneralStatusIoctl(tiRoot,PhyData);
801 if(ret == AGSA_RC_FAILURE)
802 {
803 status = IOCTL_CALL_FAIL;
804 tdsaAllShared->tdFWControlEx.payload = NULL;
805 tdsaAllShared->tdFWControlEx.inProgress = 0;
806 break;
807 }
808 else if(ret == IOCTL_ERR_STATUS_NOT_SUPPORTED)
809 {
810
811 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NOT_SUPPORTED;
812 status = IOCTL_CALL_SUCCESS;
813 break;
814 }
815
816 //status = IOCTL_CALL_PENDING;
817 status = IOCTL_CALL_PENDING;
818 }
819
820 break;
821 #if 1
822 case IOCTL_MJ_GET_PHY_PROFILE:
823 {
824 TI_DBG1(("tiCOMMgntIOCTL: IOCTL_MJ_GET_PHY_PROFILE %p %p %p\n",agParam1,agParam2,agParam3));
825 status = tdsaPhyProfileIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, agParam3);
826 break;
827 }
828 #endif
829 case IOCTL_MJ_LL_TRACING:
830 {
831 void * stu = &agIOCTLPayload->FunctionSpecificArea[0];
832 switch(agIOCTLPayload->MinorFunction)
833 {
834
835 case IOCTL_MN_LL_RESET_TRACE_INDEX:
836 {
837
838 #ifdef SA_ENABLE_TRACE_FUNCTIONS
839 TSTMTID_TRACE_BUFFER_RESET *llist = (TSTMTID_TRACE_BUFFER_RESET *)stu;
840 hpTraceBufferParms_t BufferParms;
841 TI_DBG5(("tdReturnIOCTL_Info: hpIOCTL_ResetTraceIndex\n"));
842
843 BufferParms.TraceCompiled = 0;
844 BufferParms.TraceWrap = 0;
845 BufferParms.CurrentTraceIndexWrapCount = 0;
846 BufferParms.BufferSize = 0;
847 BufferParms.CurrentIndex = 0;
848 BufferParms.pTrace = NULL;
849 BufferParms.pTraceIndexWrapCount = NULL;
850 BufferParms.pTraceMask = NULL;
851 BufferParms.pCurrentTraceIndex = NULL;
852
853 smTraceGetInfo(agRoot,&BufferParms);
854 TI_DBG5(("tdReturnIOCTL_Info: pTrace %p\n",BufferParms.pTrace));
855 TI_DBG5(("tdReturnIOCTL_Info: pCurrentTraceIndex %p %X\n",BufferParms.pCurrentTraceIndex,*BufferParms.pCurrentTraceIndex));
856 TI_DBG5(("tdReturnIOCTL_Info: pTraceIndexWrapCount %p %X\n",BufferParms.pTraceIndexWrapCount,*BufferParms.pTraceIndexWrapCount));
857 TI_DBG5(("tdReturnIOCTL_Info: pTraceMask %p %X\n",BufferParms.pTraceMask,*BufferParms.pTraceMask));
858
859 if( llist->Flag != 0)
860 {
861 if( llist->TraceMask != *BufferParms.pTraceMask)
862 {
863 smTraceSetMask(agRoot, llist->TraceMask );
864 }
865 }
866 if( llist->Reset)
867 {
868
869 *BufferParms.pCurrentTraceIndex = 0;
870 smResetTraceBuffer(agRoot);
871
872 *BufferParms.pCurrentTraceIndex = 0;
873 *BufferParms.pTraceIndexWrapCount =0;
874 llist->TraceMask = *BufferParms.pTraceMask;
875 }
876 #endif /* SA_ENABLE_TRACE_FUNCTIONS */
877 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
878 status = IOCTL_CALL_SUCCESS;
879
880 }
881 break;
882
883 case IOCTL_MN_LL_GET_TRACE_BUFFER_INFO:
884 {
885 hpTraceBufferParms_t BufferParms;
886 TSTMTID_TRACE_BUFFER_INFO *llist = (TSTMTID_TRACE_BUFFER_INFO *)stu;
887 TI_DBG5(("tdReturnIOCTL_Info: hpIOCTL_GetTraceBufferInfo\n"));
888
889
890 BufferParms.TraceCompiled = 0;
891 BufferParms.TraceWrap = 0;
892 BufferParms.CurrentTraceIndexWrapCount = 0;
893 BufferParms.BufferSize = 0;
894 BufferParms.CurrentIndex = 0;
895 BufferParms.pTrace = NULL;
896 BufferParms.pTraceMask = NULL;
897 #ifdef SA_ENABLE_TRACE_FUNCTIONS
898 smTraceGetInfo(agRoot,&BufferParms);
899 #endif /* SA_ENABLE_TRACE_FUNCTIONS not enabled */
900 llist->TraceCompiled = BufferParms.TraceCompiled;
901 llist->BufferSize = BufferParms.BufferSize;
902 llist->CurrentIndex = BufferParms.CurrentIndex ;
903 llist->CurrentTraceIndexWrapCount = BufferParms.CurrentTraceIndexWrapCount;
904 llist->TraceWrap = BufferParms.TraceWrap;
905 if(BufferParms.pTraceMask != NULL)
906 {
907 llist->TraceMask = *BufferParms.pTraceMask;
908 }
909 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
910 status = IOCTL_CALL_SUCCESS;
911 }
912 break;
913
914 case IOCTL_MN_LL_GET_TRACE_BUFFER:
915 {
916 #ifdef SA_ENABLE_TRACE_FUNCTIONS
917 TSTMTID_TRACE_BUFFER_FETCH *llist = (TSTMTID_TRACE_BUFFER_FETCH *)stu;
918
919 hpTraceBufferParms_t BufferParms;
920 bit32 c= 0;
921
922 BufferParms.TraceCompiled = 0;
923 BufferParms.TraceWrap = 0;
924 BufferParms.CurrentTraceIndexWrapCount = 0;
925 BufferParms.BufferSize = 0;
926 BufferParms.CurrentIndex = 0;
927 BufferParms.pTrace = NULL;
928 smTraceGetInfo(agRoot,&BufferParms);
929
930 TI_DBG6(("tdReturnIOCTL_Info: hpIOCTL_GetTraceBuffer\n"));
931
932 if(llist->LowFence != LowFence32Bits)
933 {
934 break;
935 }
936 if(llist->HighFence != HighFence32Bits)
937 {
938 break;
939 }
940
941 if(llist->BufferOffsetBegin + FetchBufferSIZE > BufferParms.BufferSize )
942 {
943 }
944
945 for ( c=0; c < FetchBufferSIZE;c++)
946 {
947 llist->Data[c] = *(BufferParms.pTrace+( c + llist->BufferOffsetBegin));
948 }
949 #endif /* SA_ENABLE_TRACE_FUNCTIONS not enabled */
950 }
951 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
952 status = IOCTL_CALL_SUCCESS;
953 break;
954 }
955 break;
956 }
957
958 #ifdef SA_LL_API_TEST
959 case IOCTL_MJ_LL_API_TEST:
960 {
961 status = tdLlApiTestIoctl( tiRoot, agIOCTLPayload,
962 agParam1,agParam2,agParam3 );
963 break;
964 }
965
966 #endif /* SA_LL_API_TEST */
967
968 case IOCTL_MJ_MODE_CTL_PAGE:
969 {
970 /* The SPCv controller has some options accessed via mode pages */
971 tiEncryptDekConfigPage_t *pModePage= (tiEncryptDekConfigPage_t *) &agIOCTLPayload->FunctionSpecificArea[0];
972 bit32 pageLength = 0;
973 bit32 pageCode;
974 bit32 modeOperation;
975
976 pageCode = pModePage->pageCode & 0xFF;
977 modeOperation = *(bit32 *) agParam2;
978
979 switch(modeOperation)
980 {
981
982 case tiModePageSet:
983 switch (pageCode)
984 {
985 case TI_ENCRYPTION_DEK_CONFIG_PAGE:
986 pageLength = sizeof(tiEncryptDekConfigPage_t);
987 break;
988
989 case TI_ENCRYPTION_CONTROL_PARM_PAGE:
990 pageLength = sizeof(tiEncryptControlParamPage_t);
991 break;
992
993 case TI_ENCRYPTION_GENERAL_CONFIG_PAGE:
994 /* Pages are currently unsupported */
995 pageLength = 0;
996 break;
997 }
998
999 status = saSetControllerConfig(agRoot, 0, pageCode, pageLength, pModePage, (agsaContext_t *)agIOCTLPayload);
1000 break;
1001
1002 case tiModePageGet:
1003 status = saGetControllerConfig(agRoot, 0, pageCode, 0, 0, (agsaContext_t *)agIOCTLPayload);
1004 break;
1005
1006 default:
1007 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NOT_SUPPORTED;
1008 }
1009 }
1010 break;
1011 #ifdef PHY_RESTART_TEST
1012 case IOCTL_MJ_PORT_START:
1013 {
1014 bit32 portID, tiStatus;
1015 bit32 *data = (bit32*) &agIOCTLPayload->FunctionSpecificArea[0];
1016 portID = *data;
1017
1018 tiStatus = tiCOMPortStart(tiRoot, portID, tdsaAllShared->Ports[portID].tiPortalContext, 0);
1019
1020 if (tiStatus == tiSuccess)
1021 {
1022 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1023 }
1024 else
1025 {
1026 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1027 }
1028 status = IOCTL_CALL_SUCCESS;
1029 break;
1030 }
1031
1032 case IOCTL_MJ_PORT_STOP:
1033 {
1034 bit32 portID, tiStatus;
1035 bit32 *data = (bit32*) &agIOCTLPayload->FunctionSpecificArea[0];
1036 portID = *data;
1037
1038 tiStatus = tiCOMPortStop(tiRoot, tdsaAllShared->Ports[portID].tiPortalContext);
1039 if (tiStatus == tiSuccess)
1040 {
1041 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1042 }
1043 else
1044 {
1045 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1046 }
1047
1048 status = IOCTL_CALL_SUCCESS;
1049 break;
1050 }
1051 #endif
1052 case IOCTL_MJ_SEND_TMF:
1053 switch(agIOCTLPayload->MinorFunction)
1054 {
1055 case IOCTL_MN_TMF_DEVICE_RESET:
1056 status = tdsaSendTMFIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, AG_TARGET_WARM_RESET);
1057 break;
1058 case IOCTL_MN_TMF_LUN_RESET:
1059 status = tdsaSendTMFIoctl(tiRoot, agIOCTLPayload, agParam1, agParam2, AG_LOGICAL_UNIT_RESET);
1060 break;
1061 }
1062 break;
1063 case IOCTL_MJ_GET_DRIVER_VERSION:
1064 osti_sprintf(agIOCTLPayload->FunctionSpecificArea, "%s", AGTIAPI_DRIVER_VERSION);
1065 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1066 status=IOCTL_CALL_SUCCESS;
1067 break;
1068 default:
1069 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NOT_SUPPORTED;
1070 break;
1071 }
1072
1073 return status;
1074 }
1075
1076 #if 0
1077 /*****************************************************************************
1078 *
1079 * tdsaGpioSetup
1080 *
1081 * Purpose: This routine is called to set Gpio parameters to the controller.
1082 *
1083 * Parameters:
1084 * tiRoot: Pointer to driver instance
1085 * agsaContext_t :
1086 * tiIOCTLPayload_t : ioctl header with payload gpio info
1087 * agParam1,agParam2 : Generic parameters
1088 *
1089 * Return: status
1090 *
1091 *
1092 *****************************************************************************/
1093 osGLOBAL bit32
1094 tdsaGpioSetup(
1095 tiRoot_t *tiRoot,
1096 agsaContext_t *agContext,
1097 tiIOCTLPayload_t *agIOCTLPayload,
1098 void *agParam1,
1099 void *agParam2
1100 )
1101 {
1102
1103 tdsaTimerRequest_t *osIoctlTimer;
1104 agsaGpioEventSetupInfo_t *gpioEventSetupInfo;
1105 agsaGpioWriteSetupInfo_t *gpioWriteSetupInfo;
1106 agsaGpioPinSetupInfo_t *gpioPinSetupInfo;
1107 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1108 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1109 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
1110 bit32 status = IOCTL_CALL_SUCCESS;
1111
1112 TI_DBG3(("tdsaGpioSetup: start\n"));
1113
1114 if(tiRoot == agNULL || agIOCTLPayload == agNULL )
1115 return IOCTL_CALL_FAIL;
1116
1117 osIoctlTimer = &tdsaAllShared->osIoctlTimer;
1118 tdsaInitTimerRequest(tiRoot, osIoctlTimer);
1119 tdIoctlStartTimer(tiRoot, osIoctlTimer); /* Start the timout handler for both ioctl and controller response */
1120 tdsaAllShared->tdFWControlEx.virtAddr = (bit8 *)osIoctlTimer;
1121
1122 tdsaAllShared->tdFWControlEx.usrAddr = (bit8 *)&agIOCTLPayload->FunctionSpecificArea[0];
1123 tdsaAllShared->tdFWControlEx.param1 = agParam1;
1124 tdsaAllShared->tdFWControlEx.param2 = agParam2;
1125 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
1126 tdsaAllShared->tdFWControlEx.inProgress = 1;
1127
1128 switch (agIOCTLPayload->MinorFunction)
1129 {
1130
1131 case IOCTL_MN_GPIO_PINSETUP:
1132 {
1133 TI_DBG3(("tdsaGpioSetup: IOCTL_MN_GPIO_PINSETUP\n"));
1134 gpioPinSetupInfo =(agsaGpioPinSetupInfo_t *)&agIOCTLPayload->FunctionSpecificArea[0];
1135 status = saGpioPinSetup(agRoot, agContext, 0, gpioPinSetupInfo);
1136
1137 break;
1138 }
1139 case IOCTL_MN_GPIO_EVENTSETUP:
1140 {
1141 TI_DBG3(("tdsaGpioSetup: IOCTL_MN_GPIO_EVENTSETUP\n"));
1142 gpioEventSetupInfo = (agsaGpioEventSetupInfo_t *)&agIOCTLPayload->FunctionSpecificArea[0];
1143 status = saGpioEventSetup(agRoot, agContext, 0, gpioEventSetupInfo);
1144
1145 break;
1146 }
1147
1148 case IOCTL_MN_GPIO_READ:
1149 {
1150 TI_DBG3(("tdsaGpioSetup: IOCTL_MN_GPIO_READ\n"));
1151 status = saGpioRead(agRoot, agContext, 0);
1152
1153 break;
1154 }
1155
1156 case IOCTL_MN_GPIO_WRITE:
1157 {
1158 TI_DBG3(("tdsaGpioSetup: IOCTL_MN_GPIO_WRITE\n"));
1159 gpioWriteSetupInfo = (agsaGpioWriteSetupInfo_t *)&agIOCTLPayload->FunctionSpecificArea[0];
1160 status = saGpioWrite(agRoot, agContext, 0, gpioWriteSetupInfo->gpioWritemask, gpioWriteSetupInfo->gpioWriteVal);
1161
1162 break;
1163 }
1164
1165 default :
1166 return status;
1167 }
1168
1169 if(status != AGSA_RC_SUCCESS)
1170 {
1171 status = IOCTL_CALL_FAIL;
1172 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1173
1174 tdsaSingleThreadedEnter(tiRoot, TD_TIMER_LOCK);
1175 if (osIoctlTimer->timerRunning == agTRUE)
1176 {
1177 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
1178 tdsaKillTimer(tiRoot, osIoctlTimer);
1179
1180 }else{
1181 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
1182 }
1183 }
1184
1185 TI_DBG3(("tdsaGpioPinSetup: End\n"));
1186 return status;
1187
1188 }
1189 #endif
1190
1191 /*****************************************************************************
1192 *
1193 * ostiGetGpioIOCTLRsp
1194 *
1195 * Purpose: This routine is called for Get Gpio IOCTL reaponse has been received.
1196 *
1197 * Parameters:
1198 * tiRoot: Pointer to driver instance
1199 * payloadRsp: Pointer to the FW download IOMB's payload.
1200 *
1201 * Return: none
1202 *
1203 *
1204 *****************************************************************************/
1205
ostiGetGpioIOCTLRsp(tiRoot_t * tiRoot,bit32 status,bit32 gpioReadValue,agsaGpioPinSetupInfo_t * gpioPinSetupInfo,agsaGpioEventSetupInfo_t * gpioEventSetupInfo)1206 osGLOBAL void ostiGetGpioIOCTLRsp(
1207 tiRoot_t *tiRoot,
1208 bit32 status,
1209 bit32 gpioReadValue,
1210 agsaGpioPinSetupInfo_t *gpioPinSetupInfo,
1211 agsaGpioEventSetupInfo_t *gpioEventSetupInfo
1212 )
1213 {
1214 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1215 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1216 tiIOCTLPayload_t *agIoctlPayload ;
1217 agsaGpioReadInfo_t *gpioReadInfo;
1218
1219 tdsaTimerRequest_t *osIoctlTimer;
1220 osIoctlTimer = (tdsaTimerRequest_t *)tdsaAllShared->tdFWControlEx.virtAddr;
1221
1222 TI_DBG2(("ostiGetGpioIOCTLRsp: start, status = %d \n", status));
1223
1224 agIoctlPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1225
1226 if(agIoctlPayload == agNULL){
1227 return;
1228 }
1229
1230 agIoctlPayload->Status =(bit16) status;
1231
1232 if( (status != IOCTL_CALL_TIMEOUT) && (osIoctlTimer != NULL))
1233 {
1234 tdsaSingleThreadedEnter(tiRoot, TD_TIMER_LOCK);
1235 if (osIoctlTimer->timerRunning == agTRUE)
1236 {
1237 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
1238 tdsaKillTimer(tiRoot, osIoctlTimer);
1239
1240 }else{
1241 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK);
1242 }
1243 }else {
1244 tdsaAllShared->tdFWControlEx.inProgress = 0;
1245 agIoctlPayload->Status = (bit16)status;
1246 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
1247 tdsaAllShared->tdFWControlEx.param2, NULL);
1248 return;
1249 }
1250
1251 if(status == SUCCESS)
1252 TI_DBG3((" ostiGetGpioIOCTLRsp:Got GPIO response from OUTBuf"));
1253 else {
1254 tdsaAllShared->tdFWControlEx.inProgress = 0;
1255 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
1256 tdsaAllShared->tdFWControlEx.param2, NULL);
1257 return;
1258 }
1259
1260 switch (agIoctlPayload->MinorFunction)
1261 {
1262
1263 case IOCTL_MN_GPIO_PINSETUP:
1264 {
1265 TI_DBG3((" ostiGetGpioIOCTLRsp:Got GPIO response for IOCTL_MN_GPIO_PINSETUP"));
1266
1267 break;
1268 }
1269 case IOCTL_MN_GPIO_EVENTSETUP:
1270 {
1271 TI_DBG3((" ostiGetGpioIOCTLRsp:Got GPIO response for IOCTL_MN_GPIO_EVENTSETUP"));
1272
1273 break;
1274 }
1275
1276 case IOCTL_MN_GPIO_WRITE:
1277 {
1278 TI_DBG3((" ostiGetGpioIOCTLRsp:Got GPIO response for IOCTL_MN_GPIO_WRITE"));
1279
1280 break;
1281 }
1282
1283 case IOCTL_MN_GPIO_READ:
1284 {
1285 gpioReadInfo = ( agsaGpioReadInfo_t *)tdsaAllShared->tdFWControlEx.usrAddr;
1286
1287 gpioReadInfo->gpioReadValue = gpioReadValue;
1288 gpioReadInfo->gpioInputEnabled = gpioPinSetupInfo->gpioInputEnabled ; /* GPIOIE */
1289 gpioReadInfo->gpioEventLevelChangePart1 = gpioPinSetupInfo->gpioTypePart1; /* GPIEVCHANGE (pins 11-0) */
1290 gpioReadInfo->gpioEventLevelChangePart2 = gpioPinSetupInfo->gpioTypePart2; /* GPIEVCHANGE (pins 23-20) */
1291 gpioReadInfo->gpioEventRisingEdgePart1 = 0xFFF & gpioEventSetupInfo->gpioEventRisingEdge; /* GPIEVRISE (pins 11-0) */
1292 gpioReadInfo->gpioEventRisingEdgePart2 = 0x00F00000 & (gpioEventSetupInfo->gpioEventRisingEdge); /* GPIEVRISE (pins 23-20) */
1293 gpioReadInfo->gpioEventFallingEdgePart1 = 0xFFF & gpioEventSetupInfo->gpioEventFallingEdge; /* GPIEVALL (pins 11-0) */
1294 gpioReadInfo->gpioEventFallingEdgePart2 = 0x00F00000 & gpioEventSetupInfo->gpioEventFallingEdge; /* GPIEVALL (pins 23-20 */
1295
1296 break;
1297 }
1298
1299 default :
1300 break;
1301 }
1302
1303 if(tdsaAllShared->tdFWControlEx.inProgress)
1304 {
1305 tdsaAllShared->tdFWControlEx.inProgress = 0;
1306 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
1307 tdsaAllShared->tdFWControlEx.param2, NULL);
1308 }
1309 TI_DBG2(("ostiGetGpioIOCTLRsp: end \n"));
1310
1311 return ;
1312 }
1313
1314 /*****************************************************************************
1315 *
1316 * tdsaSGpioIoctlSetup
1317 *
1318 * Purpose: This routine is called to send SGPIO request to the controller.
1319 *
1320 * Parameters:
1321 * tiRoot: Pointer to driver instance
1322 * agsaContext_t: Context for this request
1323 * tiIOCTLPayload_t: ioctl header with payload sgpio info
1324 * agParam1,agParam2: Generic parameters
1325 *
1326 * Return: status
1327 *
1328 *
1329 *****************************************************************************/
1330 osGLOBAL bit32
tdsaSGpioIoctlSetup(tiRoot_t * tiRoot,agsaContext_t * agContext,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2)1331 tdsaSGpioIoctlSetup(
1332 tiRoot_t *tiRoot,
1333 agsaContext_t *agContext,
1334 tiIOCTLPayload_t *agIOCTLPayload,
1335 void *agParam1,
1336 void *agParam2
1337 )
1338 {
1339 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1340 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1341 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
1342 bit32 status = IOCTL_CALL_FAIL;
1343 agsaSGpioReqResponse_t *pSGpioReq = (agsaSGpioReqResponse_t *)&agIOCTLPayload->FunctionSpecificArea[0];
1344
1345 TI_DBG3(("tdsaSGpioIoctlSetup: start\n"));
1346
1347 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1348
1349 do
1350 {
1351 if (tiRoot == agNULL || agIOCTLPayload == agNULL)
1352 {
1353 break;
1354 }
1355
1356 /* Validate the length */
1357 if (agIOCTLPayload->Length < sizeof(agsaSGpioReqResponse_t))
1358 {
1359 TI_DBG3(("Invalid length\n"));
1360 break;
1361 }
1362
1363 /* Validate the SMP Frame Type, Function and Register Type fields */
1364 if ((pSGpioReq->smpFrameType != SMP_REQUEST) || \
1365 ((pSGpioReq->function != SMP_READ_GPIO_REGISTER) && (pSGpioReq->function != SMP_WRITE_GPIO_REGISTER)) || \
1366 (pSGpioReq->registerType > AGSA_SGPIO_GENERAL_PURPOSE_TRANSMIT_REG))
1367 {
1368 TI_DBG4(("Invalid Parameter\n"));
1369 break;
1370 }
1371
1372 /* Specific validation for configuration register type */
1373 if (AGSA_SGPIO_CONFIG_REG == pSGpioReq->registerType)
1374 {
1375 if ((pSGpioReq->registerIndex > 0x01) || \
1376 ((0x00 == pSGpioReq->registerIndex) && (pSGpioReq->registerCount > 0x02)) || \
1377 ((0x01 == pSGpioReq->registerIndex) && (pSGpioReq->registerCount > 0x01)))
1378 {
1379 break;
1380 }
1381 }
1382
1383 /* Use FW control place in shared structure to keep the necessary information */
1384 tdsaAllShared->tdFWControlEx.param1 = agParam1;
1385 tdsaAllShared->tdFWControlEx.param2 = agParam2;
1386 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
1387 tdsaAllShared->tdFWControlEx.inProgress = 1;
1388
1389 status = saSgpio(agRoot, agContext, 0, pSGpioReq);
1390 if (status != AGSA_RC_SUCCESS)
1391 {
1392 break;
1393 }
1394
1395 status = IOCTL_CALL_PENDING;
1396
1397 } while (0);
1398
1399 TI_DBG3(("tdsaGpioPinSetup: End\n"));
1400 return status;
1401 }
1402
1403 /*****************************************************************************
1404 *
1405 * ostiSgpioIoctlRsp
1406 *
1407 * Purpose: This routine is called when a SGPIO IOCTL response is received.
1408 *
1409 * Parameters:
1410 * tiRoot: Pointer to driver instance
1411 * pSgpioResponse: Pointer to the SGPIO response
1412 *
1413 * Return: none
1414 *
1415 *
1416 *****************************************************************************/
ostiSgpioIoctlRsp(tiRoot_t * tiRoot,agsaSGpioReqResponse_t * pSgpioResponse)1417 osGLOBAL void ostiSgpioIoctlRsp(
1418 tiRoot_t *tiRoot,
1419 agsaSGpioReqResponse_t *pSgpioResponse
1420 )
1421 {
1422 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1423 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1424 tiIOCTLPayload_t *agIoctlPayload = agNULL;
1425
1426 TI_DBG3(("ostiSgpioIoctlRsp: start\n"));
1427
1428 if (tdsaAllShared->tdFWControlEx.inProgress)
1429 {
1430 agIoctlPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1431 if (agIoctlPayload)
1432 {
1433 tdsaAllShared->tdFWControlEx.payload = NULL;
1434 osti_memcpy(&agIoctlPayload->FunctionSpecificArea[0], pSgpioResponse, sizeof(agsaSGpioReqResponse_t));
1435 agIoctlPayload->Status = IOCTL_ERR_STATUS_OK;
1436 sgpioResponseSet = 1;
1437 }
1438 tdsaAllShared->sgpioResponseSet = 1; //Sunitha:Check if needed?
1439
1440 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
1441 tdsaAllShared->tdFWControlEx.param2, agNULL);
1442
1443 tdsaAllShared->tdFWControlEx.inProgress = 0;
1444 }
1445
1446 TI_DBG3(("ostiSgpioIoctlRsp: end\n"));
1447 }
1448 /*****************************************************************************
1449 *
1450 * ostiCOMMgntIOCTLRsp
1451 *
1452 * Purpose: This routine is called when FW control IOCTL reaponse has been received.
1453 * This function is used for both target and initiator.
1454 *
1455 * Parameters:
1456 * tiRoot: Pointer to driver instance
1457 * payloadRsp: Pointer to the FW download IOMB's payload.
1458 *
1459 * Return: none
1460 *
1461 *
1462 *
1463 *****************************************************************************/
1464
ostiCOMMgntIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1465 osGLOBAL void ostiCOMMgntIOCTLRsp(
1466 tiRoot_t *tiRoot,
1467 bit32 status
1468 )
1469 {
1470 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1471 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1472
1473 TI_DBG1(("ostiCOMMgntIOCTLRsp: status 0x%x\n",status));
1474 (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = status;
1475
1476 ostiFreeMemory(tiRoot,
1477 tdsaAllShared->tdFWControlEx.buffer,
1478 tdsaAllShared->tdFWControlEx.tdFWControl->len);
1479
1480 ostiIOCTLSetSignal(tiRoot,
1481 tdsaAllShared->tdFWControlEx.param1,
1482 tdsaAllShared->tdFWControlEx.param2,
1483 NULL);
1484 }
1485
1486
1487 /*****************************************************************************
1488 *
1489 * ostiRegDumpIOCTLRsp
1490 *
1491 * Purpose: This routine is called when Register Dump from flash IOCTL reaponse has been received.
1492 * This function is used for both target and initiator.
1493 *
1494 * Parameters:
1495 * tiRoot: Pointer to driver instance
1496 * payloadRsp: Pointer to the FW download IOMB's payload.
1497 *
1498 * Return: none
1499 *
1500 *
1501 *
1502 *****************************************************************************/
1503
ostiRegDumpIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1504 osGLOBAL void ostiRegDumpIOCTLRsp(
1505 tiRoot_t *tiRoot,
1506 bit32 status
1507 )
1508 {
1509 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1510 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1511
1512 TI_DBG1(("ostiRegDumpIOCTLRsp: start\n"));
1513 // (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = status;
1514 osti_memcpy((void *)(tdsaAllShared->tdFWControlEx.usrAddr),
1515 (void *)(tdsaAllShared->tdFWControlEx.virtAddr),
1516 tdsaAllShared->tdFWControlEx.len);
1517
1518 ostiFreeMemory(tiRoot,
1519 tdsaAllShared->tdFWControlEx.buffer,
1520 tdsaAllShared->tdFWControlEx.len);
1521
1522 ostiIOCTLSetSignal(tiRoot,
1523 tdsaAllShared->tdFWControlEx.param1,
1524 tdsaAllShared->tdFWControlEx.param2,
1525 NULL);
1526 }
1527
1528 /*****************************************************************************
1529 *
1530 * ostiSetNVMDIOCTLRsp
1531 *
1532 * Purpose: This routine is called for Set NVMD IOCTL reaponse has been received.
1533 * This function is used for both target and initiator.
1534 *
1535 * Parameters:
1536 * tiRoot: Pointer to driver instance
1537 * payloadRsp: Pointer to the FW download IOMB's payload.
1538 *
1539 * Return: none
1540 *
1541 *
1542 *
1543 *****************************************************************************/
1544
ostiSetNVMDIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1545 osGLOBAL void ostiSetNVMDIOCTLRsp(
1546 tiRoot_t *tiRoot,
1547 bit32 status
1548 )
1549 {
1550 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1551 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1552 tiIOCTLPayload_t *agIOCTLPayload;
1553
1554 if(status)
1555 {
1556 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1557 agIOCTLPayload->Status = (bit16)status;
1558 }
1559
1560 TI_DBG1(("ostiSetNVMDIOCTLRsp: start, status = %d\n", status));
1561 // (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = status;
1562 ostiFreeMemory(tiRoot,
1563 tdsaAllShared->tdFWControlEx.buffer,
1564 tdsaAllShared->tdFWControlEx.len);
1565
1566 ostiIOCTLSetSignal(tiRoot,
1567 tdsaAllShared->tdFWControlEx.param1,
1568 tdsaAllShared->tdFWControlEx.param2,
1569 NULL);
1570 }
1571 #ifdef SPC_ENABLE_PROFILE
1572 /*****************************************************************************
1573 *
1574 * ostiFWProfileIOCTLRsp
1575 *
1576 * Purpose: This routine is called for Fw Profile IOCTL reaponse has been received.
1577 * This function is used for both target and initiator.
1578 *
1579 * Parameters:
1580 * tiRoot: Pointer to driver instance
1581 * status:
1582 *
1583 * Return: none
1584 *
1585 *
1586 *
1587 *****************************************************************************/
1588
ostiFWProfileIOCTLRsp(tiRoot_t * tiRoot,bit32 status,bit32 len)1589 osGLOBAL void ostiFWProfileIOCTLRsp(
1590 tiRoot_t *tiRoot,
1591 bit32 status,
1592 bit32 len)
1593 {
1594 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1595 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1596 tdFWProfile_t *fwProfile;
1597
1598 TI_DBG1(("ostiFWProfileIOCTLRsp: start\n"));
1599 fwProfile = (tdFWProfile_t *)tdsaAllShared->tdFWProfileEx.tdFWProfile;
1600 // (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = status;
1601 if (status == AGSA_RC_SUCCESS)
1602 {
1603 if((fwProfile->cmd == STOP_TIMER_PROFILE) || (fwProfile->cmd == STOP_CODE_PROFILE))
1604 {
1605 osti_memcpy((void *)(fwProfile->buffer),
1606 (void *)(tdsaAllShared->tdFWProfileEx.virtAddr),
1607 len);
1608
1609 ostiFreeMemory(tiRoot,
1610 tdsaAllShared->tdFWProfileEx.buffer,
1611 tdsaAllShared->tdFWProfileEx.len);
1612 }
1613 }
1614 fwProfile->status = status;
1615 fwProfile->len = len;
1616 ostiIOCTLSetSignal(tiRoot,
1617 tdsaAllShared->tdFWProfileEx.param1,
1618 tdsaAllShared->tdFWProfileEx.param2,
1619 NULL);
1620 }
1621 #endif
1622 /*****************************************************************************
1623 *
1624 * ostiGetNVMDIOCTLRsp
1625 *
1626 * Purpose: This routine is called for Get NVMD IOCTL reaponse has been received.
1627 * This function is used for both target and initiator.
1628 *
1629 * Parameters:
1630 * tiRoot: Pointer to driver instance
1631 * payloadRsp: Pointer to the FW download IOMB's payload.
1632 *
1633 * Return: none
1634 *
1635 *
1636 *
1637 *****************************************************************************/
1638
ostiGetNVMDIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1639 osGLOBAL void ostiGetNVMDIOCTLRsp(
1640 tiRoot_t *tiRoot,
1641 bit32 status
1642 )
1643 {
1644 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1645 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1646 tiIOCTLPayload_t *agIOCTLPayload;
1647
1648 if(status)
1649 {
1650 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1651 agIOCTLPayload->Status = (bit16)status;
1652 }
1653
1654 TI_DBG1(("ostiGetNVMDIOCTLRsp: start, status = %d\n", status));
1655 tdsaAllShared->NvmdResponseSet = 1;
1656
1657 if(tdsaAllShared->tdFWControlEx.param1 != agNULL)
1658 {
1659 osti_memcpy((void *)(tdsaAllShared->tdFWControlEx.usrAddr),
1660 (void *)(tdsaAllShared->tdFWControlEx.virtAddr),
1661 tdsaAllShared->tdFWControlEx.len);
1662
1663 ostiFreeMemory(tiRoot,
1664 tdsaAllShared->tdFWControlEx.buffer,
1665 tdsaAllShared->tdFWControlEx.len);
1666
1667 ostiIOCTLSetSignal(tiRoot,
1668 tdsaAllShared->tdFWControlEx.param1,
1669 tdsaAllShared->tdFWControlEx.param2,
1670 NULL);
1671 }
1672 }
1673
1674
1675 /*****************************************************************************
1676 *
1677 * ostiGetPhyProfileIOCTLRsp
1678 *
1679 * Purpose: This routine is called for phy response has been received.
1680 * This function is used for both target and initiator.
1681 *
1682 * Parameters:
1683 * tiRoot: Pointer to driver instance
1684 * payloadRsp: Pointer to the IOMB's payload.
1685 *
1686 * Return: none
1687 *
1688 *
1689 *
1690 *****************************************************************************/
1691
ostiGetPhyProfileIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1692 osGLOBAL void ostiGetPhyProfileIOCTLRsp(
1693 tiRoot_t *tiRoot,
1694 bit32 status
1695 )
1696 {
1697 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1698 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1699 tiIOCTLPayload_t *agIOCTLPayload;
1700 tdPhyCount_t *PhyBlob = agNULL;
1701 if(status)
1702 {
1703 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1704 agIOCTLPayload->Status = (bit16)status;
1705
1706 PhyBlob = (tdPhyCount_t*)&agIOCTLPayload->FunctionSpecificArea[0];
1707 if(PhyBlob)
1708 {
1709 // PhyBlob->Phy |= 0x800;
1710 if(PhyBlob->phyResetProblem == 0 )
1711 {
1712 PhyBlob->phyResetProblem = -1;
1713 }
1714 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->Phy 0x%x\n",PhyBlob->Phy));
1715 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->BW_rx 0x%x\n",PhyBlob->BW_rx));
1716 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->BW_tx 0x%x\n",PhyBlob->BW_tx));
1717 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->InvalidDword 0x%x\n",PhyBlob->InvalidDword));
1718 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->runningDisparityError 0x%x\n",PhyBlob->runningDisparityError));
1719 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->codeViolation 0x%x\n",PhyBlob->codeViolation));
1720 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->phyResetProblem 0x%x\n",PhyBlob->phyResetProblem));
1721 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: PhyBlob->inboundCRCError 0x%x\n",PhyBlob->inboundCRCError));
1722
1723 }
1724
1725
1726 }
1727
1728 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: start, status = %d\n", status));
1729 TI_DBG1(("ostiGetPhyProfileIOCTLRsp: start, len = %d %p %p\n", tdsaAllShared->tdFWControlEx.len,tdsaAllShared->tdFWControlEx.usrAddr,tdsaAllShared->tdFWControlEx.virtAddr));
1730
1731 // osti_memcpy((void *)(tdsaAllShared->tdFWControlEx.usrAddr),
1732 // (void *)(tdsaAllShared->tdFWControlEx.virtAddr),
1733 // tdsaAllShared->tdFWControlEx.len);
1734
1735 ostiFreeMemory(tiRoot,
1736 tdsaAllShared->tdFWControlEx.buffer,
1737 tdsaAllShared->tdFWControlEx.len);
1738
1739 ostiIOCTLSetSignal(tiRoot,
1740 tdsaAllShared->tdFWControlEx.param1,
1741 tdsaAllShared->tdFWControlEx.param2,
1742 NULL);
1743 }
1744
1745
1746 /*****************************************************************************
1747 *
1748 * ostiGenEventIOCTLRsp
1749 *
1750 * Purpose: This routine is called when General Event happened while waiting for IOCTL response.
1751 * This function is used for both target and initiator.
1752 *
1753 * Parameters:
1754 * tiRoot: Pointer to driver instance
1755 * payloadRsp: Pointer to the FW download IOMB's payload.
1756 *
1757 * Return: none
1758 *
1759 *
1760 *
1761 *****************************************************************************/
1762
ostiGenEventIOCTLRsp(tiRoot_t * tiRoot,bit32 status)1763 osGLOBAL void ostiGenEventIOCTLRsp(
1764 tiRoot_t *tiRoot,
1765 bit32 status
1766 )
1767 {
1768 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1769 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1770 tiIOCTLPayload_t *agIOCTLPayload;
1771
1772 TI_DBG1(("ostiGenEventIOCTLRsp: start\n"));
1773
1774 if(tdsaAllShared->tdFWControlEx.inProgress) /*Free only if our IOCTL is in progress*/
1775 {
1776 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1777 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1778 (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1779
1780 ostiFreeMemory(tiRoot,
1781 tdsaAllShared->tdFWControlEx.buffer,
1782 tdsaAllShared->tdFWControlEx.len);
1783
1784 ostiIOCTLSetSignal(tiRoot,
1785 tdsaAllShared->tdFWControlEx.param1,
1786 tdsaAllShared->tdFWControlEx.param2,
1787 NULL);
1788 tdsaAllShared->tdFWControlEx.inProgress = 0;
1789 }
1790 #ifdef SPC_ENABLE_PROFILE
1791 if(tdsaAllShared->tdFWProfileEx.inProgress)
1792 {
1793 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWProfileEx.payload);
1794 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1795 if(tdsaAllShared->tdFWProfileEx.virtAddr != NULL) /*Free only if our IOCTL is in progress*/
1796 {
1797 ostiFreeMemory(tiRoot,
1798 tdsaAllShared->tdFWProfileEx.buffer,
1799 tdsaAllShared->tdFWProfileEx.len);
1800 tdsaAllShared->tdFWProfileEx.virtAddr = NULL;
1801 }
1802 ostiIOCTLSetSignal(tiRoot,
1803 tdsaAllShared->tdFWProfileEx.param1,
1804 tdsaAllShared->tdFWProfileEx.param2,
1805 NULL);
1806 tdsaAllShared->tdFWProfileEx.inProgress = 0;
1807
1808 }
1809 #endif /*SPC_ENABLE_PROFILE*/
1810
1811 }
1812
1813 osGLOBAL void
ostiGetDeviceInfoIOCTLRsp(tiRoot_t * tiRoot,bit32 status,void * param)1814 ostiGetDeviceInfoIOCTLRsp(
1815 tiRoot_t *tiRoot,
1816 bit32 status,
1817 void *param
1818 )
1819 {
1820 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1821 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1822 tiIOCTLPayload_t *agIOCTLPayload = agNULL;
1823 tdDeviceInfoPayload_t *pTDDeviceInfo = agNULL;
1824 agsaDeviceInfo_t *pSADeviceInfo = agNULL;
1825
1826 TI_DBG1(("ostiGetDeviceInfoIOCTLRsp: start\n"));
1827
1828 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1829 pSADeviceInfo = (agsaDeviceInfo_t*)param;
1830 pTDDeviceInfo = (tdDeviceInfoPayload_t*)agIOCTLPayload->FunctionSpecificArea;
1831
1832 if (pSADeviceInfo != agNULL)
1833 {
1834 /* fill the device information in IOCTL payload */
1835 osti_memcpy(&pTDDeviceInfo->devInfo.sasAddressHi, pSADeviceInfo->sasAddressHi, sizeof(bit32));
1836 osti_memcpy(&pTDDeviceInfo->devInfo.sasAddressLo, pSADeviceInfo->sasAddressLo, sizeof(bit32));
1837
1838 pTDDeviceInfo->devInfo.sasAddressHi = DMA_BEBIT32_TO_BIT32(pTDDeviceInfo->devInfo.sasAddressHi);
1839 pTDDeviceInfo->devInfo.sasAddressLo = DMA_BEBIT32_TO_BIT32(pTDDeviceInfo->devInfo.sasAddressLo);
1840
1841 pTDDeviceInfo->devInfo.deviceType = (pSADeviceInfo->devType_S_Rate & 0x30) >> 4;
1842 pTDDeviceInfo->devInfo.linkRate = pSADeviceInfo->devType_S_Rate & 0x0F;
1843
1844 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1845 }
1846 else
1847 {
1848 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INVALID_DEVICE;
1849 }
1850
1851 if(tdsaAllShared->tdFWControlEx.inProgress) /*Free only if our IOCTL is in progress*/
1852 {
1853 ostiIOCTLSetSignal(tiRoot,
1854 tdsaAllShared->tdFWControlEx.param1,
1855 tdsaAllShared->tdFWControlEx.param2,
1856 NULL);
1857 tdsaAllShared->tdFWControlEx.inProgress = 0;
1858 }
1859 }
1860
1861
1862 #ifdef INITIATOR_DRIVER
1863 osGLOBAL void
ostiGetIoErrorStatsIOCTLRsp(tiRoot_t * tiRoot,bit32 status,void * param)1864 ostiGetIoErrorStatsIOCTLRsp(
1865 tiRoot_t *tiRoot,
1866 bit32 status,
1867 void *param
1868 )
1869 {
1870 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1871 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1872 itdsaIni_t *Initiator = (itdsaIni_t *)tdsaAllShared->itdsaIni;
1873 tiIOCTLPayload_t *agIOCTLPayload = agNULL;
1874 tdIoErrorStatisticPayload_t *pIoErrorPayload = agNULL;
1875 agsaIOErrorEventStats_t *pIoErrorCount = agNULL;
1876
1877 OS_ASSERT(sizeof(agsaIOErrorEventStats_t) == sizeof(tdIoErrorEventStatisticIOCTL_t), "agsaIOErrorEventStats_t tdIoErrorEventStatisticIOCTL_t\n");
1878 TI_DBG1(("ostiGetIoErrorStatsIOCTLRsp: start\n"));
1879
1880 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1881 pIoErrorPayload = (tdIoErrorStatisticPayload_t*)agIOCTLPayload->FunctionSpecificArea;
1882 pIoErrorCount = (agsaIOErrorEventStats_t*)param;
1883
1884 osti_memcpy(&pIoErrorPayload->IoError, pIoErrorCount, sizeof(agsaIOErrorEventStats_t));
1885 /*copy SCSI status and sense key count from OS layer to TD layer*/
1886 osti_memcpy(&pIoErrorPayload->ScsiStatusCounter, &Initiator->ScsiStatusCounts, sizeof(tdSCSIStatusCount_t));
1887 osti_memcpy(&pIoErrorPayload->SenseKeyCounter, &Initiator->SenseKeyCounter, sizeof(tdSenseKeyCount_t));
1888 if (pIoErrorPayload->flag)
1889 {
1890 osti_memset(&Initiator->ScsiStatusCounts, 0,sizeof(tdSCSIStatusCount_t) );
1891 osti_memset(&Initiator->SenseKeyCounter, 0,sizeof(tdSenseKeyCount_t) );
1892 }
1893
1894 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1895 }
1896 #endif /* INITIATOR_DRIVER */
1897
1898 osGLOBAL void
ostiGetIoEventStatsIOCTLRsp(tiRoot_t * tiRoot,bit32 status,void * param)1899 ostiGetIoEventStatsIOCTLRsp(
1900 tiRoot_t *tiRoot,
1901 bit32 status,
1902 void *param
1903 )
1904 {
1905 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1906 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1907 tiIOCTLPayload_t *agIOCTLPayload = agNULL;
1908 tdIoEventStatisticPayload_t *pIoEventPayload = agNULL;
1909 agsaIOErrorEventStats_t *pIoEventCount = agNULL;
1910
1911 TI_DBG1(("ostiGetIoEventStatsIOCTLRsp: start\n"));
1912
1913 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1914 pIoEventPayload = (tdIoEventStatisticPayload_t*)agIOCTLPayload->FunctionSpecificArea;
1915 pIoEventCount = (agsaIOErrorEventStats_t*)param;
1916
1917 osti_memcpy(&pIoEventPayload->IoEvent, pIoEventCount, sizeof(agsaIOErrorEventStats_t));
1918
1919 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1920 }
1921
1922 osGLOBAL void
ostiGetForensicDataIOCTLRsp(tiRoot_t * tiRoot,bit32 status,void * param)1923 ostiGetForensicDataIOCTLRsp(
1924 tiRoot_t *tiRoot,
1925 bit32 status,
1926 void *param
1927 )
1928 {
1929 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1930 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1931 tiIOCTLPayload_t *agIOCTLPayload = agNULL;
1932 tdForensicDataPayload_t *pForensicDataPayload = agNULL;
1933 agsaForensicData_t *pForensicData = agNULL;
1934
1935 TI_DBG3(("ostiGetForensicDataIOCTLRsp: start, status = %d\n", status));
1936
1937 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
1938 pForensicDataPayload = (tdForensicDataPayload_t*)agIOCTLPayload->FunctionSpecificArea;
1939 pForensicData = (agsaForensicData_t*)param;
1940
1941 if (agNULL == agIOCTLPayload)
1942 {
1943 return;
1944 }
1945
1946 if (FORENSIC_DATA_TYPE_CHECK_FATAL == pForensicData->DataType)
1947 {
1948 agIOCTLPayload->Status = (bit16)status;
1949 return;
1950 }
1951
1952 if (status == AGSA_RC_SUCCESS)
1953 {
1954 switch (pForensicData->DataType)
1955 {
1956 case FORENSIC_DATA_TYPE_NON_FATAL:
1957 case FORENSIC_DATA_TYPE_FATAL:
1958 pForensicDataPayload->dataBuffer.directOffset = pForensicData->BufferType.dataBuf.directOffset;
1959 pForensicDataPayload->dataBuffer.readLen = pForensicData->BufferType.dataBuf.readLen;
1960 break;
1961 case FORENSIC_DATA_TYPE_GSM_SPACE:
1962 pForensicDataPayload->gsmBuffer.directOffset = pForensicData->BufferType.gsmBuf.directOffset;
1963 pForensicDataPayload->gsmBuffer.readLen = pForensicData->BufferType.gsmBuf.readLen;
1964 break;
1965
1966 case FORENSIC_DATA_TYPE_QUEUE:
1967 break;
1968
1969 default:
1970 TI_DBG1(("ostiGetForensicDataIOCTLRsp: forensic data type error %d\n", pForensicData->DataType));
1971 break;
1972 }
1973 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
1974 }
1975 else if(status == IOCTL_ERROR_NO_FATAL_ERROR)
1976 {
1977 agIOCTLPayload->Status = (bit16)status;
1978 }
1979 else
1980 {
1981 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
1982 }
1983
1984 /*Free only if our IOCTL is in progress*/
1985 if(tdsaAllShared->tdFWControlEx.inProgress)
1986 {
1987 TI_DBG3(("ostiGetForensicDataIOCTLRsp: Waiting for the signal \n"));
1988 ostiIOCTLSetSignal(tiRoot,
1989 tdsaAllShared->tdFWControlEx.param1,
1990 tdsaAllShared->tdFWControlEx.param2,
1991 NULL);
1992 TI_DBG3(("ostiGetForensicDataIOCTLRsp: Signal wait completed \n"));
1993 tdsaAllShared->tdFWControlEx.inProgress = 0;
1994 }
1995 }
1996
1997 /*****************************************************************************
1998 *
1999 * tdsaRegDumpGetIoctl
2000 *
2001 * Purpose: This routine is called to get Register Dump information.
2002 * This function is used for both target and initiator.
2003 *
2004 * Parameters:
2005 * tiRoot: Pointer to driver instance
2006 * agIOCTLPayload: Pointer to the IOCTL payload.
2007 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2008 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2009 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2010 *
2011 * Return:
2012 *
2013 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2014 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2015 * Detail error code is function specific and
2016 * defined by the specific IOCTL function.
2017 * IOCTL_CALL_PENDING This request is asynchronous and completed
2018 * in some other context.
2019 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2020 *
2021 *
2022 *****************************************************************************/
2023 osGLOBAL bit32
tdsaRegDumpGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2024 tdsaRegDumpGetIoctl(
2025 tiRoot_t *tiRoot,
2026 tiIOCTLPayload_t *agIOCTLPayload,
2027 void *agParam1,
2028 void *agParam2,
2029 void *agParam3
2030 )
2031 {
2032 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2033 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2034 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2035 // agsaControllerStatus_t RegDump;
2036 bit32 Offset = 0;
2037 bit32 RequestLength = 0; /* user request on how much data to pass to application */
2038 agsaRegDumpInfo_t regDumpInfo;
2039 void *buffer = agNULL;
2040 void *osMemHandle = agNULL;
2041 bit32 status = IOCTL_CALL_SUCCESS;
2042 bit32 CoreDumpLength = 16384; /* change it once data is available */
2043 bit32 EventLogOffset = 65536;
2044
2045 ///saGetControllerStatus(agRoot, &RegDump);
2046 /* length of FSA as provided by application */
2047 RequestLength = agIOCTLPayload->Length;
2048 /// FunctionSpecificOffset = 0; /* Offset into the FunctionSpecificArea of payload */
2049 /* offset into core dump that was passed from application */
2050 Offset = agIOCTLPayload->Reserved;
2051
2052 if((CoreDumpLength <= Offset)&&
2053 (agIOCTLPayload->MinorFunction != IOCTL_MN_FW_GET_EVENT_FLASH_LOG1)&&
2054 (agIOCTLPayload->MinorFunction != IOCTL_MN_FW_GET_EVENT_FLASH_LOG2))
2055 {
2056 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
2057 agIOCTLPayload->Length = 0;
2058 status=IOCTL_CALL_SUCCESS;
2059 return status;
2060 }
2061 regDumpInfo.regDumpOffset = Offset;
2062 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
2063 /* dump either aap1 or iop registers */
2064 switch(agIOCTLPayload->MinorFunction){
2065
2066 /*Coredump*/
2067 case IOCTL_MN_FW_GET_CORE_DUMP_AAP1:
2068 //CoreDumpBAROffset = RegDump.fatalErrorInfo.regDumpOffset0; /* get this from mpi config table */
2069 //CoreDumpLength = RegDump.fatalErrorInfo.regDumpLen0;
2070 /*changes for added Call back*/
2071 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2072 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2073 regDumpInfo.regDumpSrc = 0;
2074 regDumpInfo.regDumpNum = 0;
2075 regDumpInfo.directLen = RequestLength;
2076 regDumpInfo.directData = &agIOCTLPayload->FunctionSpecificArea[0];
2077 /*changes for added Call back*/
2078 //status = IOCTL_CALL_SUCCESS;
2079 tdsaAllShared->tdFWControlEx.inProgress = 1;
2080 status = IOCTL_CALL_PENDING;
2081 break;
2082 case IOCTL_MN_FW_GET_CORE_DUMP_IOP:
2083 //CoreDumpBAROffset = RegDump.fatalErrorInfo.regDumpOffset1; /* get this from mpi config table */
2084 //CoreDumpLength = RegDump.fatalErrorInfo.regDumpLen1;
2085 /*changes for added Call back*/
2086 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2087 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2088 regDumpInfo.regDumpSrc = 0;
2089 regDumpInfo.regDumpNum = 1;
2090 regDumpInfo.directLen = RequestLength;
2091 regDumpInfo.directData = &agIOCTLPayload->FunctionSpecificArea[0];
2092 /*changes for added Call back*/
2093 //status = IOCTL_CALL_SUCCESS;
2094 tdsaAllShared->tdFWControlEx.inProgress = 1;
2095 status = IOCTL_CALL_PENDING;
2096 break;
2097 case IOCTL_MN_FW_GET_CORE_DUMP_FLASH_AAP1:
2098 regDumpInfo.regDumpSrc = 1;
2099 regDumpInfo.regDumpNum = 0;
2100 if(RequestLength != 0)
2101 {
2102 if(ostiAllocMemory( tiRoot,
2103 &osMemHandle,
2104 (void **)&buffer,
2105 &(regDumpInfo.indirectAddrUpper32),
2106 &(regDumpInfo.indirectAddrLower32),
2107 8,
2108 RequestLength,
2109 agFALSE))
2110 return IOCTL_CALL_FAIL;
2111 }
2112 osti_memset((void *)buffer, 0, RequestLength);
2113 regDumpInfo.indirectLen = RequestLength;
2114
2115 // use FW control place in shared structure to keep the neccesary information
2116 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2117 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2118 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2119 tdsaAllShared->tdFWControlEx.len = RequestLength;
2120 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2121 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2122 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2123 tdsaAllShared->tdFWControlEx.inProgress = 1;
2124 status = IOCTL_CALL_PENDING;
2125 break;
2126 case IOCTL_MN_FW_GET_CORE_DUMP_FLASH_IOP:
2127 regDumpInfo.regDumpSrc = 1;
2128 regDumpInfo.regDumpNum = 1;
2129 if(RequestLength != 0)
2130 {
2131 if(ostiAllocMemory( tiRoot,
2132 &osMemHandle,
2133 (void **)&buffer,
2134 &(regDumpInfo.indirectAddrUpper32),
2135 &(regDumpInfo.indirectAddrLower32),
2136 8,
2137 RequestLength,
2138 agFALSE))
2139 return IOCTL_CALL_FAIL;
2140 }
2141 osti_memset((void *)buffer, 0, RequestLength);
2142 regDumpInfo.indirectLen = RequestLength;
2143
2144 // use FW control place in shared structure to keep the neccesary information
2145 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2146 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2147 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2148 tdsaAllShared->tdFWControlEx.len = RequestLength;
2149 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2150 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2151 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2152 tdsaAllShared->tdFWControlEx.inProgress = 1;
2153 status = IOCTL_CALL_PENDING;
2154 break;
2155 /*EventLog from Flash*/
2156 case IOCTL_MN_FW_GET_EVENT_FLASH_LOG1: //aap1 Eventlog
2157 if(CoreDumpLength + EventLogOffset <= Offset)
2158 {
2159 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
2160 agIOCTLPayload->Length = 0;
2161 status=IOCTL_CALL_SUCCESS;
2162 return status;
2163 }
2164 regDumpInfo.regDumpSrc = 1;
2165 regDumpInfo.regDumpNum = 0;
2166 if(RequestLength != 0)
2167 {
2168 if(ostiAllocMemory( tiRoot,
2169 &osMemHandle,
2170 (void **)&buffer,
2171 &(regDumpInfo.indirectAddrUpper32),
2172 &(regDumpInfo.indirectAddrLower32),
2173 8,
2174 RequestLength,
2175 agFALSE))
2176 return IOCTL_CALL_FAIL;
2177 }
2178 osti_memset((void *)buffer, 0, RequestLength);
2179 regDumpInfo.indirectLen = RequestLength;
2180
2181 // use FW control place in shared structure to keep the neccesary information
2182 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2183 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2184 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2185 tdsaAllShared->tdFWControlEx.len = RequestLength;
2186 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2187 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2188 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2189 tdsaAllShared->tdFWControlEx.inProgress = 1;
2190 status = IOCTL_CALL_PENDING;
2191 break;
2192 case IOCTL_MN_FW_GET_EVENT_FLASH_LOG2: //iop Eventlog
2193 if(CoreDumpLength + EventLogOffset <= Offset)
2194 {
2195 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
2196 agIOCTLPayload->Length = 0;
2197 status=IOCTL_CALL_SUCCESS;
2198 return status;
2199 }
2200 regDumpInfo.regDumpSrc = 1;
2201 regDumpInfo.regDumpNum = 1;
2202 if(RequestLength != 0)
2203 {
2204 if(ostiAllocMemory( tiRoot,
2205 &osMemHandle,
2206 (void **)&buffer,
2207 &(regDumpInfo.indirectAddrUpper32),
2208 &(regDumpInfo.indirectAddrLower32),
2209 8,
2210 RequestLength,
2211 agFALSE))
2212 return IOCTL_CALL_FAIL;
2213 }
2214 osti_memset((void *)buffer, 0, RequestLength);
2215 regDumpInfo.indirectLen = RequestLength;
2216
2217 // use FW control place in shared structure to keep the neccesary information
2218 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2219 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2220 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2221 tdsaAllShared->tdFWControlEx.len = RequestLength;
2222 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2223 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2224 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2225 tdsaAllShared->tdFWControlEx.inProgress = 1;
2226 status = IOCTL_CALL_PENDING;
2227 break;
2228 default:
2229 status = IOCTL_CALL_INVALID_CODE;
2230 TI_DBG1(("tiCOMMgntIOCTL: ERROR: Wrong IOCTL code %d\n", agIOCTLPayload->MinorFunction));
2231 break;
2232 }
2233 if(saGetRegisterDump(agRoot, agNULL, 0, ®DumpInfo) != AGSA_RC_SUCCESS)
2234 {
2235 status = IOCTL_CALL_FAIL;
2236 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
2237 }
2238
2239 return status;
2240 }
2241
2242 osGLOBAL void
ostiCOMMgntVPDSetIOCTLRsp(tiRoot_t * tiRoot,bit32 status)2243 ostiCOMMgntVPDSetIOCTLRsp(
2244 tiRoot_t *tiRoot,
2245 bit32 status
2246 )
2247 {
2248 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2249 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2250 // agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2251
2252 TI_DBG1(("ostiCOMMgntVPDSetIOCTLRsp: start\n"));
2253 (tdsaAllShared->tdFWControlEx.tdFWControl)->retcode = status;
2254
2255 ostiFreeMemory(tiRoot,
2256 tdsaAllShared->tdFWControlEx.buffer,
2257 tdsaAllShared->tdFWControlEx.len);
2258
2259 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
2260 tdsaAllShared->tdFWControlEx.param2,
2261 NULL);
2262 }
2263
2264 /*****************************************************************************
2265 *
2266 * tdsaNVMDSetIoctl
2267 *
2268 * Purpose: This routine is called to set Config. SEEPROM information.
2269 * This function is used for both target and initiator.
2270 *
2271 * Parameters:
2272 * tiRoot: Pointer to driver instance
2273 * agIOCTLPayload: Pointer to the IOCTL payload.
2274 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2275 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2276 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2277 *
2278 * Return:
2279 *
2280 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2281 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2282 * Detail error code is function specific and
2283 * defined by the specific IOCTL function.
2284 * IOCTL_CALL_PENDING This request is asynchronous and completed
2285 * in some other context.
2286 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2287 *
2288 *
2289 *****************************************************************************/
2290 osGLOBAL bit32
tdsaNVMDSetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2291 tdsaNVMDSetIoctl(
2292 tiRoot_t *tiRoot,
2293 tiIOCTLPayload_t *agIOCTLPayload,
2294 void *agParam1,
2295 void *agParam2,
2296 void *agParam3
2297 )
2298 {
2299 bit32 RequestLength = 0;
2300 bit32 bufAddrUpper = 0;
2301 bit32 bufAddrLower = 0;
2302 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2303 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2304 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2305 void *buffer = agNULL;
2306 void *osMemHandle = agNULL;
2307 bit32 status = IOCTL_CALL_SUCCESS;
2308 agsaNVMDData_t nvmdInfo;
2309
2310
2311 TI_DBG2(("tdsaNVMDSetIoctl: start\n"));
2312
2313 RequestLength = agIOCTLPayload->Length;
2314
2315 osti_memset(&nvmdInfo, 0, sizeof(agsaNVMDData_t));
2316
2317 switch(agIOCTLPayload->MinorFunction)
2318 {
2319 case IOCTL_MN_NVMD_SET_CONFIG:
2320
2321 //nvmdInfo.NVMDevice = 1;
2322 nvmdInfo.NVMDevice = *((bit8*)agParam3);
2323 nvmdInfo.signature = 0xFEDCBA98;
2324 nvmdInfo.dataOffsetAddress = agIOCTLPayload->Reserved;
2325 nvmdInfo.indirectPayload = 1;
2326 nvmdInfo.indirectLen = RequestLength;
2327
2328 if (nvmdInfo.NVMDevice == 0) {
2329 nvmdInfo.TWIDeviceAddress = 0xa0;
2330 nvmdInfo.TWIBusNumber = 0;
2331 nvmdInfo.TWIDevicePageSize = 0;
2332 nvmdInfo.TWIDeviceAddressSize = 1;
2333 }
2334
2335 if(RequestLength != 0)
2336 {
2337 if(ostiAllocMemory( tiRoot,
2338 &osMemHandle,
2339 (void **)&buffer,
2340 &bufAddrUpper,
2341 &bufAddrLower,
2342 8,
2343 RequestLength,
2344 agFALSE))
2345 return IOCTL_CALL_FAIL;
2346 }
2347 else
2348 {
2349 return IOCTL_CALL_FAIL;
2350 }
2351
2352 osti_memset((void *)buffer, 0, RequestLength);
2353
2354 osti_memcpy((void *)buffer,
2355 agIOCTLPayload->FunctionSpecificArea,
2356 RequestLength);
2357
2358 nvmdInfo.indirectAddrLower32 = bufAddrLower;
2359 nvmdInfo.indirectAddrUpper32 = bufAddrUpper;
2360 // use FW control place in shared structure to keep the neccesary information
2361 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2362 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2363 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2364 tdsaAllShared->tdFWControlEx.len = RequestLength;
2365 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2366 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2367 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2368 tdsaAllShared->tdFWControlEx.inProgress = 1;
2369 status = IOCTL_CALL_PENDING;
2370 break;
2371 default:
2372 status = IOCTL_CALL_INVALID_CODE;
2373 TI_DBG1(("tdsaNVMDSetIoctl: ERROR: Wrong IOCTL code %d\n", agIOCTLPayload->MinorFunction));
2374 break;
2375 }
2376
2377 if(saSetNVMDCommand(agRoot, agNULL, 0, &nvmdInfo) != AGSA_RC_SUCCESS)
2378 {
2379 status = IOCTL_CALL_FAIL;
2380 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
2381 }
2382
2383 return status;
2384
2385 }
2386
2387 /*****************************************************************************
2388 *
2389 * tdsaNVMDGetIoctl
2390 *
2391 * Purpose: This routine is called to get Config. SEEPROM information.
2392 * This function is used for both target and initiator.
2393 *
2394 * Parameters:
2395 * tiRoot: Pointer to driver instance
2396 * agIOCTLPayload: Pointer to the IOCTL payload.
2397 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2398 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2399 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2400 *
2401 * Return:
2402 *
2403 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2404 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2405 * Detail error code is function specific and
2406 * defined by the specific IOCTL function.
2407 * IOCTL_CALL_PENDING This request is asynchronous and completed
2408 * in some other context.
2409 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2410 *
2411 *
2412 *****************************************************************************/
2413 osGLOBAL bit32
tdsaNVMDGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2414 tdsaNVMDGetIoctl(
2415 tiRoot_t *tiRoot,
2416 tiIOCTLPayload_t *agIOCTLPayload,
2417 void *agParam1,
2418 void *agParam2,
2419 void *agParam3
2420 )
2421 {
2422 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2423 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2424 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2425 void *buffer = agNULL;
2426 void *osMemHandle = agNULL;
2427 bit32 status = IOCTL_CALL_SUCCESS;
2428 agsaNVMDData_t nvmdInfo;
2429 bit32 Offset = 0;
2430 bit32 RequestLength = 0;
2431 bit32 ostiMemoryStatus = 0;
2432 bit32 i,j;
2433 bit8* seepromBuffer;
2434 bit8* phySettingsBuffer;
2435
2436
2437 TI_DBG2(("tdsaNVMDGetIoctl: start\n"));
2438
2439 RequestLength = agIOCTLPayload->Length;
2440 Offset = agIOCTLPayload->Reserved;
2441
2442 osti_memset(&nvmdInfo, 0, sizeof(agsaNVMDData_t));
2443 /* This condition is not valid for direct read so commenting */
2444 /*if(!tiIS_SPC(agRoot)) {
2445 if( RequestLength <= Offset ) //4096-max seeprom size
2446 {
2447 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NO_MORE_DATA;
2448 agIOCTLPayload->Length = 0;
2449 status=IOCTL_CALL_SUCCESS;
2450 return status;
2451 }
2452 }*/
2453
2454 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
2455
2456 switch(agIOCTLPayload->MinorFunction)
2457 {
2458 case IOCTL_MN_NVMD_GET_CONFIG:
2459
2460 // nvmdInfo.NVMDevice = 1;
2461 nvmdInfo.NVMDevice = *((bit8*)agParam3);
2462 nvmdInfo.signature = 0xFEDCBA98;
2463 nvmdInfo.dataOffsetAddress = Offset;
2464 nvmdInfo.indirectPayload = 1;
2465 nvmdInfo.indirectLen = RequestLength;
2466
2467 if (nvmdInfo.NVMDevice == 0) {
2468 nvmdInfo.TWIDeviceAddress = 0xa0;
2469 nvmdInfo.TWIBusNumber = 0;
2470 nvmdInfo.TWIDevicePageSize = 0;
2471 nvmdInfo.TWIDeviceAddressSize = 1;
2472 }
2473
2474 if(RequestLength != 0)
2475 {
2476 ostiMemoryStatus = ostiAllocMemory( tiRoot,
2477 &osMemHandle,
2478 (void **)&buffer,
2479 &(nvmdInfo.indirectAddrUpper32),
2480 &(nvmdInfo.indirectAddrLower32),
2481 8,
2482 RequestLength,
2483 agFALSE);
2484 if((ostiMemoryStatus != tiSuccess) && (buffer == agNULL))
2485 return IOCTL_CALL_FAIL;
2486 }
2487 else
2488 {
2489 return IOCTL_CALL_FAIL;
2490 }
2491 osti_memset((void *)buffer, 0, RequestLength);
2492
2493 // use FW control place in shared structure to keep the neccesary information
2494 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2495 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2496 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2497 tdsaAllShared->tdFWControlEx.len = RequestLength;
2498 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2499 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2500 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2501 tdsaAllShared->tdFWControlEx.inProgress = 1;
2502 status = IOCTL_CALL_PENDING;
2503 break;
2504 default:
2505 status = IOCTL_CALL_INVALID_CODE;
2506 TI_DBG1(("tiCOMMgntIOCTL: ERROR: Wrong IOCTL code %d\n", agIOCTLPayload->MinorFunction));
2507 break;
2508 }
2509 tdsaAllShared->NvmdResponseSet = 0;
2510
2511 if(saGetNVMDCommand(agRoot, agNULL, 0, &nvmdInfo) != AGSA_RC_SUCCESS)
2512 {
2513 status = IOCTL_CALL_FAIL;
2514 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
2515 return status;
2516 }
2517 /* Copy the SAS address */
2518 if(agParam1 == agNULL)
2519
2520 {
2521 while(!tdsaAllShared->NvmdResponseSet)
2522 {
2523 // tiCOMDelayedInterruptHandler(tiRoot, 0, 1, tiNonInterruptContext);
2524 }
2525 if(nvmdInfo.NVMDevice == 4 || nvmdInfo.NVMDevice == 1)
2526 {
2527 seepromBuffer = buffer;
2528 /*Get Initiator SAS address*/
2529
2530 if(tiIS_SPC(agRoot))
2531 {
2532 for(j=0,i=ADAPTER_WWN_SPC_START_OFFSET; i<= ADAPTER_WWN_SPC_END_OFFSET; i++,j++)
2533 agIOCTLPayload->FunctionSpecificArea[j] = seepromBuffer[i];
2534 }
2535 else
2536 {
2537 for(j=0,i=ADAPTER_WWN_START_OFFSET; i<= ADAPTER_WWN_END_OFFSET; i++,j++)
2538 agIOCTLPayload->FunctionSpecificArea[j] = seepromBuffer[i];
2539 }
2540 }
2541 /* Copy the Phy settings */
2542 else if(nvmdInfo.NVMDevice == 6)
2543 {
2544 phySettingsBuffer = buffer;
2545 for(i=0; i<PHY_SETTINGS_LEN; i++)
2546 agIOCTLPayload->FunctionSpecificArea[i] = phySettingsBuffer[i];
2547 }
2548 tdsaAllShared->NvmdResponseSet = 0;
2549 ostiFreeMemory(tiRoot, tdsaAllShared->tdFWControlEx.buffer, tdsaAllShared->tdFWControlEx.len);
2550
2551 }
2552 return status;
2553
2554 }
2555
2556 /*****************************************************************************
2557 *
2558 * tdsaDeviceInfoGetIoctl
2559 *
2560 * Purpose: This routine is called to get the specified device information.
2561 *
2562 * Parameters:
2563 * tiRoot: Pointer to driver instance
2564 * agIOCTLPayload: Pointer to the IOCTL payload.
2565 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2566 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2567 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2568 *
2569 * Return:
2570 *
2571 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2572 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2573 * Detail error code is function specific and
2574 * defined by the specific IOCTL function.
2575 * IOCTL_CALL_PENDING This request is asynchronous and completed
2576 * in some other context.
2577 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2578 *
2579 *
2580 *****************************************************************************/
2581 osGLOBAL bit32
tdsaDeviceInfoGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2582 tdsaDeviceInfoGetIoctl(
2583 tiRoot_t *tiRoot,
2584 tiIOCTLPayload_t *agIOCTLPayload,
2585 void *agParam1,
2586 void *agParam2,
2587 void *agParam3
2588 )
2589 {
2590 tdsaDeviceData_t *oneDeviceData = agNULL;
2591 tiDeviceHandle_t *tiDeviceHandle = agNULL;
2592 tdDeviceInfoPayload_t *pDeviceInfo = agNULL;
2593 /*agsaDevHandle_t *agDevHandle = agNULL;*/
2594 bit32 status = IOCTL_CALL_SUCCESS;
2595
2596 pDeviceInfo = (tdDeviceInfoPayload_t*)agIOCTLPayload->FunctionSpecificArea;
2597
2598 TI_DBG3(("tdsaDeviceInfoGetIoctl: %d:%3d:%d %p %p %p\n",
2599 (bit8)pDeviceInfo->PathId,
2600 (bit8)pDeviceInfo->TargetId,
2601 (bit8)pDeviceInfo->Lun,
2602 agParam1,
2603 agParam2,
2604 agParam3));
2605
2606 tiDeviceHandle = ostiMapToDevHandle(tiRoot,
2607 (bit8)pDeviceInfo->PathId,
2608 (bit8)pDeviceInfo->TargetId,
2609 (bit8)pDeviceInfo->Lun
2610 );
2611
2612 if (tiDeviceHandle == agNULL)
2613 {
2614 TI_DBG1(("tdsaDeviceInfoGetIoctl: tiDeviceHandle is NULL !!!! SCSI address = %d:%3d:%d\n",
2615 pDeviceInfo->PathId, pDeviceInfo->TargetId, pDeviceInfo->Lun));
2616 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INVALID_DEVICE;
2617 status = IOCTL_CALL_FAIL;
2618 return status;
2619 }
2620
2621 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
2622 if(oneDeviceData == agNULL)
2623 {
2624 TI_DBG1(("tdsaDeviceInfoGetIoctl: tiDeviceHandle=%p DeviceData is NULL!!! SCSI address = %d:%3d:%d\n",
2625 tiDeviceHandle, pDeviceInfo->PathId, pDeviceInfo->TargetId, pDeviceInfo->Lun));
2626 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INVALID_DEVICE;
2627 status = IOCTL_CALL_FAIL;
2628 return status;
2629 }
2630
2631 /* for hotplug */
2632 if (oneDeviceData->valid != agTRUE || oneDeviceData->registered != agTRUE ||
2633 oneDeviceData->tdPortContext == agNULL )
2634 {
2635 TI_DBG1(("tdsaDeviceInfoGetIoctl: tiDeviceHandle=%p did %d DeviceData was removed!!! SCSI address = %d:%3d:%d\n",
2636 tiDeviceHandle, oneDeviceData->id, pDeviceInfo->PathId, pDeviceInfo->TargetId, pDeviceInfo->Lun));
2637 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INVALID_DEVICE;
2638 status = IOCTL_CALL_FAIL;
2639 return status;
2640 }
2641
2642 /* fill the device information in IOCTL payload */
2643 pDeviceInfo->devInfo.phyId = oneDeviceData->phyID;
2644 osti_memcpy(&pDeviceInfo->devInfo.sasAddressHi, oneDeviceData->agDeviceInfo.sasAddressHi, sizeof(bit32));
2645 osti_memcpy(&pDeviceInfo->devInfo.sasAddressLo, oneDeviceData->agDeviceInfo.sasAddressLo, sizeof(bit32));
2646
2647 pDeviceInfo->devInfo.sasAddressHi = DMA_BEBIT32_TO_BIT32(pDeviceInfo->devInfo.sasAddressHi);
2648 pDeviceInfo->devInfo.sasAddressLo = DMA_BEBIT32_TO_BIT32(pDeviceInfo->devInfo.sasAddressLo);
2649
2650 pDeviceInfo->devInfo.deviceType = (oneDeviceData->agDeviceInfo.devType_S_Rate & 0x30) >> 4;
2651 pDeviceInfo->devInfo.linkRate = oneDeviceData->agDeviceInfo.devType_S_Rate & 0x0F;
2652
2653 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
2654
2655 TI_DBG3(("tdsaDeviceInfoGetIoctl:IOCTL_CALL_SUCCESS\n"));
2656
2657 /*saGetDeviceInfo(agRoot, agNULL, 0, 0, agDevHandle);*/
2658
2659 status = IOCTL_CALL_SUCCESS;
2660
2661 return status;
2662 }
2663 /*****************************************************************************
2664 *
2665 * tdsaIoErrorStatisticGetIoctl
2666 *
2667 * Purpose: This routine is called to get the IO error statistic.
2668 *
2669 * Parameters:
2670 * tiRoot: Pointer to driver instance
2671 * agIOCTLPayload: Pointer to the IOCTL payload.
2672 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2673 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2674 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2675 *
2676 * Return:
2677 *
2678 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2679 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2680 * Detail error code is function specific and
2681 * defined by the specific IOCTL function.
2682 * IOCTL_CALL_PENDING This request is asynchronous and completed
2683 * in some other context.
2684 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2685 *
2686 *
2687 *****************************************************************************/
2688 osGLOBAL bit32
tdsaIoErrorStatisticGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2689 tdsaIoErrorStatisticGetIoctl(
2690 tiRoot_t *tiRoot,
2691 tiIOCTLPayload_t *agIOCTLPayload,
2692 void *agParam1,
2693 void *agParam2,
2694 void *agParam3
2695 )
2696 {
2697 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2698 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2699 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2700 tdIoErrorStatisticPayload_t *pIoErrorPayload = agNULL;
2701 bit32 status = IOCTL_CALL_SUCCESS;
2702
2703 pIoErrorPayload = (tdIoErrorStatisticPayload_t*)agIOCTLPayload->FunctionSpecificArea;
2704
2705 tdsaAllShared->tdFWControlEx.buffer = agNULL;
2706 tdsaAllShared->tdFWControlEx.virtAddr = agNULL;
2707 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2708 tdsaAllShared->tdFWControlEx.len = 0;
2709 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2710 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2711 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2712 tdsaAllShared->tdFWControlEx.inProgress = 0;
2713
2714 saGetIOErrorStats(agRoot, agNULL, pIoErrorPayload->flag);
2715
2716 return status;
2717 }
2718
2719 /*****************************************************************************
2720 *
2721 * tdsaIoEventStatisticGetIoctl
2722 *
2723 * Purpose: This routine is called to get the IO event statistic.
2724 *
2725 * Parameters:
2726 * tiRoot: Pointer to driver instance
2727 * agIOCTLPayload: Pointer to the IOCTL payload.
2728 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2729 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2730 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2731 *
2732 * Return:
2733 *
2734 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2735 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2736 * Detail error code is function specific and
2737 * defined by the specific IOCTL function.
2738 * IOCTL_CALL_PENDING This request is asynchronous and completed
2739 * in some other context.
2740 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2741 *
2742 *
2743 *****************************************************************************/
2744 osGLOBAL bit32
tdsaIoEventStatisticGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2745 tdsaIoEventStatisticGetIoctl(
2746 tiRoot_t *tiRoot,
2747 tiIOCTLPayload_t *agIOCTLPayload,
2748 void *agParam1,
2749 void *agParam2,
2750 void *agParam3
2751 )
2752 {
2753 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2754 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2755 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2756 tdIoEventStatisticPayload_t *pIoEventPayload = agNULL;
2757 bit32 status = IOCTL_CALL_SUCCESS;
2758
2759 pIoEventPayload = (tdIoEventStatisticPayload_t*)agIOCTLPayload->FunctionSpecificArea;
2760
2761 tdsaAllShared->tdFWControlEx.buffer = agNULL;
2762 tdsaAllShared->tdFWControlEx.virtAddr = agNULL;
2763 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2764 tdsaAllShared->tdFWControlEx.len = 0;
2765 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2766 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2767 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2768 tdsaAllShared->tdFWControlEx.inProgress = 0;
2769
2770 saGetIOEventStats(agRoot, agNULL, pIoEventPayload->flag);
2771
2772 return status;
2773 }
2774
2775 /*****************************************************************************
2776 *
2777 * tdsaRegisterIoctl
2778 *
2779 * Purpose: This routine is called to get Forensic Data.
2780 *
2781 * Parameters:
2782 * tiRoot: Pointer to driver instance
2783 * agIOCTLPayload: Pointer to the IOCTL payload.
2784 * agParam1: Pointer to pass context handle for IOCTL DMA operation
2785 * agParam2: Pointer to pass context handle for IOCTL DMA operation
2786 * agParam3: Pointer to pass context handle for IOCTL DMA operation
2787 *
2788 * Return:
2789 *
2790 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
2791 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
2792 * Detail error code is function specific and
2793 * defined by the specific IOCTL function.
2794 * IOCTL_CALL_PENDING This request is asynchronous and completed
2795 * in some other context.
2796 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
2797 *
2798 *
2799 *****************************************************************************/
2800 osGLOBAL bit32
tdsaRegisterIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2801 tdsaRegisterIoctl(
2802 tiRoot_t *tiRoot,
2803 tiIOCTLPayload_t *agIOCTLPayload,
2804 void *agParam1,
2805 void *agParam2,
2806 void *agParam3
2807 )
2808 {
2809 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2810 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2811 // agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2812 tdRegisterPayload_t *pRegisterPayload = agNULL;
2813 bit32 status = IOCTL_CALL_SUCCESS;
2814
2815 pRegisterPayload = (tdRegisterPayload_t*)agIOCTLPayload->FunctionSpecificArea;
2816
2817 tdsaAllShared->tdFWControlEx.buffer = agNULL;
2818 tdsaAllShared->tdFWControlEx.virtAddr = agNULL;
2819 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2820 tdsaAllShared->tdFWControlEx.len = 0;
2821 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2822 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2823 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2824 tdsaAllShared->tdFWControlEx.inProgress = 0;
2825
2826 TI_DBG1(("tdsaRegisterIoctl: Flag %d RegAddr 0x%x RegValue 0x%x\n",
2827 pRegisterPayload->flag, pRegisterPayload->RegAddr, pRegisterPayload->RegValue));
2828
2829 if (pRegisterPayload->flag)
2830 {
2831 /* set register */
2832 ostiChipWriteBit32Ext(tiRoot, 0, pRegisterPayload->RegAddr, pRegisterPayload->RegValue);
2833 }
2834 else
2835 {
2836 /* get register */
2837 pRegisterPayload->RegValue = ostiChipReadBit32Ext(tiRoot, 0, pRegisterPayload->RegAddr);
2838 }
2839 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
2840 return status;
2841 }
2842
2843 osGLOBAL bit32
tdsaGetPhyGeneralStatusIoctl(tiRoot_t * tiRoot,agsaPhyGeneralState_t * PhyData)2844 tdsaGetPhyGeneralStatusIoctl(
2845 tiRoot_t *tiRoot,
2846 agsaPhyGeneralState_t *PhyData
2847 )
2848 {
2849 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2850 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2851 agsaRoot_t *agRoot = &(tdsaAllShared->agRootNonInt);
2852 // agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
2853 // bit8 totalValidPhys;
2854 bit32 status = AGSA_RC_SUCCESS;
2855 bit32 i = 0;
2856 agsaControllerInfo_t ControllerInfo;
2857 saGetControllerInfo(agRoot,&ControllerInfo);
2858
2859 TI_DBG3(("tdsaGetPhyGeneralStatusIoctl: start\n"));
2860 do
2861 {
2862 if(tIsSPC(agRoot)||tIsSPCHIL(agRoot))
2863 {
2864 status = IOCTL_ERR_STATUS_NOT_SUPPORTED;
2865 break;
2866 }
2867
2868 PhyData->Reserved1 = ControllerInfo.phyCount;
2869 for(i=0;i<PhyData->Reserved1;i++)
2870 {
2871 status = saGetPhyProfile( agRoot,agNULL,tdsaRotateQnumber(tiRoot, agNULL), AGSA_SAS_PHY_GENERAL_STATUS_PAGE,i);
2872 if(status == AGSA_RC_FAILURE)
2873 {
2874 break;
2875 }
2876 }
2877 }while(0);
2878 TI_DBG3(("tdsaGetPhyGeneralStatusIoctl: End\n"));
2879 return status;
2880 }
2881 /*****************************************************************************
2882 *
2883 * ostiGetPhyGeneralStatusRsp
2884 *
2885 * Purpose: This routine is called when a PhyStatus IOCTL response is received.
2886 *
2887 * Parameters:
2888 * tiRoot: Pointer to driver instance
2889 * agsaSASPhyGeneralStatusPage_t: Status of the phy.
2890 * bit32: phyID
2891 *
2892 * Return: none
2893 *
2894 *
2895 *****************************************************************************/
ostiGetPhyGeneralStatusRsp(tiRoot_t * tiRoot,agsaSASPhyGeneralStatusPage_t * GenStatus,bit32 phyID)2896 osGLOBAL void ostiGetPhyGeneralStatusRsp(
2897 tiRoot_t *tiRoot,
2898 agsaSASPhyGeneralStatusPage_t *GenStatus,
2899 bit32 phyID
2900 )
2901 {
2902
2903 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2904 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2905 tiIOCTLPayload_t *agIoctlPayload = agNULL;
2906 agsaPhyGeneralState_t *pSetPhyStatusRes = agNULL;
2907
2908
2909 TI_DBG1(("ostiGetPhyGeneralStatusRsp: start\n"));
2910
2911 if (tdsaAllShared->tdFWControlEx.inProgress)
2912 {
2913 agIoctlPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
2914 if ((agIoctlPayload) && (PMC_IOCTL_SIGNATURE == agIoctlPayload->Signature)&&
2915 (IOCTL_MJ_PHY_GENERAL_STATUS == agIoctlPayload->MajorFunction))
2916 {
2917 pSetPhyStatusRes = (agsaPhyGeneralState_t*) &agIoctlPayload->FunctionSpecificArea[0];
2918 osti_memcpy(&pSetPhyStatusRes->PhyGenData[phyID], GenStatus, sizeof(agsaSASPhyGeneralStatusPage_t));
2919 pSetPhyStatusRes->Reserved2++;
2920 if(pSetPhyStatusRes->Reserved1 == pSetPhyStatusRes->Reserved2)
2921 {
2922 tdsaAllShared->tdFWControlEx.payload = NULL;
2923 ostiIOCTLSetSignal(tiRoot, tdsaAllShared->tdFWControlEx.param1,
2924 tdsaAllShared->tdFWControlEx.param2, agNULL);
2925 tdsaAllShared->tdFWControlEx.inProgress = 0;
2926 agIoctlPayload->Status = IOCTL_ERR_STATUS_OK;
2927
2928 }
2929 }
2930 }
2931
2932 TI_DBG1(("ostiGetPhyGeneralStatusRsp: end\n"));
2933 }
2934
2935
2936 osGLOBAL bit32
tdsaPhyProfileIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)2937 tdsaPhyProfileIoctl(
2938 tiRoot_t *tiRoot,
2939 tiIOCTLPayload_t *agIOCTLPayload,
2940 void *agParam1,
2941 void *agParam2,
2942 void *agParam3
2943 )
2944 {
2945 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2946 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2947 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
2948 void *buffer = agNULL;
2949 void *osMemHandle = agNULL;
2950 bit32 status = IOCTL_CALL_SUCCESS;
2951 bit32 retcode = AGSA_RC_FAILURE;
2952 bit32 RequestLength= agIOCTLPayload->Length;
2953 bit32 bufAddrUpper = 0;
2954 bit32 bufAddrLower = 0;
2955
2956 tdPhyCount_t *PhyBlob = (tdPhyCount_t*)&agIOCTLPayload->FunctionSpecificArea[0];
2957
2958
2959 if(ostiAllocMemory( tiRoot,
2960 &osMemHandle,
2961 (void **)&buffer,
2962 &bufAddrUpper,
2963 &bufAddrLower,
2964 RequestLength,
2965 RequestLength,
2966 agTRUE))
2967 return IOCTL_CALL_FAIL;
2968
2969
2970 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
2971 tdsaAllShared->tdFWControlEx.virtAddr = buffer;
2972 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
2973 tdsaAllShared->tdFWControlEx.len = 32;
2974 tdsaAllShared->tdFWControlEx.param1 = agParam1;
2975 tdsaAllShared->tdFWControlEx.param2 = agParam2;
2976 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
2977 tdsaAllShared->tdFWControlEx.inProgress = 1;
2978
2979 TI_DBG1(("tdsaPhyProfileIoctl: MinorFunction %d\n",agIOCTLPayload->MinorFunction));
2980 // PhyBlob->Phy |= 0x100;
2981
2982 if( tiIS_SPC(agRoot) )
2983 {
2984 TI_DBG1(("tdsaPhyProfileIoctl: SPC operation 0x%x PHY %d\n",agIOCTLPayload->MinorFunction,PhyBlob->Phy));
2985 retcode = saLocalPhyControl(agRoot,agNULL,0 ,PhyBlob->Phy ,agIOCTLPayload->MinorFunction , agNULL);
2986 if(retcode == AGSA_RC_SUCCESS)
2987 {
2988 status = IOCTL_CALL_PENDING;
2989 }
2990 }
2991 else
2992 {
2993 TI_DBG1(("tdsaPhyProfileIoctl: SPCv operation 0x%x PHY %d\n",agIOCTLPayload->MinorFunction,PhyBlob->Phy));
2994 retcode = saGetPhyProfile( agRoot,agNULL,0,agIOCTLPayload->MinorFunction , PhyBlob->Phy);
2995
2996 if(retcode == AGSA_RC_SUCCESS)
2997 {
2998 status = IOCTL_CALL_PENDING;
2999 }
3000
3001 }
3002
3003 TI_DBG2(("tdsaPhyProfileIoctl: after\n"));
3004
3005
3006 return status;
3007 }
3008
3009 /*****************************************************************************
3010 *
3011 * tdsaForensicDataGetIoctl
3012 *
3013 * Purpose: This routine is called to get Forensic Data.
3014 *
3015 * Parameters:
3016 * tiRoot: Pointer to driver instance
3017 * agIOCTLPayload: Pointer to the IOCTL payload.
3018 * agParam1: Pointer to pass context handle for IOCTL DMA operation
3019 * agParam2: Pointer to pass context handle for IOCTL DMA operation
3020 * agParam3: Pointer to pass context handle for IOCTL DMA operation
3021 *
3022 * Return:
3023 *
3024 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
3025 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
3026 * Detail error code is function specific and
3027 * defined by the specific IOCTL function.
3028 * IOCTL_CALL_PENDING This request is asynchronous and completed
3029 * in some other context.
3030 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
3031 *
3032 *
3033 *****************************************************************************/
3034 osGLOBAL bit32
tdsaForensicDataGetIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)3035 tdsaForensicDataGetIoctl(
3036 tiRoot_t *tiRoot,
3037 tiIOCTLPayload_t *agIOCTLPayload,
3038 void *agParam1,
3039 void *agParam2,
3040 void *agParam3
3041 )
3042 {
3043 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3044 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3045 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3046 tdForensicDataPayload_t *pForensicDataPayload = agNULL;
3047 agsaForensicData_t ForensicData;
3048 bit32 status = IOCTL_CALL_SUCCESS;
3049
3050 pForensicDataPayload = (tdForensicDataPayload_t*)agIOCTLPayload->FunctionSpecificArea;
3051
3052 tdsaAllShared->tdFWControlEx.buffer = agNULL;
3053 tdsaAllShared->tdFWControlEx.virtAddr = agNULL;
3054 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
3055 tdsaAllShared->tdFWControlEx.len = 0;
3056 tdsaAllShared->tdFWControlEx.param1 = agParam1;
3057 tdsaAllShared->tdFWControlEx.param2 = agParam2;
3058 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
3059 tdsaAllShared->tdFWControlEx.inProgress = 0;
3060
3061 osti_memset(&ForensicData, 0, sizeof(agsaForensicData_t));
3062
3063 ForensicData.DataType = pForensicDataPayload->DataType;
3064
3065 switch (ForensicData.DataType)
3066 {
3067 case FORENSIC_DATA_TYPE_NON_FATAL:
3068 case FORENSIC_DATA_TYPE_FATAL:
3069 ForensicData.BufferType.dataBuf.directLen = pForensicDataPayload->dataBuffer.directLen;
3070 ForensicData.BufferType.dataBuf.directOffset = pForensicDataPayload->dataBuffer.directOffset;
3071 ForensicData.BufferType.dataBuf.readLen = pForensicDataPayload->dataBuffer.readLen;
3072 ForensicData.BufferType.dataBuf.directData = (void*)pForensicDataPayload->dataBuffer.directData;
3073 break;
3074 case FORENSIC_DATA_TYPE_GSM_SPACE:
3075 ForensicData.BufferType.gsmBuf.directLen = pForensicDataPayload->gsmBuffer.directLen;
3076 ForensicData.BufferType.gsmBuf.directOffset = pForensicDataPayload->gsmBuffer.directOffset;
3077 ForensicData.BufferType.dataBuf.readLen = pForensicDataPayload->gsmBuffer.readLen;
3078 ForensicData.BufferType.gsmBuf.directData = (void*)pForensicDataPayload->gsmBuffer.directData;
3079 break;
3080
3081 case FORENSIC_DATA_TYPE_IB_QUEUE:
3082 ForensicData.BufferType.queueBuf.directLen = pForensicDataPayload->queueBuffer.directLen;
3083 //ForensicData.BufferType.queueBuf.queueType = pForensicDataPayload->queueBuffer.queueType;
3084 ForensicData.BufferType.queueBuf.queueType = FORENSIC_DATA_TYPE_IB_QUEUE;
3085 ForensicData.BufferType.queueBuf.queueIndex = pForensicDataPayload->queueBuffer.queueIndex;
3086 ForensicData.BufferType.queueBuf.directData = (void*)pForensicDataPayload->queueBuffer.directData;
3087 break;
3088 case FORENSIC_DATA_TYPE_OB_QUEUE:
3089 ForensicData.BufferType.queueBuf.directLen = pForensicDataPayload->queueBuffer.directLen;
3090 ForensicData.BufferType.queueBuf.queueType = FORENSIC_DATA_TYPE_OB_QUEUE;
3091 ForensicData.BufferType.queueBuf.queueIndex = pForensicDataPayload->queueBuffer.queueIndex;
3092 ForensicData.BufferType.queueBuf.directData = (void*)pForensicDataPayload->queueBuffer.directData;
3093 break;
3094
3095 default:
3096 TI_DBG1(("tdsaGetForensicDataIoctl: forensic data type error %d\n", pForensicDataPayload->DataType));
3097 status = IOCTL_CALL_INVALID_CODE;
3098 return status;
3099 }
3100
3101 if ( saGetForensicData(agRoot, agNULL, &ForensicData) != AGSA_RC_SUCCESS )
3102 {
3103 status = IOCTL_CALL_FAIL;
3104 }
3105
3106 return status;
3107 }
3108
3109 osGLOBAL bit32
tdsaSendSMPIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)3110 tdsaSendSMPIoctl(
3111 tiRoot_t *tiRoot,
3112 tiIOCTLPayload_t *agIOCTLPayload,
3113 void *agParam1,
3114 void *agParam2,
3115 void *agParam3
3116 )
3117 {
3118 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3119 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3120 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3121 void *reqBuffer = agNULL;
3122 void *respBuffer = agNULL;
3123 void *osMemHandle = agNULL;
3124 bit32 status = IOCTL_CALL_SUCCESS;
3125 // bit32 Offset = 0;
3126 // bit32 RequestLength = 0;
3127 bit32 ostiMemoryStatus = 0;
3128 smp_pass_through_req_t *smp_pass_through_req;
3129
3130 tiDeviceHandle_t *devHandle;
3131 agsaSMPFrame_t agSMPFrame;
3132 tdsaDeviceData_t *oneDeviceData = agNULL;
3133 bit32 i;
3134
3135 TI_DBG2(("tdsaSendSMPIoctl: start\n"));
3136
3137 smp_pass_through_req = (smp_pass_through_req_t*)agIOCTLPayload->FunctionSpecificArea;
3138
3139 for(i=0;i<8;i++)
3140 TI_DBG2(("SAS Address[%d]:%x",i,smp_pass_through_req->exp_sas_addr[i]));
3141 TI_DBG2(("SAS Request Length:%d",smp_pass_through_req->smp_req_len));
3142 TI_DBG2(("SAS Response Length:%d",smp_pass_through_req->smp_resp_len));
3143 for(i=0;i<smp_pass_through_req->smp_req_len;i++)
3144 TI_DBG2(("SAS request + %d:%x",i,smp_pass_through_req->smp_req_resp[i]));
3145
3146 devHandle = ostiGetDevHandleFromSasAddr(tiRoot, smp_pass_through_req->exp_sas_addr);
3147 if(devHandle == NULL)
3148 {
3149 status = IOCTL_CALL_FAIL;
3150 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
3151 return status;
3152 }
3153
3154
3155
3156 //agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
3157 agIOCTLPayload->Status = IOCTL_ERR_STATUS_NOT_RESPONDING;
3158
3159
3160
3161 if((ostiMemoryStatus != tiSuccess) && (reqBuffer == agNULL ))
3162 return IOCTL_CALL_FAIL;
3163
3164
3165 tdsaAllShared->tdFWControlEx.param3 = osMemHandle;
3166
3167
3168 agSMPFrame.outFrameBuf = smp_pass_through_req->smp_req_resp;
3169 agSMPFrame.expectedRespLen = smp_pass_through_req->smp_resp_len;
3170 agSMPFrame.inFrameLen = smp_pass_through_req->smp_resp_len - 4;
3171
3172 if(!(smp_pass_through_req->smp_req_len - 8) && !tiIS_SPC(agRoot))
3173 {
3174 agSMPFrame.flag = 1; // Direct request Indirect response
3175 agSMPFrame.outFrameLen = smp_pass_through_req->smp_req_len - 4; //Exclude header
3176 }
3177 else
3178 {
3179
3180 agSMPFrame.flag = 3; //Indirect request and Indirect response
3181 ostiMemoryStatus = ostiAllocMemory( tiRoot,
3182 &osMemHandle,
3183 (void **)&reqBuffer,
3184 &(agSMPFrame.outFrameAddrUpper32),
3185 &(agSMPFrame.outFrameAddrLower32),
3186 8,
3187 smp_pass_through_req->smp_req_len,
3188 agFALSE);
3189 tdsaAllShared->tdFWControlEx.param3 = osMemHandle;
3190 if(tiIS_SPC(agRoot))
3191 {
3192 agSMPFrame.outFrameLen = smp_pass_through_req->smp_req_len - 4; //Exclude crc
3193 osti_memcpy((void *)reqBuffer, (void *)(smp_pass_through_req->smp_req_resp), smp_pass_through_req->smp_req_len);
3194 }
3195 else
3196 {
3197 agSMPFrame.outFrameLen = smp_pass_through_req->smp_req_len - 8; //Exclude header and crc
3198 osti_memcpy((void *)reqBuffer, (void *)(smp_pass_through_req->smp_req_resp + 4), smp_pass_through_req->smp_req_len - 4);
3199 }
3200 }
3201
3202 ostiMemoryStatus = ostiAllocMemory( tiRoot,
3203 &osMemHandle,
3204 (void **)&respBuffer,
3205 &(agSMPFrame.inFrameAddrUpper32),
3206 &(agSMPFrame.inFrameAddrLower32),
3207 8,
3208 smp_pass_through_req->smp_resp_len + 4,
3209 agFALSE);
3210 if((ostiMemoryStatus != tiSuccess) && (respBuffer == agNULL ))
3211 return IOCTL_CALL_FAIL;
3212
3213
3214 osti_memset((void *)respBuffer, 0, smp_pass_through_req->smp_resp_len);
3215
3216 // use FW control place in shared structure to keep the neccesary information
3217 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
3218 tdsaAllShared->tdFWControlEx.virtAddr = respBuffer;
3219 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)smp_pass_through_req->smp_req_resp + smp_pass_through_req->smp_req_len;
3220 tdsaAllShared->tdFWControlEx.len = smp_pass_through_req->smp_resp_len;
3221 tdsaAllShared->tdFWControlEx.param1 = agParam1;
3222 tdsaAllShared->tdFWControlEx.param2 = agParam2;
3223 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
3224 tdsaAllShared->tdFWControlEx.inProgress = 1;
3225 status = IOCTL_CALL_PENDING;
3226
3227 oneDeviceData = (tdsaDeviceData_t *)devHandle->tdData;
3228 if(saSendSMPIoctl(agRoot, oneDeviceData->agDevHandle, 0, &agSMPFrame, &ossaSMPIoctlCompleted) != AGSA_RC_SUCCESS)
3229 {
3230 status = IOCTL_CALL_FAIL;
3231 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
3232 }
3233 return status;
3234 }
3235
ostiSendSMPIOCTLRsp(tiRoot_t * tiRoot,bit32 status)3236 osGLOBAL void ostiSendSMPIOCTLRsp(
3237 tiRoot_t *tiRoot,
3238 bit32 status
3239 )
3240 {
3241 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3242 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3243 tiIOCTLPayload_t *agIOCTLPayload;
3244
3245 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
3246 agIOCTLPayload->Status = (bit16)status;
3247
3248 TI_DBG1(("ostiSendSMPIOCTLRsp: start, status = %d\n", status));
3249
3250 // if(tdsaAllShared->tdFWControlEx.param1 != agNULL)
3251 // {
3252 osti_memcpy((void *)(tdsaAllShared->tdFWControlEx.usrAddr),
3253 (void *)(tdsaAllShared->tdFWControlEx.virtAddr),
3254 tdsaAllShared->tdFWControlEx.len);
3255 // }
3256 ostiFreeMemory(tiRoot,
3257 tdsaAllShared->tdFWControlEx.buffer,
3258 tdsaAllShared->tdFWControlEx.len);
3259 ostiFreeMemory(tiRoot,
3260 tdsaAllShared->tdFWControlEx.param3,
3261 tdsaAllShared->tdFWControlEx.len);
3262 //if(tdsaAllShared->tdFWControlEx.param1 != agNULL)
3263 // {
3264 ostiIOCTLComplete(tiRoot,
3265 tdsaAllShared->tdFWControlEx.param1,
3266 tdsaAllShared->tdFWControlEx.param2,
3267 NULL);
3268 // }
3269 }
3270
3271
3272
3273
3274 /*****************************************************************************
3275 *
3276 * tdsaSendBISTIoctl
3277 *
3278 * Purpose: This routine is called to get Forensic Data.
3279 *
3280 * Parameters:
3281 * tiRoot: Pointer to driver instance
3282 * agIOCTLPayload: Pointer to the IOCTL payload.
3283 * agParam1: Pointer to pass context handle for IOCTL DMA operation
3284 * agParam2: Pointer to pass context handle for IOCTL DMA operation
3285 * agParam3: Pointer to pass context handle for IOCTL DMA operation
3286 *
3287 * Return:
3288 *
3289 * IOCTL_CALL_SUCCESS The requested operation completed successfully.
3290 * IOCTL_CALL_FAIL Fail to complete the IOCTL request.
3291 * Detail error code is function specific and
3292 * defined by the specific IOCTL function.
3293 * IOCTL_CALL_PENDING This request is asynchronous and completed
3294 * in some other context.
3295 * IOCTL_CALL_INVALID_CODE This IOCTL function is not recognized.
3296 *
3297 *
3298 *****************************************************************************/
3299 osGLOBAL bit32
tdsaSendBISTIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)3300 tdsaSendBISTIoctl(
3301 tiRoot_t *tiRoot,
3302 tiIOCTLPayload_t *agIOCTLPayload,
3303 void *agParam1,
3304 void *agParam2,
3305 void *agParam3
3306 )
3307 {
3308 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3309 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3310 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3311 tdBistPayload_t *pBistPayload;
3312 // bit32 length = 0;
3313 // bit32 status = IOCTL_CALL_SUCCESS;
3314 bit32 status = IOCTL_CALL_FAIL;
3315
3316 pBistPayload = (tdBistPayload_t*)agIOCTLPayload->FunctionSpecificArea;
3317
3318 tdsaAllShared->tdFWControlEx.buffer = agNULL;
3319 tdsaAllShared->tdFWControlEx.virtAddr = agNULL;
3320 tdsaAllShared->tdFWControlEx.usrAddr = (bit8*)&agIOCTLPayload->FunctionSpecificArea[0];
3321 tdsaAllShared->tdFWControlEx.len = 0;
3322 tdsaAllShared->tdFWControlEx.param1 = agParam1;
3323 tdsaAllShared->tdFWControlEx.param2 = agParam2;
3324 tdsaAllShared->tdFWControlEx.payload = agIOCTLPayload;
3325 tdsaAllShared->tdFWControlEx.inProgress = 0;
3326
3327 TI_DBG1(("tdsaSendBISTIoctl: Type %d Length %d Data %p\n",
3328 pBistPayload->testType,
3329 pBistPayload->testLength,
3330 pBistPayload->testData ));
3331
3332
3333 // pBistPayload->testtype = AGSA_BIST_TEST;
3334
3335 if( pBistPayload->testType == AGSA_BIST_TEST)
3336 {
3337 if( pBistPayload->testLength != sizeof(agsaEncryptSelfTestBitMap_t))
3338 {
3339 return status;
3340 }
3341 }
3342 else if( pBistPayload->testType == AGSA_SHA_TEST)
3343 {
3344 if( pBistPayload->testLength != sizeof(agsaEncryptSHATestDescriptor_t) )
3345 {
3346 return status;
3347 }
3348 }
3349 else if( pBistPayload->testType == AGSA_HMAC_TEST )
3350 {
3351 if( pBistPayload->testLength != sizeof(agsaEncryptHMACTestDescriptor_t))
3352 {
3353 return status;
3354 }
3355 }
3356
3357 /*
3358 GLOBAL bit32 saEncryptSelftestExecute(
3359 agsaRoot_t *agRoot,
3360 agsaContext_t *agContext,
3361 bit32 queueNum,
3362 bit32 type,
3363 bit32 length,
3364 void *TestDescriptor);
3365
3366 */
3367 if ( saEncryptSelftestExecute(agRoot,
3368 agNULL,
3369 0,
3370 pBistPayload->testType,
3371 pBistPayload->testLength,
3372 pBistPayload->testData ) != AGSA_RC_SUCCESS )
3373 {
3374 status = IOCTL_CALL_FAIL;
3375 }
3376
3377 return status;
3378 }
3379
3380
3381 osGLOBAL bit32
tdsaSendTMFIoctl(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,unsigned long resetType)3382 tdsaSendTMFIoctl( tiRoot_t *tiRoot,
3383 tiIOCTLPayload_t *agIOCTLPayload,
3384 void *agParam1,
3385 void *agParam2,
3386 unsigned long resetType
3387 )
3388 {
3389 bit32 status;
3390 tmf_pass_through_req_t *tmf_req = (tmf_pass_through_req_t*)agIOCTLPayload->FunctionSpecificArea;
3391 #if !(defined(__FreeBSD__))
3392 status = ostiSendResetDeviceIoctl(tiRoot, agParam2, tmf_req->pathId, tmf_req->targetId, tmf_req->lun, resetType);
3393 #endif
3394 TI_DBG3(("Status returned from ostiSendResetDeviceIoctl is %d\n",status));
3395 if(status != IOCTL_CALL_SUCCESS)
3396 {
3397 agIOCTLPayload->Status = status;
3398 return status;
3399 }
3400 status = IOCTL_CALL_SUCCESS;
3401 return status;
3402 }
3403
3404
3405 #ifdef VPD_TESTING
3406 /* temporary to test saSetVPDCommand() and saGetVPDCommand */
3407 osGLOBAL bit32
tdsaVPDSet(tiRoot_t * tiRoot)3408 tdsaVPDSet(
3409 tiRoot_t *tiRoot
3410 )
3411 {
3412 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3413 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3414 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3415 bit32 status = IOCTL_CALL_SUCCESS;
3416 agsaVPD_t VPDInfo;
3417 bit32 ret = AGSA_RC_SUCCESS;
3418
3419 bit32 bufAddrUpper = 0;
3420 bit32 bufAddrLower = 0;
3421 tdVPDControl_t *VPDControl;
3422
3423 void *osMemHandle = agNULL;
3424 void *buffer;
3425 bit32 timeCount=0;
3426 bit8 ioctlErr=0;
3427 bit8 VPDPayload[32];
3428 bit8 i;
3429 TI_DBG2(("tdsaVPDSet: start\n"));
3430
3431 for(i=0;i<sizeof(VPDPayload);i++)
3432 {
3433 VPDPayload[i] = i;
3434 }
3435 if(ostiAllocMemory( tiRoot,
3436 &osMemHandle,
3437 (void **)&buffer,
3438 &bufAddrUpper,
3439 &bufAddrLower,
3440 8,
3441 sizeof(VPDPayload),
3442 agFALSE))
3443 {
3444 return tiError;
3445 }
3446 osti_memcpy((void *)buffer,
3447 VPDPayload,
3448 sizeof(VPDPayload));
3449
3450
3451 osti_memset(&VPDInfo, 0, sizeof(agsaVPD_t));
3452 #ifdef NOT_YET /* direct mode worked */
3453 /* For now, only direct mode */
3454 VPDInfo.indirectMode = 0; /* direct mode */
3455 VPDInfo.VPDDevice = 1; /* SEEPROM-1 */
3456 VPDInfo.directLen = (bit8)sizeof(VPDPayload);
3457 VPDInfo.VPDOffset = 0;
3458 VPDInfo.directData = buffer;
3459 VPDInfo.indirectAddrUpper32 = bufAddrUpper;
3460 VPDInfo.indirectAddrLower32 = bufAddrLower;
3461 VPDInfo.indirectLen = sizeof(VPDPayload);
3462 #endif
3463
3464 /* indirect mode */
3465 VPDInfo.indirectMode = 1; /* indirect mode */
3466 VPDInfo.VPDDevice = 1; /* SEEPROM-1 */
3467 VPDInfo.directLen = 0;
3468 VPDInfo.VPDOffset = 0;
3469 VPDInfo.directData = agNULL;
3470 VPDInfo.indirectAddrUpper32 = bufAddrUpper;
3471 VPDInfo.indirectAddrLower32 = bufAddrLower;
3472 VPDInfo.indirectLen = sizeof(VPDPayload);
3473
3474 tdsaAllShared->tdFWControlEx.buffer = osMemHandle;
3475 tdsaAllShared->tdFWControlEx.param1 = agParam1;
3476 tdsaAllShared->tdFWControlEx.param2 = agParam2;
3477
3478 /* for testing only */
3479 tdsaAllShared->addrUpper = bufAddrUpper;
3480 tdsaAllShared->addrLower = bufAddrLower;
3481
3482 ret = saSetVPDCommand(agRoot, agNULL, 0, &VPDInfo);
3483
3484 if (ret == AGSA_RC_SUCCESS)
3485 {
3486 status = tiSuccess;
3487 }
3488 else
3489 {
3490 status = tiError;
3491 }
3492
3493 ostiFreeMemory(tiRoot, osMemHandle, sizeof(VPDPayload));
3494 return status;
3495 }
3496
3497 /* temporary to test saSetVPDCommand() and saGetVPDCommand */
3498 osGLOBAL bit32
tdsaVPDGet(tiRoot_t * tiRoot)3499 tdsaVPDGet(tiRoot_t *tiRoot)
3500 {
3501 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3502 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3503 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3504 bit32 status = IOCTL_CALL_SUCCESS;
3505 agsaVPD_t VPDInfo;
3506 bit32 ret = AGSA_RC_SUCCESS;
3507
3508
3509 TI_DBG2(("tdsaVPDGet: start\n"));
3510
3511 osti_memset(&VPDInfo, 0, sizeof(agsaVPD_t));
3512
3513 /* direct mode worked */
3514 VPDInfo.indirectMode = 0; /* direct mode */
3515 VPDInfo.VPDDevice = 1; /* SEEPROM-1*/
3516 VPDInfo.directLen = 32;
3517 VPDInfo.VPDOffset = 0;
3518 VPDInfo.directData = agNULL;
3519 VPDInfo.indirectAddrUpper32 = 0;
3520 VPDInfo.indirectAddrLower32 = 0;
3521 VPDInfo.indirectLen = 0;
3522
3523
3524 #ifdef NOT_YET /* worked; can't read VPD in ossaGetVPDResponseCB() because of indirect */
3525 VPDInfo.indirectMode = 1; /* direct mode */
3526 VPDInfo.VPDDevice = 1; /* SEEPROM-1*/
3527 VPDInfo.directLen = 0;
3528 VPDInfo.VPDOffset = 0;
3529 VPDInfo.directData = agNULL;
3530 VPDInfo.indirectAddrUpper32 = tdsaAllShared->addrUpper;
3531 VPDInfo.indirectAddrLower32 = tdsaAllShared->addrLower;
3532 VPDInfo.indirectLen = 32;
3533 #endif
3534 ret = saGetVPDCommand(agRoot, agNULL, 0, &VPDInfo);
3535
3536 if (ret == AGSA_RC_SUCCESS)
3537 {
3538 status = tiSuccess;
3539 }
3540 else
3541 {
3542 status = tiError;
3543 }
3544 return status;
3545 }
3546 #endif
3547 /*****************************************************************************
3548 *
3549 * tdsaGetNumOfLUNIOCTL
3550 *
3551 * Purpose: This routine is called to send Report LUN SSP command request.
3552 *
3553 * Parameters:
3554 * tiRoot: Pointer to driver instance
3555 * tiIOCTLPayload_t: Status of the Controller Reset.
3556 * agParam1: Void pointer to device extension
3557 * agParam2: Void pointer to SRB
3558 * agParam3: NULL
3559 *
3560 * Return: status
3561 *
3562 *
3563 *****************************************************************************/
3564 osGLOBAL bit32
tdsaGetNumOfLUNIOCTL(tiRoot_t * tiRoot,tiIOCTLPayload_t * agIOCTLPayload,void * agParam1,void * agParam2,void * agParam3)3565 tdsaGetNumOfLUNIOCTL(
3566 tiRoot_t *tiRoot,
3567 tiIOCTLPayload_t *agIOCTLPayload,
3568 void *agParam1,
3569 void *agParam2,
3570 void *agParam3
3571 )
3572 {
3573 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3574 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3575 agsaRoot_t *agRoot = &(tdsaAllShared->agRootInt);
3576 tdDeviceLUNInfoIOCTL_t *pDeviceLUNInfo = agNULL;
3577 tiDeviceHandle_t *devHandle = agNULL;
3578 void *tiRequestBody = agNULL;
3579 tiIORequest_t *tiIORequest = agNULL;
3580 bit32 status = IOCTL_CALL_SUCCESS;
3581
3582 TI_DBG2(("tdsaGetNumOfLUNIOCTL: Start\n"));
3583 do
3584 {
3585 pDeviceLUNInfo = (tdDeviceLUNInfoIOCTL_t*)agIOCTLPayload->FunctionSpecificArea;
3586
3587 if (agIOCTLPayload->Length < sizeof(tdDeviceLUNInfoIOCTL_t))
3588 {
3589 status = IOCTL_CALL_FAIL;
3590 break;
3591 }
3592 if(!pDeviceLUNInfo->tiDeviceHandle)
3593 {
3594 status = IOCTL_CALL_FAIL;
3595 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
3596 break;
3597 }
3598 devHandle = (tiDeviceHandle_t*)pDeviceLUNInfo->tiDeviceHandle;
3599 agIOCTLPayload->Status = IOCTL_ERR_STATUS_OK;
3600
3601 status = ostiNumOfLUNIOCTLreq(tiRoot,agParam1,agParam2,&tiRequestBody,&tiIORequest);
3602
3603
3604 if(status != AGSA_RC_SUCCESS)
3605 {
3606 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
3607 break;
3608 }
3609 status = tiNumOfLunIOCTLreq(tiRoot,tiIORequest,devHandle,tiRequestBody,agIOCTLPayload,agParam1,agParam2);
3610
3611 if(status != AGSA_RC_SUCCESS)
3612 {
3613 agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
3614 break;
3615 }
3616 // ostiIOCTLWaitForSignal (tiRoot, agParam1, agParam2, agParam3);
3617
3618 }while(0);
3619 TI_DBG2(("tdsaGetNumOfLUNIOCTL: End\n"));
3620 return status;
3621 }
3622
3623
3624 /*****************************************************************************
3625 *
3626 * ostiNumOfLUNIOCTLRsp
3627 *
3628 * Purpose: This routine is called when a Report LUN SSP command response id recieved.
3629 *
3630 * Parameters:
3631 * tiRoot: Pointer to driver instance
3632 * bit32 status
3633 *
3634 * Return: none
3635 *
3636 *
3637 *****************************************************************************/
ostiNumOfLUNIOCTLRsp(tiRoot_t * tiRoot,bit32 status)3638 osGLOBAL void ostiNumOfLUNIOCTLRsp(
3639 tiRoot_t *tiRoot,
3640 bit32 status
3641 )
3642 {
3643 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3644 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3645 tiIOCTLPayload_t *agIOCTLPayload;
3646 tdDeviceLUNInfoIOCTL_t *pDeviceLUNInfo = NULL;
3647 bit32 count = 0;
3648 bit32 numOfLUN =0;
3649
3650 TI_DBG1(("ostiNumOfLUNIOCTLRsp: start, status = %d\n", status));
3651
3652 if(tdsaAllShared->tdFWControlEx.inProgress == 1)
3653 {
3654 agIOCTLPayload = (tiIOCTLPayload_t *)(tdsaAllShared->tdFWControlEx.payload);
3655 if ((agIOCTLPayload) && (PMC_IOCTL_SIGNATURE == agIOCTLPayload->Signature)&&
3656 (IOCTL_MJ_GET_DEVICE_LUN == agIOCTLPayload->MajorFunction))
3657 {
3658 agIOCTLPayload->Status = (bit16)status;
3659 pDeviceLUNInfo = (tdDeviceLUNInfoIOCTL_t*)agIOCTLPayload->FunctionSpecificArea;
3660 numOfLUN = ((tdsaAllShared->tdFWControlEx.virtAddr[0] << 24)|(tdsaAllShared->tdFWControlEx.virtAddr[1] << 16)|\
3661 (tdsaAllShared->tdFWControlEx.virtAddr[2] << 8)|(tdsaAllShared->tdFWControlEx.virtAddr[3]));
3662 numOfLUN = numOfLUN/8;
3663 pDeviceLUNInfo->numOfLun = numOfLUN;
3664 // ostiFreeMemory(tiRoot,
3665 // tdsaAllShared->tdFWControlEx.virtAddr,
3666 // tdsaAllShared->tdFWControlEx.len);
3667 // if(tdsaAllShared->tdFWControlEx.param1 != agNULL)
3668 // {
3669 ostiIOCTLSetSignal(tiRoot,
3670 tdsaAllShared->tdFWControlEx.param1,
3671 tdsaAllShared->tdFWControlEx.param2,
3672 NULL);
3673 tdsaAllShared->tdFWControlEx.payload = NULL;
3674 // }
3675
3676 tdsaAllShared->tdFWControlEx.inProgress = 0;
3677 }
3678 }
3679 TI_DBG1(("ostiNumOfLUNIOCTLRsp: End\n"));
3680 }
3681
3682