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
@@ -61,7 +59,7 @@ static void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev)
6159}
6260
6361static void irdma_fill_qos_info (struct irdma_l2params * l2params ,
64- struct iidc_qos_params * qos_info )
62+ struct iidc_rdma_qos_params * qos_info )
6563{
6664 int i ;
6765
@@ -85,38 +83,40 @@ 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_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
93- if (* event -> type & BIT (IIDC_EVENT_AFTER_MTU_CHANGE )) {
92+ if (* event -> type & BIT (IIDC_RDMA_EVENT_AFTER_MTU_CHANGE )) {
9493 ibdev_dbg (& iwdev -> ibdev , "CLNT: new MTU = %d\n" , iwdev -> netdev -> mtu );
9594 if (iwdev -> vsi .mtu != iwdev -> netdev -> mtu ) {
9695 l2params .mtu = iwdev -> netdev -> mtu ;
9796 l2params .mtu_changed = true;
9897 irdma_log_invalid_mtu (l2params .mtu , & iwdev -> rf -> sc_dev );
9998 irdma_change_l2params (& iwdev -> vsi , & l2params );
10099 }
101- } else if (* event -> type & BIT (IIDC_EVENT_BEFORE_TC_CHANGE )) {
100+ } else if (* event -> type & BIT (IIDC_RDMA_EVENT_BEFORE_TC_CHANGE )) {
102101 if (iwdev -> vsi .tc_change_pending )
103102 return ;
104103
105104 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 ;
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 );
119- } else if (* event -> type & BIT (IIDC_EVENT_CRIT_ERR )) {
119+ } else if (* event -> type & BIT (IIDC_RDMA_EVENT_CRIT_ERR )) {
120120 ibdev_warn (& iwdev -> ibdev , "ICE OICR event notification: oicr = 0x%08x\n" ,
121121 event -> reg );
122122 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
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,56 +233,65 @@ 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}
245245
246246static void irdma_remove (struct auxiliary_device * aux_dev )
247247{
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 ;
252248 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 ;
253254
255+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , false);
254256 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 );
257258
258259 kfree (iwdev -> rf );
259260
260- 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 ));
261262}
262263
263- static void irdma_fill_device_info (struct irdma_device * iwdev , struct ice_pf * pf ,
264- struct ice_vsi * vsi )
264+ static void irdma_fill_device_info (struct irdma_device * iwdev ,
265+ struct iidc_rdma_core_dev_info * cdev_info )
265266{
267+ struct iidc_rdma_priv_dev_info * iidc_priv = cdev_info -> iidc_priv ;
266268 struct irdma_pci_f * rf = iwdev -> rf ;
267269
268- 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 ;
269277 rf -> gen_ops .register_qset = irdma_lan_register_qset ;
270278 rf -> gen_ops .unregister_qset = irdma_lan_unregister_qset ;
271- rf -> hw .hw_addr = pf -> hw .hw_addr ;
272- rf -> pcidev = pf -> pdev ;
273- rf -> pf_id = pf -> hw .pf_id ;
274- rf -> default_vsi .vsi_idx = vsi -> vsi_num ;
275- rf -> protocol_used = pf -> rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
276- 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 ;
277284 rf -> rdma_ver = IRDMA_GEN_2 ;
278285 rf -> rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT ;
279286 rf -> rst_to = IRDMA_RST_TIMEOUT_HZ ;
280287 rf -> gen_ops .request_reset = irdma_request_reset ;
281288 rf -> limits_sel = 7 ;
282289 rf -> iwdev = iwdev ;
290+
283291 mutex_init (& iwdev -> ah_tbl_lock );
284- iwdev -> netdev = vsi -> netdev ;
285- iwdev -> vsi_num = vsi -> vsi_num ;
292+
293+ iwdev -> netdev = iidc_priv -> netdev ;
294+ iwdev -> vsi_num = iidc_priv -> vport_id ;
286295 iwdev -> init_state = INITIAL_STATE ;
287296 iwdev -> roce_cwnd = IRDMA_ROCE_CWND_DEFAULT ;
288297 iwdev -> roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT ;
@@ -294,19 +303,18 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
294303
295304static int irdma_probe (struct auxiliary_device * aux_dev , const struct auxiliary_device_id * id )
296305{
297- struct iidc_auxiliary_dev * iidc_adev = container_of (aux_dev ,
298- struct iidc_auxiliary_dev ,
299- adev );
300- struct ice_pf * pf = iidc_adev -> pf ;
301- struct ice_vsi * vsi = ice_get_main_vsi (pf );
302- struct iidc_qos_params qos_info = {};
306+ struct iidc_rdma_core_auxiliary_dev * iidc_adev ;
307+ struct iidc_rdma_core_dev_info * cdev_info ;
308+ struct iidc_rdma_priv_dev_info * iidc_priv ;
309+ struct irdma_l2params l2params = {};
303310 struct irdma_device * iwdev ;
304311 struct irdma_pci_f * rf ;
305- struct irdma_l2params l2params = {};
306312 int err ;
307313
308- if (!vsi )
309- return - EIO ;
314+ iidc_adev = container_of (aux_dev , struct iidc_rdma_core_auxiliary_dev , adev );
315+ cdev_info = iidc_adev -> cdev_info ;
316+ iidc_priv = cdev_info -> iidc_priv ;
317+
310318 iwdev = ib_alloc_device (irdma_device , ibdev );
311319 if (!iwdev )
312320 return - ENOMEM ;
@@ -316,10 +324,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
316324 return - ENOMEM ;
317325 }
318326
319- irdma_fill_device_info (iwdev , pf , vsi );
327+ irdma_fill_device_info (iwdev , cdev_info );
320328 rf = iwdev -> rf ;
321329
322- err = irdma_init_interrupts (rf , pf );
330+ err = irdma_init_interrupts (rf , cdev_info );
323331 if (err )
324332 goto err_init_interrupts ;
325333
@@ -328,8 +336,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
328336 goto err_ctrl_init ;
329337
330338 l2params .mtu = iwdev -> netdev -> mtu ;
331- ice_get_qos_params (pf , & qos_info );
332- irdma_fill_qos_info (& l2params , & qos_info );
339+ irdma_fill_qos_info (& l2params , & iidc_priv -> qos_info );
333340 if (iwdev -> rf -> protocol_used != IRDMA_IWARP_PROTOCOL_ONLY )
334341 iwdev -> dcb_vlan_mode = l2params .num_tc > 1 && !l2params .dscp_mode ;
335342
@@ -341,7 +348,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
341348 if (err )
342349 goto err_ibreg ;
343350
344- ice_rdma_update_vsi_filter (pf , iwdev -> vsi_num , true);
351+ ice_rdma_update_vsi_filter (cdev_info , iwdev -> vsi_num , true);
345352
346353 ibdev_dbg (& iwdev -> ibdev , "INIT: Gen2 PF[%d] device probe success\n" , PCI_FUNC (rf -> pcidev -> devfn ));
347354 auxiliary_set_drvdata (aux_dev , iwdev );
@@ -353,7 +360,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
353360err_rt_init :
354361 irdma_ctrl_deinit_hw (rf );
355362err_ctrl_init :
356- irdma_deinit_interrupts (rf , pf );
363+ irdma_deinit_interrupts (rf , cdev_info );
357364err_init_interrupts :
358365 kfree (iwdev -> rf );
359366 ib_dealloc_device (& iwdev -> ibdev );
@@ -369,7 +376,7 @@ static const struct auxiliary_device_id irdma_auxiliary_id_table[] = {
369376
370377MODULE_DEVICE_TABLE (auxiliary , irdma_auxiliary_id_table );
371378
372- static struct iidc_auxiliary_drv irdma_auxiliary_drv = {
379+ static struct iidc_rdma_core_auxiliary_drv irdma_auxiliary_drv = {
373380 .adrv = {
374381 .id_table = irdma_auxiliary_id_table ,
375382 .probe = irdma_probe ,
0 commit comments