Skip to content

Commit 73af08e

Browse files
Jayamohan KallickalChristoph Hellwig
authored andcommitted
be2iscsi: Fix interrupt Coalescing mechanism.
Signed-off-by: Minh Tran <minhduc.tran@emulex.com> Signed-off-by: John Soni Jose <sony.john-n@emulex.com> Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 0598b8a commit 73af08e

6 files changed

Lines changed: 118 additions & 5 deletions

File tree

‎drivers/scsi/be2iscsi/be.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,20 @@ static inline void queue_tail_inc(struct be_queue_info *q)
8383

8484
/*ISCSI */
8585

86+
struct be_aic_obj { /* Adaptive interrupt coalescing (AIC) info */
87+
bool enable;
88+
u32 min_eqd; /* in usecs */
89+
u32 max_eqd; /* in usecs */
90+
u32 prev_eqd; /* in usecs */
91+
u32 et_eqd; /* configured val when aic is off */
92+
ulong jiffs;
93+
u64 eq_prev; /* Used to calculate eqe */
94+
};
95+
8696
struct be_eq_obj {
8797
bool todo_mcc_cq;
8898
bool todo_cq;
99+
u32 cq_count;
89100
struct be_queue_info q;
90101
struct beiscsi_hba *phba;
91102
struct be_queue_info *cq;

‎drivers/scsi/be2iscsi/be_cmds.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ struct be_cmd_resp_eq_create {
271271
u16 rsvd0; /* sword */
272272
} __packed;
273273

274+
struct be_set_eqd {
275+
u32 eq_id;
276+
u32 phase;
277+
u32 delay_multiplier;
278+
} __packed;
279+
274280
struct mgmt_chap_format {
275281
u32 flags;
276282
u8 intr_chap_name[256];
@@ -622,7 +628,7 @@ struct be_cmd_req_modify_eq_delay {
622628
u32 eq_id;
623629
u32 phase;
624630
u32 delay_multiplier;
625-
} delay[8];
631+
} delay[MAX_CPUS];
626632
} __packed;
627633

628634
/******************** Get MAC ADDR *******************/
@@ -708,6 +714,8 @@ unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
708714

709715
void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
710716

717+
int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
718+
int num);
711719
int beiscsi_mccq_compl(struct beiscsi_hba *phba,
712720
uint32_t tag, struct be_mcc_wrb **wrb,
713721
struct be_dma_mem *mbx_cmd_mem);

‎drivers/scsi/be2iscsi/be_main.c‎

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ static int be_iopoll(struct blk_iopoll *iop, int budget)
22712271

22722272
pbe_eq = container_of(iop, struct be_eq_obj, iopoll);
22732273
ret = beiscsi_process_cq(pbe_eq);
2274+
pbe_eq->cq_count += ret;
22742275
if (ret < budget) {
22752276
phba = pbe_eq->phba;
22762277
blk_iopoll_complete(iop);
@@ -3825,9 +3826,9 @@ static int hwi_init_port(struct beiscsi_hba *phba)
38253826

38263827
phwi_ctrlr = phba->phwi_ctrlr;
38273828
phwi_context = phwi_ctrlr->phwi_ctxt;
3828-
phwi_context->max_eqd = 0;
3829+
phwi_context->max_eqd = 128;
38293830
phwi_context->min_eqd = 0;
3830-
phwi_context->cur_eqd = 64;
3831+
phwi_context->cur_eqd = 0;
38313832
be_cmd_fw_initialize(&phba->ctrl);
38323833

38333834
status = beiscsi_create_eqs(phba, phwi_context);
@@ -5282,6 +5283,57 @@ static void beiscsi_msix_enable(struct beiscsi_hba *phba)
52825283
return;
52835284
}
52845285

