Lines Matching refs:pf

15  * @pf: pointer to the PF struct
20 static void ice_eswitch_del_sp_rules(struct ice_pf *pf)
25 xa_for_each(&pf->eswitch.reprs, id, repr) {
27 ice_rem_adv_rule_by_id(&pf->hw, &repr->sp_rule);
33 * @pf: pointer to PF struct
39 static int ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
41 struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
44 struct ice_hw *hw = &pf->hw;
67 dev_err(ice_pf_to_dev(pf), "Unable to add slow-path rule for eswitch for PR %d",
75 ice_eswitch_add_sp_rules(struct ice_pf *pf)
81 xa_for_each(&pf->eswitch.reprs, id, repr) {
82 err = ice_eswitch_add_sp_rule(pf, repr);
84 ice_eswitch_del_sp_rules(pf);
94 * @pf: pointer to PF struct
99 static int ice_eswitch_setup_env(struct ice_pf *pf)
101 struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi;
102 struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
107 ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx);
211 * @pf: poiner to PF struct
215 ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr)
234 * @pf: pointer to PF struct
237 static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr)
239 struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
243 ice_remove_vsi_fltr(&pf->hw, vsi->idx);
285 struct ice_pf *pf = vsi->back;
289 if (!ice_is_switchdev_running(pf))
292 repr = xa_load(&pf->eswitch.reprs, repr_id);
306 dev_err(ice_pf_to_dev(pf), "Failed to update VSI of port representor %d",
369 * @pf: pointer to PF struct
374 static void ice_eswitch_release_env(struct ice_pf *pf)
376 struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi;
377 struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
394 * @pf: pointer to PF structure
398 ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
406 return ice_vsi_setup(pf, &params);
437 * @pf: pointer to PF structure
439 static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
443 uplink_vsi = ice_get_main_vsi(pf);
448 dev_err(ice_pf_to_dev(pf),
453 pf->eswitch.control_vsi = ice_eswitch_vsi_setup(pf, pf->hw.port_info);
454 if (!pf->eswitch.control_vsi)
457 ctrl_vsi = pf->eswitch.control_vsi;
459 pf->eswitch.qs.value = 1;
460 pf->eswitch.uplink_vsi = uplink_vsi;
462 if (ice_eswitch_setup_env(pf))
465 if (ice_eswitch_br_offloads_init(pf))
468 pf->eswitch.is_running = true;
473 ice_eswitch_release_env(pf);
481 * @pf: pointer to PF structure
483 static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
485 struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
487 ice_eswitch_br_offloads_deinit(pf);
488 ice_eswitch_release_env(pf);
491 pf->eswitch.is_running = false;
492 pf->eswitch.qs.is_reaching = false;
505 struct ice_pf *pf = devlink_priv(devlink);
507 if (pf->eswitch_mode == mode)
510 if (ice_has_vfs(pf)) {
511 dev_info(ice_pf_to_dev(pf), "Changing eswitch mode is allowed only if there is no VFs created");
518 dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
519 pf->hw.pf_id);
520 xa_destroy(&pf->eswitch.reprs);
525 if (ice_is_adq_active(pf)) {
526 dev_err(ice_pf_to_dev(pf), "Couldn't change eswitch mode to switchdev - ADQ is active. Delete ADQ configs and try again, e.g. tc qdisc del dev $PF root");
531 dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to switchdev",
532 pf->hw.pf_id);
533 xa_init_flags(&pf->eswitch.reprs, XA_FLAGS_ALLOC);
542 pf->eswitch_mode = mode;
553 struct ice_pf *pf = devlink_priv(devlink);
555 *mode = pf->eswitch_mode;
561 * @pf: pointer to PF structure
566 bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf)
568 return pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV;
573 * @pf: pointer to PF structure
575 static void ice_eswitch_start_all_tx_queues(struct ice_pf *pf)
580 if (test_bit(ICE_DOWN, pf->state))
583 xa_for_each(&pf->eswitch.reprs, id, repr)
589 * @pf: pointer to PF structure
591 void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf)
596 if (test_bit(ICE_DOWN, pf->state))
599 xa_for_each(&pf->eswitch.reprs, id, repr)
603 static void ice_eswitch_stop_reprs(struct ice_pf *pf)
605 ice_eswitch_del_sp_rules(pf);
606 ice_eswitch_stop_all_tx_queues(pf);
607 ice_eswitch_napi_disable(&pf->eswitch.reprs);
610 static void ice_eswitch_start_reprs(struct ice_pf *pf)
612 ice_eswitch_napi_enable(&pf->eswitch.reprs);
613 ice_eswitch_start_all_tx_queues(pf);
614 ice_eswitch_add_sp_rules(pf);
651 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
657 if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_LEGACY)
660 if (xa_empty(&pf->eswitch.reprs)) {
661 err = ice_eswitch_enable_switchdev(pf);
665 pf->eswitch.qs.to_reach -= 1;
669 ice_eswitch_stop_reprs(pf);
677 err = ice_eswitch_setup_repr(pf, repr);
681 err = xa_alloc(&pf->eswitch.reprs, &repr->id, repr,
688 ice_eswitch_cp_change_queues(&pf->eswitch, change);
689 ice_eswitch_start_reprs(pf);
694 ice_eswitch_release_repr(pf, repr);
698 if (xa_empty(&pf->eswitch.reprs))
699 ice_eswitch_disable_switchdev(pf);
700 ice_eswitch_start_reprs(pf);
705 void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf)
707 struct ice_repr *repr = xa_load(&pf->eswitch.reprs, vf->repr_id);
708 struct devlink *devlink = priv_to_devlink(pf);
713 ice_eswitch_stop_reprs(pf);
714 xa_erase(&pf->eswitch.reprs, repr->id);
716 if (xa_empty(&pf->eswitch.reprs))
717 ice_eswitch_disable_switchdev(pf);
719 ice_eswitch_cp_change_queues(&pf->eswitch, -1);
721 ice_eswitch_release_repr(pf, repr);
724 if (xa_empty(&pf->eswitch.reprs)) {
728 ice_devlink_rate_clear_tx_topology(ice_get_main_vsi(pf));
733 ice_eswitch_start_reprs(pf);
739 * @pf: pointer to PF structure
741 int ice_eswitch_rebuild(struct ice_pf *pf)
747 if (!ice_is_switchdev_running(pf))
750 err = ice_vsi_rebuild(pf->eswitch.control_vsi, ICE_VSI_FLAG_INIT);
754 xa_for_each(&pf->eswitch.reprs, id, repr)
755 ice_eswitch_detach(pf, repr->vf);
762 * @pf: pointer to PF structure
767 void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change)
769 if (pf->eswitch.qs.value + change < 0)
772 pf->eswitch.qs.to_reach = pf->eswitch.qs.value + change;
773 pf->eswitch.qs.is_reaching = true;