Skip to content

Commit b14e4e9

Browse files
emuslndavem330
authored andcommitted
ionic: tx separate servicing
We give the tx clean path its own budget and service routine in order to give a little more leeway to be more aggressive, and in preparation for coming changes. We've found this gives us a little better performance in some packet processing scenarios without hurting other scenarios. Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 155f15a commit b14e4e9

File tree

3 files changed

+53
-56
lines changed

3 files changed

+53
-56
lines changed

drivers/net/ethernet/pensando/ionic/ionic_lif.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index
20652065
lif->index = index;
20662066
lif->ntxq_descs = IONIC_DEF_TXRX_DESC;
20672067
lif->nrxq_descs = IONIC_DEF_TXRX_DESC;
2068+
lif->tx_budget = IONIC_TX_BUDGET_DEFAULT;
20682069

20692070
/* Convert the default coalesce value to actual hw resolution */
20702071
lif->rx_coalesce_usecs = IONIC_ITR_COAL_USEC_DEFAULT;

drivers/net/ethernet/pensando/ionic/ionic_lif.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define IONIC_MAX_NUM_NAPI_CNTR (NAPI_POLL_WEIGHT + 1)
1414
#define IONIC_MAX_NUM_SG_CNTR (IONIC_TX_MAX_SG_ELEMS + 1)
1515
#define IONIC_RX_COPYBREAK_DEFAULT 256
16+
#define IONIC_TX_BUDGET_DEFAULT 256
1617

1718
struct ionic_tx_stats {
1819
u64 dma_map_err;
@@ -176,6 +177,7 @@ struct ionic_lif {
176177
unsigned int ntxq_descs;
177178
unsigned int nrxq_descs;
178179
u32 rx_copybreak;
180+
u32 tx_budget;
179181
unsigned int rx_mode;
180182
u64 hw_features;
181183
bool mc_overflow;

drivers/net/ethernet/pensando/ionic/ionic_txrx.c

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ static void ionic_rx_clean(struct ionic_queue *q,
1515
struct ionic_cq_info *cq_info,
1616
void *cb_arg);
1717

18+
static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info);
19+
20+
static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info);
21+
1822
static inline void ionic_txq_post(struct ionic_queue *q, bool ring_dbell,
1923
ionic_desc_cb cb_func, void *cb_arg)
2024
{
@@ -249,29 +253,13 @@ static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
249253
return true;
250254
}
251255

252-
static u32 ionic_rx_walk_cq(struct ionic_cq *rxcq, u32 limit)
253-
{
254-
u32 work_done = 0;
255-
256-
while (ionic_rx_service(rxcq, rxcq->tail)) {
257-
if (rxcq->tail->last)
258-
rxcq->done_color = !rxcq->done_color;
259-
rxcq->tail = rxcq->tail->next;
260-
DEBUG_STATS_CQE_CNT(rxcq);
261-
262-
if (++work_done >= limit)
263-
break;
264-
}
265-
266-
return work_done;
267-
}
268-
269256
void ionic_rx_flush(struct ionic_cq *cq)
270257
{
271258
struct ionic_dev *idev = &cq->lif->ionic->idev;
272259
u32 work_done;
273260

274-
work_done = ionic_rx_walk_cq(cq, cq->num_descs);
261+
work_done = ionic_cq_service(cq, cq->num_descs,
262+
ionic_rx_service, NULL, NULL);
275263

276264
if (work_done)
277265
ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
@@ -439,32 +427,42 @@ int ionic_rx_napi(struct napi_struct *napi, int budget)
439427
struct ionic_dev *idev;
440428
struct ionic_lif *lif;
441429
struct ionic_cq *txcq;
430+
u32 rx_work_done = 0;
431+
u32 tx_work_done = 0;
442432
u32 work_done = 0;
443433
u32 flags = 0;
434+
bool unmask;
444435

445436
lif = rxcq->bound_q->lif;
446437
idev = &lif->ionic->idev;
447438
txcq = &lif->txqcqs[qi].qcq->cq;
448439

449-
ionic_tx_flush(txcq);
450-
451-
work_done = ionic_rx_walk_cq(rxcq, budget);
440+
tx_work_done = ionic_cq_service(txcq, lif->tx_budget,
441+
ionic_tx_service, NULL, NULL);
452442

453-
if (work_done)
443+
rx_work_done = ionic_cq_service(rxcq, budget,
444+
ionic_rx_service, NULL, NULL);
445+
if (rx_work_done)
454446
ionic_rx_fill_cb(rxcq->bound_q);
455447

456-
if (work_done < budget && napi_complete_done(napi, work_done)) {
448+
unmask = (rx_work_done < budget) && (tx_work_done < lif->tx_budget);
449+
450+
if (unmask && napi_complete_done(napi, rx_work_done)) {
457451
flags |= IONIC_INTR_CRED_UNMASK;
458452
DEBUG_STATS_INTR_REARM(rxcq->bound_intr);
453+
work_done = rx_work_done;
454+
} else {
455+
work_done = budget;
459456
}
460457

461458
if (work_done || flags) {
462459
flags |= IONIC_INTR_CRED_RESET_COALESCE;
463460
ionic_intr_credits(idev->intr_ctrl, rxcq->bound_intr->index,
464-
work_done, flags);
461+
tx_work_done + rx_work_done, flags);
465462
}
466463

467-
DEBUG_STATS_NAPI_POLL(qcq, work_done);
464+
DEBUG_STATS_NAPI_POLL(qcq, rx_work_done);
465+
DEBUG_STATS_NAPI_POLL(qcq, tx_work_done);
468466

469467
return work_done;
470468
}
@@ -552,43 +550,39 @@ static void ionic_tx_clean(struct ionic_queue *q,
552550
}
553551
}
554552

