Skip to content

Commit ed0a5dc

Browse files
alexaringholtmann
authored andcommitted
mac802154: tx: add support for xmit_async callback
This patch renames the existsing xmit callback to xmit_sync and introduces an asynchronous xmit_async function. If ieee802154_ops doesn't provide the xmit_async callback, then we have a fallback to the xmit_sync callback. Signed-off-by: Alexander Aring <[email protected]> Cc: Alan Ott <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent cdb66be commit ed0a5dc

File tree

7 files changed

+35
-14
lines changed

7 files changed

+35
-14
lines changed

drivers/net/ieee802154/at86rf230.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
12371237

12381238
static struct ieee802154_ops at86rf230_ops = {
12391239
.owner = THIS_MODULE,
1240-
.xmit = at86rf230_xmit,
1240+
.xmit_sync = at86rf230_xmit,
12411241
.ed = at86rf230_ed,
12421242
.set_channel = at86rf230_channel,
12431243
.start = at86rf230_start,

drivers/net/ieee802154/cc2520.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static struct ieee802154_ops cc2520_ops = {
635635
.owner = THIS_MODULE,
636636
.start = cc2520_start,
637637
.stop = cc2520_stop,
638-
.xmit = cc2520_tx,
638+
.xmit_sync = cc2520_tx,
639639
.ed = cc2520_ed,
640640
.set_channel = cc2520_set_channel,
641641
.set_hw_addr_filt = cc2520_filter,

drivers/net/ieee802154/fakelb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fakelb_hw_stop(struct ieee802154_hw *hw) {
131131

132132
static struct ieee802154_ops fakelb_ops = {
133133
.owner = THIS_MODULE,
134-
.xmit = fakelb_hw_xmit,
134+
.xmit_sync = fakelb_hw_xmit,
135135
.ed = fakelb_hw_ed,
136136
.set_channel = fakelb_hw_channel,
137137
.start = fakelb_hw_start,

drivers/net/ieee802154/mrf24j40.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static int mrf24j40_handle_rx(struct mrf24j40 *devrec)
581581

582582
static struct ieee802154_ops mrf24j40_ops = {
583583
.owner = THIS_MODULE,
584-
.xmit = mrf24j40_tx,
584+
.xmit_sync = mrf24j40_tx,
585585
.ed = mrf24j40_ed,
586586
.start = mrf24j40_start,
587587
.stop = mrf24j40_stop,

include/net/mac802154.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ struct ieee802154_hw {
109109
* stop: Handler that 802.15.4 module calls for device cleanup.
110110
* This function is called after the last interface is removed.
111111
*
112-
* xmit: Handler that 802.15.4 module calls for each transmitted frame.
112+
* xmit_sync:
113+
* Handler that 802.15.4 module calls for each transmitted frame.
114+
* skb cntains the buffer starting from the IEEE 802.15.4 header.
115+
* The low-level driver should send the frame based on available
116+
* configuration. This is called by a workqueue and useful for
117+
* synchronous 802.15.4 drivers.
118+
* This function should return zero or negative errno.
119+
*
120+
* xmit_async:
121+
* Handler that 802.15.4 module calls for each transmitted frame.
113122
* skb cntains the buffer starting from the IEEE 802.15.4 header.
114123
* The low-level driver should send the frame based on available
115124
* configuration.
@@ -160,8 +169,10 @@ struct ieee802154_ops {
160169
struct module *owner;
161170
int (*start)(struct ieee802154_hw *hw);
162171
void (*stop)(struct ieee802154_hw *hw);
163-
int (*xmit)(struct ieee802154_hw *hw,
164-
struct sk_buff *skb);
172+
int (*xmit_sync)(struct ieee802154_hw *hw,
173+
struct sk_buff *skb);
174+
int (*xmit_async)(struct ieee802154_hw *hw,
175+
struct sk_buff *skb);
165176
int (*ed)(struct ieee802154_hw *hw, u8 *level);
166177
int (*set_channel)(struct ieee802154_hw *hw,
167178
int page,

net/mac802154/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops)
229229
struct ieee802154_local *local;
230230
size_t priv_size;
231231

232-
if (!ops || !ops->xmit || !ops->ed || !ops->start ||
233-
!ops->stop || !ops->set_channel) {
232+
if (!ops || !(ops->xmit_async || ops->xmit_sync) || !ops->ed ||
233+
!ops->start || !ops->stop || !ops->set_channel) {
234234
pr_err("undefined IEEE802.15.4 device operations\n");
235235
return NULL;
236236
}

net/mac802154/tx.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void mac802154_xmit_worker(struct work_struct *work)
5050
struct sk_buff *skb = cb->skb;
5151
int res;
5252

53-
res = local->ops->xmit(&local->hw, skb);
53+
res = local->ops->xmit_sync(&local->hw, skb);
5454
if (res) {
5555
pr_debug("transmission failed\n");
5656
/* Restart the netif queue on each sub_if_data object. */
@@ -66,6 +66,7 @@ static netdev_tx_t
6666
mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
6767
{
6868
struct wpan_xmit_cb *cb = wpan_xmit_cb(skb);
69+
int ret;
6970

7071
mac802154_monitors_rx(local, skb);
7172

@@ -83,11 +84,20 @@ mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
8384
/* Stop the netif queue on each sub_if_data object. */
8485
ieee802154_stop_queue(&local->hw);
8586

86-
INIT_WORK(&cb->work, mac802154_xmit_worker);
87-
cb->skb = skb;
88-
cb->local = local;
87+
/* async is priority, otherwise sync is fallback */
88+
if (local->ops->xmit_async) {
89+
ret = local->ops->xmit_async(&local->hw, skb);
90+
if (ret) {
91+
ieee802154_wake_queue(&local->hw);
92+
goto err_tx;
93+
}
94+
} else {
95+
INIT_WORK(&cb->work, mac802154_xmit_worker);
96+
cb->skb = skb;
97+
cb->local = local;
8998

90-
queue_work(local->workqueue, &cb->work);
99+
queue_work(local->workqueue, &cb->work);
100+
}
91101

92102
return NETDEV_TX_OK;
93103

0 commit comments

Comments
 (0)