ionic memory usage rework
Subsystems (3)
v2 cover ionic memory usage rework
Previous review comments have suggested [1],[2] that this driver needs to rework how queue resources are managed and reconfigured so that we don't do a full driver reset and to better handle potential allocation failures. This patchset is intended to address those comments.
The first few patches clean some general issues and simplify some of the memory structures. The last 4 patches specifically address queue parameter changes without a full ionic_stop()/ionic_open().
[1] https://lore.kernel.org/netdev/20200706103305.182bd727@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
[2] https://lore.kernel.org/netdev/[email protected]/
v2: use PTR_ALIGN
recovery if netif_set_real_num_tx/rx_queues fails less racy queue bring up after reconfig common-ize the reconfig queue stop and start
Shannon Nelson (12):
ionic: set MTU floor at ETH_MIN_MTU
ionic: fix up a couple of debug strings
ionic: use kcalloc for new arrays
ionic: remove lif list concept
ionic: rework and simplify handling of the queue stats block
ionic: clean up unnecessary non-static functions
ionic: reduce contiguous memory allocation requirement
ionic: use index not pointer for queue tracking
ionic: change mtu without full queue rebuild
ionic: change the descriptor ring length without full reset
ionic: change queue count with no reset
ionic: pull reset_queues into tx_timeout handler
drivers/net/ethernet/pensando/ionic/ionic.h | 4 +- .../ethernet/pensando/ionic/ionic_bus_pci.c | 32 +- .../ethernet/pensando/ionic/ionic_debugfs.c | 29 +- .../net/ethernet/pensando/ionic/ionic_dev.c | 46 +- .../net/ethernet/pensando/ionic/ionic_dev.h | 49 +- .../ethernet/pensando/ionic/ionic_devlink.c | 2 +- .../ethernet/pensando/ionic/ionic_ethtool.c | 127 ++- .../net/ethernet/pensando/ionic/ionic_lif.c | 785 +++++++++++------- .../net/ethernet/pensando/ionic/ionic_lif.h | 94 ++- .../net/ethernet/pensando/ionic/ionic_main.c | 26 +- .../net/ethernet/pensando/ionic/ionic_stats.c | 48 +- .../net/ethernet/pensando/ionic/ionic_txrx.c | 82 +- 12 files changed, 790 insertions(+), 534 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/12 ionic: set MTU floor at ETH_MIN_MTU
The NIC might tell us its minimum MTU, but let's be sure not to use something smaller than ETH_MIN_MTU.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -1
@@ -2079,7 +2079,8 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index 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->min_mtu = max_t(unsigned int, ETH_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 ;
Signature · 1 line
2.17.1
PATCH v2 2/12 ionic: fix up a couple of debug strings
In reply to Shannon NelsonFix the queue name displayed.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +4 -3
@@ -433,14 +433,14 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, err =ionic_intr_alloc (lif, &new->intr);if (err) {netdev_warn (lif->netdev,"no intr for %s: %d\n" , - name, err); + new->q.name, err); goto err_out; } err =ionic_bus_get_irq (lif->ionic, new->intr.index);if (err <0 ) {netdev_warn (lif->netdev,"no vector for %s: %d\n" , - name, err); + new->q.name, err); goto err_out_free_intr; } new->intr.vector = err;
@@ -449,7 +449,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, err =ionic_request_irq (lif, new);if (err) { -netdev_warn (lif->netdev,"irq request failed %d\n" , err); +netdev_warn (lif->netdev,"irq request failed for %s: %d\n" , + new->q.name, err); goto err_out_free_intr; }
Signature · 1 line
2.17.1
PATCH v2 3/12 ionic: use kcalloc for new arrays
In reply to Shannon NelsonUse kcalloc for allocating arrays of structures.
Following along after
commit e71642009cbdA ("ionic_lif: Use devm_kcalloc() in ionic_qcq_alloc()") there are a couple more array allocations that can be converted to using devm_kcalloc().
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +4 -4
@@ -522,7 +522,6 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,static int ionic_qcqs_alloc (struct ionic_lif *lif) {struct device *dev = lif->ionic->dev; -unsigned int q_list_size;unsigned int flags;int err;int i;
@@ -552,9 +551,9 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif)ionic_link_qcq_interrupts (lif->adminqcq, lif->notifyqcq); } - q_list_size =sizeof (*lif->txqcqs) * lif->nxqs; err = -ENOMEM ; - lif->txqcqs =devm_kzalloc (dev, q_list_size,GFP_KERNEL ); + lif->txqcqs =devm_kcalloc (dev, lif->ionic->ntxqs_per_lif, +sizeof (*lif->txqcqs),GFP_KERNEL );if (!lif->txqcqs) goto err_out_free_notifyqcq;for (i =0 ; i < lif->nxqs; i++) {
@@ -565,7 +564,8 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif) goto err_out_free_tx_stats; } - lif->rxqcqs =devm_kzalloc (dev, q_list_size,GFP_KERNEL ); + lif->rxqcqs =devm_kcalloc (dev, lif->ionic->nrxqs_per_lif, +sizeof (*lif->rxqcqs),GFP_KERNEL );if (!lif->rxqcqs) goto err_out_free_tx_stats;for (i =0 ; i < lif->nxqs; i++) {
Signature · 1 line
2.17.1
PATCH v2 4/12 ionic: remove lif list concept
In reply to Shannon NelsonAs 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.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 4 +- .../ethernet/pensando/ionic/ionic_bus_pci.c | 32 +++-- .../net/ethernet/pensando/ionic/ionic_dev.c | 6 +- .../ethernet/pensando/ionic/ionic_devlink.c | 2 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 131 +++++------------- .../net/ethernet/pensando/ionic/ionic_lif.h | 14 +- 6 files changed, 62 insertions(+), 127 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -3
@@ -42,13 +42,11 @@ struct ionic {struct ionic_dev_bar bars[IONIC_BARS_MAX ];unsigned int num_bars;struct ionic_identity ident; -struct list_head lifs; -struct ionic_lif *master_lif; +struct ionic_lif *lif;unsigned int nnqs_per_lif;unsigned int neqs_per_lif;unsigned int ntxqs_per_lif;unsigned int nrxqs_per_lif; -DECLARE_BITMAP (lifbits,IONIC_LIFS_MAX );unsigned int nintrs;DECLARE_BITMAP (intrs,IONIC_INTR_CTRL_REGS_MAX );struct work_struct nb_work;
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +17 -15
@@ -294,21 +294,21 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_port_reset; } - err =ionic_lifs_size (ionic); + err =ionic_lif_size (ionic);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; } - err =ionic_lifs_alloc (ionic); + err =ionic_lif_alloc (ionic);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; } - err =ionic_lifs_init (ionic); + err =ionic_lif_init (ionic->lif);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; }
@@ -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); } - err =ionic_lifs_register (ionic); + err =ionic_lif_register (ionic->lif);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; }
@@ -336,12 +336,13 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return 0 ; err_out_deregister_lifs: -ionic_lifs_unregister (ionic); +ionic_lif_unregister (ionic->lif); err_out_deinit_lifs:ionic_vf_dealloc (ionic); -ionic_lifs_deinit (ionic); +ionic_lif_deinit (ionic->lif); err_out_free_lifs: -ionic_lifs_free (ionic); +ionic_lif_free (ionic->lif); + ionic->lif =NULL ; err_out_free_irqs:ionic_bus_free_irq_vectors (ionic); err_out_port_reset:
@@ -377,11 +378,12 @@ static void ionic_remove(struct pci_dev *pdev)if (!ionic)return ; -if (ionic->master_lif) { +if (ionic->lif) {ionic_devlink_unregister (ionic); -ionic_lifs_unregister (ionic); -ionic_lifs_deinit (ionic); -ionic_lifs_free (ionic); +ionic_lif_unregister (ionic->lif); +ionic_lif_deinit (ionic->lif); +ionic_lif_free (ionic->lif); + ionic->lif =NULL ;ionic_bus_free_irq_vectors (ionic); }
drivers/net/ethernet/pensando/ionic/ionic_dev.c +3 -3
@@ -21,8 +21,8 @@ static void ionic_watchdog_cb(struct timer_list *t) hb =ionic_heartbeat_check (ionic); -if (hb >=0 && ionic->master_lif) -ionic_link_status_check_request (ionic->master_lif); +if (hb >=0 && ionic->lif) +ionic_link_status_check_request (ionic->lif); }void ionic_init_devinfo (struct ionic *ionic)
@@ -126,7 +126,7 @@ int ionic_heartbeat_check(struct ionic *ionic)/* is this a transition? */ if (fw_status != idev->last_fw_status && idev->last_fw_status !=0xff ) { -struct ionic_lif *lif = ionic->master_lif; +struct ionic_lif *lif = ionic->lif;bool trigger = false;if (!fw_status || fw_status ==0xff ) {
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +1 -1
@@ -85,7 +85,7 @@ int ionic_devlink_register(struct ionic *ionic)dev_err (ionic->dev,"devlink_port_register failed: %d\n" , err); else devlink_port_type_eth_set(&ionic->dl_port, - ionic->master_lif->netdev); + ionic->lif->netdev);return err; }
drivers/net/ethernet/pensando/ionic/ionic_lif.c +33 -98
260 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +7 -7
@@ -242,15 +242,15 @@ void ionic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *ns);void ionic_lif_deferred_enqueue (struct ionic_deferred *def,struct ionic_deferred_work *work); -int ionic_lifs_alloc (struct ionic *ionic); -void ionic_lifs_free (struct ionic *ionic); -void ionic_lifs_deinit (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_alloc (struct ionic *ionic); +int ionic_lif_init (struct ionic_lif *lif); +void ionic_lif_free (struct ionic_lif *lif); +void ionic_lif_deinit (struct ionic_lif *lif); +int ionic_lif_register (struct ionic_lif *lif); +void ionic_lif_unregister (struct ionic_lif *lif);int ionic_lif_identify (struct ionic *ionic,u8 lif_type,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,const u8 *key,const u32 *indir);
Signature · 1 line
2.17.1
PATCH v2 5/12 ionic: rework and simplify handling of the queue stats block
In reply to Shannon NelsonUse a block of stats structs attached to the lif instead of little ones attached to each qcq. This simplifies our memory management and gets rid of a lot of unnecessary indirection.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 4 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 135 +++++++----------- .../net/ethernet/pensando/ionic/ionic_lif.h | 42 ++---- .../net/ethernet/pensando/ionic/ionic_stats.c | 48 +++---- .../net/ethernet/pensando/ionic/ionic_txrx.c | 12 +- 5 files changed, 92 insertions(+), 149 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +2 -2
@@ -454,7 +454,7 @@ static int ionic_set_coalesce(struct net_device *netdev,if (test_bit (IONIC_LIF_F_UP , lif->state)) {for (i =0 ; i < lif->nxqs; i++) { - qcq = lif->rxqcqs[i].qcq; + qcq = lif->rxqcqs[i];ionic_intr_coal_init (lif->ionic->idev.intr_ctrl, qcq->intr.index, lif->rx_coalesce_hw);
@@ -471,7 +471,7 @@ static int ionic_set_coalesce(struct net_device *netdev,if (test_bit (IONIC_LIF_F_UP , lif->state)) {for (i =0 ; i < lif->nxqs; i++) { - qcq = lif->txqcqs[i].qcq; + qcq = lif->txqcqs[i];ionic_intr_coal_init (lif->ionic->idev.intr_ctrl, qcq->intr.index, lif->tx_coalesce_hw);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +52 -83
278 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +12 -30
93 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_stats.c +20 -28
84 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +6 -6
@@ -22,7 +22,7 @@ static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)static inline void ionic_txq_post (struct ionic_queue *q,bool ring_dbell,ionic_desc_cb cb_func,void *cb_arg) { -DEBUG_STATS_TXQ_POST (q_to_qcq (q), q->head->desc, ring_dbell); +DEBUG_STATS_TXQ_POST (q, q->head->desc, ring_dbell);ionic_q_post (q, ring_dbell, cb_func, cb_arg); }
@@ -32,7 +32,7 @@ static inline void ionic_rxq_post(struct ionic_queue *q, bool ring_dbell, {ionic_q_post (q, ring_dbell, cb_func, cb_arg); -DEBUG_STATS_RX_BUFF_CNT (q_to_qcq (q)); +DEBUG_STATS_RX_BUFF_CNT (q); }static inline struct netdev_queue *q_to_ndq (struct ionic_queue *q)
@@ -49,7 +49,7 @@ static struct sk_buff *ionic_rx_skb_alloc(struct ionic_queue *q,struct sk_buff *skb; netdev = lif->netdev; - stats =q_to_rx_stats (q); + stats = &q->lif->rxqstats[q->index];if (frags) skb =napi_get_frags (&q_to_qcq (q)->napi);
@@ -502,7 +502,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) lif = rxcq->bound_q->lif; idev = &lif->ionic->idev; - txcq = &lif->txqcqs[qi].qcq->cq; + txcq = &lif->txqcqs[qi]->cq; tx_work_done =ionic_cq_service (txcq, lif->tx_budget, ionic_tx_service,NULL ,NULL );
@@ -1111,9 +1111,9 @@ netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev)return NETDEV_TX_OK ; } -if (unlikely (!lif_to_txqcq (lif, queue_index))) +if (unlikely (queue_index >= lif->nxqs)) queue_index =0 ; - q =lif_to_txq (lif, queue_index); + q = &lif->txqcqs[queue_index]->q; ndescs =ionic_tx_descs_needed (q, skb);if (ndescs <0 )
Signature · 1 line
2.17.1
PATCH v2 6/12 ionic: clean up unnecessary non-static functions
In reply to Shannon Nelsonionic_open() and ionic_stop() are not referenced outside of their defining file, so make them static.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++-- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -2
@@ -1658,7 +1658,7 @@ static int ionic_start_queues(struct ionic_lif *lif)return 0 ; } -int ionic_open (struct net_device *netdev) +static int ionic_open (struct net_device *netdev) {struct ionic_lif *lif =netdev_priv (netdev);int err;
@@ -1704,7 +1704,7 @@ static void ionic_stop_queues(struct ionic_lif *lif)ionic_txrx_disable (lif); } -int ionic_stop (struct net_device *netdev) +static int ionic_stop (struct net_device *netdev) {struct ionic_lif *lif =netdev_priv (netdev);
drivers/net/ethernet/pensando/ionic/ionic_lif.h +0 -2
@@ -236,8 +236,6 @@ int ionic_lif_size(struct ionic *ionic);int ionic_lif_rss_config (struct ionic_lif *lif,u16 types,const u8 *key,const u32 *indir); -int ionic_open (struct net_device *netdev); -int ionic_stop (struct net_device *netdev);int ionic_reset_queues (struct ionic_lif *lif,ionic_reset_cb cb,void *arg); static inline void debug_stats_txq_post(struct ionic_queue *q,
Signature · 1 line
2.17.1
PATCH v2 7/12 ionic: reduce contiguous memory allocation requirement
In reply to Shannon NelsonSplit out the queue descriptor blocks into separate dma allocations to make for smaller blocks.
--- .../ethernet/pensando/ionic/ionic_debugfs.c | 23 ++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 100 +++++++++++------- .../net/ethernet/pensando/ionic/ionic_lif.h | 12 ++- 3 files changed, 81 insertions(+), 54 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_debugfs.c +12 -11
@@ -112,7 +112,8 @@ static const struct debugfs_reg32 intr_ctrl_regs[] = {void ionic_debugfs_add_qcq (struct ionic_lif *lif,struct ionic_qcq *qcq) { -struct dentry *q_dentry, *cq_dentry, *intr_dentry, *stats_dentry; +struct dentry *qcq_dentry, *q_dentry, *cq_dentry; +struct dentry *intr_dentry, *stats_dentry;struct ionic_dev *idev = &lif->ionic->idev;struct debugfs_regset32 *intr_ctrl_regset;struct ionic_intr_info *intr = &qcq->intr;
@@ -121,21 +122,21 @@ void ionic_debugfs_add_qcq(struct ionic_lif *lif, struct ionic_qcq *qcq)struct ionic_queue *q = &qcq->q;struct ionic_cq *cq = &qcq->cq; - qcq->dentry =debugfs_create_dir (q->name, lif->dentry); + qcq_dentry =debugfs_create_dir (q->name, lif->dentry); +if (IS_ERR_OR_NULL (qcq_dentry)) +return ; + qcq->dentry = qcq_dentry; -debugfs_create_x32 ("total_size" ,0400 , qcq->dentry, &qcq->total_size); -debugfs_create_x64 ("base_pa" ,0400 , qcq->dentry, &qcq->base_pa); +debugfs_create_x64 ("q_base_pa" ,0400 , qcq_dentry, &qcq->q_base_pa); +debugfs_create_x32 ("q_size" ,0400 , qcq_dentry, &qcq->q_size); +debugfs_create_x64 ("cq_base_pa" ,0400 , qcq_dentry, &qcq->cq_base_pa); +debugfs_create_x32 ("cq_size" ,0400 , qcq_dentry, &qcq->cq_size); +debugfs_create_x64 ("sg_base_pa" ,0400 , qcq_dentry, &qcq->sg_base_pa); +debugfs_create_x32 ("sg_size" ,0400 , qcq_dentry, &qcq->sg_size); q_dentry =debugfs_create_dir ("q" , qcq->dentry);debugfs_create_u32 ("index" ,0400 , q_dentry, &q->index); -debugfs_create_x64 ("base_pa" ,0400 , q_dentry, &q->base_pa); -if (qcq->flags &IONIC_QCQ_F_SG ) { -debugfs_create_x64 ("sg_base_pa" ,0400 , q_dentry, - &q->sg_base_pa); -debugfs_create_u32 ("sg_desc_size" ,0400 , q_dentry, - &q->sg_desc_size); - }debugfs_create_u32 ("num_descs" ,0400 , q_dentry, &q->num_descs);debugfs_create_u32 ("desc_size" ,0400 , q_dentry, &q->desc_size);debugfs_create_u32 ("pid" ,0400 , q_dentry, &q->pid);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +60 -40
157 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +9 -3
@@ -57,9 +57,15 @@ struct ionic_napi_stats { };struct ionic_qcq { -void *base; -dma_addr_t base_pa; -unsigned int total_size; +void *q_base; +dma_addr_t q_base_pa; +u32 q_size; +void *cq_base; +dma_addr_t cq_base_pa; +u32 cq_size; +void *sg_base; +dma_addr_t sg_base_pa; +u32 sg_size;struct ionic_queue q;struct ionic_cq cq;struct ionic_intr_info intr;
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerRe: [PATCH v2 net-next 07/12] ionic: reduce contiguous memory allocation requirement
drivers/net/ethernet/pensando/ionic/ionic_lif.c static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, · line 483
Quoted 1 line · On Thu, 27 Aug 2020 11:07:30 -0700 Shannon Nelson wrote:
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0+ q_base = (void *)PTR_ALIGN ((uintptr_t )new->q_base,PAGE_SIZE );
The point of PTR_ALIGN is to make the casts unnecessary. Does it not work?
Re: [PATCH v2 net-next 07/12] ionic: reduce contiguous memory allocation requirement
Quoted 4 lines · Jakub Kicinski
drivers/net/ethernet/pensando/ionic/ionic_lif.c static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, · line 483
Quoted 1 line · On Thu, 27 Aug 2020 11:07:30 -0700 Shannon Nelson wrote:
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0+ q_base = (void *)PTR_ALIGN ((uintptr_t )new->q_base,PAGE_SIZE );The point of
PTR_ALIGNis to make the casts unnecessary. Does it not work?
Here's what I see from two different compiler versions:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion] q_base = PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning: assignment to 'void *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion] q_base = PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);
sln
Jakub Kicinski
maintainerRe: [PATCH v2 net-next 07/12] ionic: reduce contiguous memory allocation requirement
Quoted 12 lines · On Thu, 27 Aug 2020 12:53:17 -0700 Shannon Nelson wrote:
Quoted 4 lines · Jakub Kicinski
drivers/net/ethernet/pensando/ionic/ionic_lif.c static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, · line 483
Quoted 1 line · On Thu, 27 Aug 2020 11:07:30 -0700 Shannon Nelson wrote:
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0+ q_base = (void *)PTR_ALIGN ((uintptr_t )new->q_base,PAGE_SIZE );The point of
PTR_ALIGNis to make the casts unnecessary. Does it not work?Here's what I see from two different compiler versions:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning:
assignment makes pointer from integer without a cast [-Wint-conversion]
q_base=PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);
Quoted 4 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning:
assignment to 'void *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion]
q_base=PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);
Just
q_base = PTR_ALIGN(new->q_base, PAGE_SIZE);
Re: [PATCH v2 net-next 07/12] ionic: reduce contiguous memory allocation requirement
Quoted 13 lines · Jakub Kicinski
Quoted 12 lines · On Thu, 27 Aug 2020 12:53:17 -0700 Shannon Nelson wrote:
Quoted 4 lines · Jakub Kicinski
drivers/net/ethernet/pensando/ionic/ionic_lif.c static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, · line 483
Quoted 1 line · On Thu, 27 Aug 2020 11:07:30 -0700 Shannon Nelson wrote:
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0+ q_base = (void *)PTR_ALIGN ((uintptr_t )new->q_base,PAGE_SIZE );The point of
PTR_ALIGNis to make the casts unnecessary. Does it not work?Here's what I see from two different compiler versions:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning:
assignment makes pointer from integer without a cast [-Wint-conversion]
q_base=PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);
Quoted 7 lines
Quoted 4 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c:514:9: warning:
assignment to 'void *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion]
q_base=PTR_ALIGN((uintptr_t)new->q_base, PAGE_SIZE);Just
q_base = PTR_ALIGN(new->q_base, PAGE_SIZE);
Got it
sln
Jakub Kicinski
maintainerRe: [PATCH v2 net-next 07/12] ionic: reduce contiguous memory allocation requirement
In reply to Shannon NelsonQuoted 1 line · On Thu, 27 Aug 2020 11:07:30 -0700 Shannon Nelson wrote:
Authored-by Neel Patel <[email protected]>
Also - what's Authored-by? :S Do we need a sign-off for this? Perhaps Co-developed-by, which is more standard?
PATCH v2 8/12 ionic: use index not pointer for queue tracking
In reply to Shannon NelsonUse index counters rather than pointers for tracking head and tail in the queues to save a little memory and to perhaps slightly faster queue processing.
--- .../ethernet/pensando/ionic/ionic_debugfs.c | 6 +- .../net/ethernet/pensando/ionic/ionic_dev.c | 40 ++++++----- .../net/ethernet/pensando/ionic/ionic_dev.h | 49 +++++++++---- .../net/ethernet/pensando/ionic/ionic_lif.c | 12 ++-- .../net/ethernet/pensando/ionic/ionic_lif.h | 12 ++-- .../net/ethernet/pensando/ionic/ionic_main.c | 26 ++++--- .../net/ethernet/pensando/ionic/ionic_txrx.c | 72 ++++++++++--------- 7 files changed, 129 insertions(+), 88 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_debugfs.c +3 -3
@@ -76,7 +76,7 @@ static int q_tail_show(struct seq_file *seq, void *v) {struct ionic_queue *q = seq->private; -seq_printf (seq,"%d\n" , q->tail->index); +seq_printf (seq,"%d\n" , q->tail_idx);return 0 ; }
@@ -86,7 +86,7 @@ static int q_head_show(struct seq_file *seq, void *v) {struct ionic_queue *q = seq->private; -seq_printf (seq,"%d\n" , q->head->index); +seq_printf (seq,"%d\n" , q->head_idx);return 0 ; }
@@ -96,7 +96,7 @@ static int cq_tail_show(struct seq_file *seq, void *v) {struct ionic_cq *cq = seq->private; -seq_printf (seq,"%d\n" , cq->tail->index); +seq_printf (seq,"%d\n" , cq->tail_idx);return 0 ; }
drivers/net/ethernet/pensando/ionic/ionic_dev.c +23 -17
@@ -482,7 +482,7 @@ int ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq, cq->bound_intr = intr; cq->num_descs = num_descs; cq->desc_size = desc_size; - cq->tail = cq->info; + cq->tail_idx =0 ; cq->done_color =1 ; cur = cq->info;
@@ -522,15 +522,18 @@ unsigned int ionic_cq_service(struct ionic_cq *cq, unsigned int work_to_do, ionic_cq_cb cb, ionic_cq_done_cb done_cb, void *done_arg) { + struct ionic_cq_info *cq_info;unsigned int work_done =0 ;if (work_to_do ==0 )return 0 ; -while (cb (cq, cq->tail)) { -if (cq->tail->last) + cq_info = &cq->info[cq->tail_idx]; +while (cb (cq, cq_info)) { +if (cq->tail_idx == cq->num_descs -1 ) cq->done_color = !cq->done_color; - cq->tail = cq->tail->next; + cq->tail_idx = (cq->tail_idx +1 ) & (cq->num_descs -1 ); + cq_info = &cq->info[cq->tail_idx];DEBUG_STATS_CQE_CNT (cq);if (++work_done >= work_to_do)
@@ -565,8 +568,8 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev, q->num_descs = num_descs; q->desc_size = desc_size; q->sg_desc_size = sg_desc_size; - q->tail = q->info; - q->head = q->tail; + q->tail_idx =0 ; + q->head_idx =0 ; q->pid = pid;snprintf (q->name,sizeof (q->name),"L%d-%s%u" , lif->index, name, index);
@@ -614,19 +617,22 @@ void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, ionic_desc_cb cb, void *cb_arg) {struct device *dev = q->lif->ionic->dev; +struct ionic_desc_info *desc_info;struct ionic_lif *lif = q->lif; - q->head->cb = cb; - q->head->cb_arg = cb_arg; - q->head = q->head->next; + desc_info = &q->info[q->head_idx]; + desc_info->cb = cb; + desc_info->cb_arg = cb_arg; + + q->head_idx = (q->head_idx +1 ) & (q->num_descs -1 );dev_dbg (dev,"lif=%d qname=%s qid=%d qtype=%d p_index=%d ringdb=%d\n" , q->lif->index, q->name, q->hw_type, q->hw_index, - q->head->index, ring_doorbell); + q->head_idx, ring_doorbell);if (ring_doorbell)ionic_dbell_ring (lif->kern_dbpage, q->hw_type, - q->dbval | q->head->index); + q->dbval | q->head_idx); }static bool ionic_q_is_posted (struct ionic_queue *q,unsigned int pos)
@@ -634,8 +640,8 @@ static bool ionic_q_is_posted(struct ionic_queue *q, unsigned int pos)unsigned int mask, tail, head; mask = q->num_descs -1 ; - tail = q->tail->index; - head = q->head->index; + tail = q->tail_idx; + head = q->head_idx;return ((pos - tail) & mask) < ((head - tail) & mask); }
@@ -648,18 +654,18 @@ void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info,void *cb_arg;/* check for empty queue */ -if (q->tail->index == q->head->index) +if (q->tail_idx == q->head_idx)return ;/* stop index must be for a descriptor that is not yet completed */ if (unlikely (!ionic_q_is_posted (q, stop_index)))dev_err (q->lif->ionic->dev,"ionic stop is not posted %s stop %u tail %u head %u\n" , - q->name, stop_index, q->tail->index, q->head->index); + q->name, stop_index, q->tail_idx, q->head_idx); do { - desc_info = q->tail; - q->tail = desc_info->next; + desc_info = &q->info[q->tail_idx]; + q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1); cb = desc_info->cb; cb_arg = desc_info->cb_arg;
drivers/net/ethernet/pensando/ionic/ionic_dev.h +37 -12
95 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.c +6 -6
@@ -632,9 +632,9 @@ static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)dev_dbg (dev,"txq_init.ver %d\n" , ctx.cmd.q_init.ver);dev_dbg (dev,"txq_init.intr_index %d\n" , ctx.cmd.q_init.intr_index); - q->tail = q->info; - q->head = q->tail; - cq->tail = cq->info; + q->tail_idx =0 ; + q->head_idx =0 ; + cq->tail_idx =0 ; err =ionic_adminq_post_wait (lif, &ctx);if (err)
@@ -689,9 +689,9 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)dev_dbg (dev,"rxq_init.ver %d\n" , ctx.cmd.q_init.ver);dev_dbg (dev,"rxq_init.intr_index %d\n" , ctx.cmd.q_init.intr_index); - q->tail = q->info; - q->head = q->tail; - cq->tail = cq->info; + q->tail_idx =0 ; + q->head_idx =0 ; + cq->tail_idx =0 ; err =ionic_adminq_post_wait (lif, &ctx);if (err)
drivers/net/ethernet/pensando/ionic/ionic_lif.h +6 -6
@@ -244,14 +244,15 @@ int ionic_lif_rss_config(struct ionic_lif *lif, u16 types,int ionic_reset_queues (struct ionic_lif *lif,ionic_reset_cb cb,void *arg); -static inline void debug_stats_txq_post (struct ionic_queue *q, -struct ionic_txq_desc *desc,bool dbell) +static inline void debug_stats_txq_post (struct ionic_queue *q,bool dbell) { -u8 num_sg_elems = ((le64_to_cpu (desc->cmd) >>IONIC_TXQ_DESC_NSGE_SHIFT ) - &IONIC_TXQ_DESC_NSGE_MASK ); +struct ionic_txq_desc *desc = &q->txq[q->head_idx]; +u8 num_sg_elems; q->dbell_count += dbell; + num_sg_elems = ((le64_to_cpu (desc->cmd) >>IONIC_TXQ_DESC_NSGE_SHIFT ) + &IONIC_TXQ_DESC_NSGE_MASK );if (num_sg_elems > (IONIC_MAX_NUM_SG_CNTR -1 )) num_sg_elems =IONIC_MAX_NUM_SG_CNTR -1 ;
@@ -272,8 +273,7 @@ static inline void debug_stats_napi_poll(struct ionic_qcq *qcq,#define DEBUG_STATS_CQE_CNT (cq) ((cq)->compl_count++)#define DEBUG_STATS_RX_BUFF_CNT (q) ((q)->lif->rxqstats[q->index].buffers_posted++)#define DEBUG_STATS_INTR_REARM (intr) ((intr)->rearm_count++) -#define DEBUG_STATS_TXQ_POST (q, txdesc, dbell) \ - debug_stats_txq_post(q, txdesc, dbell) +#define DEBUG_STATS_TXQ_POST (q, dbell) debug_stats_txq_post(q, dbell)#define DEBUG_STATS_NAPI_POLL (qcq, work_done) \ debug_stats_napi_poll(qcq, work_done)
drivers/net/ethernet/pensando/ionic/ionic_main.c +15 -11
@@ -181,15 +181,17 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode)static void ionic_adminq_flush (struct ionic_lif *lif) { -struct ionic_queue *adminq = &lif->adminqcq->q; +struct ionic_queue *q = &lif->adminqcq->q; +struct ionic_desc_info *desc_info;spin_lock (&lif->adminq_lock); -while (adminq->tail != adminq->head) { -memset (adminq->tail->desc,0 ,sizeof (union ionic_adminq_cmd )); - adminq->tail->cb =NULL ; - adminq->tail->cb_arg =NULL ; - adminq->tail = adminq->tail->next; +while (q->tail_idx != q->head_idx) { + desc_info = &q->info[q->tail_idx]; +memset (desc_info->desc,0 ,sizeof (union ionic_adminq_cmd )); + desc_info->cb =NULL ; + desc_info->cb_arg =NULL ; + q->tail_idx = (q->tail_idx +1 ) & (q->num_descs -1 ); }spin_unlock (&lif->adminq_lock); }
@@ -245,7 +247,8 @@ static void ionic_adminq_cb(struct ionic_queue *q,static int ionic_adminq_post (struct ionic_lif *lif,struct ionic_admin_ctx *ctx) { -struct ionic_queue *adminq; +struct ionic_desc_info *desc_info; +struct ionic_queue *q;int err =0 ;WARN_ON (in_interrupt ());
@@ -253,10 +256,10 @@ static int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)if (!lif->adminqcq)return -EIO ; - adminq = &lif->adminqcq->q; + q = &lif->adminqcq->q;spin_lock (&lif->adminq_lock); -if (!ionic_q_has_space (adminq,1 )) { +if (!ionic_q_has_space (q,1 )) { err = -ENOSPC ; goto err_out; }
@@ -265,13 +268,14 @@ static int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)if (err) goto err_out; -memcpy (adminq->head->desc, &ctx->cmd,sizeof (ctx->cmd)); + desc_info = &q->info[q->head_idx]; +memcpy (desc_info->desc, &ctx->cmd,sizeof (ctx->cmd));dev_dbg (&lif->netdev->dev,"post admin queue command:\n" );dynamic_hex_dump ("cmd " ,DUMP_PREFIX_OFFSET ,16 ,1 , &ctx->cmd,sizeof (ctx->cmd), true); -ionic_q_post (adminq, true, ionic_adminq_cb, ctx); +ionic_q_post (q, true, ionic_adminq_cb, ctx); err_out:spin_unlock (&lif->adminq_lock);
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +39 -33
178 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 9/12 ionic: change mtu without full queue rebuild
In reply to Shannon NelsonWe really don't need to tear down and rebuild the whole queue structure when changing the MTU; we can simply stop the queues, clean and refill, then restart the queues.
--- .../net/ethernet/pensando/ionic/ionic_lif.c | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +49 -8
@@ -36,6 +36,8 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif);static void ionic_lif_handle_fw_up (struct ionic_lif *lif);static void ionic_lif_set_netdev_info (struct ionic_lif *lif); +static void ionic_txrx_deinit (struct ionic_lif *lif); +static int ionic_txrx_init (struct ionic_lif *lif);static int ionic_start_queues (struct ionic_lif *lif);static void ionic_stop_queues (struct ionic_lif *lif);static void ionic_lif_queue_identify (struct ionic_lif *lif);
@@ -593,6 +595,17 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif)return err; } +static void ionic_qcq_sanitize (struct ionic_qcq *qcq) +{ + qcq->q.tail_idx =0 ; + qcq->q.head_idx =0 ; + qcq->cq.tail_idx =0 ; + qcq->cq.done_color =1 ; +memset (qcq->q_base,0 , qcq->q_size); +memset (qcq->cq_base,0 , qcq->cq_size); +memset (qcq->sg_base,0 , qcq->sg_size); +} +static int ionic_lif_txq_init (struct ionic_lif *lif,struct ionic_qcq *qcq) {struct device *dev = lif->ionic->dev;
@@ -632,9 +645,7 @@ static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)dev_dbg (dev,"txq_init.ver %d\n" , ctx.cmd.q_init.ver);dev_dbg (dev,"txq_init.intr_index %d\n" , ctx.cmd.q_init.intr_index); - q->tail_idx =0 ; - q->head_idx =0 ; - cq->tail_idx =0 ; +ionic_qcq_sanitize (qcq); err =ionic_adminq_post_wait (lif, &ctx);if (err)
@@ -689,9 +700,7 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)dev_dbg (dev,"rxq_init.ver %d\n" , ctx.cmd.q_init.ver);dev_dbg (dev,"rxq_init.intr_index %d\n" , ctx.cmd.q_init.intr_index); - q->tail_idx =0 ; - q->head_idx =0 ; - cq->tail_idx =0 ; +ionic_qcq_sanitize (qcq); err =ionic_adminq_post_wait (lif, &ctx);if (err)
@@ -1307,6 +1316,35 @@ static int ionic_set_mac_address(struct net_device *netdev, void *sa)return ionic_addr_add (netdev, mac); } +static void ionic_stop_queues_reconfig (struct ionic_lif *lif) +{ +/* Stop and clean the queues before reconfiguration */ +mutex_lock (&lif->queue_lock); +netif_device_detach (lif->netdev); +ionic_stop_queues (lif); +ionic_txrx_deinit (lif); +} + +static int ionic_start_queues_reconfig (struct ionic_lif *lif) +{ +int err; + +/* Re-init the queues after reconfiguration */ + +/* The only way txrx_init can fail here is if communication +* with FW is suddenly broken. There's not much we can do +* at this point - error messages have already been printed, +* so we can continue on and the user can eventually do a +* DOWN and UP to try to reset and clear the issue. +*/ + err =ionic_txrx_init (lif); +mutex_unlock (&lif->queue_lock); +ionic_link_status_check_request (lif); +netif_device_attach (lif->netdev); + +return err; +} +static int ionic_change_mtu (struct net_device *netdev,int new_mtu) {struct ionic_lif *lif =netdev_priv (netdev);
@@ -1326,9 +1364,12 @@ static int ionic_change_mtu(struct net_device *netdev, int new_mtu)return err; netdev->mtu = new_mtu; - err =ionic_reset_queues (lif,NULL ,NULL ); +/* if we're not running, nothing more to do */ +if (!netif_running (netdev)) +return 0 ; -return err; +ionic_stop_queues_reconfig (lif); +return ionic_start_queues_reconfig (lif); }static void ionic_tx_timeout_work (struct work_struct *ws)
Signature · 1 line
2.17.1
PATCH v2 10/12 ionic: change the descriptor ring length without full reset
In reply to Shannon NelsonThe original way of changing ring length was to completely tear down the lif's queue structure and then rebuild it, while running the risk of allocations that might fail in the middle and leave us with a broken driver.
Instead, we can set up all the new queue and descriptor allocations first, then swap them out and delete the old allocations. If the new allocations fail, we report the error, stay with the old setup and continue running. This gives us a safer path, and a smaller window of time where we're not processing traffic.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 35 +++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 145 +++++++++++++++++- .../net/ethernet/pensando/ionic/ionic_lif.h | 19 ++- 3 files changed, 185 insertions(+), 14 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +26 -9
@@ -493,18 +493,14 @@ static void ionic_get_ringparam(struct net_device *netdev, ring->rx_pending = lif->nrxq_descs; } -static void ionic_set_ringsize (struct ionic_lif *lif,void *arg) -{ -struct ethtool_ringparam *ring = arg; - - lif->ntxq_descs = ring->tx_pending; - lif->nrxq_descs = ring->rx_pending; -} -static int ionic_set_ringparam (struct net_device *netdev,struct ethtool_ringparam *ring) {struct ionic_lif *lif =netdev_priv (netdev); +struct ionic_queue_params qparam; +int err; + +ionic_init_queue_params (lif, &qparam);if (ring->rx_mini_pending || ring->rx_jumbo_pending) {netdev_info (netdev,"Changing jumbo or mini descriptors not supported\n" );
@@ -522,7 +518,28 @@ static int ionic_set_ringparam(struct net_device *netdev, ring->rx_pending == lif->nrxq_descs)return 0 ; -return ionic_reset_queues (lif, ionic_set_ringsize, ring); +if (ring->tx_pending != lif->ntxq_descs) +netdev_info (netdev,"Changing Tx ring size from %d to %d\n" , + lif->ntxq_descs, ring->tx_pending); + +if (ring->rx_pending != lif->nrxq_descs) +netdev_info (netdev,"Changing Rx ring size from %d to %d\n" , + lif->nrxq_descs, ring->rx_pending); + +/* if we're not running, just set the values and return */ +if (!netif_running (lif->netdev)) { + lif->ntxq_descs = ring->tx_pending; + lif->nrxq_descs = ring->rx_pending; +return 0 ; + } + + qparam.ntxq_descs = ring->tx_pending; + qparam.nrxq_descs = ring->rx_pending; + err =ionic_reconfigure_queues (lif, &qparam); +if (err) +netdev_info (netdev,"Ring reconfiguration failed, changes canceled: %d\n" , err); + +return err; } static void ionic_get_channels(struct net_device *netdev,
drivers/net/ethernet/pensando/ionic/ionic_lif.c +141 -4
157 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +18 -1
@@ -207,6 +207,22 @@ struct ionic_lif {struct work_struct tx_timeout_work; }; +struct ionic_queue_params { +unsigned int nxqs; +unsigned int ntxq_descs; +unsigned int nrxq_descs; +unsigned int intr_split; +}; + +static inline void ionic_init_queue_params (struct ionic_lif *lif, +struct ionic_queue_params *qparam) +{ + qparam->nxqs = lif->nxqs; + qparam->ntxq_descs = lif->ntxq_descs; + qparam->nrxq_descs = lif->nrxq_descs; + qparam->intr_split =test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); +} +static inline u32 ionic_coal_usec_to_hw (struct ionic *ionic,u32 usecs) {u32 mult =le32_to_cpu (ionic->ident.dev.intr_coal_mult);
@@ -241,7 +257,8 @@ int ionic_lif_identify(struct ionic *ionic, u8 lif_type,int ionic_lif_size (struct ionic *ionic);int ionic_lif_rss_config (struct ionic_lif *lif,u16 types,const u8 *key,const u32 *indir); - +int ionic_reconfigure_queues (struct ionic_lif *lif, +struct ionic_queue_params *qparam);int ionic_reset_queues (struct ionic_lif *lif,ionic_reset_cb cb,void *arg);static inline void debug_stats_txq_post (struct ionic_queue *q,bool dbell)
Signature · 1 line
2.17.1
PATCH v2 11/12 ionic: change queue count with no reset
In reply to Shannon NelsonAdd to our new ionic_reconfigure_queues() to also be able to change the number of queues in use, and to change the queue interrupt layout between split and combined.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 88 ++++--- .../net/ethernet/pensando/ionic/ionic_lif.c | 216 +++++++++++++----- 2 files changed, 213 insertions(+), 91 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +57 -31
@@ -561,32 +561,15 @@ static void ionic_get_channels(struct net_device *netdev, } } -static void ionic_set_queuecount (struct ionic_lif *lif,void *arg) -{ -struct ethtool_channels *ch = arg; - -if (ch->combined_count) { - lif->nxqs = ch->combined_count; -if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) { -clear_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); - lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; - lif->tx_coalesce_hw = lif->rx_coalesce_hw; -netdev_info (lif->netdev,"Sharing queue interrupts\n" ); - } - }else { - lif->nxqs = ch->rx_count; -if (!test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) { -set_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); -netdev_info (lif->netdev,"Splitting queue interrupts\n" ); - } - } -} -static int ionic_set_channels (struct net_device *netdev,struct ethtool_channels *ch) {struct ionic_lif *lif =netdev_priv (netdev); -int new_cnt; +struct ionic_queue_params qparam; +int max_cnt; +int err; + +ionic_init_queue_params (lif, &qparam);if (ch->rx_count != ch->tx_count) {netdev_info (netdev,"The rx and tx count must be equal\n" );
@@ -594,20 +577,63 @@ static int ionic_set_channels(struct net_device *netdev, }if (ch->combined_count && ch->rx_count) { -netdev_info (netdev,"Use either combined_count or rx/tx_count, not both\n" ); +netdev_info (netdev,"Use either combined or rx and tx, not both\n" );return -EINVAL ; } -if (ch->combined_count) - new_cnt = ch->combined_count; -else - new_cnt = ch->rx_count; + max_cnt = lif->ionic->ntxqs_per_lif; +if (ch->combined_count) { +if (ch->combined_count > max_cnt) +return -EINVAL ; + +if (test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) +netdev_info (lif->netdev,"Sharing queue interrupts\n" ); +else if (ch->combined_count == lif->nxqs) +return 0 ; -if (lif->nxqs != new_cnt) -netdev_info (netdev,"Changing queue count from %d to %d\n" , - lif->nxqs, new_cnt); +if (lif->nxqs != ch->combined_count) +netdev_info (netdev,"Changing queue count from %d to %d\n" , + lif->nxqs, ch->combined_count); -return ionic_reset_queues (lif, ionic_set_queuecount, ch); + qparam.nxqs = ch->combined_count; + qparam.intr_split =0 ; + }else { + max_cnt /=2 ; +if (ch->rx_count > max_cnt) +return -EINVAL ; + +if (!test_bit (IONIC_LIF_F_SPLIT_INTR , lif->state)) +netdev_info (lif->netdev,"Splitting queue interrupts\n" ); +else if (ch->rx_count == lif->nxqs) +return 0 ; + +if (lif->nxqs != ch->rx_count) +netdev_info (netdev,"Changing queue count from %d to %d\n" , + lif->nxqs, ch->rx_count); + + qparam.nxqs = ch->rx_count; + qparam.intr_split =1 ; + } + +/* if we're not running, just set the values and return */ +if (!netif_running (lif->netdev)) { + lif->nxqs = qparam.nxqs; + +if (qparam.intr_split) { +set_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); + }else { +clear_bit (IONIC_LIF_F_SPLIT_INTR , lif->state); + lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; + lif->tx_coalesce_hw = lif->rx_coalesce_hw; + } +return 0 ; + } + + err =ionic_reconfigure_queues (lif, &qparam); +if (err) +netdev_info (netdev,"Queue reconfiguration failed, changes canceled: %d\n" , err); + +return err; }static u32 ionic_get_priv_flags (struct net_device *netdev)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +156 -60
357 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 12/12 ionic: pull reset_queues into tx_timeout handler
In reply to Shannon NelsonConvert tx_timeout handler to not do the full reset. As this was the last user of ionic_reset_queues(), we can drop it.
--- .../net/ethernet/pensando/ionic/ionic_lif.c | 39 ++++--------------- .../net/ethernet/pensando/ionic/ionic_lif.h | 1 - 2 files changed, 8 insertions(+), 32 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +8 -31
@@ -1406,9 +1406,14 @@ static void ionic_tx_timeout_work(struct work_struct *ws)netdev_info (lif->netdev,"Tx Timeout recovery\n" ); -rtnl_lock (); -ionic_reset_queues (lif,NULL ,NULL ); -rtnl_unlock (); +/* if we were stopped before this scheduled job was launched, +* don't bother the queues as they are already stopped. +*/ +if (!netif_running (lif->netdev)) +return ; + +ionic_stop_queues_reconfig (lif); +ionic_start_queues_reconfig (lif); }static void ionic_tx_timeout (struct net_device *netdev,unsigned int txqueue)
@@ -2280,34 +2285,6 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,return err; } -int ionic_reset_queues (struct ionic_lif *lif,ionic_reset_cb cb,void *arg) -{ -bool running; -int err =0 ; - -mutex_lock (&lif->queue_lock); - running =netif_running (lif->netdev); -if (running) { -netif_device_detach (lif->netdev); - err =ionic_stop (lif->netdev); -if (err) - goto reset_out; - } - -if (cb) -cb (lif, arg); - -if (running) { - err =ionic_open (lif->netdev); -netif_device_attach (lif->netdev); - } - -reset_out: -mutex_unlock (&lif->queue_lock); - -return err; -} -int ionic_lif_alloc (struct ionic *ionic) {struct device *dev = ionic->dev;
drivers/net/ethernet/pensando/ionic/ionic_lif.h +0 -1
@@ -259,7 +259,6 @@ int ionic_lif_rss_config(struct ionic_lif *lif, u16 types, const u8 *key, const u32 *indir);int ionic_reconfigure_queues (struct ionic_lif *lif,struct ionic_queue_params *qparam); -int ionic_reset_queues (struct ionic_lif *lif,ionic_reset_cb cb,void *arg);static inline void debug_stats_txq_post (struct ionic_queue *q,bool dbell) {
Signature · 1 line
2.17.1