linux-wpan.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
@ 2014-08-12 13:14 Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 01/11] ieee802154: rename ieee802154_dev to ieee802154_hw Alexander Aring
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

Hi,

this is the first part to make the mac802154/ieee802154 implementation like
wireless. There is much things do to but at around 10 patches I will send
a complete patch series of my work to make the review easier.

This patch renames more variables/structs like it's also available in wireless.
I think this was done also in the current implementation but all variables
was renamed and now I get confuse about priv/ipriv (I call it priv variable hell)
and netdev/ieee802154_dev.

We rename the ieee802154_dev to ieee802154_hw, like a ieee80211_hw.

The mac802154_priv is now ieee802154_local, like a ieee80211_local.
The mac802154_sub_if_data is now ieee802154_sub_if_data.

Also change the variables name to this so there should never be a variable priv
and you don't know if it's a mac802154_sub_if_data or mac802154_priv. That's
confusing me so much sometimes. Now it's also clear to see mutliple dereferencing.
Please send patches for this, if you like.

The next step is the frame parsing like wireless and interface registration like
wireless.


The last one replace the receiving workqueue with a tasklet, which is also used
in wireless. This have a less overhead and I removed a kmalloc call in this hot
path.

- Alex

Alexander Aring (11):
  ieee802154: rename ieee802154_dev to ieee802154_hw
  mac802154: rename ieee802154_dev.c to main.c
  mac802154: remove not functional monitor device
  ieee802154: add new interface types
  nl802154: add missing endif comment
  mac802154: rename mac802154_priv to ieee802154_local
  mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data
  mac802154: rename mac802154.h to ieee802154_i.h
  mac802154: rename hw subif_data variable to local
  mac802154: use hw_to_local
  mac802154: rx: use tasklet instead workqueue

 drivers/net/ieee802154/at86rf230.c |  90 ++++----
 drivers/net/ieee802154/cc2520.c    |  50 ++---
 drivers/net/ieee802154/mrf24j40.c  |  48 ++--
 include/linux/nl802154.h           |  15 +-
 include/net/mac802154.h            |  46 ++--
 net/ieee802154/nl-phy.c            |   4 +-
 net/mac802154/Makefile             |   4 +-
 net/mac802154/ieee802154_dev.c     | 415 -----------------------------------
 net/mac802154/ieee802154_i.h       | 178 +++++++++++++++
 net/mac802154/llsec.c              |   2 +-
 net/mac802154/mac802154.h          | 172 ---------------
 net/mac802154/mac_cmd.c            |   6 +-
 net/mac802154/main.c               | 435 +++++++++++++++++++++++++++++++++++++
 net/mac802154/mib.c                | 207 +++++++++---------
 net/mac802154/monitor.c            | 117 ----------
 net/mac802154/rx.c                 |  60 ++---
 net/mac802154/tx.c                 |  42 ++--
 net/mac802154/wpan.c               | 145 +++++++------
 18 files changed, 958 insertions(+), 1078 deletions(-)
 delete mode 100644 net/mac802154/ieee802154_dev.c
 create mode 100644 net/mac802154/ieee802154_i.h
 delete mode 100644 net/mac802154/mac802154.h
 create mode 100644 net/mac802154/main.c
 delete mode 100644 net/mac802154/monitor.c

-- 
2.0.3


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 01/11] ieee802154: rename ieee802154_dev to ieee802154_hw
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 02/11] mac802154: rename ieee802154_dev.c to main.c Alexander Aring
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

The identical struct of the wireless stack implementation is named
ieee80211_hw. This is useful to name the variable hw instead of get
confusing with netdev dev variable.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 90 +++++++++++++++++++-------------------
 drivers/net/ieee802154/cc2520.c    | 50 ++++++++++-----------
 drivers/net/ieee802154/mrf24j40.c  | 48 ++++++++++----------
 include/net/mac802154.h            | 44 +++++++++----------
 net/mac802154/ieee802154_dev.c     | 34 +++++++-------
 net/mac802154/mac802154.h          |  2 +-
 net/mac802154/rx.c                 | 12 ++---
 7 files changed, 140 insertions(+), 140 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index c9d2a75..c2fc833 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -79,7 +79,7 @@ struct at86rf230_state_change {
 struct at86rf230_local {
 	struct spi_device *spi;
 
-	struct ieee802154_dev *dev;
+	struct ieee802154_hw *hw;
 	struct at86rf2xx_chip_data *data;
 	struct regmap *regmap;
 
@@ -805,7 +805,7 @@ at86rf230_rx(struct at86rf230_local *lp,
 	/* We do not put CRC into the frame */
 	skb_trim(skb, len - 2);
 
-	ieee802154_rx_irqsafe(lp->dev, skb, lqi);
+	ieee802154_rx_irqsafe(lp->hw, skb, lqi);
 }
 
 static void
@@ -969,9 +969,9 @@ at86rf230_xmit_tx_on(void *context)
 }
 
 static int
-at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff *skb)
+at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 	struct at86rf230_state_change *ctx = &lp->tx;
 
 	void (*tx_complete)(void *context) = at86rf230_write_frame;
@@ -1013,7 +1013,7 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff *skb)
 }
 
 static int
-at86rf230_ed(struct ieee802154_dev *dev, u8 *level)
+at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
 {
 	might_sleep();
 	BUG_ON(!level);
@@ -1022,15 +1022,15 @@ at86rf230_ed(struct ieee802154_dev *dev, u8 *level)
 }
 
 static int
-at86rf230_start(struct ieee802154_dev *dev)
+at86rf230_start(struct ieee802154_hw *hw)
 {
-	return at86rf230_sync_state_change(dev->priv, STATE_RX_AACK_ON);
+	return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
 }
 
 static void
-at86rf230_stop(struct ieee802154_dev *dev)
+at86rf230_stop(struct ieee802154_hw *hw)
 {
-	at86rf230_sync_state_change(dev->priv, STATE_FORCE_TRX_OFF);
+	at86rf230_sync_state_change(hw->priv, STATE_FORCE_TRX_OFF);
 }
 
 static int
@@ -1065,15 +1065,15 @@ at86rf212_set_channel(struct at86rf230_local *lp, int page, int channel)
 }
 
 static int
-at86rf230_channel(struct ieee802154_dev *dev, int page, int channel)
+at86rf230_channel(struct ieee802154_hw *hw, int page, int channel)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 	int rc;
 
 	might_sleep();
 
 	if (page < 0 || page > 31 ||
-	    !(lp->dev->phy->channels_supported[page] & BIT(channel))) {
+	    !(lp->hw->phy->channels_supported[page] & BIT(channel))) {
 		WARN_ON(1);
 		return -EINVAL;
 	}
@@ -1085,18 +1085,18 @@ at86rf230_channel(struct ieee802154_dev *dev, int page, int channel)
 	/* Wait for PLL */
 	usleep_range(lp->data->t_channel_switch,
 		     lp->data->t_channel_switch + 10);
-	dev->phy->current_channel = channel;
-	dev->phy->current_page = page;
+	hw->phy->current_channel = channel;
+	hw->phy->current_page = page;
 
 	return 0;
 }
 
 static int
