bnxt_en: Check maximum supported MTU from firmware.
authorMichael Chan <michael.chan@broadcom.com>
Thu, 26 Oct 2017 15:51:25 +0000 (11:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Oct 2017 15:02:44 +0000 (00:02 +0900)
Some NICs have a firmware enforced maximum MTU setting by management
firmware.  Set up netdev->max_mtu accordingly.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index ef5a5e52eb04346f044785455873ddf50b269914..285863ba51a32825690c32c2e068bac6cbe68a2b 100644 (file)
@@ -2835,7 +2835,8 @@ int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode)
        if (page_mode) {
                if (bp->dev->mtu > BNXT_MAX_PAGE_MODE_MTU)
                        return -EOPNOTSUPP;
-               bp->dev->max_mtu = BNXT_MAX_PAGE_MODE_MTU;
+               bp->dev->max_mtu =
+                       min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU);
                bp->flags &= ~BNXT_FLAG_AGG_RINGS;
                bp->flags |= BNXT_FLAG_NO_AGG_RINGS | BNXT_FLAG_RX_PAGE_MODE;
                bp->dev->hw_features &= ~NETIF_F_LRO;
@@ -2843,7 +2844,7 @@ int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode)
                bp->rx_dir = DMA_BIDIRECTIONAL;
                bp->rx_skb_func = bnxt_rx_page_skb;
        } else {
-               bp->dev->max_mtu = BNXT_MAX_MTU;
+               bp->dev->max_mtu = bp->max_mtu;
                bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE;
                bp->rx_dir = DMA_FROM_DEVICE;
                bp->rx_skb_func = bnxt_rx_skb;
@@ -4732,6 +4733,10 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
        else
                bp->br_mode = BRIDGE_MODE_UNDEF;
 
+       bp->max_mtu = le16_to_cpu(resp->max_mtu_configured);
+       if (!bp->max_mtu)
+               bp->max_mtu = BNXT_MAX_MTU;
+
 func_qcfg_exit:
        mutex_unlock(&bp->hwrm_cmd_lock);
        return rc;
@@ -8095,10 +8100,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        dev->features |= dev->hw_features | NETIF_F_HIGHDMA;
        dev->priv_flags |= IFF_UNICAST_FLT;
 
-       /* MTU range: 60 - 9500 */
-       dev->min_mtu = ETH_ZLEN;
-       dev->max_mtu = BNXT_MAX_MTU;
-
 #ifdef CONFIG_BNXT_SRIOV
        init_waitqueue_head(&bp->sriov_cfg_wait);
        mutex_init(&bp->sriov_lock);
@@ -8146,6 +8147,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        bnxt_ethtool_init(bp);
        bnxt_dcb_init(bp);
 
+       /* MTU range: 60 - FW defined max */
+       dev->min_mtu = ETH_ZLEN;
+       dev->max_mtu = bp->max_mtu;
+
        rc = bnxt_probe_phy(bp);
        if (rc)
                goto init_err_pci_clean;
index d193923d20a616e1fcfd991c6355c2b43d384b75..5f1fce4a724db9b5941e7c4f0dde7aa67e8dea1c 100644 (file)
@@ -1172,6 +1172,7 @@ struct bnxt {
        int                     nr_vnics;
        u32                     rss_hash_cfg;
 
+       u16                     max_mtu;
        u8                      max_tc;
        u8                      max_lltc;       /* lossless TCs */
        struct bnxt_queue_info  q_info[BNXT_MAX_QUEUE];