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

ionic: Add the basic NDO callbacks for netdev support

Set up the initial NDO structure and callbacks for netdev
to use, and register the netdev.  This will allow us to do
a few basic operations on the device, but no traffic yet.
Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 77ceb68e
...@@ -28,6 +28,7 @@ struct ionic_lif; ...@@ -28,6 +28,7 @@ struct ionic_lif;
struct ionic { struct ionic {
struct pci_dev *pdev; struct pci_dev *pdev;
struct device *dev; struct device *dev;
struct devlink_port dl_port;
struct ionic_dev idev; struct ionic_dev idev;
struct mutex dev_cmd_lock; /* lock for dev_cmd operations */ struct mutex dev_cmd_lock; /* lock for dev_cmd operations */
struct dentry *dentry; struct dentry *dentry;
...@@ -35,6 +36,7 @@ struct ionic { ...@@ -35,6 +36,7 @@ struct ionic {
unsigned int num_bars; unsigned int num_bars;
struct ionic_identity ident; struct ionic_identity ident;
struct list_head lifs; struct list_head lifs;
struct ionic_lif *master_lif;
unsigned int nnqs_per_lif; unsigned int nnqs_per_lif;
unsigned int neqs_per_lif; unsigned int neqs_per_lif;
unsigned int ntxqs_per_lif; unsigned int ntxqs_per_lif;
......
...@@ -206,12 +206,24 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -206,12 +206,24 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_free_lifs; goto err_out_free_lifs;
} }
err = ionic_lifs_register(ionic);
if (err) {
dev_err(dev, "Cannot register LIFs: %d, aborting\n", err);
goto err_out_deinit_lifs;
}
err = ionic_devlink_register(ionic); err = ionic_devlink_register(ionic);
if (err) if (err) {
dev_err(dev, "Cannot register devlink: %d\n", err); dev_err(dev, "Cannot register devlink: %d\n", err);
goto err_out_deregister_lifs;
}
return 0; return 0;
err_out_deregister_lifs:
ionic_lifs_unregister(ionic);
err_out_deinit_lifs:
ionic_lifs_deinit(ionic);
err_out_free_lifs: err_out_free_lifs:
ionic_lifs_free(ionic); ionic_lifs_free(ionic);
err_out_free_irqs: err_out_free_irqs:
...@@ -246,6 +258,7 @@ static void ionic_remove(struct pci_dev *pdev) ...@@ -246,6 +258,7 @@ static void ionic_remove(struct pci_dev *pdev)
return; return;
ionic_devlink_unregister(ionic); ionic_devlink_unregister(ionic);
ionic_lifs_unregister(ionic);
ionic_lifs_deinit(ionic); ionic_lifs_deinit(ionic);
ionic_lifs_free(ionic); ionic_lifs_free(ionic);
ionic_bus_free_irq_vectors(ionic); ionic_bus_free_irq_vectors(ionic);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#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_LIFS_MAX 1024 #define IONIC_LIFS_MAX 1024
struct ionic_dev_bar { struct ionic_dev_bar {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ionic.h" #include "ionic.h"
#include "ionic_bus.h" #include "ionic_bus.h"
#include "ionic_lif.h"
#include "ionic_devlink.h" #include "ionic_devlink.h"
static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
...@@ -72,8 +73,19 @@ int ionic_devlink_register(struct ionic *ionic) ...@@ -72,8 +73,19 @@ int ionic_devlink_register(struct ionic *ionic)
int err; int err;
err = devlink_register(dl, ionic->dev); err = devlink_register(dl, ionic->dev);
if (err) if (err) {
dev_warn(ionic->dev, "devlink_register failed: %d\n", err); dev_warn(ionic->dev, "devlink_register failed: %d\n", err);
return err;
}
devlink_port_attrs_set(&ionic->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
0, false, 0, NULL, 0);
err = devlink_port_register(dl, &ionic->dl_port, 0);
if (err)
dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
else
devlink_port_type_eth_set(&ionic->dl_port,
ionic->master_lif->netdev);
return err; return err;
} }
...@@ -82,5 +94,6 @@ void ionic_devlink_unregister(struct ionic *ionic) ...@@ -82,5 +94,6 @@ void ionic_devlink_unregister(struct ionic *ionic)
{ {
struct devlink *dl = priv_to_devlink(ionic); struct devlink *dl = priv_to_devlink(ionic);
devlink_port_unregister(&ionic->dl_port);
devlink_unregister(dl); devlink_unregister(dl);
} }
...@@ -59,6 +59,8 @@ struct ionic_qcq { ...@@ -59,6 +59,8 @@ struct ionic_qcq {
enum ionic_lif_state_flags { enum ionic_lif_state_flags {
IONIC_LIF_INITED, IONIC_LIF_INITED,
IONIC_LIF_UP,
IONIC_LIF_QUEUE_RESET,
/* leave this as last */ /* leave this as last */
IONIC_LIF_STATE_SIZE IONIC_LIF_STATE_SIZE
...@@ -82,6 +84,7 @@ struct ionic_lif { ...@@ -82,6 +84,7 @@ struct ionic_lif {
u64 last_eid; u64 last_eid;
unsigned int neqs; unsigned int neqs;
unsigned int nxqs; unsigned int nxqs;
u64 hw_features;
struct ionic_lif_info *info; struct ionic_lif_info *info;
dma_addr_t info_pa; dma_addr_t info_pa;
...@@ -93,14 +96,31 @@ struct ionic_lif { ...@@ -93,14 +96,31 @@ struct ionic_lif {
u32 flags; u32 flags;
}; };
static inline int ionic_wait_for_bit(struct ionic_lif *lif, int bitname)
{
unsigned long tlimit = jiffies + HZ;
while (test_and_set_bit(bitname, lif->state) &&
time_before(jiffies, tlimit))
usleep_range(100, 200);
return test_bit(bitname, lif->state);
}
int ionic_lifs_alloc(struct ionic *ionic); int ionic_lifs_alloc(struct ionic *ionic);
void ionic_lifs_free(struct ionic *ionic); void ionic_lifs_free(struct ionic *ionic);
void ionic_lifs_deinit(struct ionic *ionic); void ionic_lifs_deinit(struct ionic *ionic);
int ionic_lifs_init(struct ionic *ionic); int ionic_lifs_init(struct ionic *ionic);
int ionic_lifs_register(struct ionic *ionic);
void ionic_lifs_unregister(struct ionic *ionic);
int ionic_lif_identify(struct ionic *ionic, u8 lif_type, int ionic_lif_identify(struct ionic *ionic, u8 lif_type,
union ionic_lif_identity *lif_ident); union ionic_lif_identity *lif_ident);
int ionic_lifs_size(struct ionic *ionic); int ionic_lifs_size(struct ionic *ionic);
int ionic_open(struct net_device *netdev);
int ionic_stop(struct net_device *netdev);
int ionic_reset_queues(struct ionic_lif *lif);
static inline void debug_stats_napi_poll(struct ionic_qcq *qcq, static inline void debug_stats_napi_poll(struct ionic_qcq *qcq,
unsigned int work_done) unsigned int work_done)
{ {
......
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