Skip to content

Commit 7a13240

Browse files
Edwin Peerdavem330
authored andcommitted
bnxt_en: fix ethtool_reset_flags ABI violations
The ethtool ABI specifies that the reset operation should only clear the flags that were actually reset. Setting the flags to zero after a chip reset violates this because it does not include resetting the application processor complex. Similarly, components that are not yet defined are also not necessarily being reset. The fact that chip reset does not cover the AP also means that it is inappropriate to treat these two components exclusively of one another. The ABI provides a mechanism to report a failure to reset independent components via the returned bitmask, so it is also wrong to fail hard if one of a set of independent resets is not possible. It is incorrect to rely on the passed by reference flags in bnxt_reset(), which are being updated as components are reset. The initially requested value should be used instead so that hard errors do not propagate if any earlier components could have been reset successfully. Note, AP and chip resets are global in nature. Dedicated resets are thus not currently supported. Signed-off-by: Edwin Peer <edwin.peer@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 94f17e8 commit 7a13240

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,7 +2999,10 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
29992999
static int bnxt_reset(struct net_device *dev, u32 *flags)
30003000
{
30013001
struct bnxt *bp = netdev_priv(dev);
3002-
int rc = 0;
3002+
u32 req = *flags;
3003+
3004+
if (!req)
3005+
return -EINVAL;
30033006

30043007
if (!BNXT_PF(bp)) {
30053008
netdev_err(dev, "Reset is not supported from a VF\n");
@@ -3013,33 +3016,33 @@ static int bnxt_reset(struct net_device *dev, u32 *flags)
30133016
return -EBUSY;
30143017
}
30153018

3016-
if (*flags == ETH_RESET_ALL) {
3019+
if ((req & BNXT_FW_RESET_CHIP) == BNXT_FW_RESET_CHIP) {
30173020
/* This feature is not supported in older firmware versions */
3018-
if (bp->hwrm_spec_code < 0x10803)
3019-
return -EOPNOTSUPP;
3020-
3021-
rc = bnxt_firmware_reset_chip(dev);
3022-
if (!rc) {
3023-
netdev_info(dev, "Reset request successful.\n");
3024-
if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET))
3025-
netdev_info(dev, "Reload driver to complete reset\n");
3026-
*flags = 0;
3021+
if (bp->hwrm_spec_code >= 0x10803) {
3022+
if (!bnxt_firmware_reset_chip(dev)) {
3023+
netdev_info(dev, "Firmware reset request successful.\n");
3024+
if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET))
3025+
netdev_info(dev, "Reload driver to complete reset\n");
3026+
*flags &= ~BNXT_FW_RESET_CHIP;
3027+
}
3028+
} else if (req == BNXT_FW_RESET_CHIP) {
3029+
return -EOPNOTSUPP; /* only request, fail hard */
30273030
}
3028-
} else if (*flags == ETH_RESET_AP) {
3029-
/* This feature is not supported in older firmware versions */
3030-
if (bp->hwrm_spec_code < 0x10803)
3031-
return -EOPNOTSUPP;
3031+
}
30323032

3033-
rc = bnxt_firmware_reset_ap(dev);
3034-
if (!rc) {
3035-
netdev_info(dev, "Reset Application Processor request successful.\n");
3036-
*flags = 0;
3033+
if (req & BNXT_FW_RESET_AP) {
3034+
/* This feature is not supported in older firmware versions */
3035+
if (bp->hwrm_spec_code >= 0x10803) {
3036+
if (!bnxt_firmware_reset_ap(dev)) {
3037+
netdev_info(dev, "Reset application processor successful.\n");
3038+
*flags &= ~BNXT_FW_RESET_AP;
3039+
}
3040+
} else if (req == BNXT_FW_RESET_AP) {
3041+
return -EOPNOTSUPP; /* only request, fail hard */
30373042
}
3038-
} else {
3039-
rc = -EINVAL;
30403043
}
30413044

3042-
return rc;
3045+
return 0;
30433046
}
30443047

30453048
static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg, int msg_len,

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ struct hwrm_dbg_cmn_output {
7777
#define BNXT_LED_DFLT_ENABLES(x) \
7878
cpu_to_le32(BNXT_LED_DFLT_ENA << (BNXT_LED_DFLT_ENA_SHIFT * (x)))
7979

80-
#define BNXT_FW_RESET_AP 0xfffe
81-
#define BNXT_FW_RESET_CHIP 0xffff
80+
#define BNXT_FW_RESET_AP (ETH_RESET_AP << ETH_RESET_SHARED_SHIFT)
81+
#define BNXT_FW_RESET_CHIP ((ETH_RESET_MGMT | ETH_RESET_IRQ | \
82+
ETH_RESET_DMA | ETH_RESET_FILTER | \
83+
ETH_RESET_OFFLOAD | ETH_RESET_MAC | \
84+
ETH_RESET_PHY | ETH_RESET_RAM) \
85+
<< ETH_RESET_SHARED_SHIFT)
8286

8387
extern const struct ethtool_ops bnxt_ethtool_ops;
8488

0 commit comments

Comments
 (0)