Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  * Copyright (C) 2007-2012 Siemens AG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Written by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef __IEEE802154_I_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define __IEEE802154_I_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/hrtimer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/cfg802154.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <net/mac802154.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/nl802154.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <net/ieee802154_netdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "llsec.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* mac802154 device private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct ieee802154_local {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct ieee802154_hw hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	const struct ieee802154_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	/* ieee802154 phy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct wpan_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int open_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/* As in mac80211 slaves list is modified:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	 * 1) under the RTNL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * 2) protected by slaves_mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 * 3) in an RCU manner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	 * So atomic readers can use any of this protection methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct list_head	interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct mutex		iflist_mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	/* This one is used for scanning and other jobs not to be interfered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 * with serial driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct workqueue_struct	*workqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct hrtimer ifs_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	bool started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	bool suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	struct tasklet_struct tasklet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct sk_buff_head skb_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct sk_buff *tx_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct work_struct tx_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	IEEE802154_RX_MSG        = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) enum ieee802154_sdata_state_bits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	SDATA_STATE_RUNNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /* Slave interface definition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * Slaves represent typical network interfaces available from userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * Each ieee802154 device/transceiver may have several slaves and able
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * to be associated with several networks at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) struct ieee802154_sub_if_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct list_head list; /* the ieee802154_priv->slaves list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct wpan_dev wpan_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct ieee802154_local *local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	char name[IFNAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* protects sec from concurrent access by netlink. access by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * encrypt/decrypt/header_create safe without additional protection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct mutex sec_mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct mac802154_llsec sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) /* utility functions/constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) extern const void *const mac802154_wpan_phy_privid; /*  for wpan_phy privid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static inline struct ieee802154_local *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) hw_to_local(struct ieee802154_hw *hw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	return container_of(hw, struct ieee802154_local, hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static inline struct ieee802154_sub_if_data *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static inline struct ieee802154_sub_if_data *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) IEEE802154_WPAN_DEV_TO_SUB_IF(struct wpan_dev *wpan_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return container_of(wpan_dev, struct ieee802154_sub_if_data, wpan_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void ieee802154_xmit_worker(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) netdev_tx_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) netdev_tx_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* MIB callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int mac802154_get_params(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			 struct ieee802154_llsec_params *params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int mac802154_set_params(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			 const struct ieee802154_llsec_params *params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			 int changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int mac802154_add_key(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		      const struct ieee802154_llsec_key_id *id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		      const struct ieee802154_llsec_key *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) int mac802154_del_key(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		      const struct ieee802154_llsec_key_id *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int mac802154_add_dev(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		      const struct ieee802154_llsec_device *llsec_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int mac802154_add_devkey(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			 __le64 device_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			 const struct ieee802154_llsec_device_key *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int mac802154_del_devkey(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			 __le64 device_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			 const struct ieee802154_llsec_device_key *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int mac802154_add_seclevel(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			   const struct ieee802154_llsec_seclevel *sl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int mac802154_del_seclevel(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			   const struct ieee802154_llsec_seclevel *sl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) void mac802154_lock_table(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void mac802154_get_table(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			 struct ieee802154_llsec_table **t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void mac802154_unlock_table(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int mac802154_wpan_update_llsec(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* interface handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int ieee802154_iface_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) void ieee802154_iface_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct net_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ieee802154_if_add(struct ieee802154_local *local, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		  unsigned char name_assign_type, enum nl802154_iftype type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		  __le64 extended_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) void ieee802154_remove_interfaces(struct ieee802154_local *local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) void ieee802154_stop_device(struct ieee802154_local *local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #endif /* __IEEE802154_I_H */