Lines Matching full:pf
15 #define ENETC_DRV_NAME_STR "ENETC PF driver"
58 static void enetc_enable_si_vlan_promisc(struct enetc_pf *pf, int si_idx) in enetc_enable_si_vlan_promisc() argument
60 pf->vlan_promisc_simap |= BIT(si_idx); in enetc_enable_si_vlan_promisc()
61 enetc_set_vlan_promisc(&pf->si->hw, pf->vlan_promisc_simap); in enetc_enable_si_vlan_promisc()
64 static void enetc_disable_si_vlan_promisc(struct enetc_pf *pf, int si_idx) in enetc_disable_si_vlan_promisc() argument
66 pf->vlan_promisc_simap &= ~BIT(si_idx); in enetc_disable_si_vlan_promisc()
67 enetc_set_vlan_promisc(&pf->si->hw, pf->vlan_promisc_simap); in enetc_disable_si_vlan_promisc()
153 static void enetc_sync_mac_filters(struct enetc_pf *pf) in enetc_sync_mac_filters() argument
155 struct enetc_mac_filter *f = pf->mac_filter; in enetc_sync_mac_filters()
156 struct enetc_si *si = pf->si; in enetc_sync_mac_filters()
200 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_rx_mode() local
209 /* enable promisc mode for SI0 (PF) */ in enetc_pf_set_rx_mode()
214 /* enable multi cast promisc mode for SI0 (PF) */ in enetc_pf_set_rx_mode()
219 /* first 2 filter entries belong to PF */ in enetc_pf_set_rx_mode()
222 filter = &pf->mac_filter[UC]; in enetc_pf_set_rx_mode()
238 filter = &pf->mac_filter[MC]; in enetc_pf_set_rx_mode()
250 /* update PF entries */ in enetc_pf_set_rx_mode()
251 enetc_sync_mac_filters(pf); in enetc_pf_set_rx_mode()
276 static void enetc_sync_vlan_ht_filter(struct enetc_pf *pf, bool rehash) in enetc_sync_vlan_ht_filter() argument
281 bitmap_zero(pf->vlan_ht_filter, ENETC_VLAN_HT_SIZE); in enetc_sync_vlan_ht_filter()
283 for_each_set_bit(i, pf->active_vlans, VLAN_N_VID) { in enetc_sync_vlan_ht_filter()
286 __set_bit(hidx, pf->vlan_ht_filter); in enetc_sync_vlan_ht_filter()
290 enetc_set_vlan_ht_filter(&pf->si->hw, 0, *pf->vlan_ht_filter); in enetc_sync_vlan_ht_filter()
296 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_vlan_rx_add_vid() local
299 __set_bit(vid, pf->active_vlans); in enetc_vlan_rx_add_vid()
302 if (!__test_and_set_bit(idx, pf->vlan_ht_filter)) in enetc_vlan_rx_add_vid()
303 enetc_sync_vlan_ht_filter(pf, false); in enetc_vlan_rx_add_vid()
311 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_vlan_rx_del_vid() local
313 __clear_bit(vid, pf->active_vlans); in enetc_vlan_rx_del_vid()
314 enetc_sync_vlan_ht_filter(pf, true); in enetc_vlan_rx_del_vid()
346 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_mac() local
349 if (vf >= pf->total_vfs) in enetc_pf_set_vf_mac()
355 vf_state = &pf->vf_state[vf]; in enetc_pf_set_vf_mac()
365 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_vlan() local
370 if (vf >= pf->total_vfs) in enetc_pf_set_vf_vlan()
384 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_vf_spoofchk() local
387 if (vf >= pf->total_vfs) in enetc_pf_set_vf_spoofchk()
397 static int enetc_setup_mac_address(struct device_node *np, struct enetc_pf *pf, in enetc_setup_mac_address() argument
400 struct device *dev = &pf->si->pdev->dev; in enetc_setup_mac_address()
401 struct enetc_hw *hw = &pf->si->hw; in enetc_setup_mac_address()
429 struct enetc_pf *pf) in enetc_setup_mac_addresses() argument
433 /* The PF might take its MAC from the device tree */ in enetc_setup_mac_addresses()
434 err = enetc_setup_mac_address(np, pf, 0); in enetc_setup_mac_addresses()
438 for (i = 0; i < pf->total_vfs; i++) { in enetc_setup_mac_addresses()
439 err = enetc_setup_mac_address(NULL, pf, i + 1); in enetc_setup_mac_addresses()
449 struct enetc_pf *pf = enetc_si_priv(si); in enetc_port_assign_rfs_entries() local
457 vf_entries = num_entries / (pf->total_vfs + 1); in enetc_port_assign_rfs_entries()
459 for (i = 0; i < pf->total_vfs; i++) in enetc_port_assign_rfs_entries()
462 num_entries - vf_entries * pf->total_vfs); in enetc_port_assign_rfs_entries()
470 struct enetc_pf *pf = enetc_si_priv(si); in enetc_port_si_configure() local
491 /* Add default one-time settings for SI0 (PF) */ in enetc_port_si_configure()
504 num_rings /= pf->total_vfs; in enetc_port_si_configure()
509 for (i = 0; i < pf->total_vfs; i++) in enetc_port_si_configure()
602 static void enetc_configure_port(struct enetc_pf *pf) in enetc_configure_port() argument
605 struct enetc_hw *hw = &pf->si->hw; in enetc_configure_port()
611 enetc_port_si_configure(pf->si); in enetc_configure_port()
618 enetc_port_assign_rfs_entries(pf->si); in enetc_configure_port()
621 pf->vlan_promisc_simap = ENETC_VLAN_PROMISC_MAP_ALL; in enetc_configure_port()
622 enetc_set_vlan_promisc(hw, pf->vlan_promisc_simap); in enetc_configure_port()
631 static u16 enetc_msg_pf_set_vf_primary_mac_addr(struct enetc_pf *pf, in enetc_msg_pf_set_vf_primary_mac_addr() argument
634 struct enetc_vf_state *vf_state = &pf->vf_state[vf_id]; in enetc_msg_pf_set_vf_primary_mac_addr()
635 struct enetc_msg_swbd *msg = &pf->rxmsg[vf_id]; in enetc_msg_pf_set_vf_primary_mac_addr()
637 struct device *dev = &pf->si->pdev->dev; in enetc_msg_pf_set_vf_primary_mac_addr()
648 dev_warn(dev, "Attempt to override PF set mac addr for VF%d\n", in enetc_msg_pf_set_vf_primary_mac_addr()
651 enetc_pf_set_primary_mac_addr(&pf->si->hw, vf_id + 1, addr); in enetc_msg_pf_set_vf_primary_mac_addr()
656 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id, u16 *status) in enetc_msg_handle_rxmsg() argument
658 struct enetc_msg_swbd *msg = &pf->rxmsg[vf_id]; in enetc_msg_handle_rxmsg()
659 struct device *dev = &pf->si->pdev->dev; in enetc_msg_handle_rxmsg()
669 *status = enetc_msg_pf_set_vf_primary_mac_addr(pf, vf_id); in enetc_msg_handle_rxmsg()
681 struct enetc_pf *pf = enetc_si_priv(si); in enetc_sriov_configure() local
685 enetc_msg_psi_free(pf); in enetc_sriov_configure()
686 kfree(pf->vf_state); in enetc_sriov_configure()
687 pf->num_vfs = 0; in enetc_sriov_configure()
690 pf->num_vfs = num_vfs; in enetc_sriov_configure()
692 pf->vf_state = kcalloc(num_vfs, sizeof(struct enetc_vf_state), in enetc_sriov_configure()
694 if (!pf->vf_state) { in enetc_sriov_configure()
695 pf->num_vfs = 0; in enetc_sriov_configure()
699 err = enetc_msg_psi_init(pf); in enetc_sriov_configure()
715 enetc_msg_psi_free(pf); in enetc_sriov_configure()
717 kfree(pf->vf_state); in enetc_sriov_configure()
718 pf->num_vfs = 0; in enetc_sriov_configure()
740 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_pf_set_features() local
743 enetc_disable_si_vlan_promisc(pf, 0); in enetc_pf_set_features()
745 enetc_enable_si_vlan_promisc(pf, 0); in enetc_pf_set_features()
839 static int enetc_mdio_probe(struct enetc_pf *pf, struct device_node *np) in enetc_mdio_probe() argument
841 struct device *dev = &pf->si->pdev->dev; in enetc_mdio_probe()
855 mdio_priv->hw = &pf->si->hw; in enetc_mdio_probe()
863 pf->mdio = bus; in enetc_mdio_probe()
868 static void enetc_mdio_remove(struct enetc_pf *pf) in enetc_mdio_remove() argument
870 if (pf->mdio) in enetc_mdio_remove()
871 mdiobus_unregister(pf->mdio); in enetc_mdio_remove()
874 static int enetc_imdio_create(struct enetc_pf *pf) in enetc_imdio_create() argument
876 struct device *dev = &pf->si->pdev->dev; in enetc_imdio_create()
893 mdio_priv->hw = &pf->si->hw; in enetc_imdio_create()
918 pf->imdio = bus; in enetc_imdio_create()
919 pf->pcs = phylink_pcs; in enetc_imdio_create()
930 static void enetc_imdio_remove(struct enetc_pf *pf) in enetc_imdio_remove() argument
934 if (pf->pcs) { in enetc_imdio_remove()
935 mdio_device = lynx_get_mdio_device(pf->pcs); in enetc_imdio_remove()
937 lynx_pcs_destroy(pf->pcs); in enetc_imdio_remove()
939 if (pf->imdio) { in enetc_imdio_remove()
940 mdiobus_unregister(pf->imdio); in enetc_imdio_remove()
941 mdiobus_free(pf->imdio); in enetc_imdio_remove()
945 static bool enetc_port_has_pcs(struct enetc_pf *pf) in enetc_port_has_pcs() argument
947 return (pf->if_mode == PHY_INTERFACE_MODE_SGMII || in enetc_port_has_pcs()
948 pf->if_mode == PHY_INTERFACE_MODE_2500BASEX || in enetc_port_has_pcs()
949 pf->if_mode == PHY_INTERFACE_MODE_USXGMII); in enetc_port_has_pcs()
952 static int enetc_mdiobus_create(struct enetc_pf *pf, struct device_node *node) in enetc_mdiobus_create() argument
959 err = enetc_mdio_probe(pf, mdio_np); in enetc_mdiobus_create()
966 if (enetc_port_has_pcs(pf)) { in enetc_mdiobus_create()
967 err = enetc_imdio_create(pf); in enetc_mdiobus_create()
969 enetc_mdio_remove(pf); in enetc_mdiobus_create()
977 static void enetc_mdiobus_destroy(struct enetc_pf *pf) in enetc_mdiobus_destroy() argument
979 enetc_mdio_remove(pf); in enetc_mdiobus_destroy()
980 enetc_imdio_remove(pf); in enetc_mdiobus_destroy()
986 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_select_pcs() local
988 return pf->pcs; in enetc_pl_mac_select_pcs()
995 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_config() local
997 enetc_mac_config(&pf->si->hw, state->interface); in enetc_pl_mac_config()
1033 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_link_up() local
1036 struct enetc_hw *hw = &pf->si->hw; in enetc_pl_mac_link_up()
1041 priv = netdev_priv(pf->si->ndev); in enetc_pl_mac_link_up()
1043 if (pf->si->hw_features & ENETC_SI_F_QBV) in enetc_pl_mac_link_up()
1108 struct enetc_pf *pf = phylink_to_enetc_pf(config); in enetc_pl_mac_link_down() local
1110 enetc_mac_enable(&pf->si->hw, false); in enetc_pl_mac_link_down()
1124 struct enetc_pf *pf = enetc_si_priv(priv->si); in enetc_phylink_create() local
1128 pf->phylink_config.dev = &priv->ndev->dev; in enetc_phylink_create()
1129 pf->phylink_config.type = PHYLINK_NETDEV; in enetc_phylink_create()
1130 pf->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in enetc_phylink_create()
1134 pf->phylink_config.supported_interfaces); in enetc_phylink_create()
1136 pf->phylink_config.supported_interfaces); in enetc_phylink_create()
1138 pf->phylink_config.supported_interfaces); in enetc_phylink_create()
1140 pf->phylink_config.supported_interfaces); in enetc_phylink_create()
1141 phy_interface_set_rgmii(pf->phylink_config.supported_interfaces); in enetc_phylink_create()
1143 phylink = phylink_create(&pf->phylink_config, of_fwnode_handle(node), in enetc_phylink_create()
1144 pf->if_mode, &enetc_mac_phylink_ops); in enetc_phylink_create()
1161 * of this port (PF + VFs)
1211 /* Don't register with the IERB if the PF itself is disabled */ in enetc_pf_register_with_ierb()
1236 struct enetc_pf *pf; in enetc_pf_probe() local
1247 err = enetc_pci_probe(pdev, KBUILD_MODNAME, sizeof(*pf)); in enetc_pf_probe()
1254 dev_err(&pdev->dev, "could not map PF space, probing a VF?\n"); in enetc_pf_probe()
1281 pf = enetc_si_priv(si); in enetc_pf_probe()
1282 pf->si = si; in enetc_pf_probe()
1283 pf->total_vfs = pci_sriov_get_totalvfs(pdev); in enetc_pf_probe()
1285 err = enetc_setup_mac_addresses(node, pf); in enetc_pf_probe()
1289 enetc_configure_port(pf); in enetc_pf_probe()
1324 err = of_get_phy_mode(node, &pf->if_mode); in enetc_pf_probe()
1330 err = enetc_mdiobus_create(pf, node); in enetc_pf_probe()
1347 enetc_mdiobus_destroy(pf); in enetc_pf_probe()
1373 struct enetc_pf *pf = enetc_si_priv(si); in enetc_pf_remove() local
1378 if (pf->num_vfs) in enetc_pf_remove()
1384 enetc_mdiobus_destroy(pf); in enetc_pf_remove()