ionic: remove lif list concept

As we aren't yet supporting multiple lifs, we can remove
complexity by removing the list concept and related code,
to be re-engineered later when actually needed.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Shannon Nelson 2020-08-27 16:00:22 -07:00 committed by David S. Miller
parent ee205626af
commit 30b87ab4c0
6 changed files with 62 additions and 127 deletions

View file

@ -42,13 +42,11 @@ struct ionic {
struct ionic_dev_bar bars[IONIC_BARS_MAX]; struct ionic_dev_bar bars[IONIC_BARS_MAX];
unsigned int num_bars; unsigned int num_bars;
struct ionic_identity ident; struct ionic_identity ident;
struct list_head lifs; struct ionic_lif *lif;
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;
unsigned int nrxqs_per_lif; unsigned int nrxqs_per_lif;
DECLARE_BITMAP(lifbits, IONIC_LIFS_MAX);
unsigned int nintrs; unsigned int nintrs;
DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX); DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
struct work_struct nb_work; struct work_struct nb_work;

View file

@ -294,21 +294,21 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_port_reset; goto err_out_port_reset;
} }
err = ionic_lifs_size(ionic); err = ionic_lif_size(ionic);
if (err) { if (err) {
dev_err(dev, "Cannot size LIFs: %d, aborting\n", err); dev_err(dev, "Cannot size LIF: %d, aborting\n", err);
goto err_out_port_reset; goto err_out_port_reset;
} }
err = ionic_lifs_alloc(ionic); err = ionic_lif_alloc(ionic);
if (err) { if (err) {
dev_err(dev, "Cannot allocate LIFs: %d, aborting\n", err); dev_err(dev, "Cannot allocate LIF: %d, aborting\n", err);
goto err_out_free_irqs; goto err_out_free_irqs;
} }
err = ionic_lifs_init(ionic); err = ionic_lif_init(ionic->lif);
if (err) { if (err) {
dev_err(dev, "Cannot init LIFs: %d, aborting\n", err); dev_err(dev, "Cannot init LIF: %d, aborting\n", err);
goto err_out_free_lifs; goto err_out_free_lifs;
} }
@ -321,9 +321,9 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_err(dev, "Cannot enable existing VFs: %d\n", err); dev_err(dev, "Cannot enable existing VFs: %d\n", err);
} }
err = ionic_lifs_register(ionic); err = ionic_lif_register(ionic->lif);
if (err) { if (err) {
dev_err(dev, "Cannot register LIFs: %d, aborting\n", err); dev_err(dev, "Cannot register LIF: %d, aborting\n", err);
goto err_out_deinit_lifs; goto err_out_deinit_lifs;
} }
@ -336,12 +336,13 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0; return 0;
err_out_deregister_lifs: err_out_deregister_lifs:
ionic_lifs_unregister(ionic); ionic_lif_unregister(ionic->lif);
err_out_deinit_lifs: err_out_deinit_lifs:
ionic_vf_dealloc(ionic); ionic_vf_dealloc(ionic);
ionic_lifs_deinit(ionic); ionic_lif_deinit(ionic->lif);
err_out_free_lifs: err_out_free_lifs:
ionic_lifs_free(ionic); ionic_lif_free(ionic->lif);
ionic->lif = NULL;
err_out_free_irqs: err_out_free_irqs:
ionic_bus_free_irq_vectors(ionic); ionic_bus_free_irq_vectors(ionic);
err_out_port_reset: err_out_port_reset:
@ -377,11 +378,12 @@ static void ionic_remove(struct pci_dev *pdev)
if (!ionic) if (!ionic)
return; return;
if (ionic->master_lif) { if (ionic->lif) {
ionic_devlink_unregister(ionic); ionic_devlink_unregister(ionic);
ionic_lifs_unregister(ionic); ionic_lif_unregister(ionic->lif);
ionic_lifs_deinit(ionic); ionic_lif_deinit(ionic->lif);
ionic_lifs_free(ionic); ionic_lif_free(ionic->lif);
ionic->lif = NULL;
ionic_bus_free_irq_vectors(ionic); ionic_bus_free_irq_vectors(ionic);
} }

View file

