1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2019 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
9 mt76_mcu_msg_alloc(const void *data
, int head_len
,
10 int data_len
, int tail_len
)
12 int length
= head_len
+ data_len
+ tail_len
;
15 skb
= alloc_skb(length
, GFP_KERNEL
);
19 memset(skb
->head
, 0, length
);
20 skb_reserve(skb
, head_len
);
23 skb_put_data(skb
, data
, data_len
);
27 EXPORT_SYMBOL_GPL(mt76_mcu_msg_alloc
);
29 struct sk_buff
*mt76_mcu_get_response(struct mt76_dev
*dev
,
30 unsigned long expires
)
32 unsigned long timeout
;
34 if (!time_is_after_jiffies(expires
))
37 timeout
= expires
- jiffies
;
38 wait_event_timeout(dev
->mcu
.wait
,
39 (!skb_queue_empty(&dev
->mcu
.res_q
) ||
40 test_bit(MT76_MCU_RESET
, &dev
->phy
.state
)),
42 return skb_dequeue(&dev
->mcu
.res_q
);
44 EXPORT_SYMBOL_GPL(mt76_mcu_get_response
);
46 void mt76_mcu_rx_event(struct mt76_dev
*dev
, struct sk_buff
*skb
)
48 skb_queue_tail(&dev
->mcu
.res_q
, skb
);
49 wake_up(&dev
->mcu
.wait
);
51 EXPORT_SYMBOL_GPL(mt76_mcu_rx_event
);