#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 { … } __packed;
struct sfp_diag { … } __packed;
enum { … };
enum { … };
enum { … };
struct fwnode_handle;
struct ethtool_eeprom;
struct ethtool_modinfo;
struct sfp_bus;
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);
const char *sfp_get_name(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)
{
}
static inline const char *sfp_get_name(struct sfp_bus *bus)
{
return NULL;
}
#endif
#endif