1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * The full GNU General Public License is included in this distribution in the
10 * file called LICENSE.
12 * Contact Information:
13 * wlanfae <wlanfae@realtek.com>
14 ******************************************************************************/
17 #include "r8192E_hw.h"
18 #include "r8192E_cmdpkt.h"
20 bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data,
24 bool rt_status = true;
25 struct r8192_priv *priv = rtllib_priv(dev);
26 u16 frag_length = 0, frag_offset = 0;
28 unsigned char *seg_ptr;
29 struct cb_desc *tcb_desc;
32 struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
34 RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, len);
37 if ((len - frag_offset) > CMDPACKET_FRAG_SIZE) {
38 frag_length = CMDPACKET_FRAG_SIZE;
42 frag_length = (u16)(len - frag_offset);
46 if (type == DESC_PACKET_TYPE_NORMAL)
47 skb = dev_alloc_skb(frag_length +
48 priv->rtllib->tx_headroom + 4);
50 skb = dev_alloc_skb(frag_length + 4);
57 memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
58 tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
59 tcb_desc->queue_index = TXCMD_QUEUE;
60 tcb_desc->bCmdOrInit = type;
61 tcb_desc->bLastIniPkt = bLastIniPkt;
63 if (type == DESC_PACKET_TYPE_NORMAL) {
64 tcb_desc->pkt_size = frag_length;
66 seg_ptr = skb_put(skb, priv->rtllib->tx_headroom);
67 pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr;
68 memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci));
69 memset(pTxFwInfo, 0x12, 8);
71 tcb_desc->txbuf_size = (u16)frag_length;
74 seg_ptr = skb_put(skb, frag_length);
75 memcpy(seg_ptr, data, (u32)frag_length);
77 if (type == DESC_PACKET_TYPE_INIT &&
78 (!priv->rtllib->check_nic_enough_desc(dev, TXCMD_QUEUE) ||
79 (!skb_queue_empty(&priv->rtllib->skb_waitQ[TXCMD_QUEUE])) ||
80 (priv->rtllib->queue_stop))) {
81 skb_queue_tail(&priv->rtllib->skb_waitQ[TXCMD_QUEUE],
84 priv->rtllib->softmac_hard_start_xmit(skb, dev);
88 frag_offset += frag_length;
90 } while (frag_offset < len);
92 rtl92e_writeb(dev, TPPoll, TPPoll_CQ);