Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
0002 /*
0003  * Copyright(c) 2016 - 2018 Intel Corporation.
0004  */
0005 
0006 #ifndef HFI1_VERBS_TXREQ_H
0007 #define HFI1_VERBS_TXREQ_H
0008 
0009 #include <linux/types.h>
0010 #include <linux/slab.h>
0011 
0012 #include "verbs.h"
0013 #include "sdma_txreq.h"
0014 #include "iowait.h"
0015 
0016 struct verbs_txreq {
0017     struct hfi1_sdma_header phdr;
0018     struct sdma_txreq       txreq;
0019     struct rvt_qp           *qp;
0020     struct rvt_swqe         *wqe;
0021     struct rvt_mregion  *mr;
0022     struct rvt_sge_state    *ss;
0023     struct sdma_engine     *sde;
0024     struct send_context     *psc;
0025     u16                     hdr_dwords;
0026     u16         s_cur_size;
0027 };
0028 
0029 struct hfi1_ibdev;
0030 struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev,
0031                 struct rvt_qp *qp);
0032 
0033 #define VERBS_TXREQ_GFP (GFP_ATOMIC | __GFP_NOWARN)
0034 static inline struct verbs_txreq *get_txreq(struct hfi1_ibdev *dev,
0035                         struct rvt_qp *qp)
0036     __must_hold(&qp->slock)
0037 {
0038     struct verbs_txreq *tx;
0039     struct hfi1_qp_priv *priv = qp->priv;
0040 
0041     tx = kmem_cache_alloc(dev->verbs_txreq_cache, VERBS_TXREQ_GFP);
0042     if (unlikely(!tx)) {
0043         /* call slow path to get the lock */
0044         tx = __get_txreq(dev, qp);
0045         if (!tx)
0046             return tx;
0047     }
0048     tx->qp = qp;
0049     tx->mr = NULL;
0050     tx->sde = priv->s_sde;
0051     tx->psc = priv->s_sendcontext;
0052     /* so that we can test if the sdma descriptors are there */
0053     tx->txreq.num_desc = 0;
0054     /* Set the header type */
0055     tx->phdr.hdr.hdr_type = priv->hdr_type;
0056     tx->txreq.flags = 0;
0057     return tx;
0058 }
0059 
0060 static inline struct verbs_txreq *get_waiting_verbs_txreq(struct iowait_work *w)
0061 {
0062     struct sdma_txreq *stx;
0063 
0064     stx = iowait_get_txhead(w);
0065     if (stx)
0066         return container_of(stx, struct verbs_txreq, txreq);
0067     return NULL;
0068 }
0069 
0070 static inline bool verbs_txreq_queued(struct iowait_work *w)
0071 {
0072     return iowait_packet_queued(w);
0073 }
0074 
0075 void hfi1_put_txreq(struct verbs_txreq *tx);
0076 int verbs_txreq_init(struct hfi1_ibdev *dev);
0077 void verbs_txreq_exit(struct hfi1_ibdev *dev);
0078 
0079 #endif                         /* HFI1_VERBS_TXREQ_H */