-at86rf230_set_hw_addr_filt(struct ieee802154_dev *dev,
+at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
 			   struct ieee802154_hw_addr_filt *filt,
 			   unsigned long changed)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 
 	if (changed & IEEE802515_AFILT_SADDR_CHANGED) {
 		u16 addr = le16_to_cpu(filt->short_addr);
@@ -1139,9 +1139,9 @@ at86rf230_set_hw_addr_filt(struct ieee802154_dev *dev,
 }
 
 static int
-at86rf230_set_txpower(struct ieee802154_dev *dev, int db)
+at86rf230_set_txpower(struct ieee802154_hw *hw, int db)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 
 	/* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five
 	 * bits decrease power in 1dB steps. 0x60 represents extra PA gain of
@@ -1158,17 +1158,17 @@ at86rf230_set_txpower(struct ieee802154_dev *dev, int db)
 }
 
 static int
-at86rf230_set_lbt(struct ieee802154_dev *dev, bool on)
+at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 
 	return at86rf230_write_subreg(lp, SR_CSMA_LBT_MODE, on);
 }
 
 static int
-at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode)
+at86rf230_set_cca_mode(struct ieee802154_hw *hw, u8 mode)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 
 	return at86rf230_write_subreg(lp, SR_CCA_MODE, mode);
 }
@@ -1186,9 +1186,9 @@ at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level)
 }
 
 static int
-at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
+at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 level)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 
 	if (level < lp->data->rssi_base_val || level > 30)
 		return -EINVAL;
@@ -1198,10 +1198,10 @@ at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
 }
 
 static int
-at86rf230_set_csma_params(struct ieee802154_dev *dev, u8 min_be, u8 max_be,
+at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
 			  u8 retries)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 	int rc;
 
 	if (min_be > max_be || max_be > 8 || retries > 5)
@@ -1219,9 +1219,9 @@ at86rf230_set_csma_params(struct ieee802154_dev *dev, u8 min_be, u8 max_be,
 }
 
 static int
-at86rf230_set_frame_retries(struct ieee802154_dev *dev, s8 retries)
+at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
 {
-	struct at86rf230_local *lp = dev->priv;
+	struct at86rf230_local *lp = hw->priv;
 	int rc = 0;
 
 	if (retries < -1 || retries > 15)
@@ -1409,8 +1409,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)
 		return -EINVAL;
 	}
 
-	lp->dev->extra_tx_headroom = 0;
-	lp->dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK |
+	lp->hw->extra_tx_headroom = 0;
+	lp->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK |
 			 IEEE802154_HW_TXPOWER | IEEE802154_HW_CSMA;
 
 	switch (part) {
@@ -1421,15 +1421,15 @@ at86rf230_detect_device(struct at86rf230_local *lp)
 	case 3:
 		chip = "at86rf231";
 		lp->data = &at86rf231_data;
-		lp->dev->phy->channels_supported[0] = 0x7FFF800;
+		lp->hw->phy->channels_supported[0] = 0x7FFF800;
 		break;
 	case 7:
 		chip = "at86rf212";
 		if (version == 1) {
 			lp->data = &at86rf212_data;
-			lp->dev->flags |= IEEE802154_HW_LBT;
-			lp->dev->phy->channels_supported[0] = 0x00007FF;
-			lp->dev->phy->channels_supported[2] = 0x00007FF;
+			lp->hw->flags |= IEEE802154_HW_LBT;
+			lp->hw->phy->channels_supported[0] = 0x00007FF;
+			lp->hw->phy->channels_supported[2] = 0x00007FF;
 		} else {
 			rc = -ENOTSUPP;
 		}
@@ -1437,7 +1437,7 @@ at86rf230_detect_device(struct at86rf230_local *lp)
 	case 11:
 		chip = "at86rf233";
 		lp->data = &at86rf233_data;
-		lp->dev->phy->channels_supported[0] = 0x7FFF800;
+		lp->hw->phy->channels_supported[0] = 0x7FFF800;
 		break;
 	default:
 		chip = "unkown";
@@ -1478,7 +1478,7 @@ at86rf230_setup_spi_messages(struct at86rf230_local *lp)
 static int at86rf230_probe(struct spi_device *spi)
 {
 	struct at86rf230_platform_data *pdata;
-	struct ieee802154_dev *dev;
+	struct ieee802154_hw *hw;
 	struct at86rf230_local *lp;
 	unsigned int status;
 	int rc, irq_type;
@@ -1517,14 +1517,14 @@ static int at86rf230_probe(struct spi_device *spi)
 		usleep_range(120, 240);
 	}
 
-	dev = ieee802154_alloc_device(sizeof(*lp), &at86rf230_ops);
-	if (!dev)
+	hw = ieee802154_alloc_hw(sizeof(*lp), &at86rf230_ops);
+	if (!hw)
 		return -ENOMEM;
 
-	lp = dev->priv;
-	lp->dev = dev;
+	lp = hw->priv;
+	lp->hw = hw;
 	lp->spi = spi;
-	dev->parent = &spi->dev;
+	hw->parent = &spi->dev;
 
 	lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
 	if (IS_ERR(lp->regmap)) {
@@ -1564,14 +1564,14 @@ static int at86rf230_probe(struct spi_device *spi)
 	if (rc)
 		goto free_dev;
 
-	rc = ieee802154_register_device(lp->dev);
+	rc = ieee802154_register_hw(lp->hw);
 	if (rc)
 		goto free_dev;
 
 	return rc;
 
 free_dev:
-	ieee802154_free_device(lp->dev);
+	ieee802154_free_hw(lp->hw);
 
 	return rc;
 }
@@ -1582,8 +1582,8 @@ static int at86rf230_remove(struct spi_device *spi)
 
 	/* mask all at86rf230 irq's */
 	at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
-	ieee802154_unregister_device(lp->dev);
-	ieee802154_free_device(lp->dev);
+	ieee802154_unregister_hw(lp->hw);
+	ieee802154_free_hw(lp->hw);
 	dev_dbg(&spi->dev, "unregistered at86rf230\n");
 
 	return 0;
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 8a5ac7a..defd954 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -193,7 +193,7 @@
 /* Driver private information */
 struct cc2520_private {
 	struct spi_device *spi;		/* SPI device structure */
-	struct ieee802154_dev *dev;	/* IEEE-802.15.4 device */
+	struct ieee802154_hw *hw;	/* IEEE-802.15.4 device */
 	u8 *buf;			/* SPI TX/Rx data buffer */
 	struct mutex buffer_mutex;	/* SPI buffer mutex */
 	bool is_tx;			/* Flag for sync b/w Tx and Rx */
@@ -453,20 +453,20 @@ cc2520_read_rxfifo(struct cc2520_private *priv, u8 *data, u8 len, u8 *lqi)
 	return status;
 }
 
-static int cc2520_start(struct ieee802154_dev *dev)
+static int cc2520_start(struct ieee802154_hw *hw)
 {
-	return cc2520_cmd_strobe(dev->priv, CC2520_CMD_SRXON);
+	return cc2520_cmd_strobe(hw->priv, CC2520_CMD_SRXON);
 }
 
-static void cc2520_stop(struct ieee802154_dev *dev)
+static void cc2520_stop(struct ieee802154_hw *hw)
 {
-	cc2520_cmd_strobe(dev->priv, CC2520_CMD_SRFOFF);
+	cc2520_cmd_strobe(hw->priv, CC2520_CMD_SRFOFF);
 }
 
 static int
-cc2520_tx(struct ieee802154_dev *dev, struct sk_buff *skb)
+cc2520_tx(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
-	struct cc2520_private *priv = dev->priv;
+	struct cc2520_private *priv = hw->priv;
 	unsigned long flags;
 	int rc;
 	u8 status = 0;
@@ -536,7 +536,7 @@ static int cc2520_rx(struct cc2520_private *priv)
 
 	skb_trim(skb, skb->len - 2);
 
-	ieee802154_rx_irqsafe(priv->dev, skb, lqi);
+	ieee802154_rx_irqsafe(priv->hw, skb, lqi);
 
 	dev_vdbg(&priv->spi->dev, "RXFIFO: %x %x\n", len, lqi);
 
@@ -544,9 +544,9 @@ static int cc2520_rx(struct cc2520_private *priv)
 }
 
 static int
-cc2520_ed(struct ieee802154_dev *dev, u8 *level)
+cc2520_ed(struct ieee802154_hw *hw, u8 *level)
 {
-	struct cc2520_private *priv = dev->priv;
+	struct cc2520_private *priv = hw->priv;
 	u8 status = 0xff;
 	u8 rssi;
 	int ret;
@@ -569,9 +569,9 @@ cc2520_ed(struct ieee802154_dev *dev, u8 *level)
 }
 
 static int
-cc2520_set_channel(struct ieee802154_dev *dev, int page, int channel)
+cc2520_set_channel(struct ieee802154_hw *hw, int page, int channel)
 {
-	struct cc2520_private *priv = dev->priv;
+	struct cc2520_private *priv = hw->priv;
 	int ret;
 
 	might_sleep();
@@ -588,10 +588,10 @@ cc2520_set_channel(struct ieee802154_dev *dev, int page, int channel)
 }
 
 static int
-cc2520_filter(struct ieee802154_dev *dev,
+cc2520_filter(struct ieee802154_hw *hw,
 	      struct ieee802154_hw_addr_filt *filt, unsigned long changed)
 {
-	struct cc2520_private *priv = dev->priv;
+	struct cc2520_private *priv = hw->priv;
 
 	if (changed & IEEE802515_AFILT_PANID_CHANGED) {
 		u16 panid = le16_to_cpu(filt->pan_id);
@@ -645,27 +645,27 @@ static int cc2520_register(struct cc2520_private *priv)
 {
 	int ret = -ENOMEM;
 
-	priv->dev = ieee802154_alloc_device(sizeof(*priv), &cc2520_ops);
-	if (!priv->dev)
+	priv->hw = ieee802154_alloc_hw(sizeof(*priv), &cc2520_ops);
+	if (!priv->hw)
 		goto err_ret;
 
-	priv->dev->priv = priv;
-	priv->dev->parent = &priv->spi->dev;
-	priv->dev->extra_tx_headroom = 0;
+	priv->hw->priv = priv;
+	priv->hw->parent = &priv->spi->dev;
+	priv->hw->extra_tx_headroom = 0;
 
 	/* We do support only 2.4 Ghz */
-	priv->dev->phy->channels_supported[0] = 0x7FFF800;
-	priv->dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
+	priv->hw->phy->channels_supported[0] = 0x7FFF800;
+	priv->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
 
 	dev_vdbg(&priv->spi->dev, "registered cc2520\n");
-	ret = ieee802154_register_device(priv->dev);
+	ret = ieee802154_register_hw(priv->hw);
 	if (ret)
 		goto err_free_device;
 
 	return 0;
 
 err_free_device:
-	ieee802154_free_device(priv->dev);
+	ieee802154_free_hw(priv->hw);
 err_ret:
 	return ret;
 }
@@ -1002,8 +1002,8 @@ static int cc2520_remove(struct spi_device *spi)
 	mutex_destroy(&priv->buffer_mutex);
 	flush_work(&priv->fifop_irqwork);
 
-	ieee802154_unregister_device(priv->dev);
-	ieee802154_free_device(priv->dev);
+	ieee802154_unregister_hw(priv->hw);
+	ieee802154_free_hw(priv->hw);
 
 	return 0;
 }
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 9e6a124..5189dad 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -78,7 +78,7 @@
 /* Device Private Data */
 struct mrf24j40 {
 	struct spi_device *spi;
-	struct ieee802154_dev *dev;
+	struct ieee802154_hw *hw;
 
 	struct mutex buffer_mutex; /* only used to protect buf */
 	struct completion tx_complete;
@@ -331,9 +331,9 @@ out:
 	return ret;
 }
 
-static int mrf24j40_tx(struct ieee802154_dev *dev, struct sk_buff *skb)
+static int mrf24j40_tx(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
-	struct mrf24j40 *devrec = dev->priv;
+	struct mrf24j40 *devrec = hw->priv;
 	u8 val;
 	int ret = 0;
 
@@ -382,7 +382,7 @@ err:
 	return ret;
 }
 
-static int mrf24j40_ed(struct ieee802154_dev *dev, u8 *level)
+static int mrf24j40_ed(struct ieee802154_hw *hw, u8 *level)
 {
 	/* TODO: */
 	printk(KERN_WARNING "mrf24j40: ed not implemented\n");
@@ -390,9 +390,9 @@ static int mrf24j40_ed(struct ieee802154_dev *dev, u8 *level)
 	return 0;
 }
 
-static int mrf24j40_start(struct ieee802154_dev *dev)
+static int mrf24j40_start(struct ieee802154_hw *hw)
 {
-	struct mrf24j40 *devrec = dev->priv;
+	struct mrf24j40 *devrec = hw->priv;
 	u8 val;
 	int ret;
 
@@ -407,9 +407,9 @@ static int mrf24j40_start(struct ieee802154_dev *dev)
 	return 0;
 }
 
-static void mrf24j40_stop(struct ieee802154_dev *dev)
+static void mrf24j40_stop(struct ieee802154_hw *hw)
 {
-	struct mrf24j40 *devrec = dev->priv;
+	struct mrf24j40 *devrec = hw->priv;
 	u8 val;
 	int ret;
 	dev_dbg(printdev(devrec), "stop\n");
@@ -423,10 +423,10 @@ static void mrf24j40_stop(struct ieee802154_dev *dev)
 	return;
 }
 
-static int mrf24j40_set_channel(struct ieee802154_dev *dev,
+static int mrf24j40_set_channel(struct ieee802154_hw *hw,
 				int page, int channel)
 {
-	struct mrf24j40 *devrec = dev->priv;
+	struct mrf24j40 *devrec = hw->priv;
 	u8 val;
 	int ret;
 
@@ -454,11 +454,11 @@ static int mrf24j40_set_channel(struct ieee802154_dev *dev,
 	return 0;
 }
 
-static int mrf24j40_filter(struct ieee802154_dev *dev,
+static int mrf24j40_filter(struct ieee802154_hw *hw,
 			   struct ieee802154_hw_addr_filt *filt,
 			   unsigned long changed)
 {
-	struct mrf24j40 *devrec = dev->priv;
+	struct mrf24j40 *devrec = hw->priv;
 
 	dev_dbg(printdev(devrec), "filter\n");
 
@@ -562,7 +562,7 @@ static int mrf24j40_handle_rx(struct mrf24j40 *devrec)
 	/* TODO: Other drivers call ieee20154_rx_irqsafe() here (eg: cc2040,
 	 * also from a workqueue).  I think irqsafe is not necessary here.
 	 * Can someone confirm? */
-	ieee802154_rx_irqsafe(devrec->dev, skb, lqi);
+	ieee802154_rx_irqsafe(devrec->hw, skb, lqi);
 
 	dev_dbg(printdev(devrec), "RX Handled\n");
 
@@ -721,17 +721,17 @@ static int mrf24j40_probe(struct spi_device *spi)
 
 	/* Register with the 802154 subsystem */
 
-	devrec->dev = ieee802154_alloc_device(0, &mrf24j40_ops);
-	if (!devrec->dev)
+	devrec->hw = ieee802154_alloc_hw(0, &mrf24j40_ops);
+	if (!devrec->hw)
 		goto err_ret;
 
-	devrec->dev->priv = devrec;
-	devrec->dev->parent = &devrec->spi->dev;
-	devrec->dev->phy->channels_supported[0] = CHANNEL_MASK;
-	devrec->dev->flags = IEEE802154_HW_OMIT_CKSUM|IEEE802154_HW_AACK;
+	devrec->hw->priv = devrec;
+	devrec->hw->parent = &devrec->spi->dev;
+	devrec->hw->phy->channels_supported[0] = CHANNEL_MASK;
+	devrec->hw->flags = IEEE802154_HW_OMIT_CKSUM|IEEE802154_HW_AACK;
 
 	dev_dbg(printdev(devrec), "registered mrf24j40\n");
-	ret = ieee802154_register_device(devrec->dev);
+	ret = ieee802154_register_hw(devrec->hw);
 	if (ret)
 		goto err_register_device;
 
@@ -756,9 +756,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 
 err_irq:
 err_hw_init:
-	ieee802154_unregister_device(devrec->dev);
+	ieee802154_unregister_hw(devrec->hw);
 err_register_device:
-	ieee802154_free_device(devrec->dev);
+	ieee802154_free_hw(devrec->hw);
 err_ret:
 	return ret;
 }
@@ -769,8 +769,8 @@ static int mrf24j40_remove(struct spi_device *spi)
 
 	dev_dbg(printdev(devrec), "remove\n");
 
-	ieee802154_unregister_device(devrec->dev);
-	ieee802154_free_device(devrec->dev);
+	ieee802154_unregister_hw(devrec->hw);
+	ieee802154_free_hw(devrec->hw);
 	/* TODO: Will ieee802154_free_device() wait until ->xmit() is
 	 * complete? */
 
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 2e67cdd..ffc8cee 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -55,7 +55,7 @@ struct ieee802154_hw_addr_filt {
 	u8	pan_coord;
 };
 
-struct ieee802154_dev {
+struct ieee802154_hw {
 	/* filled by the driver */
 	int	extra_tx_headroom;
 	u32	flags;
@@ -162,37 +162,37 @@ struct ieee802154_dev {
  */
 struct ieee802154_ops {
 	struct module	*owner;
-	int		(*start)(struct ieee802154_dev *dev);
-	void		(*stop)(struct ieee802154_dev *dev);
-	int		(*xmit)(struct ieee802154_dev *dev,
+	int		(*start)(struct ieee802154_hw *hw);
+	void		(*stop)(struct ieee802154_hw *hw);
+	int		(*xmit)(struct ieee802154_hw *hw,
 				struct sk_buff *skb);
-	int		(*ed)(struct ieee802154_dev *dev, u8 *level);
-	int		(*set_channel)(struct ieee802154_dev *dev,
+	int		(*ed)(struct ieee802154_hw *hw, u8 *level);
+	int		(*set_channel)(struct ieee802154_hw *hw,
 				       int page,
 				       int channel);
-	int		(*set_hw_addr_filt)(struct ieee802154_dev *dev,
-					  struct ieee802154_hw_addr_filt *filt,
+	int		(*set_hw_addr_filt)(struct ieee802154_hw *hw,
+					    struct ieee802154_hw_addr_filt *filt,
 					    unsigned long changed);
-	int		(*ieee_addr)(struct ieee802154_dev *dev, __le64 addr);
-	int		(*set_txpower)(struct ieee802154_dev *dev, int db);
-	int		(*set_lbt)(struct ieee802154_dev *dev, bool on);
-	int		(*set_cca_mode)(struct ieee802154_dev *dev, u8 mode);
-	int		(*set_cca_ed_level)(struct ieee802154_dev *dev,
+	int		(*ieee_addr)(struct ieee802154_hw *hw, __le64 addr);
+	int		(*set_txpower)(struct ieee802154_hw *hw, int db);
+	int		(*set_lbt)(struct ieee802154_hw *hw, bool on);
+	int		(*set_cca_mode)(struct ieee802154_hw *hw, u8 mode);
+	int		(*set_cca_ed_level)(struct ieee802154_hw *hw,
 					    s32 level);
-	int		(*set_csma_params)(struct ieee802154_dev *dev,
+	int		(*set_csma_params)(struct ieee802154_hw *hw,
 					   u8 min_be, u8 max_be, u8 retries);
-	int		(*set_frame_retries)(struct ieee802154_dev *dev,
+	int		(*set_frame_retries)(struct ieee802154_hw *hw,
 					     s8 retries);
 };
 
-/* Basic interface to register ieee802154 device */
-struct ieee802154_dev *
-ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops);
-void ieee802154_free_device(struct ieee802154_dev *dev);
-int ieee802154_register_device(struct ieee802154_dev *dev);
-void ieee802154_unregister_device(struct ieee802154_dev *dev);
+/* Basic interface to register ieee802154 hwice */
+struct ieee802154_hw *
+ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops);
+void ieee802154_free_hw(struct ieee802154_hw *hw);
+int ieee802154_register_hw(struct ieee802154_hw *hw);
+void ieee802154_unregister_hw(struct ieee802154_hw *hw);
 
-void ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb,
+void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
 			   u8 lqi);
 
 #endif /* NET_MAC802154_H */
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index b36b2b9..adb3f76 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -239,8 +239,8 @@ static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
 	return priv->ops->set_frame_retries(&priv->hw, retries);
 }
 
-struct ieee802154_dev *
-ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops)
+struct ieee802154_hw *
+ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 {
 	struct wpan_phy *phy;
 	struct mac802154_priv *priv;
@@ -289,9 +289,9 @@ ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops)
 
 	return &priv->hw;
 }
-EXPORT_SYMBOL(ieee802154_alloc_device);
+EXPORT_SYMBOL(ieee802154_alloc_hw);
 
-void ieee802154_free_device(struct ieee802154_dev *hw)
+void ieee802154_free_hw(struct ieee802154_hw *hw)
 {
 	struct mac802154_priv *priv = mac802154_to_priv(hw);
 
@@ -301,49 +301,49 @@ void ieee802154_free_device(struct ieee802154_dev *hw)
 
 	wpan_phy_free(priv->phy);
 }
-EXPORT_SYMBOL(ieee802154_free_device);
+EXPORT_SYMBOL(ieee802154_free_hw);
 
-int ieee802154_register_device(struct ieee802154_dev *dev)
+int ieee802154_register_hw(struct ieee802154_hw *hw)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(dev);
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
 	int rc = -ENOSYS;
 
-	if (dev->flags & IEEE802154_HW_TXPOWER) {
+	if (hw->flags & IEEE802154_HW_TXPOWER) {
 		if (!priv->ops->set_txpower)
 			goto out;
 
 		priv->phy->set_txpower = mac802154_set_txpower;
 	}
 
-	if (dev->flags & IEEE802154_HW_LBT) {
+	if (hw->flags & IEEE802154_HW_LBT) {
 		if (!priv->ops->set_lbt)
 			goto out;
 
 		priv->phy->set_lbt = mac802154_set_lbt;
 	}
 
-	if (dev->flags & IEEE802154_HW_CCA_MODE) {
+	if (hw->flags & IEEE802154_HW_CCA_MODE) {
 		if (!priv->ops->set_cca_mode)
 			goto out;
 
 		priv->phy->set_cca_mode = mac802154_set_cca_mode;
 	}
 
-	if (dev->flags & IEEE802154_HW_CCA_ED_LEVEL) {
+	if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
 		if (!priv->ops->set_cca_ed_level)
 			goto out;
 
 		priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
 	}
 
-	if (dev->flags & IEEE802154_HW_CSMA_PARAMS) {
+	if (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
 		if (!priv->ops->set_csma_params)
 			goto out;
 
 		priv->phy->set_csma_params = mac802154_set_csma_params;
 	}
 
-	if (dev->flags & IEEE802154_HW_FRAME_RETRIES) {
+	if (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
 		if (!priv->ops->set_frame_retries)
 			goto out;
 
@@ -381,11 +381,11 @@ out_wq:
 out:
 	return rc;
 }
-EXPORT_SYMBOL(ieee802154_register_device);
+EXPORT_SYMBOL(ieee802154_register_hw);
 
-void ieee802154_unregister_device(struct ieee802154_dev *dev)
+void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(dev);
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
 	struct mac802154_sub_if_data *sdata, *next;
 
 	flush_workqueue(priv->dev_workqueue);
@@ -409,7 +409,7 @@ void ieee802154_unregister_device(struct ieee802154_dev *dev)
 
 	wpan_phy_unregister(priv->phy);
 }
-EXPORT_SYMBOL(ieee802154_unregister_device);
+EXPORT_SYMBOL(ieee802154_unregister_hw);
 
 MODULE_DESCRIPTION("IEEE 802.15.4 implementation");
 MODULE_LICENSE("GPL v2");
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 762a6f8..6375a39 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -31,7 +31,7 @@
 
 /* mac802154 device private data */
 struct mac802154_priv {
-	struct ieee802154_dev hw;
+	struct ieee802154_hw hw;
 	struct ieee802154_ops *ops;
 
 	/* ieee802154 phy */
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index a14cf9e..574290d 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -46,12 +46,12 @@
 struct rx_work {
 	struct sk_buff *skb;
 	struct work_struct work;
-	struct ieee802154_dev *dev;
+	struct ieee802154_hw *hw;
 	u8 lqi;
 };
 
 static void
-mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
+mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
 	struct mac802154_priv *priv = mac802154_to_priv(hw);
 
@@ -87,14 +87,14 @@ static void mac802154_rx_worker(struct work_struct *work)
 {
 	struct rx_work *rw = container_of(work, struct rx_work, work);
 
-	mac802154_subif_rx(rw->dev, rw->skb, rw->lqi);
+	mac802154_subif_rx(rw->hw, rw->skb, rw->lqi);
 	kfree(rw);
 }
 
 void
-ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb, u8 lqi)
+ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(dev);
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
 	struct rx_work *work;
 
 	if (!skb)
@@ -106,7 +106,7 @@ ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb, u8 lqi)
 
 	INIT_WORK(&work->work, mac802154_rx_worker);
 	work->skb = skb;
-	work->dev = dev;
+	work->hw = hw;
 	work->lqi = lqi;
 
 	queue_work(priv->dev_workqueue, &work->work);
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 02/11] mac802154: rename ieee802154_dev.c to main.c
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 01/11] ieee802154: rename ieee802154_dev to ieee802154_hw Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 03/11] mac802154: remove not functional monitor device Alexander Aring
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This file contains hw functionality which is similar to the
net/mac80211/main.c file.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/Makefile         |   2 +-
 net/mac802154/ieee802154_dev.c | 415 -----------------------------------------
 net/mac802154/main.c           | 411 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 412 insertions(+), 416 deletions(-)
 delete mode 100644 net/mac802154/ieee802154_dev.c
 create mode 100644 net/mac802154/main.c

diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 9723d6f..1ecbc47 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_MAC802154)	+= mac802154.o
-mac802154-objs		:= ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o \
+mac802154-objs		:= main.o rx.o tx.o mac_cmd.o mib.o \
 			   monitor.o wpan.o llsec.o
 
 ccflags-y += -D__CHECK_ENDIAN__
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
deleted file mode 100644
index adb3f76..0000000
--- a/net/mac802154/ieee802154_dev.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Siemens AG
- *
- * Written by:
- * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
- *
- * Based on the code from 'linux-zigbee.sourceforge.net' project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-
-#include <net/netlink.h>
-#include <linux/nl802154.h>
-#include <net/mac802154.h>
-#include <net/ieee802154_netdev.h>
-#include <net/route.h>
-#include <net/wpan-phy.h>
-
-#include "mac802154.h"
-
-int mac802154_slave_open(struct net_device *dev)
-{
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct mac802154_sub_if_data *subif;
-	struct mac802154_priv *ipriv = priv->hw;
-	int res = 0;
-
-	ASSERT_RTNL();
-
-	if (priv->type == IEEE802154_DEV_WPAN) {
-		mutex_lock(&priv->hw->slaves_mtx);
-		list_for_each_entry(subif, &priv->hw->slaves, list) {
-			if (subif != priv && subif->type == priv->type &&
-			    subif->running) {
-				mutex_unlock(&priv->hw->slaves_mtx);
-				return -EBUSY;
-			}
-		}
-		mutex_unlock(&priv->hw->slaves_mtx);
-	}
-
-	mutex_lock(&priv->hw->slaves_mtx);
-	priv->running = true;
-	mutex_unlock(&priv->hw->slaves_mtx);
-
-	if (ipriv->open_count++ == 0) {
-		res = ipriv->ops->start(&ipriv->hw);
-		WARN_ON(res);
-		if (res)
-			goto err;
-	}
-
-	if (ipriv->ops->ieee_addr) {
-		__le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr);
-
-		res = ipriv->ops->ieee_addr(&ipriv->hw, addr);
-		WARN_ON(res);
-		if (res)
-			goto err;
-		mac802154_dev_set_ieee_addr(dev);
-	}
-
-	netif_start_queue(dev);
-	return 0;
-err:
-	priv->hw->open_count--;
-
-	return res;
-}
-
-int mac802154_slave_close(struct net_device *dev)
-{
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct mac802154_priv *ipriv = priv->hw;
-
-	ASSERT_RTNL();
-
-	netif_stop_queue(dev);
-
-	mutex_lock(&priv->hw->slaves_mtx);
-	priv->running = false;
-	mutex_unlock(&priv->hw->slaves_mtx);
-
-	if (!--ipriv->open_count)
-		ipriv->ops->stop(&ipriv->hw);
-
-	return 0;
-}
-
-static int
-mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
-{
-	struct mac802154_sub_if_data *priv;
-	struct mac802154_priv *ipriv;
-	int err;
-
-	ipriv = wpan_phy_priv(phy);
-
-	priv = netdev_priv(dev);
-	priv->dev = dev;
-	priv->hw = ipriv;
-
-	dev->needed_headroom = ipriv->hw.extra_tx_headroom;
-
-	SET_NETDEV_DEV(dev, &ipriv->phy->dev);
-
-	mutex_lock(&ipriv->slaves_mtx);
-	if (!ipriv->running) {
-		mutex_unlock(&ipriv->slaves_mtx);
-		return -ENODEV;
-	}
-	mutex_unlock(&ipriv->slaves_mtx);
-
-	err = register_netdev(dev);
-	if (err < 0)
-		return err;
-
-	rtnl_lock();
-	mutex_lock(&ipriv->slaves_mtx);
-	list_add_tail_rcu(&priv->list, &ipriv->slaves);
-	mutex_unlock(&ipriv->slaves_mtx);
-	rtnl_unlock();
-
-	return 0;
-}
-
-static void
-mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
-{
-	struct mac802154_sub_if_data *sdata;
-
-	ASSERT_RTNL();
-
-	sdata = netdev_priv(dev);
-
-	BUG_ON(sdata->hw->phy != phy);
-
-	mutex_lock(&sdata->hw->slaves_mtx);
-	list_del_rcu(&sdata->list);
-	mutex_unlock(&sdata->hw->slaves_mtx);
-
-	synchronize_rcu();
-	unregister_netdevice(sdata->dev);
-}
-
-static struct net_device *
-mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
-{
-	struct net_device *dev;
-	int err = -ENOMEM;
-
-	switch (type) {
-	case IEEE802154_DEV_MONITOR:
-		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
-				   name, NET_NAME_UNKNOWN,
-				   mac802154_monitor_setup);
-		break;
-	case IEEE802154_DEV_WPAN:
-		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
-				   name, NET_NAME_UNKNOWN,
-				   mac802154_wpan_setup);
-		break;
-	default:
-		dev = NULL;
-		err = -EINVAL;
-		break;
-	}
-	if (!dev)
-		goto err;
-
-	err = mac802154_netdev_register(phy, dev);
-	if (err)
-		goto err_free;
-
-	dev_hold(dev); /* we return an incremented device refcount */
-	return dev;
-
-err_free:
-	free_netdev(dev);
-err:
-	return ERR_PTR(err);
-}
-
-static int mac802154_set_txpower(struct wpan_phy *phy, int db)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_txpower(&priv->hw, db);
-}
-
-static int mac802154_set_lbt(struct wpan_phy *phy, bool on)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_lbt(&priv->hw, on);
-}
-
-static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_cca_mode(&priv->hw, mode);
-}
-
-static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_cca_ed_level(&priv->hw, level);
-}
-
-static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be,
-				     u8 max_be, u8 retries)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_csma_params(&priv->hw, min_be, max_be, retries);
-}
-
-static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
-{
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
-
-	return priv->ops->set_frame_retries(&priv->hw, retries);
-}
-
-struct ieee802154_hw *
-ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
-{
-	struct wpan_phy *phy;
-	struct mac802154_priv *priv;
-	size_t priv_size;
-
-	if (!ops || !ops->xmit || !ops->ed || !ops->start ||
-	    !ops->stop || !ops->set_channel) {
-		pr_err("undefined IEEE802.15.4 device operations\n");
-		return NULL;
-	}
-
-	/* Ensure 32-byte alignment of our private data and hw private data.
-	 * We use the wpan_phy priv data for both our mac802154_priv and for
-	 * the driver's private data
-	 *
-	 * in memory it'll be like this:
-	 *
-	 * +-----------------------+
-	 * | struct wpan_phy       |
-	 * +-----------------------+
-	 * | struct mac802154_priv |
-	 * +-----------------------+
-	 * | driver's private data |
-	 * +-----------------------+
-	 *
-	 * Due to ieee802154 layer isn't aware of driver and MAC structures,
-	 * so lets allign them here.
-	 */
-
-	priv_size = ALIGN(sizeof(*priv), NETDEV_ALIGN) + priv_data_len;
-
-	phy = wpan_phy_alloc(priv_size);
-	if (!phy) {
-		pr_err("failure to allocate master IEEE802.15.4 device\n");
-		return NULL;
-	}
-
-	priv = wpan_phy_priv(phy);
-	priv->phy = phy;
-	priv->hw.phy = priv->phy;
-	priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
-	priv->ops = ops;
-
-	INIT_LIST_HEAD(&priv->slaves);
-	mutex_init(&priv->slaves_mtx);
-
-	return &priv->hw;
-}
-EXPORT_SYMBOL(ieee802154_alloc_hw);
-
-void ieee802154_free_hw(struct ieee802154_hw *hw)
-{
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
-
-	BUG_ON(!list_empty(&priv->slaves));
-
-	mutex_destroy(&priv->slaves_mtx);
-
-	wpan_phy_free(priv->phy);
-}
-EXPORT_SYMBOL(ieee802154_free_hw);
-
-int ieee802154_register_hw(struct ieee802154_hw *hw)
-{
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
-	int rc = -ENOSYS;
-
-	if (hw->flags & IEEE802154_HW_TXPOWER) {
-		if (!priv->ops->set_txpower)
-			goto out;
-
-		priv->phy->set_txpower = mac802154_set_txpower;
-	}
-
-	if (hw->flags & IEEE802154_HW_LBT) {
-		if (!priv->ops->set_lbt)
-			goto out;
-
-		priv->phy->set_lbt = mac802154_set_lbt;
-	}
-
-	if (hw->flags & IEEE802154_HW_CCA_MODE) {
-		if (!priv->ops->set_cca_mode)
-			goto out;
-
-		priv->phy->set_cca_mode = mac802154_set_cca_mode;
-	}
-
-	if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
-		if (!priv->ops->set_cca_ed_level)
-			goto out;
-
-		priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
-	}
-
-	if (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
-		if (!priv->ops->set_csma_params)
-			goto out;
-
-		priv->phy->set_csma_params = mac802154_set_csma_params;
-	}
-
-	if (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
-		if (!priv->ops->set_frame_retries)
-			goto out;
-
-		priv->phy->set_frame_retries = mac802154_set_frame_retries;
-	}
-
-	priv->dev_workqueue =
-		create_singlethread_workqueue(wpan_phy_name(priv->phy));
-	if (!priv->dev_workqueue) {
-		rc = -ENOMEM;
-		goto out;
-	}
-
-	wpan_phy_set_dev(priv->phy, priv->hw.parent);
-
-	priv->phy->add_iface = mac802154_add_iface;
-	priv->phy->del_iface = mac802154_del_iface;
-
-	rc = wpan_phy_register(priv->phy);
-	if (rc < 0)
-		goto out_wq;
-
-	rtnl_lock();
-
-	mutex_lock(&priv->slaves_mtx);
-	priv->running = MAC802154_DEVICE_RUN;
-	mutex_unlock(&priv->slaves_mtx);
-
-	rtnl_unlock();
-
-	return 0;
-
-out_wq:
-	destroy_workqueue(priv->dev_workqueue);
-out:
-	return rc;
-}
-EXPORT_SYMBOL(ieee802154_register_hw);
-
-void ieee802154_unregister_hw(struct ieee802154_hw *hw)
-{
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
-	struct mac802154_sub_if_data *sdata, *next;
-
-	flush_workqueue(priv->dev_workqueue);
-	destroy_workqueue(priv->dev_workqueue);
-
-	rtnl_lock();
-
-	mutex_lock(&priv->slaves_mtx);
-	priv->running = MAC802154_DEVICE_STOPPED;
-	mutex_unlock(&priv->slaves_mtx);
-
-	list_for_each_entry_safe(sdata, next, &priv->slaves, list) {
-		mutex_lock(&sdata->hw->slaves_mtx);
-		list_del(&sdata->list);
-		mutex_unlock(&sdata->hw->slaves_mtx);
-
-		unregister_netdevice(sdata->dev);
-	}
-
-	rtnl_unlock();
-
-	wpan_phy_unregister(priv->phy);
-}
-EXPORT_SYMBOL(ieee802154_unregister_hw);
-
-MODULE_DESCRIPTION("IEEE 802.15.4 implementation");
-MODULE_LICENSE("GPL v2");
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
new file mode 100644
index 0000000..645a994
--- /dev/null
+++ b/net/mac802154/main.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2007-2012 Siemens AG
+ *
+ * Written by:
+ * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
+ *
+ * Based on the code from 'linux-zigbee.sourceforge.net' project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+
+#include <net/netlink.h>
+#include <linux/nl802154.h>
+#include <net/mac802154.h>
+#include <net/ieee802154_netdev.h>
+#include <net/route.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+
+int mac802154_slave_open(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct mac802154_sub_if_data *subif;
+	struct mac802154_priv *ipriv = priv->hw;
+	int res = 0;
+
+	ASSERT_RTNL();
+
+	if (priv->type == IEEE802154_DEV_WPAN) {
+		mutex_lock(&priv->hw->slaves_mtx);
+		list_for_each_entry(subif, &priv->hw->slaves, list) {
+			if (subif != priv && subif->type == priv->type &&
+			    subif->running) {
+				mutex_unlock(&priv->hw->slaves_mtx);
+				return -EBUSY;
+			}
+		}
+		mutex_unlock(&priv->hw->slaves_mtx);
+	}
+
+	mutex_lock(&priv->hw->slaves_mtx);
+	priv->running = true;
+	mutex_unlock(&priv->hw->slaves_mtx);
+
+	if (ipriv->open_count++ == 0) {
+		res = ipriv->ops->start(&ipriv->hw);
+		WARN_ON(res);
+		if (res)
+			goto err;
+	}
+
+	if (ipriv->ops->ieee_addr) {
+		__le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr);
+
+		res = ipriv->ops->ieee_addr(&ipriv->hw, addr);
+		WARN_ON(res);
+		if (res)
+			goto err;
+		mac802154_dev_set_ieee_addr(dev);
+	}
+
+	netif_start_queue(dev);
+	return 0;
+err:
+	priv->hw->open_count--;
+
+	return res;
+}
+
+int mac802154_slave_close(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct mac802154_priv *ipriv = priv->hw;
+
+	ASSERT_RTNL();
+
+	netif_stop_queue(dev);
+
+	mutex_lock(&priv->hw->slaves_mtx);
+	priv->running = false;
+	mutex_unlock(&priv->hw->slaves_mtx);
+
+	if (!--ipriv->open_count)
+		ipriv->ops->stop(&ipriv->hw);
+
+	return 0;
+}
+
+static int
+mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv;
+	struct mac802154_priv *ipriv;
+	int err;
+
+	ipriv = wpan_phy_priv(phy);
+
+	priv = netdev_priv(dev);
+	priv->dev = dev;
+	priv->hw = ipriv;
+
+	dev->needed_headroom = ipriv->hw.extra_tx_headroom;
+
+	SET_NETDEV_DEV(dev, &ipriv->phy->dev);
+
+	mutex_lock(&ipriv->slaves_mtx);
+	if (!ipriv->running) {
+		mutex_unlock(&ipriv->slaves_mtx);
+		return -ENODEV;
+	}
+	mutex_unlock(&ipriv->slaves_mtx);
+
+	err = register_netdev(dev);
+	if (err < 0)
+		return err;
+
+	rtnl_lock();
+	mutex_lock(&ipriv->slaves_mtx);
+	list_add_tail_rcu(&priv->list, &ipriv->slaves);
+	mutex_unlock(&ipriv->slaves_mtx);
+	rtnl_unlock();
+
+	return 0;
+}
+
+static void
+mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
+{
+	struct mac802154_sub_if_data *sdata;
+
+	ASSERT_RTNL();
+
+	sdata = netdev_priv(dev);
+
+	BUG_ON(sdata->hw->phy != phy);
+
+	mutex_lock(&sdata->hw->slaves_mtx);
+	list_del_rcu(&sdata->list);
+	mutex_unlock(&sdata->hw->slaves_mtx);
+
+	synchronize_rcu();
+	unregister_netdevice(sdata->dev);
+}
+
+static struct net_device *
+mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
+{
+	struct net_device *dev;
+	int err = -ENOMEM;
+
+	switch (type) {
+	case IEEE802154_DEV_MONITOR:
+		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
+				   name, NET_NAME_UNKNOWN,
+				   mac802154_monitor_setup);
+		break;
+	case IEEE802154_DEV_WPAN:
+		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
+				   name, NET_NAME_UNKNOWN,
+				   mac802154_wpan_setup);
+		break;
+	default:
+		dev = NULL;
+		err = -EINVAL;
+		break;
+	}
+	if (!dev)
+		goto err;
+
+	err = mac802154_netdev_register(phy, dev);
+	if (err)
+		goto err_free;
+
+	dev_hold(dev); /* we return an incremented device refcount */
+	return dev;
+
+err_free:
+	free_netdev(dev);
+err:
+	return ERR_PTR(err);
+}
+
+static int mac802154_set_txpower(struct wpan_phy *phy, int db)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_txpower(&priv->hw, db);
+}
+
+static int mac802154_set_lbt(struct wpan_phy *phy, bool on)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_lbt(&priv->hw, on);
+}
+
+static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_cca_mode(&priv->hw, mode);
+}
+
+static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_cca_ed_level(&priv->hw, level);
+}
+
+static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be,
+				     u8 max_be, u8 retries)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_csma_params(&priv->hw, min_be, max_be, retries);
+}
+
+static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
+{
+	struct mac802154_priv *priv = wpan_phy_priv(phy);
+
+	return priv->ops->set_frame_retries(&priv->hw, retries);
+}
+
+struct ieee802154_hw *
+ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
+{
+	struct wpan_phy *phy;
+	struct mac802154_priv *priv;
+	size_t priv_size;
+
+	if (!ops || !ops->xmit || !ops->ed || !ops->start ||
+	    !ops->stop || !ops->set_channel) {
+		pr_err("undefined IEEE802.15.4 device operations\n");
+		return NULL;
+	}
+
+	/* Ensure 32-byte alignment of our private data and hw private data.
+	 * We use the wpan_phy priv data for both our mac802154_priv and for
+	 * the driver's private data
+	 *
+	 * in memory it'll be like this:
+	 *
+	 * +-----------------------+
+	 * | struct wpan_phy       |
+	 * +-----------------------+
+	 * | struct mac802154_priv |
+	 * +-----------------------+
+	 * | driver's private data |
+	 * +-----------------------+
+	 *
+	 * Due to ieee802154 layer isn't aware of driver and MAC structures,
+	 * so lets allign them here.
+	 */
+
+	priv_size = ALIGN(sizeof(*priv), NETDEV_ALIGN) + priv_data_len;
+
+	phy = wpan_phy_alloc(priv_size);
+	if (!phy) {
+		pr_err("failure to allocate master IEEE802.15.4 device\n");
+		return NULL;
+	}
+
+	priv = wpan_phy_priv(phy);
+	priv->phy = phy;
+	priv->hw.phy = priv->phy;
+	priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
+	priv->ops = ops;
+
+	INIT_LIST_HEAD(&priv->slaves);
+	mutex_init(&priv->slaves_mtx);
+
+	return &priv->hw;
+}
+EXPORT_SYMBOL(ieee802154_alloc_hw);
+
+void ieee802154_free_hw(struct ieee802154_hw *hw)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
+
+	BUG_ON(!list_empty(&priv->slaves));
+
+	mutex_destroy(&priv->slaves_mtx);
+
+	wpan_phy_free(priv->phy);
+}
+EXPORT_SYMBOL(ieee802154_free_hw);
+
+int ieee802154_register_hw(struct ieee802154_hw *hw)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	int rc = -ENOSYS;
+
+	if (hw->flags & IEEE802154_HW_TXPOWER) {
+		if (!priv->ops->set_txpower)
+			goto out;
+
+		priv->phy->set_txpower = mac802154_set_txpower;
+	}
+
+	if (hw->flags & IEEE802154_HW_LBT) {
+		if (!priv->ops->set_lbt)
+			goto out;
+
+		priv->phy->set_lbt = mac802154_set_lbt;
+	}
+
+	if (hw->flags & IEEE802154_HW_CCA_MODE) {
+		if (!priv->ops->set_cca_mode)
+			goto out;
+
+		priv->phy->set_cca_mode = mac802154_set_cca_mode;
+	}
+
+	if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
+		if (!priv->ops->set_cca_ed_level)
+			goto out;
+
+		priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
+	}
+
+	if (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
+		if (!priv->ops->set_csma_params)
+			goto out;
+
+		priv->phy->set_csma_params = mac802154_set_csma_params;
+	}
+
+	if (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
+		if (!priv->ops->set_frame_retries)
+			goto out;
+
+		priv->phy->set_frame_retries = mac802154_set_frame_retries;
+	}
+
+	priv->dev_workqueue =
+		create_singlethread_workqueue(wpan_phy_name(priv->phy));
+	if (!priv->dev_workqueue) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	wpan_phy_set_dev(priv->phy, priv->hw.parent);
+
+	priv->phy->add_iface = mac802154_add_iface;
+	priv->phy->del_iface = mac802154_del_iface;
+
+	rc = wpan_phy_register(priv->phy);
+	if (rc < 0)
+		goto out_wq;
+
+	rtnl_lock();
+
+	mutex_lock(&priv->slaves_mtx);
+	priv->running = MAC802154_DEVICE_RUN;
+	mutex_unlock(&priv->slaves_mtx);
+
+	rtnl_unlock();
+
+	return 0;
+
+out_wq:
+	destroy_workqueue(priv->dev_workqueue);
+out:
+	return rc;
+}
+EXPORT_SYMBOL(ieee802154_register_hw);
+
+void ieee802154_unregister_hw(struct ieee802154_hw *hw)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct mac802154_sub_if_data *sdata, *next;
+
+	flush_workqueue(priv->dev_workqueue);
+	destroy_workqueue(priv->dev_workqueue);
+
+	rtnl_lock();
+
+	mutex_lock(&priv->slaves_mtx);
+	priv->running = MAC802154_DEVICE_STOPPED;
+	mutex_unlock(&priv->slaves_mtx);
+
+	list_for_each_entry_safe(sdata, next, &priv->slaves, list) {
+		mutex_lock(&sdata->hw->slaves_mtx);
+		list_del(&sdata->list);
+		mutex_unlock(&sdata->hw->slaves_mtx);
+
+		unregister_netdevice(sdata->dev);
+	}
+
+	rtnl_unlock();
+
+	wpan_phy_unregister(priv->phy);
+}
+EXPORT_SYMBOL(ieee802154_unregister_hw);
+
+MODULE_DESCRIPTION("IEEE 802.15.4 implementation");
+MODULE_LICENSE("GPL v2");
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 03/11] mac802154: remove not functional monitor device
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 01/11] ieee802154: rename ieee802154_dev to ieee802154_hw Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 02/11] mac802154: rename ieee802154_dev.c to main.c Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 04/11] ieee802154: add new interface types Alexander Aring
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This is broken in many ways, drop the current monitor device support and
later we will implement a new implement for this.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/linux/nl802154.h  |   1 -
 net/mac802154/Makefile    |   2 +-
 net/mac802154/mac802154.h |   3 --
 net/mac802154/main.c      |   5 --
 net/mac802154/monitor.c   | 117 ----------------------------------------------
 net/mac802154/rx.c        |   1 -
 net/mac802154/tx.c        |   2 -
 7 files changed, 1 insertion(+), 130 deletions(-)
 delete mode 100644 net/mac802154/monitor.c

diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index 20163b9..fe775e3 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -174,7 +174,6 @@ enum {
 	__IEEE802154_DEV_INVALID = -1,
 
 	IEEE802154_DEV_WPAN,
-	IEEE802154_DEV_MONITOR,
 
 	__IEEE802154_DEV_MAX,
 };
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 1ecbc47..5f54676 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_MAC802154)	+= mac802154.o
 mac802154-objs		:= main.o rx.o tx.o mac_cmd.o mib.o \
-			   monitor.o wpan.o llsec.o
+			   wpan.o llsec.o
 
 ccflags-y += -D__CHECK_ENDIAN__
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 6375a39..1c4fb8f 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -113,9 +113,6 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
 int mac802154_slave_open(struct net_device *dev);
 int mac802154_slave_close(struct net_device *dev);
 
-void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb);
-void mac802154_monitor_setup(struct net_device *dev);
-
 void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb);
 void mac802154_wpan_setup(struct net_device *dev);
 
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 645a994..1e68e49 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -161,11 +161,6 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
 	int err = -ENOMEM;
 
 	switch (type) {
-	case IEEE802154_DEV_MONITOR:
-		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
-				   name, NET_NAME_UNKNOWN,
-				   mac802154_monitor_setup);
-		break;
 	case IEEE802154_DEV_WPAN:
 		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
 				   name, NET_NAME_UNKNOWN,
diff --git a/net/mac802154/monitor.c b/net/mac802154/monitor.c
deleted file mode 100644
index a68230e..0000000
--- a/net/mac802154/monitor.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Siemens AG
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Written by:
- * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
- * Sergey Lapin <slapin@ossfans.org>
- * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
- * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
- */
-
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/if_arp.h>
-#include <linux/crc-ccitt.h>
-
-#include <net/ieee802154.h>
-#include <net/mac802154.h>
-#include <net/netlink.h>
-#include <net/wpan-phy.h>
-#include <linux/nl802154.h>
-
-#include "mac802154.h"
-
-static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb,
-					  struct net_device *dev)
-{
-	struct mac802154_sub_if_data *priv;
-	u8 chan, page;
-
-	priv = netdev_priv(dev);
-
-	/* FIXME: locking */
-	chan = priv->hw->phy->current_channel;
-	page = priv->hw->phy->current_page;
-
-	if (chan == MAC802154_CHAN_NONE) /* not initialized */
-		return NETDEV_TX_OK;
-
-	if (WARN_ON(page >= WPAN_NUM_PAGES) ||
-	    WARN_ON(chan >= WPAN_NUM_CHANNELS))
-		return NETDEV_TX_OK;
-
-	skb->skb_iif = dev->ifindex;
-	dev->stats.tx_packets++;
-	dev->stats.tx_bytes += skb->len;
-
-	return mac802154_tx(priv->hw, skb, page, chan);
-}
-
-
-void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb)
-{
-	struct sk_buff *skb2;
-	struct mac802154_sub_if_data *sdata;
-	u16 crc = crc_ccitt(0, skb->data, skb->len);
-	u8 *data;
-
-	rcu_read_lock();
-	list_for_each_entry_rcu(sdata, &priv->slaves, list) {
-		if (sdata->type != IEEE802154_DEV_MONITOR ||
-		    !netif_running(sdata->dev))
-			continue;
-
-		skb2 = skb_clone(skb, GFP_ATOMIC);
-		skb2->dev = sdata->dev;
-		skb2->pkt_type = PACKET_HOST;
-		data = skb_put(skb2, 2);
-		data[0] = crc & 0xff;
-		data[1] = crc >> 8;
-
-		netif_rx_ni(skb2);
-	}
-	rcu_read_unlock();
-}
-
-static const struct net_device_ops mac802154_monitor_ops = {
-	.ndo_open		= mac802154_slave_open,
-	.ndo_stop		= mac802154_slave_close,
-	.ndo_start_xmit		= mac802154_monitor_xmit,
-};
-
-void mac802154_monitor_setup(struct net_device *dev)
-{
-	struct mac802154_sub_if_data *priv;
-
-	dev->addr_len		= 0;
-	dev->hard_header_len	= 0;
-	dev->needed_tailroom	= 2; /* room for FCS */
-	dev->mtu		= IEEE802154_MTU;
-	dev->tx_queue_len	= 10;
-	dev->type		= ARPHRD_IEEE802154_MONITOR;
-	dev->flags		= IFF_NOARP | IFF_BROADCAST;
-	dev->watchdog_timeo	= 0;
-
-	dev->destructor		= free_netdev;
-	dev->netdev_ops		= &mac802154_monitor_ops;
-	dev->ml_priv		= &mac802154_mlme_reduced;
-
-	priv = netdev_priv(dev);
-	priv->type = IEEE802154_DEV_MONITOR;
-
-	priv->chan = MAC802154_CHAN_NONE; /* not initialized */
-	priv->page = 0;
-}
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 574290d..48f1523 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -74,7 +74,6 @@ mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 		skb_trim(skb, skb->len - 2); /* CRC */
 	}
 
