IOC mediator: DEBUG: add dummy channels

Add three PTY devices as dummy native channels. They are used for emulating
native lifecycle channel, native signal channel and native OEM raw channel
for IOC debugging.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Liu Yuan 2018-04-13 16:40:31 +08:00 committed by Jack Ren
parent 75b5e670d5
commit fd5472b421

View File

@ -106,6 +106,12 @@ do { if (ioc_debug && dbg_file) { fprintf(dbg_file, format, arg);\
fflush(dbg_file); } } while (0)
#define WPRINTF(format, arg...) printf(format, ##arg)
/*
* For debugging only, to generate lifecycle, signal and oem-raw data
* from PTY devices instead of native CBC cdevs.
*/
/* #define IOC_DUMMY */
/*
* Type definition for thread function.
*/
@ -122,6 +128,16 @@ static char virtual_uart_path[32];
*/
static uint32_t ioc_boot_reason;
/*
* Dummy pty slave fd is to maintain the pty active,
* to avoid EIO error when close the slave pty.
*/
#ifdef IOC_DUMMY
static int dummy0_sfd = -1;
static int dummy1_sfd = -1;
static int dummy2_sfd = -1;
#endif
/*
* IOC channels definition.
*/
@ -146,6 +162,11 @@ static struct ioc_ch_info ioc_ch_tbl[] = {
{IOC_INIT_FD, IOC_NP_RAW10, IOC_NATIVE_RAW10, IOC_CH_ON},
{IOC_INIT_FD, IOC_NP_RAW11, IOC_NATIVE_RAW11, IOC_CH_ON},
{IOC_INIT_FD, IOC_DP_NONE, IOC_VIRTUAL_UART, IOC_CH_ON},
#ifdef IOC_DUMMY
{IOC_INIT_FD, IOC_NP_FLF, IOC_NATIVE_DUMMY0, IOC_CH_ON},
{IOC_INIT_FD, IOC_NP_FSIG, IOC_NATIVE_DUMMY1, IOC_CH_ON},
{IOC_INIT_FD, IOC_NP_FRAW, IOC_NATIVE_DUMMY2, IOC_CH_ON}
#endif
};
static struct cbc_signal cbc_tx_signal_table[] = {
@ -713,6 +734,24 @@ ioc_ch_init(struct ioc_dev *ioc)
case IOC_VIRTUAL_UART:
fd = ioc_open_virtual_uart(virtual_uart_path);
break;
#ifdef IOC_DUMMY
/*
* TODO: check open if success for dummy fd
*/
case IOC_NATIVE_DUMMY0:
fd = ioc_open_virtual_uart(chl->name);
dummy0_sfd = open(chl->name, O_RDWR | O_NOCTTY |
O_NONBLOCK);
case IOC_NATIVE_DUMMY1:
fd = ioc_open_virtual_uart(chl->name);
dummy1_sfd = open(chl->name, O_RDWR | O_NOCTTY |
O_NONBLOCK);
case IOC_NATIVE_DUMMY2:
fd = ioc_open_virtual_uart(chl->name);
dummy2_sfd = open(chl->name, O_RDWR | O_NOCTTY |
O_NONBLOCK);
break;
#endif
default:
fd = -1;
break;
@ -751,6 +790,12 @@ ioc_ch_deinit(void)
close(chl->fd);
chl->fd = IOC_INIT_FD;
}
#ifdef IOC_DUMMY
close(dummy0_sfd);
close(dummy1_sfd);
close(dummy2_sfd);
#endif
}
/*
@ -890,7 +935,18 @@ ioc_process_tx(struct ioc_dev *ioc, enum ioc_ch_id id)
req->srv_len = count;
req->link_len = 0;
req->rtype = CBC_REQ_T_PROT;
#ifdef IOC_DUMMY
if (id == IOC_NATIVE_DUMMY0)
req->id = IOC_NATIVE_LFCC;
else if (id == IOC_NATIVE_DUMMY1)
req->id = IOC_NATIVE_SIGNAL;
else if (id == IOC_NATIVE_DUMMY2)
req->id = IOC_NATIVE_RAW11;
else
req->id = id;
#else
req->id = id;
#endif
cbc_request_enqueue(ioc, req, CBC_QUEUE_T_TX, false);
return 0;
}
@ -906,6 +962,11 @@ ioc_dispatch(struct ioc_dev *ioc, struct ioc_ch_info *chl)
case IOC_NATIVE_LFCC:
case IOC_NATIVE_SIGNAL:
case IOC_NATIVE_RAW0 ... IOC_NATIVE_RAW11:
#ifdef IOC_DUMMY
case IOC_NATIVE_DUMMY0:
case IOC_NATIVE_DUMMY1:
case IOC_NATIVE_DUMMY2:
#endif
ioc_process_tx(ioc, chl->id);
break;
case IOC_VIRTUAL_UART:
@ -1158,6 +1219,9 @@ ioc_init(void)
if (ioc_is_platform_supported() != 0)
goto ioc_err;
/* Check IOC boot reason */
if (ioc_boot_reason == 0)
goto ioc_err;
ioc = (struct ioc_dev *)calloc(1, sizeof(struct ioc_dev));
if (!ioc)
goto ioc_err;