Lines Matching +full:pa +full:- +full:stats

1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
32 dma_addr_t pa = wil_tx_desc_get_addr_edma(&d->dma); in wil_tx_desc_unmap_edma() local
33 u16 dmalen = le16_to_cpu(d->dma.length); in wil_tx_desc_unmap_edma()
35 switch (ctx->mapped_as) { in wil_tx_desc_unmap_edma()
37 dma_unmap_single(dev, pa, dmalen, DMA_TO_DEVICE); in wil_tx_desc_unmap_edma()
40 dma_unmap_page(dev, pa, dmalen, DMA_TO_DEVICE); in wil_tx_desc_unmap_edma()
52 if (!wil->srings[i].va) in wil_find_free_sring()
56 return -EINVAL; in wil_find_free_sring()
65 if (!sring || !sring->va) in wil_sring_free()
68 sz = sring->elem_size * sring->size; in wil_sring_free()
71 sz, sring->va, &sring->pa); in wil_sring_free()
73 dma_free_coherent(dev, sz, (void *)sring->va, sring->pa); in wil_sring_free()
74 sring->pa = 0; in wil_sring_free()
75 sring->va = NULL; in wil_sring_free()
82 size_t sz = sring->elem_size * sring->size; in wil_sring_alloc()
88 return -EINVAL; in wil_sring_alloc()
91 sring->swhead = 0; in wil_sring_alloc()
96 sring->va = dma_alloc_coherent(dev, sz, &sring->pa, GFP_KERNEL); in wil_sring_alloc()
97 if (!sring->va) in wil_sring_alloc()
98 return -ENOMEM; in wil_sring_alloc()
100 wil_dbg_misc(wil, "status_ring[%d] 0x%p:%pad\n", sring->size, sring->va, in wil_sring_alloc()
101 &sring->pa); in wil_sring_alloc()
113 if (wil->tx_status_ring_order < WIL_SRING_SIZE_ORDER_MIN || in wil_tx_init_edma()
114 wil->tx_status_ring_order > WIL_SRING_SIZE_ORDER_MAX) in wil_tx_init_edma()
115 wil->tx_status_ring_order = WIL_TX_SRING_SIZE_ORDER_DEFAULT; in wil_tx_init_edma()
117 status_ring_size = 1 << wil->tx_status_ring_order; in wil_tx_init_edma()
128 sring = &wil->srings[ring_id]; in wil_tx_init_edma()
130 sring->is_rx = false; in wil_tx_init_edma()
131 sring->size = status_ring_size; in wil_tx_init_edma()
132 sring->elem_size = sizeof(struct wil_ring_tx_status); in wil_tx_init_edma()
141 sring->desc_rdy_pol = 1; in wil_tx_init_edma()
142 wil->tx_sring_idx = ring_id; in wil_tx_init_edma()
155 unsigned int sz = wil->rx_buf_len; in wil_ring_alloc_skb_edma()
156 dma_addr_t pa; in wil_ring_alloc_skb_edma() local
158 struct list_head *active = &wil->rx_buff_mgmt.active; in wil_ring_alloc_skb_edma()
159 struct list_head *free = &wil->rx_buff_mgmt.free; in wil_ring_alloc_skb_edma()
161 struct wil_rx_buff *buff_arr = wil->rx_buff_mgmt.buff_arr; in wil_ring_alloc_skb_edma()
165 &ring->va[i].rx.enhanced; in wil_ring_alloc_skb_edma()
168 wil->rx_buff_mgmt.free_list_empty_cnt++; in wil_ring_alloc_skb_edma()
169 return -EAGAIN; in wil_ring_alloc_skb_edma()
174 return -ENOMEM; in wil_ring_alloc_skb_edma()
182 skb->ip_summed = CHECKSUM_NONE; in wil_ring_alloc_skb_edma()
184 pa = dma_map_single(dev, skb->data, skb->len, DMA_FROM_DEVICE); in wil_ring_alloc_skb_edma()
185 if (unlikely(dma_mapping_error(dev, pa))) { in wil_ring_alloc_skb_edma()
187 return -ENOMEM; in wil_ring_alloc_skb_edma()
190 /* Get the buffer ID - the index of the rx buffer in the buff_arr */ in wil_ring_alloc_skb_edma()
192 buff_id = rx_buff->id; in wil_ring_alloc_skb_edma()
195 list_move(&rx_buff->list, active); in wil_ring_alloc_skb_edma()
199 wil_desc_set_addr_edma(&d->dma.addr, &d->dma.addr_high_high, pa); in wil_ring_alloc_skb_edma()
200 d->dma.length = cpu_to_le16(sz); in wil_ring_alloc_skb_edma()
201 d->mac.buff_id = cpu_to_le16(buff_id); in wil_ring_alloc_skb_edma()
204 /* Save the physical address in skb->cb for later use in dma_unmap */ in wil_ring_alloc_skb_edma()
205 memcpy(skb->cb, &pa, sizeof(pa)); in wil_ring_alloc_skb_edma()
217 (sring->va + (sring->elem_size * sring->swhead)); in wil_get_next_rx_status_msg()
218 *dr_bit = WIL_GET_BITS(_msg->d0, 31, 31); in wil_get_next_rx_status_msg()
221 memcpy(msg, (void *)_msg, sring->elem_size); in wil_get_next_rx_status_msg()
226 sring->swhead = (sring->swhead + 1) % sring->size; in wil_sring_advance_swhead()
227 if (sring->swhead == 0) in wil_sring_advance_swhead()
228 sring->desc_rdy_pol = 1 - sring->desc_rdy_pol; in wil_sring_advance_swhead()
233 struct wil_ring *ring = &wil->ring_rx; in wil_rx_refill_edma()
236 ring->swtail = *ring->edma_rx_swtail.va; in wil_rx_refill_edma()
239 (next_head != ring->swtail); in wil_rx_refill_edma()
240 ring->swhead = next_head) { in wil_rx_refill_edma()
241 rc = wil_ring_alloc_skb_edma(wil, ring, ring->swhead); in wil_rx_refill_edma()
243 if (rc == -EAGAIN) in wil_rx_refill_edma()
248 rc, ring->swhead); in wil_rx_refill_edma()
258 wil_w(wil, ring->hwtail, ring->swhead); in wil_rx_refill_edma()
267 struct list_head *active = &wil->rx_buff_mgmt.active; in wil_move_all_rx_buff_to_free_list()
268 dma_addr_t pa; in wil_move_all_rx_buff_to_free_list() local
270 if (!wil->rx_buff_mgmt.buff_arr) in wil_move_all_rx_buff_to_free_list()
276 struct sk_buff *skb = rx_buff->skb; in wil_move_all_rx_buff_to_free_list()
279 wil_err(wil, "No Rx skb at buff_id %d\n", rx_buff->id); in wil_move_all_rx_buff_to_free_list()
281 rx_buff->skb = NULL; in wil_move_all_rx_buff_to_free_list()
282 memcpy(&pa, skb->cb, sizeof(pa)); in wil_move_all_rx_buff_to_free_list()
283 dma_unmap_single(dev, pa, wil->rx_buf_len, in wil_move_all_rx_buff_to_free_list()
289 list_move(&rx_buff->list, &wil->rx_buff_mgmt.free); in wil_move_all_rx_buff_to_free_list()
295 struct wil_ring *ring = &wil->ring_rx; in wil_free_rx_buff_arr()
297 if (!wil->rx_buff_mgmt.buff_arr) in wil_free_rx_buff_arr()
305 kfree(wil->rx_buff_mgmt.buff_arr); in wil_free_rx_buff_arr()
306 wil->rx_buff_mgmt.buff_arr = NULL; in wil_free_rx_buff_arr()
313 struct list_head *active = &wil->rx_buff_mgmt.active; in wil_init_rx_buff_arr()
314 struct list_head *free = &wil->rx_buff_mgmt.free; in wil_init_rx_buff_arr()
317 wil->rx_buff_mgmt.buff_arr = kcalloc(size + 1, in wil_init_rx_buff_arr()
320 if (!wil->rx_buff_mgmt.buff_arr) in wil_init_rx_buff_arr()
321 return -ENOMEM; in wil_init_rx_buff_arr()
330 buff_arr = wil->rx_buff_mgmt.buff_arr; in wil_init_rx_buff_arr()
336 wil->rx_buff_mgmt.size = size + 1; in wil_init_rx_buff_arr()
346 struct wil_status_ring *sring = &wil->srings[ring_id]; in wil_init_rx_sring()
352 memset(&sring->rx_data, 0, sizeof(sring->rx_data)); in wil_init_rx_sring()
354 sring->is_rx = true; in wil_init_rx_sring()
355 sring->size = status_ring_size; in wil_init_rx_sring()
356 sring->elem_size = elem_size; in wil_init_rx_sring()
365 sring->desc_rdy_pol = 1; in wil_init_rx_sring()
377 size_t sz = ring->size * sizeof(ring->va[0]); in wil_ring_alloc_desc_ring()
381 BUILD_BUG_ON(sizeof(ring->va[0]) != 32); in wil_ring_alloc_desc_ring()
383 ring->swhead = 0; in wil_ring_alloc_desc_ring()
384 ring->swtail = 0; in wil_ring_alloc_desc_ring()
385 ring->ctx = kcalloc(ring->size, sizeof(ring->ctx[0]), GFP_KERNEL); in wil_ring_alloc_desc_ring()
386 if (!ring->ctx) in wil_ring_alloc_desc_ring()
389 ring->va = dma_alloc_coherent(dev, sz, &ring->pa, GFP_KERNEL); in wil_ring_alloc_desc_ring()
390 if (!ring->va) in wil_ring_alloc_desc_ring()
393 if (ring->is_rx) { in wil_ring_alloc_desc_ring()
394 sz = sizeof(*ring->edma_rx_swtail.va); in wil_ring_alloc_desc_ring()
395 ring->edma_rx_swtail.va = in wil_ring_alloc_desc_ring()
396 dma_alloc_coherent(dev, sz, &ring->edma_rx_swtail.pa, in wil_ring_alloc_desc_ring()
398 if (!ring->edma_rx_swtail.va) in wil_ring_alloc_desc_ring()
403 ring->is_rx ? "RX" : "TX", in wil_ring_alloc_desc_ring()
404 ring->size, ring->va, &ring->pa, ring->ctx); in wil_ring_alloc_desc_ring()
408 dma_free_coherent(dev, ring->size * sizeof(ring->va[0]), in wil_ring_alloc_desc_ring()
409 (void *)ring->va, ring->pa); in wil_ring_alloc_desc_ring()
410 ring->va = NULL; in wil_ring_alloc_desc_ring()
412 kfree(ring->ctx); in wil_ring_alloc_desc_ring()
413 ring->ctx = NULL; in wil_ring_alloc_desc_ring()
415 return -ENOMEM; in wil_ring_alloc_desc_ring()
424 if (!ring->va) in wil_ring_free_edma()
427 sz = ring->size * sizeof(ring->va[0]); in wil_ring_free_edma()
429 lockdep_assert_held(&wil->mutex); in wil_ring_free_edma()
430 if (ring->is_rx) { in wil_ring_free_edma()
432 ring->size, ring->va, in wil_ring_free_edma()
433 &ring->pa, ring->ctx); in wil_ring_free_edma()
436 dma_free_coherent(dev, sizeof(*ring->edma_rx_swtail.va), in wil_ring_free_edma()
437 ring->edma_rx_swtail.va, in wil_ring_free_edma()
438 ring->edma_rx_swtail.pa); in wil_ring_free_edma()
443 ring_index = ring - wil->ring_tx; in wil_ring_free_edma()
446 ring_index, ring->size, ring->va, in wil_ring_free_edma()
447 &ring->pa, ring->ctx); in wil_ring_free_edma()
455 &ring->va[ring->swtail].tx.enhanced; in wil_ring_free_edma()
457 ctx = &ring->ctx[ring->swtail]; in wil_ring_free_edma()
461 ring->swtail); in wil_ring_free_edma()
462 ring->swtail = wil_ring_next_tail(ring); in wil_ring_free_edma()
467 if (ctx->skb) in wil_ring_free_edma()
468 dev_kfree_skb_any(ctx->skb); in wil_ring_free_edma()
469 ring->swtail = wil_ring_next_tail(ring); in wil_ring_free_edma()
473 dma_free_coherent(dev, sz, (void *)ring->va, ring->pa); in wil_ring_free_edma()
474 kfree(ring->ctx); in wil_ring_free_edma()
475 ring->pa = 0; in wil_ring_free_edma()
476 ring->va = NULL; in wil_ring_free_edma()
477 ring->ctx = NULL; in wil_ring_free_edma()
483 struct wil_ring *ring = &wil->ring_rx; in wil_init_rx_desc_ring()
488 ring->size = desc_ring_size; in wil_init_rx_desc_ring()
489 ring->is_rx = true; in wil_init_rx_desc_ring()
539 if (wil->use_rx_hw_reordering) in wil_rx_crypto_check_edma()
548 s = &wil->sta[cid]; in wil_rx_crypto_check_edma()
549 c = mc ? &s->group_crypto_rx : &s->tid_crypto_rx[tid]; in wil_rx_crypto_check_edma()
550 cc = &c->key_id[key_id]; in wil_rx_crypto_check_edma()
551 pn = (u8 *)&st->ext.pn; in wil_rx_crypto_check_edma()
553 if (!cc->key_set) { in wil_rx_crypto_check_edma()
557 return -EINVAL; in wil_rx_crypto_check_edma()
560 if (reverse_memcmp(pn, cc->pn, IEEE80211_GCMP_PN_LEN) <= 0) { in wil_rx_crypto_check_edma()
563 cid, tid, mc, key_id, pn, cc->pn); in wil_rx_crypto_check_edma()
564 return -EINVAL; in wil_rx_crypto_check_edma()
566 memcpy(cc->pn, pn, IEEE80211_GCMP_PN_LEN); in wil_rx_crypto_check_edma()
579 for (i = 0; i < wil->num_rx_status_rings; i++) { in wil_is_rx_idle_edma()
580 sring = &wil->srings[i]; in wil_is_rx_idle_edma()
581 if (!sring->va) in wil_is_rx_idle_edma()
587 if (dr_bit == sring->desc_rdy_pol) in wil_is_rx_idle_edma()
597 wil->rx_buf_len = rx_large_buf ? in wil_rx_buf_len_init_edma()
604 struct wil_ring *ring = &wil->ring_rx; in wil_rx_init_edma()
606 size_t elem_size = wil->use_compressed_rx_status ? in wil_rx_init_edma()
612 if (wil->use_compressed_rx_status && !wil->use_rx_hw_reordering) { in wil_rx_init_edma()
615 return -EINVAL; in wil_rx_init_edma()
617 if (wil->rx_status_ring_order <= desc_ring_order) in wil_rx_init_edma()
619 wil->rx_status_ring_order = desc_ring_order + 1; in wil_rx_init_edma()
620 if (wil->rx_buff_id_count <= desc_ring_size) in wil_rx_init_edma()
622 wil->rx_buff_id_count = desc_ring_size + 512; in wil_rx_init_edma()
623 if (wil->rx_status_ring_order < WIL_SRING_SIZE_ORDER_MIN || in wil_rx_init_edma()
624 wil->rx_status_ring_order > WIL_SRING_SIZE_ORDER_MAX) in wil_rx_init_edma()
625 wil->rx_status_ring_order = WIL_RX_SRING_SIZE_ORDER_DEFAULT; in wil_rx_init_edma()
627 status_ring_size = 1 << wil->rx_status_ring_order; in wil_rx_init_edma()
636 if (wil->num_rx_status_rings > WIL6210_MAX_STATUS_RINGS - 1) in wil_rx_init_edma()
637 wil->num_rx_status_rings = WIL6210_MAX_STATUS_RINGS - 1; in wil_rx_init_edma()
640 wil->num_rx_status_rings); in wil_rx_init_edma()
642 rc = wil_wmi_cfg_def_rx_offload(wil, wil->rx_buf_len); in wil_rx_init_edma()
647 for (i = 0; i < wil->num_rx_status_rings; i++) { in wil_rx_init_edma()
651 rc = -EFAULT; in wil_rx_init_edma()
666 if (wil->rx_buff_id_count >= status_ring_size) { in wil_rx_init_edma()
669 wil->rx_buff_id_count, status_ring_size, in wil_rx_init_edma()
670 status_ring_size - 1); in wil_rx_init_edma()
671 wil->rx_buff_id_count = status_ring_size - 1; in wil_rx_init_edma()
675 rc = wil_init_rx_buff_arr(wil, wil->rx_buff_id_count); in wil_rx_init_edma()
690 for (i = 0; i < wil->num_rx_status_rings; i++) in wil_rx_init_edma()
691 wil_sring_free(wil, &wil->srings[i]); in wil_rx_init_edma()
701 struct wil_ring *ring = &wil->ring_tx[ring_id]; in wil_ring_init_tx_edma()
702 struct wil_ring_tx_data *txdata = &wil->ring_tx_data[ring_id]; in wil_ring_init_tx_edma()
704 lockdep_assert_held(&wil->mutex); in wil_ring_init_tx_edma()
708 ring_id, cid, tid, wil->tx_sring_idx); in wil_ring_init_tx_edma()
711 ring->size = size; in wil_ring_init_tx_edma()
716 wil->ring2cid_tid[ring_id][0] = cid; in wil_ring_init_tx_edma()
717 wil->ring2cid_tid[ring_id][1] = tid; in wil_ring_init_tx_edma()
718 if (!vif->privacy) in wil_ring_init_tx_edma()
719 txdata->dot1x_open = true; in wil_ring_init_tx_edma()
727 if (txdata->dot1x_open && agg_wsize >= 0) in wil_ring_init_tx_edma()
732 spin_lock_bh(&txdata->lock); in wil_ring_init_tx_edma()
733 txdata->dot1x_open = false; in wil_ring_init_tx_edma()
734 txdata->enabled = 0; in wil_ring_init_tx_edma()
735 spin_unlock_bh(&txdata->lock); in wil_ring_init_tx_edma()
737 wil->ring2cid_tid[ring_id][0] = wil->max_assoc_sta; in wil_ring_init_tx_edma()
738 wil->ring2cid_tid[ring_id][1] = 0; in wil_ring_init_tx_edma()
751 return -EOPNOTSUPP; in wil_tx_ring_modify_edma()
756 struct sk_buff *skb, struct wil_net_stats *stats) in wil_check_bar() argument
773 vif = wil->vifs[mid]; in wil_check_bar()
777 return -EAGAIN; in wil_check_bar()
781 "Non-data frame FC[7:0] 0x%02x MID %d CID %d TID %d Seq 0x%03x\n", in wil_check_bar()
783 if (stats) in wil_check_bar()
784 stats->rx_non_data_frame++; in wil_check_bar()
791 u32 sz = wil->use_compressed_rx_status ? in wil_check_bar()
799 "Unhandled non-data frame FC[7:0] 0x%02x MID %d CID %d TID %d Seq 0x%03x\n", in wil_check_bar()
804 skb->data, skb_headlen(skb), false); in wil_check_bar()
807 return -EAGAIN; in wil_check_bar()
812 struct wil_net_stats *stats) in wil_rx_error_check_edma() argument
825 stats->rx_mic_error++; in wil_rx_error_check_edma()
830 stats->rx_key_error++; in wil_rx_error_check_edma()
835 stats->rx_replay++; in wil_rx_error_check_edma()
840 stats->rx_amsdu_error++; in wil_rx_error_check_edma()
842 return -EFAULT; in wil_rx_error_check_edma()
845 skb->ip_summed = wil_rx_status_get_checksum(msg, stats); in wil_rx_error_check_edma()
858 dma_addr_t pa; in wil_sring_reap_rx_edma() local
859 struct wil_ring_rx_data *rxdata = &sring->rx_data; in wil_sring_reap_rx_edma()
860 unsigned int sz = wil->rx_buf_len; in wil_sring_reap_rx_edma()
861 struct wil_net_stats *stats = NULL; in wil_sring_reap_rx_edma() local
869 u16 sring_idx = sring - wil->srings; in wil_sring_reap_rx_edma()
872 BUILD_BUG_ON(sizeof(struct wil_rx_status_extended) > sizeof(skb->cb)); in wil_sring_reap_rx_edma()
878 if (dr_bit != sring->desc_rdy_pol) in wil_sring_reap_rx_edma()
890 sring->swhead); in wil_sring_reap_rx_edma()
896 (sring->va + (sring->elem_size * sring->swhead)); in wil_sring_reap_rx_edma()
901 if (unlikely(!wil_val_in_range(buff_id, 1, wil->rx_buff_mgmt.size))) { in wil_sring_reap_rx_edma()
902 wil_err(wil, "Corrupt buff_id=%d, sring->swhead=%d\n", in wil_sring_reap_rx_edma()
903 buff_id, sring->swhead); in wil_sring_reap_rx_edma()
905 msg, wil->use_compressed_rx_status ? in wil_sring_reap_rx_edma()
911 sring->invalid_buff_id_cnt++; in wil_sring_reap_rx_edma()
916 skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; in wil_sring_reap_rx_edma()
917 wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL; in wil_sring_reap_rx_edma()
922 list_move_tail(&wil->rx_buff_mgmt.buff_arr[buff_id].list, in wil_sring_reap_rx_edma()
923 &wil->rx_buff_mgmt.free); in wil_sring_reap_rx_edma()
925 sring->invalid_buff_id_cnt++; in wil_sring_reap_rx_edma()
932 memcpy(&pa, skb->cb, sizeof(pa)); in wil_sring_reap_rx_edma()
933 dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE); in wil_sring_reap_rx_edma()
936 trace_wil6210_rx_status(wil, wil->use_compressed_rx_status, buff_id, in wil_sring_reap_rx_edma()
941 (const void *)msg, wil->use_compressed_rx_status ? in wil_sring_reap_rx_edma()
946 list_move_tail(&wil->rx_buff_mgmt.buff_arr[buff_id].list, in wil_sring_reap_rx_edma()
947 &wil->rx_buff_mgmt.free); in wil_sring_reap_rx_edma()
952 if (unlikely(!wil_val_in_range(cid, 0, wil->max_assoc_sta))) { in wil_sring_reap_rx_edma()
953 wil_err(wil, "Corrupt cid=%d, sring->swhead=%d\n", in wil_sring_reap_rx_edma()
954 cid, sring->swhead); in wil_sring_reap_rx_edma()
955 rxdata->skipping = true; in wil_sring_reap_rx_edma()
958 stats = &wil->sta[cid].stats; in wil_sring_reap_rx_edma()
962 stats->rx_short_frame++; in wil_sring_reap_rx_edma()
963 rxdata->skipping = true; in wil_sring_reap_rx_edma()
970 msg, wil->use_compressed_rx_status ? in wil_sring_reap_rx_edma()
974 stats->rx_large_frame++; in wil_sring_reap_rx_edma()
975 rxdata->skipping = true; in wil_sring_reap_rx_edma()
987 if (unlikely(rxdata->skipping)) { in wil_sring_reap_rx_edma()
989 if (rxdata->skb) { in wil_sring_reap_rx_edma()
990 kfree_skb(rxdata->skb); in wil_sring_reap_rx_edma()
991 rxdata->skb = NULL; in wil_sring_reap_rx_edma()
993 rxdata->skipping = !eop; in wil_sring_reap_rx_edma()
999 prefetch(skb->data); in wil_sring_reap_rx_edma()
1001 if (!rxdata->skb) { in wil_sring_reap_rx_edma()
1002 rxdata->skb = skb; in wil_sring_reap_rx_edma()
1004 if (likely(skb_try_coalesce(rxdata->skb, skb, &headstolen, in wil_sring_reap_rx_edma()
1010 kfree_skb(rxdata->skb); in wil_sring_reap_rx_edma()
1011 rxdata->skb = NULL; in wil_sring_reap_rx_edma()
1012 rxdata->skipping = !eop; in wil_sring_reap_rx_edma()
1020 /* reaching here rxdata->skb always contains a full packet */ in wil_sring_reap_rx_edma()
1021 skb = rxdata->skb; in wil_sring_reap_rx_edma()
1022 rxdata->skb = NULL; in wil_sring_reap_rx_edma()
1023 rxdata->skipping = false; in wil_sring_reap_rx_edma()
1025 if (stats) { in wil_sring_reap_rx_edma()
1026 stats->last_mcs_rx = wil_rx_status_get_mcs(msg); in wil_sring_reap_rx_edma()
1027 if (stats->last_mcs_rx < ARRAY_SIZE(stats->rx_per_mcs)) in wil_sring_reap_rx_edma()
1028 stats->rx_per_mcs[stats->last_mcs_rx]++; in wil_sring_reap_rx_edma()
1029 else if (stats->last_mcs_rx == WIL_EXTENDED_MCS_26) in wil_sring_reap_rx_edma()
1030 stats->rx_per_mcs[WIL_BASE_MCS_FOR_EXTENDED_26]++; in wil_sring_reap_rx_edma()
1032 stats->last_cb_mode_rx = wil_rx_status_get_cb_mode(msg); in wil_sring_reap_rx_edma()
1035 if (!wil->use_rx_hw_reordering && !wil->use_compressed_rx_status && in wil_sring_reap_rx_edma()
1036 wil_check_bar(wil, msg, cid, skb, stats) == -EAGAIN) { in wil_sring_reap_rx_edma()
1055 skb->data, skb_headlen(skb), false); in wil_sring_reap_rx_edma()
1057 /* Has to be done after dma_unmap_single as skb->cb is also in wil_sring_reap_rx_edma()
1058 * used for holding the pa in wil_sring_reap_rx_edma()
1061 memcpy(s, msg, sring->elem_size); in wil_sring_reap_rx_edma()
1069 struct wil_ring *ring = &wil->ring_rx; in wil_rx_handle_edma()
1074 if (unlikely(!ring->va)) { in wil_rx_handle_edma()
1080 for (i = 0; i < wil->num_rx_status_rings; i++) { in wil_rx_handle_edma()
1081 sring = &wil->srings[i]; in wil_rx_handle_edma()
1082 if (unlikely(!sring->va)) { in wil_rx_handle_edma()
1092 (*quota)--; in wil_rx_handle_edma()
1093 if (wil->use_rx_hw_reordering) { in wil_rx_handle_edma()
1096 struct wil6210_vif *vif = wil->vifs[mid]; in wil_rx_handle_edma()
1112 wil_w(wil, sring->hwtail, (sring->swhead - 1) % sring->size); in wil_rx_handle_edma()
1119 dma_addr_t pa, in wil_tx_desc_map_edma() argument
1124 (struct wil_tx_enhanced_desc *)&desc->enhanced; in wil_tx_desc_map_edma()
1128 wil_desc_set_addr_edma(&d->dma.addr, &d->dma.addr_high_high, pa); in wil_tx_desc_map_edma()
1130 /* 0..6: mac_length; 7:ip_version 0-IP6 1-IP4*/ in wil_tx_desc_map_edma()
1131 d->dma.length = cpu_to_le16((u16)len); in wil_tx_desc_map_edma()
1132 d->mac.d[0] = (ring_index << WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS); in wil_tx_desc_map_edma()
1133 /* translation type: 0 - bypass; 1 - 802.3; 2 - native wifi; in wil_tx_desc_map_edma()
1134 * 3 - eth mode in wil_tx_desc_map_edma()
1136 d->mac.d[2] = BIT(MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_POS) | in wil_tx_desc_map_edma()
1147 (sring->va + (sring->elem_size * sring->swhead)); in wil_get_next_tx_status_msg()
1149 *dr_bit = _msg->desc_ready >> TX_STATUS_DESC_READY_POS; in wil_get_next_tx_status_msg()
1168 struct wil_net_stats *stats; in wil_tx_sring_handler() local
1182 while (dr_bit == sring->desc_rdy_pol) { in wil_tx_sring_handler()
1196 ring = &wil->ring_tx[ring_id]; in wil_tx_sring_handler()
1197 if (unlikely(!ring->va)) { in wil_tx_sring_handler()
1202 txdata = &wil->ring_tx_data[ring_id]; in wil_tx_sring_handler()
1203 if (unlikely(!txdata->enabled)) { in wil_tx_sring_handler()
1207 vif = wil->vifs[txdata->mid]; in wil_tx_sring_handler()
1210 txdata->mid, ring_id); in wil_tx_sring_handler()
1216 cid = wil->ring2cid_tid[ring_id][0]; in wil_tx_sring_handler()
1217 stats = (cid < wil->max_assoc_sta) ? &wil->sta[cid].stats : in wil_tx_sring_handler()
1227 struct wil_ctx *ctx = &ring->ctx[ring->swtail]; in wil_tx_sring_handler()
1230 struct sk_buff *skb = ctx->skb; in wil_tx_sring_handler()
1233 &ring->va[ring->swtail].tx.enhanced; in wil_tx_sring_handler()
1236 dmalen = le16_to_cpu(d->dma.length); in wil_tx_sring_handler()
1237 trace_wil6210_tx_status(&msg, ring->swtail, dmalen); in wil_tx_sring_handler()
1240 ring_id, ring->swtail, dmalen, in wil_tx_sring_handler()
1252 ndev->stats.tx_packets++; in wil_tx_sring_handler()
1253 ndev->stats.tx_bytes += skb->len; in wil_tx_sring_handler()
1254 if (stats) { in wil_tx_sring_handler()
1255 stats->tx_packets++; in wil_tx_sring_handler()
1256 stats->tx_bytes += skb->len; in wil_tx_sring_handler()
1259 &wil->sta[cid]); in wil_tx_sring_handler()
1262 ndev->stats.tx_errors++; in wil_tx_sring_handler()
1263 if (stats) in wil_tx_sring_handler()
1264 stats->tx_errors++; in wil_tx_sring_handler()
1267 if (skb->protocol == cpu_to_be16(ETH_P_PAE)) in wil_tx_sring_handler()
1280 ring->swtail = wil_ring_next_tail(ring); in wil_tx_sring_handler()
1287 if (wil_val_in_range(wil->ring_idle_trsh, in wil_tx_sring_handler()
1289 wil_dbg_txrx(wil, "Ring[%2d] idle %d -> %d\n", in wil_tx_sring_handler()
1291 txdata->last_idle = get_cycles(); in wil_tx_sring_handler()
1298 wil_w(wil, sring->hwtail, sring->swhead); in wil_tx_sring_handler()
1311 wil_w(wil, sring->hwtail, (sring->swhead - 1) % sring->size); in wil_tx_sring_handler()
1318 * @tso_desc_type is a descriptor type for TSO: 0 - a header, 1 - first data,
1319 * 2 - middle, 3 - last descriptor.
1328 d->mac.d[2] |= 1; in wil_tx_desc_offload_setup_tso_edma()
1330 d->mac.tso_mss |= cpu_to_le16(mss >> 2); in wil_tx_desc_offload_setup_tso_edma()
1332 d->dma.l4_hdr_len |= tcp_hdr_len & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK; in wil_tx_desc_offload_setup_tso_edma()
1336 d->dma.cmd |= BIT(WIL_EDMA_DESC_TX_CFG_EOP_POS) | in wil_tx_desc_offload_setup_tso_edma()
1341 /* Calculate pseudo-header */ in wil_tx_desc_offload_setup_tso_edma()
1342 d->dma.w1 |= BIT(WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_POS) | in wil_tx_desc_offload_setup_tso_edma()
1345 d->dma.ip_length |= skb_net_hdr_len; in wil_tx_desc_offload_setup_tso_edma()
1347 d->dma.b11 |= ETH_HLEN | in wil_tx_desc_offload_setup_tso_edma()
1360 &ring->va[i].tx.enhanced; in wil_tx_tso_gen_desc()
1362 int ring_index = ring - wil->ring_tx; in wil_tx_tso_gen_desc()
1363 dma_addr_t pa; in wil_tx_tso_gen_desc() local
1369 pa = dma_map_single(dev, buff_addr, len, DMA_TO_DEVICE); in wil_tx_tso_gen_desc()
1370 ring->ctx[i].mapped_as = wil_mapped_as_single; in wil_tx_tso_gen_desc()
1372 pa = skb_frag_dma_map(dev, frag, 0, len, DMA_TO_DEVICE); in wil_tx_tso_gen_desc()
1373 ring->ctx[i].mapped_as = wil_mapped_as_page; in wil_tx_tso_gen_desc()
1375 if (unlikely(dma_mapping_error(dev, pa))) { in wil_tx_tso_gen_desc()
1377 return -EINVAL; in wil_tx_tso_gen_desc()
1380 wil->txrx_ops.tx_desc_map((union wil_tx_desc *)d, pa, in wil_tx_tso_gen_desc()
1391 ring->ctx[i].skb = skb_get(skb); in wil_tx_tso_gen_desc()
1407 int ring_index = ring - wil->ring_tx; in __wil_tx_ring_tso_edma()
1408 struct wil_ring_tx_data *txdata = &wil->ring_tx_data[ring_index]; in __wil_tx_ring_tso_edma()
1409 int nr_frags = skb_shinfo(skb)->nr_frags; in __wil_tx_ring_tso_edma()
1415 u32 swhead = ring->swhead; in __wil_tx_ring_tso_edma()
1417 int rc = -EINVAL; in __wil_tx_ring_tso_edma()
1420 int mss = skb_shinfo(skb)->gso_size; in __wil_tx_ring_tso_edma()
1422 wil_dbg_txrx(wil, "tx_ring_tso: %d bytes to ring %d\n", skb->len, in __wil_tx_ring_tso_edma()
1425 if (unlikely(!txdata->enabled)) in __wil_tx_ring_tso_edma()
1426 return -EINVAL; in __wil_tx_ring_tso_edma()
1432 return -ENOMEM; in __wil_tx_ring_tso_edma()
1435 gso_type = skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV6 | SKB_GSO_TCPV4); in __wil_tx_ring_tso_edma()
1444 return -EINVAL; in __wil_tx_ring_tso_edma()
1447 if (skb->ip_summed != CHECKSUM_PARTIAL) in __wil_tx_ring_tso_edma()
1448 return -EINVAL; in __wil_tx_ring_tso_edma()
1451 * packet's descriptors - read them once here in __wil_tx_ring_tso_edma()
1462 rc = wil_tx_tso_gen_desc(wil, skb->data, hdrlen, swhead, in __wil_tx_ring_tso_edma()
1467 return -EINVAL; in __wil_tx_ring_tso_edma()
1470 headlen = skb_headlen(skb) - hdrlen; in __wil_tx_ring_tso_edma()
1472 rc = wil_tx_tso_gen_desc(wil, skb->data + hdrlen, headlen, in __wil_tx_ring_tso_edma()
1473 (swhead + descs_used) % ring->size, in __wil_tx_ring_tso_edma()
1483 skb_frag_t *frag = &skb_shinfo(skb)->frags[f]; in __wil_tx_ring_tso_edma()
1490 (swhead + descs_used) % ring->size, in __wil_tx_ring_tso_edma()
1491 (f != nr_frags - 1) ? in __wil_tx_ring_tso_edma()
1502 if (wil_val_in_range(wil->ring_idle_trsh, in __wil_tx_ring_tso_edma()
1504 txdata->idle += get_cycles() - txdata->last_idle; in __wil_tx_ring_tso_edma()
1505 wil_dbg_txrx(wil, "Ring[%2d] not idle %d -> %d\n", in __wil_tx_ring_tso_edma()
1511 wil_dbg_txrx(wil, "TSO: Tx swhead %d -> %d\n", swhead, ring->swhead); in __wil_tx_ring_tso_edma()
1518 if (wil->tx_latency) in __wil_tx_ring_tso_edma()
1519 *(ktime_t *)&skb->cb = ktime_get(); in __wil_tx_ring_tso_edma()
1521 memset(skb->cb, 0, sizeof(ktime_t)); in __wil_tx_ring_tso_edma()
1523 wil_w(wil, ring->hwtail, ring->swhead); in __wil_tx_ring_tso_edma()
1531 int i = (swhead + descs_used - 1) % ring->size; in __wil_tx_ring_tso_edma()
1535 &ring->va[i].tx.enhanced; in __wil_tx_ring_tso_edma()
1538 ctx = &ring->ctx[i]; in __wil_tx_ring_tso_edma()
1541 descs_used--; in __wil_tx_ring_tso_edma()
1550 struct wil_ring *ring = &wil->ring_tx[ring_id]; in wil_ring_init_bcast_edma()
1552 struct wil_ring_tx_data *txdata = &wil->ring_tx_data[ring_id]; in wil_ring_init_bcast_edma()
1555 ring_id, wil->tx_sring_idx); in wil_ring_init_bcast_edma()
1557 lockdep_assert_held(&wil->mutex); in wil_ring_init_bcast_edma()
1560 ring->size = size; in wil_ring_init_bcast_edma()
1561 ring->is_rx = false; in wil_ring_init_bcast_edma()
1566 wil->ring2cid_tid[ring_id][0] = WIL6210_MAX_CID; /* CID */ in wil_ring_init_bcast_edma()
1567 wil->ring2cid_tid[ring_id][1] = 0; /* TID */ in wil_ring_init_bcast_edma()
1568 if (!vif->privacy) in wil_ring_init_bcast_edma()
1569 txdata->dot1x_open = true; in wil_ring_init_bcast_edma()
1578 spin_lock_bh(&txdata->lock); in wil_ring_init_bcast_edma()
1579 txdata->enabled = 0; in wil_ring_init_bcast_edma()
1580 txdata->dot1x_open = false; in wil_ring_init_bcast_edma()
1581 spin_unlock_bh(&txdata->lock); in wil_ring_init_bcast_edma()
1590 struct wil_status_ring *sring = &wil->srings[wil->tx_sring_idx]; in wil_tx_fini_edma()
1602 kfree_skb(sring->rx_data.skb); in wil_rx_data_free()
1603 sring->rx_data.skb = NULL; in wil_rx_data_free()
1608 struct wil_ring *ring = &wil->ring_rx; in wil_rx_fini_edma()
1615 for (i = 0; i < wil->num_rx_status_rings; i++) { in wil_rx_fini_edma()
1616 wil_rx_data_free(&wil->srings[i]); in wil_rx_fini_edma()
1617 wil_sring_free(wil, &wil->srings[i]); in wil_rx_fini_edma()
1625 wil->txrx_ops.configure_interrupt_moderation = in wil_init_txrx_ops_edma()
1628 wil->txrx_ops.ring_init_tx = wil_ring_init_tx_edma; in wil_init_txrx_ops_edma()
1629 wil->txrx_ops.ring_fini_tx = wil_ring_free_edma; in wil_init_txrx_ops_edma()
1630 wil->txrx_ops.ring_init_bcast = wil_ring_init_bcast_edma; in wil_init_txrx_ops_edma()
1631 wil->txrx_ops.tx_init = wil_tx_init_edma; in wil_init_txrx_ops_edma()
1632 wil->txrx_ops.tx_fini = wil_tx_fini_edma; in wil_init_txrx_ops_edma()
1633 wil->txrx_ops.tx_desc_map = wil_tx_desc_map_edma; in wil_init_txrx_ops_edma()
1634 wil->txrx_ops.tx_desc_unmap = wil_tx_desc_unmap_edma; in wil_init_txrx_ops_edma()
1635 wil->txrx_ops.tx_ring_tso = __wil_tx_ring_tso_edma; in wil_init_txrx_ops_edma()
1636 wil->txrx_ops.tx_ring_modify = wil_tx_ring_modify_edma; in wil_init_txrx_ops_edma()
1638 wil->txrx_ops.rx_init = wil_rx_init_edma; in wil_init_txrx_ops_edma()
1639 wil->txrx_ops.wmi_addba_rx_resp = wmi_addba_rx_resp_edma; in wil_init_txrx_ops_edma()
1640 wil->txrx_ops.get_reorder_params = wil_get_reorder_params_edma; in wil_init_txrx_ops_edma()
1641 wil->txrx_ops.get_netif_rx_params = wil_get_netif_rx_params_edma; in wil_init_txrx_ops_edma()
1642 wil->txrx_ops.rx_crypto_check = wil_rx_crypto_check_edma; in wil_init_txrx_ops_edma()
1643 wil->txrx_ops.rx_error_check = wil_rx_error_check_edma; in wil_init_txrx_ops_edma()
1644 wil->txrx_ops.is_rx_idle = wil_is_rx_idle_edma; in wil_init_txrx_ops_edma()
1645 wil->txrx_ops.rx_fini = wil_rx_fini_edma; in wil_init_txrx_ops_edma()