Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
0005  *
0006  * Modifications for inclusion into the Linux staging tree are
0007  * Copyright(c) 2010 Larry Finger. All rights reserved.
0008  *
0009  * Contact information:
0010  * WLAN FAE <wlanfae@realtek.com>
0011  * Larry Finger <Larry.Finger@lwfinger.net>
0012  *
0013  ******************************************************************************/
0014 #ifndef _RTL871X_XMIT_H_
0015 #define _RTL871X_XMIT_H_
0016 
0017 #include "osdep_service.h"
0018 #include "drv_types.h"
0019 #include "xmit_osdep.h"
0020 
0021 #ifdef CONFIG_R8712_TX_AGGR
0022 #define MAX_XMITBUF_SZ  (16384)
0023 #else
0024 #define MAX_XMITBUF_SZ  (2048)
0025 #endif
0026 
0027 #define NR_XMITBUFF     (4)
0028 
0029 #ifdef CONFIG_R8712_TX_AGGR
0030 #define AGGR_NR_HIGH_BOUND      (4) /*(8) */
0031 #define AGGR_NR_LOW_BOUND       (2)
0032 #endif
0033 
0034 #define XMITBUF_ALIGN_SZ 512
0035 #define TX_GUARD_BAND       5
0036 #define MAX_NUMBLKS     (1)
0037 
0038 /* Fixed the Big Endian bug when using the software driver encryption.*/
0039 #define WEP_IV(pattrib_iv, txpn, keyidx)\
0040 do { \
0041     pattrib_iv[0] = txpn._byte_.TSC0;\
0042     pattrib_iv[1] = txpn._byte_.TSC1;\
0043     pattrib_iv[2] = txpn._byte_.TSC2;\
0044     pattrib_iv[3] = ((keyidx & 0x3) << 6);\
0045     txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val + 1);\
0046 } while (0)
0047 
0048 /* Fixed the Big Endian bug when doing the Tx.
0049  * The Linksys WRH54G will check this.
0050  */
0051 #define TKIP_IV(pattrib_iv, txpn, keyidx)\
0052 do { \
0053     pattrib_iv[0] = txpn._byte_.TSC1;\
0054     pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
0055     pattrib_iv[2] = txpn._byte_.TSC0;\
0056     pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\
0057     pattrib_iv[4] = txpn._byte_.TSC2;\
0058     pattrib_iv[5] = txpn._byte_.TSC3;\
0059     pattrib_iv[6] = txpn._byte_.TSC4;\
0060     pattrib_iv[7] = txpn._byte_.TSC5;\
0061     txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
0062     (txpn.val + 1);\
0063 } while (0)
0064 
0065 #define AES_IV(pattrib_iv, txpn, keyidx)\
0066 do { \
0067     pattrib_iv[0] = txpn._byte_.TSC0;\
0068     pattrib_iv[1] = txpn._byte_.TSC1;\
0069     pattrib_iv[2] = 0;\
0070     pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\
0071     pattrib_iv[4] = txpn._byte_.TSC2;\
0072     pattrib_iv[5] = txpn._byte_.TSC3;\
0073     pattrib_iv[6] = txpn._byte_.TSC4;\
0074     pattrib_iv[7] = txpn._byte_.TSC5;\
0075     txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
0076     (txpn.val + 1);\
0077 } while (0)
0078 
0079 struct hw_xmit {
0080     spinlock_t xmit_lock;
0081     struct list_head pending;
0082     struct  __queue *sta_queue;
0083     struct hw_txqueue *phwtxqueue;
0084     sint    txcmdcnt;
0085     int accnt;
0086 };
0087 
0088 struct pkt_attrib {
0089     u8  type;
0090     u8  subtype;
0091     u8  bswenc;
0092     u8  dhcp_pkt;
0093 
0094     u16 seqnum;
0095     u16 ether_type;
0096     u16 pktlen;     /* the original 802.3 pkt raw_data len
0097                  * (not include ether_hdr data)
0098                  */
0099     u16 last_txcmdsz;
0100 
0101     u8  pkt_hdrlen; /*the original 802.3 pkt header len*/
0102     u8  hdrlen;     /*the WLAN Header Len*/
0103     u8  nr_frags;
0104     u8  ack_policy;
0105     u8  mac_id;
0106     u8  vcs_mode;   /*virtual carrier sense method*/
0107     u8  pctrl;/*per packet txdesc control enable*/
0108     u8  qsel;
0109 
0110     u8  priority;
0111     u8  encrypt;    /* when 0 indicate no encrypt. when non-zero,
0112                  * indicate the encrypt algorithm
0113                  */
0114     u8  iv_len;
0115     u8  icv_len;
0116     unsigned char iv[8];
0117     unsigned char icv[8];
0118     u8  dst[ETH_ALEN] __aligned(2); /* for ether_addr_copy */
0119     u8  src[ETH_ALEN];
0120     u8  ta[ETH_ALEN];
0121     u8  ra[ETH_ALEN];
0122     struct sta_info *psta;
0123 };
0124 
0125 #define WLANHDR_OFFSET  64
0126 #define DATA_FRAMETAG       0x01
0127 #define L2_FRAMETAG     0x02
0128 #define MGNT_FRAMETAG       0x03
0129 #define AMSDU_FRAMETAG  0x04
0130 #define EII_FRAMETAG        0x05
0131 #define IEEE8023_FRAMETAG  0x06
0132 #define MP_FRAMETAG     0x07
0133 #define TXAGG_FRAMETAG  0x08
0134 
0135 struct xmit_buf {
0136     struct list_head list;
0137 
0138     u8 *pallocated_buf;
0139     u8 *pbuf;
0140     void *priv_data;
0141     struct urb *pxmit_urb[8];
0142     u32 aggr_nr;
0143 };
0144 
0145 struct xmit_frame {
0146     struct list_head list;
0147     struct pkt_attrib attrib;
0148     _pkt *pkt;
0149     int frame_tag;
0150     struct _adapter *padapter;
0151     u8 *buf_addr;
0152     struct xmit_buf *pxmitbuf;
0153     u8 *mem_addr;
0154     u16 sz[8];
0155     struct urb *pxmit_urb[8];
0156     u8 bpending[8];
0157     u8 last[8];
0158 };
0159 
0160 struct tx_servq {
0161     struct list_head tx_pending;
0162     struct  __queue sta_pending;
0163     int qcnt;
0164 };
0165 
0166 struct sta_xmit_priv {
0167     spinlock_t lock;
0168     sint    option;
0169     sint    apsd_setting;   /* When bit mask is on, the associated edca
0170                  * queue supports APSD.
0171                  */
0172     struct tx_servq be_q;   /* priority == 0,3 */
0173     struct tx_servq bk_q;   /* priority == 1,2*/
0174     struct tx_servq vi_q;   /*priority == 4,5*/
0175     struct tx_servq vo_q;   /*priority == 6,7*/
0176     struct list_head  legacy_dz;
0177     struct list_head apsd;
0178     u16 txseq_tid[16];
0179     uint    sta_tx_bytes;
0180     u64 sta_tx_pkts;
0181     uint    sta_tx_fail;
0182 };
0183 
0184 struct  hw_txqueue {
0185     sint    head;
0186     sint    tail;
0187     sint    free_sz;    /* in units of 64 bytes */
0188     sint    free_cmdsz;
0189     sint    txsz[8];
0190     uint    ff_hwaddr;
0191     uint    cmd_hwaddr;
0192     sint    ac_tag;
0193 };
0194 
0195 struct  xmit_priv {
0196     spinlock_t lock;
0197     struct  __queue be_pending;
0198     struct  __queue bk_pending;
0199     struct  __queue vi_pending;
0200     struct  __queue vo_pending;
0201     struct  __queue bm_pending;
0202     struct  __queue legacy_dz_queue;
0203     struct  __queue apsd_queue;
0204     u8 *pallocated_frame_buf;
0205     u8 *pxmit_frame_buf;
0206     uint free_xmitframe_cnt;
0207     uint mapping_addr;
0208     uint pkt_sz;
0209     struct  __queue free_xmit_queue;
0210     struct  hw_txqueue  be_txqueue;
0211     struct  hw_txqueue  bk_txqueue;
0212     struct  hw_txqueue  vi_txqueue;
0213     struct  hw_txqueue  vo_txqueue;
0214     struct  hw_txqueue  bmc_txqueue;
0215     uint    frag_len;
0216     struct _adapter *adapter;
0217     u8   vcs_setting;
0218     u8  vcs;
0219     u8  vcs_type;
0220     u16  rts_thresh;
0221     uint    tx_bytes;
0222     u64 tx_pkts;
0223     uint    tx_drop;
0224     struct hw_xmit *hwxmits;
0225     u8  hwxmit_entry;
0226     u8  txirp_cnt;
0227     struct tasklet_struct xmit_tasklet;
0228     struct work_struct xmit_pipe4_reset_wi;
0229     struct work_struct xmit_pipe6_reset_wi;
0230     struct work_struct xmit_piped_reset_wi;
0231     /*per AC pending irp*/
0232     int beq_cnt;
0233     int bkq_cnt;
0234     int viq_cnt;
0235     int voq_cnt;
0236     struct  __queue free_amsdu_xmit_queue;
0237     u8 *pallocated_amsdu_frame_buf;
0238     u8 *pxmit_amsdu_frame_buf;
0239     uint free_amsdu_xmitframe_cnt;
0240     struct  __queue free_txagg_xmit_queue;
0241     u8 *pallocated_txagg_frame_buf;
0242     u8 *pxmit_txagg_frame_buf;
0243     uint free_txagg_xmitframe_cnt;
0244     int cmdseq;
0245     struct  __queue free_xmitbuf_queue;
0246     struct  __queue pending_xmitbuf_queue;
0247     u8 *pallocated_xmitbuf;
0248     u8 *pxmitbuf;
0249     uint free_xmitbuf_cnt;
0250 };
0251 
0252 void r8712_free_xmitbuf(struct xmit_priv *pxmitpriv,
0253             struct xmit_buf *pxmitbuf);
0254 struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
0255 void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len);
0256 struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv);
0257 void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
0258               struct xmit_frame *pxmitframe);
0259 void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
0260                 struct  __queue *pframequeue);
0261 int r8712_xmit_classifier(struct _adapter *padapter,
0262               struct xmit_frame *pxmitframe);
0263 sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
0264                   struct xmit_frame *pxmitframe);
0265 sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
0266 void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
0267 int r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
0268             struct pkt_attrib *pattrib);
0269 int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
0270                   struct pkt_attrib *pattrib);
0271 int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
0272               struct _adapter *padapter);
0273 void _free_xmit_priv(struct xmit_priv *pxmitpriv);
0274 void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
0275                  struct xmit_frame *pxmitframe);
0276 int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe);
0277 int r8712_xmit_enqueue(struct _adapter *padapter,
0278                struct xmit_frame *pxmitframe);
0279 void r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe);
0280 void r8712_xmit_bh(struct tasklet_struct *t);
0281 
0282 void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe,
0283                   struct xmit_buf *pxmitbuf);
0284 
0285 #include "rtl8712_xmit.h"
0286 
0287 #endif  /*_RTL871X_XMIT_H_*/
0288