Lines Matching defs:table

194 		dev_err(dev, "table %u not support multi-hop addressing!\n",
203 struct hns_roce_hem_table *table, unsigned long *obj,
212 if (get_hem_table_config(hr_dev, mhop, table->type))
222 bt_num = hns_roce_get_bt_num(table->type, mhop->hop_num);
224 chunk_size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size :
226 table_idx = *obj / (chunk_size / table->obj_size);
241 dev_err(dev, "table %u not support hop_num = %u!\n",
242 table->type, mhop->hop_num);
299 struct hns_roce_hem_table *table, unsigned long obj,
310 ret = hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, mhop);
318 bt_num = hns_roce_get_bt_num(table->type, mhop->hop_num);
334 ibdev_err(ibdev, "table %u not support mhop.hop_num = %u!\n",
335 table->type, mhop->hop_num);
339 if (unlikely(index->buf >= table->num_hem)) {
340 ibdev_err(ibdev, "table %u exceed hem limt idx %llu, max %lu!\n",
341 table->type, index->buf, table->num_hem);
349 struct hns_roce_hem_table *table,
357 hns_roce_free_hem(hr_dev, table->hem[index->buf]);
358 table->hem[index->buf] = NULL;
362 dma_free_coherent(dev, bt_size, table->bt_l1[index->l1],
363 table->bt_l1_dma_addr[index->l1]);
364 table->bt_l1[index->l1] = NULL;
368 dma_free_coherent(dev, bt_size, table->bt_l0[index->l0],
369 table->bt_l0_dma_addr[index->l0]);
370 table->bt_l0[index->l0] = NULL;
375 struct hns_roce_hem_table *table,
387 if ((check_whether_bt_num_3(table->type, mhop->hop_num) ||
388 check_whether_bt_num_2(table->type, mhop->hop_num)) &&
389 !table->bt_l0[index->l0]) {
390 table->bt_l0[index->l0] = dma_alloc_coherent(dev, bt_size,
391 &table->bt_l0_dma_addr[index->l0],
393 if (!table->bt_l0[index->l0]) {
401 if (check_whether_bt_num_3(table->type, mhop->hop_num) &&
402 !table->bt_l1[index->l1]) {
403 table->bt_l1[index->l1] = dma_alloc_coherent(dev, bt_size,
404 &table->bt_l1_dma_addr[index->l1],
406 if (!table->bt_l1[index->l1]) {
411 *(table->bt_l0[index->l0] + mhop->l1_idx) =
412 table->bt_l1_dma_addr[index->l1];
419 size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size : bt_size;
421 table->hem[index->buf] = hns_roce_alloc_hem(hr_dev, size, flag);
422 if (!table->hem[index->buf]) {
428 bt_ba = table->hem[index->buf]->dma;
430 if (table->type < HEM_TYPE_MTT) {
432 *(table->bt_l1[index->l1] + mhop->l2_idx) = bt_ba;
434 *(table->bt_l0[index->l0] + mhop->l1_idx) = bt_ba;
436 *(table->bt_l0[index->l0] + mhop->l1_idx) = bt_ba;
441 free_mhop_hem(hr_dev, table, mhop, index);
447 struct hns_roce_hem_table *table, unsigned long obj,
456 ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
464 ret = hr_dev->hw->set_hem(hr_dev, table, obj, 1);
476 ret = hr_dev->hw->set_hem(hr_dev, table, obj, step_idx);
485 struct hns_roce_hem_table *table,
493 ret = calc_hem_config(hr_dev, table, obj, &mhop, &index);
499 mutex_lock(&table->mutex);
500 if (table->hem[index.buf]) {
501 refcount_inc(&table->hem[index.buf]->refcount);
505 ret = alloc_mhop_hem(hr_dev, table, &mhop, &index);
512 if (table->type < HEM_TYPE_MTT) {
513 ret = set_mhop_hem(hr_dev, table, obj, &mhop, &index);
520 refcount_set(&table->hem[index.buf]->refcount, 1);
524 free_mhop_hem(hr_dev, table, &mhop, &index);
526 mutex_unlock(&table->mutex);
531 struct hns_roce_hem_table *table, unsigned long obj)
537 if (hns_roce_check_whether_mhop(hr_dev, table->type))
538 return hns_roce_table_mhop_get(hr_dev, table, obj);
540 i = obj / (table->table_chunk_size / table->obj_size);
542 mutex_lock(&table->mutex);
544 if (table->hem[i]) {
545 refcount_inc(&table->hem[i]->refcount);
549 table->hem[i] = hns_roce_alloc_hem(hr_dev,
550 table->table_chunk_size,
552 if (!table->hem[i]) {
558 ret = hr_dev->hw->set_hem(hr_dev, table, obj, HEM_HOP_STEP_DIRECT);
560 hns_roce_free_hem(hr_dev, table->hem[i]);
561 table->hem[i] = NULL;
567 refcount_set(&table->hem[i]->refcount, 1);
569 mutex_unlock(&table->mutex);
574 struct hns_roce_hem_table *table, unsigned long obj,
586 if (check_whether_bt_num_2(table->type, hop_num)) {
587 if (hns_roce_check_hem_null(table->hem, index->buf,
588 chunk_ba_num, table->num_hem))
590 } else if (check_whether_bt_num_3(table->type, hop_num)) {
591 if (hns_roce_check_hem_null(table->hem, index->buf,
592 chunk_ba_num, table->num_hem)) {
594 if (hns_roce_check_bt_null(table->bt_l1, index->l1,
600 if (table->type < HEM_TYPE_MTT) {
606 ret = hr_dev->hw->clear_hem(hr_dev, table, obj, step_idx);
612 ret = hr_dev->hw->clear_hem(hr_dev, table, obj, 1);
619 ret = hr_dev->hw->clear_hem(hr_dev, table, obj, 0);
628 struct hns_roce_hem_table *table,
637 ret = calc_hem_config(hr_dev, table, obj, &mhop, &index);
644 mutex_lock(&table->mutex);
645 else if (!refcount_dec_and_mutex_lock(&table->hem[index.buf]->refcount,
646 &table->mutex))
649 clear_mhop_hem(hr_dev, table, obj, &mhop, &index);
650 free_mhop_hem(hr_dev, table, &mhop, &index);
652 mutex_unlock(&table->mutex);
656 struct hns_roce_hem_table *table, unsigned long obj)
662 if (hns_roce_check_whether_mhop(hr_dev, table->type)) {
663 hns_roce_table_mhop_put(hr_dev, table, obj, 1);
667 i = obj / (table->table_chunk_size / table->obj_size);
669 if (!refcount_dec_and_mutex_lock(&table->hem[i]->refcount,
670 &table->mutex))
673 ret = hr_dev->hw->clear_hem(hr_dev, table, obj, HEM_HOP_STEP_DIRECT);
678 hns_roce_free_hem(hr_dev, table->hem[i]);
679 table->hem[i] = NULL;
681 mutex_unlock(&table->mutex);
685 struct hns_roce_hem_table *table,
698 mutex_lock(&table->mutex);
700 if (!hns_roce_check_whether_mhop(hr_dev, table->type)) {
701 obj_per_chunk = table->table_chunk_size / table->obj_size;
702 hem = table->hem[obj / obj_per_chunk];
704 dma_offset = offset = idx_offset * table->obj_size;
708 if (hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop))
719 hem = table->hem[hem_idx];
732 mutex_unlock(&table->mutex);
737 struct hns_roce_hem_table *table, u32 type,
744 table->table_chunk_size = hr_dev->caps.chunk_sz;
745 obj_per_chunk = table->table_chunk_size / obj_size;
748 table->hem = kcalloc(num_hem, sizeof(*table->hem), GFP_KERNEL);
749 if (!table->hem)
774 table->hem = kcalloc(num_hem, sizeof(*table->hem),
776 if (!table->hem)
783 table->bt_l1 = kcalloc(num_bt_l1,
784 sizeof(*table->bt_l1),
786 if (!table->bt_l1)
789 table->bt_l1_dma_addr = kcalloc(num_bt_l1,
790 sizeof(*table->bt_l1_dma_addr),
793 if (!table->bt_l1_dma_addr)
799 table->bt_l0 = kcalloc(num_bt_l0, sizeof(*table->bt_l0),
801 if (!table->bt_l0)
804 table->bt_l0_dma_addr = kcalloc(num_bt_l0,
805 sizeof(*table->bt_l0_dma_addr),
807 if (!table->bt_l0_dma_addr)
812 table->type = type;
813 table->num_hem = num_hem;
814 table->obj_size = obj_size;
815 mutex_init(&table->mutex);
820 kfree(table->bt_l0);
821 table->bt_l0 = NULL;
824 kfree(table->bt_l1_dma_addr);
825 table->bt_l1_dma_addr = NULL;
828 kfree(table->bt_l1);
829 table->bt_l1 = NULL;
832 kfree(table->hem);
833 table->hem = NULL;
840 struct hns_roce_hem_table *table)
847 if (hns_roce_calc_hem_mhop(hr_dev, table, NULL, &mhop))
849 buf_chunk_size = table->type < HEM_TYPE_MTT ? mhop.buf_chunk_size :
852 for (i = 0; i < table->num_hem; ++i) {
853 obj = i * buf_chunk_size / table->obj_size;
854 if (table->hem[i])
855 hns_roce_table_mhop_put(hr_dev, table, obj, 0);
858 kfree(table->hem);
859 table->hem = NULL;
860 kfree(table->bt_l1);
861 table->bt_l1 = NULL;
862 kfree(table->bt_l1_dma_addr);
863 table->bt_l1_dma_addr = NULL;
864 kfree(table->bt_l0);
865 table->bt_l0 = NULL;
866 kfree(table->bt_l0_dma_addr);
867 table->bt_l0_dma_addr = NULL;
871 struct hns_roce_hem_table *table)
878 if (hns_roce_check_whether_mhop(hr_dev, table->type)) {
879 hns_roce_cleanup_mhop_hem_table(hr_dev, table);
883 for (i = 0; i < table->num_hem; ++i)
884 if (table->hem[i]) {
885 obj = i * table->table_chunk_size / table->obj_size;
886 ret = hr_dev->hw->clear_hem(hr_dev, table, obj, 0);
891 hns_roce_free_hem(hr_dev, table->hem[i]);
894 kfree(table->hem);
901 &hr_dev->srq_table.table);
902 hns_roce_cleanup_hem_table(hr_dev, &hr_dev->cq_table.table);
995 /* assign L0 table address to hem from root bt */
1029 * hopnum base address table levels
1041 * @bt_level: base address table level
1347 /* construct the base address table and link them by address hop config */