1 /** @file mlan_sdio.h
2  *
3  *  @brief This file contains definitions for SDIO interface.
4  *
5  *  Copyright 2008-2024 NXP
6  *
7  *  SPDX-License-Identifier: BSD-3-Clause
8  *
9  */
10 /****************************************************
11 Change log:
12 ****************************************************/
13 
14 #ifndef _MLAN_SDIO_H
15 #define _MLAN_SDIO_H
16 
17 #include "mlan_sdio_defs.h"
18 
19 /** Event header Len*/
20 #define MLAN_EVENT_HEADER_LEN 8
21 
22 /** SDIO byte mode size */
23 #define MAX_BYTE_MODE_SIZE 512
24 
25 /** The base address for packet with multiple ports aggregation */
26 #define SDIO_MPA_ADDR_BASE 0x1000U
27 
28 #ifdef SDIO_MULTI_PORT_TX_AGGR
29 
30 /** SDIO Tx aggregation in progress ? */
31 #define MP_TX_AGGR_IN_PROGRESS(a) (a->mpa_tx.pkt_cnt > 0)
32 
33 /** SDIO Tx aggregation buffer room for next packet ? */
34 #define MP_TX_AGGR_BUF_HAS_ROOM(a, mbuf, len) ((a->mpa_tx.buf_len + len) <= a->mpa_tx.buf_size)
35 
36 /** Copy current packet (SDIO Tx aggregation buffer) to SDIO buffer */
37 #define MP_TX_AGGR_BUF_PUT(a, mbuf, port)                                                     \
38     do                                                                                        \
39     {                                                                                         \
40         pmadapter->callbacks.moal_memmove(a->pmoal_handle, &a->mpa_tx.buf[a->mpa_tx.buf_len], \
41                                           mbuf->pbuf + mbuf->data_offset, mbuf->data_len);    \
42         a->mpa_tx.buf_len += mbuf->data_len;                                                  \
43         if (!a->mpa_tx.pkt_cnt)                                                               \
44         {                                                                                     \
45             a->mpa_tx.start_port = port;                                                      \
46         }                                                                                     \
47         if (a->mpa_tx.start_port <= port)                                                     \
48         {                                                                                     \
49             a->mpa_tx.ports |= (1 << (a->mpa_tx.pkt_cnt));                                    \
50         }                                                                                     \
51         else                                                                                  \
52         {                                                                                     \
53             a->mpa_tx.ports |= (1 << (a->mpa_tx.pkt_cnt + 1 + (MAX_PORT - a->mp_end_port)));  \
54         }                                                                                     \
55         a->mpa_tx.pkt_cnt++;                                                                  \
56     } while (0);
57 
58 /** SDIO Tx aggregation limit ? */
59 #define MP_TX_AGGR_PKT_LIMIT_REACHED(a) (a->mpa_tx.pkt_cnt == a->mpa_tx.pkt_aggr_limit)
60 
61 /** SDIO Tx aggregation port limit ? */
62 #define MP_TX_AGGR_PORT_LIMIT_REACHED(a)         \
63     ((a->curr_wr_port < a->mpa_tx.start_port) && \
64      (((MAX_PORT - a->mpa_tx.start_port) + a->curr_wr_port) >= SDIO_MP_AGGR_DEF_PKT_LIMIT))
65 
66 /** Reset SDIO Tx aggregation buffer parameters */
67 #define MP_TX_AGGR_BUF_RESET(a)   \
68     do                            \
69     {                             \
70         a->mpa_tx.pkt_cnt    = 0; \
71         a->mpa_tx.buf_len    = 0; \
72         a->mpa_tx.ports      = 0; \
73         a->mpa_tx.start_port = 0; \
74     } while (0);
75 
76 #endif /* SDIO_MULTI_PORT_TX_AGGR */
77 
78 #ifdef SDIO_MULTI_PORT_RX_AGGR_FOR_REF
79 
80 /** SDIO Rx aggregation limit ? */
81 #define MP_RX_AGGR_PKT_LIMIT_REACHED(a) (a->mpa_rx.pkt_cnt == a->mpa_rx.pkt_aggr_limit)
82 
83 /** SDIO Rx aggregation port limit ? */
84 #define MP_RX_AGGR_PORT_LIMIT_REACHED(a)         \
85     ((a->curr_rd_port < a->mpa_rx.start_port) && \
86      (((MAX_PORT - a->mpa_rx.start_port) + a->curr_rd_port) >= SDIO_MP_AGGR_DEF_PKT_LIMIT))
87 
88 /** SDIO Rx aggregation in progress ? */
89 #define MP_RX_AGGR_IN_PROGRESS(a) (a->mpa_rx.pkt_cnt > 0)
90 
91 /** SDIO Rx aggregation buffer room for next packet ? */
92 #define MP_RX_AGGR_BUF_HAS_ROOM(a, rx_len) ((a->mpa_rx.buf_len + rx_len) <= a->mpa_rx.buf_size)
93 
94 /** Prepare to copy current packet from card to SDIO Rx aggregation buffer */
95 #define MP_RX_AGGR_SETUP(a, mbuf, port, rx_len)                \
96     do                                                         \
97     {                                                          \
98         a->mpa_rx.buf_len += rx_len;                           \
99         if (!a->mpa_rx.pkt_cnt)                                \
100         {                                                      \
101             a->mpa_rx.start_port = port;                       \
102         }                                                      \
103         if (a->mpa_rx.start_port <= port)                      \
104         {                                                      \
105             a->mpa_rx.ports |= (1 << (a->mpa_rx.pkt_cnt));     \
106         }                                                      \
107         else                                                   \
108         {                                                      \
109             a->mpa_rx.ports |= (1 << (a->mpa_rx.pkt_cnt + 1)); \
110         }                                                      \
111         a->mpa_rx.mbuf_arr[a->mpa_rx.pkt_cnt] = mbuf;          \
112         a->mpa_rx.len_arr[a->mpa_rx.pkt_cnt]  = rx_len;        \
113         a->mpa_rx.pkt_cnt++;                                   \
114     } while (0);
115 
116 /** Reset SDIO Rx aggregation buffer parameters */
117 #define MP_RX_AGGR_BUF_RESET(a)   \
118     do                            \
119     {                             \
120         a->mpa_rx.pkt_cnt    = 0; \
121         a->mpa_rx.buf_len    = 0; \
122         a->mpa_rx.ports      = 0; \
123         a->mpa_rx.start_port = 0; \
124     } while (0);
125 
126 #endif /* SDIO_MULTI_PORT_RX_AGGR */
127 
128 /** Read interrupt status */
129 t_void wlan_interrupt(mlan_adapter *pmadapter);
130 /** Process Interrupt Status */
131 /* wmsdk */
132 /* mlan_status wlan_process_int_status(mlan_adapter * pmadapter); */
133 
134 #if CONFIG_WIFI_IND_DNLD
135 mlan_status wlan_reset_fw(pmlan_adapter pmadapter);
136 #endif
137 #endif /* _MLAN_SDIO_H */
138