Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2007-2012 Siemens AG
0004  *
0005  * Written by:
0006  * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
0007  * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
0008  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
0009  * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
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 /* mac802154 device private data */
0025 struct ieee802154_local {
0026     struct ieee802154_hw hw;
0027     const struct ieee802154_ops *ops;
0028 
0029     /* ieee802154 phy */
0030     struct wpan_phy *phy;
0031 
0032     int open_count;
0033 
0034     /* As in mac80211 slaves list is modified:
0035      * 1) under the RTNL
0036      * 2) protected by slaves_mtx;
0037      * 3) in an RCU manner
0038      *
0039      * So atomic readers can use any of this protection methods.
0040      */
0041     struct list_head    interfaces;
0042     struct mutex        iflist_mtx;
0043 
0044     /* This one is used for scanning and other jobs not to be interfered
0045      * with serial driver.
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     /* A negative Linux error code or a null/positive MLME error status */
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 /* Slave interface definition.
0072  *
0073  * Slaves represent typical network interfaces available from userspace.
0074  * Each ieee802154 device/transceiver may have several slaves and able
0075  * to be associated with several networks at the same time.
0076  */
0077 struct ieee802154_sub_if_data {
0078     struct list_head list; /* the ieee802154_priv->slaves 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     /* protects sec from concurrent access by netlink. access by
0089      * encrypt/decrypt/header_create safe without additional protection.
0090      */
0091     struct mutex sec_mtx;
0092 
0093     struct mac802154_llsec sec;
0094 };
0095 
0096 /* utility functions/constants */
0097 extern const void *const mac802154_wpan_phy_privid; /*  for 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 /* MIB callbacks */
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 /* interface handling */
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 /* __IEEE802154_I_H */