Newer
Older
/******************************************************************************
Copyright 2016 - 2019 Intel Corporation
Copyright 2015 - 2016 Lantiq Beteiligungs-GmbH & Co. KG
Copyright 2011 - 2014 Lantiq Deutschland GmbH
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
For licensing information, see the file 'LICENSE' in the root folder of
this software module.
******************************************************************************/
/** \file
Debug and Trace Interface - Basic Protocol Packet Handling.
*/
/* ============================================================================
Includes
========================================================================= */
#include "dsl_cpe_control.h"
#if defined(INCLUDE_DSL_CPE_API_VRX)
#include "cmv_message_format.h"
#include "drv_mei_cpe_interface.h"
#include "drv_dsl_cpe_api_ioctl.h"
#include "ifx_dti_protocol.h"
#include "ifx_dti_protocol_device.h"
#ifdef DTI_DONT_USE_PROTEXT
/*
Dummy defines, not requried for the DTI Serial Proxy.
*/
typedef struct DTI_ProtocolServerCtx_s
{
IFX_int_t dummy;
} DTI_ProtocolServerCtx_t;
typedef struct DTI_Connection_s
{
IFX_int_t dummy;
} DTI_Connection_t;
/* sorry for this style - we want to avoid that the dti_protocol_ext.h is included */
#ifndef _DTI_PROTOCOL_EXT_H
#define _DTI_PROTOCOL_EXT_H
#endif
#endif /* DTI_DONT_USE_PROTEXT */
#include "dti_device.h"
#include "dsl_cpe_dti_vrx_ctx.h"
/* ============================================================================
Defines
========================================================================= */
#define VRX_IOCTL_ARG unsigned long
/** DTI Device Interface Name */
#define DTI_DEV_VRX_IF_NAME "DSL-CPE"
#define DTI_DEV_VRX_BOARD_NAME "DSL CPE Board"
/** Max number of register accesses per packet */
#define DTI_DEV_VRX_MAX_REGISTER_ACCESS_NUM 0x44
/** Max number of debug accesses per packet */
#define DTI_DEV_VRX_MAX_DEBUG_ACCESS_NUM 0x44
/** max DTI buffer size for debug stream handling */
#define DTI_DEV_MEI_DBG_STREAM_MAX_BUFFER_SIZE 0x10000
/** default VRX device mailbox size */
#define DTI_DEV_VRX_DEFAULT_MBOX_SIZE CMV_USED_PAYLOAD_8BIT_SIZE
#define DTI_VRX_ARRAY_LENGTH(array) ((sizeof(array)/sizeof((array)[0])))
/* message header structure */
#define VRX_DTI_MSG_IDX_MSDID 0
#define VRX_DTI_MSG_IDX_INDEX 1
#define VRX_DTI_MSG_IDX_LENGTH 2
/* ============================================================================
Local Function Declaration
========================================================================= */
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_PacketError_t *pPacketError,
IFX_int_t lineNum);
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_PacketError_t *pPacketError,
IFX_int_t lineNum);
DSL_CPE_STATIC IFX_int_t DTI_configSet_AutoMsg(
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_H2D_DeviceConfigSet_t *pInCfgSet,
DTI_D2H_DeviceConfigSet_t *pOutCfgSet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_configGet_AutoMsg(
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
#ifndef DTI_DONT_USE_PROTEXT
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
const DTI_Connection_t *pDtiCon,
IFX_int_t devIfNum,
IFX_int_t lineNum,
IFX_char_t *pOutBuffer,
IFX_int_t outBufferSize_byte);
#endif /* !DTI_DONT_USE_PROTEXT */
#ifndef DTI_DONT_USE_PROTEXT
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum);
#endif /* !DTI_DONT_USE_PROTEXT */
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
/* ============================================================================
Device Access Functions
========================================================================= */
DSL_CPE_STATIC IFX_int_t DTI_VRX_PrintoutLevelSet(
DTI_DeviceSysInfo_t *pDeviceSystemInfo,
DTI_DeviceCtx_t **ppDtiDevCtx);
DTI_DeviceSysInfo_t *pDeviceSystemInfo,
DTI_DeviceCtx_t **ppDtiDevCtx);
DSL_CPE_STATIC IFX_int_t DTI_VRX_SystemInfoWrite(
DTI_DeviceSysInfo_t *pDeviceSystemInfo,
IFX_char_t *pSysInfoBuffer,
IFX_int_t bufferSize);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DeviceReset_t *pInDevReset,
DTI_D2H_DeviceReset_t *pOutDevReset,
IFX_int_t rstMaskSize_32,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_ProtocolServerCtx_t *pDtiProtServerCtx,
DTI_H2D_DeviceDownload_t *pInDevDownload,
DTI_D2H_DeviceDownload_t *pOutDevDownload,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DeviceLock_t *pInLock,
DTI_D2H_DeviceLock_t *pOutLock,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_RegisterGet_t *pInRegGet,
DTI_D2H_RegisterGet_t *pOutRegGet,
IFX_int_t lineNum,
IFX_uint32_t *pOutPaylSize_byte,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_RegisterSet_t *pInRegSet,
IFX_int_t inRegSetSize_Byte,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DeviceConfigSet_t *pInCfgSet,
DTI_D2H_DeviceConfigSet_t *pOutCfgSet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DeviceConfigGet_t *pInCfgGet,
DTI_D2H_DeviceConfigGet_t *pOutCfgGet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
#if (DTI_DEVICE_INTERFACE_VERSION) > (0x00000100)
DTI_DeviceCtx_t * pDtiDevCtx,
DTI_H2D_Message8_u *pInMsg8Send,
DTI_D2H_Message8_u *pOutMsg8Send,
IFX_int_t devNum,
IFX_int_t inPaylSize_byte,
IFX_int_t * pOutPaylSize_byte,
DTI_PacketError_t *pPacketError);
#endif
DSL_CPE_STATIC IFX_int_t DTI_VRX_Message16Send(
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_Message16_u *pInMsg16Send,
DTI_D2H_Message16_u *pOutMsg16Send,
IFX_int_t lineNum,
IFX_int_t inPaylSize_byte,
IFX_int_t *pOutPaylSize_byte,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_Message32Send(
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_Message32_u *pInMsg32Send,
DTI_D2H_Message32_u *pOutMsg32Send,
IFX_int_t lineNum,
IFX_int_t inPaylSize_byte,
IFX_int_t *pOutPaylSize_byte,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_TraceBufferConfigSet(
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_TraceConfigSet_t *pInTraceConfigSet,
DTI_D2H_TraceConfigSet_t *pOutTraceConfigSet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_TraceBufferReset(
DTI_DeviceCtx_t *pDtiDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_TraceBufferStatusGet(
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_D2H_TraceStatusGet_t *pOutTraceStatusGet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_TraceBufferGet(
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_TraceBufferGet_t *pInTraceBufferGet,
DTI_Packet_t **ppUsedDtiPacketOut,
IFX_int_t *pUsedBufferOutSize,
IFX_int_t lineNum,
IFX_int_t *pTrBufReadSize_byte,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DebugRead_t *pInDbgGet,
DTI_D2H_DebugRead_t *pOutDbgGet,
IFX_int_t lineNum,
IFX_int_t *pDbgReadCount,
DTI_PacketError_t *pPacketError);
DTI_DeviceCtx_t *pDtiDevCtx,
DTI_H2D_DebugWrite_t *pInDbgSet,
IFX_uint32_t *pOutDbgGet_nU,
IFX_int_t lineNum,
IFX_int_t *pDbgWriteCount,
DTI_PacketError_t *pPacketError);
DSL_CPE_STATIC IFX_int_t DTI_VRX_AutoMsgProcess(
DTI_DeviceCtx_t *pDtiDevCtx,
const DTI_Connection_t *pDtiCon,
IFX_uint32_t devSelectWait_ms,
IFX_char_t *pOutBuffer,
IFX_int_t outBufferSize_byte);
DSL_CPE_STATIC IFX_int_t DTI_VRX_WinEasyCiAccess(
DTI_DeviceCtx_t *pDtiDevCtx,
IFX_int_t lineNum,
const IFX_uint8_t *pDataIn,
const IFX_uint32_t sizeIn,
IFX_uint8_t *pDataOut,
const IFX_uint32_t sizeOut,
DTI_PacketError_t *pPacketError);
/* ============================================================================
Variables
========================================================================= */
/* Create device debug module - user part */
IFXOS_PRN_USR_MODULE_CREATE(DSL_CPE, DSL_PRN_LEVEL_HIGH);
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/**
Collection of all available device access functions.
*/
DTI_DeviceAccessFct_t DTI_DeviceAccessFct_VRX =
{
sizeof(DTI_DeviceAccessFct_t), /* structure check */
DTI_DEVICE_INTERFACE_VERSION, /* device interface version */
DTI_DEV_VRX_IF_NAME, /* device name */
DTI_VRX_PrintoutLevelSet,
DTI_VRX_ModuleSetup,
DTI_VRX_ModuleDelete,
DTI_VRX_SystemInfoWrite,
DTI_VRX_Reset,
DTI_VRX_Download,
DTI_VRX_DeviceOpen,
DTI_VRX_DeviceClose,
DTI_VRX_RegisterLock,
DTI_VRX_RegisterGet,
DTI_VRX_RegisterSet,
DTI_VRX_ConfigSet,
DTI_VRX_ConfigGet,
DTI_VRX_Message16Send,
DTI_VRX_Message32Send,
DTI_VRX_TraceBufferConfigSet,
DTI_VRX_TraceBufferReset,
DTI_VRX_TraceBufferStatusGet,
DTI_VRX_TraceBufferGet,
DTI_VRX_DebugRead,
DTI_VRX_DebugWrite,
DTI_VRX_AutoMsgProcess,
DTI_VRX_WinEasyCiAccess,
#if (DTI_DEVICE_INTERFACE_VERSION) > (0x00000100)
DTI_VRX_Message8Send,
#endif
};
/* ============================================================================
Local Function
========================================================================= */
static DSL_int_t DTI_VrxDeviceStateCheck(
DSL_int_t fd)
{
IOCTL_MEI_reqCfg_t Vdsl2_requCfg;
memset(&Vdsl2_requCfg, 0x0, sizeof(IOCTL_MEI_reqCfg_t));
if (DSL_CPE_Ioctl(fd, FIO_MEI_REQ_CONFIG, (DSL_int_t)&Vdsl2_requCfg) != 0)
{
DSL_CCA_DEBUG (DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
"ioct(FIO_MEI_REQ_CONFIG): ERROR - cannot request config, retCode = %d!"DSL_CPE_CRLF,
Vdsl2_requCfg.ictl.retCode));
return -1;
}
if (Vdsl2_requCfg.currDrvState != 6)
{
DSL_CCA_DEBUG (DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
"ioct(FIO_MEI_REQ_CONFIG): ERROR - device not available, state = %d!"DSL_CPE_CRLF,
Vdsl2_requCfg.currDrvState));
return -1;
}
return 0;
}
/**
Open a line or control device of the VRX driver
\param
num - control or line device number
\param
bCntrlDev - if set open a control device
\param
pDevName - device base name
\return
if success, a valid device fd
else IFX_ERROR.
*/
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
IFX_int_t dev_num,
IFX_char_t *pDevName)
{
DSL_char_t text[30];
DSL_int_t mei_fd = -1;
if (pDevName == DSL_NULL)
{
return -1;
}
snprintf(text, sizeof(text),"%s/%d", pDevName, dev_num);
text[sizeof(text) - 1]='\0';
mei_fd = DSL_CPE_Open(text);
/*mei_fd = open(text, O_RDWR);*/
if (mei_fd < 0)
{
DSL_CCA_DEBUG (DSL_CCA_DBG_MSG, (DSL_CPE_PREFIX
"xDSL device driver cannot be opened!"DSL_CPE_CRLF));
return -1;
}
/* Check VRX device driver state*/
if (DTI_VrxDeviceStateCheck(mei_fd) < 0)
{
DSL_CPE_Close(mei_fd);
DSL_CCA_DEBUG (DSL_CCA_DBG_MSG, (DSL_CPE_PREFIX
"xDSL device driver not ready!"DSL_CPE_CRLF));
return -1;
}
return mei_fd;
}
/**
Close a line or control device of the VRX driver
\param
devFd - a valid device fd
\return
If success IFX_SUCCESS else IFX_ERROR.
*/
IFX_int_t devFd)
{
IFX_int_t retVal = IFX_ERROR;
if (devFd > 0)
{
retVal = DSL_CPE_Close(devFd);
}
return retVal;
}
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_PacketError_t *pPacketError,
IFX_int_t lineNum)
{
*pPacketError = DTI_eNoError;
if (pVrxDevCtx->pDevFds[lineNum] < 0)
{
pVrxDevCtx->pDevFds[lineNum] =
DTI_DevOpenByName(lineNum, DSL_CPE_DSL_LOW_DEV);
if (pVrxDevCtx->pDevFds[lineNum] < 0)
{
*pPacketError = DTI_eErrPortOpen;
return IFX_ERROR;
}
}
return IFX_SUCCESS;
}
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_PacketError_t *pPacketError,
IFX_int_t lineNum)
{
*pPacketError = DTI_eNoError;
if (pVrxDevCtx->pDevFds[lineNum] >= 0)
{
(void)DTI_DevCloseByFd(pVrxDevCtx->pDevFds[lineNum]);
pVrxDevCtx->pDevFds[lineNum] = -1;
}
return IFX_SUCCESS;
}
/*
Config Set - enable / disable autonomous messages.
\param
pVrxDevCtx - points to the VRX Device context.
\param
pInCfgSet - points to the config data which will be set.
\param
pOutCfgSet - points to the data structure to return the actual config.
\param
lineNum - line number
\param
pPacketError - returns the DTI operation result
\return
-1 if something went wrong, else
size of the mailbox
*/
DSL_CPE_STATIC IFX_int_t DTI_configSet_AutoMsg(
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
DTI_H2D_DeviceConfigSet_t *pInCfgSet,
DTI_D2H_DeviceConfigSet_t *pOutCfgSet,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError)
{
#ifndef DTI_DONT_USE_PROTEXT
IFX_int_t nfcChange = 1;
IOCTL_MEI_ioctl_t drvIoCtl;
pOutCfgSet->key = pInCfgSet->key;
pOutCfgSet->value = 0;
if ((pInCfgSet->value != 1) && (pInCfgSet->value != 0))
{
*pPacketError = DTI_eErrInvalidParameters;
return IFX_SUCCESS;
}
if (pVrxDevCtx->bAutoDevMsgSupport)
{
if ( (pVrxDevCtx->pDevFds[lineNum] == -1) && (pInCfgSet->value == 0) )
{
nfcChange = 0;
}
else
{
DTI_devFdClear(pVrxDevCtx, lineNum);
}
if (nfcChange == 1)
{
cpe_control_memset_s(&drvIoCtl, sizeof(drvIoCtl), 0x00, sizeof(drvIoCtl));
if (DTI_DevOpen(pVrxDevCtx, pPacketError, lineNum) != IFX_SUCCESS)
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Config Set AutoMsg - device open error." DSL_CPE_CRLF));
*pPacketError = DTI_eErrPortOpen;
return IFX_ERROR;
}
if ( (DSL_CPE_Ioctl(
pVrxDevCtx->pDevFds[lineNum],
(pInCfgSet->value == 0) ? FIO_MEI_MBOX_NFC_DISABLE : FIO_MEI_MBOX_NFC_ENABLE,
(DSL_int_t)&drvIoCtl)) < 0 )
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Config Set AutoMsg - ioctl, NFC %s."DSL_CPE_CRLF,
(pInCfgSet->value == 0) ? "disable" : "enable"));
*pPacketError = DTI_eErrPortOperation;
}
else
{
if (pInCfgSet->value == 1)
{
IFXOS_DevFdSet( (IFX_uint32_t)pVrxDevCtx->pDevFds[lineNum],
&pVrxDevCtx->nfcDevFds);
if ((pVrxDevCtx->pDevFds[lineNum] + 1) > pVrxDevCtx->nfcMaxDevFd)
{
pVrxDevCtx->nfcMaxDevFd = pVrxDevCtx->pDevFds[lineNum] + 1;
}
pOutCfgSet->value = 1;
}
}
}
}
else
#endif /* !DTI_DONT_USE_PROTEXT */
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Cfg Set - Auto msg not supported."DSL_CPE_CRLF));
*pPacketError = DTI_eErrConfiguration;
}
return IFX_SUCCESS;
}
/*
Config Get - enable / disable status of autonous messages.
\param
pVrxDevCtx - points to the VRX Device context.
\param
lineNum - line number
\param
pPacketError - returns the DTI operation result
\return
1 if auto msg is enabled
0 if auto msg is disabled
*/
DSL_CPE_STATIC IFX_int_t DTI_configGet_AutoMsg(
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError)
{
IFX_int_t keyValue = 0;
#ifndef DTI_DONT_USE_PROTEXT
if (pVrxDevCtx->bAutoDevMsgSupport)
{
if ( (pVrxDevCtx->pDevFds[lineNum] >= 0) && (pVrxDevCtx->nfcMaxDevFd > 0))
{
keyValue = (IFXOS_DevFdIsSet( (IFX_uint32_t)pVrxDevCtx->pDevFds[lineNum],
&pVrxDevCtx->nfcDevFds)) ? 1 : 0;
}
else
{
keyValue = 0;
}
*pPacketError = DTI_eNoError;
}
else
#endif /* !DTI_DONT_USE_PROTEXT */
{
*pPacketError = DTI_eErrConfiguration;
}
return keyValue;
}
#ifndef DTI_DONT_USE_PROTEXT
/**
Clear a device FD from the FD_SET and recalc new max FD.
\param
pVrxDevCtx - points to the VRX Device context.
\param
lineNum - line number
*/
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum)
{
#if defined(IFXOS_HAVE_DEV_FD_CLEAR)
IFX_int_t i, maxDevFd = 0;
DTI_DevFdClear(pVrxDevCtx->pDevFd[lineNum], &pVrxDevCtx->nfcDevFds);
for (i = 0; i < pVrxDevCtx->numOfPorts; i++)
{
if (pVrxDevCtx->pDevFd[i] >= 0)
{
if ( (DSL_CPE_DevFdIsSet(pVrxDevCtx->pDevFds[i], &pVrxDevCtx->nfcDevFds)) &&
(pVrxDevCtx->pDevFds[i] > maxDevFd) }
{
maxDevFd = pVrxDevCtx->pDevFds[i];
}
}
}
pVrxDevCtx->nfcMaxDevFd = maxDevFd + 1;
#else
IFX_int_t i, maxDevFd = 0;
pVrxDevCtx->nfcMaxDevFd = 0;
for (i = 0; i < pVrxDevCtx->numOfPorts; i++)
{
if ( (pVrxDevCtx->pDevFds[i] >= 0) && (i != lineNum))
{
if ( DSL_CPE_DevFdIsSet((IFX_uint32_t)pVrxDevCtx->pDevFds[i], &pVrxDevCtx->nfcDevFds) )
DSL_CPE_DevFdIsSet((IFX_uint32_t)pVrxDevCtx->pDevFds[i], &pVrxDevCtx->tmpDevFds);
if (pVrxDevCtx->pDevFds[i] > maxDevFd)
{
maxDevFd = pVrxDevCtx->pDevFds[i];
}
}
}
}
cpe_control_memcpy_s(&pVrxDevCtx->nfcDevFds, sizeof(pVrxDevCtx->nfcDevFds), &pVrxDevCtx->tmpDevFds, sizeof(IFXOS_devFd_set_t));
pVrxDevCtx->nfcMaxDevFd = (maxDevFd) ? (maxDevFd + 1) : 0;
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
#endif
return;
}
#endif /* !DTI_DONT_USE_PROTEXT */
#ifndef DTI_DONT_USE_PROTEXT
/**
Check and process for xDSL Rev3 Device Autonomous Messages.
The Auto Msg is read form the device (driver) and a corresponding
DTI packet is created and sent to the upper DTI Client
\param
pVrxDevCtx - points to the VRX Device context.
\param
pDtiCon - points to the established DTI Connection data.
\param
lineNum - line number.
\param
pOutBuffer - points to the DTI packet out buffer to create a DTI packet.
\param
outBufferSize_byte - DTI out buffer size [byte]
\return
IFX_SUCCESS if the DTI packet has been sent.
IFX_ERROR DTI packet has not been sent.
\remarks
At first the device msg will be read out to free the internal driver buffer.
This is done independant on the established connection.
*/
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
const DTI_Connection_t *pDtiCon,
IFX_int_t devIfNum,
IFX_int_t lineNum,
IFX_char_t *pOutBuffer,
IFX_int_t outBufferSize_byte)
{
IFX_int_t paylBufferSize_byte = 0;
DTI_PacketError_t packetError = DTI_eNoError;
DTI_Packet_t *pAutoMsgPacket = IFX_NULL;
IFX_uint16_t *pModemPayload = IFX_NULL;
DTI_D2H_Message16_u *pMsg16;
IOCTL_MEI_message_t msgRead;
/*
First: read out the msg to free the driver.
*/
cpe_control_memset_s(&msgRead, sizeof(msgRead), 0x00, sizeof(msgRead));
msgRead.pPayload = (unsigned char*)pVrxDevCtx->pAutoMsgBuf;
msgRead.paylSize_byte = (unsigned int)pVrxDevCtx->autoMsgBuf_byte;
if ( DSL_CPE_Ioctl(
pVrxDevCtx->pDevFds[lineNum],
FIO_MEI_MBOX_NFC_RD,
(DSL_int_t)&msgRead) < 0 )
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Auto Msg[0x04X%] - ioctl error)."DSL_CPE_CRLF,
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("\tNFC[0x04X%]."DSL_CPE_CRLF,msgRead.msgId));
packetError = DTI_eErrPortAutoOperation;
}
/*
Second: prepare and send the packet.
*/
if (outBufferSize_byte < (sizeof(DTI_PacketHeader_t) + sizeof(IOCTL_MEI_message_t)))
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - not enough out buffer."DSL_CPE_CRLF));
return IFX_ERROR;
}
/* setup out packet */
uPayload.pUInt8 = (IFX_uint8_t *)pOutBuffer;
pAutoMsgPacket = (DTI_Packet_t *)DSL_PTR_CAST_GET_ULONG(uPayload);
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - DTI Packet out buffer missaligned."DSL_CPE_CRLF));
return IFX_ERROR;
}
/* setup out packet - payload */
uPayload.pUInt8 = (IFX_uint8_t *)pAutoMsgPacket->payload;
pMsg16 = (DTI_D2H_Message16_u *)DSL_PTR_CAST_GET_UINT16(uPayload);
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - DTI Payload out buffer missaligned."DSL_CPE_CRLF));
packetError = (packetError == DTI_eNoError) ? DTI_eErrMalformedPacket : packetError;
}
if (packetError == DTI_eNoError)
{
/* modem msg payload = index[16Bit] + length[16Bit] + Payload Data[16/32 Bit] */
uPayload.pUInt8 = (IFX_uint8_t *)msgRead.pPayload;
pModemPayload = (IFX_uint16_t *)DSL_PTR_CAST_GET_UINT16(uPayload);
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - DTI Payload modem buffer missaligned."DSL_CPE_CRLF));
packetError = (packetError == DTI_eNoError) ? DTI_eErrMalformedPacket : packetError;
}
}
if ( (packetError == DTI_eNoError) && (pModemPayload != IFX_NULL) )
{
/* DTI Packet Message [16/32 Bit]:
DTI Packet Header + Payload Hdr [msg ID, index, length] + Payload Data [16/32 Bit] */
paylBufferSize_byte = outBufferSize_byte - sizeof(DTI_PacketHeader_t);
paylBufferSize_byte -= sizeof(pMsg16->raw.data[0])*4 + sizeof(pMsg16->raw.sendResult);
if ( paylBufferSize_byte < ((IFX_int_t)msgRead.paylSize_byte) )
{
/* not enough buffer - cut payload and setup error packet */
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - cut Payload."DSL_CPE_CRLF));
packetError = DTI_eErrInvalidPayloadSize;
}
else
{
paylBufferSize_byte = (IFX_int_t)msgRead.paylSize_byte;
if (msgRead.paylSize_byte & 0x1)
{
/* add 1 byte in case of odd msg length */
paylBufferSize_byte +=1;
}
/* Modem 16 Bit message */
(void)DTI_headerPacketTypeSet(
pAutoMsgPacket,
(IFX_uint32_t)DTI_PacketType_eMessageSend,
(IFX_uint32_t)DTI_e16Bit,
(IFX_uint32_t)((sizeof(pMsg16->raw.data[VRX_DTI_MSG_IDX_MSDID]) + sizeof(pMsg16->raw.sendResult)) +
paylBufferSize_byte) );
pMsg16->raw.sendResult = IFX_SUCCESS;
pMsg16->raw.data[VRX_DTI_MSG_IDX_MSDID] = msgRead.msgId;
if (paylBufferSize_byte > 0)
{
cpe_control_memcpy_s(&pMsg16->raw.data[VRX_DTI_MSG_IDX_INDEX],
sizeof(pMsg16->raw.data[VRX_DTI_MSG_IDX_INDEX]),
msgRead.pPayload, paylBufferSize_byte);
}
}
}
if (packetError != DTI_eNoError)
{
(void)DTI_headerPacketTypeSet(
pAutoMsgPacket,
(IFX_uint32_t)DTI_PacketType_eMessageError, (IFX_uint32_t)DTI_e8Bit, 0);
}
/* complete header setup */
pAutoMsgPacket->header.port = DTI_HDR_PORT_PORT_NUM_SET(pAutoMsgPacket->header.port, lineNum);
pAutoMsgPacket->header.port = DTI_HDR_PORT_DEV_TYPE_NUM_SET(pAutoMsgPacket->header.port, devIfNum);
pAutoMsgPacket->header.tan = (IFX_uint32_t)0;
pAutoMsgPacket->header.error = (IFX_uint32_t)packetError;
DTI_packetShow (
pAutoMsgPacket, IFX_TRUE, IFX_FALSE, "Vrx AutoMsg",
(pAutoMsgPacket->header.error == DTI_eNoError) ? IFXOS_PRN_LEVEL_LOW : DSL_PRN_LEVEL_HIGH);
if (DTI_packetSend(pDtiCon, pAutoMsgPacket) != IFX_SUCCESS)
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Dev Auto Msg - send packet."DSL_CPE_CRLF));
return IFX_ERROR;
}
return IFX_SUCCESS;
}
#endif /* !DTI_DONT_USE_PROTEXT */
/*
Get the Line Cfg from the driver and return the mailbox size.
\param
pVrxDevCtx - points to the VRX Device context.
\param
lineNum - line number
\param
pPacketError - returns the DTI operation result
\return
-1 if something went wrong, else
size of the mailbox
*/
DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum,
DTI_PacketError_t *pPacketError)
{
IOCTL_MEI_reqCfg_t reqCfg;
if (DTI_DevOpen(pVrxDevCtx, pPacketError, lineNum) != IFX_SUCCESS)
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Config Get MB Size - device open error."DSL_CPE_CRLF));
cpe_control_memset_s(&reqCfg, sizeof(reqCfg), 0x00, sizeof(IOCTL_MEI_reqCfg_t));
if ( (DSL_CPE_Ioctl(
pVrxDevCtx->pDevFds[lineNum],
FIO_MEI_REQ_CONFIG,
(DSL_int_t)&reqCfg)) < 0 )
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_ERR,
("ERROR: Vrx Config Get MB Size - request config error."DSL_CPE_CRLF));
*pPacketError = DTI_eErrPortOperation;
return -1;
}
else
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE, DSL_PRN_LEVEL_NORMAL,
("Vrx Config MB Size: ME2ARC = 0x%X, ARC2ME = 0x%X."DSL_CPE_CRLF,
reqCfg.Me2ArcOnlineMbSize, reqCfg.Arc2MeOnlineMbSize));
*pPacketError = DTI_eNoError;
return (IFX_int_t)reqCfg.Me2ArcOnlineMbSize;
}
}
/**
xDSL Debug Stream setup
- request current config
- if still not init do init if data are given.
\param
priv_ctx - points to the VRX Device context.
\param
line_num - line number
\param
cfg_get - incoming configuration
\param
cfg_set - outgoing configuration
\return
-1 if something went wrong, else
size of the mailbox
*/
DTI_traceBufferDbgStrmCfg(DTI_DEV_VrxDriverCtx_t *pVrxDevCtx,
IFX_int_t lineNum,
IOCTL_MEI_DEBUG_STREAM_configGet_t *pCfgGet,
IOCTL_MEI_DEBUG_STREAM_configSet_t *pCfgSet)
{
/* get current config */
cpe_control_memset_s(pCfgGet, sizeof(pCfgGet), 0x00, sizeof(IOCTL_MEI_DEBUG_STREAM_configGet_t));
if (IFXOS_DeviceControl(pVrxDevCtx->pDevFds[lineNum],
FIO_MEI_DEBUG_STREAM_CONFIG_GET,
(IFX_int_t)pCfgGet) < 0)
{
if (pCfgSet != IFX_NULL)
{
if (IFXOS_DeviceControl(pVrxDevCtx->pDevFds[lineNum],
FIO_MEI_DEBUG_STREAM_CONFIG_SET,
(IFX_int_t)pCfgSet) < 0)
{
DSL_CPE_PRN_USR_ERR_NL(
DSL_CPE, DSL_PRN_LEVEL_ERR,
lineNum));
return IFX_ERROR;
}
else
{
cpe_control_memset_s(pCfgGet, sizeof(pCfgGet), 0x00, sizeof(IOCTL_MEI_DEBUG_STREAM_configGet_t));
if (IFXOS_DeviceControl(
pVrxDevCtx->pDevFds[lineNum],
FIO_MEI_DEBUG_STREAM_CONFIG_GET,
(IFX_int_t)pCfgGet) < 0)
{
DSL_CPE_PRN_USR_ERR_NL(DSL_CPE,
DSL_PRN_LEVEL_ERR,
("ERROR: Mei dbgStreamCfgGet "\
"- line %d, re-init get error"\