0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __IEEE802154_I_H
0012 #define __IEEE802154_I_H
0013
0014 #include <linux/interrupt.h>
0015 #include <linux/mutex.h>
0016 #include <linux/hrtimer.h>
0017 #include <net/cfg802154.h>
0018 #include <net/mac802154.h>
0019 #include <net/nl802154.h>
0020 #include <net/ieee802154_netdev.h>
0021
0022 #include "llsec.h"
0023
0024
0025 struct ieee802154_local {
0026 struct ieee802154_hw hw;
0027 const struct ieee802154_ops *ops;
0028
0029
0030 struct wpan_phy *phy;
0031
0032 int open_count;
0033
0034
0035
0036
0037
0038
0039
0040
0041 struct list_head interfaces;
0042 struct mutex iflist_mtx;
0043
0044
0045
0046
0047 struct workqueue_struct *workqueue;
0048
0049 struct hrtimer ifs_timer;
0050
0051 bool started;
0052 bool suspended;
0053
0054 struct tasklet_struct tasklet;
0055 struct sk_buff_head skb_queue;
0056
0057 struct sk_buff *tx_skb;
0058 struct work_struct tx_work;
0059
0060 int tx_result;
0061 };
0062
0063 enum {
0064 IEEE802154_RX_MSG = 1,
0065 };
0066
0067 enum ieee802154_sdata_state_bits {
0068 SDATA_STATE_RUNNING,
0069 };
0070
0071
0072
0073
0074
0075
0076
0077 struct ieee802154_sub_if_data {
0078 struct list_head list;
0079
0080 struct wpan_dev wpan_dev;
0081
0082 struct ieee802154_local *local;
0083 struct net_device *dev;
0084
0085 unsigned long state;
0086 char name[IFNAMSIZ];
0087
0088
0089
0090
0091 struct mutex sec_mtx;
0092
0093 struct mac802154_llsec sec;
0094 };
0095
0096
0097 extern const void *const mac802154_wpan_phy_privid;
0098
0099 static inline struct ieee802154_local *
0100 hw_to_local(struct ieee802154_hw *hw)
0101 {
0102 return container_of(hw, struct ieee802154_local, hw);
0103 }
0104
0105 static inline struct ieee802154_sub_if_data *
0106 IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
0107 {
0108 return netdev_priv(dev);
0109 }
0110
0111 static inline struct ieee802154_sub_if_data *
0112 IEEE802154_WPAN_DEV_TO_SUB_IF(struct wpan_dev *wpan_dev)
0113 {
0114 return container_of(wpan_dev, struct ieee802154_sub_if_data, wpan_dev);
0115 }
0116
0117 static inline bool
0118 ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
0119 {
0120 return test_bit(SDATA_STATE_RUNNING, &sdata->state);
0121 }
0122
0123 extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
0124
0125 void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
0126 void ieee802154_xmit_worker(struct work_struct *work);
0127 netdev_tx_t
0128 ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
0129 netdev_tx_t
0130 ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
0131 enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
0132
0133
0134 void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
0135
0136 int mac802154_get_params(struct net_device *dev,
0137 struct ieee802154_llsec_params *params);
0138 int mac802154_set_params(struct net_device *dev,
0139 const struct ieee802154_llsec_params *params,
0140 int changed);
0141
0142 int mac802154_add_key(struct net_device *dev,
0143 const struct ieee802154_llsec_key_id *id,
0144 const struct ieee802154_llsec_key *key);
0145 int mac802154_del_key(struct net_device *dev,
0146 const struct ieee802154_llsec_key_id *id);
0147
0148 int mac802154_add_dev(struct net_device *dev,
0149 const struct ieee802154_llsec_device *llsec_dev);
0150 int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
0151
0152 int mac802154_add_devkey(struct net_device *dev,
0153 __le64 device_addr,
0154 const struct ieee802154_llsec_device_key *key);
0155 int mac802154_del_devkey(struct net_device *dev,
0156 __le64 device_addr,
0157 const struct ieee802154_llsec_device_key *key);
0158
0159 int mac802154_add_seclevel(struct net_device *dev,
0160 const struct ieee802154_llsec_seclevel *sl);
0161 int mac802154_del_seclevel(struct net_device *dev,
0162 const struct ieee802154_llsec_seclevel *sl);
0163
0164 void mac802154_lock_table(struct net_device *dev);
0165 void mac802154_get_table(struct net_device *dev,
0166 struct ieee802154_llsec_table **t);
0167 void mac802154_unlock_table(struct net_device *dev);
0168
0169 int mac802154_wpan_update_llsec(struct net_device *dev);
0170
0171
0172 int ieee802154_iface_init(void);
0173 void ieee802154_iface_exit(void);
0174 void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
0175 struct net_device *
0176 ieee802154_if_add(struct ieee802154_local *local, const char *name,
0177 unsigned char name_assign_type, enum nl802154_iftype type,
0178 __le64 extended_addr);
0179 void ieee802154_remove_interfaces(struct ieee802154_local *local);
0180 void ieee802154_stop_device(struct ieee802154_local *local);
0181
0182 #endif