@ -21,8 +21,8 @@ static void ionic_watchdog_cb(struct timer_list *t)
hb = ionic_heartbeat_check(ionic); hb = ionic_heartbeat_check(ionic);
if (hb >= 0 && ionic->master_lif) if (hb >= 0 && ionic->lif)
ionic_link_status_check_request(ionic->master_lif); ionic_link_status_check_request(ionic->lif);
} }
void ionic_init_devinfo(struct ionic *ionic) void ionic_init_devinfo(struct ionic *ionic)
@ -126,7 +126,7 @@ int ionic_heartbeat_check(struct ionic *ionic)
/* is this a transition? */ /* is this a transition? */
if (fw_status != idev->last_fw_status && if (fw_status != idev->last_fw_status &&
idev->last_fw_status != 0xff) { idev->last_fw_status != 0xff) {
struct ionic_lif *lif = ionic->master_lif; struct ionic_lif *lif = ionic->lif;
bool trigger = false; bool trigger = false;
if (!fw_status || fw_status == 0xff) { if (!fw_status || fw_status == 0xff) {

View file

@ -85,7 +85,7 @@ int ionic_devlink_register(struct ionic *ionic)
dev_err(ionic->dev, "devlink_port_register failed: %d\n", err); dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
else else
devlink_port_type_eth_set(&ionic->dl_port, devlink_port_type_eth_set(&ionic->dl_port,
ionic->master_lif->netdev); ionic->lif->netdev);
return err; return err;
} }

View file

@ -2045,7 +2045,7 @@ int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg)
return err; return err;
} }
static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index) int ionic_lif_alloc(struct ionic *ionic)
{ {
struct device *dev = ionic->dev; struct device *dev = ionic->dev;
union ionic_lif_identity *lid; union ionic_lif_identity *lid;
@ -2056,7 +2056,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
lid = kzalloc(sizeof(*lid), GFP_KERNEL); lid = kzalloc(sizeof(*lid), GFP_KERNEL);
if (!lid) if (!lid)
return ERR_PTR(-ENOMEM); return -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);
@ -2070,7 +2070,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
lif = netdev_priv(netdev); lif = netdev_priv(netdev);
lif->netdev = netdev; lif->netdev = netdev;
ionic->master_lif = lif; ionic->lif = lif;
netdev->netdev_ops = &ionic_netdev_ops; netdev->netdev_ops = &ionic_netdev_ops;
ionic_ethtool_set_ops(netdev); ionic_ethtool_set_ops(netdev);
@ -2089,7 +2089,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
lif->nxqs = ionic->ntxqs_per_lif; lif->nxqs = ionic->ntxqs_per_lif;
lif->ionic = ionic; lif->ionic = ionic;
lif->index = index; lif->index = 0;
lif->ntxq_descs = IONIC_DEF_TXRX_DESC; lif->ntxq_descs = IONIC_DEF_TXRX_DESC;
lif->nrxq_descs = IONIC_DEF_TXRX_DESC; lif->nrxq_descs = IONIC_DEF_TXRX_DESC;
lif->tx_budget = IONIC_TX_BUDGET_DEFAULT; lif->tx_budget = IONIC_TX_BUDGET_DEFAULT;
@ -2101,7 +2101,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; lif->tx_coalesce_usecs = lif->rx_coalesce_usecs;
lif->tx_coalesce_hw = lif->rx_coalesce_hw; lif->tx_coalesce_hw = lif->rx_coalesce_hw;
snprintf(lif->name, sizeof(lif->name), "lif%u", index); snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index);
spin_lock_init(&lif->adminq_lock); spin_lock_init(&lif->adminq_lock);
@ -2121,7 +2121,8 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
ionic_debugfs_add_lif(lif); ionic_debugfs_add_lif(lif);
/* allocate queues */ /* allocate control queues and txrx queue arrays */
ionic_lif_queue_identify(lif);
err = ionic_qcqs_alloc(lif); err = ionic_qcqs_alloc(lif);
if (err) if (err)
goto err_out_free_lif_info; goto err_out_free_lif_info;
@ -2140,9 +2141,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
} }
netdev_rss_key_fill(lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE); netdev_rss_key_fill(lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE);
list_add_tail(&lif->list, &ionic->lifs); return 0;
return lif;
err_out_free_qcqs: err_out_free_qcqs:
ionic_qcqs_free(lif); ionic_qcqs_free(lif);
@ -2156,27 +2155,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
err_out_free_lid: err_out_free_lid:
kfree(lid); kfree(lid);
return ERR_PTR(err); return err;
}
int ionic_lifs_alloc(struct ionic *ionic)
{
struct ionic_lif *lif;
INIT_LIST_HEAD(&ionic->lifs);
/* only build the first lif, others are for later features */
set_bit(0, ionic->lifbits);
lif = ionic_lif_alloc(ionic, 0);
if (IS_ERR_OR_NULL(lif)) {
clear_bit(0, ionic->lifbits);
return -ENOMEM;
}
ionic_lif_queue_identify(lif);
return 0;
} }
static void ionic_lif_reset(struct ionic_lif *lif) static void ionic_lif_reset(struct ionic_lif *lif)
@ -2211,7 +2190,7 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif)
ionic_txrx_deinit(lif); ionic_txrx_deinit(lif);
ionic_txrx_free(lif); ionic_txrx_free(lif);
} }
ionic_lifs_deinit(ionic); ionic_lif_deinit(lif);
ionic_reset(ionic); ionic_reset(ionic);
ionic_qcqs_free(lif); ionic_qcqs_free(lif);
@ -2234,7 +2213,7 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
if (err) if (err)
goto err_out; goto err_out;
err = ionic_lifs_init(ionic); err = ionic_lif_init(lif);
if (err) if (err)
goto err_qcqs_free; goto err_qcqs_free;
@ -2263,14 +2242,14 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
err_txrx_free: err_txrx_free:
ionic_txrx_free(lif); ionic_txrx_free(lif);
err_lifs_deinit: err_lifs_deinit:
ionic_lifs_deinit(ionic); ionic_lif_deinit(lif);
err_qcqs_free: err_qcqs_free:
ionic_qcqs_free(lif); ionic_qcqs_free(lif);
err_out: err_out:
dev_err(ionic->dev, "FW Up: LIFs restart failed - err %d\n", err); dev_err(ionic->dev, "FW Up: LIFs restart failed - err %d\n", err);
} }
static void ionic_lif_free(struct ionic_lif *lif) void ionic_lif_free(struct ionic_lif *lif)
{ {
struct device *dev = lif->ionic->dev; struct device *dev = lif->ionic->dev;
@ -2299,23 +2278,10 @@ static void ionic_lif_free(struct ionic_lif *lif)
/* free netdev & lif */ /* free netdev & lif */
ionic_debugfs_del_lif(lif); ionic_debugfs_del_lif(lif);
list_del(&lif->list);
free_netdev(lif->netdev); free_netdev(lif->netdev);
} }
void ionic_lifs_free(struct ionic *ionic) void ionic_lif_deinit(struct ionic_lif *lif)
{
struct list_head *cur, *tmp;
struct ionic_lif *lif;
list_for_each_safe(cur, tmp, &ionic->lifs) {
lif = list_entry(cur, struct ionic_lif, list);
ionic_lif_free(lif);
}
}
static void ionic_lif_deinit(struct ionic_lif *lif)
{ {
if (!test_and_clear_bit(IONIC_LIF_F_INITED, lif->state)) if (!test_and_clear_bit(IONIC_LIF_F_INITED, lif->state))
return; return;
@ -2336,17 +2302,6 @@ static void ionic_lif_deinit(struct ionic_lif *lif)
ionic_lif_reset(lif); ionic_lif_reset(lif);
} }
void ionic_lifs_deinit(struct ionic *ionic)
{
struct list_head *cur, *tmp;
struct ionic_lif *lif;
list_for_each_safe(cur, tmp, &ionic->lifs) {
lif = list_entry(cur, struct ionic_lif, list);
ionic_lif_deinit(lif);
}
}
static int ionic_lif_adminq_init(struct ionic_lif *lif) static int ionic_lif_adminq_init(struct ionic_lif *lif)
{ {
struct device *dev = lif->ionic->dev; struct device *dev = lif->ionic->dev;
@ -2492,7 +2447,7 @@ static int ionic_station_set(struct ionic_lif *lif)
return 0; return 0;
} }
static int ionic_lif_init(struct ionic_lif *lif) int ionic_lif_init(struct ionic_lif *lif)
{ {
struct ionic_dev *idev = &lif->ionic->idev; struct ionic_dev *idev = &lif->ionic->idev;
struct device *dev = lif->ionic->dev; struct device *dev = lif->ionic->dev;
@ -2582,22 +2537,6 @@ static int ionic_lif_init(struct ionic_lif *lif)
return err; return err;
} }
int ionic_lifs_init(struct ionic *ionic)
{
struct list_head *cur, *tmp;
struct ionic_lif *lif;
int err;
list_for_each_safe(cur, tmp, &ionic->lifs) {
lif = list_entry(cur, struct ionic_lif, list);
err = ionic_lif_init(lif);
if (err)
return err;
}
return 0;
}
static void ionic_lif_notify_work(struct work_struct *ws) static void ionic_lif_notify_work(struct work_struct *ws)
{ {
} }
@ -2646,45 +2585,41 @@ static int ionic_lif_notify(struct notifier_block *nb,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
int ionic_lifs_register(struct ionic *ionic) int ionic_lif_register(struct ionic_lif *lif)
{ {
int err; int err;
INIT_WORK(&ionic->nb_work, ionic_lif_notify_work); INIT_WORK(&lif->ionic->nb_work, ionic_lif_notify_work);
ionic->nb.notifier_call = ionic_lif_notify; lif->ionic->nb.notifier_call = ionic_lif_notify;
err = register_netdevice_notifier(&ionic->nb); err = register_netdevice_notifier(&lif->ionic->nb);
if (err) if (err)
ionic->nb.notifier_call = NULL; lif->ionic->nb.notifier_call = NULL;
/* only register LIF0 for now */ /* only register LIF0 for now */
err = register_netdev(ionic->master_lif->netdev); err = register_netdev(lif->netdev);
if (err) { if (err) {
dev_err(ionic->dev, "Cannot register net device, aborting\n"); dev_err(lif->ionic->dev, "Cannot register net device, aborting\n");
return err; return err;
} }
ionic->master_lif->registered = true; lif->registered = true;
ionic_lif_set_netdev_info(ionic->master_lif); ionic_lif_set_netdev_info(lif);
return 0; return 0;
} }
void ionic_lifs_unregister(struct ionic *ionic) void ionic_lif_unregister(struct ionic_lif *lif)
{ {
if (ionic->nb.notifier_call) { if (lif->ionic->nb.notifier_call) {
unregister_netdevice_notifier(&ionic->nb); unregister_netdevice_notifier(&lif->ionic->nb);
cancel_work_sync(&ionic->nb_work); cancel_work_sync(&lif->ionic->nb_work);
ionic->nb.notifier_call = NULL; lif->ionic->nb.notifier_call = NULL;
} }
/* There is only one lif ever registered in the if (lif->netdev->reg_state == NETREG_REGISTERED)
* current model, so don't bother searching the unregister_netdev(lif->netdev);
* ionic->lif for candidates to unregister lif->registered = false;
*/
if (ionic->master_lif &&
ionic->master_lif->netdev->reg_state == NETREG_REGISTERED)
unregister_netdev(ionic->master_lif->netdev);
} }
static void ionic_lif_queue_identify(struct ionic_lif *lif) static void ionic_lif_queue_identify(struct ionic_lif *lif)
@ -2803,7 +2738,7 @@ int ionic_lif_identify(struct ionic *ionic, u8 lif_type,
return 0; return 0;
} }
int ionic_lifs_size(struct ionic *ionic) int ionic_lif_size(struct ionic *ionic)
{ {
struct ionic_identity *ident = &ionic->ident; struct ionic_identity *ident = &ionic->ident;
unsigned int nintrs, dev_nintrs; unsigned int nintrs, dev_nintrs;

View file

@ -242,15 +242,15 @@ void ionic_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *ns); struct rtnl_link_stats64 *ns);
void ionic_lif_deferred_enqueue(struct ionic_deferred *def, void ionic_lif_deferred_enqueue(struct ionic_deferred *def,
struct ionic_deferred_work *work); struct ionic_deferred_work *work);
int ionic_lifs_alloc(struct ionic *ionic); int ionic_lif_alloc(struct ionic *ionic);
void ionic_lifs_free(struct ionic *ionic); int ionic_lif_init(struct ionic_lif *lif);
void ionic_lifs_deinit(struct ionic *ionic); void ionic_lif_free(struct ionic_lif *lif);
int ionic_lifs_init(struct ionic *ionic); void ionic_lif_deinit(struct ionic_lif *lif);
int ionic_lifs_register(struct ionic *ionic); int ionic_lif_register(struct ionic_lif *lif);
void ionic_lifs_unregister(struct ionic *ionic); void ionic_lif_unregister(struct ionic_lif *lif);
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_lif_size(struct ionic *ionic);
int ionic_lif_rss_config(struct ionic_lif *lif, u16 types, int ionic_lif_rss_config(struct ionic_lif *lif, u16 types,
const u8 *key, const u32 *indir); const u8 *key, const u32 *indir);