aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-10-05 21:34:39 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-05 21:34:39 -0400
commita4b4a2b7f98a45c71a906b1126cabea6446a9905 (patch)
tree0d501e78aeb9df90172a9435d673f31bf89290eb /net/ieee802154
parent61b37d2f54961b336a47a501e797a05df20c3b30 (diff)
parent3f08e47291879fb047d7d4464d2beaedfea4eb63 (diff)
Merge tag 'master-2014-10-02' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next
John W. Linville says: ==================== pull request: wireless-next 2014-10-03 Please pull tihs batch of updates intended for the 3.18 stream! For the iwlwifi bits, Emmanuel says: "I have here a few things that depend on the latest mac80211's changes: RRM, TPC, Quiet Period etc... Eyal keeps improving our rate control and we have a new device ID. This last patch should probably have gone to wireless.git, but at that stage, I preferred to send it to -next and CC stable." For (most of) the Atheros bits, Kalle says: "The only new feature is testmode support from me. Ben added a new method to crash the firmware with an assert for debug purposes. As usual, we have lots of smaller fixes from Michal. Matteo fixed a Kconfig dependency with debugfs. I fixed some warnings recently added to checkpatch." For the NFC bits, Samuel says: "We've had major updates for TI and ST Microelectronics drivers, and a few NCI related changes. For TI's trf7970a driver: - Target mode support for trf7970a - Suspend/resume support for trf7970a - DT properties additions to handle different quirks - A bunch of fixes for smartphone IOP related issues For ST Microelectronics' ST21NFCA and ST21NFCB drivers: - ISO15693 support for st21nfcb - checkpatch and sparse related warning fixes - Code cleanups and a few minor fixes Finally, Marvell added ISO15693 support to the NCI stack, together with a couple of NCI fixes." For the Bluetooth bits, Johan says: "This 3.18 pull request replaces the one I did on Monday ("bluetooth-next 2014-09-22", which hasn't been pulled yet). The additions since the last request are: - SCO connection fix for devices not supporting eSCO - Cleanups regarding the SCO establishment logic - Remove unnecessary return value from logging functions - Header compression fix for 6lowpan - Cleanups to the ieee802154/mrf24j40 driver Here's a copy from previous request that this one replaces: ' Here are some more patches for 3.18. They include various fixes to the btusb HCI driver, a fix for LE SMP, as well as adding Jukka to the MAINTAINERS file for generic 6LoWPAN (as requested by Alexander Aring). I've held on to this pull request a bit since we were waiting for a SCO related fix to get sorted out first. However, since the merge window is getting closer I decided not to wait for it. If we do get the fix sorted out there'll probably be a second small pull request later this week. '" And, "Unless 3.17 gets delayed this will probably be our last -next pull request for 3.18. We've got: - New Marvell hardware supportr - Multicast support for 6lowpan - Several of 6lowpan fixes & cleanups - Fix for a (false-positive) lockdep warning in L2CAP - Minor btusb cleanup" On top of all that comes the usual sort of updates to ath5k, ath9k, ath10k, brcmfmac, mwifiex, and wil6210. This time around there are also a number of rtlwifi updates to enable some new hardware and to reconcile the in-kernel drivers with some newer releases of the Realtek vendor drivers. Also of note is some device tree work for the bcma bus. Please let me know if there are problems! ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-rw-r--r--net/ieee802154/6lowpan_rtnl.c125
1 files changed, 89 insertions, 36 deletions
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c
index 5e788cdc499a..44136297b673 100644
--- a/net/ieee802154/6lowpan_rtnl.c
+++ b/net/ieee802154/6lowpan_rtnl.c
@@ -71,20 +71,42 @@ struct lowpan_dev_record {
71 struct list_head list; 71 struct list_head list;
72}; 72};
73 73
74/* don't save pan id, it's intra pan */
75struct lowpan_addr {
76 u8 mode;
77 union {
78 /* IPv6 needs big endian here */
79 __be64 extended_addr;
80 __be16 short_addr;
81 } u;
82};
83
84struct lowpan_addr_info {
85 struct lowpan_addr daddr;
86 struct lowpan_addr saddr;
87};
88
74static inline struct 89static inline struct
75lowpan_dev_info *lowpan_dev_info(const struct net_device *dev) 90lowpan_dev_info *lowpan_dev_info(const struct net_device *dev)
76{ 91{
77 return netdev_priv(dev); 92 return netdev_priv(dev);
78} 93}
79 94
95static inline struct
96lowpan_addr_info *lowpan_skb_priv(const struct sk_buff *skb)
97{
98 WARN_ON_ONCE(skb_headroom(skb) < sizeof(struct lowpan_addr_info));
99 return (struct lowpan_addr_info *)(skb->data -
100 sizeof(struct lowpan_addr_info));
101}
102
80static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev, 103static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
81 unsigned short type, const void *_daddr, 104 unsigned short type, const void *_daddr,
82 const void *_saddr, unsigned int len) 105 const void *_saddr, unsigned int len)
83{ 106{
84 const u8 *saddr = _saddr; 107 const u8 *saddr = _saddr;
85 const u8 *daddr = _daddr; 108 const u8 *daddr = _daddr;
86 struct ieee802154_addr sa, da; 109 struct lowpan_addr_info *info;
87 struct ieee802154_mac_cb *cb = mac_cb_init(skb);
88 110
89 /* TODO: 111 /* TODO:
90 * if this package isn't ipv6 one, where should it be routed? 112 * if this package isn't ipv6 one, where should it be routed?
@@ -98,41 +120,17 @@ static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
98 raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8); 120 raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
99 raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8); 121 raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
100 122
101 lowpan_header_compress(skb, dev, type, daddr, saddr, len); 123 info = lowpan_skb_priv(skb);
102
103 /* NOTE1: I'm still unsure about the fact that compression and WPAN
104 * header are created here and not later in the xmit. So wait for
105 * an opinion of net maintainers.
106 */
107 /* NOTE2: to be absolutely correct, we must derive PANid information
108 * from MAC subif of the 'dev' and 'real_dev' network devices, but
109 * this isn't implemented in mainline yet, so currently we assign 0xff
110 */
111 cb->type = IEEE802154_FC_TYPE_DATA;
112
113 /* prepare wpan address data */
114 sa.mode = IEEE802154_ADDR_LONG;
115 sa.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev);
116 sa.extended_addr = ieee802154_devaddr_from_raw(saddr);
117
118 /* intra-PAN communications */
119 da.pan_id = sa.pan_id;
120
121 /* if the destination address is the broadcast address, use the
122 * corresponding short address
123 */
124 if (lowpan_is_addr_broadcast(daddr)) {
125 da.mode = IEEE802154_ADDR_SHORT;
126 da.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
127 } else {
128 da.mode = IEEE802154_ADDR_LONG;
129 da.extended_addr = ieee802154_devaddr_from_raw(daddr);
130 }
131 124
132 cb->ackreq = !lowpan_is_addr_broadcast(daddr); 125 /* TODO: Currently we only support extended_addr */
126 info->daddr.mode = IEEE802154_ADDR_LONG;
127 memcpy(&info->daddr.u.extended_addr, daddr,
128 sizeof(info->daddr.u.extended_addr));
129 info->saddr.mode = IEEE802154_ADDR_LONG;
130 memcpy(&info->saddr.u.extended_addr, saddr,
131 sizeof(info->daddr.u.extended_addr));
133 132
134 return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev, 133 return 0;
135 type, (void *)&da, (void *)&sa, 0);
136} 134}
137 135
138static int lowpan_give_skb_to_devices(struct sk_buff *skb, 136static int lowpan_give_skb_to_devices(struct sk_buff *skb,
@@ -330,13 +328,68 @@ err:
330 return rc; 328 return rc;
331} 329}
332 330
331static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
332{
333 struct ieee802154_addr sa, da;
334 struct ieee802154_mac_cb *cb = mac_cb_init(skb);
335 struct lowpan_addr_info info;
336 void *daddr, *saddr;
337
338 memcpy(&info, lowpan_skb_priv(skb), sizeof(info));
339
340 /* TODO: Currently we only support extended_addr */
341 daddr = &info.daddr.u.extended_addr;
342 saddr = &info.saddr.u.extended_addr;
343
344 lowpan_header_compress(skb, dev, ETH_P_IPV6, daddr, saddr, skb->len);
345
346 cb->type = IEEE802154_FC_TYPE_DATA;
347
348 /* prepare wpan address data */
349 sa.mode = IEEE802154_ADDR_LONG;
350 sa.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev);
351 sa.extended_addr = ieee802154_devaddr_from_raw(saddr);
352
353 /* intra-PAN communications */
354 da.pan_id = sa.pan_id;
355
356 /* if the destination address is the broadcast address, use the
357 * corresponding short address
358 */
359 if (lowpan_is_addr_broadcast((const u8 *)daddr)) {
360 da.mode = IEEE802154_ADDR_SHORT;
361 da.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
362 cb->ackreq = false;
363 } else {
364 da.mode = IEEE802154_ADDR_LONG;
365 da.extended_addr = ieee802154_devaddr_from_raw(daddr);
366 cb->ackreq = true;
367 }
368
369 return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
370 ETH_P_IPV6, (void *)&da, (void *)&sa, 0);
371}
372
333static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev) 373static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
334{ 374{
335 struct ieee802154_hdr wpan_hdr; 375 struct ieee802154_hdr wpan_hdr;
336 int max_single; 376 int max_single, ret;
337 377
338 pr_debug("package xmit\n"); 378 pr_debug("package xmit\n");
339 379
380 /* We must take a copy of the skb before we modify/replace the ipv6
381 * header as the header could be used elsewhere
382 */
383 skb = skb_unshare(skb, GFP_ATOMIC);
384 if (!skb)
385 return NET_XMIT_DROP;
386
387 ret = lowpan_header(skb, dev);
388 if (ret < 0) {
389 kfree_skb(skb);
390 return NET_XMIT_DROP;
391 }
392
340 if (ieee802154_hdr_peek(skb, &wpan_hdr) < 0) { 393 if (ieee802154_hdr_peek(skb, &wpan_hdr) < 0) {
341 kfree_skb(skb); 394 kfree_skb(skb);
342 return NET_XMIT_DROP; 395 return NET_XMIT_DROP;