555-
void ionic_tx_flush(struct ionic_cq *cq)
553+
static bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
556554
{
557-
struct ionic_txq_comp *comp = cq->tail->cq_desc;
558-
struct ionic_dev *idev = &cq->lif->ionic->idev;
555+
struct ionic_txq_comp *comp = cq_info->cq_desc;
559556
struct ionic_queue *q = cq->bound_q;
560557
struct ionic_desc_info *desc_info;
561-
unsigned int work_done = 0;
562-
563-
/* walk the completed cq entries */
564-
while (work_done < cq->num_descs &&
565-
color_match(comp->color, cq->done_color)) {
566-
567-
/* clean the related q entries, there could be
568-
* several q entries completed for each cq completion
569-
*/
570-
do {
571-
desc_info = q->tail;
572-
q->tail = desc_info->next;
573-
ionic_tx_clean(q, desc_info, cq->tail,
574-
desc_info->cb_arg);
575-
desc_info->cb = NULL;
576-
desc_info->cb_arg = NULL;
577-
} while (desc_info->index != le16_to_cpu(comp->comp_index));
578-
579-
if (cq->tail->last)
580-
cq->done_color = !cq->done_color;
581-
582-
cq->tail = cq->tail->next;
583-
comp = cq->tail->cq_desc;
584-
DEBUG_STATS_CQE_CNT(cq);
585-
586-
work_done++;
587-
}
588558

559+
if (!color_match(comp->color, cq->done_color))
560+
return false;
561+
562+
/* clean the related q entries, there could be
563+
* several q entries completed for each cq completion
564+
*/
565+
do {
566+
desc_info = q->tail;
567+
q->tail = desc_info->next;
568+
ionic_tx_clean(q, desc_info, cq->tail, desc_info->cb_arg);
569+
desc_info->cb = NULL;
570+
desc_info->cb_arg = NULL;
571+
} while (desc_info->index != le16_to_cpu(comp->comp_index));
572+
573+
return true;
574+
}
575+
576+
void ionic_tx_flush(struct ionic_cq *cq)
577+
{
578+
struct ionic_dev *idev = &cq->lif->ionic->idev;
579+
u32 work_done;
580+
581+
work_done = ionic_cq_service(cq, cq->num_descs,
582+
ionic_tx_service, NULL, NULL);
589583
if (work_done)
590584
ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
591-
work_done, 0);
585+
work_done, IONIC_INTR_CRED_RESET_COALESCE);
592586
}
593587

594588
void ionic_tx_empty(struct ionic_queue *q)

0 commit comments

Comments
 (0)