lkml.org 
[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 132/262] bnxt_en: Fix occasional ethtool -t loopback test failures
    Date
    From: Michael Chan <michael.chan@broadcom.com>

    [ Upstream commit cfcab3b3b61584a02bb523ffa99564eafa761dfe ]

    In the current code, we setup the port to PHY or MAC loopback mode
    and then transmit a test broadcast packet for the loopback test. This
    scheme fails sometime if the port is shared with management firmware
    that can also send packets. The driver may receive the management
    firmware's packet and the test will fail when the contents don't
    match the test packet.

    Change the test packet to use it's own MAC address as the destination
    and setup the port to only receive it's own MAC address. This should
    filter out other packets sent by management firmware.

    Fixes: 91725d89b97a ("bnxt_en: Add PHY loopback to ethtool self-test.")
    Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
    Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
    Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++++
    drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
    drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +-
    3 files changed, 9 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
    index f92bea4faa019..ce36ee5a250fb 100644
    --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
    +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
    @@ -8617,6 +8617,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
    vnic->uc_filter_count = 1;

    vnic->rx_mask = 0;
    + if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state))
    + goto skip_rx_mask;
    +
    if (bp->dev->flags & IFF_BROADCAST)
    vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST;

    @@ -8637,6 +8640,7 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
    if (rc)
    goto err_out;

    +skip_rx_mask:
    rc = bnxt_hwrm_set_coal(bp);
    if (rc)
    netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n",
    @@ -10302,8 +10306,10 @@ int bnxt_half_open_nic(struct bnxt *bp)
    netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc);
    goto half_open_err;
    }
    + set_bit(BNXT_STATE_HALF_OPEN, &bp->state);
    rc = bnxt_init_nic(bp, true);
    if (rc) {
    + clear_bit(BNXT_STATE_HALF_OPEN, &bp->state);
    netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc);
    goto half_open_err;
    }
    @@ -10324,6 +10330,7 @@ void bnxt_half_close_nic(struct bnxt *bp)
    bnxt_hwrm_resource_free(bp, false, true);
    bnxt_free_skbs(bp);
    bnxt_free_mem(bp, true);
    + clear_bit(BNXT_STATE_HALF_OPEN, &bp->state);
    }

    static void bnxt_reenable_sriov(struct bnxt *bp)
    diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
    index 0a5137c1f6d4e..ca6fdf03e5865 100644
    --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
    +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
    @@ -1840,6 +1840,7 @@ struct bnxt {
    #define BNXT_STATE_DRV_REGISTERED 7
    #define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8
    #define BNXT_STATE_NAPI_DISABLED 9
    +#define BNXT_STATE_HALF_OPEN 15 /* For offline ethtool tests */

    #define BNXT_NO_FW_ACCESS(bp) \
    (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \
    diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
    index da3ee22e8a16f..af7de9ee66cf2 100644
    --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
    +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
    @@ -3409,7 +3409,7 @@ static int bnxt_run_loopback(struct bnxt *bp)
    if (!skb)
    return -ENOMEM;
    data = skb_put(skb, pkt_size);
    - eth_broadcast_addr(data);
    + ether_addr_copy(&data[i], bp->dev->dev_addr);
    i += ETH_ALEN;
    ether_addr_copy(&data[i], bp->dev->dev_addr);
    i += ETH_ALEN;
    --
    2.34.1


    \
     
     \ /
      Last update: 2022-03-07 11:13    [W:7.054 / U:0.336 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site