/** * struct i40e_stats - definition for an ethtool statistic * @stat_string: statistic name to display in ethtool -S output * @sizeof_stat: the sizeof() the stat, must be no greater than sizeof(u64) * @stat_offset: offsetof() the stat from a base pointer * * This structure defines a statistic to be added to the ethtool stats buffer. * It defines a statistic as offset from a common base pointer. Stats should * be defined in constant arrays using the I40E_STAT macro, with every element * of the array using the same _type for calculating the sizeof_stat and * stat_offset. * * The @sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or * sizeof(u64). Other sizes are not expected and will produce a WARN_ONCE from * the i40e_add_ethtool_stat() helper function. * * The @stat_string is interpreted as a format string, allowing formatted * values to be inserted while looping over multiple structures for a given * statistics array. Thus, every statistic string in an array should have the * same type and number of format specifiers, to be formatted by variadic * arguments to the i40e_add_stat_string() helper function.
**/ struct i40e_stats { char stat_string[ETH_GSTRING_LEN]; int sizeof_stat; int stat_offset;
};
/* Helper macro to define an i40e_stat structure with proper size and type. * Use this when defining constant statistics arrays. Note that @_type expects * only a type name and is used multiple times.
*/ #define I40E_STAT(_type, _name, _stat) { \
.stat_string = _name, \
.sizeof_stat = sizeof_field(_type, _stat), \
.stat_offset = offsetof(_type, _stat) \
}
/* Helper macro for defining some statistics directly copied from the netdev * stats structure.
*/ #define I40E_NETDEV_STAT(_net_stat) \
I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
/* Helper macro for defining some statistics related to queues */ #define I40E_QUEUE_STAT(_name, _stat) \
I40E_STAT(struct i40e_ring, _name, _stat)
/* Stats associated with a Tx or Rx ring */ staticconststruct i40e_stats i40e_gstrings_queue_stats[] = {
I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
};
/** * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer * @data: location to store the stat value * @pointer: basis for where to copy from * @stat: the stat definition * * Copies the stat data defined by the pointer and stat structure pair into * the memory supplied as data. Used to implement i40e_add_ethtool_stats and * i40e_add_queue_stats. If the pointer is null, data will be zero'd.
*/ staticvoid
i40e_add_one_ethtool_stat(u64 *data, void *pointer, conststruct i40e_stats *stat)
{ char *p;
if (!pointer) { /* ensure that the ethtool data buffer is zero'd for any stats * which don't have a valid pointer.
*/
*data = 0; return;
}
/** * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer * @data: ethtool stats buffer * @pointer: location to copy stats from * @stats: array of stats to copy * @size: the size of the stats definition * * Copy the stats defined by the stats array using the pointer as a base into * the data buffer supplied by ethtool. Updates the data pointer to point to * the next empty location for successive calls to __i40e_add_ethtool_stats. * If pointer is null, set the data values to zero and update the pointer to * skip these stats.
**/ staticvoid
__i40e_add_ethtool_stats(u64 **data, void *pointer, conststruct i40e_stats stats[], constunsignedint size)
{ unsignedint i;
for (i = 0; i < size; i++)
i40e_add_one_ethtool_stat((*data)++, pointer, &stats[i]);
}
/** * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer * @data: ethtool stats buffer * @pointer: location where stats are stored * @stats: static const array of stat definitions * * Macro to ease the use of __i40e_add_ethtool_stats by taking a static * constant stats array and passing the ARRAY_SIZE(). This avoids typos by * ensuring that we pass the size associated with the given stats array. * * The parameter @stats is evaluated twice, so parameters with side effects * should be avoided.
**/ #define i40e_add_ethtool_stats(data, pointer, stats) \
__i40e_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
/** * i40e_add_queue_stats - copy queue statistics into supplied buffer * @data: ethtool stats buffer * @ring: the ring to copy * * Queue statistics must be copied while protected by * u64_stats_fetch_begin, so we can't directly use i40e_add_ethtool_stats. * Assumes that queue stats are defined in i40e_gstrings_queue_stats. If the * ring pointer is null, zero out the queue stat values and update the data * pointer. Otherwise safely copy the stats from the ring into the supplied * buffer and update the data pointer when finished. * * This function expects to be called while under rcu_read_lock().
**/ staticvoid
i40e_add_queue_stats(u64 **data, struct i40e_ring *ring)
{ constunsignedint size = ARRAY_SIZE(i40e_gstrings_queue_stats); conststruct i40e_stats *stats = i40e_gstrings_queue_stats; unsignedint start; unsignedint i;
/* To avoid invalid statistics values, ensure that we keep retrying * the copy until we get a consistent value according to * u64_stats_fetch_retry. But first, make sure our ring is * non-null before attempting to access its syncp.
*/ do {
start = !ring ? 0 : u64_stats_fetch_begin(&ring->syncp); for (i = 0; i < size; i++) {
i40e_add_one_ethtool_stat(&(*data)[i], ring,
&stats[i]);
}
} while (ring && u64_stats_fetch_retry(&ring->syncp, start));
/* Once we successfully copy the stats in, update the data pointer */
*data += size;
}
/** * __i40e_add_stat_strings - copy stat strings into ethtool buffer * @p: ethtool supplied buffer * @stats: stat definitions array * @size: size of the stats array * * Format and copy the strings described by stats into the buffer pointed at * by p.
**/ staticvoid __i40e_add_stat_strings(u8 **p, conststruct i40e_stats stats[], constunsignedint size, ...)
{ unsignedint i;
/** * i40e_add_stat_strings - copy stat strings into ethtool buffer * @p: ethtool supplied buffer * @stats: stat definitions array * * Format and copy the strings described by the const static stats value into * the buffer pointed at by p. * * The parameter @stats is evaluated twice, so parameters with side effects * should be avoided. Additionally, stats must be an array such that * ARRAY_SIZE can be called on it.
**/ #define i40e_add_stat_strings(p, stats, ...) \
__i40e_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
/* These PF_STATs might look like duplicates of some NETDEV_STATs, * but they are separate. This device supports Virtualization, and * as such might have several netdevs supporting VMDq and FCoE going * through a single port. The NETDEV_STATs are for individual netdevs * seen at the top of the stack, and the PF_STATs are for the physical * function at the bottom of the stack hosting those netdevs. * * The PF_STATs are appended to the netdev stats only when ethtool -S * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
*/ staticconststruct i40e_stats i40e_gstrings_stats[] = {
I40E_PF_STAT("port.rx_bytes", stats.eth.rx_bytes),
I40E_PF_STAT("port.tx_bytes", stats.eth.tx_bytes),
I40E_PF_STAT("port.rx_unicast", stats.eth.rx_unicast),
I40E_PF_STAT("port.tx_unicast", stats.eth.tx_unicast),
I40E_PF_STAT("port.rx_multicast", stats.eth.rx_multicast),
I40E_PF_STAT("port.tx_multicast", stats.eth.tx_multicast),
I40E_PF_STAT("port.rx_broadcast", stats.eth.rx_broadcast),
I40E_PF_STAT("port.tx_broadcast", stats.eth.tx_broadcast),
I40E_PF_STAT("port.tx_errors", stats.eth.tx_errors),
I40E_PF_STAT("port.rx_discards", stats.eth.rx_discards),
I40E_PF_STAT("port.tx_dropped_link_down", stats.tx_dropped_link_down),
I40E_PF_STAT("port.rx_crc_errors", stats.crc_errors),
I40E_PF_STAT("port.illegal_bytes", stats.illegal_bytes),
I40E_PF_STAT("port.mac_local_faults", stats.mac_local_faults),
I40E_PF_STAT("port.mac_remote_faults", stats.mac_remote_faults),
I40E_PF_STAT("port.tx_timeout", tx_timeout_count),
I40E_PF_STAT("port.rx_csum_bad", hw_csum_rx_error),
I40E_PF_STAT("port.rx_length_errors", stats.rx_length_errors),
I40E_PF_STAT("port.link_xon_rx", stats.link_xon_rx),
I40E_PF_STAT("port.link_xoff_rx", stats.link_xoff_rx),
I40E_PF_STAT("port.link_xon_tx", stats.link_xon_tx),
I40E_PF_STAT("port.link_xoff_tx", stats.link_xoff_tx),
I40E_PF_STAT("port.rx_size_64", stats.rx_size_64),
I40E_PF_STAT("port.rx_size_127", stats.rx_size_127),
I40E_PF_STAT("port.rx_size_255", stats.rx_size_255),
I40E_PF_STAT("port.rx_size_511", stats.rx_size_511),
I40E_PF_STAT("port.rx_size_1023", stats.rx_size_1023),
I40E_PF_STAT("port.rx_size_1522", stats.rx_size_1522),
I40E_PF_STAT("port.rx_size_big", stats.rx_size_big),
I40E_PF_STAT("port.tx_size_64", stats.tx_size_64),
I40E_PF_STAT("port.tx_size_127", stats.tx_size_127),
I40E_PF_STAT("port.tx_size_255", stats.tx_size_255),
I40E_PF_STAT("port.tx_size_511", stats.tx_size_511),
I40E_PF_STAT("port.tx_size_1023", stats.tx_size_1023),
I40E_PF_STAT("port.tx_size_1522", stats.tx_size_1522),
I40E_PF_STAT("port.tx_size_big", stats.tx_size_big),
I40E_PF_STAT("port.rx_undersize", stats.rx_undersize),
I40E_PF_STAT("port.rx_fragments", stats.rx_fragments),
I40E_PF_STAT("port.rx_oversize", stats.rx_oversize),
I40E_PF_STAT("port.rx_jabber", stats.rx_jabber),
I40E_PF_STAT("port.VF_admin_queue_requests", vf_aq_requests),
I40E_PF_STAT("port.arq_overflows", arq_overflows),
I40E_PF_STAT("port.tx_hwtstamp_timeouts", tx_hwtstamp_timeouts),
I40E_PF_STAT("port.rx_hwtstamp_cleared", rx_hwtstamp_cleared),
I40E_PF_STAT("port.tx_hwtstamp_skipped", tx_hwtstamp_skipped),
I40E_PF_STAT("port.fdir_flush_cnt", fd_flush_cnt),
I40E_PF_STAT("port.fdir_atr_match", stats.fd_atr_match),
I40E_PF_STAT("port.fdir_atr_tunnel_match", stats.fd_atr_tunnel_match),
I40E_PF_STAT("port.fdir_atr_status", stats.fd_atr_status),
I40E_PF_STAT("port.fdir_sb_match", stats.fd_sb_match),
I40E_PF_STAT("port.fdir_sb_status", stats.fd_sb_status),
staticconstchar i40e_gstrings_test[][ETH_GSTRING_LEN] = { "Register test (offline)", "Eeprom test (offline)", "Interrupt test (offline)", "Link test (on/offline)"
};
/** * i40e_partition_setting_complaint - generic complaint for MFP restriction * @pf: the PF struct
**/ staticvoid i40e_partition_setting_complaint(struct i40e_pf *pf)
{
dev_info(&pf->pdev->dev, "The link settings are allowed to be changed only from the first partition of a given port. Please switch to the first partition in order to change the setting.\n");
}
/** * i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes * @pf: PF struct with phy_types * @ks: ethtool link ksettings struct to fill out *
**/ staticvoid i40e_phy_type_to_ethtool(struct i40e_pf *pf, struct ethtool_link_ksettings *ks)
{ struct i40e_link_status *hw_link_info = &pf->hw.phy.link_info;
u64 phy_types = pf->hw.phy.phy_types;
/** * i40e_get_settings_link_up - Get the Link settings for when link is up * @hw: hw structure * @ks: ethtool ksettings to fill in * @netdev: network interface device structure * @pf: pointer to physical function struct
**/ staticvoid i40e_get_settings_link_up(struct i40e_hw *hw, struct ethtool_link_ksettings *ks, struct net_device *netdev, struct i40e_pf *pf)
{ struct i40e_link_status *hw_link_info = &hw->phy.link_info; struct ethtool_link_ksettings cap_ksettings;
u32 link_speed = hw_link_info->link_speed;
/* Initialize supported and advertised settings based on phy settings */ switch (hw_link_info->phy_type) { case I40E_PHY_TYPE_40GBASE_CR4: case I40E_PHY_TYPE_40GBASE_CR4_CU:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
40000baseCR4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising,
40000baseCR4_Full); break; case I40E_PHY_TYPE_XLAUI: case I40E_PHY_TYPE_XLPPI: case I40E_PHY_TYPE_40GBASE_AOC:
ethtool_link_ksettings_add_link_mode(ks, supported,
40000baseCR4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
40000baseCR4_Full); break; case I40E_PHY_TYPE_40GBASE_SR4:
ethtool_link_ksettings_add_link_mode(ks, supported,
40000baseSR4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
40000baseSR4_Full); break; case I40E_PHY_TYPE_40GBASE_LR4:
ethtool_link_ksettings_add_link_mode(ks, supported,
40000baseLR4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
40000baseLR4_Full); break; case I40E_PHY_TYPE_25GBASE_SR: case I40E_PHY_TYPE_25GBASE_LR: case I40E_PHY_TYPE_10GBASE_SR: case I40E_PHY_TYPE_10GBASE_LR: case I40E_PHY_TYPE_1000BASE_SX: case I40E_PHY_TYPE_1000BASE_LX:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
25000baseSR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
25000baseSR_Full);
i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseSR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseSR_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseLR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseLR_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseX_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
1000baseX_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseT_Full); if (hw_link_info->module_type[2] &
I40E_MODULE_TYPE_1000BASE_SX ||
hw_link_info->module_type[2] &
I40E_MODULE_TYPE_1000BASE_LX) {
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseT_Full); if (hw_link_info->requested_speeds &
I40E_LINK_SPEED_1GB)
ethtool_link_ksettings_add_link_mode(
ks, advertising, 1000baseT_Full);
} if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseT_Full); break; case I40E_PHY_TYPE_10GBASE_T: case I40E_PHY_TYPE_5GBASE_T_LINK_STATUS: case I40E_PHY_TYPE_2_5GBASE_T_LINK_STATUS: case I40E_PHY_TYPE_1000BASE_T: case I40E_PHY_TYPE_100BASE_TX:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
5000baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
2500baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
100baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_5GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
5000baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_2_5GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
2500baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
1000baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
100baseT_Full); break; case I40E_PHY_TYPE_1000BASE_T_OPTICAL:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising,
1000baseT_Full); break; case I40E_PHY_TYPE_10GBASE_CR1_CU: case I40E_PHY_TYPE_10GBASE_CR1:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseT_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseT_Full); break; case I40E_PHY_TYPE_XAUI: case I40E_PHY_TYPE_XFI: case I40E_PHY_TYPE_SFI: case I40E_PHY_TYPE_10GBASE_SFPP_CU: case I40E_PHY_TYPE_10GBASE_AOC:
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseT_Full);
i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks); break; case I40E_PHY_TYPE_SGMII:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseT_Full); if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
ethtool_link_ksettings_add_link_mode(ks, advertising,
1000baseT_Full); if (test_bit(I40E_HW_CAP_100M_SGMII, pf->hw.caps)) {
ethtool_link_ksettings_add_link_mode(ks, supported,
100baseT_Full); if (hw_link_info->requested_speeds &
I40E_LINK_SPEED_100MB)
ethtool_link_ksettings_add_link_mode(
ks, advertising, 100baseT_Full);
} break; case I40E_PHY_TYPE_40GBASE_KR4: case I40E_PHY_TYPE_25GBASE_KR: case I40E_PHY_TYPE_20GBASE_KR2: case I40E_PHY_TYPE_10GBASE_KR: case I40E_PHY_TYPE_10GBASE_KX4: case I40E_PHY_TYPE_1000BASE_KX:
ethtool_link_ksettings_add_link_mode(ks, supported,
40000baseKR4_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
25000baseKR_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
20000baseKR2_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseKR_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseKX4_Full);
ethtool_link_ksettings_add_link_mode(ks, supported,
1000baseKX_Full);
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising,
40000baseKR4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
25000baseKR_Full);
i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks);
ethtool_link_ksettings_add_link_mode(ks, advertising,
20000baseKR2_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseKR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseKX4_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
1000baseKX_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); break; case I40E_PHY_TYPE_25GBASE_CR:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
25000baseCR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
25000baseCR_Full);
i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks);
break; case I40E_PHY_TYPE_25GBASE_AOC: case I40E_PHY_TYPE_25GBASE_ACC:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported,
25000baseCR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
25000baseCR_Full);
i40e_get_settings_link_up_fec(hw_link_info->req_fec_info, ks);
ethtool_link_ksettings_add_link_mode(ks, supported,
10000baseCR_Full);
ethtool_link_ksettings_add_link_mode(ks, advertising,
10000baseCR_Full); break; default: /* if we got here and link is up something bad is afoot */
netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized, or incorrect cable is in use\n",
hw_link_info->phy_type);
}
/* Now that we've worked out everything that could be supported by the * current PHY type, get what is supported by the NVM and intersect * them to get what is truly supported
*/
memset(&cap_ksettings, 0, sizeof(struct ethtool_link_ksettings));
i40e_phy_type_to_ethtool(pf, &cap_ksettings);
ethtool_intersect_link_masks(ks, &cap_ksettings);
/* Set speed and duplex */ switch (link_speed) { case I40E_LINK_SPEED_40GB:
ks->base.speed = SPEED_40000; break; case I40E_LINK_SPEED_25GB:
ks->base.speed = SPEED_25000; break; case I40E_LINK_SPEED_20GB:
ks->base.speed = SPEED_20000; break; case I40E_LINK_SPEED_10GB:
ks->base.speed = SPEED_10000; break; case I40E_LINK_SPEED_5GB:
ks->base.speed = SPEED_5000; break; case I40E_LINK_SPEED_2_5GB:
ks->base.speed = SPEED_2500; break; case I40E_LINK_SPEED_1GB:
ks->base.speed = SPEED_1000; break; case I40E_LINK_SPEED_100MB:
ks->base.speed = SPEED_100; break; default:
ks->base.speed = SPEED_UNKNOWN; break;
}
ks->base.duplex = DUPLEX_FULL;
}
/** * i40e_get_settings_link_down - Get the Link settings for when link is down * @hw: hw structure * @ks: ethtool ksettings to fill in * @pf: pointer to physical function struct * * Reports link settings that can be determined when link is down
**/ staticvoid i40e_get_settings_link_down(struct i40e_hw *hw, struct ethtool_link_ksettings *ks, struct i40e_pf *pf)
{ /* link is down and the driver needs to fall back on * supported phy types to figure out what info to display
*/
i40e_phy_type_to_ethtool(pf, ks);
/* With no link speed and duplex are unknown */
ks->base.speed = SPEED_UNKNOWN;
ks->base.duplex = DUPLEX_UNKNOWN;
}
if (link_up)
i40e_get_settings_link_up(hw, ks, netdev, pf); else
i40e_get_settings_link_down(hw, ks, pf);
/* Now set the settings that don't rely on link being up/down */ /* Set autoneg settings */
ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
AUTONEG_ENABLE : AUTONEG_DISABLE);
/* Set media type settings */ switch (hw->phy.media_type) { case I40E_MEDIA_TYPE_BACKPLANE:
ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, supported, Backplane);
ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
ethtool_link_ksettings_add_link_mode(ks, advertising,
Backplane);
ks->base.port = PORT_NONE; break; case I40E_MEDIA_TYPE_BASET:
ethtool_link_ksettings_add_link_mode(ks, supported, TP);
ethtool_link_ksettings_add_link_mode(ks, advertising, TP);
ks->base.port = PORT_TP; break; case I40E_MEDIA_TYPE_DA: case I40E_MEDIA_TYPE_CX4:
ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE);
ks->base.port = PORT_DA; break; case I40E_MEDIA_TYPE_FIBER:
ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE);
ks->base.port = PORT_FIBRE; break; case I40E_MEDIA_TYPE_UNKNOWN: default:
ks->base.port = PORT_OTHER; break;
}
/* Set flow control settings */
ethtool_link_ksettings_add_link_mode(ks, supported, Pause);
ethtool_link_ksettings_add_link_mode(ks, supported, Asym_Pause);
/* save autoneg out of ksettings */
autoneg = copy_ks.base.autoneg;
speed = copy_ks.base.speed;
/* get our own copy of the bits to check against */
memset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings));
safe_ks.base.cmd = copy_ks.base.cmd;
safe_ks.base.link_mode_masks_nwords =
copy_ks.base.link_mode_masks_nwords;
i40e_get_link_ksettings(netdev, &safe_ks);
/* Get link modes supported by hardware and check against modes * requested by the user. Return an error if unsupported mode was set.
*/ if (!bitmap_subset(copy_ks.link_modes.advertising,
safe_ks.link_modes.supported,
__ETHTOOL_LINK_MODE_MASK_NBITS)) return -EINVAL;
/* set autoneg back to what it currently is */
copy_ks.base.autoneg = safe_ks.base.autoneg;
copy_ks.base.speed = safe_ks.base.speed;
while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) {
timeout--; if (!timeout) return -EBUSY;
usleep_range(1000, 2000);
}
/* Get the current phy config */
status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
NULL); if (status) {
err = -EAGAIN; goto done;
}
/* Copy abilities to config in case autoneg is not * set below
*/
memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
config.abilities = abilities.abilities;
/* Check autoneg */ if (autoneg == AUTONEG_ENABLE) { /* If autoneg was not already enabled */ if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { /* If autoneg is not supported, return error */ if (!ethtool_link_ksettings_test_link_mode(&safe_ks,
supported,
Autoneg)) {
netdev_info(netdev, "Autoneg not supported on this phy\n");
err = -EINVAL; goto done;
} /* Autoneg is allowed to change */
config.abilities = abilities.abilities |
I40E_AQ_PHY_ENABLE_AN;
autoneg_changed = true;
}
} else { /* If autoneg is currently enabled */ if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { /* If autoneg is supported 10GBASE_T is the only PHY * that can disable it, so otherwise return error
*/ if (ethtool_link_ksettings_test_link_mode(&safe_ks,
supported,
Autoneg) &&
hw->phy.media_type != I40E_MEDIA_TYPE_BASET) {
netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
err = -EINVAL; goto done;
} /* Autoneg is allowed to change */
config.abilities = abilities.abilities &
~I40E_AQ_PHY_ENABLE_AN;
autoneg_changed = true;
}
}
/* Autonegotiation must be disabled to change speed */ if ((speed != SPEED_UNKNOWN && safe_ks.base.speed != speed) &&
(autoneg == AUTONEG_DISABLE ||
(safe_ks.base.autoneg == AUTONEG_DISABLE && !autoneg_changed))) {
link_speed = i40e_speed_to_link_speed(speed, ks); if (link_speed == I40E_LINK_SPEED_UNKNOWN) {
netdev_info(netdev, "Given speed is not supported\n");
err = -EOPNOTSUPP; goto done;
} else {
config.link_speed = link_speed;
}
} else { if (safe_ks.base.speed != speed) {
netdev_info(netdev, "Unable to set speed, disable autoneg\n");
err = -EOPNOTSUPP; goto done;
}
}
/* If speed didn't get set, set it to what it currently is. * This is needed because if advertise is 0 (as it is when autoneg * is disabled) then speed won't get set.
*/ if (!config.link_speed)
config.link_speed = abilities.link_speed; if (autoneg_changed || abilities.link_speed != config.link_speed) { /* copy over the rest of the abilities */
config.phy_type = abilities.phy_type;
config.phy_type_ext = abilities.phy_type_ext;
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;
/* save the requested speeds */
hw->phy.link_info.requested_speeds = config.link_speed; /* set link and auto negotiation so changes take effect */
config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK; /* If link is up put link down */ if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { /* Tell the OS link is going down, the link will go * back up when fw says it is ready asynchronously
*/
i40e_print_link_message(vsi, false);
netif_carrier_off(netdev);
netif_tx_stop_all_queues(netdev);
}
/* make the aq call */
status = i40e_aq_set_phy_config(hw, &config, NULL); if (status) {
netdev_info(netdev, "Set phy config failed, err %pe aq_err %s\n",
ERR_PTR(status),
libie_aq_str(hw->aq.asq_last_status));
err = -EAGAIN; goto done;
}
status = i40e_update_link_info(hw); if (status)
netdev_dbg(netdev, "Updating link info failed with err %pe aq_err %s\n",
ERR_PTR(status),
libie_aq_str(hw->aq.asq_last_status));
if (hw->phylink_info.fec_infoI40E_AQ_CONFIG_FEC_KR_ENA
include"i40e_txrx_common." else"
fecparam->active_fec = ETHTOOL_FEC_RS; else
fecparam->active_fec = * @stat_offset: offsetof() the stat * This structure defines a statistic to be added to the ethtool * It defines a statistic as offset from * be defined in constant arrays using the * of the array using the same _type for calculating * The @sizeof_stat is expected to * sizeof(u64). Other sizes * the i40e_add_ethtool_stat() helper function.
done return err;
}
if(>device_id ! &&
hw->device_id! I40E_DEV_ID_25G_B &java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
hw->device_id != I40E_DEV_ID_KX_X722 * i40e_add_queue_stats. If the pointer is nulljava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0 return-;
if (hw-> * which don't have a valid pointer.
!test_bit(I40E_HW_CAP_X722_FEC_REQUEST, hw->caps)
netdev_err(netdev, "Setting FEC encodingnot supported byfirmware. Please update the NVM image.\n") return EOPNOTSUPP;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
switchfecparam-fec java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 caseETHTOOL_FEC_AUTO:
=I40E_AQ_SET_FEC_AUTO break case ETHTOOL_FEC_RS:
fec_cfg = (I40E_AQ_SET_FEC_REQUEST_RS |
I40E_AQ_SET_FEC_ABILITY_RS); break; case ETHTOOL_FEC_BASER:
* Copy the stats defined by the stats array using the pointer as * the data buffer supplied by ethtool. Updates the data pointer to point to
I40E_AQ_SET_FEC_ABILITY_KR); break; case ETHTOOL_FEC_OFF: case ETHTOOL_FEC_NONE:
fec_cfg = 0; break; default:
dev_warn(&pf->pdev->dev, "Unsupported FEC
fecparam-fec); return -EINVAL;
}
return i40e_set_fec_cfg{
}
staticint i40e_nway_reset(struct net_device i40e_add_one_ethtool_stat((*)++ , &[i)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
{ /* restart autonegotiation */
java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 struct i40e_pf *pf = np- * @data: ethtool * @ring: the ring to copy * struct i40e_hw * u64_stats_fetch_begin, so we can't directly use i40e_add_ethtool_stats. bool link_up = hw->phy * pointer. Otherwise safely copy the stats * buffer and update the data pointer *
nt retret =0;
ret=i40e_aq_set_link_restart_anhw, ijava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
(, linkfailed% s\n"
(ret,
&statsi])java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 return -java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return 0;
}
/** * i40e_get_pauseparam - Get Flow Control status * @netdev: netdevice structure * @pause: buffer to return pause parameters * * Return tx/rx-pause status
**/ static vsnprintf(,ETH_GSTRING_LEN, [i., args)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 struct ethtool_pauseparam * * @p: ethtool supplied * @stats: stat *
{ struct i40e_netdev_priv *np = netdev_priv(netdev * should be avoided. Additionally, stats must be an * ARRAY_SIZE can be called on struct i40e_pf *pf = np->vsi->back; struct i40e_hw *hw = &pf->hw; struct i40e_link_status *hw_link_info struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
/** * i40e_set_pauseparam - Set Flow Control parameter * @netdev: network interface device structure * @pause: return tx/rx flow control status
**/ staticint i40e_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
{ structi40e_netdev_priv* = (netdev
=>vsi-; struct i40e_vsi *vsi = np->vsi("veb.,stats.tx_discards, struct* &>; struct hw_link_info =&w-phylink_info struct i40e_dcbx_config tc_rx_packets bool = > &I40E_AQ_LINK_UP
u8 aq_failures; int err = 0; int status;
u32 is_an(vebtc_u_rx_bytes" tc_rx_bytes)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
/* Changing the port's flow control is not supported if this isn't the * port's controlling PF
*/ if (("" .)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
i40e_partition_setting_complainttx_stopped )
4E_VSI_STAT"" rx_page_failed),
}
if (vsi-STAT(rx_cache_waive,r), return -EOPNOTSUPP;
is_an = hw_link_info-> * but they are separate. This device supports Virtualization * as such might have several netdevs supporting VMDq * through a single port. The NETDEV_STATs are * seen at the top of the stack, and the * function at the bottom of the stack *
(>autoneg=is_an{
netdev_info(netdev, "To change autoneg please use returnEOPNOTSUPP
}
/* If we have link and don't have autoneg */
(test_bit__, >tate)& !) * Send message that it might not necessarily work*/I40E_PF_STAT"porttx_errors,statsethtx_errors,
(, Autonegdidsochanging ay otresultanactual\n)java.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
}
if (pause-> I40E_PF_STAT("port.", statslink_xon_tx)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
hw-fcrequested_mode=I40E_FC_FULL; elseif (pause->rx_pause && !pause->tx_pause)
(portrx_size_255, stats), elseif I40E_PF_STAT".rx_size_1023,statsrx_size_1023)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
hw-. I40E_FC_TX_PAUSE if (!>rx_pause& pause-)
hw->(".java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 53 else return (.rx_oversize statsrx_oversize)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
(port" )java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
*says it is ready asynchronously
*/
i40e_print_link_message(vsi, false);
netif_carrier_off(netdev);
netif_tx_stop_all_queues(netdev);
/* Set the fc mode and only restart an if link is up*/
status =i40e_set_fchw &aq_failures, link_up;
&) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
netdev_infonetdev "et fc failed on the get_phy_capabilities with err %peaq_err s\",
ERR_PTR(status),
libie_aq_str(I40E_PF_STAT(".tx_lpi_count, .tx_lpi_count),
err =;
} if( & I40E_SET_FC_AQ_FAIL_SET){
netdev_info(netdev, u64priority_xon_tx
ERR_PTR(status,
libie_aq_str(}
err =-EAGAIN;
} ifI40E_PFC_STAT"port.tx_priority_u_xoff_tx", priority_xoff_tx),
I40E_PFC_STAT(".%u_xon_rx",priority_xon_rx)
ERR_PTR(status),
libie_aq_str(hw->aq};
err = -EAGAIN# I40E_NETDEV_STATS_LEN ()
}
if (!test_bit(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
)
msleep(75 (ARRAY_SIZE(i40e_gstrings_veb_tc_stats)* \ if (!test_bit(__ I40E_MAX_TRAFFIC_CLASS returni40e_nway_reset(netdev)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
return err;
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{ structtest), struct i40e_pf *pf = np->vsi->back;
u32 debug_mask = pf->hw.debug_mask;
if (debug_mask)
netdev_info(netdev, "i40e debug_mask: 0x%08X\n", debug_mask);
return pf->msg_enablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
staticint i40e_get_regs_len(struct net_device *netdev)
{ int reg_count = 0; int i;
for ( 0 i40e_reg_list[].offset != 00;i+)
reg_count+ i40e_reg_list[i.;
return reg_count * sizeof(u32);
}
staticvoid i40e_get_regs(struct net_deviceI40E_PRIV_FLAG"", I40E_FLAG_HW_ATR_EVICT_ENA, 0), void *p)
{ struct i40e_netdev_priv *np = netdev_priv(netdevI40E_PRIV_FLAG("legacy-rx, , 0)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 struct i40e_pf* np-vsi-back structi40e_hw *hw=pf-hw;
u32 *I40E_PRIV_FLAGvf-vlan-pruning intj,;
;
/* Tell ethtool which driver-version-specific regs output we have. * * At some point, if we have ethtool doing special formatting of * this data, it will rely on this version number to know how to * interpret things. Hence, this needs to be updated if/when the * diags register table is changed.
*/
regs->version = 1;
/* loop through the diags reg table for what to print */
ri 0; for (i = 0; i40e_reg_list for e* i40e_phy_type_to_ethtool - convert the phy_types to ethtool link modes
reg = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
+ java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
reg_buf[ri++ u64 phy_types = pf->hw.phy.phy_types;
}
}
}
staticint i40e_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, u8 *bytes)
{ structi4e_netdev_priv* =netdev_priv(netdev;
&np-vsi-back->hw
i40e_pf*pf ==np->vsi->back;
java.lang.StringIndexOutOfBoundsException: Range [12, 4) out of bounds for length 30
u8eeprom_buffjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
u16 boolifphy_types&I40E_CAP_PHY_TYPE_XAUI|java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
#define I40E_NVM_SECTOR_SIZE 4 1000baseT_Full if (eeprom->len =(kssupported, return-;
/* check for NVMUpdate access method */
magic = hw->vendor_id | ethtool_link_ksettings_add_link_modeks supported if (eeprom->magic &e(ks, structi40e_nvm_access *md= structi40e_nvm_access)eeprom; int errno 50baseT_Full)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
00baseCR4_Full /* make sure it is the right magic for NVMUpdate */ if (( if (hw_link_info-requested_speeds &I40E_LINK_SPEED_40GBjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
errno = -EINVAL; else (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state ||
test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
ethtool_link_ksttings_add_link_mode(ks advertising, else
--> --------------------
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.