提交 3f13f570 编写于 作者: W Wojciech Drewek 提交者: Tony Nguyen

ice: Refactor PR ethtool ops

This patch improves a few things:

- it fixes issue where ethtool -i reports that PR supports
  priv-flags and tests when in fact it does not support them
- instead of using the same functions for both PF and PR ethtool ops,
  this patch introduces separate ops for both cases and internal
  functions with core logic.
- prevent accessing VF VSI while VF is not ready by calling
  ice_check_vf_ready_for_cfg
- all PR specific functions in ethtool.c were moved to one place in
  file
- instead overwriting n_priv_flags in ice_repr_get_drvinfo,
  priv-flags code was moved from __ice_get_drvinfo to ice_get_drvinfo
Signed-off-by: NWojciech Drewek <wojciech.drewek@intel.com>
Tested-by: NSandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
上级 73b483b7
...@@ -192,7 +192,6 @@ __ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo, ...@@ -192,7 +192,6 @@ __ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo,
strscpy(drvinfo->bus_info, pci_name(pf->pdev), strscpy(drvinfo->bus_info, pci_name(pf->pdev),
sizeof(drvinfo->bus_info)); sizeof(drvinfo->bus_info));
drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE;
} }
static void static void
...@@ -201,18 +200,8 @@ ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) ...@@ -201,18 +200,8 @@ ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_netdev_priv *np = netdev_priv(netdev);
__ice_get_drvinfo(netdev, drvinfo, np->vsi); __ice_get_drvinfo(netdev, drvinfo, np->vsi);
}
static void
ice_repr_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{
struct ice_repr *repr = ice_netdev_to_repr(netdev);
if (ice_check_vf_ready_for_cfg(repr->vf))
return;
__ice_get_drvinfo(netdev, drvinfo, repr->src_vsi); drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE;
} }
static int ice_get_regs_len(struct net_device __always_unused *netdev) static int ice_get_regs_len(struct net_device __always_unused *netdev)
...@@ -886,10 +875,10 @@ ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test, ...@@ -886,10 +875,10 @@ ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test,
netdev_info(netdev, "testing finished\n"); netdev_info(netdev, "testing finished\n");
} }
static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data) static void
__ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,
struct ice_vsi *vsi)
{ {
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = ice_get_netdev_priv_vsi(np);
unsigned int i; unsigned int i;
u8 *p = data; u8 *p = data;
...@@ -940,6 +929,13 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -940,6 +929,13 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
} }
} }
static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{
struct ice_netdev_priv *np = netdev_priv(netdev);
__ice_get_strings(netdev, stringset, data, np->vsi);
}
static int static int
ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state) ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state)
{ {
...@@ -1331,9 +1327,6 @@ static int ice_get_sset_count(struct net_device *netdev, int sset) ...@@ -1331,9 +1327,6 @@ static int ice_get_sset_count(struct net_device *netdev, int sset)
* order of strings will suffer from race conditions and are * order of strings will suffer from race conditions and are
* not safe. * not safe.
*/ */
if (ice_is_port_repr_netdev(netdev))
return ICE_VSI_STATS_LEN;
return ICE_ALL_STATS_LEN(netdev); return ICE_ALL_STATS_LEN(netdev);
case ETH_SS_TEST: case ETH_SS_TEST:
return ICE_TEST_LEN; return ICE_TEST_LEN;
...@@ -1345,11 +1338,10 @@ static int ice_get_sset_count(struct net_device *netdev, int sset) ...@@ -1345,11 +1338,10 @@ static int ice_get_sset_count(struct net_device *netdev, int sset)
} }
static void static void
ice_get_ethtool_stats(struct net_device *netdev, __ice_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats __always_unused *stats, u64 *data) struct ethtool_stats __always_unused *stats, u64 *data,
struct ice_vsi *vsi)
{ {
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = ice_get_netdev_priv_vsi(np);
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
struct ice_tx_ring *tx_ring; struct ice_tx_ring *tx_ring;
struct ice_rx_ring *rx_ring; struct ice_rx_ring *rx_ring;
...@@ -1416,6 +1408,15 @@ ice_get_ethtool_stats(struct net_device *netdev, ...@@ -1416,6 +1408,15 @@ ice_get_ethtool_stats(struct net_device *netdev,
} }
} }
static void
ice_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats __always_unused *stats, u64 *data)
{
struct ice_netdev_priv *np = netdev_priv(netdev);
__ice_get_ethtool_stats(netdev, stats, data, np->vsi);
}
#define ICE_PHY_TYPE_LOW_MASK_MIN_1G (ICE_PHY_TYPE_LOW_100BASE_TX | \ #define ICE_PHY_TYPE_LOW_MASK_MIN_1G (ICE_PHY_TYPE_LOW_100BASE_TX | \
ICE_PHY_TYPE_LOW_100M_SGMII) ICE_PHY_TYPE_LOW_100M_SGMII)
...@@ -3839,6 +3840,54 @@ ice_set_per_q_coalesce(struct net_device *netdev, u32 q_num, ...@@ -3839,6 +3840,54 @@ ice_set_per_q_coalesce(struct net_device *netdev, u32 q_num,
return __ice_set_coalesce(netdev, ec, q_num); return __ice_set_coalesce(netdev, ec, q_num);
} }
static void
ice_repr_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{
struct ice_repr *repr = ice_netdev_to_repr(netdev);
if (ice_check_vf_ready_for_cfg(repr->vf))
return;
__ice_get_drvinfo(netdev, drvinfo, repr->src_vsi);
}
static void
ice_repr_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{
struct ice_repr *repr = ice_netdev_to_repr(netdev);
/* for port representors only ETH_SS_STATS is supported */
if (ice_check_vf_ready_for_cfg(repr->vf) ||
stringset != ETH_SS_STATS)
return;
__ice_get_strings(netdev, stringset, data, repr->src_vsi);
}
static void
ice_repr_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats __always_unused *stats,
u64 *data)
{
struct ice_repr *repr = ice_netdev_to_repr(netdev);
if (ice_check_vf_ready_for_cfg(repr->vf))
return;
__ice_get_ethtool_stats(netdev, stats, data, repr->src_vsi);
}
static int ice_repr_get_sset_count(struct net_device *netdev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
return ICE_VSI_STATS_LEN;
default:
return -EOPNOTSUPP;
}
}
#define ICE_I2C_EEPROM_DEV_ADDR 0xA0 #define ICE_I2C_EEPROM_DEV_ADDR 0xA0
#define ICE_I2C_EEPROM_DEV_ADDR2 0xA2 #define ICE_I2C_EEPROM_DEV_ADDR2 0xA2
#define ICE_MODULE_TYPE_SFP 0x03 #define ICE_MODULE_TYPE_SFP 0x03
...@@ -4093,9 +4142,9 @@ void ice_set_ethtool_safe_mode_ops(struct net_device *netdev) ...@@ -4093,9 +4142,9 @@ void ice_set_ethtool_safe_mode_ops(struct net_device *netdev)
static const struct ethtool_ops ice_ethtool_repr_ops = { static const struct ethtool_ops ice_ethtool_repr_ops = {
.get_drvinfo = ice_repr_get_drvinfo, .get_drvinfo = ice_repr_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_strings = ice_get_strings, .get_strings = ice_repr_get_strings,
.get_ethtool_stats = ice_get_ethtool_stats, .get_ethtool_stats = ice_repr_get_ethtool_stats,
.get_sset_count = ice_get_sset_count, .get_sset_count = ice_repr_get_sset_count,
}; };
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册