-	mac802154_monitors_rx(priv, skb);
 	mac802154_wpans_rx(priv, skb);
 
 	return;
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index fdf4c0e6..bacb6ce 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -92,8 +92,6 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 		goto err_tx;
 	}
 
-	mac802154_monitors_rx(mac802154_to_priv(&priv->hw), skb);
-
 	if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
 		u16 crc = crc_ccitt(0, skb->data, skb->len);
 		u8 *data = skb_put(skb, 2);
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 04/11] ieee802154: add new interface types
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (2 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 03/11] mac802154: remove not functional monitor device Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 05/11] nl802154: add missing endif comment Alexander Aring
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch adds the new interface types NODE, MONITOR and COORD.
The NODE has the identically number like WPAN_DEV and should be backwards
compatible with current userspace tools.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/linux/nl802154.h | 12 ++++++++----
 net/ieee802154/nl-phy.c  |  4 ++--
 net/mac802154/main.c     |  4 ++--
 net/mac802154/wpan.c     |  4 ++--
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index fe775e3..3058544 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -170,12 +170,16 @@ enum {
 
 #define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1)
 
-enum {
-	__IEEE802154_DEV_INVALID = -1,
+enum nl802154_iftype {
+	NL802154_IFTYPE_UNSPEC = -1,
 
-	IEEE802154_DEV_WPAN,
+	NL802154_IFTYPE_NODE,
+	NL802154_IFTYPE_MONITOR,
+	NL802154_IFTYPE_COORD,
 
-	__IEEE802154_DEV_MAX,
+	/* keep last */
+	NUM_NL802154_IFTYPES,
+	NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1
 };
 
 #endif
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 972baf8..b4f1bd8 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -176,7 +176,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
 	const char *devname;
 	int rc = -ENOBUFS;
 	struct net_device *dev;
-	int type = __IEEE802154_DEV_INVALID;
+	enum nl802154_iftype type = NL802154_IFTYPE_UNSPEC;
 
 	pr_debug("%s\n", __func__);
 
@@ -221,7 +221,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
 
 	if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
 		type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
-		if (type >= __IEEE802154_DEV_MAX) {
+		if (type > NL802154_IFTYPE_MAX) {
 			rc = -EINVAL;
 			goto nla_put_failure;
 		}
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 1e68e49..639916e 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -38,7 +38,7 @@ int mac802154_slave_open(struct net_device *dev)
 
 	ASSERT_RTNL();
 
-	if (priv->type == IEEE802154_DEV_WPAN) {
+	if (priv->type == NL802154_IFTYPE_NODE) {
 		mutex_lock(&priv->hw->slaves_mtx);
 		list_for_each_entry(subif, &priv->hw->slaves, list) {
 			if (subif != priv && subif->type == priv->type &&
@@ -161,7 +161,7 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
 	int err = -ENOMEM;
 
 	switch (type) {
-	case IEEE802154_DEV_WPAN:
+	case NL802154_IFTYPE_NODE:
 		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
 				   name, NET_NAME_UNKNOWN,
 				   mac802154_wpan_setup);
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index ce17570..b6f7f75 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -389,7 +389,7 @@ void mac802154_wpan_setup(struct net_device *dev)
 	dev->ml_priv		= &mac802154_mlme_wpan;
 
 	priv = netdev_priv(dev);
-	priv->type = IEEE802154_DEV_WPAN;
+	priv->type = NL802154_IFTYPE_NODE;
 
 	priv->chan = MAC802154_CHAN_NONE;
 	priv->page = 0;
@@ -580,7 +580,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(sdata, &priv->slaves, list) {
-		if (sdata->type != IEEE802154_DEV_WPAN ||
+		if (sdata->type != NL802154_IFTYPE_NODE ||
 		    !netif_running(sdata->dev))
 			continue;
 
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 05/11] nl802154: add missing endif comment
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (3 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 04/11] ieee802154: add new interface types Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 06/11] mac802154: rename mac802154_priv to ieee802154_local Alexander Aring
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/linux/nl802154.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index 3058544..c33b468 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -182,4 +182,4 @@ enum nl802154_iftype {
 	NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1
 };
 
-#endif
+#endif /* NL802154_H */
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 06/11] mac802154: rename mac802154_priv to ieee802154_local
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (4 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 05/11] nl802154: add missing endif comment Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 07/11] mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data Alexander Aring
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch rename the mac802154_priv to ieee802154_local. The
mac802154_priv structure is like ieee80211_local and so we name it
ieee802154_local. This also avoid the priv variable hell.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/mac802154.h |  10 +--
 net/mac802154/main.c      | 172 +++++++++++++++++++++++-----------------------
 net/mac802154/mib.c       |  21 +++---
 net/mac802154/rx.c        |  10 +--
 net/mac802154/tx.c        |  34 ++++-----
 net/mac802154/wpan.c      |   4 +-
 6 files changed, 125 insertions(+), 126 deletions(-)

diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 1c4fb8f..bf3a08e 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -30,7 +30,7 @@
 #include "llsec.h"
 
 /* mac802154 device private data */
-struct mac802154_priv {
+struct ieee802154_local {
 	struct ieee802154_hw hw;
 	struct ieee802154_ops *ops;
 
@@ -73,7 +73,7 @@ struct mac802154_priv {
 struct mac802154_sub_if_data {
 	struct list_head list; /* the ieee802154_priv->slaves list */
 
-	struct mac802154_priv *hw;
+	struct ieee802154_local *hw;
 	struct net_device *dev;
 
 	int type;
@@ -103,7 +103,7 @@ struct mac802154_sub_if_data {
 	struct mac802154_llsec sec;
 };
 
-#define mac802154_to_priv(_hw)	container_of(_hw, struct mac802154_priv, hw)
+#define mac802154_to_priv(_hw)	container_of(_hw, struct ieee802154_local, hw)
 
 #define MAC802154_CHAN_NONE		0xff /* No channel is assigned */
 
@@ -113,10 +113,10 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
 int mac802154_slave_open(struct net_device *dev);
 int mac802154_slave_close(struct net_device *dev);
 
-void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb);
+void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
 void mac802154_wpan_setup(struct net_device *dev);
 
-netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
+netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
 			 u8 page, u8 chan);
 
 /* MIB callbacks */
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 639916e..24548ce 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -33,7 +33,7 @@ int mac802154_slave_open(struct net_device *dev)
 {
 	struct mac802154_sub_if_data *priv = netdev_priv(dev);
 	struct mac802154_sub_if_data *subif;
-	struct mac802154_priv *ipriv = priv->hw;
+	struct ieee802154_local *local = priv->hw;
 	int res = 0;
 
 	ASSERT_RTNL();
@@ -54,17 +54,17 @@ int mac802154_slave_open(struct net_device *dev)
 	priv->running = true;
 	mutex_unlock(&priv->hw->slaves_mtx);
 
-	if (ipriv->open_count++ == 0) {
-		res = ipriv->ops->start(&ipriv->hw);
+	if (local->open_count++ == 0) {
+		res = local->ops->start(&local->hw);
 		WARN_ON(res);
 		if (res)
 			goto err;
 	}
 
-	if (ipriv->ops->ieee_addr) {
+	if (local->ops->ieee_addr) {
 		__le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr);
 
-		res = ipriv->ops->ieee_addr(&ipriv->hw, addr);
+		res = local->ops->ieee_addr(&local->hw, addr);
 		WARN_ON(res);
 		if (res)
 			goto err;
@@ -82,7 +82,7 @@ err:
 int mac802154_slave_close(struct net_device *dev)
 {
 	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct mac802154_priv *ipriv = priv->hw;
+	struct ieee802154_local *local = priv->hw;
 
 	ASSERT_RTNL();
 
@@ -92,8 +92,8 @@ int mac802154_slave_close(struct net_device *dev)
 	priv->running = false;
 	mutex_unlock(&priv->hw->slaves_mtx);
 
-	if (!--ipriv->open_count)
-		ipriv->ops->stop(&ipriv->hw);
+	if (!--local->open_count)
+		local->ops->stop(&local->hw);
 
 	return 0;
 }
@@ -102,34 +102,34 @@ static int
 mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
 {
 	struct mac802154_sub_if_data *priv;
-	struct mac802154_priv *ipriv;
+	struct ieee802154_local *local;
 	int err;
 
-	ipriv = wpan_phy_priv(phy);
+	local = wpan_phy_priv(phy);
 
 	priv = netdev_priv(dev);
 	priv->dev = dev;
-	priv->hw = ipriv;
+	priv->hw = local;
 
-	dev->needed_headroom = ipriv->hw.extra_tx_headroom;
+	dev->needed_headroom = local->hw.extra_tx_headroom;
 
-	SET_NETDEV_DEV(dev, &ipriv->phy->dev);
+	SET_NETDEV_DEV(dev, &local->phy->dev);
 
-	mutex_lock(&ipriv->slaves_mtx);
-	if (!ipriv->running) {
-		mutex_unlock(&ipriv->slaves_mtx);
+	mutex_lock(&local->slaves_mtx);
+	if (!local->running) {
+		mutex_unlock(&local->slaves_mtx);
 		return -ENODEV;
 	}
-	mutex_unlock(&ipriv->slaves_mtx);
+	mutex_unlock(&local->slaves_mtx);
 
 	err = register_netdev(dev);
 	if (err < 0)
 		return err;
 
 	rtnl_lock();
-	mutex_lock(&ipriv->slaves_mtx);
-	list_add_tail_rcu(&priv->list, &ipriv->slaves);
-	mutex_unlock(&ipriv->slaves_mtx);
+	mutex_lock(&local->slaves_mtx);
+	list_add_tail_rcu(&priv->list, &local->slaves);
+	mutex_unlock(&local->slaves_mtx);
 	rtnl_unlock();
 
 	return 0;
@@ -189,52 +189,52 @@ err:
 
 static int mac802154_set_txpower(struct wpan_phy *phy, int db)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_txpower(&priv->hw, db);
+	return local->ops->set_txpower(&local->hw, db);
 }
 
 static int mac802154_set_lbt(struct wpan_phy *phy, bool on)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_lbt(&priv->hw, on);
+	return local->ops->set_lbt(&local->hw, on);
 }
 
 static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_cca_mode(&priv->hw, mode);
+	return local->ops->set_cca_mode(&local->hw, mode);
 }
 
 static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_cca_ed_level(&priv->hw, level);
+	return local->ops->set_cca_ed_level(&local->hw, level);
 }
 
 static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be,
 				     u8 max_be, u8 retries)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_csma_params(&priv->hw, min_be, max_be, retries);
+	return local->ops->set_csma_params(&local->hw, min_be, max_be, retries);
 }
 
 static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
 {
-	struct mac802154_priv *priv = wpan_phy_priv(phy);
+	struct ieee802154_local *local = wpan_phy_priv(phy);
 
-	return priv->ops->set_frame_retries(&priv->hw, retries);
+	return local->ops->set_frame_retries(&local->hw, retries);
 }
 
 struct ieee802154_hw *
 ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 {
 	struct wpan_phy *phy;
-	struct mac802154_priv *priv;
+	struct ieee802154_local *local;
 	size_t priv_size;
 
 	if (!ops || !ops->xmit || !ops->ed || !ops->start ||
@@ -244,24 +244,24 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 	}
 
 	/* Ensure 32-byte alignment of our private data and hw private data.
-	 * We use the wpan_phy priv data for both our mac802154_priv and for
+	 * We use the wpan_phy priv data for both our ieee802154_local and for
 	 * the driver's private data
 	 *
 	 * in memory it'll be like this:
 	 *
-	 * +-----------------------+
-	 * | struct wpan_phy       |
-	 * +-----------------------+
-	 * | struct mac802154_priv |
-	 * +-----------------------+
-	 * | driver's private data |
-	 * +-----------------------+
+	 * +-------------------------+
+	 * | struct wpan_phy         |
+	 * +-------------------------+
+	 * | struct ieee802154_local |
+	 * +-------------------------+
+	 * | driver's private data   |
+	 * +-------------------------+
 	 *
 	 * Due to ieee802154 layer isn't aware of driver and MAC structures,
 	 * so lets allign them here.
 	 */
 
-	priv_size = ALIGN(sizeof(*priv), NETDEV_ALIGN) + priv_data_len;
+	priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len;
 
 	phy = wpan_phy_alloc(priv_size);
 	if (!phy) {
@@ -269,106 +269,106 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 		return NULL;
 	}
 
-	priv = wpan_phy_priv(phy);
-	priv->phy = phy;
-	priv->hw.phy = priv->phy;
-	priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
-	priv->ops = ops;
+	local = wpan_phy_priv(phy);
+	local->phy = phy;
+	local->hw.phy = local->phy;
+	local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);
+	local->ops = ops;
 
-	INIT_LIST_HEAD(&priv->slaves);
-	mutex_init(&priv->slaves_mtx);
+	INIT_LIST_HEAD(&local->slaves);
+	mutex_init(&local->slaves_mtx);
 
-	return &priv->hw;
+	return &local->hw;
 }
 EXPORT_SYMBOL(ieee802154_alloc_hw);
 
 void ieee802154_free_hw(struct ieee802154_hw *hw)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct ieee802154_local *local = mac802154_to_priv(hw);
 
-	BUG_ON(!list_empty(&priv->slaves));
+	BUG_ON(!list_empty(&local->slaves));
 
-	mutex_destroy(&priv->slaves_mtx);
+	mutex_destroy(&local->slaves_mtx);
 
-	wpan_phy_free(priv->phy);
+	wpan_phy_free(local->phy);
 }
 EXPORT_SYMBOL(ieee802154_free_hw);
 
 int ieee802154_register_hw(struct ieee802154_hw *hw)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct ieee802154_local *local = mac802154_to_priv(hw);
 	int rc = -ENOSYS;
 
 	if (hw->flags & IEEE802154_HW_TXPOWER) {
-		if (!priv->ops->set_txpower)
+		if (!local->ops->set_txpower)
 			goto out;
 
-		priv->phy->set_txpower = mac802154_set_txpower;
+		local->phy->set_txpower = mac802154_set_txpower;
 	}
 
 	if (hw->flags & IEEE802154_HW_LBT) {
-		if (!priv->ops->set_lbt)
+		if (!local->ops->set_lbt)
 			goto out;
 
-		priv->phy->set_lbt = mac802154_set_lbt;
+		local->phy->set_lbt = mac802154_set_lbt;
 	}
 
 	if (hw->flags & IEEE802154_HW_CCA_MODE) {
-		if (!priv->ops->set_cca_mode)
+		if (!local->ops->set_cca_mode)
 			goto out;
 
-		priv->phy->set_cca_mode = mac802154_set_cca_mode;
+		local->phy->set_cca_mode = mac802154_set_cca_mode;
 	}
 
 	if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
-		if (!priv->ops->set_cca_ed_level)
+		if (!local->ops->set_cca_ed_level)
 			goto out;
 
-		priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
+		local->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
 	}
 
 	if (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
-		if (!priv->ops->set_csma_params)
+		if (!local->ops->set_csma_params)
 			goto out;
 
-		priv->phy->set_csma_params = mac802154_set_csma_params;
+		local->phy->set_csma_params = mac802154_set_csma_params;
 	}
 
 	if (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
-		if (!priv->ops->set_frame_retries)
+		if (!local->ops->set_frame_retries)
 			goto out;
 
-		priv->phy->set_frame_retries = mac802154_set_frame_retries;
+		local->phy->set_frame_retries = mac802154_set_frame_retries;
 	}
 
-	priv->dev_workqueue =
-		create_singlethread_workqueue(wpan_phy_name(priv->phy));
-	if (!priv->dev_workqueue) {
+	local->dev_workqueue =
+		create_singlethread_workqueue(wpan_phy_name(local->phy));
+	if (!local->dev_workqueue) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	wpan_phy_set_dev(priv->phy, priv->hw.parent);
+	wpan_phy_set_dev(local->phy, local->hw.parent);
 
-	priv->phy->add_iface = mac802154_add_iface;
-	priv->phy->del_iface = mac802154_del_iface;
+	local->phy->add_iface = mac802154_add_iface;
+	local->phy->del_iface = mac802154_del_iface;
 
-	rc = wpan_phy_register(priv->phy);
+	rc = wpan_phy_register(local->phy);
 	if (rc < 0)
 		goto out_wq;
 
 	rtnl_lock();
 
-	mutex_lock(&priv->slaves_mtx);
-	priv->running = MAC802154_DEVICE_RUN;
-	mutex_unlock(&priv->slaves_mtx);
+	mutex_lock(&local->slaves_mtx);
+	local->running = MAC802154_DEVICE_RUN;
+	mutex_unlock(&local->slaves_mtx);
 
 	rtnl_unlock();
 
 	return 0;
 
 out_wq:
-	destroy_workqueue(priv->dev_workqueue);
+	destroy_workqueue(local->dev_workqueue);
 out:
 	return rc;
 }
@@ -376,19 +376,19 @@ EXPORT_SYMBOL(ieee802154_register_hw);
 
 void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct ieee802154_local *local = mac802154_to_priv(hw);
 	struct mac802154_sub_if_data *sdata, *next;
 
-	flush_workqueue(priv->dev_workqueue);
-	destroy_workqueue(priv->dev_workqueue);
+	flush_workqueue(local->dev_workqueue);
+	destroy_workqueue(local->dev_workqueue);
 
 	rtnl_lock();
 
-	mutex_lock(&priv->slaves_mtx);
-	priv->running = MAC802154_DEVICE_STOPPED;
-	mutex_unlock(&priv->slaves_mtx);
+	mutex_lock(&local->slaves_mtx);
+	local->running = MAC802154_DEVICE_STOPPED;
+	mutex_unlock(&local->slaves_mtx);
 
-	list_for_each_entry_safe(sdata, next, &priv->slaves, list) {
+	list_for_each_entry_safe(sdata, next, &local->slaves, list) {
 		mutex_lock(&sdata->hw->slaves_mtx);
 		list_del(&sdata->list);
 		mutex_unlock(&sdata->hw->slaves_mtx);
@@ -398,7 +398,7 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 
 	rtnl_unlock();
 
-	wpan_phy_unregister(priv->phy);
+	wpan_phy_unregister(local->phy);
 }
 EXPORT_SYMBOL(ieee802154_unregister_hw);
 
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index 868a040..a0d1ef8 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -40,7 +40,7 @@ struct hw_addr_filt_notify_work {
 	unsigned long changed;
 };
 
-static struct mac802154_priv *mac802154_slave_get_priv(struct net_device *dev)
+static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev)
 {
 	struct mac802154_sub_if_data *priv = netdev_priv(dev);
 
@@ -53,12 +53,11 @@ static void hw_addr_notify(struct work_struct *work)
 {
 	struct hw_addr_filt_notify_work *nw = container_of(work,
 			struct hw_addr_filt_notify_work, work);
-	struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev);
+	struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev);
 	int res;
 
-	res = hw->ops->set_hw_addr_filt(&hw->hw,
-					&hw->hw.hw_filt,
-					nw->changed);
+	res = local->ops->set_hw_addr_filt(&local->hw, &local->hw.hw_filt,
+					   nw->changed);
 	if (res)
 		pr_debug("failed changed mask %lx\n", nw->changed);
 
@@ -114,13 +113,13 @@ __le16 mac802154_dev_get_short_addr(const struct net_device *dev)
 void mac802154_dev_set_ieee_addr(struct net_device *dev)
 {
 	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct mac802154_priv *mac = priv->hw;
+	struct ieee802154_local *local = priv->hw;
 
 	priv->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
 
-	if (mac->ops->set_hw_addr_filt &&
-	    mac->hw.hw_filt.ieee_addr != priv->extended_addr) {
-		mac->hw.hw_filt.ieee_addr = priv->extended_addr;
+	if (local->ops->set_hw_addr_filt &&
+	    local->hw.hw_filt.ieee_addr != priv->extended_addr) {
+		local->hw.hw_filt.ieee_addr = priv->extended_addr;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_IEEEADDR_CHANGED);
 	}
 }
@@ -169,12 +168,12 @@ static void phy_chan_notify(struct work_struct *work)
 {
 	struct phy_chan_notify_work *nw = container_of(work,
 					  struct phy_chan_notify_work, work);
-	struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev);
+	struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev);
 	struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
 	int res;
 
 	mutex_lock(&priv->hw->phy->pib_lock);
-	res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
+	res = local->ops->set_channel(&local->hw, priv->page, priv->chan);
 	if (res) {
 		pr_debug("set_channel failed\n");
 	} else {
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 48f1523..5389fb7 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -53,13 +53,13 @@ struct rx_work {
 static void
 mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct ieee802154_local *local = mac802154_to_priv(hw);
 
 	mac_cb(skb)->lqi = lqi;
 	skb->protocol = htons(ETH_P_IEEE802154);
 	skb_reset_mac_header(skb);
 
-	if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
+	if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
 		u16 crc;
 
 		if (skb->len < 2) {
@@ -74,7 +74,7 @@ mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 		skb_trim(skb, skb->len - 2); /* CRC */
 	}
 
-	mac802154_wpans_rx(priv, skb);
+	mac802154_wpans_rx(local, skb);
 
 	return;
 
@@ -93,7 +93,7 @@ static void mac802154_rx_worker(struct work_struct *work)
 void
 ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
-	struct mac802154_priv *priv = mac802154_to_priv(hw);
+	struct ieee802154_local *local = mac802154_to_priv(hw);
 	struct rx_work *work;
 
 	if (!skb)
@@ -108,6 +108,6 @@ ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 	work->hw = hw;
 	work->lqi = lqi;
 
-	queue_work(priv->dev_workqueue, &work->work);
+	queue_work(local->dev_workqueue, &work->work);
 }
 EXPORT_SYMBOL(ieee802154_rx_irqsafe);
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index bacb6ce..7074521 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -37,7 +37,7 @@
 struct xmit_work {
 	struct sk_buff *skb;
 	struct work_struct work;
-	struct mac802154_priv *priv;
+	struct ieee802154_local *local;
 	u8 chan;
 	u8 page;
 };
@@ -48,10 +48,10 @@ static void mac802154_xmit_worker(struct work_struct *work)
 	struct mac802154_sub_if_data *sdata;
 	int res;
 
-	mutex_lock(&xw->priv->phy->pib_lock);
-	if (xw->priv->phy->current_channel != xw->chan ||
-	    xw->priv->phy->current_page != xw->page) {
-		res = xw->priv->ops->set_channel(&xw->priv->hw,
+	mutex_lock(&xw->local->phy->pib_lock);
+	if (xw->local->phy->current_channel != xw->chan ||
+	    xw->local->phy->current_page != xw->page) {
+		res = xw->local->ops->set_channel(&xw->local->hw,
 						  xw->page,
 						  xw->chan);
 		if (res) {
@@ -59,20 +59,20 @@ static void mac802154_xmit_worker(struct work_struct *work)
 			goto out;
 		}
 
-		xw->priv->phy->current_channel = xw->chan;
-		xw->priv->phy->current_page = xw->page;
+		xw->local->phy->current_channel = xw->chan;
+		xw->local->phy->current_page = xw->page;
 	}
 
-	res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
+	res = xw->local->ops->xmit(&xw->local->hw, xw->skb);
 	if (res)
 		pr_debug("transmission failed\n");
 
 out:
-	mutex_unlock(&xw->priv->phy->pib_lock);
+	mutex_unlock(&xw->local->phy->pib_lock);
 
 	/* Restart the netif queue on each sub_if_data object. */
 	rcu_read_lock();
-	list_for_each_entry_rcu(sdata, &xw->priv->slaves, list)
+	list_for_each_entry_rcu(sdata, &xw->local->slaves, list)
 		netif_wake_queue(sdata->dev);
 	rcu_read_unlock();
 
@@ -81,18 +81,18 @@ out:
 	kfree(xw);
 }
 
-netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
+netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
 			 u8 page, u8 chan)
 {
 	struct xmit_work *work;
 	struct mac802154_sub_if_data *sdata;
 
-	if (!(priv->phy->channels_supported[page] & (1 << chan))) {
+	if (!(local->phy->channels_supported[page] & (1 << chan))) {
 		WARN_ON(1);
 		goto err_tx;
 	}
 
-	if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
+	if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
 		u16 crc = crc_ccitt(0, skb->data, skb->len);
 		u8 *data = skb_put(skb, 2);
 
@@ -100,7 +100,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 		data[1] = crc >> 8;
 	}
 
-	if (skb_cow_head(skb, priv->hw.extra_tx_headroom))
+	if (skb_cow_head(skb, local->hw.extra_tx_headroom))
 		goto err_tx;
 
 	work = kzalloc(sizeof(*work), GFP_ATOMIC);
@@ -111,17 +111,17 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 
 	/* Stop the netif queue on each sub_if_data object. */
 	rcu_read_lock();
-	list_for_each_entry_rcu(sdata, &priv->slaves, list)
+	list_for_each_entry_rcu(sdata, &local->slaves, list)
 		netif_stop_queue(sdata->dev);
 	rcu_read_unlock();
 
 	INIT_WORK(&work->work, mac802154_xmit_worker);
 	work->skb = skb;
-	work->priv = priv;
+	work->local = local;
 	work->page = page;
 	work->chan = chan;
 
-	queue_work(priv->dev_workqueue, &work->work);
+	queue_work(local->dev_workqueue, &work->work);
 
 	return NETDEV_TX_OK;
 
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index b6f7f75..cc7bbdd 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -566,7 +566,7 @@ static int mac802154_parse_frame_start(struct sk_buff *skb,
 	return 0;
 }
 
-void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
+void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb)
 {
 	int ret;
 	struct mac802154_sub_if_data *sdata;
@@ -579,7 +579,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
 	}
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(sdata, &priv->slaves, list) {
+	list_for_each_entry_rcu(sdata, &local->slaves, list) {
 		if (sdata->type != NL802154_IFTYPE_NODE ||
 		    !netif_running(sdata->dev))
 			continue;
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 07/11] mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (5 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 06/11] mac802154: rename mac802154_priv to ieee802154_local Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 08/11] mac802154: rename mac802154.h to ieee802154_i.h Alexander Aring
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

In wireless they don't name it macXXXX it's ieeeXXXX.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/mac802154.h |   2 +-
 net/mac802154/mac_cmd.c   |   4 +-
 net/mac802154/main.c      |  52 ++++++-------
 net/mac802154/mib.c       | 192 +++++++++++++++++++++++-----------------------
 net/mac802154/tx.c        |   4 +-
 net/mac802154/wpan.c      | 137 +++++++++++++++++----------------
 6 files changed, 196 insertions(+), 195 deletions(-)

diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index bf3a08e..9fe20cd 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -70,7 +70,7 @@ struct ieee802154_local {
  * Each ieee802154 device/transceiver may have several slaves and able
  * to be associated with several networks at the same time.
  */
-struct mac802154_sub_if_data {
+struct ieee802154_sub_if_data {
 	struct list_head list; /* the ieee802154_priv->slaves list */
 
 	struct ieee802154_local *hw;
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
index bf80913..08a6161 100644
--- a/net/mac802154/mac_cmd.c
+++ b/net/mac802154/mac_cmd.c
@@ -79,11 +79,11 @@ static int mac802154_mlme_start_req(struct net_device *dev,
 
 static struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	return to_phy(get_device(&priv->hw->phy->dev));
+	return to_phy(get_device(&sdata->hw->phy->dev));
 }
 
 static struct ieee802154_llsec_ops mac802154_llsec_ops = {
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 24548ce..eb17dbc 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -31,28 +31,28 @@
 
 int mac802154_slave_open(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct mac802154_sub_if_data *subif;
-	struct ieee802154_local *local = priv->hw;
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
+	struct ieee802154_sub_if_data *subif;
+	struct ieee802154_local *local = sdata->hw;
 	int res = 0;
 
 	ASSERT_RTNL();
 
-	if (priv->type == NL802154_IFTYPE_NODE) {
-		mutex_lock(&priv->hw->slaves_mtx);
-		list_for_each_entry(subif, &priv->hw->slaves, list) {
-			if (subif != priv && subif->type == priv->type &&
+	if (sdata->type == NL802154_IFTYPE_NODE) {
+		mutex_lock(&sdata->hw->slaves_mtx);
+		list_for_each_entry(subif, &sdata->hw->slaves, list) {
+			if (subif != sdata && subif->type == sdata->type &&
 			    subif->running) {
-				mutex_unlock(&priv->hw->slaves_mtx);
+				mutex_unlock(&sdata->hw->slaves_mtx);
 				return -EBUSY;
 			}
 		}
-		mutex_unlock(&priv->hw->slaves_mtx);
+		mutex_unlock(&sdata->hw->slaves_mtx);
 	}
 
-	mutex_lock(&priv->hw->slaves_mtx);
-	priv->running = true;
-	mutex_unlock(&priv->hw->slaves_mtx);
+	mutex_lock(&sdata->hw->slaves_mtx);
+	sdata->running = true;
+	mutex_unlock(&sdata->hw->slaves_mtx);
 
 	if (local->open_count++ == 0) {
 		res = local->ops->start(&local->hw);
@@ -74,23 +74,23 @@ int mac802154_slave_open(struct net_device *dev)
 	netif_start_queue(dev);
 	return 0;
 err:
-	priv->hw->open_count--;
+	sdata->hw->open_count--;
 
 	return res;
 }
 
 int mac802154_slave_close(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct ieee802154_local *local = priv->hw;
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
+	struct ieee802154_local *local = sdata->hw;
 
 	ASSERT_RTNL();
 
 	netif_stop_queue(dev);
 
-	mutex_lock(&priv->hw->slaves_mtx);
-	priv->running = false;
-	mutex_unlock(&priv->hw->slaves_mtx);
+	mutex_lock(&sdata->hw->slaves_mtx);
+	sdata->running = false;
+	mutex_unlock(&sdata->hw->slaves_mtx);
 
 	if (!--local->open_count)
 		local->ops->stop(&local->hw);
@@ -101,15 +101,15 @@ int mac802154_slave_close(struct net_device *dev)
 static int
 mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv;
+	struct ieee802154_sub_if_data *sdata;
 	struct ieee802154_local *local;
 	int err;
 
 	local = wpan_phy_priv(phy);
 
-	priv = netdev_priv(dev);
-	priv->dev = dev;
-	priv->hw = local;
+	sdata = netdev_priv(dev);
+	sdata->dev = dev;
+	sdata->hw = local;
 
 	dev->needed_headroom = local->hw.extra_tx_headroom;
 
@@ -128,7 +128,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
 
 	rtnl_lock();
 	mutex_lock(&local->slaves_mtx);
-	list_add_tail_rcu(&priv->list, &local->slaves);
+	list_add_tail_rcu(&sdata->list, &local->slaves);
 	mutex_unlock(&local->slaves_mtx);
 	rtnl_unlock();
 
@@ -138,7 +138,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
 static void
 mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
 {
-	struct mac802154_sub_if_data *sdata;
+	struct ieee802154_sub_if_data *sdata;
 
 	ASSERT_RTNL();
 
@@ -162,7 +162,7 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
 
 	switch (type) {
 	case NL802154_IFTYPE_NODE:
-		dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
+		dev = alloc_netdev(sizeof(struct ieee802154_sub_if_data),
 				   name, NET_NAME_UNKNOWN,
 				   mac802154_wpan_setup);
 		break;
@@ -377,7 +377,7 @@ EXPORT_SYMBOL(ieee802154_register_hw);
 void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 {
 	struct ieee802154_local *local = mac802154_to_priv(hw);
-	struct mac802154_sub_if_data *sdata, *next;
+	struct ieee802154_sub_if_data *sdata, *next;
 
 	flush_workqueue(local->dev_workqueue);
 	destroy_workqueue(local->dev_workqueue);
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index a0d1ef8..40c9952 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -42,11 +42,11 @@ struct hw_addr_filt_notify_work {
 
 static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	return priv->hw;
+	return sdata->hw;
 }
 
 static void hw_addr_notify(struct work_struct *work)
@@ -66,7 +66,7 @@ static void hw_addr_notify(struct work_struct *work)
 
 static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct hw_addr_filt_notify_work *work;
 
 	work = kzalloc(sizeof(*work), GFP_ATOMIC);
@@ -76,92 +76,92 @@ static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
 	INIT_WORK(&work->work, hw_addr_notify);
 	work->dev = dev;
 	work->changed = changed;
-	queue_work(priv->hw->dev_workqueue, &work->work);
+	queue_work(sdata->hw->dev_workqueue, &work->work);
 }
 
 void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	spin_lock_bh(&priv->mib_lock);
-	priv->short_addr = val;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	sdata->short_addr = val;
+	spin_unlock_bh(&sdata->mib_lock);
 
-	if ((priv->hw->ops->set_hw_addr_filt) &&
-	    (priv->hw->hw.hw_filt.short_addr != priv->short_addr)) {
-		priv->hw->hw.hw_filt.short_addr = priv->short_addr;
+	if ((sdata->hw->ops->set_hw_addr_filt) &&
+	    (sdata->hw->hw.hw_filt.short_addr != sdata->short_addr)) {
+		sdata->hw->hw.hw_filt.short_addr = sdata->short_addr;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_SADDR_CHANGED);
 	}
 }
 
 __le16 mac802154_dev_get_short_addr(const struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	__le16 ret;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	spin_lock_bh(&priv->mib_lock);
-	ret = priv->short_addr;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	ret = sdata->short_addr;
+	spin_unlock_bh(&sdata->mib_lock);
 
 	return ret;
 }
 
 void mac802154_dev_set_ieee_addr(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct ieee802154_local *local = priv->hw;
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
+	struct ieee802154_local *local = sdata->hw;
 
-	priv->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
+	sdata->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
 
 	if (local->ops->set_hw_addr_filt &&
-	    local->hw.hw_filt.ieee_addr != priv->extended_addr) {
-		local->hw.hw_filt.ieee_addr = priv->extended_addr;
+	    local->hw.hw_filt.ieee_addr != sdata->extended_addr) {
+		local->hw.hw_filt.ieee_addr = sdata->extended_addr;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_IEEEADDR_CHANGED);
 	}
 }
 
 __le16 mac802154_dev_get_pan_id(const struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	__le16 ret;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	spin_lock_bh(&priv->mib_lock);
-	ret = priv->pan_id;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	ret = sdata->pan_id;
+	spin_unlock_bh(&sdata->mib_lock);
 
 	return ret;
 }
 
 void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	spin_lock_bh(&priv->mib_lock);
-	priv->pan_id = val;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	sdata->pan_id = val;
+	spin_unlock_bh(&sdata->mib_lock);
 
-	if ((priv->hw->ops->set_hw_addr_filt) &&
-	    (priv->hw->hw.hw_filt.pan_id != priv->pan_id)) {
-		priv->hw->hw.hw_filt.pan_id = priv->pan_id;
+	if ((sdata->hw->ops->set_hw_addr_filt) &&
+	    (sdata->hw->hw.hw_filt.pan_id != sdata->pan_id)) {
+		sdata->hw->hw.hw_filt.pan_id = sdata->pan_id;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_PANID_CHANGED);
 	}
 }
 
 u8 mac802154_dev_get_dsn(const struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	return priv->dsn++;
+	return sdata->dsn++;
 }
 
 static void phy_chan_notify(struct work_struct *work)
@@ -169,38 +169,38 @@ static void phy_chan_notify(struct work_struct *work)
 	struct phy_chan_notify_work *nw = container_of(work,
 					  struct phy_chan_notify_work, work);
 	struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev);
-	struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(nw->dev);
 	int res;
 
-	mutex_lock(&priv->hw->phy->pib_lock);
-	res = local->ops->set_channel(&local->hw, priv->page, priv->chan);
+	mutex_lock(&sdata->hw->phy->pib_lock);
+	res = local->ops->set_channel(&local->hw, sdata->page, sdata->chan);
 	if (res) {
 		pr_debug("set_channel failed\n");
 	} else {
-		priv->hw->phy->current_channel = priv->chan;
-		priv->hw->phy->current_page = priv->page;
+		sdata->hw->phy->current_channel = sdata->chan;
+		sdata->hw->phy->current_page = sdata->page;
 	}
-	mutex_unlock(&priv->hw->phy->pib_lock);
+	mutex_unlock(&sdata->hw->phy->pib_lock);
 
 	kfree(nw);
 }
 
 void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct phy_chan_notify_work *work;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	spin_lock_bh(&priv->mib_lock);
-	priv->page = page;
-	priv->chan = chan;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	sdata->page = page;
+	sdata->chan = chan;
+	spin_unlock_bh(&sdata->mib_lock);
 
-	mutex_lock(&priv->hw->phy->pib_lock);
-	if (priv->hw->phy->current_channel != priv->chan ||
-	    priv->hw->phy->current_page != priv->page) {
-		mutex_unlock(&priv->hw->phy->pib_lock);
+	mutex_lock(&sdata->hw->phy->pib_lock);
+	if (sdata->hw->phy->current_channel != sdata->chan ||
+	    sdata->hw->phy->current_page != sdata->page) {
+		mutex_unlock(&sdata->hw->phy->pib_lock);
 
 		work = kzalloc(sizeof(*work), GFP_ATOMIC);
 		if (!work)
@@ -208,9 +208,9 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
 
 		INIT_WORK(&work->work, phy_chan_notify);
 		work->dev = dev;
-		queue_work(priv->hw->dev_workqueue, &work->work);
+		queue_work(sdata->hw->dev_workqueue, &work->work);
 	} else {
-		mutex_unlock(&priv->hw->phy->pib_lock);
+		mutex_unlock(&sdata->hw->phy->pib_lock);
 	}
 }
 
@@ -218,14 +218,14 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
 int mac802154_get_params(struct net_device *dev,
 			 struct ieee802154_llsec_params *params)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_get_params(&priv->sec, params);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_get_params(&sdata->sec, params);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -234,14 +234,14 @@ int mac802154_set_params(struct net_device *dev,
 			 const struct ieee802154_llsec_params *params,
 			 int changed)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_set_params(&priv->sec, params, changed);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_set_params(&sdata->sec, params, changed);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -251,14 +251,14 @@ int mac802154_add_key(struct net_device *dev,
 		      const struct ieee802154_llsec_key_id *id,
 		      const struct ieee802154_llsec_key *key)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_key_add(&priv->sec, id, key);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_key_add(&sdata->sec, id, key);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -266,14 +266,14 @@ int mac802154_add_key(struct net_device *dev,
 int mac802154_del_key(struct net_device *dev,
 		      const struct ieee802154_llsec_key_id *id)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_key_del(&priv->sec, id);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_key_del(&sdata->sec, id);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -282,28 +282,28 @@ int mac802154_del_key(struct net_device *dev,
 int mac802154_add_dev(struct net_device *dev,
 		      const struct ieee802154_llsec_device *llsec_dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_dev_add(&priv->sec, llsec_dev);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_dev_add(&sdata->sec, llsec_dev);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
 
 int mac802154_del_dev(struct net_device *dev, __le64 dev_addr)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_dev_del(&priv->sec, dev_addr);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_dev_del(&sdata->sec, dev_addr);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -313,14 +313,14 @@ int mac802154_add_devkey(struct net_device *dev,
 			 __le64 device_addr,
 			 const struct ieee802154_llsec_device_key *key)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_devkey_add(&priv->sec, device_addr, key);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_devkey_add(&sdata->sec, device_addr, key);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -329,14 +329,14 @@ int mac802154_del_devkey(struct net_device *dev,
 			 __le64 device_addr,
 			 const struct ieee802154_llsec_device_key *key)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_devkey_del(&priv->sec, device_addr, key);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_devkey_del(&sdata->sec, device_addr, key);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -345,14 +345,14 @@ int mac802154_del_devkey(struct net_device *dev,
 int mac802154_add_seclevel(struct net_device *dev,
 			   const struct ieee802154_llsec_seclevel *sl)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_seclevel_add(&priv->sec, sl);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_seclevel_add(&sdata->sec, sl);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -360,14 +360,14 @@ int mac802154_add_seclevel(struct net_device *dev,
 int mac802154_del_seclevel(struct net_device *dev,
 			   const struct ieee802154_llsec_seclevel *sl)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	int res;
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
-	res = mac802154_llsec_seclevel_del(&priv->sec, sl);
-	mutex_unlock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
+	res = mac802154_llsec_seclevel_del(&sdata->sec, sl);
+	mutex_unlock(&sdata->sec_mtx);
 
 	return res;
 }
@@ -375,28 +375,28 @@ int mac802154_del_seclevel(struct net_device *dev,
 
 void mac802154_lock_table(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_lock(&priv->sec_mtx);
+	mutex_lock(&sdata->sec_mtx);
 }
 
 void mac802154_get_table(struct net_device *dev,
 			 struct ieee802154_llsec_table **t)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	*t = &priv->sec.table;
+	*t = &sdata->sec.table;
 }
 
 void mac802154_unlock_table(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	mutex_unlock(&priv->sec_mtx);
+	mutex_unlock(&sdata->sec_mtx);
 }
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 7074521..192b0dd 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -45,7 +45,7 @@ struct xmit_work {
 static void mac802154_xmit_worker(struct work_struct *work)
 {
 	struct xmit_work *xw = container_of(work, struct xmit_work, work);
-	struct mac802154_sub_if_data *sdata;
+	struct ieee802154_sub_if_data *sdata;
 	int res;
 
 	mutex_lock(&xw->local->phy->pib_lock);
@@ -85,7 +85,7 @@ netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
 			 u8 page, u8 chan)
 {
 	struct xmit_work *work;
-	struct mac802154_sub_if_data *sdata;
+	struct ieee802154_sub_if_data *sdata;
 
 	if (!(local->phy->channels_supported[page] & (1 << chan))) {
 		WARN_ON(1);
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index cc7bbdd..663f89d 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -37,7 +37,7 @@
 
 static int mac802154_wpan_update_llsec(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev);
 	int rc = 0;
 
@@ -45,10 +45,10 @@ static int mac802154_wpan_update_llsec(struct net_device *dev)
 		struct ieee802154_llsec_params params;
 		int changed = 0;
 
-		params.pan_id = priv->pan_id;
+		params.pan_id = sdata->pan_id;
 		changed |= IEEE802154_LLSEC_PARAM_PAN_ID;
 
-		params.hwaddr = priv->extended_addr;
+		params.hwaddr = sdata->extended_addr;
 		changed |= IEEE802154_LLSEC_PARAM_HWADDR;
 
 		rc = ops->llsec->set_params(dev, &params, changed);
@@ -60,20 +60,20 @@ static int mac802154_wpan_update_llsec(struct net_device *dev)
 static int
 mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct sockaddr_ieee802154 *sa =
 		(struct sockaddr_ieee802154 *)&ifr->ifr_addr;
 	int err = -ENOIOCTLCMD;
 
-	spin_lock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
 
 	switch (cmd) {
 	case SIOCGIFADDR:
 	{
 		u16 pan_id, short_addr;
 
-		pan_id = le16_to_cpu(priv->pan_id);
-		short_addr = le16_to_cpu(priv->short_addr);
+		pan_id = le16_to_cpu(sdata->pan_id);
+		short_addr = le16_to_cpu(sdata->short_addr);
 		if (pan_id == IEEE802154_PANID_BROADCAST ||
 		    short_addr == IEEE802154_ADDR_BROADCAST) {
 			err = -EADDRNOTAVAIL;
@@ -100,14 +100,14 @@ mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 			break;
 		}
 
-		priv->pan_id = cpu_to_le16(sa->addr.pan_id);
-		priv->short_addr = cpu_to_le16(sa->addr.short_addr);
+		sdata->pan_id = cpu_to_le16(sa->addr.pan_id);
+		sdata->short_addr = cpu_to_le16(sa->addr.short_addr);
 
 		err = mac802154_wpan_update_llsec(dev);
 		break;
 	}
 
-	spin_unlock_bh(&priv->mib_lock);
+	spin_unlock_bh(&sdata->mib_lock);
 	return err;
 }
 
@@ -127,11 +127,11 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
 int mac802154_set_mac_params(struct net_device *dev,
 			     const struct ieee802154_mac_params *params)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
-	mutex_lock(&priv->hw->slaves_mtx);
-	priv->mac_params = *params;
-	mutex_unlock(&priv->hw->slaves_mtx);
+	mutex_lock(&sdata->hw->slaves_mtx);
+	sdata->mac_params = *params;
+	mutex_unlock(&sdata->hw->slaves_mtx);
 
 	return 0;
 }
@@ -139,18 +139,18 @@ int mac802154_set_mac_params(struct net_device *dev,
 void mac802154_get_mac_params(struct net_device *dev,
 			      struct ieee802154_mac_params *params)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
-	mutex_lock(&priv->hw->slaves_mtx);
-	*params = priv->mac_params;
-	mutex_unlock(&priv->hw->slaves_mtx);
+	mutex_lock(&sdata->hw->slaves_mtx);
+	*params = sdata->mac_params;
+	mutex_unlock(&sdata->hw->slaves_mtx);
 }
 
 static int mac802154_wpan_open(struct net_device *dev)
 {
 	int rc;
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
-	struct wpan_phy *phy = priv->hw->phy;
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
+	struct wpan_phy *phy = sdata->hw->phy;
 
 	rc = mac802154_slave_open(dev);
 	if (rc < 0)
@@ -159,40 +159,40 @@ static int mac802154_wpan_open(struct net_device *dev)
 	mutex_lock(&phy->pib_lock);
 
 	if (phy->set_txpower) {
-		rc = phy->set_txpower(phy, priv->mac_params.transmit_power);
+		rc = phy->set_txpower(phy, sdata->mac_params.transmit_power);
 		if (rc < 0)
 			goto out;
 	}
 
 	if (phy->set_lbt) {
-		rc = phy->set_lbt(phy, priv->mac_params.lbt);
+		rc = phy->set_lbt(phy, sdata->mac_params.lbt);
 		if (rc < 0)
 			goto out;
 	}
 
 	if (phy->set_cca_mode) {
-		rc = phy->set_cca_mode(phy, priv->mac_params.cca_mode);
+		rc = phy->set_cca_mode(phy, sdata->mac_params.cca_mode);
 		if (rc < 0)
 			goto out;
 	}
 
 	if (phy->set_cca_ed_level) {
-		rc = phy->set_cca_ed_level(phy, priv->mac_params.cca_ed_level);
+		rc = phy->set_cca_ed_level(phy, sdata->mac_params.cca_ed_level);
 		if (rc < 0)
 			goto out;
 	}
 
 	if (phy->set_csma_params) {
-		rc = phy->set_csma_params(phy, priv->mac_params.min_be,
-					  priv->mac_params.max_be,
-					  priv->mac_params.csma_retries);
+		rc = phy->set_csma_params(phy, sdata->mac_params.min_be,
+					  sdata->mac_params.max_be,
+					  sdata->mac_params.csma_retries);
 		if (rc < 0)
 			goto out;
 	}
 
 	if (phy->set_frame_retries) {
 		rc = phy->set_frame_retries(phy,
-					    priv->mac_params.frame_retries);
+					    sdata->mac_params.frame_retries);
 		if (rc < 0)
 			goto out;
 	}
@@ -205,14 +205,14 @@ out:
 	return rc;
 }
 
-static int mac802154_set_header_security(struct mac802154_sub_if_data *priv,
+static int mac802154_set_header_security(struct ieee802154_sub_if_data *sdata,
 					 struct ieee802154_hdr *hdr,
 					 const struct ieee802154_mac_cb *cb)
 {
 	struct ieee802154_llsec_params params;
 	u8 level;
 
-	mac802154_llsec_get_params(&priv->sec, &params);
+	mac802154_llsec_get_params(&sdata->sec, &params);
 
 	if (!params.enabled && cb->secen_override && cb->secen)
 		return -EINVAL;
@@ -245,7 +245,7 @@ static int mac802154_header_create(struct sk_buff *skb,
 				   unsigned len)
 {
 	struct ieee802154_hdr hdr;
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct ieee802154_mac_cb *cb = mac_cb(skb);
 	int hlen;
 
@@ -258,25 +258,25 @@ static int mac802154_header_create(struct sk_buff *skb,
 	hdr.fc.ack_request = cb->ackreq;
 	hdr.seq = ieee802154_mlme_ops(dev)->get_dsn(dev);
 
-	if (mac802154_set_header_security(priv, &hdr, cb) < 0)
+	if (mac802154_set_header_security(sdata, &hdr, cb) < 0)
 		return -EINVAL;
 
 	if (!saddr) {
-		spin_lock_bh(&priv->mib_lock);
+		spin_lock_bh(&sdata->mib_lock);
 
-		if (priv->short_addr == cpu_to_le16(IEEE802154_ADDR_BROADCAST) ||
-		    priv->short_addr == cpu_to_le16(IEEE802154_ADDR_UNDEF) ||
-		    priv->pan_id == cpu_to_le16(IEEE802154_PANID_BROADCAST)) {
+		if (sdata->short_addr == cpu_to_le16(IEEE802154_ADDR_BROADCAST) ||
+		    sdata->short_addr == cpu_to_le16(IEEE802154_ADDR_UNDEF) ||
+		    sdata->pan_id == cpu_to_le16(IEEE802154_PANID_BROADCAST)) {
 			hdr.source.mode = IEEE802154_ADDR_LONG;
-			hdr.source.extended_addr = priv->extended_addr;
+			hdr.source.extended_addr = sdata->extended_addr;
 		} else {
 			hdr.source.mode = IEEE802154_ADDR_SHORT;
-			hdr.source.short_addr = priv->short_addr;
+			hdr.source.short_addr = sdata->short_addr;
 		}
 
-		hdr.source.pan_id = priv->pan_id;
+		hdr.source.pan_id = sdata->pan_id;
 
-		spin_unlock_bh(&priv->mib_lock);
+		spin_unlock_bh(&sdata->mib_lock);
 	} else {
 		hdr.source = *(const struct ieee802154_addr *)saddr;
 	}
@@ -314,16 +314,16 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 static netdev_tx_t
 mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv;
+	struct ieee802154_sub_if_data *sdata;
 	u8 chan, page;
 	int rc;
 
-	priv = netdev_priv(dev);
+	sdata = netdev_priv(dev);
 
-	spin_lock_bh(&priv->mib_lock);
-	chan = priv->chan;
-	page = priv->page;
-	spin_unlock_bh(&priv->mib_lock);
+	spin_lock_bh(&sdata->mib_lock);
+	chan = sdata->chan;
+	page = sdata->page;
+	spin_unlock_bh(&sdata->mib_lock);
 
 	if (chan == MAC802154_CHAN_NONE ||
 	    page >= WPAN_NUM_PAGES ||
@@ -332,7 +332,7 @@ mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_OK;
 	}
 
-	rc = mac802154_llsec_encrypt(&priv->sec, skb);
+	rc = mac802154_llsec_encrypt(&sdata->sec, skb);
 	if (rc) {
 		pr_warn("encryption failed: %i\n", rc);
 		kfree_skb(skb);
@@ -343,7 +343,7 @@ mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
 	dev->stats.tx_packets++;
 	dev->stats.tx_bytes += skb->len;
 
-	return mac802154_tx(priv->hw, skb, page, chan);
+	return mac802154_tx(sdata->hw, skb, page, chan);
 }
 
 static struct header_ops mac802154_header_ops = {
@@ -361,16 +361,16 @@ static const struct net_device_ops mac802154_wpan_ops = {
 
 static void mac802154_wpan_free(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
-	mac802154_llsec_destroy(&priv->sec);
+	mac802154_llsec_destroy(&sdata->sec);
 
 	free_netdev(dev);
 }
 
 void mac802154_wpan_setup(struct net_device *dev)
 {
-	struct mac802154_sub_if_data *priv;
+	struct ieee802154_sub_if_data *sdata;
 
 	dev->addr_len		= IEEE802154_ADDR_LEN;
 	memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN);
@@ -388,28 +388,29 @@ void mac802154_wpan_setup(struct net_device *dev)
 	dev->netdev_ops		= &mac802154_wpan_ops;
 	dev->ml_priv		= &mac802154_mlme_wpan;
 
-	priv = netdev_priv(dev);
-	priv->type = NL802154_IFTYPE_NODE;
+	sdata = netdev_priv(dev);
+	sdata->type = NL802154_IFTYPE_NODE;
 
-	priv->chan = MAC802154_CHAN_NONE;
-	priv->page = 0;
+	sdata->chan = MAC802154_CHAN_NONE;
+	sdata->page = 0;
 
-	spin_lock_init(&priv->mib_lock);
-	mutex_init(&priv->sec_mtx);
+	spin_lock_init(&sdata->mib_lock);
+	mutex_init(&sdata->sec_mtx);
 
-	get_random_bytes(&priv->bsn, 1);
-	get_random_bytes(&priv->dsn, 1);
+	get_random_bytes(&sdata->bsn, 1);
+	get_random_bytes(&sdata->dsn, 1);
 
 	/* defaults per 802.15.4-2011 */
-	priv->mac_params.min_be = 3;
-	priv->mac_params.max_be = 5;
-	priv->mac_params.csma_retries = 4;
-	priv->mac_params.frame_retries = -1; /* for compatibility, actual default is 3 */
+	sdata->mac_params.min_be = 3;
+	sdata->mac_params.max_be = 5;
+	sdata->mac_params.csma_retries = 4;
+	/* for compatibility, actual default is 3 */
+	sdata->mac_params.frame_retries = -1;
 
-	priv->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
-	priv->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
+	sdata->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
+	sdata->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
 
-	mac802154_llsec_init(&priv->sec);
+	mac802154_llsec_init(&sdata->sec);
 }
 
 static int mac802154_process_data(struct net_device *dev, struct sk_buff *skb)
@@ -418,7 +419,7 @@ static int mac802154_process_data(struct net_device *dev, struct sk_buff *skb)
 }
 
 static int
-mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb,
+mac802154_subif_frame(struct ieee802154_sub_if_data *sdata, struct sk_buff *skb,
 		      const struct ieee802154_hdr *hdr)
 {
 	__le16 span, sshort;
@@ -569,7 +570,7 @@ static int mac802154_parse_frame_start(struct sk_buff *skb,
 void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb)
 {
 	int ret;
-	struct mac802154_sub_if_data *sdata;
+	struct ieee802154_sub_if_data *sdata;
 	struct ieee802154_hdr hdr;
 
 	ret = mac802154_parse_frame_start(skb, &hdr);
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 08/11] mac802154: rename mac802154.h to ieee802154_i.h
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (6 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 07/11] mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 09/11] mac802154: rename hw subif_data variable to local Alexander Aring
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch name the mac802154.h INTERNAL header to ieee802154_i.h like
wireless stack. This avoids confusing with the not internal header
net/mac802154.h header.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/ieee802154_i.h | 167 ++++++++++++++++++++++++++++++++++++++++++
 net/mac802154/llsec.c        |   2 +-
 net/mac802154/mac802154.h    | 169 -------------------------------------------
 net/mac802154/mac_cmd.c      |   2 +-
 net/mac802154/main.c         |   2 +-
 net/mac802154/mib.c          |   2 +-
 net/mac802154/rx.c           |   2 +-
 net/mac802154/tx.c           |   2 +-
 net/mac802154/wpan.c         |   2 +-
 9 files changed, 174 insertions(+), 176 deletions(-)
 create mode 100644 net/mac802154/ieee802154_i.h
 delete mode 100644 net/mac802154/mac802154.h

diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
new file mode 100644
index 0000000..e7a1b11
--- /dev/null
+++ b/net/mac802154/ieee802154_i.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2007-2012 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Written by:
+ * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
+ * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
+ * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
+ */
+#ifndef __IEEE802154_I_H
+#define __IEEE802154_I_H
+
+#include <linux/mutex.h>
+#include <net/mac802154.h>
+#include <net/ieee802154_netdev.h>
+
+#include "llsec.h"
+
+struct ieee802154_local;
+
+/* Slave interface definition.
+ *
+ * Slaves represent typical network interfaces available from userspace.
+ * Each ieee802154 device/transceiver may have several slaves and able
+ * to be associated with several networks at the same time.
+ */
+struct ieee802154_sub_if_data {
+	struct list_head list; /* the ieee802154_priv->slaves list */
+
+	struct ieee802154_local *hw;
+	struct net_device *dev;
+
+	int type;
+	bool running;
+
+	spinlock_t mib_lock;
+
+	__le16 pan_id;
+	__le16 short_addr;
+	__le64 extended_addr;
+
+	u8 chan;
+	u8 page;
+
+	struct ieee802154_mac_params mac_params;
+
+	/* MAC BSN field */
+	u8 bsn;
+	/* MAC DSN field */
+	u8 dsn;
+
+	/* protects sec from concurrent access by netlink. access by
+	 * encrypt/decrypt/header_create safe without additional protection.
+	 */
+	struct mutex sec_mtx;
+
+	struct mac802154_llsec sec;
+};
+
+/* mac802154 device private data */
+struct ieee802154_local {
+	struct ieee802154_hw hw;
+	struct ieee802154_ops *ops;
+
+	/* ieee802154 phy */
+	struct wpan_phy *phy;
+
+	int open_count;
+
+	/* As in mac80211 slaves list is modified:
+	 * 1) under the RTNL
+	 * 2) protected by slaves_mtx;
+	 * 3) in an RCU manner
+	 *
+	 * So atomic readers can use any of this protection methods.
+	 */
+	struct list_head	slaves;
+	struct mutex		slaves_mtx;
+
+	/* This one is used for scanning and other jobs not to be interfered
+	 * with serial driver.
+	 */
+	struct workqueue_struct	*dev_workqueue;
+
+	/* SoftMAC device is registered and running. One can add subinterfaces.
+	 * This flag should be modified under slaves_mtx and RTNL, so you can
+	 * read them using any of protection methods.
+	 */
+	bool running;
+};
+
+#define	MAC802154_DEVICE_STOPPED	0x00
+#define MAC802154_DEVICE_RUN		0x01
+
+#define mac802154_to_priv(_hw)	container_of(_hw, struct ieee802154_local, hw)
+
+#define MAC802154_CHAN_NONE		0xff /* No channel is assigned */
+
+extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
+extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
+
+int mac802154_slave_open(struct net_device *dev);
+int mac802154_slave_close(struct net_device *dev);
+
+void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
+void mac802154_wpan_setup(struct net_device *dev);
+
+netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
+			 u8 page, u8 chan);
+
+/* MIB callbacks */
+void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
+__le16 mac802154_dev_get_short_addr(const struct net_device *dev);
+void mac802154_dev_set_ieee_addr(struct net_device *dev);
+__le16 mac802154_dev_get_pan_id(const struct net_device *dev);
+void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val);
+void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
+u8 mac802154_dev_get_dsn(const struct net_device *dev);
+
+int mac802154_set_mac_params(struct net_device *dev,
+			     const struct ieee802154_mac_params *params);
+void mac802154_get_mac_params(struct net_device *dev,
+			      struct ieee802154_mac_params *params);
+
+int mac802154_get_params(struct net_device *dev,
+			 struct ieee802154_llsec_params *params);
+int mac802154_set_params(struct net_device *dev,
+			 const struct ieee802154_llsec_params *params,
+			 int changed);
+
+int mac802154_add_key(struct net_device *dev,
+		      const struct ieee802154_llsec_key_id *id,
+		      const struct ieee802154_llsec_key *key);
+int mac802154_del_key(struct net_device *dev,
+		      const struct ieee802154_llsec_key_id *id);
+
+int mac802154_add_dev(struct net_device *dev,
+		      const struct ieee802154_llsec_device *llsec_dev);
+int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
+
+int mac802154_add_devkey(struct net_device *dev,
+			 __le64 device_addr,
+			 const struct ieee802154_llsec_device_key *key);
+int mac802154_del_devkey(struct net_device *dev,
+			 __le64 device_addr,
+			 const struct ieee802154_llsec_device_key *key);
+
+int mac802154_add_seclevel(struct net_device *dev,
+			   const struct ieee802154_llsec_seclevel *sl);
+int mac802154_del_seclevel(struct net_device *dev,
+			   const struct ieee802154_llsec_seclevel *sl);
+
+void mac802154_lock_table(struct net_device *dev);
+void mac802154_get_table(struct net_device *dev,
+			 struct ieee802154_llsec_table **t);
+void mac802154_unlock_table(struct net_device *dev);
+
+#endif /* __IEEE802154_I_H */
diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c
index 4570581..26f8761 100644
--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -20,7 +20,7 @@
 #include <net/ieee802154.h>
 #include <crypto/algapi.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 #include "llsec.h"
 
 static void llsec_key_put(struct mac802154_llsec_key *key);
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
deleted file mode 100644
index 9fe20cd..0000000
--- a/net/mac802154/mac802154.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Siemens AG
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Written by:
- * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
- * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
- * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
- * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
- */
-#ifndef MAC802154_H
-#define MAC802154_H
-
-#include <linux/mutex.h>
-#include <net/mac802154.h>
-#include <net/ieee802154_netdev.h>
-
-#include "llsec.h"
-
-/* mac802154 device private data */
-struct ieee802154_local {
-	struct ieee802154_hw hw;
-	struct ieee802154_ops *ops;
-
-	/* ieee802154 phy */
-	struct wpan_phy *phy;
-
-	int open_count;
-
-	/* As in mac80211 slaves list is modified:
-	 * 1) under the RTNL
-	 * 2) protected by slaves_mtx;
-	 * 3) in an RCU manner
-	 *
-	 * So atomic readers can use any of this protection methods.
-	 */
-	struct list_head	slaves;
-	struct mutex		slaves_mtx;
-
-	/* This one is used for scanning and other jobs not to be interfered
-	 * with serial driver.
-	 */
-	struct workqueue_struct	*dev_workqueue;
-
-	/* SoftMAC device is registered and running. One can add subinterfaces.
-	 * This flag should be modified under slaves_mtx and RTNL, so you can
-	 * read them using any of protection methods.
-	 */
-	bool running;
-};
-
-#define	MAC802154_DEVICE_STOPPED	0x00
-#define MAC802154_DEVICE_RUN		0x01
-
-/* Slave interface definition.
- *
- * Slaves represent typical network interfaces available from userspace.
- * Each ieee802154 device/transceiver may have several slaves and able
- * to be associated with several networks at the same time.
- */
-struct ieee802154_sub_if_data {
-	struct list_head list; /* the ieee802154_priv->slaves list */
-
-	struct ieee802154_local *hw;
-	struct net_device *dev;
-
-	int type;
-	bool running;
-
-	spinlock_t mib_lock;
-
-	__le16 pan_id;
-	__le16 short_addr;
-	__le64 extended_addr;
-
-	u8 chan;
-	u8 page;
-
-	struct ieee802154_mac_params mac_params;
-
-	/* MAC BSN field */
-	u8 bsn;
-	/* MAC DSN field */
-	u8 dsn;
-
-	/* protects sec from concurrent access by netlink. access by
-	 * encrypt/decrypt/header_create safe without additional protection.
-	 */
-	struct mutex sec_mtx;
-
-	struct mac802154_llsec sec;
-};
-
-#define mac802154_to_priv(_hw)	container_of(_hw, struct ieee802154_local, hw)
-
-#define MAC802154_CHAN_NONE		0xff /* No channel is assigned */
-
-extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
-extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
-
-int mac802154_slave_open(struct net_device *dev);
-int mac802154_slave_close(struct net_device *dev);
-
-void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
-void mac802154_wpan_setup(struct net_device *dev);
-
-netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
-			 u8 page, u8 chan);
-
-/* MIB callbacks */
-void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
-__le16 mac802154_dev_get_short_addr(const struct net_device *dev);
-void mac802154_dev_set_ieee_addr(struct net_device *dev);
-__le16 mac802154_dev_get_pan_id(const struct net_device *dev);
-void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val);
-void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
-u8 mac802154_dev_get_dsn(const struct net_device *dev);
-
-int mac802154_set_mac_params(struct net_device *dev,
-			     const struct ieee802154_mac_params *params);
-void mac802154_get_mac_params(struct net_device *dev,
-			      struct ieee802154_mac_params *params);
-
-int mac802154_get_params(struct net_device *dev,
-			 struct ieee802154_llsec_params *params);
-int mac802154_set_params(struct net_device *dev,
-			 const struct ieee802154_llsec_params *params,
-			 int changed);
-
-int mac802154_add_key(struct net_device *dev,
-		      const struct ieee802154_llsec_key_id *id,
-		      const struct ieee802154_llsec_key *key);
-int mac802154_del_key(struct net_device *dev,
-		      const struct ieee802154_llsec_key_id *id);
-
-int mac802154_add_dev(struct net_device *dev,
-		      const struct ieee802154_llsec_device *llsec_dev);
-int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
-
-int mac802154_add_devkey(struct net_device *dev,
-			 __le64 device_addr,
-			 const struct ieee802154_llsec_device_key *key);
-int mac802154_del_devkey(struct net_device *dev,
-			 __le64 device_addr,
-			 const struct ieee802154_llsec_device_key *key);
-
-int mac802154_add_seclevel(struct net_device *dev,
-			   const struct ieee802154_llsec_seclevel *sl);
-int mac802154_del_seclevel(struct net_device *dev,
-			   const struct ieee802154_llsec_seclevel *sl);
-
-void mac802154_lock_table(struct net_device *dev);
-void mac802154_get_table(struct net_device *dev,
-			 struct ieee802154_llsec_table **t);
-void mac802154_unlock_table(struct net_device *dev);
-
-#endif /* MAC802154_H */
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
index 08a6161..9dfa8ff 100644
--- a/net/mac802154/mac_cmd.c
+++ b/net/mac802154/mac_cmd.c
@@ -31,7 +31,7 @@
 #include <net/mac802154.h>
 #include <net/nl802154.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 static int mac802154_mlme_start_req(struct net_device *dev,
 				    struct ieee802154_addr *addr,
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index eb17dbc..9d90892 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -27,7 +27,7 @@
 #include <net/route.h>
 #include <net/wpan-phy.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 int mac802154_slave_open(struct net_device *dev)
 {
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index 40c9952..c8fee8d 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -27,7 +27,7 @@
 #include <net/ieee802154_netdev.h>
 #include <net/wpan-phy.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 struct phy_chan_notify_work {
 	struct work_struct work;
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 5389fb7..730e56d 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -30,7 +30,7 @@
 #include <net/mac802154.h>
 #include <net/ieee802154_netdev.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 /* The IEEE 802.15.4 standard defines 4 MAC packet types:
  * - beacon frame
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 192b0dd..23735dd 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -29,7 +29,7 @@
 #include <net/mac802154.h>
 #include <net/wpan-phy.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 /* IEEE 802.15.4 transceivers can sleep during the xmit session, so process
  * packets through the workqueue.
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index 663f89d..d2fc40b 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -33,7 +33,7 @@
 #include <net/ieee802154.h>
 #include <net/wpan-phy.h>
 
-#include "mac802154.h"
+#include "ieee802154_i.h"
 
 static int mac802154_wpan_update_llsec(struct net_device *dev)
 {
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 09/11] mac802154: rename hw subif_data variable to local
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (7 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 08/11] mac802154: rename mac802154.h to ieee802154_i.h Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 10/11] mac802154: use hw_to_local Alexander Aring
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch renames the hw attribute in struct ieee802154_sub_if_data to
local. This avoid confusing with the struct ieee802154_hw hw; inside of
local struct.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/ieee802154_i.h |  2 +-
 net/mac802154/mac_cmd.c      |  2 +-
 net/mac802154/main.c         | 34 +++++++++++++++++-----------------
 net/mac802154/mib.c          | 38 +++++++++++++++++++-------------------
 net/mac802154/wpan.c         | 12 ++++++------
 5 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index e7a1b11..2f0d995 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -36,7 +36,7 @@ struct ieee802154_local;
 struct ieee802154_sub_if_data {
 	struct list_head list; /* the ieee802154_priv->slaves list */
 
-	struct ieee802154_local *hw;
+	struct ieee802154_local *local;
 	struct net_device *dev;
 
 	int type;
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
index 9dfa8ff..2abbc39 100644
--- a/net/mac802154/mac_cmd.c
+++ b/net/mac802154/mac_cmd.c
@@ -83,7 +83,7 @@ static struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	return to_phy(get_device(&sdata->hw->phy->dev));
+	return to_phy(get_device(&sdata->local->phy->dev));
 }
 
 static struct ieee802154_llsec_ops mac802154_llsec_ops = {
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 9d90892..6641707 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -33,26 +33,26 @@ int mac802154_slave_open(struct net_device *dev)
 {
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 	struct ieee802154_sub_if_data *subif;
-	struct ieee802154_local *local = sdata->hw;
+	struct ieee802154_local *local = sdata->local;
 	int res = 0;
 
 	ASSERT_RTNL();
 
 	if (sdata->type == NL802154_IFTYPE_NODE) {
-		mutex_lock(&sdata->hw->slaves_mtx);
-		list_for_each_entry(subif, &sdata->hw->slaves, list) {
+		mutex_lock(&sdata->local->slaves_mtx);
+		list_for_each_entry(subif, &sdata->local->slaves, list) {
 			if (subif != sdata && subif->type == sdata->type &&
 			    subif->running) {
-				mutex_unlock(&sdata->hw->slaves_mtx);
+				mutex_unlock(&sdata->local->slaves_mtx);
 				return -EBUSY;
 			}
 		}
-		mutex_unlock(&sdata->hw->slaves_mtx);
+		mutex_unlock(&sdata->local->slaves_mtx);
 	}
 
-	mutex_lock(&sdata->hw->slaves_mtx);
+	mutex_lock(&sdata->local->slaves_mtx);
 	sdata->running = true;
-	mutex_unlock(&sdata->hw->slaves_mtx);
+	mutex_unlock(&sdata->local->slaves_mtx);
 
 	if (local->open_count++ == 0) {
 		res = local->ops->start(&local->hw);
@@ -74,7 +74,7 @@ int mac802154_slave_open(struct net_device *dev)
 	netif_start_queue(dev);
 	return 0;
 err:
-	sdata->hw->open_count--;
+	sdata->local->open_count--;
 
 	return res;
 }
@@ -82,15 +82,15 @@ err:
 int mac802154_slave_close(struct net_device *dev)
 {
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
-	struct ieee802154_local *local = sdata->hw;
+	struct ieee802154_local *local = sdata->local;
 
 	ASSERT_RTNL();
 
 	netif_stop_queue(dev);
 
-	mutex_lock(&sdata->hw->slaves_mtx);
+	mutex_lock(&sdata->local->slaves_mtx);
 	sdata->running = false;
-	mutex_unlock(&sdata->hw->slaves_mtx);
+	mutex_unlock(&sdata->local->slaves_mtx);
 
 	if (!--local->open_count)
 		local->ops->stop(&local->hw);
@@ -109,7 +109,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
 
 	sdata = netdev_priv(dev);
 	sdata->dev = dev;
-	sdata->hw = local;
+	sdata->local = local;
 
 	dev->needed_headroom = local->hw.extra_tx_headroom;
 
@@ -144,11 +144,11 @@ mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
 
 	sdata = netdev_priv(dev);
 
-	BUG_ON(sdata->hw->phy != phy);
+	BUG_ON(sdata->local->phy != phy);
 
-	mutex_lock(&sdata->hw->slaves_mtx);
+	mutex_lock(&sdata->local->slaves_mtx);
 	list_del_rcu(&sdata->list);
-	mutex_unlock(&sdata->hw->slaves_mtx);
+	mutex_unlock(&sdata->local->slaves_mtx);
 
 	synchronize_rcu();
 	unregister_netdevice(sdata->dev);
@@ -389,9 +389,9 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 	mutex_unlock(&local->slaves_mtx);
 
 	list_for_each_entry_safe(sdata, next, &local->slaves, list) {
-		mutex_lock(&sdata->hw->slaves_mtx);
+		mutex_lock(&sdata->local->slaves_mtx);
 		list_del(&sdata->list);
-		mutex_unlock(&sdata->hw->slaves_mtx);
+		mutex_unlock(&sdata->local->slaves_mtx);
 
 		unregister_netdevice(sdata->dev);
 	}
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index c8fee8d..62dc94c 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -46,7 +46,7 @@ static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev)
 
 	BUG_ON(dev->type != ARPHRD_IEEE802154);
 
-	return sdata->hw;
+	return sdata->local;
 }
 
 static void hw_addr_notify(struct work_struct *work)
@@ -76,7 +76,7 @@ static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
 	INIT_WORK(&work->work, hw_addr_notify);
 	work->dev = dev;
 	work->changed = changed;
-	queue_work(sdata->hw->dev_workqueue, &work->work);
+	queue_work(sdata->local->dev_workqueue, &work->work);
 }
 
 void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val)
@@ -89,9 +89,9 @@ void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val)
 	sdata->short_addr = val;
 	spin_unlock_bh(&sdata->mib_lock);
 
-	if ((sdata->hw->ops->set_hw_addr_filt) &&
-	    (sdata->hw->hw.hw_filt.short_addr != sdata->short_addr)) {
-		sdata->hw->hw.hw_filt.short_addr = sdata->short_addr;
+	if ((sdata->local->ops->set_hw_addr_filt) &&
+	    (sdata->local->hw.hw_filt.short_addr != sdata->short_addr)) {
+		sdata->local->hw.hw_filt.short_addr = sdata->short_addr;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_SADDR_CHANGED);
 	}
 }
@@ -113,7 +113,7 @@ __le16 mac802154_dev_get_short_addr(const struct net_device *dev)
 void mac802154_dev_set_ieee_addr(struct net_device *dev)
 {
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
-	struct ieee802154_local *local = sdata->hw;
+	struct ieee802154_local *local = sdata->local;
 
 	sdata->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
 
@@ -148,9 +148,9 @@ void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val)
 	sdata->pan_id = val;
 	spin_unlock_bh(&sdata->mib_lock);
 
-	if ((sdata->hw->ops->set_hw_addr_filt) &&
-	    (sdata->hw->hw.hw_filt.pan_id != sdata->pan_id)) {
-		sdata->hw->hw.hw_filt.pan_id = sdata->pan_id;
+	if ((sdata->local->ops->set_hw_addr_filt) &&
+	    (sdata->local->hw.hw_filt.pan_id != sdata->pan_id)) {
+		sdata->local->hw.hw_filt.pan_id = sdata->pan_id;
 		set_hw_addr_filt(dev, IEEE802515_AFILT_PANID_CHANGED);
 	}
 }
@@ -172,15 +172,15 @@ static void phy_chan_notify(struct work_struct *work)
 	struct ieee802154_sub_if_data *sdata = netdev_priv(nw->dev);
 	int res;
 
-	mutex_lock(&sdata->hw->phy->pib_lock);
+	mutex_lock(&sdata->local->phy->pib_lock);
 	res = local->ops->set_channel(&local->hw, sdata->page, sdata->chan);
 	if (res) {
 		pr_debug("set_channel failed\n");
 	} else {
-		sdata->hw->phy->current_channel = sdata->chan;
-		sdata->hw->phy->current_page = sdata->page;
+		sdata->local->phy->current_channel = sdata->chan;
+		sdata->local->phy->current_page = sdata->page;
 	}
-	mutex_unlock(&sdata->hw->phy->pib_lock);
+	mutex_unlock(&sdata->local->phy->pib_lock);
 
 	kfree(nw);
 }
@@ -197,10 +197,10 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
 	sdata->chan = chan;
 	spin_unlock_bh(&sdata->mib_lock);
 
-	mutex_lock(&sdata->hw->phy->pib_lock);
-	if (sdata->hw->phy->current_channel != sdata->chan ||
-	    sdata->hw->phy->current_page != sdata->page) {
-		mutex_unlock(&sdata->hw->phy->pib_lock);
+	mutex_lock(&sdata->local->phy->pib_lock);
+	if (sdata->local->phy->current_channel != sdata->chan ||
+	    sdata->local->phy->current_page != sdata->page) {
+		mutex_unlock(&sdata->local->phy->pib_lock);
 
 		work = kzalloc(sizeof(*work), GFP_ATOMIC);
 		if (!work)
@@ -208,9 +208,9 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
 
 		INIT_WORK(&work->work, phy_chan_notify);
 		work->dev = dev;
-		queue_work(sdata->hw->dev_workqueue, &work->work);
+		queue_work(sdata->local->dev_workqueue, &work->work);
 	} else {
-		mutex_unlock(&sdata->hw->phy->pib_lock);
+		mutex_unlock(&sdata->local->phy->pib_lock);
 	}
 }
 
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index d2fc40b..f350218 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -129,9 +129,9 @@ int mac802154_set_mac_params(struct net_device *dev,
 {
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
-	mutex_lock(&sdata->hw->slaves_mtx);
+	mutex_lock(&sdata->local->slaves_mtx);
 	sdata->mac_params = *params;
-	mutex_unlock(&sdata->hw->slaves_mtx);
+	mutex_unlock(&sdata->local->slaves_mtx);
 
 	return 0;
 }
@@ -141,16 +141,16 @@ void mac802154_get_mac_params(struct net_device *dev,
 {
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
 
-	mutex_lock(&sdata->hw->slaves_mtx);
+	mutex_lock(&sdata->local->slaves_mtx);
 	*params = sdata->mac_params;
-	mutex_unlock(&sdata->hw->slaves_mtx);
+	mutex_unlock(&sdata->local->slaves_mtx);
 }
 
 static int mac802154_wpan_open(struct net_device *dev)
 {
 	int rc;
 	struct ieee802154_sub_if_data *sdata = netdev_priv(dev);
-	struct wpan_phy *phy = sdata->hw->phy;
+	struct wpan_phy *phy = sdata->local->phy;
 
 	rc = mac802154_slave_open(dev);
 	if (rc < 0)
@@ -343,7 +343,7 @@ mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
 	dev->stats.tx_packets++;
 	dev->stats.tx_bytes += skb->len;
 
-	return mac802154_tx(sdata->hw, skb, page, chan);
+	return mac802154_tx(sdata->local, skb, page, chan);
 }
 
 static struct header_ops mac802154_header_ops = {
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 10/11] mac802154: use hw_to_local
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (8 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 09/11] mac802154: rename hw subif_data variable to local Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-12 13:14 ` [PATCH wpan-next 11/11] mac802154: rx: use tasklet instead workqueue Alexander Aring
  2014-08-14  7:37 ` [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Martin Townsend
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch replace the mac802154_to_priv macro with a static inline
function named hw_to_local.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/ieee802154_i.h | 8 ++++++--
 net/mac802154/main.c         | 6 +++---
 net/mac802154/rx.c           | 4 ++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 2f0d995..1a344ab 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -101,10 +101,14 @@ struct ieee802154_local {
 #define	MAC802154_DEVICE_STOPPED	0x00
 #define MAC802154_DEVICE_RUN		0x01
 
-#define mac802154_to_priv(_hw)	container_of(_hw, struct ieee802154_local, hw)
-
 #define MAC802154_CHAN_NONE		0xff /* No channel is assigned */
 
+static inline struct ieee802154_local *
+hw_to_local(struct ieee802154_hw *hw)
+{
+	return container_of(hw, struct ieee802154_local, hw);
+}
+
 extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
 extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
 
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 6641707..685d5bd 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -284,7 +284,7 @@ EXPORT_SYMBOL(ieee802154_alloc_hw);
 
 void ieee802154_free_hw(struct ieee802154_hw *hw)
 {
-	struct ieee802154_local *local = mac802154_to_priv(hw);
+	struct ieee802154_local *local = hw_to_local(hw);
 
 	BUG_ON(!list_empty(&local->slaves));
 
@@ -296,7 +296,7 @@ EXPORT_SYMBOL(ieee802154_free_hw);
 
 int ieee802154_register_hw(struct ieee802154_hw *hw)
 {
-	struct ieee802154_local *local = mac802154_to_priv(hw);
+	struct ieee802154_local *local = hw_to_local(hw);
 	int rc = -ENOSYS;
 
 	if (hw->flags & IEEE802154_HW_TXPOWER) {
@@ -376,7 +376,7 @@ EXPORT_SYMBOL(ieee802154_register_hw);
 
 void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 {
-	struct ieee802154_local *local = mac802154_to_priv(hw);
+	struct ieee802154_local *local = hw_to_local(hw);
 	struct ieee802154_sub_if_data *sdata, *next;
 
 	flush_workqueue(local->dev_workqueue);
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 730e56d..7bd3c85 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -53,7 +53,7 @@ struct rx_work {
 static void
 mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
-	struct ieee802154_local *local = mac802154_to_priv(hw);
+	struct ieee802154_local *local = hw_to_local(hw);
 
 	mac_cb(skb)->lqi = lqi;
 	skb->protocol = htons(ETH_P_IEEE802154);
@@ -93,7 +93,7 @@ static void mac802154_rx_worker(struct work_struct *work)
 void
 ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
-	struct ieee802154_local *local = mac802154_to_priv(hw);
+	struct ieee802154_local *local = hw_to_local(hw);
 	struct rx_work *work;
 
 	if (!skb)
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wpan-next 11/11] mac802154: rx: use tasklet instead workqueue
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (9 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 10/11] mac802154: use hw_to_local Alexander Aring
@ 2014-08-12 13:14 ` Alexander Aring
  2014-08-14  7:37 ` [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Martin Townsend
  11 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-12 13:14 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

Tasklets have much less overhead than workqueues and we save the heap
allocation on this hot path.

This patch is part of getting wireless feeling into the ieee802154
implementation.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/mac802154.h      |  2 ++
 net/mac802154/ieee802154_i.h |  7 +++++++
 net/mac802154/main.c         | 29 +++++++++++++++++++++++++++
 net/mac802154/rx.c           | 47 ++++++++------------------------------------
 4 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index ffc8cee..9e9d8fa 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -195,4 +195,6 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw);
 void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
 			   u8 lqi);
 
+void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb);
+
 #endif /* NET_MAC802154_H */
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 1a344ab..6bad21f 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -27,6 +27,10 @@
 
 struct ieee802154_local;
 
+enum {
+	IEEE802154_RX_MSG        = 1,
+};
+
 /* Slave interface definition.
  *
  * Slaves represent typical network interfaces available from userspace.
@@ -96,6 +100,9 @@ struct ieee802154_local {
 	 * read them using any of protection methods.
 	 */
 	bool running;
+
+	struct tasklet_struct tasklet;
+	struct sk_buff_head skb_queue;
 };
 
 #define	MAC802154_DEVICE_STOPPED	0x00
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 685d5bd..1f8c968 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -230,6 +230,29 @@ static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
 	return local->ops->set_frame_retries(&local->hw, retries);
 }
 
+static void ieee802154_tasklet_handler(unsigned long data)
+{
+	struct ieee802154_local *local = (struct ieee802154_local *)data;
+	struct sk_buff *skb;
+
+	while ((skb = skb_dequeue(&local->skb_queue))) {
+		switch (skb->pkt_type) {
+		case IEEE802154_RX_MSG:
+			/* Clear skb->pkt_type in order to not confuse kernel
+			 * netstack.
+			 */
+			skb->pkt_type = 0;
+			ieee802154_rx(&local->hw, skb);
+			break;
+		default:
+			WARN(1, "mac80211: Packet is of unknown type %d\n",
+			     skb->pkt_type);
+			kfree_skb(skb);
+			break;
+		}
+	}
+}
+
 struct ieee802154_hw *
 ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 {
@@ -278,6 +301,12 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
 	INIT_LIST_HEAD(&local->slaves);
 	mutex_init(&local->slaves_mtx);
 
+	tasklet_init(&local->tasklet,
+		     ieee802154_tasklet_handler,
+		     (unsigned long)local);
+
+	skb_queue_head_init(&local->skb_queue);
+
 	return &local->hw;
 }
 EXPORT_SYMBOL(ieee802154_alloc_hw);
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 7bd3c85..fe16754 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -32,30 +32,11 @@
 
 #include "ieee802154_i.h"
 
-/* The IEEE 802.15.4 standard defines 4 MAC packet types:
- * - beacon frame
- * - MAC command frame
- * - acknowledgement frame
- * - data frame
- *
- * and only the data frame should be pushed to the upper layers, other types
- * are just internal MAC layer management information. So only data packets
- * are going to be sent to the networking queue, all other will be processed
- * right here by using the device workqueue.
- */
-struct rx_work {
-	struct sk_buff *skb;
-	struct work_struct work;
-	struct ieee802154_hw *hw;
-	u8 lqi;
-};
-
 static void
-mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
+mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
 	struct ieee802154_local *local = hw_to_local(hw);
 
-	mac_cb(skb)->lqi = lqi;
 	skb->protocol = htons(ETH_P_IEEE802154);
 	skb_reset_mac_header(skb);
 
@@ -82,32 +63,20 @@ fail:
 	kfree_skb(skb);
 }
 
-static void mac802154_rx_worker(struct work_struct *work)
+void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
-	struct rx_work *rw = container_of(work, struct rx_work, work);
-
-	mac802154_subif_rx(rw->hw, rw->skb, rw->lqi);
-	kfree(rw);
+	mac802154_subif_rx(hw, skb);
 }
+EXPORT_SYMBOL(ieee802154_rx);
 
 void
 ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
 {
 	struct ieee802154_local *local = hw_to_local(hw);
-	struct rx_work *work;
 
-	if (!skb)
-		return;
-
-	work = kzalloc(sizeof(*work), GFP_ATOMIC);
-	if (!work)
-		return;
-
-	INIT_WORK(&work->work, mac802154_rx_worker);
-	work->skb = skb;
-	work->hw = hw;
-	work->lqi = lqi;
-
-	queue_work(local->dev_workqueue, &work->work);
+	mac_cb(skb)->lqi = lqi;
+	skb->pkt_type = IEEE802154_RX_MSG;
+	skb_queue_tail(&local->skb_queue, skb);
+	tasklet_schedule(&local->tasklet);
 }
 EXPORT_SYMBOL(ieee802154_rx_irqsafe);
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
  2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
                   ` (10 preceding siblings ...)
  2014-08-12 13:14 ` [PATCH wpan-next 11/11] mac802154: rx: use tasklet instead workqueue Alexander Aring
@ 2014-08-14  7:37 ` Martin Townsend
  2014-08-14  7:59   ` Alexander Aring
  11 siblings, 1 reply; 17+ messages in thread
From: Martin Townsend @ 2014-08-14  7:37 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan

Hi Alex,

Looks good to me.  The monitor devices work fine for us on both our wireless and plc interfaces using tcpdump.  Out of interest, in  what way are they broken?

- Martin.

On 12/08/14 14:14, Alexander Aring wrote:
> Hi,
>
> this is the first part to make the mac802154/ieee802154 implementation like
> wireless. There is much things do to but at around 10 patches I will send
> a complete patch series of my work to make the review easier.
>
> This patch renames more variables/structs like it's also available in wireless.
> I think this was done also in the current implementation but all variables
> was renamed and now I get confuse about priv/ipriv (I call it priv variable hell)
> and netdev/ieee802154_dev.
>
> We rename the ieee802154_dev to ieee802154_hw, like a ieee80211_hw.
>
> The mac802154_priv is now ieee802154_local, like a ieee80211_local.
> The mac802154_sub_if_data is now ieee802154_sub_if_data.
>
> Also change the variables name to this so there should never be a variable priv
> and you don't know if it's a mac802154_sub_if_data or mac802154_priv. That's
> confusing me so much sometimes. Now it's also clear to see mutliple dereferencing.
> Please send patches for this, if you like.
>
> The next step is the frame parsing like wireless and interface registration like
> wireless.
>
>
> The last one replace the receiving workqueue with a tasklet, which is also used
> in wireless. This have a less overhead and I removed a kmalloc call in this hot
> path.
>
> - Alex
>
> Alexander Aring (11):
>   ieee802154: rename ieee802154_dev to ieee802154_hw
>   mac802154: rename ieee802154_dev.c to main.c
>   mac802154: remove not functional monitor device
>   ieee802154: add new interface types
>   nl802154: add missing endif comment
>   mac802154: rename mac802154_priv to ieee802154_local
>   mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data
>   mac802154: rename mac802154.h to ieee802154_i.h
>   mac802154: rename hw subif_data variable to local
>   mac802154: use hw_to_local
>   mac802154: rx: use tasklet instead workqueue
>
>  drivers/net/ieee802154/at86rf230.c |  90 ++++----
>  drivers/net/ieee802154/cc2520.c    |  50 ++---
>  drivers/net/ieee802154/mrf24j40.c  |  48 ++--
>  include/linux/nl802154.h           |  15 +-
>  include/net/mac802154.h            |  46 ++--
>  net/ieee802154/nl-phy.c            |   4 +-
>  net/mac802154/Makefile             |   4 +-
>  net/mac802154/ieee802154_dev.c     | 415 -----------------------------------
>  net/mac802154/ieee802154_i.h       | 178 +++++++++++++++
>  net/mac802154/llsec.c              |   2 +-
>  net/mac802154/mac802154.h          | 172 ---------------
>  net/mac802154/mac_cmd.c            |   6 +-
>  net/mac802154/main.c               | 435 +++++++++++++++++++++++++++++++++++++
>  net/mac802154/mib.c                | 207 +++++++++---------
>  net/mac802154/monitor.c            | 117 ----------
>  net/mac802154/rx.c                 |  60 ++---
>  net/mac802154/tx.c                 |  42 ++--
>  net/mac802154/wpan.c               | 145 +++++++------
>  18 files changed, 958 insertions(+), 1078 deletions(-)
>  delete mode 100644 net/mac802154/ieee802154_dev.c
>  create mode 100644 net/mac802154/ieee802154_i.h
>  delete mode 100644 net/mac802154/mac802154.h
>  create mode 100644 net/mac802154/main.c
>  delete mode 100644 net/mac802154/monitor.c
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
  2014-08-14  7:37 ` [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Martin Townsend
@ 2014-08-14  7:59   ` Alexander Aring
  2014-08-14  8:09     ` Martin Townsend
  2014-08-14  8:13     ` Alexander Aring
  0 siblings, 2 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-14  7:59 UTC (permalink / raw)
  To: Martin Townsend; +Cc: linux-wpan

Hi,

On Thu, Aug 14, 2014 at 08:37:24AM +0100, Martin Townsend wrote:
> Hi Alex,
> 
> Looks good to me.  The monitor devices work fine for us on both our wireless and plc interfaces using tcpdump.  Out of interest, in  what way are they broken?
> 

Okay, in my setup I can't set any channels to the monitor interface. It's
only working if I set some channel hardcoded and the remove of the
monitor interface is also broken.


I gave up to understand how it works. If you see [0] you will see:

dev->ml_priv            = &mac802154_mlme_reduced;

The mac802154_mlme_reduced struct is defined at [1]. It has only the 

.get_phy = mac802154_get_phy,

assign.

But mac802154_get_phy has a assertion on:

BUG_ON(dev->type != ARPHRD_IEEE802154);

Back to [0] you will see:

dev->type               = ARPHRD_IEEE802154_MONITOR;

which doesn't fit together with a

BUG_ON(dev->type != ARPHRD_IEEE802154);

I never hit this BUG_ON and really doesn't know what's going on there,
I want to implement a MONITOR interface like 80211. :-)



Nevertheless I gave up to understand what going on there and I can't
also set channels. Also removing the monitor interface with iz doesn't
work (I think there was some deadlock).

A monitor device should be going into the promiscous mode of a device.
But we also don't support this. Okay if you device doesn't has a
hardware filter, it's like to have a promiscous mode. But sometimes
promiscous mode also doesn't care about CRC or something else. A monitor
device should also be able to show broken packets.

I drop this interface type because it really bypass only the mac802154
stack and nothing else. I don't want to say "we don't need a MONITOR
interface type", but this is for my opinion in an not useful state.



And really I don't want to insert something mainline which breaks any
existing support (monitor, fakelb, crypto, ...). I can't do a deletion of
net/mac802154 (ieee802154) and simple add a new one, but deleting of
subsubsystems like montior, fakelb and add a rework of this should not
make any problems.

- Alex

[0] http://lxr.free-electrons.com/source/net/mac802154/monitor.c
[1] http://lxr.free-electrons.com/source/net/mac802154/mac_cmd.c#L105
[2] http://lxr.free-electrons.com/source/net/mac802154/mac_cmd.c#L80

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
  2014-08-14  7:59   ` Alexander Aring
@ 2014-08-14  8:09     ` Martin Townsend
  2014-08-14  8:24       ` Alexander Aring
  2014-08-14  8:13     ` Alexander Aring
  1 sibling, 1 reply; 17+ messages in thread
From: Martin Townsend @ 2014-08-14  8:09 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan

It would be good to have a way of cleanly putting devices into promiscuous mode, currently we have to patch the mrf driver to do this.

I look forward to trying out the new monitor interface. :)

- Martin.

On 14/08/14 08:59, Alexander Aring wrote:
> Hi,
>
> On Thu, Aug 14, 2014 at 08:37:24AM +0100, Martin Townsend wrote:
>> Hi Alex,
>>
>> Looks good to me.  The monitor devices work fine for us on both our wireless and plc interfaces using tcpdump.  Out of interest, in  what way are they broken?
>>
> Okay, in my setup I can't set any channels to the monitor interface. It's
> only working if I set some channel hardcoded and the remove of the
> monitor interface is also broken.
>
>
> I gave up to understand how it works. If you see [0] you will see:
>
> dev->ml_priv            = &mac802154_mlme_reduced;
>
> The mac802154_mlme_reduced struct is defined at [1]. It has only the 
>
> .get_phy = mac802154_get_phy,
>
> assign.
>
> But mac802154_get_phy has a assertion on:
>
> BUG_ON(dev->type != ARPHRD_IEEE802154);
>
> Back to [0] you will see:
>
> dev->type               = ARPHRD_IEEE802154_MONITOR;
>
> which doesn't fit together with a
>
> BUG_ON(dev->type != ARPHRD_IEEE802154);
>
> I never hit this BUG_ON and really doesn't know what's going on there,
> I want to implement a MONITOR interface like 80211. :-)
>
>
>
> Nevertheless I gave up to understand what going on there and I can't
> also set channels. Also removing the monitor interface with iz doesn't
> work (I think there was some deadlock).
>
> A monitor device should be going into the promiscous mode of a device.
> But we also don't support this. Okay if you device doesn't has a
> hardware filter, it's like to have a promiscous mode. But sometimes
> promiscous mode also doesn't care about CRC or something else. A monitor
> device should also be able to show broken packets.
>
> I drop this interface type because it really bypass only the mac802154
> stack and nothing else. I don't want to say "we don't need a MONITOR
> interface type", but this is for my opinion in an not useful state.
>
>
>
> And really I don't want to insert something mainline which breaks any
> existing support (monitor, fakelb, crypto, ...). I can't do a deletion of
> net/mac802154 (ieee802154) and simple add a new one, but deleting of
> subsubsystems like montior, fakelb and add a rework of this should not
> make any problems.
>
> - Alex
>
> [0] http://lxr.free-electrons.com/source/net/mac802154/monitor.c
> [1] http://lxr.free-electrons.com/source/net/mac802154/mac_cmd.c#L105
> [2] http://lxr.free-electrons.com/source/net/mac802154/mac_cmd.c#L80
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
  2014-08-14  7:59   ` Alexander Aring
  2014-08-14  8:09     ` Martin Townsend
@ 2014-08-14  8:13     ` Alexander Aring
  1 sibling, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-14  8:13 UTC (permalink / raw)
  To: Martin Townsend; +Cc: linux-wpan

On Thu, Aug 14, 2014 at 09:59:00AM +0200, Alexander Aring wrote:
> And really I don't want to insert something mainline which breaks any
> existing support (monitor, fakelb, crypto, ...). I can't do a deletion of
> net/mac802154 (ieee802154) and simple add a new one, but deleting of
> subsubsystems like montior, fakelb and add a rework of this should not
> make any problems.
> 

okay, that's maybe not correct I want to drop the channel setting
feature while xmit which "could" be use for channel hoping On
multiple interfaces.

The reason are more... this is a sync callback and I can't deal with a
async xmit with that. Okay I can solve this to make the channel setting
async but... if somebody want channel hoping then the logic for that
should be in userspace. We don't have any kernelspace implementation of
any protocol which use the channel hoping feature.

btw. the wireless implementation forbids multiple interface with
different channels. [0]

[0] is a neat introduction how wireless userspace access works. Page
21/35 "only matching PHY parameters possible e.g. all virtual interfaces
are on one channel".

[0] http://wireless.kernel.org/en/developers/Documentation/cfg80211?action=AttachFile&do=view&target=control.pdf

- Alex

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation
  2014-08-14  8:09     ` Martin Townsend
@ 2014-08-14  8:24       ` Alexander Aring
  0 siblings, 0 replies; 17+ messages in thread
From: Alexander Aring @ 2014-08-14  8:24 UTC (permalink / raw)
  To: Martin Townsend; +Cc: linux-wpan

On Thu, Aug 14, 2014 at 09:09:59AM +0100, Martin Townsend wrote:
> It would be good to have a way of cleanly putting devices into promiscuous mode, currently we have to patch the mrf driver to do this.
> 
hacked solution which came not mainline because it had some issues which
I don't know yet anymore.

https://github.com/linux-wpan/linux-wpan-next/commit/55d497e2d8dc08d0673bb9be24d649a79afc5e9e

- Alex

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-08-14  8:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-12 13:14 [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 01/11] ieee802154: rename ieee802154_dev to ieee802154_hw Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 02/11] mac802154: rename ieee802154_dev.c to main.c Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 03/11] mac802154: remove not functional monitor device Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 04/11] ieee802154: add new interface types Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 05/11] nl802154: add missing endif comment Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 06/11] mac802154: rename mac802154_priv to ieee802154_local Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 07/11] mac802154: rename mac802154_sub_if_data to ieee802154_sub_if_data Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 08/11] mac802154: rename mac802154.h to ieee802154_i.h Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 09/11] mac802154: rename hw subif_data variable to local Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 10/11] mac802154: use hw_to_local Alexander Aring
2014-08-12 13:14 ` [PATCH wpan-next 11/11] mac802154: rx: use tasklet instead workqueue Alexander Aring
2014-08-14  7:37 ` [PATCH wpan-next 00/11] ieee802154: mac802154: wireless transformation Martin Townsend
2014-08-14  7:59   ` Alexander Aring
2014-08-14  8:09     ` Martin Townsend
2014-08-14  8:24       ` Alexander Aring
2014-08-14  8:13     ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).