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 struct mutex lock; /* Prevent concurrent access */ 18 enum enetc_vf_flags flags; 19 }; 20 21 struct enetc_port_caps { 22 u32 half_duplex:1; 23 int num_vsi; 24 int num_msix; 25 int num_rx_bdr; 26 int num_tx_bdr; 27 int mac_filter_num; 28 }; 29 30 struct enetc_pf; 31 32 struct enetc_pf_ops { 33 void (*set_si_primary_mac)(struct enetc_hw *hw, int si, const u8 *addr); 34 void (*get_si_primary_mac)(struct enetc_hw *hw, int si, u8 *addr); 35 struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf, struct mii_bus *bus); 36 void (*destroy_pcs)(struct phylink_pcs *pcs); 37 int (*enable_psfp)(struct enetc_ndev_priv *priv); 38 }; 39 40 struct enetc_pf { 41 struct enetc_si *si; 42 int num_vfs; /* number of active VFs, after sriov_init */ 43 int total_vfs; /* max number of VFs, set for PF at probe */ 44 struct enetc_vf_state *vf_state; 45 46 struct enetc_mac_filter mac_filter[ENETC_MAX_NUM_MAC_FLT]; 47 48 struct enetc_msg_swbd rxmsg[ENETC_MAX_NUM_VFS]; 49 struct work_struct msg_task; 50 char msg_int_name[ENETC_INT_NAME_MAX]; 51 52 char vlan_promisc_simap; /* bitmap of SIs in VLAN promisc mode */ 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 int num_mfe; /* number of mac address filter table entries */ 67 }; 68 69 #define phylink_to_enetc_pf(config) \ 70 container_of((config), struct enetc_pf, phylink_config) 71 72 int enetc_msg_psi_init(struct enetc_pf *pf); 73 void enetc_msg_psi_free(struct enetc_pf *pf); 74 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int mbox_id, u16 *status); 75