11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2f0166e5eSDmitry Eremin-Solenikov /* 3f0166e5eSDmitry Eremin-Solenikov * An interface between IEEE802.15.4 device and rest of the kernel. 4f0166e5eSDmitry Eremin-Solenikov * 574a02fcfSalex.bluesman.smirnov@gmail.com * Copyright (C) 2007-2012 Siemens AG 6f0166e5eSDmitry Eremin-Solenikov * 7f0166e5eSDmitry Eremin-Solenikov * Written by: 8f0166e5eSDmitry Eremin-Solenikov * Pavel Smolenskiy <pavel.smolenskiy@gmail.com> 9f0166e5eSDmitry Eremin-Solenikov * Maxim Gorbachyov <maxim.gorbachev@siemens.com> 10f0166e5eSDmitry Eremin-Solenikov * Maxim Osipov <maxim.osipov@siemens.com> 11f0166e5eSDmitry Eremin-Solenikov * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 1274a02fcfSalex.bluesman.smirnov@gmail.com * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> 13f0166e5eSDmitry Eremin-Solenikov */ 14f0166e5eSDmitry Eremin-Solenikov 15f0166e5eSDmitry Eremin-Solenikov #ifndef IEEE802154_NETDEVICE_H 16f0166e5eSDmitry Eremin-Solenikov #define IEEE802154_NETDEVICE_H 17f0166e5eSDmitry Eremin-Solenikov 1894160108SHaimin Zhang #define IEEE802154_REQUIRED_SIZE(struct_type, member) \ 1994160108SHaimin Zhang (offsetof(typeof(struct_type), member) + \ 2094160108SHaimin Zhang sizeof(((typeof(struct_type) *)(NULL))->member)) 2194160108SHaimin Zhang 2294160108SHaimin Zhang #define IEEE802154_ADDR_OFFSET \ 2394160108SHaimin Zhang offsetof(typeof(struct sockaddr_ieee802154), addr) 2494160108SHaimin Zhang 2594160108SHaimin Zhang #define IEEE802154_MIN_NAMELEN (IEEE802154_ADDR_OFFSET + \ 2694160108SHaimin Zhang IEEE802154_REQUIRED_SIZE(struct ieee802154_addr_sa, addr_type)) 2794160108SHaimin Zhang 2894160108SHaimin Zhang #define IEEE802154_NAMELEN_SHORT (IEEE802154_ADDR_OFFSET + \ 2994160108SHaimin Zhang IEEE802154_REQUIRED_SIZE(struct ieee802154_addr_sa, short_addr)) 3094160108SHaimin Zhang 3194160108SHaimin Zhang #define IEEE802154_NAMELEN_LONG (IEEE802154_ADDR_OFFSET + \ 3294160108SHaimin Zhang IEEE802154_REQUIRED_SIZE(struct ieee802154_addr_sa, hwaddr)) 3394160108SHaimin Zhang 341cd829c8Salex.bluesman.smirnov@gmail.com #include <net/af_ieee802154.h> 3594b4f6c2SPhoebe Buckheister #include <linux/netdevice.h> 3694b4f6c2SPhoebe Buckheister #include <linux/skbuff.h> 374ca24acaSAlexander Aring #include <linux/ieee802154.h> 3894b4f6c2SPhoebe Buckheister 397fe9a388SAlexander Aring #include <net/cfg802154.h> 407fe9a388SAlexander Aring 4194b4f6c2SPhoebe Buckheister struct ieee802154_sechdr { 4294b4f6c2SPhoebe Buckheister #if defined(__LITTLE_ENDIAN_BITFIELD) 4394b4f6c2SPhoebe Buckheister u8 level:3, 4494b4f6c2SPhoebe Buckheister key_id_mode:2, 4594b4f6c2SPhoebe Buckheister reserved:3; 4694b4f6c2SPhoebe Buckheister #elif defined(__BIG_ENDIAN_BITFIELD) 4794b4f6c2SPhoebe Buckheister u8 reserved:3, 4894b4f6c2SPhoebe Buckheister key_id_mode:2, 4994b4f6c2SPhoebe Buckheister level:3; 5094b4f6c2SPhoebe Buckheister #else 5194b4f6c2SPhoebe Buckheister #error "Please fix <asm/byteorder.h>" 5294b4f6c2SPhoebe Buckheister #endif 5394b4f6c2SPhoebe Buckheister u8 key_id; 5494b4f6c2SPhoebe Buckheister __le32 frame_counter; 5594b4f6c2SPhoebe Buckheister union { 5694b4f6c2SPhoebe Buckheister __le32 short_src; 5794b4f6c2SPhoebe Buckheister __le64 extended_src; 5894b4f6c2SPhoebe Buckheister }; 5994b4f6c2SPhoebe Buckheister }; 601cd829c8Salex.bluesman.smirnov@gmail.com 6194b4f6c2SPhoebe Buckheister struct ieee802154_hdr_fc { 6294b4f6c2SPhoebe Buckheister #if defined(__LITTLE_ENDIAN_BITFIELD) 6394b4f6c2SPhoebe Buckheister u16 type:3, 6494b4f6c2SPhoebe Buckheister security_enabled:1, 6594b4f6c2SPhoebe Buckheister frame_pending:1, 6694b4f6c2SPhoebe Buckheister ack_request:1, 6794b4f6c2SPhoebe Buckheister intra_pan:1, 6894b4f6c2SPhoebe Buckheister reserved:3, 6994b4f6c2SPhoebe Buckheister dest_addr_mode:2, 7094b4f6c2SPhoebe Buckheister version:2, 7194b4f6c2SPhoebe Buckheister source_addr_mode:2; 7294b4f6c2SPhoebe Buckheister #elif defined(__BIG_ENDIAN_BITFIELD) 7394b4f6c2SPhoebe Buckheister u16 reserved:1, 7494b4f6c2SPhoebe Buckheister intra_pan:1, 7594b4f6c2SPhoebe Buckheister ack_request:1, 7694b4f6c2SPhoebe Buckheister frame_pending:1, 7794b4f6c2SPhoebe Buckheister security_enabled:1, 7894b4f6c2SPhoebe Buckheister type:3, 7994b4f6c2SPhoebe Buckheister source_addr_mode:2, 8094b4f6c2SPhoebe Buckheister version:2, 8194b4f6c2SPhoebe Buckheister dest_addr_mode:2, 8294b4f6c2SPhoebe Buckheister reserved2:2; 8394b4f6c2SPhoebe Buckheister #else 8494b4f6c2SPhoebe Buckheister #error "Please fix <asm/byteorder.h>" 8594b4f6c2SPhoebe Buckheister #endif 8694b4f6c2SPhoebe Buckheister }; 8794b4f6c2SPhoebe Buckheister 8894b4f6c2SPhoebe Buckheister struct ieee802154_hdr { 8994b4f6c2SPhoebe Buckheister struct ieee802154_hdr_fc fc; 9094b4f6c2SPhoebe Buckheister u8 seq; 9194b4f6c2SPhoebe Buckheister struct ieee802154_addr source; 9294b4f6c2SPhoebe Buckheister struct ieee802154_addr dest; 9394b4f6c2SPhoebe Buckheister struct ieee802154_sechdr sec; 9494b4f6c2SPhoebe Buckheister }; 9594b4f6c2SPhoebe Buckheister 9694b4f6c2SPhoebe Buckheister /* pushes hdr onto the skb. fields of hdr->fc that can be calculated from 9794b4f6c2SPhoebe Buckheister * the contents of hdr will be, and the actual value of those bits in 9894b4f6c2SPhoebe Buckheister * hdr->fc will be ignored. this includes the INTRA_PAN bit and the frame 9994b4f6c2SPhoebe Buckheister * version, if SECEN is set. 10094b4f6c2SPhoebe Buckheister */ 101a1da67b8SAlexander Aring int ieee802154_hdr_push(struct sk_buff *skb, struct ieee802154_hdr *hdr); 10294b4f6c2SPhoebe Buckheister 10394b4f6c2SPhoebe Buckheister /* pulls the entire 802.15.4 header off of the skb, including the security 10494b4f6c2SPhoebe Buckheister * header, and performs pan id decompression 10594b4f6c2SPhoebe Buckheister */ 10694b4f6c2SPhoebe Buckheister int ieee802154_hdr_pull(struct sk_buff *skb, struct ieee802154_hdr *hdr); 10794b4f6c2SPhoebe Buckheister 10894b4f6c2SPhoebe Buckheister /* parses the frame control, sequence number of address fields in a given skb 10994b4f6c2SPhoebe Buckheister * and stores them into hdr, performing pan id decompression and length checks 11094b4f6c2SPhoebe Buckheister * to be suitable for use in header_ops.parse 11194b4f6c2SPhoebe Buckheister */ 11294b4f6c2SPhoebe Buckheister int ieee802154_hdr_peek_addrs(const struct sk_buff *skb, 11394b4f6c2SPhoebe Buckheister struct ieee802154_hdr *hdr); 11494b4f6c2SPhoebe Buckheister 115c3a6114fSPhoebe Buckheister /* parses the full 802.15.4 header a given skb and stores them into hdr, 116c3a6114fSPhoebe Buckheister * performing pan id decompression and length checks to be suitable for use in 117c3a6114fSPhoebe Buckheister * header_ops.parse 118c3a6114fSPhoebe Buckheister */ 119c3a6114fSPhoebe Buckheister int ieee802154_hdr_peek(const struct sk_buff *skb, struct ieee802154_hdr *hdr); 120c3a6114fSPhoebe Buckheister 121c3a6114fSPhoebe Buckheister int ieee802154_max_payload(const struct ieee802154_hdr *hdr); 122c3a6114fSPhoebe Buckheister 123c3a6114fSPhoebe Buckheister static inline int 124c3a6114fSPhoebe Buckheister ieee802154_sechdr_authtag_len(const struct ieee802154_sechdr *sec) 125c3a6114fSPhoebe Buckheister { 126c3a6114fSPhoebe Buckheister switch (sec->level) { 127c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_MIC32: 128c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_ENC_MIC32: 129c3a6114fSPhoebe Buckheister return 4; 130c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_MIC64: 131c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_ENC_MIC64: 132c3a6114fSPhoebe Buckheister return 8; 133c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_MIC128: 134c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_ENC_MIC128: 135c3a6114fSPhoebe Buckheister return 16; 136c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_NONE: 137c3a6114fSPhoebe Buckheister case IEEE802154_SCF_SECLEVEL_ENC: 138c3a6114fSPhoebe Buckheister default: 139c3a6114fSPhoebe Buckheister return 0; 140c3a6114fSPhoebe Buckheister } 141c3a6114fSPhoebe Buckheister } 142c3a6114fSPhoebe Buckheister 14394b4f6c2SPhoebe Buckheister static inline int ieee802154_hdr_length(struct sk_buff *skb) 14494b4f6c2SPhoebe Buckheister { 14594b4f6c2SPhoebe Buckheister struct ieee802154_hdr hdr; 14694b4f6c2SPhoebe Buckheister int len = ieee802154_hdr_pull(skb, &hdr); 14794b4f6c2SPhoebe Buckheister 14894b4f6c2SPhoebe Buckheister if (len > 0) 14994b4f6c2SPhoebe Buckheister skb_push(skb, len); 15094b4f6c2SPhoebe Buckheister 15194b4f6c2SPhoebe Buckheister return len; 15294b4f6c2SPhoebe Buckheister } 15394b4f6c2SPhoebe Buckheister 15446ef0eb3SPhoebe Buckheister static inline bool ieee802154_addr_equal(const struct ieee802154_addr *a1, 15546ef0eb3SPhoebe Buckheister const struct ieee802154_addr *a2) 15646ef0eb3SPhoebe Buckheister { 15746ef0eb3SPhoebe Buckheister if (a1->pan_id != a2->pan_id || a1->mode != a2->mode) 15846ef0eb3SPhoebe Buckheister return false; 15946ef0eb3SPhoebe Buckheister 16046ef0eb3SPhoebe Buckheister if ((a1->mode == IEEE802154_ADDR_LONG && 16146ef0eb3SPhoebe Buckheister a1->extended_addr != a2->extended_addr) || 16246ef0eb3SPhoebe Buckheister (a1->mode == IEEE802154_ADDR_SHORT && 16346ef0eb3SPhoebe Buckheister a1->short_addr != a2->short_addr)) 16446ef0eb3SPhoebe Buckheister return false; 16546ef0eb3SPhoebe Buckheister 16646ef0eb3SPhoebe Buckheister return true; 16746ef0eb3SPhoebe Buckheister } 16846ef0eb3SPhoebe Buckheister 16946ef0eb3SPhoebe Buckheister static inline __le64 ieee802154_devaddr_from_raw(const void *raw) 17046ef0eb3SPhoebe Buckheister { 17146ef0eb3SPhoebe Buckheister u64 temp; 17246ef0eb3SPhoebe Buckheister 17346ef0eb3SPhoebe Buckheister memcpy(&temp, raw, IEEE802154_ADDR_LEN); 17446ef0eb3SPhoebe Buckheister return (__force __le64)swab64(temp); 17546ef0eb3SPhoebe Buckheister } 17646ef0eb3SPhoebe Buckheister 17746ef0eb3SPhoebe Buckheister static inline void ieee802154_devaddr_to_raw(void *raw, __le64 addr) 17846ef0eb3SPhoebe Buckheister { 17946ef0eb3SPhoebe Buckheister u64 temp = swab64((__force u64)addr); 18046ef0eb3SPhoebe Buckheister 18146ef0eb3SPhoebe Buckheister memcpy(raw, &temp, IEEE802154_ADDR_LEN); 18246ef0eb3SPhoebe Buckheister } 18346ef0eb3SPhoebe Buckheister 18494160108SHaimin Zhang static inline int 18594160108SHaimin Zhang ieee802154_sockaddr_check_size(struct sockaddr_ieee802154 *daddr, int len) 18694160108SHaimin Zhang { 18794160108SHaimin Zhang struct ieee802154_addr_sa *sa; 188*30393181SAlexander Aring int ret = 0; 18994160108SHaimin Zhang 19094160108SHaimin Zhang sa = &daddr->addr; 19194160108SHaimin Zhang if (len < IEEE802154_MIN_NAMELEN) 19294160108SHaimin Zhang return -EINVAL; 19394160108SHaimin Zhang switch (sa->addr_type) { 194*30393181SAlexander Aring case IEEE802154_ADDR_NONE: 195*30393181SAlexander Aring break; 19694160108SHaimin Zhang case IEEE802154_ADDR_SHORT: 19794160108SHaimin Zhang if (len < IEEE802154_NAMELEN_SHORT) 198*30393181SAlexander Aring ret = -EINVAL; 19994160108SHaimin Zhang break; 20094160108SHaimin Zhang case IEEE802154_ADDR_LONG: 20194160108SHaimin Zhang if (len < IEEE802154_NAMELEN_LONG) 202*30393181SAlexander Aring ret = -EINVAL; 203*30393181SAlexander Aring break; 204*30393181SAlexander Aring default: 205*30393181SAlexander Aring ret = -EINVAL; 20694160108SHaimin Zhang break; 20794160108SHaimin Zhang } 208*30393181SAlexander Aring return ret; 20994160108SHaimin Zhang } 21094160108SHaimin Zhang 21146ef0eb3SPhoebe Buckheister static inline void ieee802154_addr_from_sa(struct ieee802154_addr *a, 21246ef0eb3SPhoebe Buckheister const struct ieee802154_addr_sa *sa) 21346ef0eb3SPhoebe Buckheister { 21446ef0eb3SPhoebe Buckheister a->mode = sa->addr_type; 21546ef0eb3SPhoebe Buckheister a->pan_id = cpu_to_le16(sa->pan_id); 21646ef0eb3SPhoebe Buckheister 21746ef0eb3SPhoebe Buckheister switch (a->mode) { 21846ef0eb3SPhoebe Buckheister case IEEE802154_ADDR_SHORT: 21946ef0eb3SPhoebe Buckheister a->short_addr = cpu_to_le16(sa->short_addr); 22046ef0eb3SPhoebe Buckheister break; 22146ef0eb3SPhoebe Buckheister case IEEE802154_ADDR_LONG: 22246ef0eb3SPhoebe Buckheister a->extended_addr = ieee802154_devaddr_from_raw(sa->hwaddr); 22346ef0eb3SPhoebe Buckheister break; 22446ef0eb3SPhoebe Buckheister } 22546ef0eb3SPhoebe Buckheister } 22646ef0eb3SPhoebe Buckheister 22746ef0eb3SPhoebe Buckheister static inline void ieee802154_addr_to_sa(struct ieee802154_addr_sa *sa, 22846ef0eb3SPhoebe Buckheister const struct ieee802154_addr *a) 22946ef0eb3SPhoebe Buckheister { 23046ef0eb3SPhoebe Buckheister sa->addr_type = a->mode; 23146ef0eb3SPhoebe Buckheister sa->pan_id = le16_to_cpu(a->pan_id); 23246ef0eb3SPhoebe Buckheister 23346ef0eb3SPhoebe Buckheister switch (a->mode) { 23446ef0eb3SPhoebe Buckheister case IEEE802154_ADDR_SHORT: 23546ef0eb3SPhoebe Buckheister sa->short_addr = le16_to_cpu(a->short_addr); 23646ef0eb3SPhoebe Buckheister break; 23746ef0eb3SPhoebe Buckheister case IEEE802154_ADDR_LONG: 23846ef0eb3SPhoebe Buckheister ieee802154_devaddr_to_raw(sa->hwaddr, a->extended_addr); 23946ef0eb3SPhoebe Buckheister break; 24046ef0eb3SPhoebe Buckheister } 24146ef0eb3SPhoebe Buckheister } 24246ef0eb3SPhoebe Buckheister 243f0166e5eSDmitry Eremin-Solenikov /* 244f0166e5eSDmitry Eremin-Solenikov * A control block of skb passed between the ARPHRD_IEEE802154 device 245f0166e5eSDmitry Eremin-Solenikov * and other stack parts. 246f0166e5eSDmitry Eremin-Solenikov */ 247f0166e5eSDmitry Eremin-Solenikov struct ieee802154_mac_cb { 248f0166e5eSDmitry Eremin-Solenikov u8 lqi; 24932edc40aSPhoebe Buckheister u8 type; 25032edc40aSPhoebe Buckheister bool ackreq; 25132edc40aSPhoebe Buckheister bool secen; 252f30be4d5SPhoebe Buckheister bool secen_override; 253f30be4d5SPhoebe Buckheister u8 seclevel; 254f30be4d5SPhoebe Buckheister bool seclevel_override; 255ae531b94SPhoebe Buckheister struct ieee802154_addr source; 256ae531b94SPhoebe Buckheister struct ieee802154_addr dest; 257f0166e5eSDmitry Eremin-Solenikov }; 258f0166e5eSDmitry Eremin-Solenikov 259f0166e5eSDmitry Eremin-Solenikov static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb) 260f0166e5eSDmitry Eremin-Solenikov { 261f0166e5eSDmitry Eremin-Solenikov return (struct ieee802154_mac_cb *)skb->cb; 262f0166e5eSDmitry Eremin-Solenikov } 263f0166e5eSDmitry Eremin-Solenikov 26432edc40aSPhoebe Buckheister static inline struct ieee802154_mac_cb *mac_cb_init(struct sk_buff *skb) 265f0166e5eSDmitry Eremin-Solenikov { 26632edc40aSPhoebe Buckheister BUILD_BUG_ON(sizeof(struct ieee802154_mac_cb) > sizeof(skb->cb)); 267f0166e5eSDmitry Eremin-Solenikov 26832edc40aSPhoebe Buckheister memset(skb->cb, 0, sizeof(struct ieee802154_mac_cb)); 26932edc40aSPhoebe Buckheister return mac_cb(skb); 270f0166e5eSDmitry Eremin-Solenikov } 271f0166e5eSDmitry Eremin-Solenikov 272dc20759fSPhoebe Buckheister enum { 273dc20759fSPhoebe Buckheister IEEE802154_LLSEC_DEVKEY_IGNORE, 274dc20759fSPhoebe Buckheister IEEE802154_LLSEC_DEVKEY_RESTRICT, 275f0f77dc6SPhoebe Buckheister IEEE802154_LLSEC_DEVKEY_RECORD, 276dc20759fSPhoebe Buckheister 277dc20759fSPhoebe Buckheister __IEEE802154_LLSEC_DEVKEY_MAX, 278dc20759fSPhoebe Buckheister }; 279dc20759fSPhoebe Buckheister 280f0166e5eSDmitry Eremin-Solenikov #define IEEE802154_MAC_SCAN_ED 0 281f0166e5eSDmitry Eremin-Solenikov #define IEEE802154_MAC_SCAN_ACTIVE 1 282f0166e5eSDmitry Eremin-Solenikov #define IEEE802154_MAC_SCAN_PASSIVE 2 283f0166e5eSDmitry Eremin-Solenikov #define IEEE802154_MAC_SCAN_ORPHAN 3 284f0166e5eSDmitry Eremin-Solenikov 285e462ded6SPhoebe Buckheister struct ieee802154_mac_params { 286e462ded6SPhoebe Buckheister s8 transmit_power; 287e462ded6SPhoebe Buckheister u8 min_be; 288e462ded6SPhoebe Buckheister u8 max_be; 289e462ded6SPhoebe Buckheister u8 csma_retries; 290e462ded6SPhoebe Buckheister s8 frame_retries; 291e462ded6SPhoebe Buckheister 292e462ded6SPhoebe Buckheister bool lbt; 2937fe9a388SAlexander Aring struct wpan_phy_cca cca; 294e462ded6SPhoebe Buckheister s32 cca_ed_level; 295e462ded6SPhoebe Buckheister }; 296e462ded6SPhoebe Buckheister 29742723448SDmitry Eremin-Solenikov struct wpan_phy; 298dc20759fSPhoebe Buckheister 299dc20759fSPhoebe Buckheister enum { 300fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_ENABLED = BIT(0), 301fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_FRAME_COUNTER = BIT(1), 302fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_OUT_LEVEL = BIT(2), 303fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_OUT_KEY = BIT(3), 304fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_KEY_SOURCE = BIT(4), 305fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_PAN_ID = BIT(5), 306fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_HWADDR = BIT(6), 307fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_COORD_HWADDR = BIT(7), 308fe89e690SVarka Bhadram IEEE802154_LLSEC_PARAM_COORD_SHORTADDR = BIT(8), 309dc20759fSPhoebe Buckheister }; 310dc20759fSPhoebe Buckheister 31129e02374SPhoebe Buckheister struct ieee802154_llsec_ops { 31229e02374SPhoebe Buckheister int (*get_params)(struct net_device *dev, 31329e02374SPhoebe Buckheister struct ieee802154_llsec_params *params); 31429e02374SPhoebe Buckheister int (*set_params)(struct net_device *dev, 31529e02374SPhoebe Buckheister const struct ieee802154_llsec_params *params, 31629e02374SPhoebe Buckheister int changed); 31729e02374SPhoebe Buckheister 31829e02374SPhoebe Buckheister int (*add_key)(struct net_device *dev, 31929e02374SPhoebe Buckheister const struct ieee802154_llsec_key_id *id, 32029e02374SPhoebe Buckheister const struct ieee802154_llsec_key *key); 32129e02374SPhoebe Buckheister int (*del_key)(struct net_device *dev, 32229e02374SPhoebe Buckheister const struct ieee802154_llsec_key_id *id); 32329e02374SPhoebe Buckheister 32429e02374SPhoebe Buckheister int (*add_dev)(struct net_device *dev, 32529e02374SPhoebe Buckheister const struct ieee802154_llsec_device *llsec_dev); 32629e02374SPhoebe Buckheister int (*del_dev)(struct net_device *dev, __le64 dev_addr); 32729e02374SPhoebe Buckheister 32829e02374SPhoebe Buckheister int (*add_devkey)(struct net_device *dev, 32929e02374SPhoebe Buckheister __le64 device_addr, 33029e02374SPhoebe Buckheister const struct ieee802154_llsec_device_key *key); 33129e02374SPhoebe Buckheister int (*del_devkey)(struct net_device *dev, 33229e02374SPhoebe Buckheister __le64 device_addr, 33329e02374SPhoebe Buckheister const struct ieee802154_llsec_device_key *key); 33429e02374SPhoebe Buckheister 33529e02374SPhoebe Buckheister int (*add_seclevel)(struct net_device *dev, 33629e02374SPhoebe Buckheister const struct ieee802154_llsec_seclevel *sl); 33729e02374SPhoebe Buckheister int (*del_seclevel)(struct net_device *dev, 33829e02374SPhoebe Buckheister const struct ieee802154_llsec_seclevel *sl); 33929e02374SPhoebe Buckheister 34029e02374SPhoebe Buckheister void (*lock_table)(struct net_device *dev); 34129e02374SPhoebe Buckheister void (*get_table)(struct net_device *dev, 34229e02374SPhoebe Buckheister struct ieee802154_llsec_table **t); 34329e02374SPhoebe Buckheister void (*unlock_table)(struct net_device *dev); 34429e02374SPhoebe Buckheister }; 345f0166e5eSDmitry Eremin-Solenikov /* 346f0166e5eSDmitry Eremin-Solenikov * This should be located at net_device->ml_priv 34742723448SDmitry Eremin-Solenikov * 34842723448SDmitry Eremin-Solenikov * get_phy should increment the reference counting on returned phy. 34942723448SDmitry Eremin-Solenikov * Use wpan_wpy_put to put that reference. 350f0166e5eSDmitry Eremin-Solenikov */ 351f0166e5eSDmitry Eremin-Solenikov struct ieee802154_mlme_ops { 35256aa091dSWerner Almesberger /* The following fields are optional (can be NULL). */ 35356aa091dSWerner Almesberger 354f0166e5eSDmitry Eremin-Solenikov int (*assoc_req)(struct net_device *dev, 355ae531b94SPhoebe Buckheister struct ieee802154_addr *addr, 35616eea493SDmitry Eremin-Solenikov u8 channel, u8 page, u8 cap); 357f0166e5eSDmitry Eremin-Solenikov int (*assoc_resp)(struct net_device *dev, 358ae531b94SPhoebe Buckheister struct ieee802154_addr *addr, 359b70ab2e8SPhoebe Buckheister __le16 short_addr, u8 status); 360f0166e5eSDmitry Eremin-Solenikov int (*disassoc_req)(struct net_device *dev, 361ae531b94SPhoebe Buckheister struct ieee802154_addr *addr, 362f0166e5eSDmitry Eremin-Solenikov u8 reason); 363f0166e5eSDmitry Eremin-Solenikov int (*start_req)(struct net_device *dev, 364ae531b94SPhoebe Buckheister struct ieee802154_addr *addr, 36516eea493SDmitry Eremin-Solenikov u8 channel, u8 page, u8 bcn_ord, u8 sf_ord, 366f0166e5eSDmitry Eremin-Solenikov u8 pan_coord, u8 blx, u8 coord_realign); 367f0166e5eSDmitry Eremin-Solenikov int (*scan_req)(struct net_device *dev, 36816eea493SDmitry Eremin-Solenikov u8 type, u32 channels, u8 page, u8 duration); 369f0166e5eSDmitry Eremin-Solenikov 370e462ded6SPhoebe Buckheister int (*set_mac_params)(struct net_device *dev, 371e462ded6SPhoebe Buckheister const struct ieee802154_mac_params *params); 372e462ded6SPhoebe Buckheister void (*get_mac_params)(struct net_device *dev, 373e462ded6SPhoebe Buckheister struct ieee802154_mac_params *params); 374e462ded6SPhoebe Buckheister 37529663b0cSJulia Lawall const struct ieee802154_llsec_ops *llsec; 376f0166e5eSDmitry Eremin-Solenikov }; 377f0166e5eSDmitry Eremin-Solenikov 37874a02fcfSalex.bluesman.smirnov@gmail.com static inline struct ieee802154_mlme_ops * 37974a02fcfSalex.bluesman.smirnov@gmail.com ieee802154_mlme_ops(const struct net_device *dev) 38074a02fcfSalex.bluesman.smirnov@gmail.com { 38174a02fcfSalex.bluesman.smirnov@gmail.com return dev->ml_priv; 38274a02fcfSalex.bluesman.smirnov@gmail.com } 38374a02fcfSalex.bluesman.smirnov@gmail.com 384f0166e5eSDmitry Eremin-Solenikov #endif 385