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()
76 if (tx->plen) in build_vnic_ulp_payload()
77 ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, in build_vnic_ulp_payload()
78 tx->pad + HFI1_VNIC_MAX_PAD - tx->plen, in build_vnic_ulp_payload()
79 tx->plen); in build_vnic_ulp_payload()
93 &tx->txreq, in build_vnic_tx_desc()
95 hdrbytes + tx->skb->len + tx->plen, in build_vnic_tx_desc()
105 tx->pbc_val = cpu_to_le64(pbc); in build_vnic_tx_desc()
107 sde->dd, in build_vnic_tx_desc()
108 &tx->txreq, in build_vnic_tx_desc()
109 &tx->pbc_val, in build_vnic_tx_desc()
123 pad[HFI1_VNIC_MAX_PAD - 1] = plen - OPA_VNIC_ICRC_TAIL_LEN; in hfi1_vnic_update_pad()
130 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_send_dma()
131 struct sdma_engine *sde = vnic_sdma->sde; in hfi1_vnic_send_dma()
133 int ret = -ECOMM; in hfi1_vnic_send_dma()
135 if (unlikely(READ_ONCE(vnic_sdma->state) != HFI1_VNIC_SDMA_Q_ACTIVE)) in hfi1_vnic_send_dma()
141 tx = kmem_cache_alloc(dd->vnic.txreq_cache, GFP_ATOMIC); in hfi1_vnic_send_dma()
143 ret = -ENOMEM; in hfi1_vnic_send_dma()
147 tx->sdma = vnic_sdma; in hfi1_vnic_send_dma()
148 tx->skb = skb; in hfi1_vnic_send_dma()
149 hfi1_vnic_update_pad(tx->pad, plen); in hfi1_vnic_send_dma()
150 tx->plen = plen; in hfi1_vnic_send_dma()
155 ret = sdma_send_txreq(sde, iowait_get_ib_work(&vnic_sdma->wait), in hfi1_vnic_send_dma()
156 &tx->txreq, vnic_sdma->pkts_sent); in hfi1_vnic_send_dma()
157 /* When -ECOMM, sdma callback will be called with ABORT status */ in hfi1_vnic_send_dma()
158 if (unlikely(ret && unlikely(ret != -ECOMM))) in hfi1_vnic_send_dma()
162 vnic_sdma->pkts_sent = true; in hfi1_vnic_send_dma()
163 iowait_starve_clear(vnic_sdma->pkts_sent, &vnic_sdma->wait); in hfi1_vnic_send_dma()
168 sdma_txclean(dd, &tx->txreq); in hfi1_vnic_send_dma()
169 kmem_cache_free(dd->vnic.txreq_cache, tx); in hfi1_vnic_send_dma()
171 if (ret != -EBUSY) in hfi1_vnic_send_dma()
174 vnic_sdma->pkts_sent = false; in hfi1_vnic_send_dma()
179 * hfi1_vnic_sdma_sleep - vnic sdma sleep function
182 * sdma descriptors available to send the packet. It adds Tx queue's wait
187 struct iowait_work *wait, in hfi1_vnic_sdma_sleep() argument
193 container_of(wait->iow, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_sleep()
195 write_seqlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
197 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
198 return -EAGAIN; in hfi1_vnic_sdma_sleep()
201 vnic_sdma->state = HFI1_VNIC_SDMA_Q_DEFERRED; in hfi1_vnic_sdma_sleep()
202 if (list_empty(&vnic_sdma->wait.list)) { in hfi1_vnic_sdma_sleep()
203 iowait_get_priority(wait->iow); in hfi1_vnic_sdma_sleep()
204 iowait_queue(pkts_sent, wait->iow, &sde->dmawait); in hfi1_vnic_sdma_sleep()
206 write_sequnlock(&sde->waitlock); in hfi1_vnic_sdma_sleep()
207 return -EBUSY; in hfi1_vnic_sdma_sleep()
211 * hfi1_vnic_sdma_wakeup - vnic sdma wakeup function
214 * queue's wait structure was previously added to sdma engine's dmawait list.
217 static void hfi1_vnic_sdma_wakeup(struct iowait *wait, int reason) in hfi1_vnic_sdma_wakeup() argument
220 container_of(wait, struct hfi1_vnic_sdma, wait); in hfi1_vnic_sdma_wakeup()
221 struct hfi1_vnic_vport_info *vinfo = vnic_sdma->vinfo; in hfi1_vnic_sdma_wakeup()
223 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_wakeup()
224 if (__netif_subqueue_stopped(vinfo->netdev, vnic_sdma->q_idx)) in hfi1_vnic_sdma_wakeup()
225 netif_wake_subqueue(vinfo->netdev, vnic_sdma->q_idx); in hfi1_vnic_sdma_wakeup()
231 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; in hfi1_vnic_sdma_write_avail()
233 return (READ_ONCE(vnic_sdma->state) == HFI1_VNIC_SDMA_Q_ACTIVE); in hfi1_vnic_sdma_write_avail()
240 for (i = 0; i < vinfo->num_tx_q; i++) { in hfi1_vnic_sdma_init()
241 struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[i]; in hfi1_vnic_sdma_init()
243 iowait_init(&vnic_sdma->wait, 0, NULL, NULL, in hfi1_vnic_sdma_init()
246 vnic_sdma->sde = &vinfo->dd->per_sdma[i]; in hfi1_vnic_sdma_init()
247 vnic_sdma->dd = vinfo->dd; in hfi1_vnic_sdma_init()
248 vnic_sdma->vinfo = vinfo; in hfi1_vnic_sdma_init()
249 vnic_sdma->q_idx = i; in hfi1_vnic_sdma_init()
250 vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; in hfi1_vnic_sdma_init()
253 if (vnic_sdma->sde->descq_cnt > HFI1_VNIC_SDMA_DESC_WTRMRK) { in hfi1_vnic_sdma_init()
256 INIT_LIST_HEAD(&vnic_sdma->stx.list); in hfi1_vnic_sdma_init()
257 vnic_sdma->stx.num_desc = HFI1_VNIC_SDMA_DESC_WTRMRK; in hfi1_vnic_sdma_init()
258 work = iowait_get_ib_work(&vnic_sdma->wait); in hfi1_vnic_sdma_init()
259 list_add_tail(&vnic_sdma->stx.list, &work->tx_head); in hfi1_vnic_sdma_init()
268 snprintf(buf, sizeof(buf), "hfi1_%u_vnic_txreq_cache", dd->unit); in hfi1_vnic_txreq_init()
269 dd->vnic.txreq_cache = kmem_cache_create(buf, in hfi1_vnic_txreq_init()
273 if (!dd->vnic.txreq_cache) in hfi1_vnic_txreq_init()
274 return -ENOMEM; in hfi1_vnic_txreq_init()
280 kmem_cache_destroy(dd->vnic.txreq_cache); in hfi1_vnic_txreq_deinit()
281 dd->vnic.txreq_cache = NULL; in hfi1_vnic_txreq_deinit()