1 /*
2 * This file is part of the Chelsio T6 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2017-2018 Chelsio Communications, Inc. All rights reserved.
5 *
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:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
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.
24 *
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
32 * SOFTWARE.
33 */
34
35 #include "cxgb4.h"
36 #include "t4_msg.h"
37 #include "srq.h"
38
t4_init_srq(int srq_size)39 struct srq_data *t4_init_srq(int srq_size)
40 {
41 struct srq_data *s;
42
43 s = kvzalloc(sizeof(*s), GFP_KERNEL);
44 if (!s)
45 return NULL;
46
47 s->srq_size = srq_size;
48 init_completion(&s->comp);
49 mutex_init(&s->lock);
50
51 return s;
52 }
53
do_srq_table_rpl(struct adapter * adap,const struct cpl_srq_table_rpl * rpl)54 void do_srq_table_rpl(struct adapter *adap,
55 const struct cpl_srq_table_rpl *rpl)
56 {
57 unsigned int idx = TID_TID_G(GET_TID(rpl));
58 struct srq_data *s = adap->srq;
59 struct srq_entry *e;
60
61 if (unlikely(rpl->status != CPL_CONTAINS_READ_RPL)) {
62 dev_err(adap->pdev_dev,
63 "Unexpected SRQ_TABLE_RPL status %u for entry %u\n",
64 rpl->status, idx);
65 goto out;
66 }
67
68 /* Store the read entry */
69 e = s->entryp;
70 e->valid = 1;
71 e->idx = idx;
72 e->pdid = SRQT_PDID_G(be64_to_cpu(rpl->rsvd_pdid));
73 e->qlen = SRQT_QLEN_G(be32_to_cpu(rpl->qlen_qbase));
74 e->qbase = SRQT_QBASE_G(be32_to_cpu(rpl->qlen_qbase));
75 e->cur_msn = be16_to_cpu(rpl->cur_msn);
76 e->max_msn = be16_to_cpu(rpl->max_msn);
77 out:
78 complete(&s->comp);
79 }
80