Kyle Swenson | 7900a3c | 2021-08-12 14:34:44 -0600 | [diff] [blame] | 1 | /* |
| 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]" |
| 27 | struct 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 | |
| 41 | struct device *get_lowest_priority_device(struct class *class); |
| 42 | struct device *relink_priority_list(struct class *class); |
| 43 | struct device *get_highest_priority_device(struct class *class); |
| 44 | int match_port_priority(struct device *dev, const void *data); |
| 45 | int match_port_id(struct device *dev, const void *data); |
| 46 | int compare_port_priority(struct pse_port_device *p1, struct pse_port_device *p2); |
| 47 | struct device *get_lowest_priority_device(struct class *class); |
| 48 | struct device *get_highest_priority_device(struct class *class); |
| 49 | struct device *get_next_lowest_priority_device(struct class *class, struct device *dev); |
| 50 | void disconnect_port(struct device *dev); |
| 51 | |
| 52 | int calc_power_used(struct class *class, struct device *start); |
| 53 | int allocate_power(struct pse_port_device *port); |
| 54 | void pse_event(struct device *dev); |
| 55 | void redistribute_power(struct class *class); |
| 56 | |
| 57 | #endif |