-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathhoma_grant.h
61 lines (54 loc) · 2.29 KB
/
homa_grant.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* SPDX-License-Identifier: BSD-2-Clause */
/* This file contains definitions that related to generating grants. */
#ifndef _HOMA_GRANT_H
#define _HOMA_GRANT_H
int homa_grantable_lock_slow(struct homa *homa, int recalc);
void homa_grant_add_rpc(struct homa_rpc *rpc);
void homa_grant_check_rpc(struct homa_rpc *rpc);
void homa_grant_find_oldest(struct homa *homa);
void homa_grant_free_rpc(struct homa_rpc *rpc);
void homa_grant_log_tt(struct homa *homa);
int homa_grant_outranks(struct homa_rpc *rpc1,
struct homa_rpc *rpc2);
int homa_grant_pick_rpcs(struct homa *homa, struct homa_rpc **rpcs,
int max_rpcs);
void homa_grant_pkt(struct sk_buff *skb, struct homa_rpc *rpc);
void homa_grant_recalc(struct homa *homa, int locked);
void homa_grant_remove_rpc(struct homa_rpc *rpc);
int homa_grant_send(struct homa_rpc *rpc, struct homa *homa);
int homa_grant_update_incoming(struct homa_rpc *rpc,
struct homa *homa);
/**
* homa_grantable_lock() - Acquire the grantable lock. If the lock
* isn't immediately available, record stats on the waiting time.
* @homa: Overall data about the Homa protocol implementation.
* @recalc: Nonzero means the caller is homa_grant_recalc; if another thread
* is already recalculating, can return without waiting for the lock.
* Return: Nonzero means this thread now owns the grantable lock. Zero
* means the lock was not acquired and there is no need for this
* thread to do the work of homa_grant_recalc because some other
* thread started a fresh calculation after this method was invoked.
*/
static inline int homa_grantable_lock(struct homa *homa, int recalc)
__acquires(&homa->grantable_lock)
{
int result;
if (spin_trylock_bh(&homa->grantable_lock))
result = 1;
else
result = homa_grantable_lock_slow(homa, recalc);
homa->grantable_lock_time = sched_clock();
return result;
}
/**
* homa_grantable_unlock() - Release the grantable lock.
* @homa: Overall data about the Homa protocol implementation.
*/
static inline void homa_grantable_unlock(struct homa *homa)
__releases(&homa->grantable_lock)
{
INC_METRIC(grantable_lock_ns, sched_clock() -
homa->grantable_lock_time);
spin_unlock_bh(&homa->grantable_lock);
}
#endif /* _HOMA_GRANT_H */