resource-lp.h 2.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (C) 2014 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
*/

/* this header defines the user-facing functionality needed to interact with a
 * resource LP. All of the LP-specific implementation details are in the
 * corresponding C file */

#ifndef RESOURCE_LP_H
#define RESOURCE_LP_H

#include "ross.h"
#include "codes/lp-msg.h"
#include "codes/resource.h"
#include <stdint.h>

19
#define RESOURCE_MAX_CALLBACK_PAYLOAD 64
20 21 22 23 24 25 26 27

typedef struct {
    int ret;
    /* in the case of a reserve, need to return the token */
    resource_token_t tok;
} resource_callback;

void resource_lp_init();
28
void resource_lp_configure();
29 30 31 32

/* Wrappers for the underlying resource structure.
 * Implicitly maps the given LPID to it's group and repetition, then messages
 * the resource LP with the request.
33 34 35
 * The following functions expect the sending LP to put its magic and callback
 * event type into the header parameter (lpid not necessary, it's grabbed from
 * sender) */
36 37 38
void resource_lp_get(
        msg_header *header,
        uint64_t req, 
39
        int block_on_unavail,
40 41 42
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
43 44 45
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
46 47
        tw_lp *sender);
/* no callback for frees thus far */
48
void resource_lp_free(uint64_t req, tw_lp *sender);
49 50 51
void resource_lp_reserve(
        msg_header *header, 
        uint64_t req,
52
        int block_on_unavail,
53 54 55
        int msg_size,
        int msg_header_offset,
        int msg_callback_offset,
56 57 58
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
59 60 61 62 63
        tw_lp *sender);
void resource_lp_get_reserved(
        msg_header *header,
        uint64_t req,
        resource_token_t tok,
64
        int block_on_unavail,
65 66 67
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
68 69 70
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
        tw_lp *sender);
void resource_lp_free_reserved(
        uint64_t req,
        resource_token_t tok,
        tw_lp *sender);

/* rc functions - thankfully, they only use codes-local-latency, so no need 
 * to pass in any arguments */
void resource_lp_get_rc(tw_lp *sender);
void resource_lp_free_rc(tw_lp *sender);
void resource_lp_reserve_rc(tw_lp *sender);
void resource_lp_get_reserved_rc(tw_lp *sender);
void resource_lp_free_reserved_rc(tw_lp *sender);

#endif /* end of include guard: RESOURCE_LP_H */

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ts=8 sts=4 sw=4 expandtab
 */