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/list.h> 13 14 #include "fman_port.h" 15 #include "fman.h" 16 #include "fman_mac.h" 17 18 struct fman_mac; 19 struct mac_priv_s; 20 21 struct mac_device { 22 void __iomem *vaddr; 23 struct device *dev; 24 struct resource *res; 25 u8 addr[ETH_ALEN]; 26 struct fman_port *port[2]; 27 u32 if_support; 28 struct phy_device *phy_dev; 29 phy_interface_t phy_if; 30 struct device_node *phy_node; 31 struct net_device *net_dev; 32 33 bool autoneg_pause; 34 bool rx_pause_req; 35 bool tx_pause_req; 36 bool rx_pause_active; 37 bool tx_pause_active; 38 bool promisc; 39 bool allmulti; 40 41 int (*enable)(struct fman_mac *mac_dev); 42 void (*disable)(struct fman_mac *mac_dev); 43 void (*adjust_link)(struct mac_device *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_multi)(struct net_device *net_dev, 49 struct mac_device *mac_dev); 50 int (*set_rx_pause)(struct fman_mac *mac_dev, bool en); 51 int (*set_tx_pause)(struct fman_mac *mac_dev, u8 priority, 52 u16 pause_time, u16 thresh_time); 53 int (*set_exception)(struct fman_mac *mac_dev, 54 enum fman_mac_exceptions exception, bool enable); 55 int (*add_hash_mac_addr)(struct fman_mac *mac_dev, 56 enet_addr_t *eth_addr); 57 int (*remove_hash_mac_addr)(struct fman_mac *mac_dev, 58 enet_addr_t *eth_addr); 59 60 void (*update_speed)(struct mac_device *mac_dev, int speed); 61 62 struct fman_mac *fman_mac; 63 struct mac_priv_s *priv; 64 }; 65 66 struct dpaa_eth_data { 67 struct mac_device *mac_dev; 68 int mac_hw_id; 69 int fman_hw_id; 70 }; 71 72 extern const char *mac_driver_description; 73 74 int fman_set_mac_active_pause(struct mac_device *mac_dev, bool rx, bool tx); 75 76 void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause, 77 bool *tx_pause); 78 int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev); 79 80 #endif /* __MAC_H */ 81