11// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
22/* Copyright (c) 2015 - 2021 Intel Corporation */
33#include "main.h"
4- #include "../../../net/ethernet/intel/ice/ice.h"
54
65MODULE_ALIAS ("i40iw" );
7- MODULE_AUTHOR (
"Intel Corporation, <[email protected] >" );
86MODULE_DESCRIPTION ("Intel(R) Ethernet Protocol Driver for RDMA" );
97MODULE_LICENSE ("Dual BSD/GPL" );
108
@@ -85,9 +83,10 @@ static void irdma_fill_qos_info(struct irdma_l2params *l2params,
8583 }
8684}
8785
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 )
8988{
90- struct irdma_device * iwdev = dev_get_drvdata (& pf -> adev -> dev );
89+ struct irdma_device * iwdev = dev_get_drvdata (& cdev_info -> adev -> dev );
9190 struct irdma_l2params l2params = {};
9291
9392 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 *
104103
105104 irdma_prep_tc_change (iwdev );
106105 } 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 ;
108107
109108 if (!iwdev -> vsi .tc_change_pending )
110109 return ;
111110
112111 l2params .tc_changed = true;
113112 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 );
116115 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 ;
118118 irdma_change_l2params (& iwdev -> vsi , & l2params );
119119 } else if (* event -> type & BIT (IIDC_RDMA_EVENT_CRIT_ERR )) {
120120 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 *
151151 */
152152static void irdma_request_reset (struct irdma_pci_f * rf )
153153{
154- struct ice_pf * pf = rf -> cdev ;
155-
156154 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 );
158156}
159157
160158/**
@@ -166,14 +164,15 @@ static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi,
166164 struct irdma_ws_node * tc_node )
167165{
168166 struct irdma_device * iwdev = vsi -> back_vsi ;
169- struct ice_pf * pf = iwdev -> rf -> cdev ;
167+ struct iidc_rdma_core_dev_info * cdev_info ;
170168 struct iidc_rdma_qset_params qset = {};
171169 int ret ;
172170
171+ cdev_info = iwdev -> rf -> cdev ;
173172 qset .qs_handle = tc_node -> qs_handle ;
174173 qset .tc = tc_node -> traffic_class ;
175174 qset .vport_id = vsi -> vsi_idx ;
176- ret = ice_add_rdma_qset (pf , & qset );
175+ ret = ice_add_rdma_qset (cdev_info , & qset );
177176 if (ret ) {
178177 ibdev_dbg (& iwdev -> ibdev , "WS: LAN alloc_res for rdma qset failed.\n" );
179178 return ret ;
@@ -194,19 +193,20 @@ static void irdma_lan_unregister_qset(struct irdma_sc_vsi *vsi,
194193 struct irdma_ws_node * tc_node )
195194{
196195 struct irdma_device * iwdev = vsi -> back_vsi ;
197- struct ice_pf * pf = iwdev -> rf -> cdev ;
196+ struct iidc_rdma_core_dev_info * cdev_info ;
198197 struct iidc_rdma_qset_params qset = {};
199198
199+ cdev_info = iwdev -> rf -> cdev ;
200200 qset .qs_handle = tc_node -> qs_handle ;
201201 qset .tc = tc_node -> traffic_class ;
202202 qset .vport_id = vsi -> vsi_idx ;
203203 qset .teid = tc_node -> l2_sched_node_id ;
204204
205- if (ice_del_rdma_qset (pf , & qset ))
205+ if (ice_del_rdma_qset (cdev_info , & qset ))
206206 ibdev_dbg (& iwdev -> ibdev , "WS: LAN free_res for rdma qset failed.\n" );
207207}
208208
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 )
210210{
211211 int i ;
212212
@@ -217,12 +217,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
217217 return - ENOMEM ;
218218
219219 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 ]))
221221 break ;
222222
223223 if (i < IRDMA_MIN_MSIX ) {
224224 for (; i > 0 ; i -- )
225- ice_free_rdma_qvector (pf , & rf -> msix_entries [i ]);
225+ ice_free_rdma_qvector (cdev , & rf -> msix_entries [i ]);
226226
227227 kfree (rf -> msix_entries );
228228 return - ENOMEM ;
@@ -233,12 +233,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
233233 return 0 ;
234234}
235235
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 )
237237{
238238 int i ;
239239
240240 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 ]);
242242
243243 kfree (rf -> msix_entries );
244244}
@@ -247,41 +247,49 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
247247{
248248 struct irdma_device * iwdev = auxiliary_get_drvdata (aux_dev );
249249 struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
250- struct ice_pf * pf ;
250+ struct iidc_rdma_core_dev_info * cdev_info ;
251251
252252 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 ;
254254
255+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , false);
255256 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 );
258258
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 ));
260260}
261261
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 )
264264{
265+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
265266 struct irdma_pci_f * rf = iwdev -> rf ;
266267
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 ;
268275 rf -> gen_ops .register_qset = irdma_lan_register_qset ;
269276 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 ;
276282 rf -> rdma_ver = IRDMA_GEN_2 ;
277283 rf -> rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT ;
278284 rf -> rst_to = IRDMA_RST_TIMEOUT_HZ ;
279285 rf -> gen_ops .request_reset = irdma_request_reset ;
280286 rf -> limits_sel = 7 ;
281287 rf -> iwdev = iwdev ;
288+
282289 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 ;
285293 iwdev -> init_state = INITIAL_STATE ;
286294 iwdev -> roce_cwnd = IRDMA_ROCE_CWND_DEFAULT ;
287295 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
294302static int irdma_probe (struct auxiliary_device * aux_dev , const struct auxiliary_device_id * id )
295303{
296304 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 ;
298307 struct irdma_l2params l2params = {};
299308 struct irdma_device * iwdev ;
300309 struct irdma_pci_f * rf ;
301- struct ice_vsi * vsi ;
302- struct ice_pf * pf ;
303310 int err ;
304311
305312 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 ;
308315
309- if (!vsi )
310- return - EIO ;
311316 iwdev = ib_alloc_device (irdma_device , ibdev );
312317 if (!iwdev )
313318 return - ENOMEM ;
@@ -317,10 +322,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
317322 return - ENOMEM ;
318323 }
319324
320- irdma_fill_device_info (iwdev , pf , vsi );
325+ irdma_fill_device_info (iwdev , cdev_info );
321326 rf = iwdev -> rf ;
322327
323- err = irdma_init_interrupts (rf , pf );
328+ err = irdma_init_interrupts (rf , cdev_info );
324329 if (err )
325330 goto err_init_interrupts ;
326331
@@ -329,8 +334,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
329334 goto err_ctrl_init ;
330335
331336 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 );
334338 if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
335339 iwdev -> dcb_vlan_mode = l2params .num_tc > 1 && !l2params .dscp_mode ;
336340
@@ -342,7 +346,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
342346 if (err )
343347 goto err_ibreg ;
344348
345- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , true);
349+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , true);
346350
347351 ibdev_dbg (& iwdev -> ibdev , "INIT: Gen2 PF[%d] device probe success\n" , PCI_FUNC (rf -> pcidev -> devfn ));
348352 auxiliary_set_drvdata (aux_dev , iwdev );
@@ -354,7 +358,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
354358err_rt_init :
355359 irdma_ctrl_deinit_hw (rf );
356360err_ctrl_init :
357- irdma_deinit_interrupts (rf , pf );
361+ irdma_deinit_interrupts (rf , cdev_info );
358362err_init_interrupts :
359363 kfree (iwdev -> rf );
360364 ib_dealloc_device (& iwdev -> ibdev );
0 commit comments