rxe.c (3ccffe8abf2febab4642033d4675a20bbade151b) rxe.c (3225717f6dfa29a6f03629b7a7f8492e1521d06d)
1// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2/*
3 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 */
6
7#include <rdma/rdma_netlink.h>
8#include <net/addrconf.h>

--- 100 unchanged lines hidden (view full) ---

109
110 rxe_init_port_param(port);
111 addrconf_addr_eui48((unsigned char *)&port->port_guid,
112 rxe->ndev->dev_addr);
113 spin_lock_init(&port->port_lock);
114}
115
116/* init pools of managed objects */
1// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2/*
3 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 */
6
7#include <rdma/rdma_netlink.h>
8#include <net/addrconf.h>

--- 100 unchanged lines hidden (view full) ---

109
110 rxe_init_port_param(port);
111 addrconf_addr_eui48((unsigned char *)&port->port_guid,
112 rxe->ndev->dev_addr);
113 spin_lock_init(&port->port_lock);
114}
115
116/* init pools of managed objects */
117static int rxe_init_pools(struct rxe_dev *rxe)
117static void rxe_init_pools(struct rxe_dev *rxe)
118{
118{
119 int err;
120
121 err = rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC);
122 if (err)
123 goto err1;
124
125 err = rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD);
126 if (err)
127 goto err2;
128
129 err = rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH);
130 if (err)
131 goto err3;
132
133 err = rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ);
134 if (err)
135 goto err4;
136
137 err = rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP);
138 if (err)
139 goto err5;
140
141 err = rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ);
142 if (err)
143 goto err6;
144
145 err = rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR);
146 if (err)
147 goto err7;
148
149 err = rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW);
150 if (err)
151 goto err8;
152
153 return 0;
154
155err8:
156 rxe_pool_cleanup(&rxe->mr_pool);
157err7:
158 rxe_pool_cleanup(&rxe->cq_pool);
159err6:
160 rxe_pool_cleanup(&rxe->qp_pool);
161err5:
162 rxe_pool_cleanup(&rxe->srq_pool);
163err4:
164 rxe_pool_cleanup(&rxe->ah_pool);
165err3:
166 rxe_pool_cleanup(&rxe->pd_pool);
167err2:
168 rxe_pool_cleanup(&rxe->uc_pool);
169err1:
170 return err;
119 rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC);
120 rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD);
121 rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH);
122 rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ);
123 rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP);
124 rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ);
125 rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR);
126 rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW);
171}
172
173/* initialize rxe device state */
127}
128
129/* initialize rxe device state */
174static int rxe_init(struct rxe_dev *rxe)
130static void rxe_init(struct rxe_dev *rxe)
175{
131{
176 int err;
177
178 /* init default device parameters */
179 rxe_init_device_param(rxe);
180
181 rxe_init_ports(rxe);
132 /* init default device parameters */
133 rxe_init_device_param(rxe);
134
135 rxe_init_ports(rxe);
136 rxe_init_pools(rxe);
182
137
183 err = rxe_init_pools(rxe);
184 if (err)
185 return err;
186
187 /* init pending mmap list */
188 spin_lock_init(&rxe->mmap_offset_lock);
189 spin_lock_init(&rxe->pending_lock);
190 INIT_LIST_HEAD(&rxe->pending_mmaps);
191
192 /* init multicast support */
193 spin_lock_init(&rxe->mcg_lock);
194 rxe->mcg_tree = RB_ROOT;
195
196 mutex_init(&rxe->usdev_lock);
138 /* init pending mmap list */
139 spin_lock_init(&rxe->mmap_offset_lock);
140 spin_lock_init(&rxe->pending_lock);
141 INIT_LIST_HEAD(&rxe->pending_mmaps);
142
143 /* init multicast support */
144 spin_lock_init(&rxe->mcg_lock);
145 rxe->mcg_tree = RB_ROOT;
146
147 mutex_init(&rxe->usdev_lock);
197
198 return 0;
199}
200
201void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu)
202{
203 struct rxe_port *port = &rxe->port;
204 enum ib_mtu mtu;
205
206 mtu = eth_mtu_int_to_enum(ndev_mtu);

--- 5 unchanged lines hidden (view full) ---

212 port->mtu_cap = ib_mtu_enum_to_int(mtu);
213}
214
215/* called by ifc layer to create new rxe device.
216 * The caller should allocate memory for rxe by calling ib_alloc_device.
217 */
218int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name)
219{
148}
149
150void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu)
151{
152 struct rxe_port *port = &rxe->port;
153 enum ib_mtu mtu;
154
155 mtu = eth_mtu_int_to_enum(ndev_mtu);

--- 5 unchanged lines hidden (view full) ---

161 port->mtu_cap = ib_mtu_enum_to_int(mtu);
162}
163
164/* called by ifc layer to create new rxe device.
165 * The caller should allocate memory for rxe by calling ib_alloc_device.
166 */
167int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name)
168{
220 int err;
221
222 err = rxe_init(rxe);
223 if (err)
224 return err;
225
169 rxe_init(rxe);
226 rxe_set_mtu(rxe, mtu);
227
228 return rxe_register_device(rxe, ibdev_name);
229}
230
231static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)
232{
233 struct rxe_dev *exists;

--- 56 unchanged lines hidden ---
170 rxe_set_mtu(rxe, mtu);
171
172 return rxe_register_device(rxe, ibdev_name);
173}
174
175static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)
176{
177 struct rxe_dev *exists;

--- 56 unchanged lines hidden ---