5286+
static void be_eqd_update(struct beiscsi_hba *phba)
5287+
{
5288+
struct be_set_eqd set_eqd[MAX_CPUS];
5289+
struct be_aic_obj *aic;
5290+
struct be_eq_obj *pbe_eq;
5291+
struct hwi_controller *phwi_ctrlr;
5292+
struct hwi_context_memory *phwi_context;
5293+
int eqd, i, num = 0;
5294+
ulong now;
5295+
u32 pps, delta;
5296+
unsigned int tag;
5297+
5298+
phwi_ctrlr = phba->phwi_ctrlr;
5299+
phwi_context = phwi_ctrlr->phwi_ctxt;
5300+
5301+
for (i = 0; i <= phba->num_cpus; i++) {
5302+
aic = &phba->aic_obj[i];
5303+
pbe_eq = &phwi_context->be_eq[i];
5304+
now = jiffies;
5305+
if (!aic->jiffs || time_before(now, aic->jiffs) ||
5306+
pbe_eq->cq_count < aic->eq_prev) {
5307+
aic->jiffs = now;
5308+
aic->eq_prev = pbe_eq->cq_count;
5309+
continue;
5310+
}
5311+
delta = jiffies_to_msecs(now - aic->jiffs);
5312+
pps = (((u32)(pbe_eq->cq_count - aic->eq_prev) * 1000) / delta);
5313+
eqd = (pps / 1500) << 2;
5314+
5315+
if (eqd < 8)
5316+
eqd = 0;
5317+
eqd = min_t(u32, eqd, phwi_context->max_eqd);
5318+
eqd = max_t(u32, eqd, phwi_context->min_eqd);
5319+
5320+
aic->jiffs = now;
5321+
aic->eq_prev = pbe_eq->cq_count;
5322+
5323+
if (eqd != aic->prev_eqd) {
5324+
set_eqd[num].delay_multiplier = (eqd * 65)/100;
5325+
set_eqd[num].eq_id = pbe_eq->q.id;
5326+
aic->prev_eqd = eqd;
5327+
num++;
5328+
}
5329+
}
5330+
if (num) {
5331+
tag = be_cmd_modify_eq_delay(phba, set_eqd, num);
5332+
if (tag)
5333+
beiscsi_mccq_compl(phba, tag, NULL, NULL);
5334+
}
5335+
}
5336+
52855337
/*
52865338
* beiscsi_hw_health_check()- Check adapter health
52875339
* @work: work item to check HW health
@@ -5295,6 +5347,8 @@ beiscsi_hw_health_check(struct work_struct *work)
52955347
container_of(work, struct beiscsi_hba,
52965348
beiscsi_hw_check_task.work);
52975349

5350+
be_eqd_update(phba);
5351+
52985352
beiscsi_ue_detect(phba);
52995353

53005354
schedule_delayed_work(&phba->beiscsi_hw_check_task,

‎drivers/scsi/be2iscsi/be_main.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171

7272
#define BEISCSI_SGLIST_ELEMENTS 30
7373

74-
#define BEISCSI_CMD_PER_LUN 128 /* scsi_host->cmd_per_lun */
75-
#define BEISCSI_MAX_SECTORS 2048 /* scsi_host->max_sectors */
74+
#define BEISCSI_CMD_PER_LUN 128 /* scsi_host->cmd_per_lun */
75+
#define BEISCSI_MAX_SECTORS 1024 /* scsi_host->max_sectors */
7676
#define BEISCSI_TEMPLATE_HDR_PER_CXN_SIZE 128 /* Template size per cxn */
7777

7878
#define BEISCSI_MAX_CMD_LEN 16 /* scsi_host->max_cmd_len */
@@ -427,6 +427,7 @@ struct beiscsi_hba {
427427
struct mgmt_session_info boot_sess;
428428
struct invalidate_command_table inv_tbl[128];
429429

430+
struct be_aic_obj aic_obj[MAX_CPUS];
430431
unsigned int attr_log_enable;
431432
int (*iotask_fn)(struct iscsi_task *,
432433
struct scatterlist *sg,

‎drivers/scsi/be2iscsi/be_mgmt.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,43 @@ void beiscsi_ue_detect(struct beiscsi_hba *phba)
155155
}
156156
}
157157

158+
int be_cmd_modify_eq_delay(struct beiscsi_hba *phba,
159+
struct be_set_eqd *set_eqd, int num)
160+
{
161+
struct be_ctrl_info *ctrl = &phba->ctrl;
162+
struct be_mcc_wrb *wrb;
163+
struct be_cmd_req_modify_eq_delay *req;
164+
unsigned int tag = 0;
165+
int i;
166+
167+
spin_lock(&ctrl->mbox_lock);
168+
tag = alloc_mcc_tag(phba);
169+
if (!tag) {
170+
spin_unlock(&ctrl->mbox_lock);
171+
return tag;
172+
}
173+
174+
wrb = wrb_from_mccq(phba);
175+
req = embedded_payload(wrb);
176+
177+
wrb->tag0 |= tag;
178+
be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
179+
be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
180+
OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req));
181+
182+
req->num_eq = cpu_to_le32(num);
183+
for (i = 0; i < num; i++) {
184+
req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id);
185+
req->delay[i].phase = 0;
186+
req->delay[i].delay_multiplier =
187+
cpu_to_le32(set_eqd[i].delay_multiplier);
188+
}
189+
190+
be_mcc_notify(phba);
191+
spin_unlock(&ctrl->mbox_lock);
192+
return tag;
193+
}
194+
158195
/**
159196
* mgmt_reopen_session()- Reopen a session based on reopen_type
160197
* @phba: Device priv structure instance

‎drivers/scsi/be2iscsi/be_mgmt.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,7 @@ void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
335335
void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
336336
struct wrb_handle *pwrb_handle);
337337
void beiscsi_ue_detect(struct beiscsi_hba *phba);
338+
int be_cmd_modify_eq_delay(struct beiscsi_hba *phba,
339+
struct be_set_eqd *, int num);
338340

339341
#endif

0 commit comments

Comments
 (0)