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, <e1000-rdma@lists.sourceforge.net>" );
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,43 +247,51 @@ 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
259259 kfree (iwdev -> rf );
260260
261- pr_debug ("INIT: Gen2 PF[%d] device remove success\n" , PCI_FUNC (pf -> pdev -> devfn ));
261+ pr_debug ("INIT: Gen2 PF[%d] device remove success\n" , PCI_FUNC (cdev_info -> pdev -> devfn ));
262262}
263263
264- static void irdma_fill_device_info (struct irdma_device * iwdev , struct ice_pf * pf ,
265- struct ice_vsi * vsi )
264+ static void irdma_fill_device_info (struct irdma_device * iwdev ,
265+ struct iidc_rdma_core_dev_info * cdev_info )
266266{
267+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
267268 struct irdma_pci_f * rf = iwdev -> rf ;
268269
269- rf -> cdev = pf ;
270+ rf -> sc_dev .hw = & rf -> hw ;
271+ rf -> iwdev = iwdev ;
272+ rf -> cdev = cdev_info ;
273+ rf -> hw .hw_addr = iidc_priv -> hw_addr ;
274+ rf -> pcidev = cdev_info -> pdev ;
275+ rf -> hw .device = & rf -> pcidev -> dev ;
276+ rf -> pf_id = iidc_priv -> pf_id ;
270277 rf -> gen_ops .register_qset = irdma_lan_register_qset ;
271278 rf -> gen_ops .unregister_qset = irdma_lan_unregister_qset ;
272- rf -> hw .hw_addr = pf -> hw .hw_addr ;
273- rf -> pcidev = pf -> pdev ;
274- rf -> pf_id = pf -> hw .pf_id ;
275- rf -> default_vsi .vsi_idx = vsi -> vsi_num ;
276- rf -> protocol_used = pf -> rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
277- IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY ;
279+
280+ rf -> default_vsi .vsi_idx = iidc_priv -> vport_id ;
281+ rf -> protocol_used =
282+ cdev_info -> rdma_protocol == IIDC_RDMA_PROTOCOL_ROCEV2 ?
283+ IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY ;
278284 rf -> rdma_ver = IRDMA_GEN_2 ;
279285 rf -> rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT ;
280286 rf -> rst_to = IRDMA_RST_TIMEOUT_HZ ;
281287 rf -> gen_ops .request_reset = irdma_request_reset ;
282288 rf -> limits_sel = 7 ;
283289 rf -> iwdev = iwdev ;
290+
284291 mutex_init (& iwdev -> ah_tbl_lock );
285- iwdev -> netdev = vsi -> netdev ;
286- iwdev -> vsi_num = vsi -> vsi_num ;
292+
293+ iwdev -> netdev = iidc_priv -> netdev ;
294+ iwdev -> vsi_num = iidc_priv -> vport_id ;
287295 iwdev -> init_state = INITIAL_STATE ;
288296 iwdev -> roce_cwnd = IRDMA_ROCE_CWND_DEFAULT ;
289297 iwdev -> roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT ;
@@ -296,20 +304,17 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
296304static int irdma_probe (struct auxiliary_device * aux_dev , const struct auxiliary_device_id * id )
297305{
298306 struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
299- struct iidc_rdma_qos_params qos_info = {};
307+ struct iidc_rdma_core_dev_info * cdev_info ;
308+ struct iidc_rdma_priv_dev_info * iidc_priv ;
300309 struct irdma_l2params l2params = {};
301310 struct irdma_device * iwdev ;
302311 struct irdma_pci_f * rf ;
303- struct ice_vsi * vsi ;
304- struct ice_pf * pf ;
305312 int err ;
306313
307314 iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
308- pf = iidc_adev -> pf ;
309- vsi = ice_get_main_vsi ( pf ) ;
315+ cdev_info = iidc_adev -> cdev_info ;
316+ iidc_priv = cdev_info -> iidc_priv ;
310317
311- if (!vsi )
312- return - EIO ;
313318 iwdev = ib_alloc_device (irdma_device , ibdev );
314319 if (!iwdev )
315320 return - ENOMEM ;
@@ -319,10 +324,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
319324 return - ENOMEM ;
320325 }
321326
322- irdma_fill_device_info (iwdev , pf , vsi );
327+ irdma_fill_device_info (iwdev , cdev_info );
323328 rf = iwdev -> rf ;
324329
325- err = irdma_init_interrupts (rf , pf );
330+ err = irdma_init_interrupts (rf , cdev_info );
326331 if (err )
327332 goto err_init_interrupts ;
328333
@@ -331,8 +336,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
331336 goto err_ctrl_init ;
332337
333338 l2params .mtu = iwdev -> netdev -> mtu ;
334- ice_get_qos_params (pf , & qos_info );
335- irdma_fill_qos_info (& l2params , & qos_info );
339+ irdma_fill_qos_info (& l2params , & iidc_priv -> qos_info );
336340 if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
337341 iwdev -> dcb_vlan_mode = l2params .num_tc > 1 && !l2params .dscp_mode ;
338342
@@ -344,7 +348,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
344348 if (err )
345349 goto err_ibreg ;
346350
347- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , true);
351+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , true);
348352
349353 ibdev_dbg (& iwdev -> ibdev , "INIT: Gen2 PF[%d] device probe success\n" , PCI_FUNC (rf -> pcidev -> devfn ));
350354 auxiliary_set_drvdata (aux_dev , iwdev );
@@ -356,7 +360,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
356360err_rt_init :
357361 irdma_ctrl_deinit_hw (rf );
358362err_ctrl_init :
359- irdma_deinit_interrupts (rf , pf );
363+ irdma_deinit_interrupts (rf , cdev_info );
360364err_init_interrupts :
361365 kfree (iwdev -> rf );
362366 ib_dealloc_device (& iwdev -> ibdev );
0 commit comments