aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/octeontx2/af/rvu_validation.h
blob: 9dc8252d99864be9f55d06731c77a5a9bf22213f (plain)
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
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: GPL-2.0
/* Marvell OcteonTx2 RVU Admin Function driver
 *
 * Copyright (C) 2018 Marvell International Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef RVU_VALIDATION_H
#define RVU_VALIDATION_H

struct rvu;
struct rvu_quotas;

struct rvu_quota {
	struct kobj_attribute	sysfs;
	/* Device to scope logs to */
	struct device		*dev;
	/* Kobject of the sysfs file */
	struct kobject		*parent;
	/* Pointer to base structure */
	struct rvu_quotas	*base;
	/* Argument passed to the quota_ops when this quota is modified */
	void			*ops_arg;
	/* Value of the quota */
	int			val;
};

struct rvu_quota_ops {
	/*
	 * Called before sysfs store(). store() will proceed if returns 0.
	 * It is called with struct rvu_quotas::lock taken.
	 */
	int (*pre_store)(void *arg, struct rvu_quota *quota, int new_val);
	/** called after sysfs store(). */
	void (*post_store)(void *arg, struct rvu_quota *quota, int old_val);
};

struct rvu_quotas {
	struct rvu_quota_ops	ops;
	struct mutex		*lock; /* lock taken for each sysfs operation */
	u32			cnt; /* number of elements in arr */
	u32			max; /* maximum value for a single quota */
	u64			max_sum; /* maximum sum of all quotas */
	struct rvu_quota	a[0]; /* array of quota assignments */
};

struct rvu_limits {
	struct rvu_quotas	*sso;
	struct rvu_quotas	*ssow;
	struct rvu_quotas	*tim;
	struct rvu_quotas	*cpt;
	struct rvu_quotas	*npa;
	struct rvu_quotas	*nix;
	struct rvu_quotas	*smq;
	struct rvu_quotas	*tl4;
	struct rvu_quotas	*tl3;
	struct rvu_quotas	*tl2;
};

int rvu_policy_init(struct rvu *rvu);
void rvu_policy_destroy(struct rvu *rvu);
int rvu_check_rsrc_policy(struct rvu *rvu,
			  struct rsrc_attach *req, u16 pcifunc);
int rvu_check_txsch_policy(struct rvu *rvu, struct nix_txsch_alloc_req *req,
			   u16 pcifunc);

int rvu_mbox_handler_free_rsrc_cnt(struct rvu *rvu, struct msg_req *req,
				   struct free_rsrcs_rsp *rsp);
#endif /* RVU_VALIDATION_H */