1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2017-2019 NXP */
3 
4 #include "enetc.h"
5 #include <linux/pcs-lynx.h>
6 
7 #define ENETC_PF_NUM_RINGS	8
8 
9 enum enetc_mac_addr_type {UC, MC, MADDR_TYPE};
10 #define ENETC_MAX_NUM_MAC_FLT	((ENETC_MAX_NUM_VFS + 1) * MADDR_TYPE)
11 
12 #define ENETC_MADDR_HASH_TBL_SZ	64
13 struct enetc_mac_filter {
14 	union {
15 		char mac_addr[ETH_ALEN];
16 		DECLARE_BITMAP(mac_hash_table, ENETC_MADDR_HASH_TBL_SZ);
17 	};
18 	int mac_addr_cnt;
19 };
20 
21 #define ENETC_VLAN_HT_SIZE	64
22 
23 enum enetc_vf_flags {
24 	ENETC_VF_FLAG_PF_SET_MAC	= BIT(0),
25 };
26 
27 struct enetc_vf_state {
28 	enum enetc_vf_flags flags;
29 };
30 
31 struct enetc_pf {
32 	struct enetc_si *si;
33 	int num_vfs; /* number of active VFs, after sriov_init */
34 	int total_vfs; /* max number of VFs, set for PF at probe */
35 	struct enetc_vf_state *vf_state;
36 
37 	struct enetc_mac_filter mac_filter[ENETC_MAX_NUM_MAC_FLT];
38 
39 	struct enetc_msg_swbd rxmsg[ENETC_MAX_NUM_VFS];
40 	struct work_struct msg_task;
41 	char msg_int_name[ENETC_INT_NAME_MAX];
42 
43 	char vlan_promisc_simap; /* bitmap of SIs in VLAN promisc mode */
44 	DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE);
45 	DECLARE_BITMAP(active_vlans, VLAN_N_VID);
46 
47 	struct mii_bus *mdio; /* saved for cleanup */
48 	struct mii_bus *imdio;
49 	struct lynx_pcs *pcs;
50 
51 	phy_interface_t if_mode;
52 	struct phylink_config phylink_config;
53 };
54 
55 #define phylink_to_enetc_pf(config) \
56 	container_of((config), struct enetc_pf, phylink_config)
57 
58 int enetc_msg_psi_init(struct enetc_pf *pf);
59 void enetc_msg_psi_free(struct enetc_pf *pf);
60 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int mbox_id, u16 *status);
61