Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 703ccb63ae9f7444d6ff876d024e17f628103c69 99 lines 3.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3#ifndef __PHY_PORT_H 4#define __PHY_PORT_H 5 6#include <linux/ethtool.h> 7#include <linux/types.h> 8#include <linux/phy.h> 9 10struct phy_port; 11 12/** 13 * enum phy_port_parent - The device this port is attached to 14 * 15 * @PHY_PORT_PHY: Indicates that the port is driven by a PHY device 16 */ 17enum phy_port_parent { 18 PHY_PORT_PHY, 19}; 20 21struct phy_port_ops { 22 /* Sometimes, the link state can be retrieved from physical, 23 * out-of-band channels such as the LOS signal on SFP. These 24 * callbacks allows notifying the port about state changes 25 */ 26 void (*link_up)(struct phy_port *port); 27 void (*link_down)(struct phy_port *port); 28 29 /* If the port acts as a Media Independent Interface (Serdes port), 30 * configures the port with the relevant state and mode. When enable is 31 * not set, interface should be ignored 32 */ 33 int (*configure_mii)(struct phy_port *port, bool enable, phy_interface_t interface); 34}; 35 36/** 37 * struct phy_port - A representation of a network device physical interface 38 * 39 * @head: Used by the port's parent to list ports 40 * @parent_type: The type of device this port is directly connected to 41 * @phy: If the parent is PHY_PORT_PHYDEV, the PHY controlling that port 42 * @ops: Callback ops implemented by the port controller 43 * @pairs: The number of pairs this port has, 0 if not applicable 44 * @mediums: Bitmask of the physical mediums this port provides access to 45 * @supported: The link modes this port can expose, if this port is MDI (not MII) 46 * @interfaces: The MII interfaces this port supports, if this port is MII 47 * @not_described: Indicates to the parent driver if this port isn't described, 48 * so it's up to the parent to filter its capabilities. 49 * @active: Indicates if the port is currently part of the active link. 50 * @is_mii: Indicates if this port is MII (Media Independent Interface), 51 * or MDI (Media Dependent Interface). 52 * @is_sfp: Indicates if this port drives an SFP cage. 53 */ 54struct phy_port { 55 struct list_head head; 56 enum phy_port_parent parent_type; 57 union { 58 struct phy_device *phy; 59 }; 60 61 const struct phy_port_ops *ops; 62 63 int pairs; 64 unsigned long mediums; 65 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 66 DECLARE_PHY_INTERFACE_MASK(interfaces); 67 68 unsigned int not_described:1; 69 unsigned int active:1; 70 unsigned int is_mii:1; 71 unsigned int is_sfp:1; 72}; 73 74struct phy_port *phy_port_alloc(void); 75void phy_port_destroy(struct phy_port *port); 76 77static inline struct phy_device *port_phydev(struct phy_port *port) 78{ 79 return port->phy; 80} 81 82struct phy_port *phy_of_parse_port(struct device_node *dn); 83 84static inline bool phy_port_is_copper(struct phy_port *port) 85{ 86 return port->mediums == BIT(ETHTOOL_LINK_MEDIUM_BASET); 87} 88 89static inline bool phy_port_is_fiber(struct phy_port *port) 90{ 91 return !!(port->mediums & ETHTOOL_MEDIUM_FIBER_BITS); 92} 93 94void phy_port_update_supported(struct phy_port *port); 95int phy_port_restrict_mediums(struct phy_port *port, unsigned long mediums); 96 97int phy_port_get_type(struct phy_port *port); 98 99#endif