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_MAX_NUM_MAC_FLT ((ENETC_MAX_NUM_VFS + 1) * MADDR_TYPE) 9 10 #define ENETC_VLAN_HT_SIZE 64 11 12 enum enetc_vf_flags { 13 ENETC_VF_FLAG_PF_SET_MAC = BIT(0), 14 }; 15 16 struct enetc_vf_state { 17 enum enetc_vf_flags flags; 18 }; 19 20 struct enetc_port_caps { 21 u32 half_duplex:1; 22 int num_vsi; 23 int num_msix; 24 int num_rx_bdr; 25 int num_tx_bdr; 26 int mac_filter_num; 27 }; 28 29 struct enetc_pf; 30 31 struct enetc_pf_ops { 32 void (*set_si_primary_mac)(struct enetc_hw *hw, int si, const u8 *addr); 33 void (*get_si_primary_mac)(struct enetc_hw *hw, int si, u8 *addr); 34 struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf, struct mii_bus *bus); 35 void (*destroy_pcs)(struct phylink_pcs *pcs); 36 int (*enable_psfp)(struct enetc_ndev_priv *priv); 37 }; 38 39 struct enetc_pf { 40 struct enetc_si *si; 41 int num_vfs; /* number of active VFs, after sriov_init */ 42 int total_vfs; /* max number of VFs, set for PF at probe */ 43 struct enetc_vf_state *vf_state; 44 45 struct enetc_mac_filter mac_filter[ENETC_MAX_NUM_MAC_FLT]; 46 47 struct enetc_msg_swbd rxmsg[ENETC_MAX_NUM_VFS]; 48 struct work_struct msg_task; 49 char msg_int_name[ENETC_INT_NAME_MAX]; 50 51 char vlan_promisc_simap; /* bitmap of SIs in VLAN promisc mode */ 52 DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE); 53 DECLARE_BITMAP(active_vlans, VLAN_N_VID); 54 55 struct mii_bus *mdio; /* saved for cleanup */ 56 struct mii_bus *imdio; 57 struct phylink_pcs *pcs; 58 59 phy_interface_t if_mode; 60 struct phylink_config phylink_config; 61 62 struct enetc_port_caps caps; 63 const struct enetc_pf_ops *ops; 64 65 int num_mfe; /* number of mac address filter table entries */ 66 }; 67 68 #define phylink_to_enetc_pf(config) \ 69 container_of((config), struct enetc_pf, phylink_config) 70 71 int enetc_msg_psi_init(struct enetc_pf *pf); 72 void enetc_msg_psi_free(struct enetc_pf *pf); 73 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int mbox_id, u16 *status); 74