Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor...

55
Intro to: InterProcessor Communications (IPC)

Transcript of Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor...

Page 1: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Intro to:   Inter‐Processor 

Communications (IPC)

Page 2: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Agenda Basic Concepts  IPC Services IPC Services Setup and Examples IPC T t IPC Transports For More Information

Page 3: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Basic Concepts Basic Concepts  IPC Services IPC Services Setup and Examples IPC T t IPC Transports For More Information

Page 4: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – Definition IPC  =  Inter‐Processor CommunicationWhile this definition is rather generic, it really means:

“Transporting data and/or signals between threads of execution”

These threads could be located anywhere: These threads could be located anywhere:

Thread 1 Thread 2Data

CorePac 0 CorePac 0CorePac 0Device 0

CorePac 1Device 1

How would YOU solve this problem?

Page 5: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – Possible Solutions How do you transport the data and signal? Manual: Develop your own protocol using device resourcesManual:  Develop your own protocol using device resources

Auto:       Using existing RTOS/Framework Utilities (i.e., IPC)

Thread 1 Thread 2Data

CorePac 0 CorePac 0CorePac 0Device 0

CorePac 1Device 1

What solutions exist in TI’s RTOS to perform IPC ?

Page 6: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – RTOS/Framework Solutions SAME C P TI’ RTOS (SYS/BIOS) t l i f SAME CorePac:  TI’s RTOS (SYS/BIOS) supports several services for

inter‐thread communication (e.g. semaphores, queues, mailboxes, etc.).

DIFFERENT CorePac: The IPC framework supports communications DIFFERENT CorePac:  The IPC framework supports communicationsbetween CorePacs via several transports.

DIFFERENT DEVICE: IPC transports can also be implementedb dbetween devices.

KEY: Same IPC APIs can be used for local or remote communications.

Thread 1 Thread 2Data

SYS/BIOS (or IPC)

SolutionsCorePac 0 CorePac 0

IPC + transportIPC + transport

CorePac 0Device 0

CorePac 1Device 1 p

Page 7: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – Transports Current IPC implementation uses several transports: Current IPC implementation uses several transports:

• CorePac  CorePac   (Shared Memory Model, Multicore Navigator)D i D i (S i l R id I/O)• Device  Device  (Serial Rapid I/O)

Chosen at configuration; Same code regardless of thread location.

Device 1CorePac 1 CorePac 2

Device 2CorePac 1

Thread

 1

Thread

 2

Thread

 1

Thread

 2

Thread

 1

Thread

 2

T

IPC

T T

IPCT T

IPC

T

SRIO

MEM MulticoreNavigatoror

SRIOSRIO SRIO

Page 8: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Services Basic Concepts  IPC Services IPC Services

• Message QueueN tif• Notify

• Data Passing• Support Utilities

Setup and Examples Setup and Examples IPC Transports F M I f ti For More Information

Page 9: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC ServicesTh IPC k i f API The IPC package is a set of APIs 

MessageQ uses the modules below …h d l l b d d d l But each module can also be used independently.

Application

MessageQ

Notify Module 

g Q

Basic Functionality(ListMP, HeapMP, gateMP, Shared Region)

IPC Config and 

Initialization

Transport Layer

Utilities(Name Server, MultiProc, List)

Transport Layer(Shared Memory, Multicore Navigator, SRIO)

Page 10: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Services – Message Queue Basic Concepts  IPC Services IPC Services

• Message QueueN tif• Notify

• Data Passing• Support Utilities

Setup and Examples Setup and Examples IPC Transports F M I f ti For More Information

Page 11: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

MessageQ – Highest Layer API

SINGLE reader, multiple WRITERS model (READER owns queue/mailbox), p ( q / )

Supports structured sending/receiving of variable‐length messages, which can include (pointers to) data

Uses all of the IPC services layers along with IPC Configuration & Initialization Uses all of the IPC services layers along with IPC Configuration & Initialization

