0001
0002
0003
0004
0005
0006
0007 #ifndef __iwl_op_mode_h__
0008 #define __iwl_op_mode_h__
0009
0010 #include <linux/netdevice.h>
0011 #include <linux/debugfs.h>
0012 #include "iwl-dbg-tlv.h"
0013
0014 struct iwl_op_mode;
0015 struct iwl_trans;
0016 struct sk_buff;
0017 struct iwl_device_cmd;
0018 struct iwl_rx_cmd_buffer;
0019 struct iwl_fw;
0020 struct iwl_cfg;
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 struct iwl_op_mode_ops {
0090 struct iwl_op_mode *(*start)(struct iwl_trans *trans,
0091 const struct iwl_cfg *cfg,
0092 const struct iwl_fw *fw,
0093 struct dentry *dbgfs_dir);
0094 void (*stop)(struct iwl_op_mode *op_mode);
0095 void (*rx)(struct iwl_op_mode *op_mode, struct napi_struct *napi,
0096 struct iwl_rx_cmd_buffer *rxb);
0097 void (*rx_rss)(struct iwl_op_mode *op_mode, struct napi_struct *napi,
0098 struct iwl_rx_cmd_buffer *rxb, unsigned int queue);
0099 void (*async_cb)(struct iwl_op_mode *op_mode,
0100 const struct iwl_device_cmd *cmd);
0101 void (*queue_full)(struct iwl_op_mode *op_mode, int queue);
0102 void (*queue_not_full)(struct iwl_op_mode *op_mode, int queue);
0103 bool (*hw_rf_kill)(struct iwl_op_mode *op_mode, bool state);
0104 void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb);
0105 void (*nic_error)(struct iwl_op_mode *op_mode, bool sync);
0106 void (*cmd_queue_full)(struct iwl_op_mode *op_mode);
0107 void (*nic_config)(struct iwl_op_mode *op_mode);
0108 void (*wimax_active)(struct iwl_op_mode *op_mode);
0109 void (*time_point)(struct iwl_op_mode *op_mode,
0110 enum iwl_fw_ini_time_point tp_id,
0111 union iwl_dbg_tlv_tp_data *tp_data);
0112 };
0113
0114 int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops);
0115 void iwl_opmode_deregister(const char *name);
0116
0117
0118
0119
0120
0121
0122
0123 struct iwl_op_mode {
0124 const struct iwl_op_mode_ops *ops;
0125
0126 char op_mode_specific[] __aligned(sizeof(void *));
0127 };
0128
0129 static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode)
0130 {
0131 might_sleep();
0132 op_mode->ops->stop(op_mode);
0133 }
0134
0135 static inline void iwl_op_mode_rx(struct iwl_op_mode *op_mode,
0136 struct napi_struct *napi,
0137 struct iwl_rx_cmd_buffer *rxb)
0138 {
0139 return op_mode->ops->rx(op_mode, napi, rxb);
0140 }
0141
0142 static inline void iwl_op_mode_rx_rss(struct iwl_op_mode *op_mode,
0143 struct napi_struct *napi,
0144 struct iwl_rx_cmd_buffer *rxb,
0145 unsigned int queue)
0146 {
0147 op_mode->ops->rx_rss(op_mode, napi, rxb, queue);
0148 }
0149
0150 static inline void iwl_op_mode_async_cb(struct iwl_op_mode *op_mode,
0151 const struct iwl_device_cmd *cmd)
0152 {
0153 if (op_mode->ops->async_cb)
0154 op_mode->ops->async_cb(op_mode, cmd);
0155 }
0156
0157 static inline void iwl_op_mode_queue_full(struct iwl_op_mode *op_mode,
0158 int queue)
0159 {
0160 op_mode->ops->queue_full(op_mode, queue);
0161 }
0162
0163 static inline void iwl_op_mode_queue_not_full(struct iwl_op_mode *op_mode,
0164 int queue)
0165 {
0166 op_mode->ops->queue_not_full(op_mode, queue);
0167 }
0168
0169 static inline bool __must_check
0170 iwl_op_mode_hw_rf_kill(struct iwl_op_mode *op_mode, bool state)
0171 {
0172 might_sleep();
0173 return op_mode->ops->hw_rf_kill(op_mode, state);
0174 }
0175
0176 static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode,
0177 struct sk_buff *skb)
0178 {
0179 if (WARN_ON_ONCE(!op_mode))
0180 return;
0181 op_mode->ops->free_skb(op_mode, skb);
0182 }
0183
0184 static inline void iwl_op_mode_nic_error(struct iwl_op_mode *op_mode, bool sync)
0185 {
0186 op_mode->ops->nic_error(op_mode, sync);
0187 }
0188
0189 static inline void iwl_op_mode_cmd_queue_full(struct iwl_op_mode *op_mode)
0190 {
0191 op_mode->ops->cmd_queue_full(op_mode);
0192 }
0193
0194 static inline void iwl_op_mode_nic_config(struct iwl_op_mode *op_mode)
0195 {
0196 might_sleep();
0197 op_mode->ops->nic_config(op_mode);
0198 }
0199
0200 static inline void iwl_op_mode_wimax_active(struct iwl_op_mode *op_mode)
0201 {
0202 might_sleep();
0203 op_mode->ops->wimax_active(op_mode);
0204 }
0205
0206 static inline void iwl_op_mode_time_point(struct iwl_op_mode *op_mode,
0207 enum iwl_fw_ini_time_point tp_id,
0208 union iwl_dbg_tlv_tp_data *tp_data)
0209 {
0210 if (!op_mode || !op_mode->ops || !op_mode->ops->time_point)
0211 return;
0212 op_mode->ops->time_point(op_mode, tp_id, tp_data);
0213 }
0214
0215 #endif