Skip to content

Commit 61db2c7

Browse files
yliu80jren1
authored andcommitted
IOC mediator: support IOC lifecycle
This patch implements the IOC lifecycle virtualization. In native environment, lifecycle is uesed for SoC system power control, likes enter/exit S3/S5. So these related messages can not forward directly between physical IOC and Guest OS, they need to be mapped to VM pause, exit and launch. 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>
1 parent a1d7cae commit 61db2c7

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

devicemodel/hw/platform/ioc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ ioc_rx_thread(void *arg)
968968

969969
memset(&packet, 0, sizeof(packet));
970970
packet.cfg = &ioc->rx_config;
971+
packet.boot_reason = ioc_boot_reason;
971972
for (;;) {
972973
pthread_mutex_lock(&ioc->rx_mtx);
973974
while (SIMPLEQ_EMPTY(&ioc->rx_qhead)) {
@@ -1019,6 +1020,7 @@ ioc_tx_thread(void *arg)
10191020

10201021
memset(&packet, 0, sizeof(packet));
10211022
packet.cfg = &ioc->tx_config;
1023+
packet.boot_reason = ioc_boot_reason;
10221024
for (;;) {
10231025
pthread_mutex_lock(&ioc->tx_mtx);
10241026
while (SIMPLEQ_EMPTY(&ioc->tx_qhead)) {

devicemodel/hw/platform/ioc_cbc.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,40 @@ cbc_send_pkt(struct cbc_pkt *pkt)
346346
DPRINTF("ioc xmit failed on channel id=%d\n\r", id);
347347
}
348348

349+
/*
350+
* Update heartbeat state.
351+
*/
352+
static void
353+
cbc_update_heartbeat(struct cbc_pkt *pkt, uint8_t cmd, uint8_t sus_action)
354+
{
355+
uint8_t stat;
356+
357+
(void) sus_action;
358+
359+
/*
360+
* If heartbeat state switches(active/inactive), update the new state
361+
* value based on heartbeat commands.
362+
* The default state is inactive.
363+
*/
364+
if (cmd == CBC_HB_ACTIVE || cmd == CBC_HB_STANDBY ||
365+
cmd == CBC_HB_INITIAL)
366+
stat = 1;
367+
else
368+
stat = 0;
369+
370+
/* Default heartbeat state is zero, that means not active */
371+
if (stat != pkt->hb_state) {
372+
/*
373+
* Route the cbc request to the tx thread
374+
* and request type is SOC state update
375+
*/
376+
pkt->qtype = CBC_QUEUE_T_TX;
377+
pkt->req->rtype = CBC_REQ_T_SOC;
378+
pkt->req->buf[0] = stat;
379+
pkt->hb_state = stat;
380+
}
381+
}
382+
349383
/*
350384
* Update wakeup reason value and notify UOS immediately.
351385
* Some events can change the wakeup reason include periodic wakeup reason
@@ -355,6 +389,37 @@ cbc_send_pkt(struct cbc_pkt *pkt)
355389
static void
356390
cbc_update_wakeup_reason(struct cbc_pkt *pkt, uint32_t reason)
357391
{
392+
uint8_t *payload;
393+
394+
/* TODO: VMM requests S3/S5 do not implement yet */
395+
if (pkt->soc_active) {
396+
pkt->boot_reason = 0;
397+
reason |= CBC_WK_RSN_SOC;
398+
} else
399+
reason &= ~CBC_WK_RSN_SOC;
400+
reason &= CBC_WK_RSN_ALL;
401+
402+
if (pkt->boot_reason != 0)
403+
reason = pkt->boot_reason;
404+
405+
pkt->reason = reason;
406+
407+
/* Wakeup reason only has three bytes in CBC payload */
408+
payload = pkt->req->buf + CBC_PAYLOAD_POS;
409+
payload[0] = reason;
410+
payload[1] = reason >> 8;
411+
payload[2] = reason >> 16;
412+
413+
/* For CBC address layer header packing */
414+
pkt->req->id = IOC_NATIVE_LFCC;
415+
416+
/* Fill service header */
417+
pkt->req->buf[CBC_SRV_POS] = CBC_SC_WK_RSN;
418+
pkt->req->srv_len = 4;
419+
pkt->req->link_len = 0;
420+
421+
/* Send the CBC packet */
422+
cbc_send_pkt(pkt);
358423
}
359424

360425
/*
@@ -364,6 +429,25 @@ cbc_update_wakeup_reason(struct cbc_pkt *pkt, uint32_t reason)
364429
static void
365430
cbc_process_lifecycle(struct cbc_pkt *pkt)
366431
{
432+
uint8_t cmd;
433+
uint8_t *payload;
434+
uint32_t reason;
435+
436+
cmd = pkt->req->buf[CBC_SRV_POS];
437+
payload = pkt->req->buf + CBC_PAYLOAD_POS;
438+
switch (cmd) {
439+
case CBC_SC_WK_RSN:
440+
reason = payload[0] | (payload[1] << 8) | (payload[2] << 16);
441+
cbc_update_wakeup_reason(pkt, reason);
442+
break;
443+
case CBC_SC_HB:
444+
cbc_update_heartbeat(pkt, payload[0], payload[1]);
445+
break;
446+
default:
447+
DPRINTF("ioc lifecycle command=%d can not be handled\r\n",
448+
cmd);
449+
break;
450+
}
367451
}
368452

369453
/*

devicemodel/include/ioc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ struct cbc_pkt {
662662
uint8_t soc_active; /* Record soc state */
663663
uint8_t hb_state; /* Record Heartbeat state */
664664
uint32_t reason; /* Record current wakeup reason */
665+
uint32_t boot_reason; /* Record boot up wakeup reason */
665666
struct cbc_request *req; /* CBC packet data */
666667
struct cbc_config *cfg; /* CBC and whitelist configurations */
667668
enum cbc_queue_type qtype; /* Routes cbc_request to queue */

0 commit comments

Comments
 (0)