RDMA/hns: Remove unused RR mechanism
[linux-2.6-microblaze.git] / drivers / infiniband / hw / hns / hns_roce_hw_v1.c
index 5346fdc..4045d59 100644 (file)
@@ -54,7 +54,7 @@
  *             GID[0][0], GID[1][0],.....GID[N - 1][0],
  *             And so on
  */
-u8 hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
+u8 hns_get_gid_index(struct hns_roce_dev *hr_dev, u32 port, int gid_index)
 {
        return gid_index * hr_dev->caps.num_ports + port;
 }
@@ -345,7 +345,7 @@ out:
                doorbell[0] = sq_db.u32_4;
                doorbell[1] = sq_db.u32_8;
 
-               hns_roce_write64_k(doorbell, qp->sq.db_reg_l);
+               hns_roce_write64_k(doorbell, qp->sq.db_reg);
        }
 
        spin_unlock_irqrestore(&qp->sq.lock, flags);
@@ -440,7 +440,7 @@ out:
                        doorbell[0] = rq_db.u32_4;
                        doorbell[1] = rq_db.u32_8;
 
-                       hns_roce_write64_k(doorbell, hr_qp->rq.db_reg_l);
+                       hns_roce_write64_k(doorbell, hr_qp->rq.db_reg);
                }
        }
        spin_unlock_irqrestore(&hr_qp->rq.lock, flags);
@@ -462,6 +462,81 @@ static void hns_roce_set_db_event_mode(struct hns_roce_dev *hr_dev,
        roce_write(hr_dev, ROCEE_GLB_CFG_REG, val);
 }
 
+static int hns_roce_v1_set_hem(struct hns_roce_dev *hr_dev,
+                              struct hns_roce_hem_table *table, int obj,
+                              int step_idx)
+{
+       spinlock_t *lock = &hr_dev->bt_cmd_lock;
+       struct device *dev = hr_dev->dev;
+       struct hns_roce_hem_iter iter;
+       void __iomem *bt_cmd;
+       __le32 bt_cmd_val[2];
+       __le32 bt_cmd_h = 0;
+       unsigned long flags;
+       __le32 bt_cmd_l;
+       int ret = 0;
+       u64 bt_ba;
+       long end;
+
+       /* Find the HEM(Hardware Entry Memory) entry */
+       unsigned long i = obj / (table->table_chunk_size / table->obj_size);
+
+       switch (table->type) {
+       case HEM_TYPE_QPC:
+       case HEM_TYPE_MTPT:
+       case HEM_TYPE_CQC:
+       case HEM_TYPE_SRQC:
+               roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
+                       ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, table->type);
+               break;
+       default:
+               return ret;
+       }
+
+       roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
+                      ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj);
+       roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
+       roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_HW_SYNS_S, 1);
+
+       /* Currently iter only a chunk */
+       for (hns_roce_hem_first(table->hem[i], &iter);
+            !hns_roce_hem_last(&iter); hns_roce_hem_next(&iter)) {
+               bt_ba = hns_roce_hem_addr(&iter) >> HNS_HW_PAGE_SHIFT;
+
+               spin_lock_irqsave(lock, flags);
+
+               bt_cmd = hr_dev->reg_base + ROCEE_BT_CMD_H_REG;
+
+               end = HW_SYNC_TIMEOUT_MSECS;
+               while (end > 0) {
+                       if (!(readl(bt_cmd) >> BT_CMD_SYNC_SHIFT))
+                               break;
+
+                       mdelay(HW_SYNC_SLEEP_TIME_INTERVAL);
+                       end -= HW_SYNC_SLEEP_TIME_INTERVAL;
+               }
+
+               if (end <= 0) {
+                       dev_err(dev, "Write bt_cmd err,hw_sync is not zero.\n");
+                       spin_unlock_irqrestore(lock, flags);
+                       return -EBUSY;
+               }
+
+               bt_cmd_l = cpu_to_le32(bt_ba);
+               roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
+                              ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S,
+                              upper_32_bits(bt_ba));
+
+               bt_cmd_val[0] = bt_cmd_l;
+               bt_cmd_val[1] = bt_cmd_h;
+               hns_roce_write64_k(bt_cmd_val,
+                                  hr_dev->reg_base + ROCEE_BT_CMD_L_REG);
+               spin_unlock_irqrestore(lock, flags);
+       }
+
+       return ret;
+}
+
 static void hns_roce_set_db_ext_mode(struct hns_roce_dev *hr_dev, u32 sdb_mode,
                                     u32 odb_mode)
 {
@@ -538,7 +613,7 @@ static void hns_roce_set_sdb_ext(struct hns_roce_dev *hr_dev, u32 ext_sdb_alept,
        /*
         * 44 = 32 + 12, When evaluating addr to hardware, shift 12 because of
         * using 4K page, and shift more 32 because of
-        * caculating the high 32 bit value evaluated to hardware.
+        * calculating the high 32 bit value evaluated to hardware.
         */
        roce_set_field(tmp, ROCEE_EXT_DB_SQ_H_EXT_DB_SQ_BA_H_M,
                       ROCEE_EXT_DB_SQ_H_EXT_DB_SQ_BA_H_S, sdb_dma_addr >> 44);
@@ -711,7 +786,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
        int i, j;
        u8 queue_en[HNS_ROCE_V1_RESV_QP] = { 0 };
        u8 phy_port;
-       u8 port = 0;
+       u32 port = 0;
        u8 sl;
 
        /* Reserved cq for loop qp */
@@ -1124,7 +1199,7 @@ free_mr:
                mr->key, jiffies_to_usecs(jiffies) - jiffies_to_usecs(start));
 
        hns_roce_bitmap_free(&hr_dev->mr_table.mtpt_bitmap,
-                            key_to_hw_index(mr->key), 0);
+                            key_to_hw_index(mr->key));
        hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr);
        kfree(mr);
 
