Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2016-04-26

Here's another set of Bluetooth & 802.15.4 patches for the 4.7 kernel:

- Cleanups & refactoring of ieee802154 & 6lowpan code
- Security related additions to ieee802154 and mrf24j40 driver
- Memory corruption fix to Bluetooth 6lowpan code
- Race condition fix in vhci driver
- Enhancements to the atusb 802.15.4 driver

Please let me know if there are any issues pulling. Thanks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+356 -167
+4 -2
drivers/bluetooth/ath3k.c
··· 206 206 const struct firmware *firmware) 207 207 { 208 208 u8 *send_buf; 209 - int err, pipe, len, size, sent = 0; 209 + int len = 0; 210 + int err, pipe, size, sent = 0; 210 211 int count = firmware->size; 211 212 212 213 BT_DBG("udev %p", udev); ··· 303 302 const struct firmware *firmware) 304 303 { 305 304 u8 *send_buf; 306 - int err, pipe, len, size, count, sent = 0; 305 + int len = 0; 306 + int err, pipe, size, count, sent = 0; 307 307 int ret; 308 308 309 309 count = firmware->size;
+17 -6
drivers/bluetooth/hci_vhci.c
··· 50 50 wait_queue_head_t read_wait; 51 51 struct sk_buff_head readq; 52 52 53 + struct mutex open_mutex; 53 54 struct delayed_work open_timeout; 54 55 }; 55 56 ··· 88 87 return 0; 89 88 } 90 89 91 - static int vhci_create_device(struct vhci_data *data, __u8 opcode) 90 + static int __vhci_create_device(struct vhci_data *data, __u8 opcode) 92 91 { 93 92 struct hci_dev *hdev; 94 93 struct sk_buff *skb; 95 94 __u8 dev_type; 95 + 96 + if (data->hdev) 97 + return -EBADFD; 96 98 97 99 /* bits 0-1 are dev_type (BR/EDR or AMP) */ 98 100 dev_type = opcode & 0x03; ··· 155 151 return 0; 156 152 } 157 153 154 + static int vhci_create_device(struct vhci_data *data, __u8 opcode) 155 + { 156 + int err; 157 + 158 + mutex_lock(&data->open_mutex); 159 + err = __vhci_create_device(data, opcode); 160 + mutex_unlock(&data->open_mutex); 161 + 162 + return err; 163 + } 164 + 158 165 static inline ssize_t vhci_get_user(struct vhci_data *data, 159 166 struct iov_iter *from) 160 167 { ··· 205 190 206 191 case HCI_VENDOR_PKT: 207 192 cancel_delayed_work_sync(&data->open_timeout); 208 - 209 - if (data->hdev) { 210 - kfree_skb(skb); 211 - return -EBADFD; 212 - } 213 193 214 194 opcode = *((__u8 *) skb->data); 215 195 skb_pull(skb, 1); ··· 330 320 skb_queue_head_init(&data->readq); 331 321 init_waitqueue_head(&data->read_wait); 332 322 323 + mutex_init(&data->open_mutex); 333 324 INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout); 334 325 335 326 file->private_data = data;
+3 -3
drivers/net/ieee802154/at86rf230.c
··· 1340 1340 .t_off_to_aack = 80, 1341 1341 .t_off_to_tx_on = 80, 1342 1342 .t_off_to_sleep = 35, 1343 - .t_sleep_to_off = 210, 1343 + .t_sleep_to_off = 1000, 1344 1344 .t_frame = 4096, 1345 1345 .t_p_ack = 545, 1346 1346 .rssi_base_val = -91, ··· 1355 1355 .t_off_to_aack = 110, 1356 1356 .t_off_to_tx_on = 110, 1357 1357 .t_off_to_sleep = 35, 1358 - .t_sleep_to_off = 380, 1358 + .t_sleep_to_off = 1000, 1359 1359 .t_frame = 4096, 1360 1360 .t_p_ack = 545, 1361 1361 .rssi_base_val = -91, ··· 1370 1370 .t_off_to_aack = 200, 1371 1371 .t_off_to_tx_on = 200, 1372 1372 .t_off_to_sleep = 35, 1373 - .t_sleep_to_off = 380, 1373 + .t_sleep_to_off = 1000, 1374 1374 .t_frame = 4096, 1375 1375 .t_p_ack = 545, 1376 1376 .rssi_base_val = -100,
+89 -2
drivers/net/ieee802154/atusb.c
··· 3 3 * 4 4 * Written 2013 by Werner Almesberger <werner@almesberger.net> 5 5 * 6 + * Copyright (c) 2015 - 2016 Stefan Schmidt <stefan@datenfreihafen.org> 7 + * 6 8 * This program is free software; you can redistribute it and/or 7 9 * modify it under the terms of the GNU General Public License as 8 10 * published by the Free Software Foundation, version 2 ··· 474 472 return -EINVAL; 475 473 } 476 474 475 + #define ATUSB_MAX_ED_LEVELS 0xF 476 + static const s32 atusb_ed_levels[ATUSB_MAX_ED_LEVELS + 1] = { 477 + -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300, 478 + -7100, -6900, -6700, -6500, -6300, -6100, 479 + }; 480 + 481 + static int 482 + atusb_set_cca_mode(struct ieee802154_hw *hw, const struct wpan_phy_cca *cca) 483 + { 484 + struct atusb *atusb = hw->priv; 485 + u8 val; 486 + 487 + /* mapping 802.15.4 to driver spec */ 488 + switch (cca->mode) { 489 + case NL802154_CCA_ENERGY: 490 + val = 1; 491 + break; 492 + case NL802154_CCA_CARRIER: 493 + val = 2; 494 + break; 495 + case NL802154_CCA_ENERGY_CARRIER: 496 + switch (cca->opt) { 497 + case NL802154_CCA_OPT_ENERGY_CARRIER_AND: 498 + val = 3; 499 + break; 500 + case NL802154_CCA_OPT_ENERGY_CARRIER_OR: 501 + val = 0; 502 + break; 503 + default: 504 + return -EINVAL; 505 + } 506 + break; 507 + default: 508 + return -EINVAL; 509 + } 510 + 511 + return atusb_write_subreg(atusb, SR_CCA_MODE, val); 512 + } 513 + 514 + static int 515 + atusb_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm) 516 + { 517 + struct atusb *atusb = hw->priv; 518 + u32 i; 519 + 520 + for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) { 521 + if (hw->phy->supported.cca_ed_levels[i] == mbm) 522 + return atusb_write_subreg(atusb, SR_CCA_ED_THRES, i); 523 + } 524 + 525 + return -EINVAL; 526 + } 527 + 528 + static int 529 + atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries) 530 + { 531 + struct atusb *atusb = hw->priv; 532 + int ret; 533 + 534 + ret = atusb_write_subreg(atusb, SR_MIN_BE, min_be); 535 + if (ret) 536 + return ret; 537 + 538 + ret = atusb_write_subreg(atusb, SR_MAX_BE, max_be); 539 + if (ret) 540 + return ret; 541 + 542 + return atusb_write_subreg(atusb, SR_MAX_CSMA_RETRIES, retries); 543 + } 544 + 477 545 static int 478 546 atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on) 479 547 { ··· 580 508 .stop = atusb_stop, 581 509 .set_hw_addr_filt = atusb_set_hw_addr_filt, 582 510 .set_txpower = atusb_set_txpower, 511 + .set_cca_mode = atusb_set_cca_mode, 512 + .set_cca_ed_level = atusb_set_cca_ed_level, 513 + .set_csma_params = atusb_set_csma_params, 583 514 .set_promiscuous_mode = atusb_set_promiscuous_mode, 584 515 }; 585 516 ··· 711 636 712 637 hw->parent = &usb_dev->dev; 713 638 hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT | 714 - IEEE802154_HW_PROMISCUOUS; 639 + IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS; 715 640 716 - hw->phy->flags = WPAN_PHY_FLAG_TXPOWER; 641 + hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL | 642 + WPAN_PHY_FLAG_CCA_MODE; 643 + 644 + hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) | 645 + BIT(NL802154_CCA_CARRIER) | BIT(NL802154_CCA_ENERGY_CARRIER); 646 + hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) | 647 + BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR); 648 + 649 + hw->phy->supported.cca_ed_levels = atusb_ed_levels; 650 + hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(atusb_ed_levels); 651 + 652 + hw->phy->cca.mode = NL802154_CCA_ENERGY; 717 653 718 654 hw->phy->current_page = 0; 719 655 hw->phy->current_channel = 11; /* reset default */ ··· 733 647 hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers); 734 648 hw->phy->transmit_power = hw->phy->supported.tx_powers[0]; 735 649 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); 650 + hw->phy->cca_ed_level = hw->phy->supported.cca_ed_levels[7]; 736 651 737 652 atusb_command(atusb, ATUSB_RF_RESET, 0); 738 653 atusb_get_and_show_chip(atusb);
+13 -1
drivers/net/ieee802154/mrf24j40.c
··· 61 61 #define REG_TXBCON0 0x1A 62 62 #define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ 63 63 #define BIT_TXNTRIG BIT(0) 64 + #define BIT_TXNSECEN BIT(1) 64 65 #define BIT_TXNACKREQ BIT(2) 65 66 66 67 #define REG_TXG1CON 0x1C ··· 86 85 #define REG_INTSTAT 0x31 /* Interrupt Status */ 87 86 #define BIT_TXNIF BIT(0) 88 87 #define BIT_RXIF BIT(3) 88 + #define BIT_SECIF BIT(4) 89 + #define BIT_SECIGNORE BIT(7) 89 90 90 91 #define REG_INTCON 0x32 /* Interrupt Control */ 91 92 #define BIT_TXNIE BIT(0) 92 93 #define BIT_RXIE BIT(3) 94 + #define BIT_SECIE BIT(4) 93 95 94 96 #define REG_GPIO 0x33 /* GPIO */ 95 97 #define REG_TRISGPIO 0x34 /* GPIO direction */ ··· 552 548 u8 val = BIT_TXNTRIG; 553 549 int ret; 554 550 551 + if (ieee802154_is_secen(fc)) 552 + val |= BIT_TXNSECEN; 553 + 555 554 if (ieee802154_is_ackreq(fc)) 556 555 val |= BIT_TXNACKREQ; 557 556 ··· 623 616 624 617 /* Clear TXNIE and RXIE. Enable interrupts */ 625 618 return regmap_update_bits(devrec->regmap_short, REG_INTCON, 626 - BIT_TXNIE | BIT_RXIE, 0); 619 + BIT_TXNIE | BIT_RXIE | BIT_SECIE, 0); 627 620 } 628 621 629 622 static void mrf24j40_stop(struct ieee802154_hw *hw) ··· 1031 1024 u8 intstat = devrec->irq_buf[1]; 1032 1025 1033 1026 enable_irq(devrec->spi->irq); 1027 + 1028 + /* Ignore Rx security decryption */ 1029 + if (intstat & BIT_SECIF) 1030 + regmap_write_async(devrec->regmap_short, REG_SECCON0, 1031 + BIT_SECIGNORE); 1034 1032 1035 1033 /* Check for TX complete */ 1036 1034 if (intstat & BIT_TXNIF)
+42 -3
include/linux/ieee802154.h
··· 47 47 #define IEEE802154_ADDR_SHORT_UNSPEC 0xfffe 48 48 49 49 #define IEEE802154_EXTENDED_ADDR_LEN 8 50 + #define IEEE802154_SHORT_ADDR_LEN 2 50 51 51 52 #define IEEE802154_LIFS_PERIOD 40 52 53 #define IEEE802154_SIFS_PERIOD 12 ··· 219 218 /* frame control handling */ 220 219 #define IEEE802154_FCTL_FTYPE 0x0003 221 220 #define IEEE802154_FCTL_ACKREQ 0x0020 221 + #define IEEE802154_FCTL_SECEN 0x0004 222 222 #define IEEE802154_FCTL_INTRA_PAN 0x0040 223 223 224 224 #define IEEE802154_FTYPE_DATA 0x0001 ··· 232 230 { 233 231 return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) == 234 232 cpu_to_le16(IEEE802154_FTYPE_DATA); 233 + } 234 + 235 + /** 236 + * ieee802154_is_secen - check if Security bit is set 237 + * @fc: frame control bytes in little-endian byteorder 238 + */ 239 + static inline bool ieee802154_is_secen(__le16 fc) 240 + { 241 + return fc & cpu_to_le16(IEEE802154_FCTL_SECEN); 235 242 } 236 243 237 244 /** ··· 271 260 * 272 261 * @len: psdu len with (MHR + payload + MFR) 273 262 */ 274 - static inline bool ieee802154_is_valid_psdu_len(const u8 len) 263 + static inline bool ieee802154_is_valid_psdu_len(u8 len) 275 264 { 276 265 return (len == IEEE802154_ACK_PSDU_LEN || 277 266 (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU)); 278 267 } 279 268 280 269 /** 281 - * ieee802154_is_valid_psdu_len - check if extended addr is valid 270 + * ieee802154_is_valid_extended_unicast_addr - check if extended addr is valid 282 271 * @addr: extended addr to check 283 272 */ 284 - static inline bool ieee802154_is_valid_extended_unicast_addr(const __le64 addr) 273 + static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr) 285 274 { 286 275 /* Bail out if the address is all zero, or if the group 287 276 * address bit is set. 288 277 */ 289 278 return ((addr != cpu_to_le64(0x0000000000000000ULL)) && 290 279 !(addr & cpu_to_le64(0x0100000000000000ULL))); 280 + } 281 + 282 + /** 283 + * ieee802154_is_broadcast_short_addr - check if short addr is broadcast 284 + * @addr: short addr to check 285 + */ 286 + static inline bool ieee802154_is_broadcast_short_addr(__le16 addr) 287 + { 288 + return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST)); 289 + } 290 + 291 + /** 292 + * ieee802154_is_unspec_short_addr - check if short addr is unspecified 293 + * @addr: short addr to check 294 + */ 295 + static inline bool ieee802154_is_unspec_short_addr(__le16 addr) 296 + { 297 + return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC)); 298 + } 299 + 300 + /** 301 + * ieee802154_is_valid_src_short_addr - check if source short address is valid 302 + * @addr: short addr to check 303 + */ 304 + static inline bool ieee802154_is_valid_src_short_addr(__le16 addr) 305 + { 306 + return !(ieee802154_is_broadcast_short_addr(addr) || 307 + ieee802154_is_unspec_short_addr(addr)); 291 308 } 292 309 293 310 /**
+34 -3
include/net/6lowpan.h
··· 58 58 #include <net/ipv6.h> 59 59 #include <net/net_namespace.h> 60 60 61 + /* special link-layer handling */ 62 + #include <net/mac802154.h> 63 + 61 64 #define EUI64_ADDR_LEN 8 62 65 63 66 #define LOWPAN_NHC_MAX_ID_LEN 1 ··· 96 93 } 97 94 98 95 #define LOWPAN_PRIV_SIZE(llpriv_size) \ 99 - (sizeof(struct lowpan_priv) + llpriv_size) 96 + (sizeof(struct lowpan_dev) + llpriv_size) 100 97 101 98 enum lowpan_lltypes { 102 99 LOWPAN_LLTYPE_BTLE, ··· 132 129 return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags); 133 130 } 134 131 135 - struct lowpan_priv { 132 + struct lowpan_dev { 136 133 enum lowpan_lltypes lltype; 137 134 struct dentry *iface_debugfs; 138 135 struct lowpan_iphc_ctx_table ctx; ··· 142 139 }; 143 140 144 141 static inline 145 - struct lowpan_priv *lowpan_priv(const struct net_device *dev) 142 + struct lowpan_dev *lowpan_dev(const struct net_device *dev) 146 143 { 147 144 return netdev_priv(dev); 145 + } 146 + 147 + /* private device info */ 148 + struct lowpan_802154_dev { 149 + struct net_device *wdev; /* wpan device ptr */ 150 + u16 fragment_tag; 151 + }; 152 + 153 + static inline struct 154 + lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev) 155 + { 156 + return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv; 148 157 } 149 158 150 159 struct lowpan_802154_cb { ··· 170 155 { 171 156 BUILD_BUG_ON(sizeof(struct lowpan_802154_cb) > sizeof(skb->cb)); 172 157 return (struct lowpan_802154_cb *)skb->cb; 158 + } 159 + 160 + static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr, 161 + const void *lladdr) 162 + { 163 + /* fe:80::XXXX:XXXX:XXXX:XXXX 164 + * \_________________/ 165 + * hwaddr 166 + */ 167 + ipaddr->s6_addr[0] = 0xFE; 168 + ipaddr->s6_addr[1] = 0x80; 169 + memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN); 170 + /* second bit-flip (Universe/Local) 171 + * is done according RFC2464 172 + */ 173 + ipaddr->s6_addr[8] ^= 0x02; 173 174 } 174 175 175 176 #ifdef DEBUG
+2
include/net/bluetooth/hci.h
··· 61 61 #define HCI_RS232 4 62 62 #define HCI_PCI 5 63 63 #define HCI_SDIO 6 64 + #define HCI_SPI 7 65 + #define HCI_I2C 8 64 66 65 67 /* HCI controller types */ 66 68 #define HCI_BREDR 0x00
+10
include/net/mac802154.h
··· 288 288 } 289 289 290 290 /** 291 + * ieee802154_be16_to_le16 - copies and convert be16 to le16 292 + * @le16_dst: le16 destination pointer 293 + * @be16_src: be16 source pointer 294 + */ 295 + static inline void ieee802154_be16_to_le16(void *le16_dst, const void *be16_src) 296 + { 297 + put_unaligned_le16(get_unaligned_be16(be16_src), le16_dst); 298 + } 299 + 300 + /** 291 301 * ieee802154_alloc_hw - Allocate a new hardware device 292 302 * 293 303 * This must be called once for each hardware device. The returned pointer
+9
net/6lowpan/6lowpan_i.h
··· 3 3 4 4 #include <linux/netdevice.h> 5 5 6 + #include <net/6lowpan.h> 7 + 8 + /* caller need to be sure it's dev->type is ARPHRD_6LOWPAN */ 9 + static inline bool lowpan_is_ll(const struct net_device *dev, 10 + enum lowpan_lltypes lltype) 11 + { 12 + return lowpan_dev(dev)->lltype == lltype; 13 + } 14 + 6 15 #ifdef CONFIG_6LOWPAN_DEBUGFS 7 16 int lowpan_dev_debugfs_init(struct net_device *dev); 8 17 void lowpan_dev_debugfs_exit(struct net_device *dev);
+4 -4
net/6lowpan/core.c
··· 27 27 dev->mtu = IPV6_MIN_MTU; 28 28 dev->priv_flags |= IFF_NO_QUEUE; 29 29 30 - lowpan_priv(dev)->lltype = lltype; 30 + lowpan_dev(dev)->lltype = lltype; 31 31 32 - spin_lock_init(&lowpan_priv(dev)->ctx.lock); 32 + spin_lock_init(&lowpan_dev(dev)->ctx.lock); 33 33 for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) 34 - lowpan_priv(dev)->ctx.table[i].id = i; 34 + lowpan_dev(dev)->ctx.table[i].id = i; 35 35 36 36 ret = register_netdevice(dev); 37 37 if (ret < 0) ··· 85 85 case NETDEV_DOWN: 86 86 for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) 87 87 clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, 88 - &lowpan_priv(dev)->ctx.table[i].flags); 88 + &lowpan_dev(dev)->ctx.table[i].flags); 89 89 break; 90 90 default: 91 91 return NOTIFY_DONE;
+11 -11
net/6lowpan/debugfs.c
··· 172 172 static int lowpan_dev_debugfs_ctx_init(struct net_device *dev, 173 173 struct dentry *ctx, u8 id) 174 174 { 175 - struct lowpan_priv *lpriv = lowpan_priv(dev); 175 + struct lowpan_dev *ldev = lowpan_dev(dev); 176 176 struct dentry *dentry, *root; 177 177 char buf[32]; 178 178 ··· 185 185 return -EINVAL; 186 186 187 187 dentry = debugfs_create_file("active", 0644, root, 188 - &lpriv->ctx.table[id], 188 + &ldev->ctx.table[id], 189 189 &lowpan_ctx_flag_active_fops); 190 190 if (!dentry) 191 191 return -EINVAL; 192 192 193 193 dentry = debugfs_create_file("compression", 0644, root, 194 - &lpriv->ctx.table[id], 194 + &ldev->ctx.table[id], 195 195 &lowpan_ctx_flag_c_fops); 196 196 if (!dentry) 197 197 return -EINVAL; 198 198 199 199 dentry = debugfs_create_file("prefix", 0644, root, 200 - &lpriv->ctx.table[id], 200 + &ldev->ctx.table[id], 201 201 &lowpan_ctx_pfx_fops); 202 202 if (!dentry) 203 203 return -EINVAL; 204 204 205 205 dentry = debugfs_create_file("prefix_len", 0644, root, 206 - &lpriv->ctx.table[id], 206 + &ldev->ctx.table[id], 207 207 &lowpan_ctx_plen_fops); 208 208 if (!dentry) 209 209 return -EINVAL; ··· 247 247 248 248 int lowpan_dev_debugfs_init(struct net_device *dev) 249 249 { 250 - struct lowpan_priv *lpriv = lowpan_priv(dev); 250 + struct lowpan_dev *ldev = lowpan_dev(dev); 251 251 struct dentry *contexts, *dentry; 252 252 int ret, i; 253 253 254 254 /* creating the root */ 255 - lpriv->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs); 256 - if (!lpriv->iface_debugfs) 255 + ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs); 256 + if (!ldev->iface_debugfs) 257 257 goto fail; 258 258 259 - contexts = debugfs_create_dir("contexts", lpriv->iface_debugfs); 259 + contexts = debugfs_create_dir("contexts", ldev->iface_debugfs); 260 260 if (!contexts) 261 261 goto remove_root; 262 262 263 263 dentry = debugfs_create_file("show", 0644, contexts, 264 - &lowpan_priv(dev)->ctx, 264 + &lowpan_dev(dev)->ctx, 265 265 &lowpan_context_fops); 266 266 if (!dentry) 267 267 goto remove_root; ··· 282 282 283 283 void lowpan_dev_debugfs_exit(struct net_device *dev) 284 284 { 285 - debugfs_remove_recursive(lowpan_priv(dev)->iface_debugfs); 285 + debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs); 286 286 } 287 287 288 288 int __init lowpan_debugfs_init(void)
+49 -62
net/6lowpan/iphc.c
··· 53 53 #include <net/6lowpan.h> 54 54 #include <net/ipv6.h> 55 55 56 - /* special link-layer handling */ 57 - #include <net/mac802154.h> 58 - 59 56 #include "6lowpan_i.h" 60 57 #include "nhc.h" 61 58 ··· 153 156 #define LOWPAN_IPHC_CID_DCI(cid) (cid & 0x0f) 154 157 #define LOWPAN_IPHC_CID_SCI(cid) ((cid & 0xf0) >> 4) 155 158 156 - static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr, 157 - const void *lladdr) 158 - { 159 - /* fe:80::XXXX:XXXX:XXXX:XXXX 160 - * \_________________/ 161 - * hwaddr 162 - */ 163 - ipaddr->s6_addr[0] = 0xFE; 164 - ipaddr->s6_addr[1] = 0x80; 165 - memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN); 166 - /* second bit-flip (Universe/Local) 167 - * is done according RFC2464 168 - */ 169 - ipaddr->s6_addr[8] ^= 0x02; 170 - } 171 - 172 - static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr, 173 - const void *lladdr) 159 + static inline void 160 + lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr, 161 + const void *lladdr) 174 162 { 175 163 const struct ieee802154_addr *addr = lladdr; 176 - u8 eui64[EUI64_ADDR_LEN] = { }; 164 + u8 eui64[EUI64_ADDR_LEN]; 177 165 178 166 switch (addr->mode) { 179 167 case IEEE802154_ADDR_LONG: 180 168 ieee802154_le64_to_be64(eui64, &addr->extended_addr); 181 - iphc_uncompress_eui64_lladdr(ipaddr, eui64); 169 + lowpan_iphc_uncompress_eui64_lladdr(ipaddr, eui64); 182 170 break; 183 171 case IEEE802154_ADDR_SHORT: 184 172 /* fe:80::ff:fe00:XXXX ··· 189 207 static struct lowpan_iphc_ctx * 190 208 lowpan_iphc_ctx_get_by_id(const struct net_device *dev, u8 id) 191 209 { 192 - struct lowpan_iphc_ctx *ret = &lowpan_priv(dev)->ctx.table[id]; 210 + struct lowpan_iphc_ctx *ret = &lowpan_dev(dev)->ctx.table[id]; 193 211 194 212 if (!lowpan_iphc_ctx_is_active(ret)) 195 213 return NULL; ··· 201 219 lowpan_iphc_ctx_get_by_addr(const struct net_device *dev, 202 220 const struct in6_addr *addr) 203 221 { 204 - struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table; 222 + struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table; 205 223 struct lowpan_iphc_ctx *ret = NULL; 206 224 struct in6_addr addr_pfx; 207 225 u8 addr_plen; ··· 245 263 lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev, 246 264 const struct in6_addr *addr) 247 265 { 248 - struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table; 266 + struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table; 249 267 struct lowpan_iphc_ctx *ret = NULL; 250 268 struct in6_addr addr_mcast, network_pfx = {}; 251 269 int i; ··· 283 301 * 284 302 * address_mode is the masked value for sam or dam value 285 303 */ 286 - static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev, 287 - struct in6_addr *ipaddr, u8 address_mode, 288 - const void *lladdr) 304 + static int lowpan_iphc_uncompress_addr(struct sk_buff *skb, 305 + const struct net_device *dev, 306 + struct in6_addr *ipaddr, 307 + u8 address_mode, const void *lladdr) 289 308 { 290 309 bool fail; 291 310 ··· 315 332 case LOWPAN_IPHC_SAM_11: 316 333 case LOWPAN_IPHC_DAM_11: 317 334 fail = false; 318 - switch (lowpan_priv(dev)->lltype) { 335 + switch (lowpan_dev(dev)->lltype) { 319 336 case LOWPAN_LLTYPE_IEEE802154: 320 - iphc_uncompress_802154_lladdr(ipaddr, lladdr); 337 + lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr); 321 338 break; 322 339 default: 323 - iphc_uncompress_eui64_lladdr(ipaddr, lladdr); 340 + lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr); 324 341 break; 325 342 } 326 343 break; ··· 343 360 /* Uncompress address function for source context 344 361 * based address(non-multicast). 345 362 */ 346 - static int uncompress_ctx_addr(struct sk_buff *skb, 347 - const struct net_device *dev, 348 - const struct lowpan_iphc_ctx *ctx, 349 - struct in6_addr *ipaddr, u8 address_mode, 350 - const void *lladdr) 363 + static int lowpan_iphc_uncompress_ctx_addr(struct sk_buff *skb, 364 + const struct net_device *dev, 365 + const struct lowpan_iphc_ctx *ctx, 366 + struct in6_addr *ipaddr, 367 + u8 address_mode, const void *lladdr) 351 368 { 352 369 bool fail; 353 370 ··· 376 393 case LOWPAN_IPHC_SAM_11: 377 394 case LOWPAN_IPHC_DAM_11: 378 395 fail = false; 379 - switch (lowpan_priv(dev)->lltype) { 396 + switch (lowpan_dev(dev)->lltype) { 380 397 case LOWPAN_LLTYPE_IEEE802154: 381 - iphc_uncompress_802154_lladdr(ipaddr, lladdr); 398 + lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr); 382 399 break; 383 400 default: 384 - iphc_uncompress_eui64_lladdr(ipaddr, lladdr); 401 + lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr); 385 402 break; 386 403 } 387 404 ipv6_addr_prefix_copy(ipaddr, &ctx->pfx, ctx->plen); ··· 640 657 } 641 658 642 659 if (iphc1 & LOWPAN_IPHC_SAC) { 643 - spin_lock_bh(&lowpan_priv(dev)->ctx.lock); 660 + spin_lock_bh(&lowpan_dev(dev)->ctx.lock); 644 661 ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_SCI(cid)); 645 662 if (!ci) { 646 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 663 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 647 664 return -EINVAL; 648 665 } 649 666 650 667 pr_debug("SAC bit is set. Handle context based source address.\n"); 651 - err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr, 652 - iphc1 & LOWPAN_IPHC_SAM_MASK, saddr); 653 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 668 + err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.saddr, 669 + iphc1 & LOWPAN_IPHC_SAM_MASK, 670 + saddr); 671 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 654 672 } else { 655 673 /* Source address uncompression */ 656 674 pr_debug("source address stateless compression\n"); 657 - err = uncompress_addr(skb, dev, &hdr.saddr, 658 - iphc1 & LOWPAN_IPHC_SAM_MASK, saddr); 675 + err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.saddr, 676 + iphc1 & LOWPAN_IPHC_SAM_MASK, 677 + saddr); 659 678 } 660 679 661 680 /* Check on error of previous branch */ ··· 666 681 667 682 switch (iphc1 & (LOWPAN_IPHC_M | LOWPAN_IPHC_DAC)) { 668 683 case LOWPAN_IPHC_M | LOWPAN_IPHC_DAC: 669 - spin_lock_bh(&lowpan_priv(dev)->ctx.lock); 684 + spin_lock_bh(&lowpan_dev(dev)->ctx.lock); 670 685 ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid)); 671 686 if (!ci) { 672 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 687 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 673 688 return -EINVAL; 674 689 } 675 690 ··· 678 693 err = lowpan_uncompress_multicast_ctx_daddr(skb, ci, 679 694 &hdr.daddr, 680 695 iphc1 & LOWPAN_IPHC_DAM_MASK); 681 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 696 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 682 697 break; 683 698 case LOWPAN_IPHC_M: 684 699 /* multicast */ ··· 686 701 iphc1 & LOWPAN_IPHC_DAM_MASK); 687 702 break; 688 703 case LOWPAN_IPHC_DAC: 689 - spin_lock_bh(&lowpan_priv(dev)->ctx.lock); 704 + spin_lock_bh(&lowpan_dev(dev)->ctx.lock); 690 705 ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid)); 691 706 if (!ci) { 692 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 707 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 693 708 return -EINVAL; 694 709 } 695 710 696 711 /* Destination address context based uncompression */ 697 712 pr_debug("DAC bit is set. Handle context based destination address.\n"); 698 - err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr, 699 - iphc1 & LOWPAN_IPHC_DAM_MASK, daddr); 700 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 713 + err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.daddr, 714 + iphc1 & LOWPAN_IPHC_DAM_MASK, 715 + daddr); 716 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 701 717 break; 702 718 default: 703 - err = uncompress_addr(skb, dev, &hdr.daddr, 704 - iphc1 & LOWPAN_IPHC_DAM_MASK, daddr); 719 + err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.daddr, 720 + iphc1 & LOWPAN_IPHC_DAM_MASK, 721 + daddr); 705 722 pr_debug("dest: stateless compression mode %d dest %pI6c\n", 706 723 iphc1 & LOWPAN_IPHC_DAM_MASK, &hdr.daddr); 707 724 break; ··· 723 736 return err; 724 737 } 725 738 726 - switch (lowpan_priv(dev)->lltype) { 739 + switch (lowpan_dev(dev)->lltype) { 727 740 case LOWPAN_LLTYPE_IEEE802154: 728 741 if (lowpan_802154_cb(skb)->d_size) 729 742 hdr.payload_len = htons(lowpan_802154_cb(skb)->d_size - ··· 1020 1033 skb->data, skb->len); 1021 1034 1022 1035 ipv6_daddr_type = ipv6_addr_type(&hdr->daddr); 1023 - spin_lock_bh(&lowpan_priv(dev)->ctx.lock); 1036 + spin_lock_bh(&lowpan_dev(dev)->ctx.lock); 1024 1037 if (ipv6_daddr_type & IPV6_ADDR_MULTICAST) 1025 1038 dci = lowpan_iphc_ctx_get_by_mcast_addr(dev, &hdr->daddr); 1026 1039 else ··· 1029 1042 memcpy(&dci_entry, dci, sizeof(*dci)); 1030 1043 cid |= dci->id; 1031 1044 } 1032 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 1045 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 1033 1046 1034 - spin_lock_bh(&lowpan_priv(dev)->ctx.lock); 1047 + spin_lock_bh(&lowpan_dev(dev)->ctx.lock); 1035 1048 sci = lowpan_iphc_ctx_get_by_addr(dev, &hdr->saddr); 1036 1049 if (sci) { 1037 1050 memcpy(&sci_entry, sci, sizeof(*sci)); 1038 1051 cid |= (sci->id << 4); 1039 1052 } 1040 - spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); 1053 + spin_unlock_bh(&lowpan_dev(dev)->ctx.lock); 1041 1054 1042 1055 /* if cid is zero it will be compressed */ 1043 1056 if (cid) {
+1 -1
net/6lowpan/nhc_udp.c
··· 91 91 * here, we obtain the hint from the remaining size of the 92 92 * frame 93 93 */ 94 - switch (lowpan_priv(skb->dev)->lltype) { 94 + switch (lowpan_dev(skb->dev)->lltype) { 95 95 case LOWPAN_LLTYPE_IEEE802154: 96 96 if (lowpan_802154_cb(skb)->d_size) 97 97 uh.len = htons(lowpan_802154_cb(skb)->d_size -
+47 -46
net/bluetooth/6lowpan.c
··· 68 68 struct in6_addr peer_addr; 69 69 }; 70 70 71 - struct lowpan_dev { 71 + struct lowpan_btle_dev { 72 72 struct list_head list; 73 73 74 74 struct hci_dev *hdev; ··· 80 80 struct delayed_work notify_peers; 81 81 }; 82 82 83 - static inline struct lowpan_dev *lowpan_dev(const struct net_device *netdev) 83 + static inline struct lowpan_btle_dev * 84 + lowpan_btle_dev(const struct net_device *netdev) 84 85 { 85 - return (struct lowpan_dev *)lowpan_priv(netdev)->priv; 86 + return (struct lowpan_btle_dev *)lowpan_dev(netdev)->priv; 86 87 } 87 88 88 - static inline void peer_add(struct lowpan_dev *dev, struct lowpan_peer *peer) 89 + static inline void peer_add(struct lowpan_btle_dev *dev, 90 + struct lowpan_peer *peer) 89 91 { 90 92 list_add_rcu(&peer->list, &dev->peers); 91 93 atomic_inc(&dev->peer_count); 92 94 } 93 95 94 - static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer) 96 + static inline bool peer_del(struct lowpan_btle_dev *dev, 97 + struct lowpan_peer *peer) 95 98 { 96 99 list_del_rcu(&peer->list); 97 100 kfree_rcu(peer, rcu); ··· 109 106 return false; 110 107 } 111 108 112 - static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev, 109 + static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_btle_dev *dev, 113 110 bdaddr_t *ba, __u8 type) 114 111 { 115 112 struct lowpan_peer *peer; ··· 137 134 return NULL; 138 135 } 139 136 140 - static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev, 141 - struct l2cap_chan *chan) 137 + static inline struct lowpan_peer * 138 + __peer_lookup_chan(struct lowpan_btle_dev *dev, struct l2cap_chan *chan) 142 139 { 143 140 struct lowpan_peer *peer; 144 141 ··· 150 147 return NULL; 151 148 } 152 149 153 - static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev, 154 - struct l2cap_conn *conn) 150 + static inline struct lowpan_peer * 151 + __peer_lookup_conn(struct lowpan_btle_dev *dev, struct l2cap_conn *conn) 155 152 { 156 153 struct lowpan_peer *peer; 157 154 ··· 163 160 return NULL; 164 161 } 165 162 166 - static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev, 163 + static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_btle_dev *dev, 167 164 struct in6_addr *daddr, 168 165 struct sk_buff *skb) 169 166 { ··· 223 220 224 221 static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn) 225 222 { 226 - struct lowpan_dev *entry; 223 + struct lowpan_btle_dev *entry; 227 224 struct lowpan_peer *peer = NULL; 228 225 229 226 rcu_read_lock(); ··· 239 236 return peer; 240 237 } 241 238 242 - static struct lowpan_dev *lookup_dev(struct l2cap_conn *conn) 239 + static struct lowpan_btle_dev *lookup_dev(struct l2cap_conn *conn) 243 240 { 244 - struct lowpan_dev *entry; 245 - struct lowpan_dev *dev = NULL; 241 + struct lowpan_btle_dev *entry; 242 + struct lowpan_btle_dev *dev = NULL; 246 243 247 244 rcu_read_lock(); 248 245 ··· 273 270 struct l2cap_chan *chan) 274 271 { 275 272 const u8 *saddr, *daddr; 276 - struct lowpan_dev *dev; 273 + struct lowpan_btle_dev *dev; 277 274 struct lowpan_peer *peer; 278 275 279 - dev = lowpan_dev(netdev); 276 + dev = lowpan_btle_dev(netdev); 280 277 281 278 rcu_read_lock(); 282 279 peer = __peer_lookup_chan(dev, chan); ··· 378 375 /* Packet from BT LE device */ 379 376 static int chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) 380 377 { 381 - struct lowpan_dev *dev; 378 + struct lowpan_btle_dev *dev; 382 379 struct lowpan_peer *peer; 383 380 int err; 384 381 ··· 434 431 bdaddr_t *peer_addr, u8 *peer_addr_type) 435 432 { 436 433 struct in6_addr ipv6_daddr; 437 - struct lowpan_dev *dev; 434 + struct ipv6hdr *hdr; 435 + struct lowpan_btle_dev *dev; 438 436 struct lowpan_peer *peer; 439 437 bdaddr_t addr, *any = BDADDR_ANY; 440 438 u8 *daddr = any->b; 441 439 int err, status = 0; 442 440 443 - dev = lowpan_dev(netdev); 441 + hdr = ipv6_hdr(skb); 444 442 445 - memcpy(&ipv6_daddr, &lowpan_cb(skb)->addr, sizeof(ipv6_daddr)); 443 + dev = lowpan_btle_dev(netdev); 444 + 445 + memcpy(&ipv6_daddr, &hdr->daddr, sizeof(ipv6_daddr)); 446 446 447 447 if (ipv6_addr_is_multicast(&ipv6_daddr)) { 448 448 lowpan_cb(skb)->chan = NULL; ··· 495 489 unsigned short type, const void *_daddr, 496 490 const void *_saddr, unsigned int len) 497 491 { 498 - struct ipv6hdr *hdr; 499 - 500 492 if (type != ETH_P_IPV6) 501 493 return -EINVAL; 502 - 503 - hdr = ipv6_hdr(skb); 504 - 505 - memcpy(&lowpan_cb(skb)->addr, &hdr->daddr, sizeof(struct in6_addr)); 506 494 507 495 return 0; 508 496 } ··· 543 543 static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev) 544 544 { 545 545 struct sk_buff *local_skb; 546 - struct lowpan_dev *entry; 546 + struct lowpan_btle_dev *entry; 547 547 int err = 0; 548 548 549 549 rcu_read_lock(); 550 550 551 551 list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { 552 552 struct lowpan_peer *pentry; 553 - struct lowpan_dev *dev; 553 + struct lowpan_btle_dev *dev; 554 554 555 555 if (entry->netdev != netdev) 556 556 continue; 557 557 558 - dev = lowpan_dev(entry->netdev); 558 + dev = lowpan_btle_dev(entry->netdev); 559 559 560 560 list_for_each_entry_rcu(pentry, &dev->peers, list) { 561 561 int ret; ··· 723 723 724 724 static void do_notify_peers(struct work_struct *work) 725 725 { 726 - struct lowpan_dev *dev = container_of(work, struct lowpan_dev, 727 - notify_peers.work); 726 + struct lowpan_btle_dev *dev = container_of(work, struct lowpan_btle_dev, 727 + notify_peers.work); 728 728 729 729 netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */ 730 730 } ··· 766 766 } 767 767 768 768 static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan, 769 - struct lowpan_dev *dev) 769 + struct lowpan_btle_dev *dev) 770 770 { 771 771 struct lowpan_peer *peer; 772 772 ··· 803 803 return peer->chan; 804 804 } 805 805 806 - static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev) 806 + static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev) 807 807 { 808 808 struct net_device *netdev; 809 809 int err = 0; 810 810 811 - netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev)), 811 + netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_btle_dev)), 812 812 IFACE_NAME_TEMPLATE, NET_NAME_UNKNOWN, 813 813 netdev_setup); 814 814 if (!netdev) ··· 820 820 SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev); 821 821 SET_NETDEV_DEVTYPE(netdev, &bt_type); 822 822 823 - *dev = lowpan_dev(netdev); 823 + *dev = lowpan_btle_dev(netdev); 824 824 (*dev)->netdev = netdev; 825 825 (*dev)->hdev = chan->conn->hcon->hdev; 826 826 INIT_LIST_HEAD(&(*dev)->peers); ··· 853 853 854 854 static inline void chan_ready_cb(struct l2cap_chan *chan) 855 855 { 856 - struct lowpan_dev *dev; 856 + struct lowpan_btle_dev *dev; 857 857 858 858 dev = lookup_dev(chan->conn); 859 859 ··· 890 890 891 891 static void delete_netdev(struct work_struct *work) 892 892 { 893 - struct lowpan_dev *entry = container_of(work, struct lowpan_dev, 894 - delete_netdev); 893 + struct lowpan_btle_dev *entry = container_of(work, 894 + struct lowpan_btle_dev, 895 + delete_netdev); 895 896 896 897 lowpan_unregister_netdev(entry->netdev); 897 898 ··· 901 900 902 901 static void chan_close_cb(struct l2cap_chan *chan) 903 902 { 904 - struct lowpan_dev *entry; 905 - struct lowpan_dev *dev = NULL; 903 + struct lowpan_btle_dev *entry; 904 + struct lowpan_btle_dev *dev = NULL; 906 905 struct lowpan_peer *peer; 907 906 int err = -ENOENT; 908 907 bool last = false, remove = true; ··· 922 921 spin_lock(&devices_lock); 923 922 924 923 list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { 925 - dev = lowpan_dev(entry->netdev); 924 + dev = lowpan_btle_dev(entry->netdev); 926 925 peer = __peer_lookup_chan(dev, chan); 927 926 if (peer) { 928 927 last = peer_del(dev, peer); ··· 1132 1131 1133 1132 static void disconnect_all_peers(void) 1134 1133 { 1135 - struct lowpan_dev *entry; 1134 + struct lowpan_btle_dev *entry; 1136 1135 struct lowpan_peer *peer, *tmp_peer, *new_peer; 1137 1136 struct list_head peers; 1138 1137 ··· 1292 1291 1293 1292 static int lowpan_control_show(struct seq_file *f, void *ptr) 1294 1293 { 1295 - struct lowpan_dev *entry; 1294 + struct lowpan_btle_dev *entry; 1296 1295 struct lowpan_peer *peer; 1297 1296 1298 1297 spin_lock(&devices_lock); ··· 1323 1322 1324 1323 static void disconnect_devices(void) 1325 1324 { 1326 - struct lowpan_dev *entry, *tmp, *new_dev; 1325 + struct lowpan_btle_dev *entry, *tmp, *new_dev; 1327 1326 struct list_head devices; 1328 1327 1329 1328 INIT_LIST_HEAD(&devices); ··· 1361 1360 unsigned long event, void *ptr) 1362 1361 { 1363 1362 struct net_device *netdev = netdev_notifier_info_to_dev(ptr); 1364 - struct lowpan_dev *entry; 1363 + struct lowpan_btle_dev *entry; 1365 1364 1366 1365 if (netdev->type != ARPHRD_6LOWPAN) 1367 1366 return NOTIFY_DONE;
+1 -13
net/ieee802154/6lowpan/6lowpan_i.h
··· 41 41 return (((__force u64)a->extended_addr) >> 32) ^ 42 42 (((__force u64)a->extended_addr) & 0xffffffff); 43 43 case IEEE802154_ADDR_SHORT: 44 - return (__force u32)(a->short_addr); 44 + return (__force u32)(a->short_addr + (a->pan_id << 16)); 45 45 default: 46 46 return 0; 47 47 } 48 - } 49 - 50 - /* private device info */ 51 - struct lowpan_dev_info { 52 - struct net_device *wdev; /* wpan device ptr */ 53 - u16 fragment_tag; 54 - }; 55 - 56 - static inline struct 57 - lowpan_dev_info *lowpan_dev_info(const struct net_device *dev) 58 - { 59 - return (struct lowpan_dev_info *)lowpan_priv(dev)->priv; 60 48 } 61 49 62 50 int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
+3 -3
net/ieee802154/6lowpan/core.c
··· 148 148 return -EBUSY; 149 149 } 150 150 151 - lowpan_dev_info(ldev)->wdev = wdev; 151 + lowpan_802154_dev(ldev)->wdev = wdev; 152 152 /* Set the lowpan hardware address to the wpan hardware address. */ 153 153 memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN); 154 154 /* We need headroom for possible wpan_dev_hard_header call and tailroom ··· 173 173 174 174 static void lowpan_dellink(struct net_device *ldev, struct list_head *head) 175 175 { 176 - struct net_device *wdev = lowpan_dev_info(ldev)->wdev; 176 + struct net_device *wdev = lowpan_802154_dev(ldev)->wdev; 177 177 178 178 ASSERT_RTNL(); 179 179 ··· 184 184 185 185 static struct rtnl_link_ops lowpan_link_ops __read_mostly = { 186 186 .kind = "lowpan", 187 - .priv_size = LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev_info)), 187 + .priv_size = LOWPAN_PRIV_SIZE(sizeof(struct lowpan_802154_dev)), 188 188 .setup = lowpan_setup, 189 189 .newlink = lowpan_newlink, 190 190 .dellink = lowpan_dellink,
+7 -7
net/ieee802154/6lowpan/tx.c
··· 84 84 lowpan_alloc_frag(struct sk_buff *skb, int size, 85 85 const struct ieee802154_hdr *master_hdr, bool frag1) 86 86 { 87 - struct net_device *wdev = lowpan_dev_info(skb->dev)->wdev; 87 + struct net_device *wdev = lowpan_802154_dev(skb->dev)->wdev; 88 88 struct sk_buff *frag; 89 89 int rc; 90 90 ··· 148 148 int frag_cap, frag_len, payload_cap, rc; 149 149 int skb_unprocessed, skb_offset; 150 150 151 - frag_tag = htons(lowpan_dev_info(ldev)->fragment_tag); 152 - lowpan_dev_info(ldev)->fragment_tag++; 151 + frag_tag = htons(lowpan_802154_dev(ldev)->fragment_tag); 152 + lowpan_802154_dev(ldev)->fragment_tag++; 153 153 154 154 frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07); 155 155 frag_hdr[1] = dgram_size & 0xff; ··· 208 208 static int lowpan_header(struct sk_buff *skb, struct net_device *ldev, 209 209 u16 *dgram_size, u16 *dgram_offset) 210 210 { 211 - struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr; 211 + struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr; 212 212 struct ieee802154_addr sa, da; 213 213 struct ieee802154_mac_cb *cb = mac_cb_init(skb); 214 214 struct lowpan_addr_info info; ··· 248 248 cb->ackreq = wpan_dev->ackreq; 249 249 } 250 250 251 - return wpan_dev_hard_header(skb, lowpan_dev_info(ldev)->wdev, &da, &sa, 252 - 0); 251 + return wpan_dev_hard_header(skb, lowpan_802154_dev(ldev)->wdev, &da, 252 + &sa, 0); 253 253 } 254 254 255 255 netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) ··· 283 283 max_single = ieee802154_max_payload(&wpan_hdr); 284 284 285 285 if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) { 286 - skb->dev = lowpan_dev_info(ldev)->wdev; 286 + skb->dev = lowpan_802154_dev(ldev)->wdev; 287 287 ldev->stats.tx_packets++; 288 288 ldev->stats.tx_bytes += dgram_size; 289 289 return dev_queue_xmit(skb);
+10
net/ieee802154/nl802154.c
··· 1078 1078 if (netif_running(dev)) 1079 1079 return -EBUSY; 1080 1080 1081 + if (wpan_dev->lowpan_dev) { 1082 + if (netif_running(wpan_dev->lowpan_dev)) 1083 + return -EBUSY; 1084 + } 1085 + 1081 1086 /* don't change address fields on monitor */ 1082 1087 if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR || 1083 1088 !info->attrs[NL802154_ATTR_PAN_ID]) ··· 1113 1108 /* conflict here while tx/rx calls */ 1114 1109 if (netif_running(dev)) 1115 1110 return -EBUSY; 1111 + 1112 + if (wpan_dev->lowpan_dev) { 1113 + if (netif_running(wpan_dev->lowpan_dev)) 1114 + return -EBUSY; 1115 + } 1116 1116 1117 1117 /* don't change address fields on monitor */ 1118 1118 if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||