aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_common.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_common.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index a4ce8a87fb0d..67301fe75482 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -259,6 +259,66 @@ ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
259} 259}
260 260
261/** 261/**
262 * ice_init_fltr_mgmt_struct - initializes filter management list and locks
263 * @hw: pointer to the hw struct
264 */
265static enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw)
266{
267 struct ice_switch_info *sw;
268
269 hw->switch_info = devm_kzalloc(ice_hw_to_dev(hw),
270 sizeof(*hw->switch_info), GFP_KERNEL);
271 sw = hw->switch_info;
272
273 if (!sw)
274 return ICE_ERR_NO_MEMORY;
275
276 INIT_LIST_HEAD(&sw->vsi_list_map_head);
277
278 mutex_init(&sw->mac_list_lock);
279 INIT_LIST_HEAD(&sw->mac_list_head);
280
281 mutex_init(&sw->vlan_list_lock);
282 INIT_LIST_HEAD(&sw->vlan_list_head);
283
284 mutex_init(&sw->eth_m_list_lock);
285 INIT_LIST_HEAD(&sw->eth_m_list_head);
286
287 mutex_init(&sw->promisc_list_lock);
288 INIT_LIST_HEAD(&sw->promisc_list_head);
289
290 mutex_init(&sw->mac_vlan_list_lock);
291 INIT_LIST_HEAD(&sw->mac_vlan_list_head);
292
293 return 0;
294}
295
296/**
297 * ice_cleanup_fltr_mgmt_struct - cleanup filter management list and locks
298 * @hw: pointer to the hw struct
299 */
300static void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw)
301{
302 struct ice_switch_info *sw = hw->switch_info;
303 struct ice_vsi_list_map_info *v_pos_map;
304 struct ice_vsi_list_map_info *v_tmp_map;
305
306 list_for_each_entry_safe(v_pos_map, v_tmp_map, &sw->vsi_list_map_head,
307 list_entry) {
308 list_del(&v_pos_map->list_entry);
309 devm_kfree(ice_hw_to_dev(hw), v_pos_map);
310 }
311
312 mutex_destroy(&sw->mac_list_lock);
313 mutex_destroy(&sw->vlan_list_lock);
314 mutex_destroy(&sw->eth_m_list_lock);
315 mutex_destroy(&sw->promisc_list_lock);
316 mutex_destroy(&sw->mac_vlan_list_lock);
317
318 devm_kfree(ice_hw_to_dev(hw), sw);
319}
320
321/**
262 * ice_init_hw - main hardware initialization routine 322 * ice_init_hw - main hardware initialization routine
263 * @hw: pointer to the hardware structure 323 * @hw: pointer to the hardware structure
264 */ 324 */
@@ -321,6 +381,8 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
321 if (status) 381 if (status)
322 goto err_unroll_alloc; 382 goto err_unroll_alloc;
323 383
384 hw->evb_veb = true;
385
324 /* Query the allocated resources for tx scheduler */ 386 /* Query the allocated resources for tx scheduler */
325 status = ice_sched_query_res_alloc(hw); 387 status = ice_sched_query_res_alloc(hw);
326 if (status) { 388 if (status) {
@@ -352,21 +414,27 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
352 if (status) 414 if (status)
353 goto err_unroll_sched; 415 goto err_unroll_sched;
354 416
417 status = ice_init_fltr_mgmt_struct(hw);
418 if (status)
419 goto err_unroll_sched;
420
355 /* Get port MAC information */ 421 /* Get port MAC information */
356 mac_buf_len = sizeof(struct ice_aqc_manage_mac_read_resp); 422 mac_buf_len = sizeof(struct ice_aqc_manage_mac_read_resp);
357 mac_buf = devm_kzalloc(ice_hw_to_dev(hw), mac_buf_len, GFP_KERNEL); 423 mac_buf = devm_kzalloc(ice_hw_to_dev(hw), mac_buf_len, GFP_KERNEL);
358 424
359 if (!mac_buf) 425 if (!mac_buf)
360 goto err_unroll_sched; 426 goto err_unroll_fltr_mgmt_struct;
361 427
362 status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL); 428 status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
363 devm_kfree(ice_hw_to_dev(hw), mac_buf); 429 devm_kfree(ice_hw_to_dev(hw), mac_buf);
364 430
365 if (status) 431 if (status)
366 goto err_unroll_sched; 432 goto err_unroll_fltr_mgmt_struct;
367 433
368 return 0; 434 return 0;
369 435
436err_unroll_fltr_mgmt_struct:
437 ice_cleanup_fltr_mgmt_struct(hw);
370err_unroll_sched: 438err_unroll_sched:
371 ice_sched_cleanup_all(hw); 439 ice_sched_cleanup_all(hw);
372err_unroll_alloc: 440err_unroll_alloc:
@@ -389,6 +457,8 @@ void ice_deinit_hw(struct ice_hw *hw)
389 devm_kfree(ice_hw_to_dev(hw), hw->port_info); 457 devm_kfree(ice_hw_to_dev(hw), hw->port_info);
390 hw->port_info = NULL; 458 hw->port_info = NULL;
391 } 459 }
460
461 ice_cleanup_fltr_mgmt_struct(hw);
392} 462}
393 463
394/** 464/**