root/drivers/staging/rtl8188eu/include/rtw_xmit.h

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

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 #ifndef _RTW_XMIT_H_
   8 #define _RTW_XMIT_H_
   9 
  10 #include <osdep_service.h>
  11 #include <drv_types.h>
  12 
  13 #define MAX_XMITBUF_SZ  (20480) /*  20k */
  14 #define NR_XMITBUFF             (4)
  15 
  16 #define XMITBUF_ALIGN_SZ        4
  17 
  18 /*  xmit extension buff defination */
  19 #define MAX_XMIT_EXTBUF_SZ      (1536)
  20 #define NR_XMIT_EXTBUFF         (32)
  21 
  22 #define MAX_NUMBLKS             (1)
  23 
  24 #define XMIT_VO_QUEUE           (0)
  25 #define XMIT_VI_QUEUE           (1)
  26 #define XMIT_BE_QUEUE           (2)
  27 #define XMIT_BK_QUEUE           (3)
  28 
  29 #define VO_QUEUE_INX            0
  30 #define VI_QUEUE_INX            1
  31 #define BE_QUEUE_INX            2
  32 #define BK_QUEUE_INX            3
  33 #define BCN_QUEUE_INX           4
  34 #define MGT_QUEUE_INX           5
  35 #define HIGH_QUEUE_INX          6
  36 #define TXCMD_QUEUE_INX         7
  37 
  38 #define HW_QUEUE_ENTRY          8
  39 
  40 #define WEP_IV(pattrib_iv, dot11txpn, keyidx)\
  41 do {\
  42         pattrib_iv[0] = dot11txpn._byte_.TSC0;\
  43         pattrib_iv[1] = dot11txpn._byte_.TSC1;\
  44         pattrib_iv[2] = dot11txpn._byte_.TSC2;\
  45         pattrib_iv[3] = ((keyidx & 0x3)<<6);\
  46         dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\
  47 } while (0)
  48 
  49 
  50 #define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\
  51 do {\
  52         pattrib_iv[0] = dot11txpn._byte_.TSC1;\
  53         pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\
  54         pattrib_iv[2] = dot11txpn._byte_.TSC0;\
  55         pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
  56         pattrib_iv[4] = dot11txpn._byte_.TSC2;\
  57         pattrib_iv[5] = dot11txpn._byte_.TSC3;\
  58         pattrib_iv[6] = dot11txpn._byte_.TSC4;\
  59         pattrib_iv[7] = dot11txpn._byte_.TSC5;\
  60         dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
  61 } while (0)
  62 
  63 #define AES_IV(pattrib_iv, dot11txpn, keyidx)\
  64 do {                                                    \
  65         pattrib_iv[0] = dot11txpn._byte_.TSC0;          \
  66         pattrib_iv[1] = dot11txpn._byte_.TSC1;          \
  67         pattrib_iv[2] = 0;                              \
  68         pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);   \
  69         pattrib_iv[4] = dot11txpn._byte_.TSC2;          \
  70         pattrib_iv[5] = dot11txpn._byte_.TSC3;          \
  71         pattrib_iv[6] = dot11txpn._byte_.TSC4;          \
  72         pattrib_iv[7] = dot11txpn._byte_.TSC5;          \
  73         dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\
  74 } while (0)
  75 
  76 #define HWXMIT_ENTRY    4
  77 
  78 #define TXDESC_SIZE 32
  79 
  80 #define PACKET_OFFSET_SZ (8)
  81 #define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ)
  82 
  83 struct tx_desc {
  84         /* DWORD 0 */
  85         __le32 txdw0;
  86         __le32 txdw1;
  87         __le32 txdw2;
  88         __le32 txdw3;
  89         __le32 txdw4;
  90         __le32 txdw5;
  91         __le32 txdw6;
  92         __le32 txdw7;
  93 };
  94 
  95 struct  hw_xmit {
  96         struct __queue *sta_queue;
  97         int     accnt;
  98 };
  99 
 100 /* reduce size */
 101 struct pkt_attrib {
 102         u8      type;
 103         u8      subtype;
 104         u8      bswenc;
 105         u8      dhcp_pkt;
 106         u16     ether_type;
 107         u16     seqnum;
 108         u16     hdrlen;         /* the WLAN Header Len */
 109         u32     pktlen;         /* the original 802.3 pkt raw_data len (not include
 110                                  * ether_hdr data)
 111                                  */
 112         u32     last_txcmdsz;
 113         u8      nr_frags;
 114         u8      encrypt;        /* when 0 indicate no encrypt. when non-zero,
 115                                  * indicate the encrypt algorith
 116                                  */
 117         u8      iv_len;
 118         u8      icv_len;
 119         u8      iv[18];
 120         u8      icv[16];
 121         u8      priority;
 122         u8      ack_policy;
 123         u8      mac_id;
 124         u8      vcs_mode;       /* virtual carrier sense method */
 125         u8      dst[ETH_ALEN];
 126         u8      src[ETH_ALEN];
 127         u8      ta[ETH_ALEN];
 128         u8      ra[ETH_ALEN];
 129         u8      key_idx;
 130         u8      qos_en;
 131         u8      ht_en;
 132         u8      raid;/* rate adpative id */
 133         u8      bwmode;
 134         u8      ch_offset;/* PRIME_CHNL_OFFSET */
 135         u8      sgi;/* short GI */
 136         u8      ampdu_en;/* tx ampdu enable */
 137         u8      mdata;/* more data bit */
 138         u8      pctrl;/* per packet txdesc control enable */
 139         u8      triggered;/* for ap mode handling Power Saving sta */
 140         u8      qsel;
 141         u8      eosp;
 142         u8      rate;
 143         u8      intel_proxim;
 144         u8      retry_ctrl;
 145         struct sta_info *psta;
 146 };
 147 
 148 #define WLANHDR_OFFSET  64
 149 
 150 #define NULL_FRAMETAG           (0x0)
 151 #define DATA_FRAMETAG           0x01
 152 #define L2_FRAMETAG             0x02
 153 #define MGNT_FRAMETAG           0x03
 154 #define AMSDU_FRAMETAG  0x04
 155 
 156 #define EII_FRAMETAG            0x05
 157 #define IEEE8023_FRAMETAG  0x06
 158 
 159 #define MP_FRAMETAG             0x07
 160 
 161 #define TXAGG_FRAMETAG  0x08
 162 
 163 struct  submit_ctx {
 164         u32 submit_time; /* */
 165         u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */
 166         int status; /* status for operation */
 167         struct completion done;
 168 };
 169 
 170 enum {
 171         RTW_SCTX_SUBMITTED = -1,
 172         RTW_SCTX_DONE_SUCCESS = 0,
 173         RTW_SCTX_DONE_UNKNOWN,
 174         RTW_SCTX_DONE_TIMEOUT,
 175         RTW_SCTX_DONE_BUF_ALLOC,
 176         RTW_SCTX_DONE_BUF_FREE,
 177         RTW_SCTX_DONE_WRITE_PORT_ERR,
 178         RTW_SCTX_DONE_TX_DESC_NA,
 179         RTW_SCTX_DONE_TX_DENY,
 180         RTW_SCTX_DONE_CCX_PKT_FAIL,
 181         RTW_SCTX_DONE_DRV_STOP,
 182         RTW_SCTX_DONE_DEV_REMOVE,
 183 };
 184 
 185 void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms);
 186 int rtw_sctx_wait(struct submit_ctx *sctx);
 187 void rtw_sctx_done_err(struct submit_ctx **sctx, int status);
 188 
 189 struct xmit_buf {
 190         struct list_head list;
 191         struct adapter *padapter;
 192         u8 *pallocated_buf;
 193         u8 *pbuf;
 194         void *priv_data;
 195         u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
 196         u16 flags;
 197         u32 alloc_sz;
 198         u32  len;
 199         struct submit_ctx *sctx;
 200         u32     ff_hwaddr;
 201         struct urb *pxmit_urb[8];
 202         dma_addr_t dma_transfer_addr;   /* (in) dma addr for transfer_buffer */
 203         u8 bpending[8];
 204         int last[8];
 205 };
 206 
 207 struct xmit_frame {
 208         struct list_head list;
 209         struct pkt_attrib attrib;
 210         struct sk_buff *pkt;
 211         int     frame_tag;
 212         struct adapter *padapter;
 213         u8      *buf_addr;
 214         struct xmit_buf *pxmitbuf;
 215 
 216         u8      agg_num;
 217         s8      pkt_offset;
 218         u8 ack_report;
 219 };
 220 
 221 struct tx_servq {
 222         struct list_head tx_pending;
 223         struct __queue sta_pending;
 224         int qcnt;
 225 };
 226 
 227 struct sta_xmit_priv {
 228         spinlock_t lock;
 229         int     option;
 230         int     apsd_setting;   /* When bit mask is on, the associated edca
 231                                  * queue supports APSD.
 232                                  */
 233         struct tx_servq be_q;                   /* priority == 0,3 */
 234         struct tx_servq bk_q;                   /* priority == 1,2 */
 235         struct tx_servq vi_q;                   /* priority == 4,5 */
 236         struct tx_servq vo_q;                   /* priority == 6,7 */
 237         struct list_head legacy_dz;
 238         struct list_head apsd;
 239         u16 txseq_tid[16];
 240 };
 241 
 242 struct  hw_txqueue {
 243         volatile int    head;
 244         volatile int    tail;
 245         volatile int    free_sz;        /* in units of 64 bytes */
 246         volatile int      free_cmdsz;
 247         volatile int     txsz[8];
 248         uint    ff_hwaddr;
 249         uint    cmd_hwaddr;
 250         int     ac_tag;
 251 };
 252 
 253 struct  xmit_priv {
 254         spinlock_t lock;
 255         struct __queue be_pending;
 256         struct __queue bk_pending;
 257         struct __queue vi_pending;
 258         struct __queue vo_pending;
 259         struct __queue bm_pending;
 260         u8 *pallocated_frame_buf;
 261         u8 *pxmit_frame_buf;
 262         uint free_xmitframe_cnt;
 263         struct __queue free_xmit_queue;
 264         uint    frag_len;
 265         struct adapter  *adapter;
 266         u8   vcs_setting;
 267         u8      vcs;
 268         u8      vcs_type;
 269         u64     tx_bytes;
 270         u64     tx_pkts;
 271         u64     tx_drop;
 272         u64     last_tx_bytes;
 273         u64     last_tx_pkts;
 274         struct hw_xmit *hwxmits;
 275         u8      hwxmit_entry;
 276         u8      wmm_para_seq[4];/* sequence for wmm ac parameter strength
 277                                  * from large to small. it's value is 0->vo,
 278                                  * 1->vi, 2->be, 3->bk.
 279                                  */
 280         u8              txirp_cnt;/*  */
 281         struct tasklet_struct xmit_tasklet;
 282         /* per AC pending irp */
 283         int beq_cnt;
 284         int bkq_cnt;
 285         int viq_cnt;
 286         int voq_cnt;
 287         struct __queue free_xmitbuf_queue;
 288         struct __queue pending_xmitbuf_queue;
 289         u8 *pallocated_xmitbuf;
 290         u8 *pxmitbuf;
 291         uint free_xmitbuf_cnt;
 292         struct __queue free_xmit_extbuf_queue;
 293         u8 *pallocated_xmit_extbuf;
 294         u8 *pxmit_extbuf;
 295         uint free_xmit_extbuf_cnt;
 296         u16     nqos_ssn;
 297         int     ack_tx;
 298         struct mutex ack_tx_mutex;
 299         struct submit_ctx ack_tx_ops;
 300 };
 301 
 302 struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
 303 s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv,
 304                          struct xmit_buf *pxmitbuf);
 305 struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
 306 s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv,
 307                      struct xmit_buf *pxmitbuf);
 308 void rtw_count_tx_stats(struct adapter *padapter,
 309                         struct xmit_frame *pxmitframe, int sz);
 310 void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len);
 311 s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr,
 312                      struct pkt_attrib *pattrib);
 313 s32 rtw_put_snap(u8 *data, u16 h_proto);
 314 
 315 struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv);
 316 s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv,
 317                        struct xmit_frame *pxmitframe);
 318 void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
 319                               struct __queue *pframequeue);
 320 struct tx_servq *rtw_get_sta_pending(struct adapter *padapter,
 321                                      struct sta_info *psta, int up, u8 *ac);
 322 s32 rtw_xmitframe_enqueue(struct adapter *padapter,
 323                           struct xmit_frame *pxmitframe);
 324 struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv,
 325                                       struct hw_xmit *phwxmit_i, int entry);
 326 
 327 s32 rtw_xmit_classifier(struct adapter *padapter,
 328                         struct xmit_frame *pxmitframe);
 329 s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt,
 330                            struct xmit_frame *pxmitframe);
 331 s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
 332 void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
 333 s32 rtw_txframes_pending(struct adapter *padapter);
 334 s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
 335                                 struct pkt_attrib *pattrib);
 336 void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
 337 s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
 338 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
 339 s32 rtw_alloc_hwxmits(struct adapter *padapter);
 340 void rtw_free_hwxmits(struct adapter *padapter);
 341 s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
 342 
 343 #if defined(CONFIG_88EU_AP_MODE)
 344 int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
 345 void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
 346 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
 347 void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
 348 #endif
 349 
 350 u8      qos_acm(u8 acm_mask, u8 priority);
 351 u32     rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe);
 352 int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms);
 353 void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
 354 
 355 /* include after declaring struct xmit_buf, in order to avoid warning */
 356 #include <xmit_osdep.h>
 357 
 358 #endif  /* _RTL871X_XMIT_H_ */

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