1
1
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2
2
/* Copyright (c) 2015 - 2021 Intel Corporation */
3
3
#include "main.h"
4
- #include "../../../net/ethernet/intel/ice/ice.h"
5
4
6
5
MODULE_ALIAS ("i40iw" );
7
- MODULE_AUTHOR (
"Intel Corporation, <[email protected] >" );
8
6
MODULE_DESCRIPTION ("Intel(R) Ethernet Protocol Driver for RDMA" );
9
7
MODULE_LICENSE ("Dual BSD/GPL" );
10
8
@@ -85,9 +83,10 @@ static void irdma_fill_qos_info(struct irdma_l2params *l2params,
85
83
}
86
84
}
87
85
88
- static void irdma_iidc_event_handler (struct ice_pf * pf , struct iidc_rdma_event * event )
86
+ static void irdma_iidc_event_handler (struct iidc_rdma_core_dev_info * cdev_info ,
87
+ struct iidc_rdma_event * event )
89
88
{
90
- struct irdma_device * iwdev = dev_get_drvdata (& pf -> adev -> dev );
89
+ struct irdma_device * iwdev = dev_get_drvdata (& cdev_info -> adev -> dev );
91
90
struct irdma_l2params l2params = {};
92
91
93
92
if (* event -> type & BIT (IIDC_RDMA_EVENT_AFTER_MTU_CHANGE )) {
@@ -104,17 +103,18 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_rdma_event *
104
103
105
104
irdma_prep_tc_change (iwdev );
106
105
} else if (* event -> type & BIT (IIDC_RDMA_EVENT_AFTER_TC_CHANGE )) {
107
- struct iidc_rdma_qos_params qos_info = {} ;
106
+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
108
107
109
108
if (!iwdev -> vsi .tc_change_pending )
110
109
return ;
111
110
112
111
l2params .tc_changed = true;
113
112
ibdev_dbg (& iwdev -> ibdev , "CLNT: TC Change\n" );
114
- ice_get_qos_params ( pf , & qos_info );
115
- irdma_fill_qos_info (& l2params , & qos_info );
113
+
114
+ irdma_fill_qos_info (& l2params , & iidc_priv -> qos_info );
116
115
if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
117
- iwdev -> dcb_vlan_mode = qos_info .num_tc > 1 && !l2params .dscp_mode ;
116
+ iwdev -> dcb_vlan_mode =
117
+ l2params .num_tc > 1 && !l2params .dscp_mode ;
118
118
irdma_change_l2params (& iwdev -> vsi , & l2params );
119
119
} else if (* event -> type & BIT (IIDC_RDMA_EVENT_CRIT_ERR )) {
120
120
ibdev_warn (& iwdev -> ibdev , "ICE OICR event notification: oicr = 0x%08x\n" ,
@@ -151,10 +151,8 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_rdma_event *
151
151
*/
152
152
static void irdma_request_reset (struct irdma_pci_f * rf )
153
153
{
154
- struct ice_pf * pf = rf -> cdev ;
155
-
156
154
ibdev_warn (& rf -> iwdev -> ibdev , "Requesting a reset\n" );
157
- ice_rdma_request_reset (pf , IIDC_PFR );
155
+ ice_rdma_request_reset (rf -> cdev , IIDC_FUNC_RESET );
158
156
}
159
157
160
158
/**
@@ -166,14 +164,15 @@ static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi,
166
164
struct irdma_ws_node * tc_node )
167
165
{
168
166
struct irdma_device * iwdev = vsi -> back_vsi ;
169
- struct ice_pf * pf = iwdev -> rf -> cdev ;
167
+ struct iidc_rdma_core_dev_info * cdev_info ;
170
168
struct iidc_rdma_qset_params qset = {};
171
169
int ret ;
172
170
171
+ cdev_info = iwdev -> rf -> cdev ;
173
172
qset .qs_handle = tc_node -> qs_handle ;
174
173
qset .tc = tc_node -> traffic_class ;
175
174
qset .vport_id = vsi -> vsi_idx ;
176
- ret = ice_add_rdma_qset (pf , & qset );
175
+ ret = ice_add_rdma_qset (cdev_info , & qset );
177
176
if (ret ) {
178
177
ibdev_dbg (& iwdev -> ibdev , "WS: LAN alloc_res for rdma qset failed.\n" );
179
178
return ret ;
@@ -194,19 +193,20 @@ static void irdma_lan_unregister_qset(struct irdma_sc_vsi *vsi,
194
193
struct irdma_ws_node * tc_node )
195
194
{
196
195
struct irdma_device * iwdev = vsi -> back_vsi ;
197
- struct ice_pf * pf = iwdev -> rf -> cdev ;
196
+ struct iidc_rdma_core_dev_info * cdev_info ;
198
197
struct iidc_rdma_qset_params qset = {};
199
198
199
+ cdev_info = iwdev -> rf -> cdev ;
200
200
qset .qs_handle = tc_node -> qs_handle ;
201
201
qset .tc = tc_node -> traffic_class ;
202
202
qset .vport_id = vsi -> vsi_idx ;
203
203
qset .teid = tc_node -> l2_sched_node_id ;
204
204
205
- if (ice_del_rdma_qset (pf , & qset ))
205
+ if (ice_del_rdma_qset (cdev_info , & qset ))
206
206
ibdev_dbg (& iwdev -> ibdev , "WS: LAN free_res for rdma qset failed.\n" );
207
207
}
208
208
209
- static int irdma_init_interrupts (struct irdma_pci_f * rf , struct ice_pf * pf )
209
+ static int irdma_init_interrupts (struct irdma_pci_f * rf , struct iidc_rdma_core_dev_info * cdev )
210
210
{
211
211
int i ;
212
212
@@ -217,12 +217,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
217
217
return - ENOMEM ;
218
218
219
219
for (i = 0 ; i < rf -> msix_count ; i ++ )
220
- if (ice_alloc_rdma_qvector (pf , & rf -> msix_entries [i ]))
220
+ if (ice_alloc_rdma_qvector (cdev , & rf -> msix_entries [i ]))
221
221
break ;
222
222
223
223
if (i < IRDMA_MIN_MSIX ) {
224
224
for (; i > 0 ; i -- )
225
- ice_free_rdma_qvector (pf , & rf -> msix_entries [i ]);
225
+ ice_free_rdma_qvector (cdev , & rf -> msix_entries [i ]);
226
226
227
227
kfree (rf -> msix_entries );
228
228
return - ENOMEM ;
@@ -233,12 +233,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
233
233
return 0 ;
234
234
}
235
235
236
- static void irdma_deinit_interrupts (struct irdma_pci_f * rf , struct ice_pf * pf )
236
+ static void irdma_deinit_interrupts (struct irdma_pci_f * rf , struct iidc_rdma_core_dev_info * cdev )
237
237
{
238
238
int i ;
239
239
240
240
for (i = 0 ; i < rf -> msix_count ; i ++ )
241
- ice_free_rdma_qvector (pf , & rf -> msix_entries [i ]);
241
+ ice_free_rdma_qvector (cdev , & rf -> msix_entries [i ]);
242
242
243
243
kfree (rf -> msix_entries );
244
244
}
@@ -247,41 +247,49 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
247
247
{
248
248
struct irdma_device * iwdev = auxiliary_get_drvdata (aux_dev );
249
249
struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
250
- struct ice_pf * pf ;
250
+ struct iidc_rdma_core_dev_info * cdev_info ;
251
251
252
252
iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
253
- pf = iidc_adev -> pf ;
253
+ cdev_info = iidc_adev -> cdev_info ;
254
254
255
+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , false);
255
256
irdma_ib_unregister_device (iwdev );
256
- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , false);
257
- irdma_deinit_interrupts (iwdev -> rf , pf );
257
+ irdma_deinit_interrupts (iwdev -> rf , cdev_info );
258
258
259
- pr_debug ("INIT: Gen2 PF[%d] device remove success\n" , PCI_FUNC (pf -> pdev -> devfn ));
259
+ pr_debug ("INIT: Gen2 PF[%d] device remove success\n" , PCI_FUNC (cdev_info -> pdev -> devfn ));
260
260
}
261
261
262
- static void irdma_fill_device_info (struct irdma_device * iwdev , struct ice_pf * pf ,
263
- struct ice_vsi * vsi )
262
+ static void irdma_fill_device_info (struct irdma_device * iwdev ,
263
+ struct iidc_rdma_core_dev_info * cdev_info )
264
264
{
265
+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
265
266
struct irdma_pci_f * rf = iwdev -> rf ;
266
267
267
- rf -> cdev = pf ;
268
+ rf -> sc_dev .hw = & rf -> hw ;
269
+ rf -> iwdev = iwdev ;
270
+ rf -> cdev = cdev_info ;
271
+ rf -> hw .hw_addr = iidc_priv -> hw_addr ;
272
+ rf -> pcidev = cdev_info -> pdev ;
273
+ rf -> hw .device = & rf -> pcidev -> dev ;
274
+ rf -> pf_id = iidc_priv -> pf_id ;
268
275
rf -> gen_ops .register_qset = irdma_lan_register_qset ;
269
276
rf -> gen_ops .unregister_qset = irdma_lan_unregister_qset ;
270
- rf -> hw .hw_addr = pf -> hw .hw_addr ;
271
- rf -> pcidev = pf -> pdev ;
272
- rf -> pf_id = pf -> hw .pf_id ;
273
- rf -> default_vsi .vsi_idx = vsi -> vsi_num ;
274
- rf -> protocol_used = pf -> rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
275
- IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY ;
277
+
278
+ rf -> default_vsi .vsi_idx = iidc_priv -> vport_id ;
279
+ rf -> protocol_used =
280
+ cdev_info -> rdma_protocol == IIDC_RDMA_PROTOCOL_ROCEV2 ?
281
+ IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY ;
276
282
rf -> rdma_ver = IRDMA_GEN_2 ;
277
283
rf -> rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT ;
278
284
rf -> rst_to = IRDMA_RST_TIMEOUT_HZ ;
279
285
rf -> gen_ops .request_reset = irdma_request_reset ;
280
286
rf -> limits_sel = 7 ;
281
287
rf -> iwdev = iwdev ;
288
+
282
289
mutex_init (& iwdev -> ah_tbl_lock );
283
- iwdev -> netdev = vsi -> netdev ;
284
- iwdev -> vsi_num = vsi -> vsi_num ;
290
+
291
+ iwdev -> netdev = iidc_priv -> netdev ;
292
+ iwdev -> vsi_num = iidc_priv -> vport_id ;
285
293
iwdev -> init_state = INITIAL_STATE ;
286
294
iwdev -> roce_cwnd = IRDMA_ROCE_CWND_DEFAULT ;
287
295
iwdev -> roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT ;
@@ -294,20 +302,17 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
294
302
static int irdma_probe (struct auxiliary_device * aux_dev , const struct auxiliary_device_id * id )
295
303
{
296
304
struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
297
- struct iidc_rdma_qos_params qos_info = {};
305
+ struct iidc_rdma_core_dev_info * cdev_info ;
306
+ struct iidc_rdma_priv_dev_info * iidc_priv ;
298
307
struct irdma_l2params l2params = {};
299
308
struct irdma_device * iwdev ;
300
309
struct irdma_pci_f * rf ;
301
- struct ice_vsi * vsi ;
302
- struct ice_pf * pf ;
303
310
int err ;
304
311
305
312
iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
306
- pf = iidc_adev -> pf ;
307
- vsi = ice_get_main_vsi ( pf ) ;
313
+ cdev_info = iidc_adev -> cdev_info ;
314
+ iidc_priv = cdev_info -> iidc_priv ;
308
315
309
- if (!vsi )
310
- return - EIO ;
311
316
iwdev = ib_alloc_device (irdma_device , ibdev );
312
317
if (!iwdev )
313
318
return - ENOMEM ;
@@ -317,10 +322,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
317
322
return - ENOMEM ;
318
323
}
319
324
320
- irdma_fill_device_info (iwdev , pf , vsi );
325
+ irdma_fill_device_info (iwdev , cdev_info );
321
326
rf = iwdev -> rf ;
322
327
323
- err = irdma_init_interrupts (rf , pf );
328
+ err = irdma_init_interrupts (rf , cdev_info );
324
329
if (err )
325
330
goto err_init_interrupts ;
326
331
@@ -329,8 +334,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
329
334
goto err_ctrl_init ;
330
335
331
336
l2params .mtu = iwdev -> netdev -> mtu ;
332
- ice_get_qos_params (pf , & qos_info );
333
- irdma_fill_qos_info (& l2params , & qos_info );
337
+ irdma_fill_qos_info (& l2params , & iidc_priv -> qos_info );
334
338
if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
335
339
iwdev -> dcb_vlan_mode = l2params .num_tc > 1 && !l2params .dscp_mode ;
336
340
@@ -342,7 +346,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
342
346
if (err )
343
347
goto err_ibreg ;
344
348
345
- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , true);
349
+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , true);
346
350
347
351
ibdev_dbg (& iwdev -> ibdev , "INIT: Gen2 PF[%d] device probe success\n" , PCI_FUNC (rf -> pcidev -> devfn ));
348
352
auxiliary_set_drvdata (aux_dev , iwdev );
@@ -354,7 +358,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
354
358
err_rt_init :
355
359
irdma_ctrl_deinit_hw (rf );
356
360
err_ctrl_init :
357
- irdma_deinit_interrupts (rf , pf );
361
+ irdma_deinit_interrupts (rf , cdev_info );
358
362
err_init_interrupts :
359
363
kfree (iwdev -> rf );
360
364
ib_dealloc_device (& iwdev -> ibdev );
0 commit comments