Skip to content

Commit

Permalink
Update header size
Browse files Browse the repository at this point in the history
  • Loading branch information
hunhoffe committed Aug 10, 2023
1 parent 1917f4f commit f1376ae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion kernel/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_network_config(workers):
NETWORK_CONFIG = get_network_config(MAX_WORKERS)
NETWORK_INFRA_IP = '172.31.0.20/24'

DCM_SCHEDULER_VERSION = "1.1.14"
DCM_SCHEDULER_VERSION = "1.1.15"

#
# Important globals
Expand Down
6 changes: 3 additions & 3 deletions kernel/src/arch/x86_64/rackscale/get_shmem_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub(crate) fn handle_get_shmem_structure(

// Modify header and write into output buffer
unsafe { encode(&logs, &mut payload) }.unwrap();
hdr.msg_len = core::mem::size_of::<[u64; MAX_PROCESSES]>() as u64;
hdr.msg_len = core::mem::size_of::<[u64; MAX_PROCESSES]>() as MsgLen;
}
ShmemStructure::NrLog => {
let log_clone = Arc::into_raw(Arc::clone(&NR_LOG));
Expand All @@ -155,7 +155,7 @@ pub(crate) fn handle_get_shmem_structure(

// Modify header and write into output buffer
unsafe { encode(&[log_paddr], &mut payload) }.unwrap();
hdr.msg_len = core::mem::size_of::<[u64; 1]>() as u64;
hdr.msg_len = core::mem::size_of::<[u64; 1]>() as MsgLen;
}
ShmemStructure::WorkQueues => {
let client_workqueue_clone = Arc::into_raw(Arc::clone(&RACKSCALE_CLIENT_WORKQUEUES));
Expand All @@ -168,7 +168,7 @@ pub(crate) fn handle_get_shmem_structure(

// Modify header and write into output buffer
unsafe { encode(&[arc_workqueue_paddr], &mut payload) }.unwrap();
hdr.msg_len = core::mem::size_of::<[u64; 1]>() as u64;
hdr.msg_len = core::mem::size_of::<[u64; 1]>() as MsgLen;
}
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/src/arch/x86_64/rackscale/kernelrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl TryFrom<RPCType> for KernelRpc {
}
}

pub(crate) const KernelRpcRes_SIZE: u64 = core::mem::size_of::<KResult<(u64, u64)>>() as u64;
pub(crate) const KernelRpcRes_SIZE: u16 = core::mem::size_of::<KResult<(u64, u64)>>() as MsgLen;

#[inline(always)]
pub(crate) fn construct_error_ret(hdr: &mut RPCHeader, payload: &mut [u8], err: KError) {
Expand All @@ -111,5 +111,5 @@ pub(crate) fn construct_ret_extra_data(
unsafe { encode(&res, &mut payload) }.unwrap();

// Modify header and write into output buffer
hdr.msg_len = KernelRpcRes_SIZE + additional_data_len;
hdr.msg_len = KernelRpcRes_SIZE + additional_data_len as MsgLen;
}
3 changes: 2 additions & 1 deletion lib/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ impl Client {
) -> Result<(), RPCError> {
// Calculate total data_out len
let data_in_len = data_in.iter().fold(0, |acc, x| acc + x.len());
debug_assert!(data_in_len < MsgLen::MAX as usize);

// Create request header and send message. It is safe to create a mutable reference here
// because it is assumed there will only be one invocation of call() running at a time, and only
// the client has access to this field.
let mut hdr = &mut self.hdr;
hdr.msg_type = rpc_id;
hdr.msg_len = data_in_len as u64;
hdr.msg_len = data_in_len as MsgLen;
self.transport.send_msg(hdr, data_in)?;

// Receive the response
Expand Down
15 changes: 8 additions & 7 deletions lib/rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ pub enum RPCError {
}
unsafe_abomonate!(RPCError);

// TODO(efficiency): type could probably be u8, but this seems easier for alignment w/ DCM?
pub type RPCType = u64;
pub const RPC_TYPE_CONNECT: u64 = 0u64;
pub type RPCType = u8;
pub const RPC_TYPE_CONNECT: u8 = 0u8;
pub type MsgId = u8;
pub type MsgLen = u16;

#[derive(Debug, Default)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
#[repr(C, packed)]
pub struct RPCHeader {
pub msg_id: MsgId,
pub msg_type: RPCType,
pub msg_len: u64,
pub msg_len: MsgLen,
}

pub const HDR_LEN: usize = core::mem::size_of::<RPCHeader>();

impl RPCHeader {
Expand Down

0 comments on commit f1376ae

Please sign in to comment.