From: Shannon Nelson <snelson@pensando.io>
Date: Tue, 21 Jul 2020 13:34:04 -0700
Subject: ionic: get MTU from lif identity
Patch-mainline: v5.9-rc1
Git-commit: 4b03b27349c03b72a084b2484623a744565bc399
References: jsc#SLE-16649
Change from using hardcoded MTU limits and instead use the
firmware defined limits. The value from the LIF attributes is
the frame size, so we take off the header size to convert to
MTU size.
Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/net/ethernet/pensando/ionic/ionic_dev.h | 2 --
drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 ++++++++++++++---
drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 +
3 files changed, 15 insertions(+), 5 deletions(-)
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
@@ -10,8 +10,6 @@
#include "ionic_if.h"
#include "ionic_regs.h"
-#define IONIC_MIN_MTU ETH_MIN_MTU
-#define IONIC_MAX_MTU 9194
#define IONIC_MAX_TX_DESC 8192
#define IONIC_MAX_RX_DESC 16384
#define IONIC_MIN_TXRX_DESC 16
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -5,6 +5,7 @@
#include <linux/dynamic_debug.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
@@ -2021,11 +2022,16 @@ reset_out:
static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index)
{
struct device *dev = ionic->dev;
+ union ionic_lif_identity *lid;
struct net_device *netdev;
struct ionic_lif *lif;
int tbl_sz;
int err;
+ lid = kzalloc(sizeof(*lid), GFP_KERNEL);
+ if (!lid)
+ return ERR_PTR(-ENOMEM);
+
netdev = alloc_etherdev_mqs(sizeof(*lif),
ionic->ntxqs_per_lif, ionic->ntxqs_per_lif);
if (!netdev) {
@@ -2044,8 +2050,12 @@ static struct ionic_lif *ionic_lif_alloc
netdev->watchdog_timeo = 2 * HZ;
netif_carrier_off(netdev);
- netdev->min_mtu = IONIC_MIN_MTU;
- netdev->max_mtu = IONIC_MAX_MTU;
+ lif->identity = lid;
+ lif->lif_type = IONIC_LIF_TYPE_CLASSIC;
+ ionic_lif_identify(ionic, lif->lif_type, lif->identity);
+ lif->netdev->min_mtu = le32_to_cpu(lif->identity->eth.min_frame_size);
+ lif->netdev->max_mtu =
+ le32_to_cpu(lif->identity->eth.max_frame_size) - ETH_HLEN - VLAN_HLEN;
lif->neqs = ionic->neqs_per_lif;
lif->nxqs = ionic->ntxqs_per_lif;
@@ -2112,6 +2122,7 @@ err_out_free_lif_info:
err_out_free_netdev:
free_netdev(lif->netdev);
lif = NULL;
+ kfree(lid);
return ERR_PTR(err);
}
@@ -2131,7 +2142,6 @@ int ionic_lifs_alloc(struct ionic *ionic
return -ENOMEM;
}
- lif->lif_type = IONIC_LIF_TYPE_CLASSIC;
ionic_lif_queue_identify(lif);
return 0;
@@ -2244,6 +2254,7 @@ static void ionic_lif_free(struct ionic_
ionic_lif_reset(lif);
/* free lif info */
+ kfree(lif->identity);
dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa);
lif->info = NULL;
lif->info_pa = 0;
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
@@ -184,6 +184,7 @@ struct ionic_lif {
u16 lif_type;
unsigned int nucast;
+ union ionic_lif_identity *identity;
struct ionic_lif_info *info;
dma_addr_t info_pa;
u32 info_sz;