xref: /linux/drivers/net/ethernet/freescale/enetc/enetc_pf.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
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 
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_port_caps {
32 	u32 half_duplex:1;
33 	int num_vsi;
34 	int num_msix;
35 	int num_rx_bdr;
36 	int num_tx_bdr;
37 };
38 
39 struct enetc_pf;
40 
41 struct enetc_pf_ops {
42 	void (*set_si_primary_mac)(struct enetc_hw *hw, int si, const u8 *addr);
43 	void (*get_si_primary_mac)(struct enetc_hw *hw, int si, u8 *addr);
44 	struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf, struct mii_bus *bus);
45 	void (*destroy_pcs)(struct phylink_pcs *pcs);
46 	int (*enable_psfp)(struct enetc_ndev_priv *priv);
47 };
48 
49 struct enetc_pf {
50 	struct enetc_si *si;
51 	int num_vfs; /* number of active VFs, after sriov_init */
52 	int total_vfs; /* max number of VFs, set for PF at probe */
53 	struct enetc_vf_state *vf_state;
54 
55 	struct enetc_mac_filter mac_filter[ENETC_MAX_NUM_MAC_FLT];
56 
57 	struct enetc_msg_swbd rxmsg[ENETC_MAX_NUM_VFS];
58 	struct work_struct msg_task;
59 	char msg_int_name[ENETC_INT_NAME_MAX];
60 
61 	char vlan_promisc_simap; /* bitmap of SIs in VLAN promisc mode */
62 	DECLARE_BITMAP(vlan_ht_filter, ENETC_VLAN_HT_SIZE);
63 	DECLARE_BITMAP(active_vlans, VLAN_N_VID);
64 
65 	struct mii_bus *mdio; /* saved for cleanup */
66 	struct mii_bus *imdio;
67 	struct phylink_pcs *pcs;
68 
69 	phy_interface_t if_mode;
70 	struct phylink_config phylink_config;
71 
72 	struct enetc_port_caps caps;
73 	const struct enetc_pf_ops *ops;
74 };
75 
76 #define phylink_to_enetc_pf(config) \
77 	container_of((config), struct enetc_pf, phylink_config)
78 
79 int enetc_msg_psi_init(struct enetc_pf *pf);
80 void enetc_msg_psi_free(struct enetc_pf *pf);
81 void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int mbox_id, u16 *status);
82