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