xref: /linux/drivers/net/ethernet/freescale/fman/mac.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
2 /*
3  * Copyright 2008 - 2015 Freescale Semiconductor Inc.
4  */
5 
6 #ifndef __MAC_H
7 #define __MAC_H
8 
9 #include <linux/device.h>
10 #include <linux/if_ether.h>
11 #include <linux/phy.h>
12 #include <linux/phylink.h>
13 #include <linux/list.h>
14 
15 #include "fman_port.h"
16 #include "fman.h"
17 #include "fman_mac.h"
18 
19 struct fman_mac;
20 struct mac_priv_s;
21 
22 #define PORT_NUM 2
23 struct mac_device {
24 	void __iomem		*vaddr;
25 	struct device		*dev;
26 	struct resource		*res;
27 	u8			 addr[ETH_ALEN];
28 	struct fman_port	*port[PORT_NUM];
29 	struct phylink		*phylink;
30 	struct phylink_config	phylink_config;
31 	phy_interface_t		phy_if;
32 
33 	bool promisc;
34 	bool allmulti;
35 
36 	const struct phylink_mac_ops *phylink_ops;
37 	int (*enable)(struct fman_mac *mac_dev);
38 	void (*disable)(struct fman_mac *mac_dev);
39 	int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
40 	int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t *enet_addr);
41 	int (*set_allmulti)(struct fman_mac *mac_dev, bool enable);
42 	int (*set_tstamp)(struct fman_mac *mac_dev, bool enable);
43 	int (*set_exception)(struct fman_mac *mac_dev,
44 			     enum fman_mac_exceptions exception, bool enable);
45 	int (*add_hash_mac_addr)(struct fman_mac *mac_dev,
46 				 enet_addr_t *eth_addr);
47 	int (*remove_hash_mac_addr)(struct fman_mac *mac_dev,
48 				    enet_addr_t *eth_addr);
49 
50 	void (*update_speed)(struct mac_device *mac_dev, int speed);
51 
52 	struct fman_mac		*fman_mac;
53 	struct mac_priv_s	*priv;
54 
55 	struct device		*fman_dev;
56 	struct device		*fman_port_devs[PORT_NUM];
57 };
58 
59 static inline struct mac_device
60 *fman_config_to_mac(struct phylink_config *config)
61 {
62 	return container_of(config, struct mac_device, phylink_config);
63 }
64 
65 struct dpaa_eth_data {
66 	struct mac_device *mac_dev;
67 	int mac_hw_id;
68 	int fman_hw_id;
69 };
70 
71 extern const char	*mac_driver_description;
72 
73 int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev);
74 
75 #endif	/* __MAC_H */
76