|
@@ -1216,40 +1216,24 @@ void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe,
|
|
|
struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
|
|
|
{
|
|
|
unsigned long irql;
|
|
|
- struct xmit_buf *pxmitbuf = NULL;
|
|
|
- struct list_head *plist, *phead;
|
|
|
+ struct xmit_buf *pxmitbuf;
|
|
|
struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
|
|
|
|
|
|
-
|
|
|
spin_lock_irqsave(&pfree_queue->lock, irql);
|
|
|
-
|
|
|
- if (list_empty(&pfree_queue->queue)) {
|
|
|
- pxmitbuf = NULL;
|
|
|
- } else {
|
|
|
- phead = get_list_head(pfree_queue);
|
|
|
-
|
|
|
- plist = phead->next;
|
|
|
-
|
|
|
- pxmitbuf = container_of(plist, struct xmit_buf, list);
|
|
|
-
|
|
|
- list_del_init(&(pxmitbuf->list));
|
|
|
- }
|
|
|
-
|
|
|
- if (pxmitbuf != NULL) {
|
|
|
+ pxmitbuf = list_first_entry_or_null(&pfree_queue->queue,
|
|
|
+ struct xmit_buf, list);
|
|
|
+ if (pxmitbuf) {
|
|
|
+ list_del_init(&pxmitbuf->list);
|
|
|
pxmitpriv->free_xmit_extbuf_cnt--;
|
|
|
-
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
/* pxmitbuf->ext_tag = true; */
|
|
|
-
|
|
|
if (pxmitbuf->sctx) {
|
|
|
DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__);
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
spin_unlock_irqrestore(&pfree_queue->lock, irql);
|
|
|
|
|
|
-
|
|
|
return pxmitbuf;
|
|
|
}
|
|
|
|
|
@@ -1278,28 +1262,16 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
|
|
|
struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
|
|
|
{
|
|
|
unsigned long irql;
|
|
|
- struct xmit_buf *pxmitbuf = NULL;
|
|
|
- struct list_head *plist, *phead;
|
|
|
+ struct xmit_buf *pxmitbuf;
|
|
|
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
|
|
|
|
|
|
-
|
|
|
/* DBG_88E("+rtw_alloc_xmitbuf\n"); */
|
|
|
|
|
|
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irql);
|
|
|
-
|
|
|
- if (list_empty(&pfree_xmitbuf_queue->queue)) {
|
|
|
- pxmitbuf = NULL;
|
|
|
- } else {
|
|
|
- phead = get_list_head(pfree_xmitbuf_queue);
|
|
|
-
|
|
|
- plist = phead->next;
|
|
|
-
|
|
|
- pxmitbuf = container_of(plist, struct xmit_buf, list);
|
|
|
-
|
|
|
- list_del_init(&(pxmitbuf->list));
|
|
|
- }
|
|
|
-
|
|
|
- if (pxmitbuf != NULL) {
|
|
|
+ pxmitbuf = list_first_entry_or_null(&pfree_xmitbuf_queue->queue,
|
|
|
+ struct xmit_buf, list);
|
|
|
+ if (pxmitbuf) {
|
|
|
+ list_del_init(&pxmitbuf->list);
|
|
|
pxmitpriv->free_xmitbuf_cnt--;
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
if (pxmitbuf->sctx) {
|
|
@@ -1309,7 +1281,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
|
|
|
}
|
|
|
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql);
|
|
|
|
|
|
-
|
|
|
return pxmitbuf;
|
|
|
}
|
|
|
|
|
@@ -1355,38 +1326,33 @@ Must be very very cautious...
|
|
|
|
|
|
*/
|
|
|
|
|
|
-struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */
|
|
|
+struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)
|
|
|
+ /* _queue *pfree_xmit_queue) */
|
|
|
{
|
|
|
/*
|
|
|
Please remember to use all the osdep_service api,
|
|
|
and lock/unlock or _enter/_exit critical to protect
|
|
|
pfree_xmit_queue
|
|
|
*/
|
|
|
-
|
|
|
- struct xmit_frame *pxframe = NULL;
|
|
|
- struct list_head *plist, *phead;
|
|
|
+ struct xmit_frame *pxframe;
|
|
|
struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
|
|
|
|
|
|
-
|
|
|
spin_lock_bh(&pfree_xmit_queue->lock);
|
|
|
-
|
|
|
- if (list_empty(&pfree_xmit_queue->queue)) {
|
|
|
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt));
|
|
|
- pxframe = NULL;
|
|
|
+ pxframe = list_first_entry_or_null(&pfree_xmit_queue->queue,
|
|
|
+ struct xmit_frame, list);
|
|
|
+ if (!pxframe) {
|
|
|
+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
|
|
|
+ ("rtw_alloc_xmitframe:%d\n",
|
|
|
+ pxmitpriv->free_xmitframe_cnt));
|
|
|
} else {
|
|
|
- phead = get_list_head(pfree_xmit_queue);
|
|
|
-
|
|
|
- plist = phead->next;
|
|
|
-
|
|
|
- pxframe = container_of(plist, struct xmit_frame, list);
|
|
|
+ list_del_init(&pxframe->list);
|
|
|
|
|
|
- list_del_init(&(pxframe->list));
|
|
|
- }
|
|
|
-
|
|
|
- if (pxframe != NULL) { /* default value setting */
|
|
|
+ /* default value setting */
|
|
|
pxmitpriv->free_xmitframe_cnt--;
|
|
|
|
|
|
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt));
|
|
|
+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
|
|
|
+ ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n",
|
|
|
+ pxmitpriv->free_xmitframe_cnt));
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
pxframe->pxmitbuf = NULL;
|
|
@@ -1402,10 +1368,8 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf
|
|
|
pxframe->agg_num = 1;
|
|
|
pxframe->ack_report = 0;
|
|
|
}
|
|
|
-
|
|
|
spin_unlock_bh(&pfree_xmit_queue->lock);
|
|
|
|
|
|
-
|
|
|
return pxframe;
|
|
|
}
|
|
|
|