aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac802154
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2014-11-19 05:32:12 -0500
committerJames Morris <james.l.morris@oracle.com>2014-11-19 05:32:12 -0500
commitb10778a00d40b3d9fdaaf5891e802794781ff71c (patch)
tree6ba4cbac86eecedc3f30650e7f764ecf00c83898 /net/mac802154
parent594081ee7145cc30a3977cb4e218f81213b63dc5 (diff)
parentbfe01a5ba2490f299e1d2d5508cbbbadd897bbe9 (diff)
Merge commit 'v3.17' into next
Diffstat (limited to 'net/mac802154')
-rw-r--r--net/mac802154/ieee802154_dev.c70
-rw-r--r--net/mac802154/llsec.c1
-rw-r--r--net/mac802154/mib.c7
-rw-r--r--net/mac802154/tx.c1
-rw-r--r--net/mac802154/wpan.c6
5 files changed, 64 insertions, 21 deletions
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 2cf66d885e68..b36b2b996578 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -143,6 +143,7 @@ static void
143mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) 143mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
144{ 144{
145 struct mac802154_sub_if_data *sdata; 145 struct mac802154_sub_if_data *sdata;
146
146 ASSERT_RTNL(); 147 ASSERT_RTNL();
147 148
148 sdata = netdev_priv(dev); 149 sdata = netdev_priv(dev);
@@ -166,11 +167,13 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
166 switch (type) { 167 switch (type) {
167 case IEEE802154_DEV_MONITOR: 168 case IEEE802154_DEV_MONITOR:
168 dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), 169 dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
169 name, mac802154_monitor_setup); 170 name, NET_NAME_UNKNOWN,
171 mac802154_monitor_setup);
170 break; 172 break;
171 case IEEE802154_DEV_WPAN: 173 case IEEE802154_DEV_WPAN:
172 dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), 174 dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
173 name, mac802154_wpan_setup); 175 name, NET_NAME_UNKNOWN,
176 mac802154_wpan_setup);
174 break; 177 break;
175 default: 178 default:
176 dev = NULL; 179 dev = NULL;
@@ -276,7 +279,8 @@ ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops)
276 } 279 }
277 280
278 priv = wpan_phy_priv(phy); 281 priv = wpan_phy_priv(phy);
279 priv->hw.phy = priv->phy = phy; 282 priv->phy = phy;
283 priv->hw.phy = priv->phy;
280 priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); 284 priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
281 priv->ops = ops; 285 priv->ops = ops;
282 286
@@ -302,29 +306,61 @@ EXPORT_SYMBOL(ieee802154_free_device);
302int ieee802154_register_device(struct ieee802154_dev *dev) 306int ieee802154_register_device(struct ieee802154_dev *dev)
303{ 307{
304 struct mac802154_priv *priv = mac802154_to_priv(dev); 308 struct mac802154_priv *priv = mac802154_to_priv(dev);
305 int rc = -ENOMEM; 309 int rc = -ENOSYS;
310
311 if (dev->flags & IEEE802154_HW_TXPOWER) {
312 if (!priv->ops->set_txpower)
313 goto out;
314
315 priv->phy->set_txpower = mac802154_set_txpower;
316 }
317
318 if (dev->flags & IEEE802154_HW_LBT) {
319 if (!priv->ops->set_lbt)
320 goto out;
321
322 priv->phy->set_lbt = mac802154_set_lbt;
323 }
324
325 if (dev->flags & IEEE802154_HW_CCA_MODE) {
326 if (!priv->ops->set_cca_mode)
327 goto out;
328
329 priv->phy->set_cca_mode = mac802154_set_cca_mode;
330 }
331
332 if (dev->flags & IEEE802154_HW_CCA_ED_LEVEL) {
333 if (!priv->ops->set_cca_ed_level)
334 goto out;
335
336 priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
337 }
338
339 if (dev->flags & IEEE802154_HW_CSMA_PARAMS) {
340 if (!priv->ops->set_csma_params)
341 goto out;
342
343 priv->phy->set_csma_params = mac802154_set_csma_params;
344 }
345
346 if (dev->flags & IEEE802154_HW_FRAME_RETRIES) {
347 if (!priv->ops->set_frame_retries)
348 goto out;
349
350 priv->phy->set_frame_retries = mac802154_set_frame_retries;
351 }
306 352
307 priv->dev_workqueue = 353 priv->dev_workqueue =
308 create_singlethread_workqueue(wpan_phy_name(priv->phy)); 354 create_singlethread_workqueue(wpan_phy_name(priv->phy));
309 if (!priv->dev_workqueue) 355 if (!priv->dev_workqueue) {
356 rc = -ENOMEM;
310 goto out; 357 goto out;
358 }
311 359
312 wpan_phy_set_dev(priv->phy, priv->hw.parent); 360 wpan_phy_set_dev(priv->phy, priv->hw.parent);
313 361
314 priv->phy->add_iface = mac802154_add_iface; 362 priv->phy->add_iface = mac802154_add_iface;
315 priv->phy->del_iface = mac802154_del_iface; 363 priv->phy->del_iface = mac802154_del_iface;
316 if (priv->ops->set_txpower)
317 priv->phy->set_txpower = mac802154_set_txpower;
318 if (priv->ops->set_lbt)
319 priv->phy->set_lbt = mac802154_set_lbt;
320 if (priv->ops->set_cca_mode)
321 priv->phy->set_cca_mode = mac802154_set_cca_mode;
322 if (priv->ops->set_cca_ed_level)
323 priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
324 if (priv->ops->set_csma_params)
325 priv->phy->set_csma_params = mac802154_set_csma_params;
326 if (priv->ops->set_frame_retries)
327 priv->phy->set_frame_retries = mac802154_set_frame_retries;
328 364
329 rc = wpan_phy_register(priv->phy); 365 rc = wpan_phy_register(priv->phy);
330 if (rc < 0) 366 if (rc < 0)
diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c
index 1456f73b02b9..457058142098 100644
--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -538,6 +538,7 @@ static int llsec_recover_addr(struct mac802154_llsec *sec,
538 struct ieee802154_addr *addr) 538 struct ieee802154_addr *addr)
539{ 539{
540 __le16 caddr = sec->params.coord_shortaddr; 540 __le16 caddr = sec->params.coord_shortaddr;
541
541 addr->pan_id = sec->params.pan_id; 542 addr->pan_id = sec->params.pan_id;
542 543
543 if (caddr == cpu_to_le16(IEEE802154_ADDR_BROADCAST)) { 544 if (caddr == cpu_to_le16(IEEE802154_ADDR_BROADCAST)) {
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index 15aa2f2b03a7..868a040fd422 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -175,9 +175,9 @@ static void phy_chan_notify(struct work_struct *work)
175 175
176 mutex_lock(&priv->hw->phy->pib_lock); 176 mutex_lock(&priv->hw->phy->pib_lock);
177 res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); 177 res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
178 if (res) 178 if (res) {
179 pr_debug("set_channel failed\n"); 179 pr_debug("set_channel failed\n");
180 else { 180 } else {
181 priv->hw->phy->current_channel = priv->chan; 181 priv->hw->phy->current_channel = priv->chan;
182 priv->hw->phy->current_page = priv->page; 182 priv->hw->phy->current_page = priv->page;
183 } 183 }
@@ -210,8 +210,9 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
210 INIT_WORK(&work->work, phy_chan_notify); 210 INIT_WORK(&work->work, phy_chan_notify);
211 work->dev = dev; 211 work->dev = dev;
212 queue_work(priv->hw->dev_workqueue, &work->work); 212 queue_work(priv->hw->dev_workqueue, &work->work);
213 } else 213 } else {
214 mutex_unlock(&priv->hw->phy->pib_lock); 214 mutex_unlock(&priv->hw->phy->pib_lock);
215 }
215} 216}
216 217
217 218
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 6d1647399d4f..8124353646ae 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -98,6 +98,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
98 if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) { 98 if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
99 u16 crc = crc_ccitt(0, skb->data, skb->len); 99 u16 crc = crc_ccitt(0, skb->data, skb->len);
100 u8 *data = skb_put(skb, 2); 100 u8 *data = skb_put(skb, 2);
101
101 data[0] = crc & 0xff; 102 data[0] = crc & 0xff;
102 data[1] = crc >> 8; 103 data[1] = crc >> 8;
103 } 104 }
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index 3c3069fd6971..547838822d5e 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -462,7 +462,10 @@ mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb,
462 skb->pkt_type = PACKET_OTHERHOST; 462 skb->pkt_type = PACKET_OTHERHOST;
463 break; 463 break;
464 default: 464 default:
465 break; 465 spin_unlock_bh(&sdata->mib_lock);
466 pr_debug("invalid dest mode\n");
467 kfree_skb(skb);
468 return NET_RX_DROP;
466 } 469 }
467 470
468 spin_unlock_bh(&sdata->mib_lock); 471 spin_unlock_bh(&sdata->mib_lock);
@@ -573,6 +576,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
573 ret = mac802154_parse_frame_start(skb, &hdr); 576 ret = mac802154_parse_frame_start(skb, &hdr);
574 if (ret) { 577 if (ret) {
575 pr_debug("got invalid frame\n"); 578 pr_debug("got invalid frame\n");
579 kfree_skb(skb);
576 return; 580 return;
577 } 581 }
578 582