Commit 64e18149 authored by Antoine Kaufmann's avatar Antoine Kaufmann Committed by Jonas Kaufmann
Browse files

lib/simbricks/mem: Introduce memory protocol

parent 03b2c4e7
......@@ -36,6 +36,7 @@
#define SIMBRICKS_PROTO_ID_BASE 0x00
#define SIMBRICKS_PROTO_ID_NET 0x01
#define SIMBRICKS_PROTO_ID_PCIE 0x02
#define SIMBRICKS_PROTO_ID_MEM 0x03
/** Listener requests synchronization */
#define SIMBRICKS_PROTO_FLAGS_LI_SYNC (1 << 0)
......
/*
* Copyright 2022 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "lib/simbricks/mem/if.h"
void SimbricksMemIfDefaultParams(struct SimbricksBaseIfParams *params) {
SimbricksBaseIfDefaultParams(params);
params->upper_layer_proto = SIMBRICKS_PROTO_ID_MEM;
params->in_entries_size = params->out_entries_size = 4096;
}
/*
* Copyright 2022 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SIMBRICKS_MEM_IF_H_
#define SIMBRICKS_MEM_IF_H_
#include <stddef.h>
#include <stdint.h>
#include <simbricks/base/generic.h>
#include <simbricks/base/if.h>
#include <simbricks/mem/proto.h>
void SimbricksMemIfDefaultParams(struct SimbricksBaseIfParams *params);
struct SimbricksMemIf {
struct SimbricksBaseIf base;
};
/** Generate queue access functions for both directions */
SIMBRICKS_BASEIF_GENERIC(SimbricksMemIfH2M, SimbricksProtoMemH2M,
SimbricksMemIf);
SIMBRICKS_BASEIF_GENERIC(SimbricksMemIfM2H, SimbricksProtoMemM2H,
SimbricksMemIf);
#endif // SIMBRICKS_MEM_IF_H_
/*
* Copyright 2022 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SIMBRICKS_MEM_PROTO_H_
#define SIMBRICKS_MEM_PROTO_H_
#include <assert.h>
#include <stdint.h>
#include <simbricks/base/proto.h>
/******************************************************************************/
/* Initialization messages on Unix socket */
/** welcome message sent by memory to host. */
struct SimbricksProtoMemMemIntro {
uint32_t dummy; /* not used, but need to avoid empty struct for standard C */
} __attribute__((packed));
/** welcome message sent by host to memory */
struct SimbricksProtoMemHostIntro {
uint32_t dummy; /* not used, but need to avoid empty struct for standard C */
} __attribute__((packed));
/******************************************************************************/
/* Messages on memory to host channel */
/** Mask for type value in own_type field */
#define SIMBRICKS_PROTO_MEM_M2H_MSG_READCOMP 0x40
#define SIMBRICKS_PROTO_MEM_M2H_MSG_WRITECOMP 0x40
struct SimbricksProtoMemM2HReadcomp {
uint64_t req_id;
uint8_t pad[40];
uint64_t timestamp;
uint8_t pad_[7];
uint8_t own_type;
uint8_t data[];
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(struct SimbricksProtoMemM2HReadcomp);
struct SimbricksProtoMemM2HWritecomp {
uint64_t req_id;
uint8_t pad[40];
uint64_t timestamp;
uint8_t pad_[7];
uint8_t own_type;
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(struct SimbricksProtoMemM2HWritecomp);
union SimbricksProtoMemM2H {
union SimbricksProtoBaseMsg base;
struct SimbricksProtoMemM2HReadcomp readcomp;
struct SimbricksProtoMemM2HWritecomp writecomp;
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(union SimbricksProtoMemM2H);
/******************************************************************************/
/* Messages on host to memory channel */
#define SIMBRICKS_PROTO_MEM_H2M_MSG_READ 0x60
#define SIMBRICKS_PROTO_MEM_H2M_MSG_WRITE 0x61
struct SimbricksProtoMemH2MRead {
uint64_t req_id;
uint64_t as_id;
uint64_t addr;
uint16_t len;
uint8_t pad[22];
uint64_t timestamp;
uint8_t pad_[7];
uint8_t own_type;
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(struct SimbricksProtoMemH2MRead);
struct SimbricksProtoMemH2MWrite {
uint64_t req_id;
uint64_t as_id;
uint64_t addr;
uint16_t len;
uint8_t pad[22];
uint64_t timestamp;
uint8_t pad_[7];
uint8_t own_type;
uint8_t data[];
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(struct SimbricksProtoMemH2MWrite);
union SimbricksProtoMemH2M {
union SimbricksProtoBaseMsg base;
struct SimbricksProtoMemH2MRead read;
struct SimbricksProtoMemH2MWrite write;
} __attribute__((packed));
SIMBRICKS_PROTO_MSG_SZCHECK(union SimbricksProtoMemH2M);
#endif // SIMBRICKS_MEM_PROTO_H_
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
include mk/subdir_pre.mk
lib_pcie := $(d)libpcie.a
OBJS := $(addprefix $(d),if.o)
libsimbricks_objs += $(OBJS)
$(lib_pcie): $(OBJS)
CLEAN := $(lib_pcie) $(OBJS)
include mk/subdir_post.mk
......@@ -27,6 +27,7 @@ lib_simbricks := $(lib_dir)libsimbricks.a
libsimbricks_objs :=
$(eval $(call subdir,base))
$(eval $(call subdir,mem))
$(eval $(call subdir,network))
$(eval $(call subdir,pcie))
$(eval $(call subdir,nicif))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment