2 * This file is part of the Chelsio T6 Ethernet driver for Linux.
4 * Copyright (c) 2017-2018 Chelsio Communications, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39 struct srq_data
*t4_init_srq(int srq_size
)
43 s
= kvzalloc(sizeof(*s
), GFP_KERNEL
);
47 s
->srq_size
= srq_size
;
48 init_completion(&s
->comp
);
54 /* cxgb4_get_srq_entry: read the SRQ table entry
55 * @dev: Pointer to the net_device
56 * @idx: Index to the srq
57 * @entryp: pointer to the srq entry
59 * Sends CPL_SRQ_TABLE_REQ message for the given index.
60 * Contents will be returned in CPL_SRQ_TABLE_RPL message.
62 * Returns zero if the read is successful, else a error
63 * number will be returned. Caller should not use the srq
64 * entry if the return value is non-zero.
68 int cxgb4_get_srq_entry(struct net_device
*dev
,
69 int srq_idx
, struct srq_entry
*entryp
)
71 struct cpl_srq_table_req
*req
;
77 adap
= netdev2adap(dev
);
80 if (!(adap
->flags
& CXGB4_FULL_INIT_DONE
) || !s
)
83 skb
= alloc_skb(sizeof(*req
), GFP_KERNEL
);
86 req
= (struct cpl_srq_table_req
*)
87 __skb_put_zero(skb
, sizeof(*req
));
89 OPCODE_TID(req
) = htonl(MK_OPCODE_TID(CPL_SRQ_TABLE_REQ
,
91 TID_QID_V(adap
->sge
.fw_evtq
.abs_id
)));
97 t4_mgmt_tx(adap
, skb
);
99 rc
= wait_for_completion_timeout(&s
->comp
, SRQ_WAIT_TO
);
102 else /* !rc means we timed out */
105 WARN_ON_ONCE(entryp
->idx
!= srq_idx
);
106 mutex_unlock(&s
->lock
);
110 EXPORT_SYMBOL(cxgb4_get_srq_entry
);
112 void do_srq_table_rpl(struct adapter
*adap
,
113 const struct cpl_srq_table_rpl
*rpl
)
115 unsigned int idx
= TID_TID_G(GET_TID(rpl
));
116 struct srq_data
*s
= adap
->srq
;
119 if (unlikely(rpl
->status
!= CPL_CONTAINS_READ_RPL
)) {
120 dev_err(adap
->pdev_dev
,
121 "Unexpected SRQ_TABLE_RPL status %u for entry %u\n",
126 /* Store the read entry */
130 e
->pdid
= SRQT_PDID_G(be64_to_cpu(rpl
->rsvd_pdid
));
131 e
->qlen
= SRQT_QLEN_G(be32_to_cpu(rpl
->qlen_qbase
));
132 e
->qbase
= SRQT_QBASE_G(be32_to_cpu(rpl
->qlen_qbase
));
133 e
->cur_msn
= be16_to_cpu(rpl
->cur_msn
);
134 e
->max_msn
= be16_to_cpu(rpl
->max_msn
);