Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/axgbe/xgbe.h
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
* THE POSSIBILITY OF SUCH DAMAGE. | * THE POSSIBILITY OF SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef __XGBE_H__ | #ifndef __XGBE_H__ | ||||
#define __XGBE_H__ | #define __XGBE_H__ | ||||
#include <dev/ofw/openfirm.h> | |||||
#include <dev/ofw/ofw_bus.h> | |||||
#include <dev/ofw/ofw_bus_subr.h> | |||||
#include "xgbe_osdep.h" | #include "xgbe_osdep.h" | ||||
/* From linux/dcbnl.h */ | /* From linux/dcbnl.h */ | ||||
#define IEEE_8021QAZ_MAX_TCS 8 | #define IEEE_8021QAZ_MAX_TCS 8 | ||||
#define XGBE_DRV_NAME "amd-xgbe" | #define XGBE_DRV_NAME "amd-xgbe" | ||||
#define XGBE_DRV_VERSION "1.0.2" | #define XGBE_DRV_VERSION "1.0.2" | ||||
#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" | #define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
#define XGBE_SPEED_1000_PLL 0x0 | #define XGBE_SPEED_1000_PLL 0x0 | ||||
#define XGBE_SPEED_1000_PQ 0xa | #define XGBE_SPEED_1000_PQ 0xa | ||||
#define XGBE_SPEED_1000_RATE 0x3 | #define XGBE_SPEED_1000_RATE 0x3 | ||||
#define XGBE_SPEED_1000_TXAMP 0xf | #define XGBE_SPEED_1000_TXAMP 0xf | ||||
#define XGBE_SPEED_1000_WORD 0x1 | #define XGBE_SPEED_1000_WORD 0x1 | ||||
#define XGBE_SPEED_1000_DFE_TAP_CONFIG 0x3 | #define XGBE_SPEED_1000_DFE_TAP_CONFIG 0x3 | ||||
#define XGBE_SPEED_1000_DFE_TAP_ENABLE 0x0 | #define XGBE_SPEED_1000_DFE_TAP_ENABLE 0x0 | ||||
/* Link mode bit operations */ | |||||
#define XGBE_ZERO_SUP(_phy) \ | |||||
((_phy)->supported = 0) | |||||
#define XGBE_SET_SUP(_phy, _mode) \ | |||||
((_phy)->supported |= SUPPORTED_##_mode) | |||||
#define XGBE_CLR_SUP(_phy, _mode) \ | |||||
((_phy)->supported &= ~SUPPORTED_##_mode) | |||||
#define XGBE_IS_SUP(_phy, _mode) \ | |||||
((_phy)->supported & SUPPORTED_##_mode) | |||||
#define XGBE_ZERO_ADV(_phy) \ | |||||
((_phy)->advertising = 0) | |||||
#define XGBE_SET_ADV(_phy, _mode) \ | |||||
((_phy)->advertising |= ADVERTISED_##_mode) | |||||
#define XGBE_CLR_ADV(_phy, _mode) \ | |||||
((_phy)->advertising &= ~ADVERTISED_##_mode) | |||||
#define XGBE_ADV(_phy, _mode) \ | |||||
((_phy)->advertising & ADVERTISED_##_mode) | |||||
#define XGBE_ZERO_LP_ADV(_phy) \ | |||||
((_phy)->lp_advertising = 0) | |||||
#define XGBE_SET_LP_ADV(_phy, _mode) \ | |||||
((_phy)->lp_advertising |= ADVERTISED_##_mode) | |||||
#define XGBE_CLR_LP_ADV(_phy, _mode) \ | |||||
((_phy)->lp_advertising &= ~ADVERTISED_##_mode) | |||||
#define XGBE_LP_ADV(_phy, _mode) \ | |||||
((_phy)->lp_advertising & ADVERTISED_##_mode) | |||||
#define XGBE_LM_COPY(_dphy, _dname, _sphy, _sname) \ | |||||
((_dphy)->_dname = (_sphy)->_sname) | |||||
struct xgbe_prv_data; | struct xgbe_prv_data; | ||||
struct xgbe_packet_data { | struct xgbe_packet_data { | ||||
struct mbuf *m; | struct mbuf *m; | ||||
unsigned int attributes; | unsigned int attributes; | ||||
unsigned int errors; | unsigned int errors; | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | |||||
enum xgbe_speed { | enum xgbe_speed { | ||||
XGBE_SPEED_1000 = 0, | XGBE_SPEED_1000 = 0, | ||||
XGBE_SPEED_2500, | XGBE_SPEED_2500, | ||||
XGBE_SPEED_10000, | XGBE_SPEED_10000, | ||||
XGBE_SPEEDS, | XGBE_SPEEDS, | ||||
}; | }; | ||||
enum xgbe_xpcs_access { | |||||
XGBE_XPCS_ACCESS_V1 = 0, | |||||
XGBE_XPCS_ACCESS_V2, | |||||
}; | |||||
enum xgbe_an_mode { | |||||
XGBE_AN_MODE_CL73 = 0, | |||||
XGBE_AN_MODE_CL73_REDRV, | |||||
XGBE_AN_MODE_CL37, | |||||
XGBE_AN_MODE_CL37_SGMII, | |||||
XGBE_AN_MODE_NONE, | |||||
}; | |||||
enum xgbe_an { | enum xgbe_an { | ||||
XGBE_AN_READY = 0, | XGBE_AN_READY = 0, | ||||
XGBE_AN_PAGE_RECEIVED, | XGBE_AN_PAGE_RECEIVED, | ||||
XGBE_AN_INCOMPAT_LINK, | XGBE_AN_INCOMPAT_LINK, | ||||
XGBE_AN_COMPLETE, | XGBE_AN_COMPLETE, | ||||
XGBE_AN_NO_LINK, | XGBE_AN_NO_LINK, | ||||
XGBE_AN_ERROR, | XGBE_AN_ERROR, | ||||
}; | }; | ||||
enum xgbe_rx { | enum xgbe_rx { | ||||
XGBE_RX_BPA = 0, | XGBE_RX_BPA = 0, | ||||
XGBE_RX_XNP, | XGBE_RX_XNP, | ||||
XGBE_RX_COMPLETE, | XGBE_RX_COMPLETE, | ||||
XGBE_RX_ERROR, | XGBE_RX_ERROR, | ||||
}; | }; | ||||
enum xgbe_mode { | enum xgbe_mode { | ||||
XGBE_MODE_KR = 0, | XGBE_MODE_KX_1000 = 0, | ||||
XGBE_MODE_KX, | XGBE_MODE_KX_2500, | ||||
XGBE_MODE_KR, | |||||
XGBE_MODE_UNKNOWN, | |||||
}; | }; | ||||
enum xgbe_speedset { | enum xgbe_speedset { | ||||
XGBE_SPEEDSET_1000_10000 = 0, | XGBE_SPEEDSET_1000_10000 = 0, | ||||
XGBE_SPEEDSET_2500_10000, | XGBE_SPEEDSET_2500_10000, | ||||
}; | }; | ||||
struct xgbe_phy { | struct xgbe_phy { | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | struct xgbe_hw_if { | ||||
int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); | int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); | ||||
int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); | int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); | ||||
int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *); | int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *); | ||||
int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *); | int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *); | ||||
int (*update_vlan_hash_table)(struct xgbe_prv_data *); | int (*update_vlan_hash_table)(struct xgbe_prv_data *); | ||||
int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); | int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); | ||||
void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); | void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); | ||||
int (*set_gmii_speed)(struct xgbe_prv_data *); | int (*set_speed)(struct xgbe_prv_data *, int); | ||||
int (*set_gmii_2500_speed)(struct xgbe_prv_data *); | |||||
int (*set_xgmii_speed)(struct xgbe_prv_data *); | |||||
void (*enable_tx)(struct xgbe_prv_data *); | void (*enable_tx)(struct xgbe_prv_data *); | ||||
void (*disable_tx)(struct xgbe_prv_data *); | void (*disable_tx)(struct xgbe_prv_data *); | ||||
void (*enable_rx)(struct xgbe_prv_data *); | void (*enable_rx)(struct xgbe_prv_data *); | ||||
void (*disable_rx)(struct xgbe_prv_data *); | void (*disable_rx)(struct xgbe_prv_data *); | ||||
void (*powerup_tx)(struct xgbe_prv_data *); | void (*powerup_tx)(struct xgbe_prv_data *); | ||||
void (*powerdown_tx)(struct xgbe_prv_data *); | void (*powerdown_tx)(struct xgbe_prv_data *); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | struct xgbe_hw_if { | ||||
void (*rx_mmc_int)(struct xgbe_prv_data *); | void (*rx_mmc_int)(struct xgbe_prv_data *); | ||||
void (*tx_mmc_int)(struct xgbe_prv_data *); | void (*tx_mmc_int)(struct xgbe_prv_data *); | ||||
void (*read_mmc_stats)(struct xgbe_prv_data *); | void (*read_mmc_stats)(struct xgbe_prv_data *); | ||||
/* For Receive Side Scaling */ | /* For Receive Side Scaling */ | ||||
int (*disable_rss)(struct xgbe_prv_data *); | int (*disable_rss)(struct xgbe_prv_data *); | ||||
}; | }; | ||||
/* This structure represents implementation specific routines for an | |||||
* implementation of a PHY. All routines are required unless noted below. | |||||
* Optional routines: | |||||
* an_pre, an_post | |||||
* kr_training_pre, kr_training_post | |||||
* module_info, module_eeprom | |||||
*/ | |||||
struct xgbe_phy_impl_if { | |||||
/* Perform Setup/teardown actions */ | |||||
int (*init)(struct xgbe_prv_data *); | |||||
void (*exit)(struct xgbe_prv_data *); | |||||
/* Perform start/stop specific actions */ | |||||
int (*reset)(struct xgbe_prv_data *); | |||||
int (*start)(struct xgbe_prv_data *); | |||||
void (*stop)(struct xgbe_prv_data *); | |||||
/* Return the link status */ | |||||
int (*link_status)(struct xgbe_prv_data *, int *); | |||||
/* Indicate if a particular speed is valid */ | |||||
bool (*valid_speed)(struct xgbe_prv_data *, int); | |||||
/* Check if the specified mode can/should be used */ | |||||
bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode); | |||||
/* Switch the PHY into various modes */ | |||||
void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode); | |||||
/* Retrieve mode needed for a specific speed */ | |||||
enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int); | |||||
/* Retrieve new/next mode when trying to auto-negotiate */ | |||||
enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *); | |||||
/* Retrieve current mode */ | |||||
enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *); | |||||
/* Retrieve current auto-negotiation mode */ | |||||
enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *); | |||||
/* Configure auto-negotiation settings */ | |||||
int (*an_config)(struct xgbe_prv_data *); | |||||
/* Set/override auto-negotiation advertisement settings */ | |||||
void (*an_advertising)(struct xgbe_prv_data *, struct xgbe_phy *); | |||||
/* Process results of auto-negotiation */ | |||||
enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *); | |||||
/* Pre/Post auto-negotiation support */ | |||||
void (*an_pre)(struct xgbe_prv_data *); | |||||
void (*an_post)(struct xgbe_prv_data *); | |||||
/* Pre/Post KR training enablement support */ | |||||
void (*kr_training_pre)(struct xgbe_prv_data *); | |||||
void (*kr_training_post)(struct xgbe_prv_data *); | |||||
/* SFP module related info */ | |||||
int (*module_info)(struct xgbe_prv_data *pdata); | |||||
int (*module_eeprom)(struct xgbe_prv_data *pdata); | |||||
}; | |||||
struct xgbe_phy_if { | struct xgbe_phy_if { | ||||
/* For initial PHY setup */ | /* For initial PHY setup */ | ||||
void (*phy_init)(struct xgbe_prv_data *); | int (*phy_init)(struct xgbe_prv_data *); | ||||
void (*phy_exit)(struct xgbe_prv_data *); | |||||
/* For PHY support when setting device up/down */ | /* For PHY support when setting device up/down */ | ||||
int (*phy_reset)(struct xgbe_prv_data *); | int (*phy_reset)(struct xgbe_prv_data *); | ||||
int (*phy_start)(struct xgbe_prv_data *); | int (*phy_start)(struct xgbe_prv_data *); | ||||
void (*phy_stop)(struct xgbe_prv_data *); | void (*phy_stop)(struct xgbe_prv_data *); | ||||
/* For PHY support while device is up */ | /* For PHY support while device is up */ | ||||
void (*phy_status)(struct xgbe_prv_data *); | void (*phy_status)(struct xgbe_prv_data *); | ||||
int (*phy_config_aneg)(struct xgbe_prv_data *); | int (*phy_config_aneg)(struct xgbe_prv_data *); | ||||
/* PHY implementation specific services */ | |||||
struct xgbe_phy_impl_if phy_impl; | |||||
}; | }; | ||||
struct xgbe_desc_if { | struct xgbe_desc_if { | ||||
int (*alloc_ring_resources)(struct xgbe_prv_data *); | int (*alloc_ring_resources)(struct xgbe_prv_data *); | ||||
void (*free_ring_resources)(struct xgbe_prv_data *); | void (*free_ring_resources)(struct xgbe_prv_data *); | ||||
int (*map_tx_skb)(struct xgbe_channel *, struct mbuf *); | int (*map_tx_skb)(struct xgbe_channel *, struct mbuf *); | ||||
int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *, | int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *, | ||||
struct xgbe_ring_data *); | struct xgbe_ring_data *); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | struct xgbe_hw_features { | ||||
unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ | unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ | ||||
unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ | unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ | ||||
unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ | unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ | ||||
unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ | unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ | ||||
unsigned int pps_out_num; /* Number of PPS outputs */ | unsigned int pps_out_num; /* Number of PPS outputs */ | ||||
unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ | unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ | ||||
}; | }; | ||||
struct xgbe_version_data { | |||||
void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *); | |||||
enum xgbe_xpcs_access xpcs_access; | |||||
unsigned int mmc_64bit; | |||||
unsigned int tx_max_fifo_size; | |||||
unsigned int rx_max_fifo_size; | |||||
unsigned int tx_tstamp_workaround; | |||||
unsigned int ecc_support; | |||||
unsigned int i2c_support; | |||||
unsigned int irq_reissue_support; | |||||
unsigned int tx_desc_prefetch; | |||||
unsigned int rx_desc_prefetch; | |||||
unsigned int an_cdr_workaround; | |||||
}; | |||||
struct xgbe_prv_data { | struct xgbe_prv_data { | ||||
struct ifnet *netdev; | struct ifnet *netdev; | ||||
struct platform_device *pdev; | struct platform_device *pdev; | ||||
struct acpi_device *adev; | struct acpi_device *adev; | ||||
device_t dev; | device_t dev; | ||||
/* Version related data */ | |||||
struct xgbe_version_data *vdata; | |||||
/* ACPI or DT flag */ | /* ACPI or DT flag */ | ||||
unsigned int use_acpi; | unsigned int use_acpi; | ||||
/* XGMAC/XPCS related mmio registers */ | /* XGMAC/XPCS related mmio registers */ | ||||
struct resource *xgmac_res; /* XGMAC CSRs */ | struct resource *xgmac_res; /* XGMAC CSRs */ | ||||
struct resource *xpcs_res; /* XPCS MMD registers */ | struct resource *xpcs_res; /* XPCS MMD registers */ | ||||
struct resource *rxtx_res; /* SerDes Rx/Tx CSRs */ | struct resource *rxtx_res; /* SerDes Rx/Tx CSRs */ | ||||
struct resource *sir0_res; /* SerDes integration registers (1/2) */ | struct resource *sir0_res; /* SerDes integration registers (1/2) */ | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | struct xgbe_prv_data { | ||||
/* Network interface message level setting */ | /* Network interface message level setting */ | ||||
u32 msg_enable; | u32 msg_enable; | ||||
/* Current PHY settings */ | /* Current PHY settings */ | ||||
int phy_link; | int phy_link; | ||||
int phy_speed; | int phy_speed; | ||||
/* MDIO/PHY related settings */ | /* MDIO/PHY related settings */ | ||||
unsigned int phy_started; | |||||
void *phy_data; | |||||
struct xgbe_phy phy; | struct xgbe_phy phy; | ||||
int mdio_mmd; | int mdio_mmd; | ||||
unsigned long link_check; | unsigned long link_check; | ||||
unsigned int kr_redrv; | |||||
char an_name[IFNAMSIZ + 32]; | char an_name[IFNAMSIZ + 32]; | ||||
struct resource *an_irq_res; | struct resource *an_irq_res; | ||||
void *an_irq_tag; | void *an_irq_tag; | ||||
unsigned int speed_set; | |||||
/* SerDes UEFI configurable settings. | |||||
* Switching between modes/speeds requires new values for some | |||||
* SerDes settings. The values can be supplied as device | |||||
* properties in array format. The first array entry is for | |||||
* 1GbE, second for 2.5GbE and third for 10GbE | |||||
*/ | |||||
u32 serdes_blwc[XGBE_SPEEDS]; | |||||
u32 serdes_cdr_rate[XGBE_SPEEDS]; | |||||
u32 serdes_pq_skew[XGBE_SPEEDS]; | |||||
u32 serdes_tx_amp[XGBE_SPEEDS]; | |||||
u32 serdes_dfe_tap_cfg[XGBE_SPEEDS]; | |||||
u32 serdes_dfe_tap_ena[XGBE_SPEEDS]; | |||||
/* Auto-negotiation state machine support */ | /* Auto-negotiation state machine support */ | ||||
unsigned int an_int; | unsigned int an_int; | ||||
struct sx an_mutex; | struct sx an_mutex; | ||||
enum xgbe_an an_result; | enum xgbe_an an_result; | ||||
enum xgbe_an an_state; | enum xgbe_an an_state; | ||||
enum xgbe_rx kr_state; | enum xgbe_rx kr_state; | ||||
enum xgbe_rx kx_state; | enum xgbe_rx kx_state; | ||||
unsigned int an_again; | |||||
unsigned int an_supported; | unsigned int an_supported; | ||||
unsigned int parallel_detect; | unsigned int parallel_detect; | ||||
unsigned int fec_ability; | unsigned int fec_ability; | ||||
unsigned long an_start; | unsigned long an_start; | ||||
enum xgbe_an_mode an_mode; | |||||
unsigned int lpm_ctrl; /* CTRL1 for resume */ | unsigned int lpm_ctrl; /* CTRL1 for resume */ | ||||
phandle_t phy_node; | |||||
}; | }; | ||||
/* Function prototypes*/ | /* Function prototypes*/ | ||||
int xgbe_open(struct ifnet *); | int xgbe_open(struct ifnet *); | ||||
int xgbe_close(struct ifnet *); | int xgbe_close(struct ifnet *); | ||||
int xgbe_xmit(struct ifnet *, struct mbuf *); | int xgbe_xmit(struct ifnet *, struct mbuf *); | ||||
int xgbe_change_mtu(struct ifnet *, int); | int xgbe_change_mtu(struct ifnet *, int); | ||||
void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); | void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); | ||||
void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *); | void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *); | ||||
void xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *); | |||||
void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); | void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); | ||||
void xgbe_get_all_hw_features(struct xgbe_prv_data *); | void xgbe_get_all_hw_features(struct xgbe_prv_data *); | ||||
void xgbe_init_rx_coalesce(struct xgbe_prv_data *); | void xgbe_init_rx_coalesce(struct xgbe_prv_data *); | ||||
void xgbe_init_tx_coalesce(struct xgbe_prv_data *); | void xgbe_init_tx_coalesce(struct xgbe_prv_data *); | ||||
/* NOTE: Uncomment for function trace log messages in KERNEL LOG */ | /* NOTE: Uncomment for function trace log messages in KERNEL LOG */ | ||||
#if 0 | #if 0 | ||||
#define YDEBUG | #define YDEBUG | ||||
Show All 17 Lines |