APIs do not change if the message is between two threads:

On the same core 

On two different cores

On two different devices

APIs do NOT change based on transport – only the CFG (init) code

Shared memory

M l i N i Multicore Navigator

SRIO

Page 12: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

MessageQ and MessagesQ How does the writer connect with the reader queue?

A MultiProc and name server keep track of queue names and core IDs.A MultiProc and name server keep track of queue names and core IDs.

Q What do we mean when we refer to structured messages with variable size?

A Each message has a standard header and data. The header specifies the size of l dpayload.

Q How and where are messages allocated?

A List utility provides a double‐link list mechanism. The actual allocation of the memoryA List utility provides a double link list mechanism. The actual allocation of the memory is done by HeapMP, SharedRegion, and ListMP.

Q If there are multiple writers, how does the system prevent race conditions (e.g., two writers attempting to allocate the same memory)?

A GateMP provides hardware semaphore API to prevent race conditions.

Q What facilitates the moving of a message to the receiver queue?

A This is done by Notify API using the transport layer.

Q Does the application need to configure all these modules?

N M t f th fi ti i d b th t M d t il l tA No. Most of the configuration is done by the system.  More details later.

Page 13: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Using MessageQ (1/3)CorePac 2 READER

MessageQ_create(“myQ”, *synchronizer);

CorePac 2 ‐ READER

MessageQ_get(“myQ”, &msg, timeout);“myQ”

