blob: 1b92582e6a2ca0a89e32cdb26c09f26990adf8a7 [file] [log] [blame]
Kyle Swenson7900a3c2021-08-12 14:34:44 -06001/*
2 * ./kernel_modules/pse/pse-class.h
3 *
4 *
5 * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com>
6 * Kyle Swenson <kswenson@cradlepoint.com>
7 *
8 * Copyright 2017 Cradlepoint Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20
21#ifndef __PSE_CLASS_H__
22#define __PSE_CLASS_H__
23
24#define PSE_CLASS_NAME_STR "pse"
25#define PSE_MAX_PORTS 64
26#define PSE_VERSION_STR "PSE Class Version v1.0.1 [01 Aug 2019]"
27struct pse_data {
28 struct class cls;
29 struct workqueue_struct *wq;
30 struct work_struct offload;
31 int power_used;
32 int power_budget;
33 uint8_t port_priorities[PSE_MAX_PORTS]; /* This is to store priorities for when ports don't exist yet */
34 uint8_t enabled;
35 struct mutex pse_lock;
36};
37
38
39#define get_pse_data(c) container_of(c, struct pse_data, cls)
40
41struct device *get_lowest_priority_device(struct class *class);
42struct device *relink_priority_list(struct class *class);
43struct device *get_highest_priority_device(struct class *class);
44int match_port_priority(struct device *dev, const void *data);
45int match_port_id(struct device *dev, const void *data);
46int compare_port_priority(struct pse_port_device *p1, struct pse_port_device *p2);
47struct device *get_lowest_priority_device(struct class *class);
48struct device *get_highest_priority_device(struct class *class);
49struct device *get_next_lowest_priority_device(struct class *class, struct device *dev);
50void disconnect_port(struct device *dev);
51
52int calc_power_used(struct class *class, struct device *start);
53int allocate_power(struct pse_port_device *port);
54void pse_event(struct device *dev);
55void redistribute_power(struct class *class);
56
57#endif