diff options
author | Quytelda Kahja <quytelda@tamalin.org> | 2018-03-27 04:41:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-29 05:59:29 -0400 |
commit | 9ff7c1aadd1a061bd360d831415eb15438361842 (patch) | |
tree | 658ca5eaa31820ed199a64dce576f8c48092c752 | |
parent | e39c83fe8a5382e7402bf7602f1637fafd060228 (diff) |
staging: rtl8723bs: Factor out rtl8723bs_recv_tasklet() sections.
Factor out code from rtl8723bs_recv_tasklet() into helper methods
to unindent lines over 80 characters.
Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 95 |
1 files changed, 69 insertions, 26 deletions
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index c4851a825fbb..038481655858 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | |||
@@ -189,6 +189,55 @@ static void rtl8723bs_c2h_packet_handler(struct adapter *padapter, | |||
189 | return; | 189 | return; |
190 | } | 190 | } |
191 | 191 | ||
192 | static inline union recv_frame *try_alloc_recvframe(struct recv_priv *precvpriv, | ||
193 | struct recv_buf *precvbuf) | ||
194 | { | ||
195 | union recv_frame *precvframe; | ||
196 | |||
197 | precvframe = rtw_alloc_recvframe(&precvpriv->free_recv_queue); | ||
198 | if (!precvframe) { | ||
199 | DBG_8192C("%s: no enough recv frame!\n", __func__); | ||
200 | rtw_enqueue_recvbuf_to_head(precvbuf, | ||
201 | &precvpriv->recv_buf_pending_queue); | ||
202 | |||
203 | /* The case of can't allocte recvframe should be temporary, */ | ||
204 | /* schedule again and hope recvframe is available next time. */ | ||
205 | tasklet_schedule(&precvpriv->recv_tasklet); | ||
206 | } | ||
207 | |||
208 | return precvframe; | ||
209 | } | ||
210 | |||
211 | static inline bool rx_crc_err(struct recv_priv *precvpriv, | ||
212 | struct hal_com_data *p_hal_data, | ||
213 | struct rx_pkt_attrib *pattrib, | ||
214 | union recv_frame *precvframe) | ||
215 | { | ||
216 | /* fix Hardware RX data error, drop whole recv_buffer */ | ||
217 | if ((!(p_hal_data->ReceiveConfig & RCR_ACRC32)) && pattrib->crc_err) { | ||
218 | DBG_8192C("%s()-%d: RX Warning! rx CRC ERROR !!\n", | ||
219 | __func__, __LINE__); | ||
220 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | ||
221 | return true; | ||
222 | } | ||
223 | |||
224 | return false; | ||
225 | } | ||
226 | |||
227 | static inline bool pkt_exceeds_tail(struct recv_priv *precvpriv, | ||
228 | u8 *end, u8 *tail, | ||
229 | union recv_frame *precvframe) | ||
230 | { | ||
231 | if (end > tail) { | ||
232 | DBG_8192C("%s()-%d: : next pkt len(%p,%d) exceed ptail(%p)!\n", | ||
233 | __func__, __LINE__, ptr, pkt_offset, precvbuf->ptail); | ||
234 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | ||
235 | return true; | ||
236 | } | ||
237 | |||
238 | return false; | ||
239 | } | ||
240 | |||
192 | static void rtl8723bs_recv_tasklet(void *priv) | 241 | static void rtl8723bs_recv_tasklet(void *priv) |
193 | { | 242 | { |
194 | struct adapter *padapter; | 243 | struct adapter *padapter; |
@@ -197,6 +246,7 @@ static void rtl8723bs_recv_tasklet(void *priv) | |||
197 | struct recv_buf *precvbuf; | 246 | struct recv_buf *precvbuf; |
198 | union recv_frame *precvframe; | 247 | union recv_frame *precvframe; |
199 | struct rx_pkt_attrib *pattrib; | 248 | struct rx_pkt_attrib *pattrib; |
249 | struct __queue *recv_buf_queue; | ||
200 | u8 *ptr; | 250 | u8 *ptr; |
201 | u32 pkt_offset, skb_len, alloc_sz; | 251 | u32 pkt_offset, skb_len, alloc_sz; |
202 | _pkt *pkt_copy = NULL; | 252 | _pkt *pkt_copy = NULL; |
@@ -205,52 +255,45 @@ static void rtl8723bs_recv_tasklet(void *priv) | |||
205 | padapter = priv; | 255 | padapter = priv; |
206 | p_hal_data = GET_HAL_DATA(padapter); | 256 | p_hal_data = GET_HAL_DATA(padapter); |
207 | precvpriv = &padapter->recvpriv; | 257 | precvpriv = &padapter->recvpriv; |
258 | recv_buf_queue = &precvpriv->recv_buf_pending_queue; | ||
208 | 259 | ||
209 | do { | 260 | do { |
210 | precvbuf = rtw_dequeue_recvbuf(&precvpriv->recv_buf_pending_queue); | 261 | precvbuf = rtw_dequeue_recvbuf(recv_buf_queue); |
211 | if (NULL == precvbuf) | 262 | if (NULL == precvbuf) |
212 | break; | 263 | break; |
213 | 264 | ||
214 | ptr = precvbuf->pdata; | 265 | ptr = precvbuf->pdata; |
215 | 266 | ||
216 | while (ptr < precvbuf->ptail) { | 267 | while (ptr < precvbuf->ptail) { |
217 | precvframe = rtw_alloc_recvframe(&precvpriv->free_recv_queue); | 268 | precvframe = try_alloc_recvframe(precvpriv, precvbuf); |
218 | if (precvframe == NULL) { | 269 | if(!precvframe) |
219 | DBG_8192C("%s: no enough recv frame!\n", __func__); | ||
220 | rtw_enqueue_recvbuf_to_head(precvbuf, &precvpriv->recv_buf_pending_queue); | ||
221 | |||
222 | /* The case of can't allocte recvframe should be temporary, */ | ||
223 | /* schedule again and hope recvframe is available next time. */ | ||
224 | tasklet_schedule(&precvpriv->recv_tasklet); | ||
225 | return; | 270 | return; |
226 | } | ||
227 | 271 | ||
228 | /* rx desc parsing */ | 272 | /* rx desc parsing */ |
229 | update_recvframe_attrib(padapter, precvframe, (struct recv_stat *)ptr); | 273 | update_recvframe_attrib(padapter, precvframe, |
274 | (struct recv_stat *)ptr); | ||
230 | 275 | ||
231 | pattrib = &precvframe->u.hdr.attrib; | 276 | pattrib = &precvframe->u.hdr.attrib; |
232 | 277 | ||
233 | /* fix Hardware RX data error, drop whole recv_buffer */ | 278 | if(rx_crc_err(precvpriv, p_hal_data, |
234 | if ((!(p_hal_data->ReceiveConfig & RCR_ACRC32)) && pattrib->crc_err) { | 279 | pattrib, precvframe)) |
235 | DBG_8192C("%s()-%d: RX Warning! rx CRC ERROR !!\n", __func__, __LINE__); | ||
236 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | ||
237 | break; | 280 | break; |
238 | } | ||
239 | 281 | ||
240 | rx_report_sz = RXDESC_SIZE + pattrib->drvinfo_sz; | 282 | rx_report_sz = RXDESC_SIZE + pattrib->drvinfo_sz; |
241 | pkt_offset = rx_report_sz + pattrib->shift_sz + pattrib->pkt_len; | 283 | pkt_offset = rx_report_sz + |
284 | pattrib->shift_sz + | ||
285 | pattrib->pkt_len; | ||
242 | 286 | ||
243 | if ((ptr + pkt_offset) > precvbuf->ptail) { | 287 | if(pkt_exceeds_tail(precvpriv, ptr + pkt_offset, |
244 | DBG_8192C("%s()-%d: : next pkt len(%p,%d) exceed ptail(%p)!\n", __func__, __LINE__, ptr, pkt_offset, precvbuf->ptail); | 288 | precvbuf->ptail, precvframe)) |
245 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | ||
246 | break; | 289 | break; |
247 | } | ||
248 | 290 | ||
249 | if ((pattrib->crc_err) || (pattrib->icv_err)) { | 291 | if ((pattrib->crc_err) || (pattrib->icv_err)) { |
250 | { | 292 | DBG_8192C("%s: crc_err =%d icv_err =%d, skip!\n", |
251 | DBG_8192C("%s: crc_err =%d icv_err =%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); | 293 | __func__, pattrib->crc_err, |
252 | } | 294 | pattrib->icv_err); |
253 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | 295 | rtw_free_recvframe(precvframe, |
296 | &precvpriv->free_recv_queue); | ||
254 | } else { | 297 | } else { |
255 | /* Modified by Albert 20101213 */ | 298 | /* Modified by Albert 20101213 */ |
256 | /* For 8 bytes IP header alignment. */ | 299 | /* For 8 bytes IP header alignment. */ |
@@ -301,7 +344,7 @@ static void rtl8723bs_recv_tasklet(void *priv) | |||
301 | skb_reset_tail_pointer(pkt_clone); | 344 | skb_reset_tail_pointer(pkt_clone); |
302 | precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail | 345 | precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail |
303 | = pkt_clone->data; | 346 | = pkt_clone->data; |
304 | precvframe->u.hdr.rx_end = pkt_clone->data + skb_len; | 347 | precvframe->u.hdr.rx_end = pkt_clone->data + skb_len; |
305 | } else { | 348 | } else { |
306 | DBG_8192C("%s: rtw_skb_clone fail\n", __func__); | 349 | DBG_8192C("%s: rtw_skb_clone fail\n", __func__); |
307 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); | 350 | rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); |