@@ -1189,7 +1264,7 @@ static int hns_roce_raq_init(struct hns_roce_dev *hr_dev)
        /*
         * 44 = 32 + 12, When evaluating addr to hardware, shift 12 because of
         * using 4K page, and shift more 32 because of
-        * caculating the high 32 bit value evaluated to hardware.
+        * calculating the high 32 bit value evaluated to hardware.
         */
        roce_set_field(tmp, ROCEE_EXT_RAQ_H_EXT_RAQ_BA_H_M,
                       ROCEE_EXT_RAQ_H_EXT_RAQ_BA_H_S,
@@ -1382,7 +1457,6 @@ static int hns_roce_free_mr_init(struct hns_roce_dev *hr_dev)
        ret = hns_roce_v1_rsv_lp_qp(hr_dev);
        if (ret) {
                dev_err(dev, "Reserved loop qp failed(%d)!\n", ret);
-               flush_workqueue(free_mr->free_mr_wq);
                destroy_workqueue(free_mr->free_mr_wq);
        }
 
@@ -1394,7 +1468,6 @@ static void hns_roce_free_mr_free(struct hns_roce_dev *hr_dev)
        struct hns_roce_v1_priv *priv = hr_dev->priv;
        struct hns_roce_free_mr *free_mr = &priv->free_mr;
 
-       flush_workqueue(free_mr->free_mr_wq);
        destroy_workqueue(free_mr->free_mr_wq);
 
        hns_roce_v1_release_lp_qp(hr_dev);
@@ -1676,7 +1749,7 @@ static int hns_roce_v1_chk_mbox(struct hns_roce_dev *hr_dev,
        return 0;
 }
 
-static int hns_roce_v1_set_gid(struct hns_roce_dev *hr_dev, u8 port,
+static int hns_roce_v1_set_gid(struct hns_roce_dev *hr_dev, u32 port,
                               int gid_index, const union ib_gid *gid,
                               const struct ib_gid_attr *attr)
 {
@@ -1939,7 +2012,7 @@ static void hns_roce_v1_cq_set_ci(struct hns_roce_cq *hr_cq, u32 cons_index)
        roce_set_field(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_INP_H_M,
                       ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_INP_H_S, hr_cq->cqn);
 
-       hns_roce_write64_k(doorbell, hr_cq->cq_db_l);
+       hns_roce_write64_k(doorbell, hr_cq->db_reg);
 }
 
 static void __hns_roce_v1_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn,
@@ -2041,7 +2114,7 @@ static void hns_roce_v1_write_cqc(struct hns_roce_dev *hr_dev,
        /**
         * 44 = 32 + 12, When evaluating addr to hardware, shift 12 because of
         * using 4K page, and shift more 32 because of
-        * caculating the high 32 bit value evaluated to hardware.
+        * calculating the high 32 bit value evaluated to hardware.
         */
        roce_set_field(cq_context->cqc_byte_20,
                       CQ_CONTEXT_CQC_BYTE_20_CQE_TPTR_ADDR_H_M,
@@ -2092,7 +2165,7 @@ static int hns_roce_v1_req_notify_cq(struct ib_cq *ibcq,
                       ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_INP_H_S,
                       hr_cq->cqn | notification_flag);
 
-       hns_roce_write64_k(doorbell, hr_cq->cq_db_l);
+       hns_roce_write64_k(doorbell, hr_cq->db_reg);
 
        return 0;
 }
@@ -2673,8 +2746,8 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
        int ret = -EINVAL;
        u64 sq_ba = 0;
        u64 rq_ba = 0;
-       int port;
-       u8 port_num;
+       u32 port;
+       u32 port_num;
        u8 *dmac;
        u8 *smac;
 
@@ -3217,12 +3290,12 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
                roce_set_bit(doorbell[1], RQ_DOORBELL_U32_8_HW_SYNC_S, 1);
 
                if (ibqp->uobject) {
-                       hr_qp->rq.db_reg_l = hr_dev->reg_base +
+                       hr_qp->rq.db_reg = hr_dev->reg_base +
                                     hr_dev->odb_offset +
                                     DB_REG_OFFSET * hr_dev->priv_uar.index;
                }
 
-               hns_roce_write64_k(doorbell, hr_qp->rq.db_reg_l);
+               hns_roce_write64_k(doorbell, hr_qp->rq.db_reg);
        }
 
        hr_qp->state = new_state;
@@ -3449,8 +3522,7 @@ static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
                                   ((roce_get_bit(context->qpc_bytes_4,
                        QP_CONTEXT_QPC_BYTE_4_ATOMIC_OPERATION_ENABLE_S)) << 3);
 
-       if (hr_qp->ibqp.qp_type == IB_QPT_RC ||
-           hr_qp->ibqp.qp_type == IB_QPT_UC) {
+       if (hr_qp->ibqp.qp_type == IB_QPT_RC) {
                struct ib_global_route *grh =
                        rdma_ah_retrieve_grh(&qp_attr->ah_attr);
 
@@ -3604,7 +3676,7 @@ static int hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
 static void set_eq_cons_index_v1(struct hns_roce_eq *eq, u32 req_not)
 {
        roce_raw_write((eq->cons_index & HNS_ROCE_V1_CONS_IDX_M) |
-                      (req_not << eq->log_entries), eq->doorbell);
+                      (req_not << eq->log_entries), eq->db_reg);
 }
 
 static void hns_roce_v1_wq_catas_err_handle(struct hns_roce_dev *hr_dev,
@@ -4170,7 +4242,7 @@ static int hns_roce_v1_create_eq(struct hns_roce_dev *hr_dev,
         * Configure eq extended address 45~49 bit.
         * 44 = 32 + 12, When evaluating addr to hardware, shift 12 because of
         * using 4K page, and shift more 32 because of
-        * caculating the high 32 bit value evaluated to hardware.
+        * calculating the high 32 bit value evaluated to hardware.
         */
        roce_set_field(tmp1, ROCEE_CAEP_AEQE_CUR_IDX_CAEP_AEQ_BT_H_M,
                       ROCEE_CAEP_AEQE_CUR_IDX_CAEP_AEQ_BT_H_S,
@@ -4234,9 +4306,9 @@ static int hns_roce_v1_init_eq_table(struct hns_roce_dev *hr_dev)
                                                ROCEE_CAEP_CEQC_SHIFT_0_REG +
                                                CEQ_REG_OFFSET * i;
                        eq->type_flag = HNS_ROCE_CEQ;
-                       eq->doorbell = hr_dev->reg_base +
-                                      ROCEE_CAEP_CEQC_CONS_IDX_0_REG +
-                                      CEQ_REG_OFFSET * i;
+                       eq->db_reg = hr_dev->reg_base +
+                                    ROCEE_CAEP_CEQC_CONS_IDX_0_REG +
+                                    CEQ_REG_OFFSET * i;
                        eq->entries = hr_dev->caps.ceqe_depth;
                        eq->log_entries = ilog2(eq->entries);
                        eq->eqe_size = HNS_ROCE_CEQE_SIZE;
@@ -4245,8 +4317,8 @@ static int hns_roce_v1_init_eq_table(struct hns_roce_dev *hr_dev)
                        eq_table->eqc_base[i] = hr_dev->reg_base +
                                                ROCEE_CAEP_AEQC_AEQE_SHIFT_REG;
                        eq->type_flag = HNS_ROCE_AEQ;
-                       eq->doorbell = hr_dev->reg_base +
-                                      ROCEE_CAEP_AEQE_CONS_IDX_REG;
+                       eq->db_reg = hr_dev->reg_base +
+                                    ROCEE_CAEP_AEQE_CONS_IDX_REG;
                        eq->entries = hr_dev->caps.aeqe_depth;
                        eq->log_entries = ilog2(eq->entries);
                        eq->eqe_size = HNS_ROCE_AEQE_SIZE;
@@ -4349,20 +4421,15 @@ static const struct hns_roce_hw hns_roce_hw_v1 = {
        .hw_init = hns_roce_v1_init,
        .hw_exit = hns_roce_v1_exit,
        .post_mbox = hns_roce_v1_post_mbox,
-       .chk_mbox = hns_roce_v1_chk_mbox,
+       .poll_mbox_done = hns_roce_v1_chk_mbox,
        .set_gid = hns_roce_v1_set_gid,
        .set_mac = hns_roce_v1_set_mac,
        .set_mtu = hns_roce_v1_set_mtu,
        .write_mtpt = hns_roce_v1_write_mtpt,
        .write_cqc = hns_roce_v1_write_cqc,
+       .set_hem = hns_roce_v1_set_hem,
        .clear_hem = hns_roce_v1_clear_hem,
        .modify_qp = hns_roce_v1_modify_qp,
-       .query_qp = hns_roce_v1_query_qp,
-       .destroy_qp = hns_roce_v1_destroy_qp,
-       .post_send = hns_roce_v1_post_send,
-       .post_recv = hns_roce_v1_post_recv,
-       .req_notify_cq = hns_roce_v1_req_notify_cq,
-       .poll_cq = hns_roce_v1_poll_cq,
        .dereg_mr = hns_roce_v1_dereg_mr,
        .destroy_cq = hns_roce_v1_destroy_cq,
        .init_eq = hns_roce_v1_init_eq_table,