1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 2 /* Copyright 2017-2019 NXP */ 3 4 #include "enetc.h" 5 #include <linux/phylink.h> 6 7 #define ENETC_PF_NUM_RINGS 8 8 #define ENETC_VLAN_HT_SIZE 64 9 #define ENETC_VF_MC_HASH_BITS_MAX 8 /* For untrusted VFs */ 10 11 enum enetc_vf_flags { 12 ENETC_VF_FLAG_PF_SET_MAC = BIT(0), 13 ENETC_VF_FLAG_TRUSTED = BIT(1), 14 ENETC_VF_FLAG_UC_PROMISC = BIT(2), 15 ENETC_VF_FLAG_MC_PROMISC = BIT(3), 16 ENETC_VF_FLAG_SPOOFCHK = BIT(4), 17 }; 18 19 struct enetc_vf_state { 20 struct mutex lock; /* Prevent concurrent access */ 21 enum enetc_vf_flags flags; 22 /* Number of consecutive failures to send PF-to-VF messages */ 23 int msg_fail_cnt; 24 u8 tpid; /* SI-based VLAN TPID (0: 0x8100, 1: 0x88a8) */ 25 u8 qos; /* SI-based VLAN QOS (priority) bits */ 26 u16 vid; /* SI-based VLAN ID */ 27 }; 28 29 struct enetc_port_caps { 30 int num_msix; 31 int num_rx_bdr; 32 int num_tx_bdr; 33 }; 34 35 struct enetc_pf; 36 37 struct enetc_pf_ops { 38 void (*set_si_primary_mac)(struct enetc_hw *hw, int si, const u8 *addr); 39 void (*get_si_primary_mac)(struct enetc_hw *hw, int si, u8 *addr); 40 struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf, struct mii_bus *bus); 41 void (*destroy_pcs)(struct phylink_pcs *pcs); 42 int (*enable_psfp)(struct enetc_ndev_priv *priv); 43 void (*vf_flr_handler)(struct enetc_pf *pf, int vf_id); 44 }; 45 46 struct enetc_pf { 47 struct enetc_si *si; 48 int num_vfs; /* number of active VFs, after sriov_init */ 49 int total_vfs; /* max number of VFs, set for PF at probe */ 50 struct enetc_vf_state *vf_state; 51 struct enetc_msg_swbd *rxmsg; 52 53 DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE); 54 DECLARE_BITMAP(active_vlans, VLAN_N_VID); 55 56 struct mii_bus *mdio; /* saved for cleanup */ 57 struct mii_bus *imdio; 58 struct phylink_pcs *pcs; 59 60 phy_interface_t if_mode; 61 struct phylink_config phylink_config; 62 63 struct enetc_port_caps caps; 64 const struct enetc_pf_ops *ops; 65 66 struct work_struct link_status_task; 67 bool sriov_enabled; 68 bool link_up; 69 u16 link_status_ms_mask; 70 }; 71 72 #define phylink_to_enetc_pf(config) \ 73 container_of((config), struct enetc_pf, phylink_config) 74