mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 21:33:00 +00:00
mac802154: Add MLME Tx locked helpers
These have the exact same behavior as before, except they expect the rtnl to be already taken (and will complain otherwise). This allows performing MLME transmissions from different contexts. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Alexander Aring <aahringo@redhat.com> Link: https://lore.kernel.org/r/20230103165644.432209-6-miquel.raynal@bootlin.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
This commit is contained in:
parent
5755cd4d94
commit
dd18096256
@ -141,10 +141,16 @@ int ieee802154_mlme_op_pre(struct ieee802154_local *local);
|
||||
int ieee802154_mlme_tx(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb);
|
||||
int ieee802154_mlme_tx_locked(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb);
|
||||
void ieee802154_mlme_op_post(struct ieee802154_local *local);
|
||||
int ieee802154_mlme_tx_one(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb);
|
||||
int ieee802154_mlme_tx_one_locked(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb);
|
||||
netdev_tx_t
|
||||
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
netdev_tx_t
|
||||
|
@ -137,34 +137,37 @@ int ieee802154_mlme_op_pre(struct ieee802154_local *local)
|
||||
return ieee802154_sync_and_hold_queue(local);
|
||||
}
|
||||
|
||||
int ieee802154_mlme_tx_locked(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
/* Avoid possible calls to ->ndo_stop() when we asynchronously perform
|
||||
* MLME transmissions.
|
||||
*/
|
||||
ASSERT_RTNL();
|
||||
|
||||
/* Ensure the device was not stopped, otherwise error out */
|
||||
if (!local->open_count)
|
||||
return -ENETDOWN;
|
||||
|
||||
/* Warn if the ieee802154 core thinks MLME frames can be sent while the
|
||||
* net interface expects this cannot happen.
|
||||
*/
|
||||
if (WARN_ON_ONCE(!netif_running(sdata->dev)))
|
||||
return -ENETDOWN;
|
||||
|
||||
ieee802154_tx(local, skb);
|
||||
return ieee802154_sync_queue(local);
|
||||
}
|
||||
|
||||
int ieee802154_mlme_tx(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Avoid possible calls to ->ndo_stop() when we asynchronously perform
|
||||
* MLME transmissions.
|
||||
*/
|
||||
rtnl_lock();
|
||||
|
||||
/* Ensure the device was not stopped, otherwise error out */
|
||||
if (!local->open_count) {
|
||||
rtnl_unlock();
|
||||
return -ENETDOWN;
|
||||
}
|
||||
|
||||
/* Warn if the ieee802154 core thinks MLME frames can be sent while the
|
||||
* net interface expects this cannot happen.
|
||||
*/
|
||||
if (WARN_ON_ONCE(!netif_running(sdata->dev))) {
|
||||
rtnl_unlock();
|
||||
return -ENETDOWN;
|
||||
}
|
||||
|
||||
ieee802154_tx(local, skb);
|
||||
ret = ieee802154_sync_queue(local);
|
||||
|
||||
ret = ieee802154_mlme_tx_locked(local, sdata, skb);
|
||||
rtnl_unlock();
|
||||
|
||||
return ret;
|
||||
@ -188,6 +191,19 @@ int ieee802154_mlme_tx_one(struct ieee802154_local *local,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ieee802154_mlme_tx_one_locked(struct ieee802154_local *local,
|
||||
struct ieee802154_sub_if_data *sdata,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ieee802154_mlme_op_pre(local);
|
||||
ret = ieee802154_mlme_tx_locked(local, sdata, skb);
|
||||
ieee802154_mlme_op_post(local);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool ieee802154_queue_is_stopped(struct ieee802154_local *local)
|
||||
{
|
||||
return test_bit(WPAN_PHY_FLAG_STATE_QUEUE_STOPPED, &local->phy->flags);
|
||||
|
Loading…
Reference in New Issue
Block a user