blob: e819a09337ee3e489d42c8073d115139df65a7f2 [file] [log] [blame]
Thomas Gleixner04672fe2019-05-29 07:12:42 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -08002/*
3 * Linux WiMAX
4 * Internal API for kernel space WiMAX stack
5 *
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -08006 * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -08009 * This header file is for declarations and definitions internal to
10 * the WiMAX stack. For public APIs and documentation, see
11 * include/net/wimax.h and include/linux/wimax.h.
12 */
13
14#ifndef __WIMAX_INTERNAL_H__
15#define __WIMAX_INTERNAL_H__
16#ifdef __KERNEL__
17
Fabian Frederick28b7dea2014-10-07 22:12:03 +020018#ifdef pr_fmt
19#undef pr_fmt
20#endif
21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080024#include <linux/device.h>
25#include <net/wimax.h>
26
27
28/*
29 * Decide if a (locked) device is ready for use
30 *
31 * Before using the device structure, it must be locked
32 * (wimax_dev->mutex). As well, most operations need to call this
33 * function to check if the state is the right one.
34 *
35 * An error value will be returned if the state is not the right
36 * one. In that case, the caller should not attempt to use the device
37 * and just unlock it.
38 */
39static inline __must_check
40int wimax_dev_is_ready(struct wimax_dev *wimax_dev)
41{
42 if (wimax_dev->state == __WIMAX_ST_NULL)
43 return -EINVAL; /* Device is not even registered! */
44 if (wimax_dev->state == WIMAX_ST_DOWN)
45 return -ENOMEDIUM;
46 if (wimax_dev->state == __WIMAX_ST_QUIESCING)
47 return -ESHUTDOWN;
48 return 0;
49}
50
51
52static inline
53void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
54{
55 wimax_dev->state = state;
56}
Joe Perchesc1b12032013-10-18 13:48:25 -070057void __wimax_state_change(struct wimax_dev *, enum wimax_st);
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080058
59#ifdef CONFIG_DEBUG_FS
Joe Perchesc1b12032013-10-18 13:48:25 -070060int wimax_debugfs_add(struct wimax_dev *);
61void wimax_debugfs_rm(struct wimax_dev *);
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080062#else
63static inline int wimax_debugfs_add(struct wimax_dev *wimax_dev)
64{
65 return 0;
66}
67static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
68#endif
69
Joe Perchesc1b12032013-10-18 13:48:25 -070070void wimax_id_table_add(struct wimax_dev *);
71struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int);
72void wimax_id_table_rm(struct wimax_dev *);
73void wimax_id_table_release(void);
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080074
Joe Perchesc1b12032013-10-18 13:48:25 -070075int wimax_rfkill_add(struct wimax_dev *);
76void wimax_rfkill_rm(struct wimax_dev *);
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080077
Johannes Bergb61a5ee2013-11-14 17:14:42 +010078/* generic netlink */
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080079extern struct genl_family wimax_gnl_family;
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080080
Johannes Bergb61a5ee2013-11-14 17:14:42 +010081/* ops */
82int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);
83int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info);
84int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info);
85int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info);
86
Inaky Perez-Gonzalez60fa9ca2008-12-20 16:57:34 -080087#endif /* #ifdef __KERNEL__ */
88#endif /* #ifndef __WIMAX_INTERNAL_H__ */