MessageQ transactions begin with READER creating a MessageQ. READER’ tt t t t lt i bl k ( l READER’s attempt to get a message results in a block (unless

timeout was specified), since no messages are in the queue yet.

What happens next?

Page 14: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Using MessageQ (2/3)CorePac 1 WRITER CorePac 2 READER

MessageQ_create(“myQ”, …);MessageQ_open (“myQ”, …);

CorePac 1 ‐WRITER CorePac 2 ‐ READER

“myQ” MessageQ_get(“myQ”, &msg…);msg = MessageQ_alloc (heap, size,…);

MessageQ_put(“myQ”, msg, …);

HeapHeap

WRITER begins by opening MessageQ created by READER. WRITER begins by opening MessageQ created by READER. WRITER gets a message block from a heap and fills it, as desired. WRITER puts the message into the MessageQ WRITER puts the message into the MessageQ.

How does the READER get unblocked?

Page 15: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Using MessageQ (3/3)CorePac 1 WRITER CorePac 2 READER

MessageQ_create(“myQ”, …);MessageQ_open (“myQ”, …);

CorePac 1 ‐WRITER CorePac 2 ‐ READER

“myQ” MessageQ_get(“myQ”, &msg…);

*** PROCESS MSG ***

msg = MessageQ_alloc (heap, size,…);

MessageQ_put(“myQ”, msg, …);

MessageQ_free(“myQ”, …);

MessageQ_delete(“myQ”, …);

MessageQ_close(“myQ”, …);

HeapHeap

Once WRITER puts msg in MessageQ, READER is unblocked. READER can now read/process the received message. READER frees message back to Heap.g p READER can optionally delete the created MessageQ, if desired.

Page 16: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

MessageQ – Configuration All API calls use the MessageQ module in IPC. User must also configure MultiProc and SharedRegion modules. All th fi ti / t i f d t ti ll All other configuration/setup is performed automatically

by MessageQ.

User APIs MessageQ

Notify

Uses

ListMP HeapMemMP +

MultiProc

Uses

Shared RegionUses Uses

GateMP

NameServer

Cfg

NameServer

Page 17: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

MessageQ – Miscellaneous Notes O/S independent:

If one CorePac is running LINUX and using SysLink If one CorePac is running LINUX and using SysLink,the API calls do not change.

SysLink is runtime software that provides connectivity SysLink is runtime software that provides connectivitybetween processors (running Linux, SYSBIOS, etc.)

Messages can be allocated statically or dynamically. Messages can be allocated statically or dynamically.

Timeouts are allowed when a task receives a message.

User can specify three priority levels: User can specify three priority levels:

Normal

High

Urgent

Page 18: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

More Information About MessageQ All structures and function descriptions can be found within 

the release:

\ipc_U_ZZ_YY_XX\docs\doxygen\html\_message_q_8h.html

Page 19: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Services ‐ Notify Basic Concepts  IPC Services IPC Services

• Message QueueN tif• Notify

• Data Passing• Support Utilities

Setup and Examples Setup and Examples IPC Transports F M I f ti For More Information

Page 20: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Using Notify – Concepts

In addition to moving MessageQ messages, Notify:

Can be used independently of MessageQ

Is a simpler form of IPC communication

Is used ONLY with shared memory transport

Device 1Device 1CorePac 1

1 2CorePac 2

1 2

Thread

 

Thread

 

Thread

 

Thread

 

IPC

MEM

IPC

MEM

Page 21: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Notify ModelC i d f SENDER d RECEIVER Comprised of SENDER and RECEIVER.

The SENDER API requires the following information:

Destination (SENDER ID is implicit)

16‐bit Line ID 

32‐bit Event ID

32‐bit payload (For example, a pointer to message handle) 32 bit payload (For example, a pointer to message handle)

The SENDER API generates an interrupt (an event) in the destination.

Based on Line ID and Event ID, the RECEIVER schedules a pre‐defined call‐back function.

Page 22: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Notify Model

Sender Receiver

During initialization, link the Event ID and Line ID with call back function.

Void Notify_registerEvent(srcId, lineId, eventId, cbFxn, cbArg);

During run time, the Sender sends a notify to the Receiver.

Void Notify_sendEvent(dstId, lineId, eventId, payload, waitClear);

Based on the Sender’s Source ID, Event ID, and Line ID,

INTERRUPT

, , ,the call‐back function that was registered during initialization is called with the argument payload.

Page 23: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Notify ImplementationQ How are interrupts generated for shared memory transport?

A The IPC hardware registers are a set of 32 bit registers that generateA The IPC hardware registers are a set of 32‐bit registers that generate interrupts.  There is one register for each core.

Q How are the notify parameters stored?

A List utility provides a double‐link list mechanism. The actual allocation of the memory is done by HeapMP, SharedRegion, and ListMPListMP.

Q How does the notify know to send the message to the correct destination?

A MultiProc and name server keep track of the core ID.

Q Does the application need to configure all these modules?

A No. Most of the configuration is done by the system.

Page 24: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Example Callback Function/** ======== cbFxn ========* Thi f i d i h N if I i ll d h i hi CPU* This fxn was registered with Notify. It is called when any event is sent to this CPU.*/Uint32 recvProcId ;Uint32 seq ;void cbFxn(UInt16 procId, UInt16 lineId, UInt32 eventId, UArg arg, UInt32 payload){{

/* The payload is a sequence number. */recvProcId = procId;seq = payload;seq payload;Semaphore_post(semHandle);

}

Page 25: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

More Information About Notify

All structures and function descriptions can be found within the release:

\ipc_U_ZZ_YY_XX\docs\doxygen\html\_notify_8h.html

Page 26: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Services ‐ Data Passing Basic Concepts  IPC Services IPC Services

• Message QueueN tif• Notify

• Data Passing• Support Utilities

Setup and Examples Setup and Examples IPC Transports F M I f ti For More Information

Page 27: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing Using Shared Memory (1/2) When there is a need to allocate memory that is accessible by 

multiple cores, shared memory is used.

However, the MPAX register for each core might assign a different logical address to the same physical shared memory address.

The Shared Region module provides a translation look‐up table that resolves the logical/physical address issue without user intervention.intervention.

Page 28: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing Using Shared Memory (2/2) Messages are created and freed, but not necessarily in consecutive 

order:

H MP id d i h tilit th t t t HeapMP provides a dynamic heap utility that supports create and free based on double link list architecture.

ListMP provides a double link list utility that makes it easy to ListMP provides a double link list utility that makes it easy to create and free messages for static memory. It is used by the HeapMP for dynamic cases.

To protect the above utilities from race conditions (e.g., multiple cores try to create messages at the same time):

GateMP provides hardware semaphore protection.

GateMP can also be used by non‐IPC applications to assign y pp ghardware semaphores.

Page 29: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing – Static Data Passing uses a double linked list that can be shared Data Passing uses a double linked list that can be shared 

between CorePacs; Linked list is defined STATICALLY. ListMP handles address translation and cache coherency. GateMP protects read/write accesses. ListMP is typically used by MessageQ not by itself.

User APIs

Notify

Uses

ListMP

MultiProc

Uses

Shared RegionUses

GateMP

NameServer

Cfg

Now, the dynamic version...

NameServer

Page 30: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing – Dynamicbl l k l h b h Data Passing uses a double linked list that can be shared 

between CPUs. Linked list is defined DYNAMICALLY (via heap). Same as previous except linked lists are allocated from Heap Same as previous, except linked lists are allocated from Heap Typically not used alone – but as a building block for MessageQ

User APIs

Notify

Uses

ListMP HeapMemMP +

MultiProc

Uses

Shared RegionUses Uses

GateMP

NameServer

Cfg

NameServer

Page 31: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing: Additional Transports

Multicore Navigator

M i d t d i t Messages are assigned to descriptors.

Monolithic descriptors provide a pointer to the message.

SRIO Type 11 has a TI‐developed message protocol that moves data and interrupts between devices.

Implementation of these transports will be discussed later.

Page 32: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Services – Support Utilities Basic Concepts  IPC Services IPC Services

• Message QueueN tif• Notify

• Data Passing• Support Utilities

Setup and Examples Setup and Examples IPC Transports F M I f ti For More Information

Page 33: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Support Utilities (1/2) IPC contains several utilities most of which do NOT need to be IPC contains several utilities, most of which do NOT need to be

configured by the user.

Here is a short description of each IPC utility: Here is a short description of each IPC utility:

IPC• Initializes IPC subsystems:

• Applications using IPC must call IPC start().IPC Applications using IPC must call IPC_start().• In the configuration file, setupNotify and setupMessageQ specify whether to set up these IPC modules.

MultiProc • Manages processor IDs and core names

• Manages shared memory using HeapMemMP allocatorSharedRegion

• Manages shared memory using HeapMemMP allocator• Handles address translation for shared memory regions

More utilities…

Page 34: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Support Utilities (2/2) IPC contains several utilities most of which do NOT need to be IPC contains several utilities, most of which do NOT need to be

configured by the user.

Here is a short description of each IPC utility: Here is a short description of each IPC utility:

ListMP• Provides linked list in shared memory• Uses multi processor gate (GateMP) to prevent collisionsListMP • Uses multi‐processor gate (GateMP) to prevent collisionson lists

GateMP • Multi‐processor gate that provides local (against otherthreads on local core) and remote context protection

HeapMemMP• Traditional heap; Supports variable‐sized alloc/free

HeapMemMP • All allocations are aligned on cache line boundaries.

Page 35: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Setup and Examples Basic Concepts  IPC Services IPC Services Setup and Examples IPC T t IPC Transports For More Information

Page 36: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – Tools/Setup Requiredk (l b ) h ll d h h IPC is a package (library) that is installed with the MCSDK.

Note: Installing IPC independent of MCSDK is strongly discouraged.

IPC also requires SYS/BIOS (threading) and XDC tools (packaging) – IPC also requires SYS/BIOS (threading) and XDC tools (packaging) installed with the MCSDK (supported by SYS/BIOS ROV and RTA).

IPC is supported on the latest KeyStone multicore devices (C667x, C665x),ll C647 d ARM DSP d ias well as C647x and ARM+DSP devices.

What IPC examples exist in the MCSDK?What IPC examples exist in the MCSDK?

Page 37: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC – Examples IPC examples are installed along with the MCSDK in the PDK folder IPC examples are installed along with the MCSDK in the PDK folder.

Simply import these projects into CCS and analyze them.

Some users start with this example code and modify as necessary.

• QMSS – Multicore Navigator(Queue Manager Subsystem)

• SHM – Shared Memoryy• SRIO – SRIO (loopback)• SRIO – Chip to Chip

Page 38: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC TransportsBasic Concepts  IPC Services IPC ServicesSetup and Examples IPC TransportsFor More InformationFor More Information

Page 39: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – Intro An IPC TRANSPORT is a … An IPC TRANSPORT is a …

“combination of physical H/W and driver code that allows twothreads to communicate on the same device or across devices.”

• This is the default transport

IPC supports three different transports:

Shared Memory• This is the default transport.• Uses on‐chip shared memory resources and interruptlines to signal the availability of data

Multicore Navigator

• Available on all KeyStone SoC devices• Uses queues and descriptors plus built‐in signalingto transmit/receive data and messages between threads

SRIO

to transmit/receive data and messages between threads

• Hardware serial peripheral that connects two or more DEVICES together

For MessageQ, only the configuration (init) code changes.All h d ( / ) i h dAll other code (e.g., put/get) remains unchanged.

Let's look briefly at the Multicore Navigator first...

Page 40: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Data Passing Using Multicore NavigatorThe Multicore Navigator:

Is an innovative packet based infrastructure that Is an innovative packet‐based infrastructure that facilitates data movement and multicore control

Provides a highly efficient inter‐core communication Provides a highly efficient inter‐core communication mechanism

Provides H/W queues and packet DMA that are the Provides H/W queues and packet DMA that are the basic building blocks for IPC

Examples of required init/CFG code are provided with the p q / pMCSDK.

Now consider the Multicore Navigator implementation …

Page 41: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – Multicore Navigator (1/3) MessageQ alloc allocates a heapMP buffer for the MessageQ msg MessageQ_alloc allocates a heapMP buffer for the MessageQ_msg 

from MSMC The buffer contains the MessageQ_Header plus the data.g _ p When MessageQ_Put is called with the MessageQ_msg, it also 

calls the TransportQmss function NotifyQmss_sendEvent.

TX Coremsg = MessageQ_alloc

RX Core“get the pointer to Msg”

MessageQ_put

MessageQ_get

NotifyQmss_sendEvent

Get a descriptor

QMSS‐received descriptor

NotifyDriverQmss isrp

Attach ptr/msg to descriptor

Qmss q e eP sh

y Q _

Qmss_queuePush(pushes descriptor directly toRxQueue of remote core)

Page 42: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – Multicore Navigator (2/3) The TransportQmss function NotifyQmss sendEvent The TransportQmss function NotifyQmss_sendEvent

gets a descriptor Adds the pointer to the MessageQ msg (located in MSMC and Adds the pointer to the MessageQ_msg (located in MSMC and 

containing the data) to the descriptor. Qmss_queuePush pushes the descriptor into a queue.

TX Coremsg = MessageQ_alloc

RX Core“get the pointer to Msg”

MessageQ_put

MessageQ_get

NotifyQmss_sendEvent

Get a descriptor

QMSS‐received descriptor

NotifyDriverQmss isrp

Attach ptr/msg to descriptor

Qmss q e eP sh

y Q _

Qmss_queuePush(pushes descriptor directly toRxQueue of remote core)

Page 43: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – Multicore Navigator (3/3)

The Interrupt generator queue calls notifyDriverQmss_isr.

The ISR schedules a QMSS receive descriptor that sends a message The ISR schedules a QMSS receive descriptor that sends a message to the queue of Receiver.

TX Coremsg = MessageQ_alloc

RX Core“get the pointer to Msg”

MessageQ_put

MessageQ_get

NotifyQmss_sendEvent

Get a descriptor

QMSS‐receive descriptor

NotifyDriverQmss isrp

Attach ptr/msg to descriptor

Qmss q e eP sh

y Q _

Qmss_queuePush(pushes descriptor directly toRxQueue of remote core)

Page 44: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – SRIO (1/3) The SRIO (Type 11) transport enables MessageQ to send data

between tasks, cores and devices via the SRIO IP block.

Refer to the MCSDK examples for setup code required to useMessageQ over this transport.

Chip V   CorePac WM Q ll

Chip X   CorePac Y“ M f ”msg = MessageQ_alloc

MessageQ_put(queueId, msg) MessageQ_get(queueHndl,rxMsg)

“get Msg from queue”

TransportSrio_put MessageQ_put(queueId, rxMsg)

Srio_sockSend(pkt, dstAddr) TransportSrio_isr

SRIO x4 SRIO x4SRIO x4 SRIO x4

Page 45: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – SRIO (2/3)d h k h h From a messageQ standpoint, the SRIO transport works the same as the QMSS 

transport. At the transport level, it is also somewhat the same.

The SRIO transport copies the messageQ message into the SRIO data buffer. The SRIO transport copies the messageQ message into the SRIO data buffer.

It will then pop a SRIO descriptor and put a pointer to the SRIO data buffer into the descriptor.

Chip V   CorePac WM Q ll

Chip X   CorePac Y“ M f ”msg = MessageQ_alloc

MessageQ_put(queueId, msg) MessageQ_get(queueHndl,rxMsg)

“get Msg from queue”

TransportSrio_put MessageQ_put(queueId, rxMsg)

Srio_sockSend(pkt, dstAddr) TransportSrio_isr

SRIO x4 SRIO x4SRIO x4 SRIO x4

Page 46: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transports – SRIO (3/3) The transport then passes the descriptor to the SRIO LLD via the 

Srio_sockSend API.

SRIO then sends and receives the buffer via the SRIO PKTDMA.

The message is then queued on the Receiver side.

Chip V   CorePac WM Q ll

Chip X   CorePac Y“ M f ”msg = MessageQ_alloc

MessageQ_put(queueId, msg) MessageQ_get(queueHndl,rxMsg)

“get Msg from queue”

TransportSrio_put MessageQ_put(queueId, rxMsg)

Srio_sockSend(pkt, dstAddr) TransportSrio_isr

SRIO x4 SRIO x4SRIO x4 SRIO x4

Page 47: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configure the Transport Layer

Most of the transport changes are in the CFG file.

The XDC tools build the configuration and initialization code. User involvement is only in changing the CFG file.

Some additional include and initialization is needed in the code.

Now consider the differences between shared memoryNow consider the differences between shared memoryand Navigator transport from the application perspective …

Page 48: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configuration: Shared Memory CFG File

var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');var Notify = xdc module('ti sdo ipc Notify');var Notify = xdc.module('ti.sdo.ipc.Notify');var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');Notify.SetupProxy =

xdc.module(Settings.getNotifySetupDelegate());MessageQ.SetupTransportProxy=

xdc.module(Settings.getMessageQSetupDelegate());

/* Use shared memory IPC *//* Use shared memory IPC */MessageQ.SetupTransportProxy =

xdc.module('ti.sdo.ipc.transports.TransportShmSetup');

Program.global.TRANSPORTSETUP = MessageQ.SetupTransportProxy.delegate$.$name;

Page 49: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configuration: Navigator CFG Filevar MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');var TransportQmss = xdc.useModule('ti.transport.ipc.qmss.transports.TransportQmss');

/* use IPC over QMSS */MessageQ.SetupTransportProxy = xdc.useModule(Settings.getMessageQSetupDelegate());var TransportQmssSetup =

xdc.useModule('ti.transport.ipc.qmss.transports.TransportQmssSetup');MessageQ.SetupTransportProxy = TransportQmssSetup;

TransportQmssSetup.descMemRegion = 0;Program.global.descriptorMemRegion = TransportQmssSetup.descMemRegion;

Program.global.numDescriptors = 8192;g g p

Program.global.descriptorSize = cacheLineSize; // multiple of cache line size

TransportQmss.numDescriptors = Program.global.numDescriptors;p Q p g g p ;

TransportQmss.descriptorIsInSharedMem = true;TransportQmss.descriptorSize = Program.global.descriptorSize;

Page 50: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configuration: SRIO CFG File

var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');var TransportSrio = xdc.useModule('ti.transport.ipc.srio.transports.TransportSrio');

/* use IPC over SRIO */MessageQ.SetupTransportProxy = xdc.useModule(Settings.getMessageQSetupDelegate());var TransportSrioSetup =

xdc.useModule('ti.transport.ipc.srio.transports.TransportSrioSetup');MessageQ.SetupTransportProxy = TransportSrioSetup;

TransportSrioSetup.messageQHeapId = 1; /* Sized specifically to handle receive side packets.* Heap should* not be used by any other application or module */

TransportSrioSetup.descMemRegion = 0;p p gTransportSrioSetup.numRxDescBuffs = 256; /* Should be sized large enough so that multiple

* packets can be queued on receive side and still* have buffs available for incoming packets */

Page 51: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configuration: Navigator Initialization (1/2) 

Additional Include:

/* QMSS LLD*/#include <ti/drv/qmss/qmss_drv.h>#include <ti/drv/qmss/qmss firmware h>#include <ti/drv/qmss/qmss_firmware.h>

/* CPPI LLD */#include <ti/drv/cppi/cppi_drv.h>_

#include <ti/transport/ipc/examples/common/bench_common.h>

#include <ti/transport/ipc/qmss/transports/TransportQmss.h>

Page 52: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

Configuration: Navigator Initialization (2/2) 

Add an initialization routine:

Int main(Int argc, Char* argv[]){

if ( lfId 0)if (selfId == 0){/* QMSS, and CPPI system wide initializations are run on* this core */t s co e /

result = systemInit();if (result != 0) {System_printf("Error (%d) while initializing QMSS\n", result);}

}

// Note that systemInit is provided by TI

Page 53: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transport Details

Message Size (B t )

SharedMemor

MulticoreNavigator SRIO

Throughput (Mb/second)

(Bytes) Memory Navigator

48 23.8 34.6 4.1

256 125 8 184 4 21 2256 125.8 184.4 21.2

1024 503 2 737 4

B h k D t il

1024 503.2 737.4 -

Benchmark Details• IPC Benchmark Examples from MCSDK• CPU Clock – 1 GHz• Header Size– 32 bytes• SRIO – Loopback Mode• Messages allocated up front

Page 54: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

IPC Transport Pros/ConsPROS CONS

• Simplest to implementd h h

• Single device onlyi if d l d ll

SharedMemory

• Moderate throughput • Requires Notify module and API callif doorbell required

• Possible contention with other tasksi th h dusing the same shared memory

• Highest throughput • Single device only

MulticoreNavigator

• Dedicated resources• Consumes least CPU cycles• Interrupt generated whend i il bldata is available

• Can be used across devices • Lowest throughputSRIO

• Can be used across devices • Lowest throughput

Page 55: Intro to: Inter Processor (IPC) - TI Training · IPC – Definition IPC = Inter‐Processor Communication While this definition is rather generic, it really means: “Transporting

For More Information• For more information, refer to the BIOS MCSDK User G ide on the EmbeddedMCSDK User Guide on the Embedded Processors Wiki.

• For questions regarding topics covered in this training, visit the support forums at thetraining, visit the support forums at theTI E2E Community website.