Lines Matching +full:wait +full:- +full:state
2 * Copyright(c) 2017 - 2018 Intel Corporation.
24 * - Redistributions of source code must retain the above copyright
26 * - Redistributions in binary form must reproduce the above copyright
30 * - Neither the name of Intel Corporation nor the names of its
62 * struct vnic_txreq - VNIC transmit descriptor
84 struct hfi1_vnic_sdma *vnic_sdma = tx->sdma; in vnic_sdma_complete()
86 sdma_txclean(vnic_sdma->dd, txreq); in vnic_sdma_complete()
87 dev_kfree_skb_any(tx->skb); in vnic_sdma_complete()
88 kmem_cache_free(vnic_sdma->dd->vnic.txreq_cache, tx); in vnic_sdma_complete()
97 sde->dd, in build_vnic_ulp_payload()
98 &tx->txreq, in build_vnic_ulp_payload()
99 tx->skb->data, in build_vnic_ulp_payload()
100 skb_headlen(tx->skb)); in build_vnic_ulp_payload()
104 for (i = 0; i < skb_shinfo(tx->skb)->nr_frags; i++) { in build_vnic_ulp_payload()
105 skb_frag_t *frag = &skb_shinfo(tx->skb)->frags[i]; in build_vnic_ulp_payload()
108 ret = sdma_txadd_page(sde->dd, in build_vnic_ulp_payload()
109 &tx->txreq, in build_vnic_ulp_payload()
117 if (tx->plen) in build_vnic_ulp_payload()
118 ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, in build_vnic_ulp_payload()
119 tx->pad + HFI1_VNIC_MAX_PAD - tx->plen, in build_vnic_ulp_payload()
120 tx->plen); in build_vnic_ulp_payload()
134 &tx->txreq, in build_vnic_tx_desc()
136 hdrbytes + tx->skb->len + tx->plen, in build_vnic_tx_desc()
146 tx->pbc_val = cpu_to_le64(pbc); in build_vnic_tx_desc()
148 sde->dd, in build_vnic_tx_desc()
149 &tx->txreq, in build_vnic_tx_desc()
150 &tx->pbc_val, in build_vnic_tx_desc()
164 pad[HFI1_VNIC_MAX_PAD - 1] = plen - OPA_VNIC_ICRC_TAIL_LEN; in hfi1_vnic_update_pad()
171 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_send_dma()
172 struct sdma_engine *sde = vnic_sdma->sde; in hfi1_vnic_send_dma()
174 int ret = -ECOMM; in hfi1_vnic_send_dma()
176 if (unlikely(READ_ONCE(vnic_sdma->state) != HFI1_VNIC_SDMA_Q_ACTIVE)) in hfi1_vnic_send_dma()
182 tx = kmem_cache_alloc(dd->vnic.txreq_cache, GFP_ATOMIC); in hfi1_vnic_send_dma()
184 ret = -ENOMEM; in hfi1_vnic_send_dma()
188 tx->sdma = vnic_sdma; in hfi1_vnic_send_dma()
189 tx->skb = skb; in hfi1_vnic_send_dma()
190 hfi1_vnic_update_pad(tx->pad, plen); in hfi1_vnic_send_dma()
191 tx->plen = plen; in hfi1_vnic_send_dma()
196 ret = sdma_send_txreq(sde, iowait_get_ib_work(&vnic_sdma->wait), in hfi1_vnic_send_dma()
197 &tx->txreq, vnic_sdma->pkts_sent); in hfi1_vnic_send_dma()
198 /* When -ECOMM, sdma callback will be called with ABORT status */ in hfi1_vnic_send_dma()
199 if (unlikely(ret && unlikely(ret != -ECOMM))) in hfi1_vnic_send_dma()
203 vnic_sdma->pkts_sent = true; in hfi1_vnic_send_dma()
204 iowait_starve_clear(vnic_sdma->pkts_sent, &vnic_sdma->wait); in hfi1_vnic_send_dma()
209 sdma_txclean(dd, &tx->txreq); in hfi1_vnic_send_dma()
210 kmem_cache_free(dd->vnic.txreq_cache, tx); in hfi1_vnic_send_dma()
212 if (ret != -EBUSY) in hfi1_vnic_send_dma()
215 vnic_sdma->pkts_sent = false; in hfi1_vnic_send_dma()
220 * hfi1_vnic_sdma_sleep - vnic sdma sleep function
223 * sdma descriptors available to send the packet. It adds Tx queue's wait
228 struct iowait_work *wait, in hfi1_vnic_sdma_sleep() argument
234 container_of(wait->iow, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_sleep()
236 write_seqlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
238 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
239 return -EAGAIN; in hfi1_vnic_sdma_sleep()
242 vnic_sdma->state = HFI1_VNIC_SDMA_Q_DEFERRED; in hfi1_vnic_sdma_sleep()
243 if (list_empty(&vnic_sdma->wait.list)) { in hfi1_vnic_sdma_sleep()
244 iowait_get_priority(wait->iow); in hfi1_vnic_sdma_sleep()
245 iowait_queue(pkts_sent, wait->iow, &sde->dmawait); in hfi1_vnic_sdma_sleep()
247 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
248 return -EBUSY; in hfi1_vnic_sdma_sleep()
252 * hfi1_vnic_sdma_wakeup - vnic sdma wakeup function
255 * queue's wait structure was previously added to sdma engine's dmawait list.
258 static void hfi1_vnic_sdma_wakeup(struct iowait *wait, int reason) in hfi1_vnic_sdma_wakeup() argument
261 container_of(wait, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_wakeup()
262 struct hfi1_vnic_vport_info *vinfo = vnic_sdma->vinfo; in hfi1_vnic_sdma_wakeup()
264 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_wakeup()
265 if (__netif_subqueue_stopped(vinfo->netdev, vnic_sdma->q_idx)) in hfi1_vnic_sdma_wakeup()
266 netif_wake_subqueue(vinfo->netdev, vnic_sdma->q_idx); in hfi1_vnic_sdma_wakeup()
272 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_sdma_write_avail()
274 return (READ_ONCE(vnic_sdma->state) == HFI1_VNIC_SDMA_Q_ACTIVE); in hfi1_vnic_sdma_write_avail()
281 for (i = 0; i < vinfo->num_tx_q; i++) { in hfi1_vnic_sdma_init()
282 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[i]; in hfi1_vnic_sdma_init()
284 iowait_init(&vnic_sdma->wait, 0, NULL, NULL, in hfi1_vnic_sdma_init()
287 vnic_sdma->sde = &vinfo->dd->per_sdma[i]; in hfi1_vnic_sdma_init()
288 vnic_sdma->dd = vinfo->dd; in hfi1_vnic_sdma_init()
289 vnic_sdma->vinfo = vinfo; in hfi1_vnic_sdma_init()
290 vnic_sdma->q_idx = i; in hfi1_vnic_sdma_init()
291 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_init()
294 if (vnic_sdma->sde->descq_cnt > HFI1_VNIC_SDMA_DESC_WTRMRK) { in hfi1_vnic_sdma_init()
297 INIT_LIST_HEAD(&vnic_sdma->stx.list); in hfi1_vnic_sdma_init()
298 vnic_sdma->stx.num_desc = HFI1_VNIC_SDMA_DESC_WTRMRK; in hfi1_vnic_sdma_init()
299 work = iowait_get_ib_work(&vnic_sdma->wait); in hfi1_vnic_sdma_init()
300 list_add_tail(&vnic_sdma->stx.list, &work->tx_head); in hfi1_vnic_sdma_init()
309 snprintf(buf, sizeof(buf), "hfi1_%u_vnic_txreq_cache", dd->unit); in hfi1_vnic_txreq_init()
310 dd->vnic.txreq_cache = kmem_cache_create(buf, in hfi1_vnic_txreq_init()
314 if (!dd->vnic.txreq_cache) in hfi1_vnic_txreq_init()
315 return -ENOMEM; in hfi1_vnic_txreq_init()
321 kmem_cache_destroy(dd->vnic.txreq_cache); in hfi1_vnic_txreq_deinit()
322 dd->vnic.txreq_cache = NULL; in hfi1_vnic_txreq_deinit()