linux/include/linux/sfp.h

#ifndef LINUX_SFP_H
#define LINUX_SFP_H

#include <linux/phy.h>

struct sfp_eeprom_base {} __packed;

struct sfp_eeprom_ext {} __packed;

/**
 * struct sfp_eeprom_id - raw SFP module identification information
 * @base: base SFP module identification structure
 * @ext: extended SFP module identification structure
 *
 * See the SFF-8472 specification and related documents for the definition
 * of these structure members. This can be obtained from
 * https://www.snia.org/technology-communities/sff/specifications
 */
struct sfp_eeprom_id {} __packed;

struct sfp_diag {} __packed;

/* SFF8024 defined constants */
enum {};

/* SFP EEPROM registers */
enum {};

/* SFP Diagnostics */
enum {};

struct fwnode_handle;
struct ethtool_eeprom;
struct ethtool_modinfo;
struct sfp_bus;

/**
 * struct sfp_upstream_ops - upstream operations structure
 * @attach: called when the sfp socket driver is bound to the upstream
 *   (mandatory).
 * @detach: called when the sfp socket driver is unbound from the upstream
 *   (mandatory).
 * @module_insert: called after a module has been detected to determine
 *   whether the module is supported for the upstream device.
 * @module_remove: called after the module has been removed.
 * @module_start: called after the PHY probe step
 * @module_stop: called before the PHY is removed
 * @link_down: called when the link is non-operational for whatever
 *   reason.
 * @link_up: called when the link is operational.
 * @connect_phy: called when an I2C accessible PHY has been detected
 *   on the module.
 * @disconnect_phy: called when a module with an I2C accessible PHY has
 *   been removed.
 */
struct sfp_upstream_ops {};

#if IS_ENABLED(CONFIG_SFP)
int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
		   unsigned long *support);
bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id);
void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
		       unsigned long *support, unsigned long *interfaces);
phy_interface_t sfp_select_interface(struct sfp_bus *bus,
				     const unsigned long *link_modes);

int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
			  u8 *data);
int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
				  const struct ethtool_module_eeprom *page,
				  struct netlink_ext_ack *extack);
void sfp_upstream_start(struct sfp_bus *bus);
void sfp_upstream_stop(struct sfp_bus *bus);
void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd);
void sfp_bus_put(struct sfp_bus *bus);
struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode);
int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
			 const struct sfp_upstream_ops *ops);
void sfp_bus_del_upstream(struct sfp_bus *bus);
#else
static inline int sfp_parse_port(struct sfp_bus *bus,
				 const struct sfp_eeprom_id *id,
				 unsigned long *support)
{
	return PORT_OTHER;
}

static inline bool sfp_may_have_phy(struct sfp_bus *bus,
				    const struct sfp_eeprom_id *id)
{
	return false;
}

static inline void sfp_parse_support(struct sfp_bus *bus,
				     const struct sfp_eeprom_id *id,
				     unsigned long *support,
				     unsigned long *interfaces)
{
}

static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus,
						const unsigned long *link_modes)
{
	return PHY_INTERFACE_MODE_NA;
}

static inline int sfp_get_module_info(struct sfp_bus *bus,
				      struct ethtool_modinfo *modinfo)
{
	return -EOPNOTSUPP;
}

static inline int sfp_get_module_eeprom(struct sfp_bus *bus,
					struct ethtool_eeprom *ee, u8 *data)
{
	return -EOPNOTSUPP;
}

static inline int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
						const struct ethtool_module_eeprom *page,
						struct netlink_ext_ack *extack)
{
	return -EOPNOTSUPP;
}

static inline void sfp_upstream_start(struct sfp_bus *bus)
{
}

static inline void sfp_upstream_stop(struct sfp_bus *bus)
{
}

static inline void sfp_upstream_set_signal_rate(struct sfp_bus *bus,
						unsigned int rate_kbd)
{
}

static inline void sfp_bus_put(struct sfp_bus *bus)
{
}

static inline struct sfp_bus *
sfp_bus_find_fwnode(const struct fwnode_handle *fwnode)
{
	return NULL;
}

static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
				       const struct sfp_upstream_ops *ops)
{
	return 0;
}

static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
{
}
#endif

#endif