Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/ixl_pf_main.c
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
static int ixl_sysctl_supported_speeds(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_supported_speeds(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_current_speed(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_current_speed(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_show_fw(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_show_fw(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_unallocated_queues(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_unallocated_queues(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_pf_tx_itr(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_pf_tx_itr(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_pf_rx_itr(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_pf_rx_itr(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_eee_enable(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_eee_enable(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_set_link_active(SYSCTL_HANDLER_ARGS); | |||||
/* Debug Sysctls */ | /* Debug Sysctls */ | ||||
static int ixl_sysctl_link_status(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_link_status(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_phy_abilities(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_phy_abilities(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_sw_filter_list(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_sw_filter_list(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_hw_res_alloc(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_hw_res_alloc(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_switch_config(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_switch_config(SYSCTL_HANDLER_ARGS); | ||||
static int ixl_sysctl_hkey(SYSCTL_HANDLER_ARGS); | static int ixl_sysctl_hkey(SYSCTL_HANDLER_ARGS); | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | case IXL_I2C_ACCESS_METHOD_BIT_BANG_I2CPARAMS: | ||||
pf->write_i2c_byte = ixl_write_i2c_byte_bb; | pf->write_i2c_byte = ixl_write_i2c_byte_bb; | ||||
break; | break; | ||||
default: | default: | ||||
/* Should not happen */ | /* Should not happen */ | ||||
device_printf(dev, "Error setting I2C access functions\n"); | device_printf(dev, "Error setting I2C access functions\n"); | ||||
break; | break; | ||||
} | } | ||||
/* Keep link active by default */ | |||||
atomic_set_32(&pf->state, IXL_PF_STATE_LINK_ACTIVE_ON_DOWN); | |||||
/* Print a subset of the capability information. */ | /* Print a subset of the capability information. */ | ||||
device_printf(dev, | device_printf(dev, | ||||
"PF-ID[%d]: VFs %d, MSI-X %d, VF MSI-X %d, QPs %d, %s\n", | "PF-ID[%d]: VFs %d, MSI-X %d, VF MSI-X %d, QPs %d, %s\n", | ||||
hw->pf_id, hw->func_caps.num_vfs, hw->func_caps.num_msix_vectors, | hw->pf_id, hw->func_caps.num_vfs, hw->func_caps.num_msix_vectors, | ||||
hw->func_caps.num_msix_vectors_vf, hw->func_caps.num_tx_qp, | hw->func_caps.num_msix_vectors_vf, hw->func_caps.num_tx_qp, | ||||
(hw->func_caps.mdio_port_mode == 2) ? "I2C" : | (hw->func_caps.mdio_port_mode == 2) ? "I2C" : | ||||
(hw->func_caps.mdio_port_mode == 1 && pf->has_i2c) ? "MDIO & I2C" : | (hw->func_caps.mdio_port_mode == 1 && pf->has_i2c) ? "MDIO & I2C" : | ||||
(hw->func_caps.mdio_port_mode == 1) ? "MDIO dedicated" : | (hw->func_caps.mdio_port_mode == 1) ? "MDIO dedicated" : | ||||
▲ Show 20 Lines • Show All 1,889 Lines • ▼ Show 20 Lines | ixl_add_device_sysctls(struct ixl_pf *pf) | ||||
SYSCTL_ADD_UQUAD(ctx, eee_list, OID_AUTO, "tx_lpi_count", | SYSCTL_ADD_UQUAD(ctx, eee_list, OID_AUTO, "tx_lpi_count", | ||||
CTLFLAG_RD | CTLFLAG_MPSAFE, &pf->stats.tx_lpi_count, | CTLFLAG_RD | CTLFLAG_MPSAFE, &pf->stats.tx_lpi_count, | ||||
"TX LPI count"); | "TX LPI count"); | ||||
SYSCTL_ADD_UQUAD(ctx, eee_list, OID_AUTO, "rx_lpi_count", | SYSCTL_ADD_UQUAD(ctx, eee_list, OID_AUTO, "rx_lpi_count", | ||||
CTLFLAG_RD | CTLFLAG_MPSAFE, &pf->stats.rx_lpi_count, | CTLFLAG_RD | CTLFLAG_MPSAFE, &pf->stats.rx_lpi_count, | ||||
"RX LPI count"); | "RX LPI count"); | ||||
SYSCTL_ADD_PROC(ctx, ctx_list, OID_AUTO, | |||||
"link_active_on_if_down", | |||||
CTLTYPE_INT | CTLFLAG_RWTUN, | |||||
pf, 0, ixl_sysctl_set_link_active, "I", | |||||
IXL_SYSCTL_HELP_SET_LINK_ACTIVE); | |||||
/* Add sysctls meant to print debug information, but don't list them | /* Add sysctls meant to print debug information, but don't list them | ||||
* in "sysctl -a" output. */ | * in "sysctl -a" output. */ | ||||
debug_node = SYSCTL_ADD_NODE(ctx, ctx_list, | debug_node = SYSCTL_ADD_NODE(ctx, ctx_list, | ||||
OID_AUTO, "debug", CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, | OID_AUTO, "debug", CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, | ||||
"Debug Sysctls"); | "Debug Sysctls"); | ||||
debug_list = SYSCTL_CHILDREN(debug_node); | debug_list = SYSCTL_CHILDREN(debug_node); | ||||
SYSCTL_ADD_UINT(ctx, debug_list, | SYSCTL_ADD_UINT(ctx, debug_list, | ||||
OID_AUTO, "shared_debug_mask", CTLFLAG_RW, | OID_AUTO, "shared_debug_mask", CTLFLAG_RW, | ||||
&pf->hw.debug_mask, 0, "Shared code debug message level"); | &pf->hw.debug_mask, 0, "Shared code debug message level"); | ||||
SYSCTL_ADD_UINT(ctx, debug_list, | SYSCTL_ADD_UINT(ctx, debug_list, | ||||
OID_AUTO, "core_debug_mask", CTLFLAG_RW, | OID_AUTO, "core_debug_mask", CTLFLAG_RW, | ||||
&pf->dbg_mask, 0, "Non-shared code debug message level"); | &pf->dbg_mask, 0, "Non-shared code debug message level"); | ||||
SYSCTL_ADD_PROC(ctx, debug_list, | SYSCTL_ADD_PROC(ctx, debug_list, | ||||
OID_AUTO, "link_status", | OID_AUTO, "link_status", | ||||
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | ||||
pf, 0, ixl_sysctl_link_status, "A", IXL_SYSCTL_HELP_LINK_STATUS); | pf, 0, ixl_sysctl_link_status, "A", IXL_SYSCTL_HELP_LINK_STATUS); | ||||
SYSCTL_ADD_PROC(ctx, debug_list, | SYSCTL_ADD_PROC(ctx, debug_list, | ||||
OID_AUTO, "phy_abilities_init", | |||||
CTLTYPE_STRING | CTLFLAG_RD, | |||||
pf, 1, ixl_sysctl_phy_abilities, "A", "Initial PHY Abilities"); | |||||
SYSCTL_ADD_PROC(ctx, debug_list, | |||||
OID_AUTO, "phy_abilities", | OID_AUTO, "phy_abilities", | ||||
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | ||||
pf, 0, ixl_sysctl_phy_abilities, "A", "PHY Abilities"); | pf, 0, ixl_sysctl_phy_abilities, "A", "PHY Abilities"); | ||||
SYSCTL_ADD_PROC(ctx, debug_list, | SYSCTL_ADD_PROC(ctx, debug_list, | ||||
OID_AUTO, "filter_list", | OID_AUTO, "filter_list", | ||||
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | ||||
pf, 0, ixl_sysctl_sw_filter_list, "A", "SW Filter List"); | pf, 0, ixl_sysctl_sw_filter_list, "A", "SW Filter List"); | ||||
▲ Show 20 Lines • Show All 566 Lines • ▼ Show 20 Lines | port_matched = ((reg & I40E_GLGEN_MDIO_I2C_SEL_PHY_PORT_NUM_MASK) | ||||
& BIT(hw->port); | & BIT(hw->port); | ||||
if (i2c_en && port_matched) | if (i2c_en && port_matched) | ||||
return (i); | return (i); | ||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } | ||||
void | |||||
ixl_set_link(struct ixl_pf *pf, bool enable) | |||||
{ | |||||
struct i40e_hw *hw = &pf->hw; | |||||
device_t dev = pf->dev; | |||||
struct i40e_aq_get_phy_abilities_resp abilities; | |||||
struct i40e_aq_set_phy_config config; | |||||
enum i40e_status_code aq_error = 0; | |||||
u32 phy_type, phy_type_ext; | |||||
/* Get initial capability information */ | |||||
aq_error = i40e_aq_get_phy_capabilities(hw, | |||||
FALSE, TRUE, &abilities, NULL); | |||||
if (aq_error) { | |||||
device_printf(dev, | |||||
"%s: Error getting phy capabilities %d," | |||||
" aq error: %d\n", __func__, aq_error, | |||||
hw->aq.asq_last_status); | |||||
return; | |||||
} | |||||
phy_type = abilities.phy_type; | |||||
phy_type_ext = abilities.phy_type_ext; | |||||
/* Get current capability information */ | |||||
aq_error = i40e_aq_get_phy_capabilities(hw, | |||||
FALSE, FALSE, &abilities, NULL); | |||||
if (aq_error) { | |||||
device_printf(dev, | |||||
"%s: Error getting phy capabilities %d," | |||||
" aq error: %d\n", __func__, aq_error, | |||||
hw->aq.asq_last_status); | |||||
return; | |||||
} | |||||
/* Prepare new config */ | |||||
memset(&config, 0, sizeof(config)); | |||||
config.link_speed = abilities.link_speed; | |||||
config.abilities = abilities.abilities; | |||||
config.eee_capability = abilities.eee_capability; | |||||
config.eeer = abilities.eeer_val; | |||||
config.low_power_ctrl = abilities.d3_lpan; | |||||
config.fec_config = abilities.fec_cfg_curr_mod_ext_info | |||||
& I40E_AQ_PHY_FEC_CONFIG_MASK; | |||||
config.phy_type = 0; | |||||
config.phy_type_ext = 0; | |||||
if (enable) { | |||||
config.phy_type = phy_type; | |||||
config.phy_type_ext = phy_type_ext; | |||||
config.abilities &= ~(I40E_AQ_PHY_FLAG_PAUSE_TX | | |||||
I40E_AQ_PHY_FLAG_PAUSE_RX); | |||||
switch (pf->fc) { | |||||
case I40E_FC_FULL: | |||||
config.abilities |= I40E_AQ_PHY_FLAG_PAUSE_TX | | |||||
I40E_AQ_PHY_FLAG_PAUSE_RX; | |||||
break; | |||||
case I40E_FC_RX_PAUSE: | |||||
config.abilities |= I40E_AQ_PHY_FLAG_PAUSE_RX; | |||||
break; | |||||
case I40E_FC_TX_PAUSE: | |||||
config.abilities |= I40E_AQ_PHY_FLAG_PAUSE_TX; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
aq_error = i40e_aq_set_phy_config(hw, &config, NULL); | |||||
if (aq_error) { | |||||
device_printf(dev, | |||||
"%s: Error setting new phy config %d," | |||||
" aq error: %d\n", __func__, aq_error, | |||||
hw->aq.asq_last_status); | |||||
return; | |||||
} | |||||
aq_error = i40e_aq_set_link_restart_an(hw, enable, NULL); | |||||
if (aq_error) { | |||||
device_printf(dev, | |||||
"%s: Error set link config %d," | |||||
" aq error: %d\n", __func__, aq_error, | |||||
hw->aq.asq_last_status); | |||||
return; | |||||
} | |||||
} | |||||
static char * | static char * | ||||
ixl_phy_type_string(u32 bit_pos, bool ext) | ixl_phy_type_string(u32 bit_pos, bool ext) | ||||
{ | { | ||||
static char * phy_types_str[32] = { | static char * phy_types_str[32] = { | ||||
"SGMII", | "SGMII", | ||||
"1000BASE-KX", | "1000BASE-KX", | ||||
"10GBASE-KX4", | "10GBASE-KX4", | ||||
"10GBASE-KR", | "10GBASE-KR", | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | ixl_sysctl_phy_abilities(SYSCTL_HANDLER_ARGS) | ||||
buf = sbuf_new_for_sysctl(NULL, NULL, 128, req); | buf = sbuf_new_for_sysctl(NULL, NULL, 128, req); | ||||
if (!buf) { | if (!buf) { | ||||
device_printf(dev, "Could not allocate sbuf for sysctl output.\n"); | device_printf(dev, "Could not allocate sbuf for sysctl output.\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
status = i40e_aq_get_phy_capabilities(hw, | status = i40e_aq_get_phy_capabilities(hw, | ||||
FALSE, FALSE, &abilities, NULL); | FALSE, arg2 != 0, &abilities, NULL); | ||||
if (status) { | if (status) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"%s: i40e_aq_get_phy_capabilities() status %s, aq error %s\n", | "%s: i40e_aq_get_phy_capabilities() status %s, aq error %s\n", | ||||
__func__, i40e_stat_str(hw, status), | __func__, i40e_stat_str(hw, status), | ||||
i40e_aq_str(hw, hw->aq.asq_last_status)); | i40e_aq_str(hw, hw->aq.asq_last_status)); | ||||
sbuf_delete(buf); | sbuf_delete(buf); | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,133 Lines • ▼ Show 20 Lines | else | ||||
atomic_set_32(&pf->state, IXL_PF_STATE_EEE_ENABLED); | atomic_set_32(&pf->state, IXL_PF_STATE_EEE_ENABLED); | ||||
} else if (cmd_status == I40E_ERR_CONFIG) | } else if (cmd_status == I40E_ERR_CONFIG) | ||||
return (EPERM); | return (EPERM); | ||||
else | else | ||||
return (EIO); | return (EIO); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
ixl_sysctl_set_link_active(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
struct ixl_pf *pf = (struct ixl_pf *)arg1; | |||||
int error, state; | |||||
state = !!(atomic_load_acq_32(&pf->state) & | |||||
IXL_PF_STATE_LINK_ACTIVE_ON_DOWN); | |||||
error = sysctl_handle_int(oidp, &state, 0, req); | |||||
if ((error) || (req->newptr == NULL)) | |||||
return (error); | |||||
if (state == 0) | |||||
atomic_clear_32(&pf->state, IXL_PF_STATE_LINK_ACTIVE_ON_DOWN); | |||||
else | |||||
atomic_set_32(&pf->state, IXL_PF_STATE_LINK_ACTIVE_ON_DOWN); | |||||
return (0); | |||||
} | |||||
int | int | ||||
ixl_attach_get_link_status(struct ixl_pf *pf) | ixl_attach_get_link_status(struct ixl_pf *pf) | ||||
{ | { | ||||
struct i40e_hw *hw = &pf->hw; | struct i40e_hw *hw = &pf->hw; | ||||
device_t dev = pf->dev; | device_t dev = pf->dev; | ||||
int error = 0; | int error = 0; | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |