diff options
Diffstat (limited to 'drivers/infiniband/hw/ehca/ehca_sqp.c')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_sqp.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_sqp.c b/drivers/infiniband/hw/ehca/ehca_sqp.c new file mode 100644 index 000000000000..9f16e9c79394 --- /dev/null +++ b/drivers/infiniband/hw/ehca/ehca_sqp.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * IBM eServer eHCA Infiniband device driver for Linux on POWER | ||
3 | * | ||
4 | * SQP functions | ||
5 | * | ||
6 | * Authors: Khadija Souissi <souissi@de.ibm.com> | ||
7 | * Heiko J Schick <schickhj@de.ibm.com> | ||
8 | * | ||
9 | * Copyright (c) 2005 IBM Corporation | ||
10 | * | ||
11 | * All rights reserved. | ||
12 | * | ||
13 | * This source code is distributed under a dual license of GPL v2.0 and OpenIB | ||
14 | * BSD. | ||
15 | * | ||
16 | * OpenIB BSD License | ||
17 | * | ||
18 | * Redistribution and use in source and binary forms, with or without | ||
19 | * modification, are permitted provided that the following conditions are met: | ||
20 | * | ||
21 | * Redistributions of source code must retain the above copyright notice, this | ||
22 | * list of conditions and the following disclaimer. | ||
23 | * | ||
24 | * Redistributions in binary form must reproduce the above copyright notice, | ||
25 | * this list of conditions and the following disclaimer in the documentation | ||
26 | * and/or other materials | ||
27 | * provided with the distribution. | ||
28 | * | ||
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
33 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
34 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
35 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
36 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
37 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
38 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
39 | * POSSIBILITY OF SUCH DAMAGE. | ||
40 | */ | ||
41 | |||
42 | |||
43 | #include <linux/module.h> | ||
44 | #include <linux/err.h> | ||
45 | #include "ehca_classes.h" | ||
46 | #include "ehca_tools.h" | ||
47 | #include "ehca_qes.h" | ||
48 | #include "ehca_iverbs.h" | ||
49 | #include "hcp_if.h" | ||
50 | |||
51 | |||
52 | /** | ||
53 | * ehca_define_sqp - Defines special queue pair 1 (GSI QP). When special queue | ||
54 | * pair is created successfully, the corresponding port gets active. | ||
55 | * | ||
56 | * Define Special Queue pair 0 (SMI QP) is still not supported. | ||
57 | * | ||
58 | * @qp_init_attr: Queue pair init attributes with port and queue pair type | ||
59 | */ | ||
60 | |||
61 | u64 ehca_define_sqp(struct ehca_shca *shca, | ||
62 | struct ehca_qp *ehca_qp, | ||
63 | struct ib_qp_init_attr *qp_init_attr) | ||
64 | { | ||
65 | u32 pma_qp_nr, bma_qp_nr; | ||
66 | u64 ret; | ||
67 | u8 port = qp_init_attr->port_num; | ||
68 | int counter; | ||
69 | |||
70 | shca->sport[port - 1].port_state = IB_PORT_DOWN; | ||
71 | |||
72 | switch (qp_init_attr->qp_type) { | ||
73 | case IB_QPT_SMI: | ||
74 | /* function not supported yet */ | ||
75 | break; | ||
76 | case IB_QPT_GSI: | ||
77 | ret = hipz_h_define_aqp1(shca->ipz_hca_handle, | ||
78 | ehca_qp->ipz_qp_handle, | ||
79 | ehca_qp->galpas.kernel, | ||
80 | (u32) qp_init_attr->port_num, | ||
81 | &pma_qp_nr, &bma_qp_nr); | ||
82 | |||
83 | if (ret != H_SUCCESS) { | ||
84 | ehca_err(&shca->ib_device, | ||
85 | "Can't define AQP1 for port %x. rc=%lx", | ||
86 | port, ret); | ||
87 | return ret; | ||
88 | } | ||
89 | break; | ||
90 | default: | ||
91 | ehca_err(&shca->ib_device, "invalid qp_type=%x", | ||
92 | qp_init_attr->qp_type); | ||
93 | return H_PARAMETER; | ||
94 | } | ||
95 | |||
96 | for (counter = 0; | ||
97 | shca->sport[port - 1].port_state != IB_PORT_ACTIVE && | ||
98 | counter < ehca_port_act_time; | ||
99 | counter++) { | ||
100 | ehca_dbg(&shca->ib_device, "... wait until port %x is active", | ||
101 | port); | ||
102 | msleep_interruptible(1000); | ||
103 | } | ||
104 | |||
105 | if (counter == ehca_port_act_time) { | ||
106 | ehca_err(&shca->ib_device, "Port %x is not active.", port); | ||
107 | return H_HARDWARE; | ||
108 | } | ||
109 | |||
110 | return H_SUCCESS; | ||
111 | } | ||