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
@@ -61,7 +59,7 @@ static void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev)
61
59
}
62
60
63
61
static void irdma_fill_qos_info (struct irdma_l2params * l2params ,
64
- struct iidc_qos_params * qos_info )
62
+ struct iidc_rdma_qos_params * qos_info )
65
63
{
66
64
int i ;
67
65
@@ -85,38 +83,40 @@ 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_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
- if (* event -> type & BIT (IIDC_EVENT_AFTER_MTU_CHANGE )) {
92
+ if (* event -> type & BIT (IIDC_RDMA_EVENT_AFTER_MTU_CHANGE )) {
94
93
ibdev_dbg (& iwdev -> ibdev , "CLNT: new MTU = %d\n" , iwdev -> netdev -> mtu );
95
94
if (iwdev -> vsi .mtu != iwdev -> netdev -> mtu ) {
96
95
l2params .mtu = iwdev -> netdev -> mtu ;
97
96
l2params .mtu_changed = true;
98
97
irdma_log_invalid_mtu (l2params .mtu , & iwdev -> rf -> sc_dev );
99
98
irdma_change_l2params (& iwdev -> vsi , & l2params );
100
99
}
101
- } else if (* event -> type & BIT (IIDC_EVENT_BEFORE_TC_CHANGE )) {
100
+ } else if (* event -> type & BIT (IIDC_RDMA_EVENT_BEFORE_TC_CHANGE )) {
102
101
if (iwdev -> vsi .tc_change_pending )
103
102
return ;
104
103
105
104
irdma_prep_tc_change (iwdev );
106
- } else if (* event -> type & BIT (IIDC_EVENT_AFTER_TC_CHANGE )) {
107
- struct iidc_qos_params qos_info = {} ;
105
+ } else if (* event -> type & BIT (IIDC_RDMA_EVENT_AFTER_TC_CHANGE )) {
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
- } else if (* event -> type & BIT (IIDC_EVENT_CRIT_ERR )) {
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" ,
121
121
event -> reg );
122
122
if (event -> reg & IRDMAPFINT_OICR_PE_CRITERR_M ) {
@@ -151,10 +151,8 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_event *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,54 +233,63 @@ 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
}
245
245
246
246
static void irdma_remove (struct auxiliary_device * aux_dev )
247
247
{
248
- struct iidc_auxiliary_dev * iidc_adev = container_of (aux_dev ,
249
- struct iidc_auxiliary_dev ,
250
- adev );
251
- struct ice_pf * pf = iidc_adev -> pf ;
252
248
struct irdma_device * iwdev = auxiliary_get_drvdata (aux_dev );
249
+ struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
250
+ struct iidc_rdma_core_dev_info * cdev_info ;
251
+
252
+ iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
253
+ cdev_info = iidc_adev -> cdev_info ;
253
254
255
+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , false);
254
256
irdma_ib_unregister_device (iwdev );
255
- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , false);
256
- irdma_deinit_interrupts (iwdev -> rf , pf );
257
+ irdma_deinit_interrupts (iwdev -> rf , cdev_info );
257
258
258
- 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 ));
259
260
}
260
261
261
- static void irdma_fill_device_info (struct irdma_device * iwdev , struct ice_pf * pf ,
262
- struct ice_vsi * vsi )
262
+ static void irdma_fill_device_info (struct irdma_device * iwdev ,
263
+ struct iidc_rdma_core_dev_info * cdev_info )
263
264
{
265
+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
264
266
struct irdma_pci_f * rf = iwdev -> rf ;
265
267
266
- 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 ;
267
275
rf -> gen_ops .register_qset = irdma_lan_register_qset ;
268
276
rf -> gen_ops .unregister_qset = irdma_lan_unregister_qset ;
269
- rf -> hw .hw_addr = pf -> hw .hw_addr ;
270
- rf -> pcidev = pf -> pdev ;
271
- rf -> pf_id = pf -> hw .pf_id ;
272
- rf -> default_vsi .vsi_idx = vsi -> vsi_num ;
273
- rf -> protocol_used = pf -> rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
274
- 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 ;
275
282
rf -> rdma_ver = IRDMA_GEN_2 ;
276
283
rf -> rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT ;
277
284
rf -> rst_to = IRDMA_RST_TIMEOUT_HZ ;
278
285
rf -> gen_ops .request_reset = irdma_request_reset ;
279
286
rf -> limits_sel = 7 ;
280
287
rf -> iwdev = iwdev ;
288
+
281
289
mutex_init (& iwdev -> ah_tbl_lock );
282
- iwdev -> netdev = vsi -> netdev ;
283
- iwdev -> vsi_num = vsi -> vsi_num ;
290
+
291
+ iwdev -> netdev = iidc_priv -> netdev ;
292
+ iwdev -> vsi_num = iidc_priv -> vport_id ;
284
293
iwdev -> init_state = INITIAL_STATE ;
285
294
iwdev -> roce_cwnd = IRDMA_ROCE_CWND_DEFAULT ;
286
295
iwdev -> roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT ;
@@ -292,19 +301,18 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
292
301
293
302
static int irdma_probe (struct auxiliary_device * aux_dev , const struct auxiliary_device_id * id )
294
303
{
295
- struct iidc_auxiliary_dev * iidc_adev = container_of (aux_dev ,
296
- struct iidc_auxiliary_dev ,
297
- adev );
298
- struct ice_pf * pf = iidc_adev -> pf ;
299
- struct ice_vsi * vsi = ice_get_main_vsi (pf );
300
- struct iidc_qos_params qos_info = {};
304
+ struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
305
+ struct iidc_rdma_core_dev_info * cdev_info ;
306
+ struct iidc_rdma_priv_dev_info * iidc_priv ;
307
+ struct irdma_l2params l2params = {};
301
308
struct irdma_device * iwdev ;
302
309
struct irdma_pci_f * rf ;
303
- struct irdma_l2params l2params = {};
304
310
int err ;
305
311
306
- if (!vsi )
307
- return - EIO ;
312
+ iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
313
+ cdev_info = iidc_adev -> cdev_info ;
314
+ iidc_priv = cdev_info -> iidc_priv ;
315
+
308
316
iwdev = ib_alloc_device (irdma_device , ibdev );
309
317
if (!iwdev )
310
318
return - ENOMEM ;
@@ -314,10 +322,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
314
322
return - ENOMEM ;
315
323
}
316
324
317
- irdma_fill_device_info (iwdev , pf , vsi );
325
+ irdma_fill_device_info (iwdev , cdev_info );
318
326
rf = iwdev -> rf ;
319
327
320
- err = irdma_init_interrupts (rf , pf );
328
+ err = irdma_init_interrupts (rf , cdev_info );
321
329
if (err )
322
330
goto err_init_interrupts ;
323
331
@@ -326,8 +334,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
326
334
goto err_ctrl_init ;
327
335
328
336
l2params .mtu = iwdev -> netdev -> mtu ;
329
- ice_get_qos_params (pf , & qos_info );
330
- irdma_fill_qos_info (& l2params , & qos_info );
337
+ irdma_fill_qos_info (& l2params , & iidc_priv -> qos_info );
331
338
if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
332
339
iwdev -> dcb_vlan_mode = l2params .num_tc > 1 && !l2params .dscp_mode ;
333
340
@@ -339,7 +346,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
339
346
if (err )
340
347
goto err_ibreg ;
341
348
342
- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , true);
349
+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , true);
343
350
344
351
ibdev_dbg (& iwdev -> ibdev , "INIT: Gen2 PF[%d] device probe success\n" , PCI_FUNC (rf -> pcidev -> devfn ));
345
352
auxiliary_set_drvdata (aux_dev , iwdev );
@@ -351,7 +358,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
351
358
err_rt_init :
352
359
irdma_ctrl_deinit_hw (rf );
353
360
err_ctrl_init :
354
- irdma_deinit_interrupts (rf , pf );
361
+ irdma_deinit_interrupts (rf , cdev_info );
355
362
err_init_interrupts :
356
363
kfree (iwdev -> rf );
357
364
ib_dealloc_device (& iwdev -> ibdev );
@@ -367,7 +374,7 @@ static const struct auxiliary_device_id irdma_auxiliary_id_table[] = {
367
374
368
375
MODULE_DEVICE_TABLE (auxiliary , irdma_auxiliary_id_table );
369
376
370
- static struct iidc_auxiliary_drv irdma_auxiliary_drv = {
377
+ static struct iidc_rdma_core_auxiliary_drv irdma_auxiliary_drv = {
371
378
.adrv = {
372
379
.id_table = irdma_auxiliary_id_table ,
373
380
.probe = irdma_probe ,
0 commit comments