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 ethtool_eth_ctrl_stats; 20 struct ethtool_eth_mac_stats; 21 struct ethtool_pause_stats; 22 struct ethtool_rmon_stats; 23 struct ethtool_rmon_hist_range; 24 struct fman_mac; 25 struct mac_priv_s; 26 27 #define PORT_NUM 2 28 struct mac_device { 29 void __iomem *vaddr; 30 struct device *dev; 31 struct resource *res; 32 u8 addr[ETH_ALEN]; 33 struct fman_port *port[PORT_NUM]; 34 struct phylink *phylink; 35 struct phylink_config phylink_config; 36 phy_interface_t phy_if; 37 38 bool promisc; 39 bool allmulti; 40 41 const struct phylink_mac_ops *phylink_ops; 42 int (*enable)(struct fman_mac *mac_dev); 43 void (*disable)(struct fman_mac *mac_dev); 44 int (*set_promisc)(struct fman_mac *mac_dev, bool enable); 45 int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t *enet_addr); 46 int (*set_allmulti)(struct fman_mac *mac_dev, bool enable); 47 int (*set_tstamp)(struct fman_mac *mac_dev, bool enable); 48 int (*set_exception)(struct fman_mac *mac_dev, 49 enum fman_mac_exceptions exception, bool enable); 50 int (*add_hash_mac_addr)(struct fman_mac *mac_dev, 51 enet_addr_t *eth_addr); 52 int (*remove_hash_mac_addr)(struct fman_mac *mac_dev, 53 enet_addr_t *eth_addr); 54 void (*get_pause_stats)(struct fman_mac *memac, 55 struct ethtool_pause_stats *s); 56 void (*get_rmon_stats)(struct fman_mac *memac, 57 struct ethtool_rmon_stats *s, 58 const struct ethtool_rmon_hist_range **ranges); 59 void (*get_eth_ctrl_stats)(struct fman_mac *memac, 60 struct ethtool_eth_ctrl_stats *s); 61 void (*get_eth_mac_stats)(struct fman_mac *memac, 62 struct ethtool_eth_mac_stats *s); 63 64 void (*update_speed)(struct mac_device *mac_dev, int speed); 65 66 struct fman_mac *fman_mac; 67 struct mac_priv_s *priv; 68 69 struct device *fman_dev; 70 struct device *fman_port_devs[PORT_NUM]; 71 }; 72 73 static inline struct mac_device 74 *fman_config_to_mac(struct phylink_config *config) 75 { 76 return container_of(config, struct mac_device, phylink_config); 77 } 78 79 struct dpaa_eth_data { 80 struct mac_device *mac_dev; 81 int mac_hw_id; 82 int fman_hw_id; 83 }; 84 85 extern const char *mac_driver_description; 86 87 int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev); 88 89 #endif /* __MAC_H */ 90