| /* |
| * ./kernel_modules/pse/pse-class.h |
| * |
| * |
| * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com> |
| * Kyle Swenson <kswenson@cradlepoint.com> |
| * |
| * Copyright 2017 Cradlepoint Technology, Inc. |
| * |
| * 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. |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| */ |
| |
| #ifndef __PSE_CLASS_H__ |
| #define __PSE_CLASS_H__ |
| |
| #define PSE_CLASS_NAME_STR "pse" |
| #define PSE_MAX_PORTS 64 |
| #define PSE_VERSION_STR "PSE Class Version v1.0.1 [01 Aug 2019]" |
| struct pse_data { |
| struct class cls; |
| struct workqueue_struct *wq; |
| struct work_struct offload; |
| int power_used; |
| int power_budget; |
| uint8_t port_priorities[PSE_MAX_PORTS]; /* This is to store priorities for when ports don't exist yet */ |
| uint8_t enabled; |
| struct mutex pse_lock; |
| }; |
| |
| |
| #define get_pse_data(c) container_of(c, struct pse_data, cls) |
| |
| struct device *get_lowest_priority_device(struct class *class); |
| struct device *relink_priority_list(struct class *class); |
| struct device *get_highest_priority_device(struct class *class); |
| int match_port_priority(struct device *dev, const void *data); |
| int match_port_id(struct device *dev, const void *data); |
| int compare_port_priority(struct pse_port_device *p1, struct pse_port_device *p2); |
| struct device *get_lowest_priority_device(struct class *class); |
| struct device *get_highest_priority_device(struct class *class); |
| struct device *get_next_lowest_priority_device(struct class *class, struct device *dev); |
| void disconnect_port(struct device *dev); |
| |
| int calc_power_used(struct class *class, struct device *start); |
| int allocate_power(struct pse_port_device *port); |
| void pse_event(struct device *dev); |
| void redistribute_power(struct class *class); |
| |
| #endif |