Lines Matching +full:wait +full:- +full:state
1 // SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
3 * Copyright(c) 2017 - 2018 Intel Corporation.
20 * struct vnic_txreq - VNIC transmit descriptor
42 struct hfi1_vnic_sdma *vnic_sdma = tx->sdma; in vnic_sdma_complete()
44 sdma_txclean(vnic_sdma->dd, txreq); in vnic_sdma_complete()
45 dev_kfree_skb_any(tx->skb); in vnic_sdma_complete()
46 kmem_cache_free(vnic_sdma->dd->vnic.txreq_cache, tx); in vnic_sdma_complete()
55 sde->dd, in build_vnic_ulp_payload()
56 &tx->txreq, in build_vnic_ulp_payload()
57 tx->skb->data, in build_vnic_ulp_payload()
58 skb_headlen(tx->skb)); in build_vnic_ulp_payload()
62 for (i = 0; i < skb_shinfo(tx->skb)->nr_frags; i++) { in build_vnic_ulp_payload()
63 skb_frag_t *frag = &skb_shinfo(tx->skb)->frags[i]; in build_vnic_ulp_payload()
66 ret = sdma_txadd_page(sde->dd, in build_vnic_ulp_payload()
67 &tx->txreq, in build_vnic_ulp_payload()
75 if (tx->plen) in build_vnic_ulp_payload()
76 ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, in build_vnic_ulp_payload()
77 tx->pad + HFI1_VNIC_MAX_PAD - tx->plen, in build_vnic_ulp_payload()
78 tx->plen); in build_vnic_ulp_payload()
92 &tx->txreq, in build_vnic_tx_desc()
94 hdrbytes + tx->skb->len + tx->plen, in build_vnic_tx_desc()
104 tx->pbc_val = cpu_to_le64(pbc); in build_vnic_tx_desc()
106 sde->dd, in build_vnic_tx_desc()
107 &tx->txreq, in build_vnic_tx_desc()
108 &tx->pbc_val, in build_vnic_tx_desc()
122 pad[HFI1_VNIC_MAX_PAD - 1] = plen - OPA_VNIC_ICRC_TAIL_LEN; in hfi1_vnic_update_pad()
129 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_send_dma()
130 struct sdma_engine *sde = vnic_sdma->sde; in hfi1_vnic_send_dma()
132 int ret = -ECOMM; in hfi1_vnic_send_dma()
134 if (unlikely(READ_ONCE(vnic_sdma->state) != HFI1_VNIC_SDMA_Q_ACTIVE)) in hfi1_vnic_send_dma()
140 tx = kmem_cache_alloc(dd->vnic.txreq_cache, GFP_ATOMIC); in hfi1_vnic_send_dma()
142 ret = -ENOMEM; in hfi1_vnic_send_dma()
146 tx->sdma = vnic_sdma; in hfi1_vnic_send_dma()
147 tx->skb = skb; in hfi1_vnic_send_dma()
148 hfi1_vnic_update_pad(tx->pad, plen); in hfi1_vnic_send_dma()
149 tx->plen = plen; in hfi1_vnic_send_dma()
154 ret = sdma_send_txreq(sde, iowait_get_ib_work(&vnic_sdma->wait), in hfi1_vnic_send_dma()
155 &tx->txreq, vnic_sdma->pkts_sent); in hfi1_vnic_send_dma()
156 /* When -ECOMM, sdma callback will be called with ABORT status */ in hfi1_vnic_send_dma()
157 if (unlikely(ret && unlikely(ret != -ECOMM))) in hfi1_vnic_send_dma()
161 vnic_sdma->pkts_sent = true; in hfi1_vnic_send_dma()
162 iowait_starve_clear(vnic_sdma->pkts_sent, &vnic_sdma->wait); in hfi1_vnic_send_dma()
167 sdma_txclean(dd, &tx->txreq); in hfi1_vnic_send_dma()
168 kmem_cache_free(dd->vnic.txreq_cache, tx); in hfi1_vnic_send_dma()
170 if (ret != -EBUSY) in hfi1_vnic_send_dma()
173 vnic_sdma->pkts_sent = false; in hfi1_vnic_send_dma()
178 * hfi1_vnic_sdma_sleep - vnic sdma sleep function
181 * sdma descriptors available to send the packet. It adds Tx queue's wait
186 struct iowait_work *wait, in hfi1_vnic_sdma_sleep() argument
192 container_of(wait->iow, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_sleep()
194 write_seqlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
196 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
197 return -EAGAIN; in hfi1_vnic_sdma_sleep()
200 vnic_sdma->state = HFI1_VNIC_SDMA_Q_DEFERRED; in hfi1_vnic_sdma_sleep()
201 if (list_empty(&vnic_sdma->wait.list)) { in hfi1_vnic_sdma_sleep()
202 iowait_get_priority(wait->iow); in hfi1_vnic_sdma_sleep()
203 iowait_queue(pkts_sent, wait->iow, &sde->dmawait); in hfi1_vnic_sdma_sleep()
205 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
206 return -EBUSY; in hfi1_vnic_sdma_sleep()
210 * hfi1_vnic_sdma_wakeup - vnic sdma wakeup function
213 * queue's wait structure was previously added to sdma engine's dmawait list.
216 static void hfi1_vnic_sdma_wakeup(struct iowait *wait, int reason) in hfi1_vnic_sdma_wakeup() argument
219 container_of(wait, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_wakeup()
220 struct hfi1_vnic_vport_info *vinfo = vnic_sdma->vinfo; in hfi1_vnic_sdma_wakeup()
222 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_wakeup()
223 if (__netif_subqueue_stopped(vinfo->netdev, vnic_sdma->q_idx)) in hfi1_vnic_sdma_wakeup()
224 netif_wake_subqueue(vinfo->netdev, vnic_sdma->q_idx); in hfi1_vnic_sdma_wakeup()
230 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_sdma_write_avail()
232 return (READ_ONCE(vnic_sdma->state) == HFI1_VNIC_SDMA_Q_ACTIVE); in hfi1_vnic_sdma_write_avail()
239 for (i = 0; i < vinfo->num_tx_q; i++) { in hfi1_vnic_sdma_init()
240 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[i]; in hfi1_vnic_sdma_init()
242 iowait_init(&vnic_sdma->wait, 0, NULL, NULL, in hfi1_vnic_sdma_init()
245 vnic_sdma->sde = &vinfo->dd->per_sdma[i]; in hfi1_vnic_sdma_init()
246 vnic_sdma->dd = vinfo->dd; in hfi1_vnic_sdma_init()
247 vnic_sdma->vinfo = vinfo; in hfi1_vnic_sdma_init()
248 vnic_sdma->q_idx = i; in hfi1_vnic_sdma_init()
249 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_init()
252 if (vnic_sdma->sde->descq_cnt > HFI1_VNIC_SDMA_DESC_WTRMRK) { in hfi1_vnic_sdma_init()
255 INIT_LIST_HEAD(&vnic_sdma->stx.list); in hfi1_vnic_sdma_init()
256 vnic_sdma->stx.num_desc = HFI1_VNIC_SDMA_DESC_WTRMRK; in hfi1_vnic_sdma_init()
257 work = iowait_get_ib_work(&vnic_sdma->wait); in hfi1_vnic_sdma_init()
258 list_add_tail(&vnic_sdma->stx.list, &work->tx_head); in hfi1_vnic_sdma_init()
267 snprintf(buf, sizeof(buf), "hfi1_%u_vnic_txreq_cache", dd->unit); in hfi1_vnic_txreq_init()
268 dd->vnic.txreq_cache = kmem_cache_create(buf, in hfi1_vnic_txreq_init()
272 if (!dd->vnic.txreq_cache) in hfi1_vnic_txreq_init()
273 return -ENOMEM; in hfi1_vnic_txreq_init()
279 kmem_cache_destroy(dd->vnic.txreq_cache); in hfi1_vnic_txreq_deinit()
280 dd->vnic.txreq_cache = NULL; in hfi1_vnic_txreq_deinit()