Commit 4b03b273 authored by Shannon Nelson's avatar Shannon Nelson Committed by David S. Miller

ionic: get MTU from lif identity

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: default avatarShannon Nelson <snelson@pensando.io>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4787dd58
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "ionic_if.h" #include "ionic_if.h"
#include "ionic_regs.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_TX_DESC 8192
#define IONIC_MAX_RX_DESC 16384 #define IONIC_MAX_RX_DESC 16384
#define IONIC_MIN_TXRX_DESC 16 #define IONIC_MIN_TXRX_DESC 16
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/dynamic_debug.h> #include <linux/dynamic_debug.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -2022,11 +2023,16 @@ int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg) ...@@ -2022,11 +2023,16 @@ int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg)
static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index) static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index)
{ {
struct device *dev = ionic->dev; struct device *dev = ionic->dev;
union ionic_lif_identity *lid;
struct net_device *netdev; struct net_device *netdev;
struct ionic_lif *lif; struct ionic_lif *lif;
int tbl_sz; int tbl_sz;
int err; int err;
lid = kzalloc(sizeof(*lid), GFP_KERNEL);
if (!lid)
return ERR_PTR(-ENOMEM);
netdev = alloc_etherdev_mqs(sizeof(*lif), netdev = alloc_etherdev_mqs(sizeof(*lif),
ionic->ntxqs_per_lif, ionic->ntxqs_per_lif); ionic->ntxqs_per_lif, ionic->ntxqs_per_lif);
if (!netdev) { if (!netdev) {
...@@ -2045,8 +2051,12 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index ...@@ -2045,8 +2051,12 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
netdev->watchdog_timeo = 2 * HZ; netdev->watchdog_timeo = 2 * HZ;
netif_carrier_off(netdev); netif_carrier_off(netdev);
netdev->min_mtu = IONIC_MIN_MTU; lif->identity = lid;
netdev->max_mtu = IONIC_MAX_MTU; 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->neqs = ionic->neqs_per_lif;
lif->nxqs = ionic->ntxqs_per_lif; lif->nxqs = ionic->ntxqs_per_lif;
...@@ -2113,6 +2123,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index ...@@ -2113,6 +2123,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
err_out_free_netdev: err_out_free_netdev:
free_netdev(lif->netdev); free_netdev(lif->netdev);
lif = NULL; lif = NULL;
kfree(lid);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -2132,7 +2143,6 @@ int ionic_lifs_alloc(struct ionic *ionic) ...@@ -2132,7 +2143,6 @@ int ionic_lifs_alloc(struct ionic *ionic)
return -ENOMEM; return -ENOMEM;
} }
lif->lif_type = IONIC_LIF_TYPE_CLASSIC;
ionic_lif_queue_identify(lif); ionic_lif_queue_identify(lif);
return 0; return 0;
...@@ -2243,6 +2253,7 @@ static void ionic_lif_free(struct ionic_lif *lif) ...@@ -2243,6 +2253,7 @@ static void ionic_lif_free(struct ionic_lif *lif)
ionic_lif_reset(lif); ionic_lif_reset(lif);
/* free lif info */ /* free lif info */
kfree(lif->identity);
dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa);
lif->info = NULL; lif->info = NULL;
lif->info_pa = 0; lif->info_pa = 0;
......
...@@ -184,6 +184,7 @@ struct ionic_lif { ...@@ -184,6 +184,7 @@ struct ionic_lif {
u16 lif_type; u16 lif_type;
unsigned int nucast; unsigned int nucast;
union ionic_lif_identity *identity;
struct ionic_lif_info *info; struct ionic_lif_info *info;
dma_addr_t info_pa; dma_addr_t info_pa;
u32 info_sz; u32 info_sz;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment