Lines Matching refs:eq

6001 				      struct hns_roce_eq *eq, u32 queue_num)
6011 irq_work->event_type = eq->event_type;
6012 irq_work->sub_type = eq->sub_type;
6017 static void update_eq_db(struct hns_roce_eq *eq)
6019 struct hns_roce_dev *hr_dev = eq->hr_dev;
6022 if (eq->type_flag == HNS_ROCE_AEQ) {
6024 eq->arm_st == HNS_ROCE_V2_EQ_ALWAYS_ARMED ?
6028 hr_reg_write(&eq_db, EQ_DB_TAG, eq->eqn);
6031 eq->arm_st == HNS_ROCE_V2_EQ_ALWAYS_ARMED ?
6036 hr_reg_write(&eq_db, EQ_DB_CI, eq->cons_index);
6038 hns_roce_write64(hr_dev, (__le32 *)&eq_db, eq->db_reg);
6041 static struct hns_roce_aeqe *next_aeqe_sw_v2(struct hns_roce_eq *eq)
6045 aeqe = hns_roce_buf_offset(eq->mtr.kmem,
6046 (eq->cons_index & (eq->entries - 1)) *
6047 eq->eqe_size);
6050 !!(eq->cons_index & eq->entries)) ? aeqe : NULL;
6054 struct hns_roce_eq *eq)
6057 struct hns_roce_aeqe *aeqe = next_aeqe_sw_v2(eq);
6105 event_type, eq->eqn, eq->cons_index);
6109 eq->event_type = event_type;
6110 eq->sub_type = sub_type;
6111 ++eq->cons_index;
6116 hns_roce_v2_init_irq_work(hr_dev, eq, queue_num);
6118 aeqe = next_aeqe_sw_v2(eq);
6121 update_eq_db(eq);
6126 static struct hns_roce_ceqe *next_ceqe_sw_v2(struct hns_roce_eq *eq)
6130 ceqe = hns_roce_buf_offset(eq->mtr.kmem,
6131 (eq->cons_index & (eq->entries - 1)) *
6132 eq->eqe_size);
6135 !!(eq->cons_index & eq->entries)) ? ceqe : NULL;
6139 struct hns_roce_eq *eq)
6141 struct hns_roce_ceqe *ceqe = next_ceqe_sw_v2(eq);
6155 ++eq->cons_index;
6159 ceqe = next_ceqe_sw_v2(eq);
6162 update_eq_db(eq);
6169 struct hns_roce_eq *eq = eq_ptr;
6170 struct hns_roce_dev *hr_dev = eq->hr_dev;
6173 if (eq->type_flag == HNS_ROCE_CEQ)
6175 int_work = hns_roce_v2_ceq_int(hr_dev, eq);
6178 int_work = hns_roce_v2_aeq_int(hr_dev, eq);
6403 static void free_eq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
6405 hns_roce_mtr_destroy(hr_dev, &eq->mtr);
6408 static void init_eq_config(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
6410 eq->db_reg = hr_dev->reg_base + ROCEE_VF_EQ_DB_CFG0_REG;
6411 eq->cons_index = 0;
6412 eq->over_ignore = HNS_ROCE_V2_EQ_OVER_IGNORE_0;
6413 eq->coalesce = HNS_ROCE_V2_EQ_COALESCE_0;
6414 eq->arm_st = HNS_ROCE_V2_EQ_ALWAYS_ARMED;
6415 eq->shift = ilog2((unsigned int)eq->entries);
6418 static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq,
6429 init_eq_config(hr_dev, eq);
6432 ret = hns_roce_mtr_find(hr_dev, &eq->mtr, 0, eqe_ba,
6439 bt_ba = hns_roce_get_mtr_ba(&eq->mtr);
6442 hr_reg_write(eqc, EQC_EQE_HOP_NUM, eq->hop_num);
6443 hr_reg_write(eqc, EQC_OVER_IGNORE, eq->over_ignore);
6444 hr_reg_write(eqc, EQC_COALESCE, eq->coalesce);
6445 hr_reg_write(eqc, EQC_ARM_ST, eq->arm_st);
6446 hr_reg_write(eqc, EQC_EQN, eq->eqn);
6449 to_hr_hw_page_shift(eq->mtr.hem_cfg.ba_pg_shift));
6451 to_hr_hw_page_shift(eq->mtr.hem_cfg.buf_pg_shift));
6453 hr_reg_write(eqc, EQC_EQ_MAX_CNT, eq->eq_max_cnt);
6456 if (eq->eq_period * HNS_ROCE_CLOCK_ADJUST > USHRT_MAX) {
6458 eq->eq_period);
6459 eq->eq_period = HNS_ROCE_MAX_EQ_PERIOD;
6461 eq->eq_period *= HNS_ROCE_CLOCK_ADJUST;
6464 hr_reg_write(eqc, EQC_EQ_PERIOD, eq->eq_period);
6468 hr_reg_write(eqc, EQC_SHIFT, eq->shift);
6476 hr_reg_write(eqc, EQC_EQE_SIZE, eq->eqe_size == HNS_ROCE_V3_EQE_SIZE);
6481 static int alloc_eq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
6487 eq->hop_num = 0;
6489 eq->hop_num = hr_dev->caps.eqe_hop_num;
6492 buf_attr.region[0].size = eq->entries * eq->eqe_size;
6493 buf_attr.region[0].hopnum = eq->hop_num;
6496 err = hns_roce_mtr_create(hr_dev, &eq->mtr, &buf_attr,
6506 struct hns_roce_eq *eq, u8 eq_cmd)
6516 ret = alloc_eq_buf(hr_dev, eq);
6520 ret = config_eqc(hr_dev, eq, mailbox->buf);
6524 ret = hns_roce_create_hw_ctx(hr_dev, mailbox, eq_cmd, eq->eqn);
6535 free_eq_buf(hr_dev, eq);
6580 ret = request_irq(eq_table->eq[j - other_num].irq,
6583 &eq_table->eq[j - other_num]);
6585 ret = request_irq(eq_table->eq[j - other_num].irq,
6588 &eq_table->eq[j - other_num]);
6602 free_irq(eq_table->eq[j - other_num].irq,
6603 &eq_table->eq[j - other_num]);
6625 free_irq(hr_dev->eq_table.eq[i].irq, &hr_dev->eq_table.eq[i]);
6635 struct hns_roce_eq *eq;
6652 eq_table->eq = kcalloc(eq_num, sizeof(*eq_table->eq), GFP_KERNEL);
6653 if (!eq_table->eq)
6656 /* create eq */
6658 eq = &eq_table->eq[i];
6659 eq->hr_dev = hr_dev;
6660 eq->eqn = i;
6664 eq->type_flag = HNS_ROCE_CEQ;
6665 eq->entries = hr_dev->caps.ceqe_depth;
6666 eq->eqe_size = hr_dev->caps.ceqe_size;
6667 eq->irq = hr_dev->irq[i + other_num + aeq_num];
6668 eq->eq_max_cnt = HNS_ROCE_CEQ_DEFAULT_BURST_NUM;
6669 eq->eq_period = HNS_ROCE_CEQ_DEFAULT_INTERVAL;
6673 eq->type_flag = HNS_ROCE_AEQ;
6674 eq->entries = hr_dev->caps.aeqe_depth;
6675 eq->eqe_size = hr_dev->caps.aeqe_size;
6676 eq->irq = hr_dev->irq[i - comp_num + other_num];
6677 eq->eq_max_cnt = HNS_ROCE_AEQ_DEFAULT_BURST_NUM;
6678 eq->eq_period = HNS_ROCE_AEQ_DEFAULT_INTERVAL;
6681 ret = hns_roce_v2_create_eq(hr_dev, eq, eq_cmd);
6683 dev_err(dev, "failed to create eq.\n");
6714 free_eq_buf(hr_dev, &eq_table->eq[i]);
6715 kfree(eq_table->eq);
6737 free_eq_buf(hr_dev, &eq_table->eq[i]);
6740 kfree(eq_table->eq);