Lines Matching refs:iwm

101 static bool iwm_tx_credit_ok(struct iwm_priv *iwm, int id, int nb)  in iwm_tx_credit_ok()  argument
105 if (npages <= iwm_tx_credit_get(&iwm->tx_credit, id)) in iwm_tx_credit_ok()
108 set_bit(id, &iwm->tx_credit.full_pools_map); in iwm_tx_credit_ok()
110 IWM_DBG_TX(iwm, DBG, "LINK: stop txq[%d], available credit: %d\n", in iwm_tx_credit_ok()
112 iwm_tx_credit_get(&iwm->tx_credit, id)); in iwm_tx_credit_ok()
117 void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages) in iwm_tx_credit_inc() argument
126 pool = &iwm->tx_credit.pools[id]; in iwm_tx_credit_inc()
127 spool = &iwm->tx_credit.spools[pool->sid]; in iwm_tx_credit_inc()
130 IWM_DBG_TX(iwm, DBG, "Free %d pages for pool[%d]\n", freed_pages, id); in iwm_tx_credit_inc()
133 IWM_DBG_TX(iwm, DBG, "No pages are freed by UMAC\n"); in iwm_tx_credit_inc()
147 IWM_DBG_TX(iwm, DBG, "Pool[%d] pages alloc: %d, total_freed: %d, " in iwm_tx_credit_inc()
151 if (test_bit(id, &iwm->tx_credit.full_pools_map) && in iwm_tx_credit_inc()
153 clear_bit(id, &iwm->tx_credit.full_pools_map); in iwm_tx_credit_inc()
157 IWM_DBG_TX(iwm, DBG, "LINK: start txq[%d], available " in iwm_tx_credit_inc()
159 iwm_tx_credit_get(&iwm->tx_credit, id)); in iwm_tx_credit_inc()
160 queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker); in iwm_tx_credit_inc()
164 static void iwm_tx_credit_dec(struct iwm_priv *iwm, int id, int alloc_pages) in iwm_tx_credit_dec() argument
170 IWM_DBG_TX(iwm, DBG, "Allocate %d pages for pool[%d]\n", in iwm_tx_credit_dec()
175 pool = &iwm->tx_credit.pools[id]; in iwm_tx_credit_dec()
176 spool = &iwm->tx_credit.spools[pool->sid]; in iwm_tx_credit_dec()
187 IWM_DBG_TX(iwm, DBG, "Pool[%d] pages alloc: %d, total_freed: %d, " in iwm_tx_credit_dec()
192 int iwm_tx_credit_alloc(struct iwm_priv *iwm, int id, int nb) in iwm_tx_credit_alloc() argument
197 spin_lock(&iwm->tx_credit.lock); in iwm_tx_credit_alloc()
199 if (!iwm_tx_credit_ok(iwm, id, nb)) { in iwm_tx_credit_alloc()
200 IWM_DBG_TX(iwm, DBG, "No credit available for pool[%d]\n", id); in iwm_tx_credit_alloc()
205 iwm_tx_credit_dec(iwm, id, npages); in iwm_tx_credit_alloc()
208 spin_unlock(&iwm->tx_credit.lock); in iwm_tx_credit_alloc()
248 void iwm_tx_credit_init_pools(struct iwm_priv *iwm, in iwm_tx_credit_init_pools() argument
253 spin_lock(&iwm->tx_credit.lock); in iwm_tx_credit_init_pools()
255 iwm->tx_credit.pool_nr = le16_to_cpu(alive->page_grp_count); in iwm_tx_credit_init_pools()
256 iwm->tx_credit.full_pools_map = 0; in iwm_tx_credit_init_pools()
257 memset(&iwm->tx_credit.spools[0], 0, sizeof(struct spool_entry)); in iwm_tx_credit_init_pools()
259 IWM_DBG_TX(iwm, DBG, "Pools number is %d\n", iwm->tx_credit.pool_nr); in iwm_tx_credit_init_pools()
261 for (i = 0; i < iwm->tx_credit.pool_nr; i++) { in iwm_tx_credit_init_pools()
264 iwm->tx_credit.pools[i].id = GET_VAL32(page_grp_state, in iwm_tx_credit_init_pools()
266 iwm->tx_credit.pools[i].sid = GET_VAL32(page_grp_state, in iwm_tx_credit_init_pools()
268 iwm->tx_credit.pools[i].min_pages = GET_VAL32(page_grp_state, in iwm_tx_credit_init_pools()
270 iwm->tx_credit.pools[i].max_pages = GET_VAL32(page_grp_state, in iwm_tx_credit_init_pools()
272 iwm->tx_credit.pools[i].alloc_pages = 0; in iwm_tx_credit_init_pools()
273 iwm->tx_credit.pools[i].total_freed_pages = 0; in iwm_tx_credit_init_pools()
275 sid = iwm->tx_credit.pools[i].sid; in iwm_tx_credit_init_pools()
276 pool_pages = iwm->tx_credit.pools[i].min_pages; in iwm_tx_credit_init_pools()
278 if (iwm->tx_credit.spools[sid].max_pages == 0) { in iwm_tx_credit_init_pools()
279 iwm->tx_credit.spools[sid].id = sid; in iwm_tx_credit_init_pools()
280 iwm->tx_credit.spools[sid].max_pages = in iwm_tx_credit_init_pools()
283 iwm->tx_credit.spools[sid].alloc_pages = 0; in iwm_tx_credit_init_pools()
286 iwm->tx_credit.spools[sid].alloc_pages += pool_pages; in iwm_tx_credit_init_pools()
288 IWM_DBG_TX(iwm, DBG, "Pool idx: %d, id: %d, sid: %d, capacity " in iwm_tx_credit_init_pools()
291 i, iwm->tx_credit.pools[i].id, in iwm_tx_credit_init_pools()
292 iwm->tx_credit.pools[i].sid, in iwm_tx_credit_init_pools()
293 iwm->tx_credit.pools[i].min_pages, in iwm_tx_credit_init_pools()
294 iwm->tx_credit.pools[i].max_pages, in iwm_tx_credit_init_pools()
295 iwm->tx_credit.pools[i].alloc_pages, in iwm_tx_credit_init_pools()
296 iwm->tx_credit.pools[i].total_freed_pages, in iwm_tx_credit_init_pools()
297 iwm->tx_credit.spools[sid].alloc_pages); in iwm_tx_credit_init_pools()
300 spin_unlock(&iwm->tx_credit.lock); in iwm_tx_credit_init_pools()
305 static __le16 iwm_tx_build_packet(struct iwm_priv *iwm, struct sk_buff *skb, in iwm_tx_build_packet() argument
326 umac_cmd.seq_num = cpu_to_le16(iwm_alloc_wifi_cmd_seq(iwm)); in iwm_tx_build_packet()
328 iwm_build_udma_wifi_hdr(iwm, &hdr->hw_hdr, &udma_cmd); in iwm_tx_build_packet()
329 iwm_build_umac_hdr(iwm, &hdr->sw_hdr, &umac_cmd); in iwm_tx_build_packet()
336 static int iwm_tx_send_concat_packets(struct iwm_priv *iwm, in iwm_tx_send_concat_packets() argument
344 IWM_DBG_TX(iwm, DBG, "Send concatenated Tx: queue %d, %d bytes\n", in iwm_tx_send_concat_packets()
348 iwm_udma_wifi_hdr_set_eop(iwm, txq->concat_ptr, 1); in iwm_tx_send_concat_packets()
350 trace_iwm_tx_packets(iwm, txq->concat_buf, txq->concat_count); in iwm_tx_send_concat_packets()
351 ret = iwm_bus_send_chunk(iwm, txq->concat_buf, txq->concat_count); in iwm_tx_send_concat_packets()
361 struct iwm_priv *iwm; in iwm_tx_worker() local
370 iwm = container_of(txq, struct iwm_priv, txq[txq->id]); in iwm_tx_worker()
374 while (!test_bit(pool_id, &iwm->tx_credit.full_pools_map) && in iwm_tx_worker()
382 sta_info = &iwm->sta_table[tx_info->sta]; in iwm_tx_worker()
384 IWM_ERR(iwm, "Trying to send a frame to unknown STA\n"); in iwm_tx_worker()
401 IWM_DBG_TX(iwm, DBG, "%dx%d stopped\n", in iwm_tx_worker()
413 IWM_DBG_TX(iwm, DBG, "Tx frame on queue %d: skb: 0x%p, sta: " in iwm_tx_worker()
418 iwm_tx_send_concat_packets(iwm, txq); in iwm_tx_worker()
420 ret = iwm_tx_credit_alloc(iwm, pool_id, cmdlen); in iwm_tx_worker()
422 IWM_DBG_TX(iwm, DBG, "not enough tx_credit for queue " in iwm_tx_worker()
434 iwm_tx_build_packet(iwm, skb, pool_id, txq->concat_ptr); in iwm_tx_worker()
442 iwm_tx_send_concat_packets(iwm, txq); in iwm_tx_worker()
444 if (__netif_subqueue_stopped(iwm_to_ndev(iwm), txq->id) && in iwm_tx_worker()
445 !test_bit(pool_id, &iwm->tx_credit.full_pools_map) && in iwm_tx_worker()
447 IWM_DBG_TX(iwm, DBG, "LINK: start netif_subqueue[%d]", txq->id); in iwm_tx_worker()
448 netif_wake_subqueue(iwm_to_ndev(iwm), txq->id); in iwm_tx_worker()
454 struct iwm_priv *iwm = ndev_to_iwm(netdev); in iwm_xmit_frame() local
455 struct wireless_dev *wdev = iwm_to_wdev(iwm); in iwm_xmit_frame()
464 if (!test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)) { in iwm_xmit_frame()
465 IWM_DBG_TX(iwm, DBG, "LINK: stop netif_all_queues: " in iwm_xmit_frame()
474 txq = &iwm->txq[queue]; in iwm_xmit_frame()
479 IWM_DBG_TX(iwm, DBG, "LINK: stop netif_subqueue[%d]\n", queue); in iwm_xmit_frame()
485 iwm->bssid, 0); in iwm_xmit_frame()
487 IWM_ERR(iwm, "build wifi header failed\n"); in iwm_xmit_frame()
494 sta_info = &iwm->sta_table[sta_id]; in iwm_xmit_frame()
501 IWM_ERR(iwm, "STA %pM not found in sta_table, Tx ignored\n", in iwm_xmit_frame()
515 spin_lock_bh(&iwm->txq[queue].lock); in iwm_xmit_frame()
516 skb_queue_tail(&iwm->txq[queue].queue, skb); in iwm_xmit_frame()
517 spin_unlock_bh(&iwm->txq[queue].lock); in iwm_xmit_frame()
519 queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker); in iwm_xmit_frame()