Skip to content

Commit

Permalink
Merge pull request #55 from optimsoc/mpclass
Browse files Browse the repository at this point in the history
sw: use MP class in mpbuffer based mp
  • Loading branch information
wallento committed Apr 21, 2017
2 parents cae4dd8 + fe8f0b0 commit f11cfcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/soc/sw/baremetal-libs/src/libmp/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void control_init() {
// Add handler so that received message are treated correctly
// Class 1: control messages
optimsoc_mp_simple_init();
optimsoc_mp_simple_addhandler(NOC_CLASS_FIFO, &control_msg_handler);
optimsoc_mp_simple_addhandler(NOC_CLASS_MP, &control_msg_handler);

optimsoc_mp_simple_enable(0);
optimsoc_mp_simple_enable(1);
Expand Down Expand Up @@ -52,7 +52,7 @@ void control_msg_handler(uint32_t* buffer,size_t len) {

// Return the get endpoint response to sender
rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_GETEP_RESP << CTRL_REQUEST_LSB);

Expand Down Expand Up @@ -80,7 +80,7 @@ void control_msg_handler(uint32_t* buffer,size_t len) {
case CTRL_REQUEST_MSG_ALLOC_REQ:
{
rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_ALLOC_RESP << CTRL_REQUEST_LSB);

Expand Down Expand Up @@ -135,7 +135,7 @@ void control_msg_handler(uint32_t* buffer,size_t len) {
ep->remote = (struct endpoint *) buffer[3];

rbuffer[0] = (src << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CONNECT_RESP << CTRL_REQUEST_LSB);

Expand Down Expand Up @@ -214,7 +214,7 @@ struct endpoint *control_get_endpoint(uint32_t domain, uint32_t node,
// Try to retrieve from remote
// We do this as long as we do not get a valid handle back (-1)
ctrl_request.buffer[0] = (domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_GETEP_REQ << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = node;
Expand Down Expand Up @@ -254,7 +254,7 @@ uint32_t control_msg_alloc(struct endpoint_handle *to_ep, uint32_t size) {
// Try to retrieve from remote
// We do this as long as we do not get a valid handle back (-1)
ctrl_request.buffer[0] = (to_ep->domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_ALLOC_REQ << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) to_ep->ep;
Expand Down Expand Up @@ -291,7 +291,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer

for (int i=0;i<words;i=i+wordsperpacket) {
ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_DATA << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -311,7 +311,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer
}

ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_MSG_COMPLETE << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -327,7 +327,7 @@ void control_msg_data(struct endpoint_handle *ep, uint32_t address, void* buffer
uint32_t control_channel_connect(struct endpoint_handle *from,
struct endpoint_handle *to) {
ctrl_request.buffer[0] = (to->domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CONNECT_REQ << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) to->ep;
Expand All @@ -348,7 +348,7 @@ void control_channel_send(struct endpoint_handle *ep, uint8_t *data, uint32_t si

for (int i=0;i<words;i=i+wordsperpacket) {
ctrl_request.buffer[0] = (ep->domain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_DATA << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep;
Expand All @@ -373,7 +373,7 @@ void control_channel_send(struct endpoint_handle *ep, uint8_t *data, uint32_t si

void control_channel_sendcredit(struct endpoint_handle *ep, int32_t credit) {
ctrl_request.buffer[0] = (ep->ep->remotedomain << OPTIMSOC_DEST_LSB) |
(NOC_CLASS_FIFO << OPTIMSOC_CLASS_LSB) |
(NOC_CLASS_MP << OPTIMSOC_CLASS_LSB) |
(optimsoc_get_tileid() << OPTIMSOC_SRC_LSB) |
(CTRL_REQUEST_CHAN_CREDIT << CTRL_REQUEST_LSB);
ctrl_request.buffer[1] = (unsigned int) ep->ep->remote;
Expand Down
5 changes: 2 additions & 3 deletions src/soc/sw/baremetal-libs/src/libmp/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include "endpoints.h"

#define NOC_CLASS_FIFO 0
#define NOC_CLASS_DMA_REQ 1
#define NOC_CLASS_DMA_RESP 2
#define NOC_CLASS_MP 3
#define NOC_CLASS_DMA 1
#define NOC_CLASS_MP 2

// The protocol for the MCAPI message passing uses control
// messages via the NoC.
Expand Down

0 comments on commit f11cfcf

Please sign in to comment.