Lines Matching full:pf
11 #define ENETC_DRV_NAME_STR "ENETC PF driver"
54 static void enetc_enable_si_vlan_promisc(struct enetc_pf *pf, int si_idx) in enetc_enable_si_vlan_promisc() argument
56 pf->vlan_promisc_simap |= BIT(si_idx); in enetc_enable_si_vlan_promisc()
57 enetc_set_vlan_promisc(&pf->si->hw, pf->vlan_promisc_simap); in enetc_enable_si_vlan_promisc()
60 static void enetc_disable_si_vlan_promisc(struct enetc_pf *pf, int si_idx) in enetc_disable_si_vlan_promisc() argument
62 pf->vlan_promisc_simap &= ~BIT(si_idx); in enetc_disable_si_vlan_promisc()
63 enetc_set_vlan_promisc(&pf->si->hw, pf->vlan_promisc_simap); in enetc_disable_si_vlan_promisc()
145 static void enetc_sync_mac_filters(struct enetc_pf *pf) in enetc_sync_mac_filters() argument
147 struct enetc_mac_filter *f = pf->mac_filter; in enetc_sync_mac_filters()
148 struct enetc_si *si = pf->si; in enetc_sync_mac_filters()
192 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_rx_mode() local
193 char vlan_promisc_simap = pf->vlan_promisc_simap; in enetc_pf_set_rx_mode()
202 /* enable promisc mode for SI0 (PF) */ in enetc_pf_set_rx_mode()
206 /* Enable VLAN promiscuous mode for SI0 (PF) */ in enetc_pf_set_rx_mode()
209 /* enable multi cast promisc mode for SI0 (PF) */ in enetc_pf_set_rx_mode()
214 enetc_set_vlan_promisc(&pf->si->hw, vlan_promisc_simap); in enetc_pf_set_rx_mode()
216 /* first 2 filter entries belong to PF */ in enetc_pf_set_rx_mode()
219 filter = &pf->mac_filter[UC]; in enetc_pf_set_rx_mode()
235 filter = &pf->mac_filter[MC]; in enetc_pf_set_rx_mode()
247 /* update PF entries */ in enetc_pf_set_rx_mode()
248 enetc_sync_mac_filters(pf); in enetc_pf_set_rx_mode()
273 static void enetc_sync_vlan_ht_filter(struct enetc_pf *pf, bool rehash) in enetc_sync_vlan_ht_filter() argument
278 bitmap_zero(pf->vlan_ht_filter, ENETC_VLAN_HT_SIZE); in enetc_sync_vlan_ht_filter()
280 for_each_set_bit(i, pf->active_vlans, VLAN_N_VID) { in enetc_sync_vlan_ht_filter()
283 __set_bit(hidx, pf->vlan_ht_filter); in enetc_sync_vlan_ht_filter()
287 enetc_set_vlan_ht_filter(&pf->si->hw, 0, (u32 *)pf->vlan_ht_filter); in enetc_sync_vlan_ht_filter()
293 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_vlan_rx_add_vid() local
296 __set_bit(vid, pf->active_vlans); in enetc_vlan_rx_add_vid()
299 if (!__test_and_set_bit(idx, pf->vlan_ht_filter)) in enetc_vlan_rx_add_vid()
300 enetc_sync_vlan_ht_filter(pf, false); in enetc_vlan_rx_add_vid()
308 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_vlan_rx_del_vid() local
310 __clear_bit(vid, pf->active_vlans); in enetc_vlan_rx_del_vid()
311 enetc_sync_vlan_ht_filter(pf, true); in enetc_vlan_rx_del_vid()
343 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_mac() local
346 if (vf >= pf->total_vfs) in enetc_pf_set_vf_mac()
352 vf_state = &pf->vf_state[vf]; in enetc_pf_set_vf_mac()
362 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_vlan() local
367 if (vf >= pf->total_vfs) in enetc_pf_set_vf_vlan()
381 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_spoofchk() local
384 if (vf >= pf->total_vfs) in enetc_pf_set_vf_spoofchk()
397 struct enetc_pf *pf = enetc_si_priv(si); in enetc_port_setup_primary_mac_address() local
401 /* check MAC addresses for PF and all VFs, if any is 0 set it ro rand */ in enetc_port_setup_primary_mac_address()
402 for (i = 0; i < pf->total_vfs + 1; i++) { in enetc_port_setup_primary_mac_address()
415 struct enetc_pf *pf = enetc_si_priv(si); in enetc_port_assign_rfs_entries() local
423 vf_entries = num_entries / (pf->total_vfs + 1); in enetc_port_assign_rfs_entries()
425 for (i = 0; i < pf->total_vfs; i++) in enetc_port_assign_rfs_entries()
428 num_entries - vf_entries * pf->total_vfs); in enetc_port_assign_rfs_entries()
436 struct enetc_pf *pf = enetc_si_priv(si); in enetc_port_si_configure() local
457 /* Add default one-time settings for SI0 (PF) */ in enetc_port_si_configure()
470 num_rings /= pf->total_vfs; in enetc_port_si_configure()
475 for (i = 0; i < pf->total_vfs; i++) in enetc_port_si_configure()
535 static void enetc_configure_port(struct enetc_pf *pf) in enetc_configure_port() argument
538 struct enetc_hw *hw = &pf->si->hw; in enetc_configure_port()
544 enetc_port_si_configure(pf->si); in enetc_configure_port()
551 enetc_port_assign_rfs_entries(pf->si); in enetc_configure_port()
554 enetc_port_setup_primary_mac_address(pf->si); in enetc_configure_port()
557 pf->vlan_promisc_simap = ENETC_VLAN_PROMISC_MAP_ALL; in enetc_configure_port()
558 enetc_set_vlan_promisc(hw, pf->vlan_promisc_simap); in enetc_configure_port()
567 static u16 enetc_msg_pf_set_vf_primary_mac_addr(struct enetc_pf *pf, in enetc_msg_pf_set_vf_primary_mac_addr() argument
570 struct enetc_vf_state *vf_state = &pf->vf_state[vf_id]; in enetc_msg_pf_set_vf_primary_mac_addr()
571 struct enetc_msg_swbd *msg = &pf->rxmsg[vf_id]; in enetc_msg_pf_set_vf_primary_mac_addr()
573 struct device *dev = &pf->si->pdev->dev; in enetc_msg_pf_set_vf_primary_mac_addr()
584 dev_warn(dev, "Attempt to override PF set mac addr for VF%d\n", in enetc_msg_pf_set_vf_primary_mac_addr()
587 enetc_pf_set_primary_mac_addr(&pf->si->hw, vf_id + 1, addr); in enetc_msg_pf_set_vf_primary_mac_addr()
592 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id, u16 *status) in enetc_msg_handle_rxmsg() argument
594 struct enetc_msg_swbd *msg = &pf->rxmsg[vf_id]; in enetc_msg_handle_rxmsg()
595 struct device *dev = &pf->si->pdev->dev; in enetc_msg_handle_rxmsg()
605 *status = enetc_msg_pf_set_vf_primary_mac_addr(pf, vf_id); in enetc_msg_handle_rxmsg()
617 struct enetc_pf *pf = enetc_si_priv(si); in enetc_sriov_configure() local
621 enetc_msg_psi_free(pf); in enetc_sriov_configure()
622 kfree(pf->vf_state); in enetc_sriov_configure()
623 pf->num_vfs = 0; in enetc_sriov_configure()
626 pf->num_vfs = num_vfs; in enetc_sriov_configure()
628 pf->vf_state = kcalloc(num_vfs, sizeof(struct enetc_vf_state), in enetc_sriov_configure()
630 if (!pf->vf_state) { in enetc_sriov_configure()
631 pf->num_vfs = 0; in enetc_sriov_configure()
635 err = enetc_msg_psi_init(pf); in enetc_sriov_configure()
651 enetc_msg_psi_free(pf); in enetc_sriov_configure()
653 kfree(pf->vf_state); in enetc_sriov_configure()
654 pf->num_vfs = 0; in enetc_sriov_configure()
669 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_features() local
672 enetc_disable_si_vlan_promisc(pf, 0); in enetc_pf_set_features()
674 enetc_enable_si_vlan_promisc(pf, 0); in enetc_pf_set_features()
748 static int enetc_mdio_probe(struct enetc_pf *pf, struct device_node *np) in enetc_mdio_probe() argument
750 struct device *dev = &pf->si->pdev->dev; in enetc_mdio_probe()
764 mdio_priv->hw = &pf->si->hw; in enetc_mdio_probe()
774 pf->mdio = bus; in enetc_mdio_probe()
779 static void enetc_mdio_remove(struct enetc_pf *pf) in enetc_mdio_remove() argument
781 if (pf->mdio) in enetc_mdio_remove()
782 mdiobus_unregister(pf->mdio); in enetc_mdio_remove()
785 static int enetc_imdio_create(struct enetc_pf *pf) in enetc_imdio_create() argument
787 struct device *dev = &pf->si->pdev->dev; in enetc_imdio_create()
804 mdio_priv->hw = &pf->si->hw; in enetc_imdio_create()
829 pf->imdio = bus; in enetc_imdio_create()
830 pf->pcs = pcs_lynx; in enetc_imdio_create()
841 static void enetc_imdio_remove(struct enetc_pf *pf) in enetc_imdio_remove() argument
843 if (pf->pcs) { in enetc_imdio_remove()
844 mdio_device_free(pf->pcs->mdio); in enetc_imdio_remove()
845 lynx_pcs_destroy(pf->pcs); in enetc_imdio_remove()
847 if (pf->imdio) { in enetc_imdio_remove()
848 mdiobus_unregister(pf->imdio); in enetc_imdio_remove()
849 mdiobus_free(pf->imdio); in enetc_imdio_remove()
853 static bool enetc_port_has_pcs(struct enetc_pf *pf) in enetc_port_has_pcs() argument
855 return (pf->if_mode == PHY_INTERFACE_MODE_SGMII || in enetc_port_has_pcs()
856 pf->if_mode == PHY_INTERFACE_MODE_2500BASEX || in enetc_port_has_pcs()
857 pf->if_mode == PHY_INTERFACE_MODE_USXGMII); in enetc_port_has_pcs()
860 static int enetc_mdiobus_create(struct enetc_pf *pf) in enetc_mdiobus_create() argument
862 struct device *dev = &pf->si->pdev->dev; in enetc_mdiobus_create()
868 err = enetc_mdio_probe(pf, mdio_np); in enetc_mdiobus_create()
875 if (enetc_port_has_pcs(pf)) { in enetc_mdiobus_create()
876 err = enetc_imdio_create(pf); in enetc_mdiobus_create()
878 enetc_mdio_remove(pf); in enetc_mdiobus_create()
886 static void enetc_mdiobus_destroy(struct enetc_pf *pf) in enetc_mdiobus_destroy() argument
888 enetc_mdio_remove(pf); in enetc_mdiobus_destroy()
889 enetc_imdio_remove(pf); in enetc_mdiobus_destroy()
937 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_config() local
940 enetc_mac_config(&pf->si->hw, state->interface); in enetc_pl_mac_config()
942 priv = netdev_priv(pf->si->ndev); in enetc_pl_mac_config()
943 if (pf->pcs) in enetc_pl_mac_config()
944 phylink_set_pcs(priv->phylink, &pf->pcs->pcs); in enetc_pl_mac_config()
952 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_link_up() local
955 priv = netdev_priv(pf->si->ndev); in enetc_pl_mac_link_up()
959 enetc_mac_enable(&pf->si->hw, true); in enetc_pl_mac_link_up()
966 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_link_down() local
968 enetc_mac_enable(&pf->si->hw, false); in enetc_pl_mac_link_down()
980 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_phylink_create() local
981 struct device *dev = &pf->si->pdev->dev; in enetc_phylink_create()
985 pf->phylink_config.dev = &priv->ndev->dev; in enetc_phylink_create()
986 pf->phylink_config.type = PHYLINK_NETDEV; in enetc_phylink_create()
988 phylink = phylink_create(&pf->phylink_config, in enetc_phylink_create()
990 pf->if_mode, &enetc_mac_phylink_ops); in enetc_phylink_create()
1013 struct enetc_pf *pf; in enetc_pf_probe() local
1021 err = enetc_pci_probe(pdev, KBUILD_MODNAME, sizeof(*pf)); in enetc_pf_probe()
1030 dev_err(&pdev->dev, "could not map PF space, probing a VF?\n"); in enetc_pf_probe()
1034 pf = enetc_si_priv(si); in enetc_pf_probe()
1035 pf->si = si; in enetc_pf_probe()
1036 pf->total_vfs = pci_sriov_get_totalvfs(pdev); in enetc_pf_probe()
1038 enetc_configure_port(pf); in enetc_pf_probe()
1067 if (!of_get_phy_mode(pdev->dev.of_node, &pf->if_mode)) { in enetc_pf_probe()
1068 err = enetc_mdiobus_create(pf); in enetc_pf_probe()
1086 enetc_mdiobus_destroy(pf); in enetc_pf_probe()
1104 struct enetc_pf *pf = enetc_si_priv(si); in enetc_pf_remove() local
1109 enetc_mdiobus_destroy(pf); in enetc_pf_remove()
1111 if (pf->num_vfs) in enetc_pf_remove()