^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Linux WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Internal API for kernel space WiMAX stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This header file is for declarations and definitions internal to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * the WiMAX stack. For public APIs and documentation, see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * include/net/wimax.h and include/linux/wimax.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #ifndef __WIMAX_INTERNAL_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define __WIMAX_INTERNAL_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifdef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #undef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <net/wimax.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Decide if a (locked) device is ready for use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Before using the device structure, it must be locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * (wimax_dev->mutex). As well, most operations need to call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * function to check if the state is the right one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * An error value will be returned if the state is not the right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * one. In that case, the caller should not attempt to use the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * and just unlock it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static inline __must_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int wimax_dev_is_ready(struct wimax_dev *wimax_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (wimax_dev->state == __WIMAX_ST_NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return -EINVAL; /* Device is not even registered! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (wimax_dev->state == WIMAX_ST_DOWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return -ENOMEDIUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (wimax_dev->state == __WIMAX_ST_QUIESCING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return -ESHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) wimax_dev->state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void __wimax_state_change(struct wimax_dev *, enum wimax_st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void wimax_debugfs_add(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void wimax_debugfs_rm(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static inline void wimax_debugfs_add(struct wimax_dev *wimax_dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) void wimax_id_table_add(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void wimax_id_table_rm(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) void wimax_id_table_release(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int wimax_rfkill_add(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void wimax_rfkill_rm(struct wimax_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* generic netlink */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) extern struct genl_family wimax_gnl_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif /* #ifdef __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif /* #ifndef __WIMAX_INTERNAL_H__ */