Commit a5e1ec53 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

mac802154: rename mac802154_priv to ieee802154_local

This patch rename the mac802154_priv to ieee802154_local. The
mac802154_priv structure is like ieee80211_local and so we name it
ieee802154_local.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 5a504397
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "llsec.h" #include "llsec.h"
/* mac802154 device private data */ /* mac802154 device private data */
struct mac802154_priv { struct ieee802154_local {
struct ieee802154_hw hw; struct ieee802154_hw hw;
struct ieee802154_ops *ops; struct ieee802154_ops *ops;
...@@ -69,7 +69,7 @@ struct mac802154_priv { ...@@ -69,7 +69,7 @@ struct mac802154_priv {
struct mac802154_sub_if_data { struct mac802154_sub_if_data {
struct list_head list; /* the ieee802154_priv->slaves list */ struct list_head list; /* the ieee802154_priv->slaves list */
struct mac802154_priv *hw; struct ieee802154_local *hw;
struct net_device *dev; struct net_device *dev;
int type; int type;
...@@ -99,7 +99,7 @@ struct mac802154_sub_if_data { ...@@ -99,7 +99,7 @@ struct mac802154_sub_if_data {
struct mac802154_llsec sec; 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 */ #define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
...@@ -109,13 +109,13 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan; ...@@ -109,13 +109,13 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
int mac802154_slave_open(struct net_device *dev); int mac802154_slave_open(struct net_device *dev);
int mac802154_slave_close(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_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb);
void mac802154_monitor_setup(struct net_device *dev); void mac802154_monitor_setup(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); 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); u8 page, u8 chan);
/* MIB callbacks */ /* MIB callbacks */
......
...@@ -565,7 +565,7 @@ static int mac802154_parse_frame_start(struct sk_buff *skb, ...@@ -565,7 +565,7 @@ static int mac802154_parse_frame_start(struct sk_buff *skb,
return 0; 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; int ret;
struct mac802154_sub_if_data *sdata; struct mac802154_sub_if_data *sdata;
...@@ -579,7 +579,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb) ...@@ -579,7 +579,7 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
} }
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(sdata, &priv->slaves, list) { list_for_each_entry_rcu(sdata, &local->slaves, list) {
if (sdata->type != IEEE802154_DEV_WPAN || if (sdata->type != IEEE802154_DEV_WPAN ||
!netif_running(sdata->dev)) !netif_running(sdata->dev))
continue; continue;
......
...@@ -33,7 +33,7 @@ int mac802154_slave_open(struct net_device *dev) ...@@ -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 *priv = netdev_priv(dev);
struct mac802154_sub_if_data *subif; struct mac802154_sub_if_data *subif;
struct mac802154_priv *ipriv = priv->hw; struct ieee802154_local *local = priv->hw;
int res = 0; int res = 0;
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -54,17 +54,17 @@ int mac802154_slave_open(struct net_device *dev) ...@@ -54,17 +54,17 @@ int mac802154_slave_open(struct net_device *dev)
priv->running = true; priv->running = true;
mutex_unlock(&priv->hw->slaves_mtx); mutex_unlock(&priv->hw->slaves_mtx);
if (ipriv->open_count++ == 0) { if (local->open_count++ == 0) {
res = ipriv->ops->start(&ipriv->hw); res = local->ops->start(&local->hw);
WARN_ON(res); WARN_ON(res);
if (res) if (res)
goto err; goto err;
} }
if (ipriv->ops->ieee_addr) { if (local->ops->ieee_addr) {
__le64 addr = ieee802154_devaddr_from_raw(dev->dev_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); WARN_ON(res);
if (res) if (res)
goto err; goto err;
...@@ -82,7 +82,7 @@ int mac802154_slave_open(struct net_device *dev) ...@@ -82,7 +82,7 @@ int mac802154_slave_open(struct net_device *dev)
int mac802154_slave_close(struct net_device *dev) int mac802154_slave_close(struct net_device *dev)
{ {
struct mac802154_sub_if_data *priv = netdev_priv(dev); struct mac802154_sub_if_data *priv = netdev_priv(dev);
struct mac802154_priv *ipriv = priv->hw; struct ieee802154_local *local = priv->hw;
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -92,8 +92,8 @@ int mac802154_slave_close(struct net_device *dev) ...@@ -92,8 +92,8 @@ int mac802154_slave_close(struct net_device *dev)
priv->running = false; priv->running = false;
mutex_unlock(&priv->hw->slaves_mtx); mutex_unlock(&priv->hw->slaves_mtx);
if (!--ipriv->open_count) if (!--local->open_count)
ipriv->ops->stop(&ipriv->hw); local->ops->stop(&local->hw);
return 0; return 0;
} }
...@@ -102,34 +102,34 @@ static int ...@@ -102,34 +102,34 @@ static int
mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev) mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
{ {
struct mac802154_sub_if_data *priv; struct mac802154_sub_if_data *priv;
struct mac802154_priv *ipriv; struct ieee802154_local *local;
int err; int err;
ipriv = wpan_phy_priv(phy); local = wpan_phy_priv(phy);
priv = netdev_priv(dev); priv = netdev_priv(dev);
priv->dev = 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); mutex_lock(&local->slaves_mtx);
if (!ipriv->running) { if (!local->running) {
mutex_unlock(&ipriv->slaves_mtx); mutex_unlock(&local->slaves_mtx);
return -ENODEV; return -ENODEV;
} }
mutex_unlock(&ipriv->slaves_mtx); mutex_unlock(&local->slaves_mtx);
err = register_netdev(dev); err = register_netdev(dev);
if (err < 0) if (err < 0)
return err; return err;
rtnl_lock(); rtnl_lock();
mutex_lock(&ipriv->slaves_mtx); mutex_lock(&local->slaves_mtx);
list_add_tail_rcu(&priv->list, &ipriv->slaves); list_add_tail_rcu(&priv->list, &local->slaves);
mutex_unlock(&ipriv->slaves_mtx); mutex_unlock(&local->slaves_mtx);
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
...@@ -194,52 +194,52 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type) ...@@ -194,52 +194,52 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
static int mac802154_set_txpower(struct wpan_phy *phy, int db) 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) 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) 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) 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, static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be,
u8 max_be, u8 retries) 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) 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 * struct ieee802154_hw *
ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
{ {
struct wpan_phy *phy; struct wpan_phy *phy;
struct mac802154_priv *priv; struct ieee802154_local *local;
size_t priv_size; size_t priv_size;
if (!ops || !ops->xmit || !ops->ed || !ops->start || if (!ops || !ops->xmit || !ops->ed || !ops->start ||
...@@ -249,24 +249,24 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) ...@@ -249,24 +249,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. /* 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 * the driver's private data
* *
* in memory it'll be like this: * in memory it'll be like this:
* *
* +-----------------------+ * +-------------------------+
* | struct wpan_phy | * | struct wpan_phy |
* +-----------------------+ * +-------------------------+
* | struct mac802154_priv | * | struct ieee802154_local |
* +-----------------------+ * +-------------------------+
* | driver's private data | * | driver's private data |
* +-----------------------+ * +-------------------------+
* *
* Due to ieee802154 layer isn't aware of driver and MAC structures, * Due to ieee802154 layer isn't aware of driver and MAC structures,
* so lets align them here. * so lets align 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); phy = wpan_phy_alloc(priv_size);
if (!phy) { if (!phy) {
...@@ -274,106 +274,106 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) ...@@ -274,106 +274,106 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
return NULL; return NULL;
} }
priv = wpan_phy_priv(phy); local = wpan_phy_priv(phy);
priv->phy = phy; local->phy = phy;
priv->hw.phy = priv->phy; local->hw.phy = local->phy;
priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);
priv->ops = ops; local->ops = ops;
INIT_LIST_HEAD(&priv->slaves); INIT_LIST_HEAD(&local->slaves);
mutex_init(&priv->slaves_mtx); mutex_init(&local->slaves_mtx);
return &priv->hw; return &local->hw;
} }
EXPORT_SYMBOL(ieee802154_alloc_hw); EXPORT_SYMBOL(ieee802154_alloc_hw);
void ieee802154_free_hw(struct ieee802154_hw *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); EXPORT_SYMBOL(ieee802154_free_hw);
int ieee802154_register_hw(struct ieee802154_hw *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; int rc = -ENOSYS;
if (hw->flags & IEEE802154_HW_TXPOWER) { if (hw->flags & IEEE802154_HW_TXPOWER) {
if (!priv->ops->set_txpower) if (!local->ops->set_txpower)
goto out; goto out;
priv->phy->set_txpower = mac802154_set_txpower; local->phy->set_txpower = mac802154_set_txpower;
} }
if (hw->flags & IEEE802154_HW_LBT) { if (hw->flags & IEEE802154_HW_LBT) {
if (!priv->ops->set_lbt) if (!local->ops->set_lbt)
goto out; goto out;
priv->phy->set_lbt = mac802154_set_lbt; local->phy->set_lbt = mac802154_set_lbt;
} }
if (hw->flags & IEEE802154_HW_CCA_MODE) { if (hw->flags & IEEE802154_HW_CCA_MODE) {
if (!priv->ops->set_cca_mode) if (!local->ops->set_cca_mode)
goto out; 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 (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
if (!priv->ops->set_cca_ed_level) if (!local->ops->set_cca_ed_level)
goto out; 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 (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
if (!priv->ops->set_csma_params) if (!local->ops->set_csma_params)
goto out; 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 (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
if (!priv->ops->set_frame_retries) if (!local->ops->set_frame_retries)
goto out; goto out;
priv->phy->set_frame_retries = mac802154_set_frame_retries; local->phy->set_frame_retries = mac802154_set_frame_retries;
} }
priv->dev_workqueue = local->dev_workqueue =
create_singlethread_workqueue(wpan_phy_name(priv->phy)); create_singlethread_workqueue(wpan_phy_name(local->phy));
if (!priv->dev_workqueue) { if (!local->dev_workqueue) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; 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; local->phy->add_iface = mac802154_add_iface;
priv->phy->del_iface = mac802154_del_iface; local->phy->del_iface = mac802154_del_iface;
rc = wpan_phy_register(priv->phy); rc = wpan_phy_register(local->phy);
if (rc < 0) if (rc < 0)
goto out_wq; goto out_wq;
rtnl_lock(); rtnl_lock();
mutex_lock(&priv->slaves_mtx); mutex_lock(&local->slaves_mtx);
priv->running = MAC802154_DEVICE_RUN; local->running = MAC802154_DEVICE_RUN;
mutex_unlock(&priv->slaves_mtx); mutex_unlock(&local->slaves_mtx);
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
out_wq: out_wq:
destroy_workqueue(priv->dev_workqueue); destroy_workqueue(local->dev_workqueue);
out: out:
return rc; return rc;
} }
...@@ -381,19 +381,19 @@ EXPORT_SYMBOL(ieee802154_register_hw); ...@@ -381,19 +381,19 @@ EXPORT_SYMBOL(ieee802154_register_hw);
void ieee802154_unregister_hw(struct ieee802154_hw *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; struct mac802154_sub_if_data *sdata, *next;
flush_workqueue(priv->dev_workqueue); flush_workqueue(local->dev_workqueue);
destroy_workqueue(priv->dev_workqueue); destroy_workqueue(local->dev_workqueue);
rtnl_lock(); rtnl_lock();
mutex_lock(&priv->slaves_mtx); mutex_lock(&local->slaves_mtx);
priv->running = MAC802154_DEVICE_STOPPED; local->running = MAC802154_DEVICE_STOPPED;
mutex_unlock(&priv->slaves_mtx); 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); mutex_lock(&sdata->hw->slaves_mtx);
list_del(&sdata->list); list_del(&sdata->list);
mutex_unlock(&sdata->hw->slaves_mtx); mutex_unlock(&sdata->hw->slaves_mtx);
...@@ -403,7 +403,7 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw) ...@@ -403,7 +403,7 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw)
rtnl_unlock(); rtnl_unlock();
wpan_phy_unregister(priv->phy); wpan_phy_unregister(local->phy);
} }
EXPORT_SYMBOL(ieee802154_unregister_hw); EXPORT_SYMBOL(ieee802154_unregister_hw);
......
...@@ -36,7 +36,7 @@ struct hw_addr_filt_notify_work { ...@@ -36,7 +36,7 @@ struct hw_addr_filt_notify_work {
unsigned long changed; 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); struct mac802154_sub_if_data *priv = netdev_priv(dev);
...@@ -49,12 +49,11 @@ static void hw_addr_notify(struct work_struct *work) ...@@ -49,12 +49,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 *nw = container_of(work,
struct hw_addr_filt_notify_work, 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; int res;
res = hw->ops->set_hw_addr_filt(&hw->hw, res = local->ops->set_hw_addr_filt(&local->hw, &local->hw.hw_filt,
&hw->hw.hw_filt, nw->changed);
nw->changed);
if (res) if (res)
pr_debug("failed changed mask %lx\n", nw->changed); pr_debug("failed changed mask %lx\n", nw->changed);
...@@ -110,13 +109,13 @@ __le16 mac802154_dev_get_short_addr(const struct net_device *dev) ...@@ -110,13 +109,13 @@ __le16 mac802154_dev_get_short_addr(const struct net_device *dev)
void mac802154_dev_set_ieee_addr(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_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); priv->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
if (mac->ops->set_hw_addr_filt && if (local->ops->set_hw_addr_filt &&
mac->hw.hw_filt.ieee_addr != priv->extended_addr) { local->hw.hw_filt.ieee_addr != priv->extended_addr) {
mac->hw.hw_filt.ieee_addr = priv->extended_addr; local->hw.hw_filt.ieee_addr = priv->extended_addr;
set_hw_addr_filt(dev, IEEE802154_AFILT_IEEEADDR_CHANGED); set_hw_addr_filt(dev, IEEE802154_AFILT_IEEEADDR_CHANGED);
} }
} }
...@@ -165,12 +164,12 @@ static void phy_chan_notify(struct work_struct *work) ...@@ -165,12 +164,12 @@ static void phy_chan_notify(struct work_struct *work)
{ {
struct phy_chan_notify_work *nw = container_of(work, struct phy_chan_notify_work *nw = container_of(work,
struct phy_chan_notify_work, 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); struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
int res; int res;
mutex_lock(&priv->hw->phy->pib_lock); 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) { if (res) {
pr_debug("set_channel failed\n"); pr_debug("set_channel failed\n");
} else { } else {
......
...@@ -57,7 +57,7 @@ static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, ...@@ -57,7 +57,7 @@ static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb,
} }
void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb) void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb)
{ {
struct sk_buff *skb2; struct sk_buff *skb2;
struct mac802154_sub_if_data *sdata; struct mac802154_sub_if_data *sdata;
...@@ -65,7 +65,7 @@ void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb) ...@@ -65,7 +65,7 @@ void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb)
u8 *data; u8 *data;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(sdata, &priv->slaves, list) { list_for_each_entry_rcu(sdata, &local->slaves, list) {
if (sdata->type != IEEE802154_DEV_MONITOR || if (sdata->type != IEEE802154_DEV_MONITOR ||
!netif_running(sdata->dev)) !netif_running(sdata->dev))
continue; continue;
......
...@@ -49,13 +49,13 @@ struct rx_work { ...@@ -49,13 +49,13 @@ struct rx_work {
static void 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, u8 lqi)
{ {
struct mac802154_priv *priv = mac802154_to_priv(hw); struct ieee802154_local *local = mac802154_to_priv(hw);
mac_cb(skb)->lqi = lqi; mac_cb(skb)->lqi = lqi;
skb->protocol = htons(ETH_P_IEEE802154); skb->protocol = htons(ETH_P_IEEE802154);
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) { if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
u16 crc; u16 crc;
if (skb->len < 2) { if (skb->len < 2) {
...@@ -70,8 +70,8 @@ mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi) ...@@ -70,8 +70,8 @@ mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
skb_trim(skb, skb->len - 2); /* CRC */ skb_trim(skb, skb->len - 2); /* CRC */
} }
mac802154_monitors_rx(priv, skb); mac802154_monitors_rx(local, skb);
mac802154_wpans_rx(priv, skb); mac802154_wpans_rx(local, skb);
return; return;
...@@ -90,7 +90,7 @@ static void mac802154_rx_worker(struct work_struct *work) ...@@ -90,7 +90,7 @@ static void mac802154_rx_worker(struct work_struct *work)
void void
ieee802154_rx_irqsafe(struct ieee802154_hw *hw, 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(hw); struct ieee802154_local *local = mac802154_to_priv(hw);
struct rx_work *work; struct rx_work *work;
if (!skb) if (!skb)
...@@ -105,6 +105,6 @@ ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi) ...@@ -105,6 +105,6 @@ ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
work->hw = hw; work->hw = hw;
work->lqi = lqi; work->lqi = lqi;
queue_work(priv->dev_workqueue, &work->work); queue_work(local->dev_workqueue, &work->work);
} }
EXPORT_SYMBOL(ieee802154_rx_irqsafe); EXPORT_SYMBOL(ieee802154_rx_irqsafe);
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
struct xmit_work { struct xmit_work {
struct sk_buff *skb; struct sk_buff *skb;
struct work_struct work; struct work_struct work;
struct mac802154_priv *priv; struct ieee802154_local *local;
u8 chan; u8 chan;
u8 page; u8 page;
}; };
...@@ -44,10 +44,10 @@ static void mac802154_xmit_worker(struct work_struct *work) ...@@ -44,10 +44,10 @@ static void mac802154_xmit_worker(struct work_struct *work)
struct mac802154_sub_if_data *sdata; struct mac802154_sub_if_data *sdata;
int res; int res;
mutex_lock(&xw->priv->phy->pib_lock); mutex_lock(&xw->local->phy->pib_lock);
if (xw->priv->phy->current_channel != xw->chan || if (xw->local->phy->current_channel != xw->chan ||
xw->priv->phy->current_page != xw->page) { xw->local->phy->current_page != xw->page) {
res = xw->priv->ops->set_channel(&xw->priv->hw, res = xw->local->ops->set_channel(&xw->local->hw,
xw->page, xw->page,
xw->chan); xw->chan);
if (res) { if (res) {
...@@ -55,20 +55,20 @@ static void mac802154_xmit_worker(struct work_struct *work) ...@@ -55,20 +55,20 @@ static void mac802154_xmit_worker(struct work_struct *work)
goto out; goto out;
} }
xw->priv->phy->current_channel = xw->chan; xw->local->phy->current_channel = xw->chan;
xw->priv->phy->current_page = xw->page; 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) if (res)
pr_debug("transmission failed\n"); pr_debug("transmission failed\n");
out: 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. */ /* Restart the netif queue on each sub_if_data object. */
rcu_read_lock(); 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); netif_wake_queue(sdata->dev);
rcu_read_unlock(); rcu_read_unlock();
...@@ -77,20 +77,20 @@ static void mac802154_xmit_worker(struct work_struct *work) ...@@ -77,20 +77,20 @@ static void mac802154_xmit_worker(struct work_struct *work)
kfree(xw); 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) u8 page, u8 chan)
{ {
struct xmit_work *work; struct xmit_work *work;
struct mac802154_sub_if_data *sdata; 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); WARN_ON(1);
goto err_tx; goto err_tx;
} }
mac802154_monitors_rx(mac802154_to_priv(&priv->hw), skb); mac802154_monitors_rx(mac802154_to_priv(&local->hw), skb);
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); u16 crc = crc_ccitt(0, skb->data, skb->len);
u8 *data = skb_put(skb, 2); u8 *data = skb_put(skb, 2);
...@@ -98,7 +98,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb, ...@@ -98,7 +98,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
data[1] = crc >> 8; 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; goto err_tx;
work = kzalloc(sizeof(*work), GFP_ATOMIC); work = kzalloc(sizeof(*work), GFP_ATOMIC);
...@@ -109,17 +109,17 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb, ...@@ -109,17 +109,17 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
/* Stop the netif queue on each sub_if_data object. */ /* Stop the netif queue on each sub_if_data object. */
rcu_read_lock(); 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); netif_stop_queue(sdata->dev);
rcu_read_unlock(); rcu_read_unlock();
INIT_WORK(&work->work, mac802154_xmit_worker); INIT_WORK(&work->work, mac802154_xmit_worker);
work->skb = skb; work->skb = skb;
work->priv = priv; work->local = local;
work->page = page; work->page = page;
work->chan = chan; work->chan = chan;
queue_work(priv->dev_workqueue, &work->work); queue_work(local->dev_workqueue, &work->work);
return NETDEV_TX_OK; return NETDEV_TX_OK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment