root/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rtl92e_send_cmd_pkt

   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
   4  *
   5  * Contact Information: wlanfae <wlanfae@realtek.com>
   6  */
   7 #include "rtl_core.h"
   8 #include "r8192E_hw.h"
   9 #include "r8192E_cmdpkt.h"
  10 
  11 bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data,
  12                          u32 len)
  13 {
  14         bool                            rt_status = true;
  15         struct r8192_priv *priv = rtllib_priv(dev);
  16         u16                             frag_length = 0, frag_offset = 0;
  17         struct sk_buff          *skb;
  18         unsigned char           *seg_ptr;
  19         struct cb_desc *tcb_desc;
  20         u8                              bLastIniPkt;
  21 
  22         struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
  23 
  24         RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, len);
  25 
  26         do {
  27                 if ((len - frag_offset) > CMDPACKET_FRAG_SIZE) {
  28                         frag_length = CMDPACKET_FRAG_SIZE;
  29                         bLastIniPkt = 0;
  30 
  31                 } else {
  32                         frag_length = (u16)(len - frag_offset);
  33                         bLastIniPkt = 1;
  34                 }
  35 
  36                 if (type == DESC_PACKET_TYPE_NORMAL)
  37                         skb = dev_alloc_skb(frag_length +
  38                                             priv->rtllib->tx_headroom + 4);
  39                 else
  40                         skb = dev_alloc_skb(frag_length + 4);
  41 
  42                 if (!skb) {
  43                         rt_status = false;
  44                         goto Failed;
  45                 }
  46 
  47                 memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
  48                 tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
  49                 tcb_desc->queue_index = TXCMD_QUEUE;
  50                 tcb_desc->bCmdOrInit = type;
  51                 tcb_desc->bLastIniPkt = bLastIniPkt;
  52 
  53                 if (type == DESC_PACKET_TYPE_NORMAL) {
  54                         tcb_desc->pkt_size = frag_length;
  55 
  56                         seg_ptr = skb_put(skb, priv->rtllib->tx_headroom);
  57                         pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr;
  58                         memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci));
  59                         memset(pTxFwInfo, 0x12, 8);
  60                 } else {
  61                         tcb_desc->txbuf_size = (u16)frag_length;
  62                 }
  63 
  64                 seg_ptr = skb_put(skb, frag_length);
  65                 memcpy(seg_ptr, data, (u32)frag_length);
  66 
  67                 if (type == DESC_PACKET_TYPE_INIT &&
  68                     (!priv->rtllib->check_nic_enough_desc(dev, TXCMD_QUEUE) ||
  69                      (!skb_queue_empty(&priv->rtllib->skb_waitQ[TXCMD_QUEUE])) ||
  70                      (priv->rtllib->queue_stop))) {
  71                         skb_queue_tail(&priv->rtllib->skb_waitQ[TXCMD_QUEUE],
  72                                        skb);
  73                 } else {
  74                         priv->rtllib->softmac_hard_start_xmit(skb, dev);
  75                 }
  76 
  77                 data += frag_length;
  78                 frag_offset += frag_length;
  79 
  80         } while (frag_offset < len);
  81 
  82         rtl92e_writeb(dev, TPPoll, TPPoll_CQ);
  83 Failed:
  84         return rt_status;
  85 }

/* [<][>][^][v][top][bottom][index][help] */