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_multi)(struct net_device *net_dev,
44 struct mac_device *mac_dev);
45 int (*set_exception)(struct fman_mac *mac_dev,
46 enum fman_mac_exceptions exception, bool enable);
47 int (*add_hash_mac_addr)(struct fman_mac *mac_dev,
48 enet_addr_t *eth_addr);
49 int (*remove_hash_mac_addr)(struct fman_mac *mac_dev,
50 enet_addr_t *eth_addr);
51
52 void (*update_speed)(struct mac_device *mac_dev, int speed);
53
54 struct fman_mac *fman_mac;
55 struct mac_priv_s *priv;
56
57 struct device *fman_dev;
58 struct device *fman_port_devs[PORT_NUM];
59 };
60
61 static inline struct mac_device
fman_config_to_mac(struct phylink_config * config)62 *fman_config_to_mac(struct phylink_config *config)
63 {
64 return container_of(config, struct mac_device, phylink_config);
65 }
66
67 struct dpaa_eth_data {
68 struct mac_device *mac_dev;
69 int mac_hw_id;
70 int fman_hw_id;
71 };
72
73 extern const char *mac_driver_description;
74
75 int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev);
76
77 #endif /* __MAC_H */
78