diff options
Diffstat (limited to 'kernel/drivers/staging/rtl8712/rtl8712_xmit.c')
-rw-r--r-- | kernel/drivers/staging/rtl8712/rtl8712_xmit.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/kernel/drivers/staging/rtl8712/rtl8712_xmit.c b/kernel/drivers/staging/rtl8712/rtl8712_xmit.c index a3093ac12..b21a60e9f 100644 --- a/kernel/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/kernel/drivers/staging/rtl8712/rtl8712_xmit.c @@ -96,13 +96,13 @@ static u32 get_ff_hwaddr(struct xmit_frame *pxmitframe) u32 addr = 0; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct _adapter *padapter = pxmitframe->padapter; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; - if (pxmitframe->frame_tag == TXAGG_FRAMETAG) + if (pxmitframe->frame_tag == TXAGG_FRAMETAG) { addr = RTL8712_DMA_H2CCMD; - else if (pxmitframe->frame_tag == MGNT_FRAMETAG) + } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { addr = RTL8712_DMA_MGTQ; - else if (pdvobj->nr_endpoint == 6) { + } else if (pdvobj->nr_endpoint == 6) { switch (pattrib->priority) { case 0: case 3: @@ -168,7 +168,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, xmitframe_phead = &pframe_queue->queue; xmitframe_plist = xmitframe_phead->next; - if ((end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { + if (!end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); list_del_init(&pxmitframe->list); @@ -188,7 +188,7 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, struct __queue *pframe_queue = NULL; struct xmit_frame *pxmitframe = NULL; int i, inx[4]; - int j, tmp, acirp_cnt[4]; + int j, acirp_cnt[4]; /*entry indx: 0->vo, 1->vi, 2->be, 3->bk.*/ inx[0] = 0; acirp_cnt[0] = pxmitpriv->voq_cnt; @@ -198,12 +198,8 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, for (i = 0; i < 4; i++) { for (j = i + 1; j < 4; j++) { if (acirp_cnt[j] < acirp_cnt[i]) { - tmp = acirp_cnt[i]; - acirp_cnt[i] = acirp_cnt[j]; - acirp_cnt[j] = tmp; - tmp = inx[i]; - inx[i] = inx[j]; - inx[j] = tmp; + swap(acirp_cnt[i], acirp_cnt[j]); + swap(inx[i], inx[j]); } } } @@ -212,7 +208,7 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, phwxmit = phwxmit_i + inx[i]; sta_phead = &phwxmit->sta_queue->queue; sta_plist = sta_phead->next; - while ((end_of_queue_search(sta_phead, sta_plist)) == false) { + while (!end_of_queue_search(sta_phead, sta_plist)) { ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); pframe_queue = &ptxservq->sta_pending; @@ -241,11 +237,11 @@ void r8712_do_queue_select(struct _adapter *padapter, struct pkt_attrib *pattrib) { unsigned int qsel = 0; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; - if (pdvobj->nr_endpoint == 6) + if (pdvobj->nr_endpoint == 6) { qsel = (unsigned int) pattrib->priority; - else if (pdvobj->nr_endpoint == 4) { + } else if (pdvobj->nr_endpoint == 4) { qsel = (unsigned int) pattrib->priority; if (qsel == 0 || qsel == 3) qsel = 3; @@ -268,13 +264,14 @@ u8 r8712_construct_txaggr_cmd_desc(struct xmit_buf *pxmitbuf) /* Fill up TxCmd Descriptor according as USB FW Tx Aaggregation info.*/ /* dw0 */ - ptx_desc->txdw0 = cpu_to_le32(CMD_HDR_SZ&0xffff); + ptx_desc->txdw0 = cpu_to_le32(CMD_HDR_SZ & 0xffff); ptx_desc->txdw0 |= - cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<<OFFSET_SHT)&0x00ff0000); + cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & + 0x00ff0000); ptx_desc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* dw1 */ - ptx_desc->txdw1 |= cpu_to_le32((0x13<<QSEL_SHT)&0x00001f00); + ptx_desc->txdw1 |= cpu_to_le32((0x13 << QSEL_SHT) & 0x00001f00); return _SUCCESS; } @@ -326,12 +323,14 @@ u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf, int i; for (i = 0; i < padding_sz; i++) - *(pxmitframe->buf_addr+TXDESC_SIZE+last_txcmdsz+i) = 0; + *(pxmitframe->buf_addr + TXDESC_SIZE + last_txcmdsz + + i) = 0; } /* Add the new mpdu's length */ - ptx_desc->txdw0 = cpu_to_le32((ptx_desc->txdw0&0xffff0000) | - ((ptx_desc->txdw0&0x0000ffff)+ - ((TXDESC_SIZE+last_txcmdsz+padding_sz)&0x0000ffff))); + ptx_desc->txdw0 = cpu_to_le32((ptx_desc->txdw0 & 0xffff0000) | + ((ptx_desc->txdw0 & 0x0000ffff) + + ((TXDESC_SIZE + last_txcmdsz + padding_sz) & + 0x0000ffff))); return _SUCCESS; } @@ -340,12 +339,12 @@ u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf, u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf, struct xmit_frame *pxmitframe) { - /* linux complete context doesnt need to protect */ + /* linux complete context doesn't need to protect */ pxmitframe->pxmitbuf = pxmitbuf; pxmitbuf->priv_data = pxmitframe; pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; /* buffer addr assoc */ - pxmitframe->buf_addr = pxmitbuf->pbuf+TXDESC_SIZE+CMD_HDR_SZ; + pxmitframe->buf_addr = pxmitbuf->pbuf + TXDESC_SIZE + CMD_HDR_SZ; /*RTL8712_DMA_H2CCMD */ r8712_construct_txaggr_cmd_desc(pxmitbuf); r8712_construct_txaggr_cmd_hdr(pxmitbuf); @@ -378,37 +377,40 @@ u8 r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf, struct xmit_frame *pxmitframe) { struct _adapter *padapter = pxmitframe->padapter; - struct dvobj_priv *pdvobj = (struct dvobj_priv *) &padapter->dvobjpriv; - struct tx_desc *ptxdesc = (struct tx_desc *)pxmitbuf->pbuf; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; + struct tx_desc *ptxdesc = pxmitbuf->pbuf; struct cmd_hdr *pcmd_hdr = (struct cmd_hdr *) (pxmitbuf->pbuf + TXDESC_SIZE); u16 total_length = (u16) (ptxdesc->txdw0 & 0xffff); /* use 1st xmitframe as media */ xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); - pcmd_hdr->cmd_dw0 = cpu_to_le32(((total_length-CMD_HDR_SZ)&0x0000ffff)| - (pcmd_hdr->cmd_dw0&0xffff0000)); + pcmd_hdr->cmd_dw0 = cpu_to_le32(((total_length - CMD_HDR_SZ) & + 0x0000ffff) | (pcmd_hdr->cmd_dw0 & + 0xffff0000)); /* urb length in cmd_dw1 */ pcmd_hdr->cmd_dw1 = cpu_to_le32((pxmitbuf->aggr_nr & 0xff)| - ((total_length+TXDESC_SIZE) << 16)); + ((total_length + TXDESC_SIZE) << 16)); pxmitframe->last[0] = 1; pxmitframe->bpending[0] = false; pxmitframe->mem_addr = pxmitbuf->pbuf; - if ((pdvobj->ishighspeed && ((total_length+TXDESC_SIZE)%0x200) == 0) || - ((!pdvobj->ishighspeed && - ((total_length+TXDESC_SIZE)%0x40) == 0))) { + if ((pdvobj->ishighspeed && ((total_length + TXDESC_SIZE) % 0x200) == + 0) || ((!pdvobj->ishighspeed && ((total_length + TXDESC_SIZE) % + 0x40) == 0))) { ptxdesc->txdw0 |= cpu_to_le32 - (((TXDESC_SIZE+OFFSET_SZ+8)<<OFFSET_SHT)&0x00ff0000); + (((TXDESC_SIZE + OFFSET_SZ + 8) << OFFSET_SHT) & + 0x00ff0000); /*32 bytes for TX Desc + 8 bytes pending*/ } else { ptxdesc->txdw0 |= cpu_to_le32 - (((TXDESC_SIZE+OFFSET_SZ)<<OFFSET_SHT)&0x00ff0000); + (((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & + 0x00ff0000); /*default = 32 bytes for TX Desc*/ } r8712_write_port(pxmitframe->padapter, RTL8712_DMA_H2CCMD, - total_length+TXDESC_SIZE, (u8 *)pxmitframe); + total_length + TXDESC_SIZE, (u8 *)pxmitframe); return _SUCCESS; } @@ -424,9 +426,9 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) struct security_priv *psecuritypriv = &padapter->securitypriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct tx_desc *ptxdesc = (struct tx_desc *)pmem; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; #ifdef CONFIG_R8712_TX_AGGR - struct cmd_priv *pcmdpriv = (struct cmd_priv *)&padapter->cmdpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; #endif u8 blnSetTxDescOffset; sint bmcst = IS_MCAST(pattrib->ra); @@ -436,7 +438,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) memcpy(&txdesc_mp, ptxdesc, sizeof(struct tx_desc)); memset(ptxdesc, 0, sizeof(struct tx_desc)); /* offset 0 */ - ptxdesc->txdw0 |= cpu_to_le32(sz&0x0000ffff); + ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff); if (pdvobj->ishighspeed) { if (((sz + TXDESC_SIZE) % 512) == 0) blnSetTxDescOffset = 1; @@ -450,42 +452,42 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) } if (blnSetTxDescOffset) { /* 32 bytes for TX Desc + 8 bytes pending */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ + 8) << + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ + 8) << OFFSET_SHT) & 0x00ff0000); } else { /* default = 32 bytes for TX Desc */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ) << + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff0000); } ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); if (pxmitframe->frame_tag == DATA_FRAMETAG) { /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id)&0x1f); + ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x1f); #ifdef CONFIG_R8712_TX_AGGR /* dirty workaround, need to check if it is aggr cmd. */ if ((u8 *)pmem != (u8 *)pxmitframe->pxmitbuf->pbuf) { ptxdesc->txdw0 |= cpu_to_le32 - ((0x3 << TYPE_SHT)&TYPE_MSK); + ((0x3 << TYPE_SHT) & TYPE_MSK); qsel = (uint)(pattrib->qsel & 0x0000001f); if (qsel == 2) qsel = 0; ptxdesc->txdw1 |= cpu_to_le32 ((qsel << QSEL_SHT) & 0x00001f00); ptxdesc->txdw2 = cpu_to_le32 - ((qsel << RTS_RC_SHT)&0x001f0000); + ((qsel << RTS_RC_SHT) & 0x001f0000); ptxdesc->txdw6 |= cpu_to_le32 - ((0x5 << RSVD6_SHT)&RSVD6_MSK); + ((0x5 << RSVD6_SHT) & RSVD6_MSK); } else { ptxdesc->txdw0 |= cpu_to_le32 - ((0x3 << TYPE_SHT)&TYPE_MSK); + ((0x3 << TYPE_SHT) & TYPE_MSK); ptxdesc->txdw1 |= cpu_to_le32 ((0x13 << QSEL_SHT) & 0x00001f00); qsel = (uint)(pattrib->qsel & 0x0000001f); if (qsel == 2) qsel = 0; ptxdesc->txdw2 = cpu_to_le32 - ((qsel << RTS_RC_SHT)&0x0001f000); + ((qsel << RTS_RC_SHT) & 0x0001f000); ptxdesc->txdw7 |= cpu_to_le32 (pcmdpriv->cmd_seq << 24); pcmdpriv->cmd_seq++; @@ -597,7 +599,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); } else { /* offset 4 */ - qsel = (uint)(pattrib->priority&0x0000001f); + qsel = (uint)(pattrib->priority & 0x0000001f); ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); /*offset 8*/ /*offset 12*/ |