Commit efe11e97 authored by Weibo Zhao's avatar Weibo Zhao Committed by JiangShui
Browse files

hns3 udma: init software tables of qp/uar and others

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I85R2F


CVE: NA

------------------------------------------------------

When driver insmoded, tables as qp/uar/jetty/jfs/jfr/jfc
and others should be created.

UAR(user-area-region) is an independent structure between
context. It contains doorbell address and direct wqe
address.

Signed-off-by: default avatarWeibo Zhao <zhaoweibo3@huawei.com>
parent e1d0edff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,6 +8,6 @@ ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/ \
		-I$(srctree)/drivers/ub/urma/

$(MODULE_NAME)-objs := hns3_udma_hw.o hns3_udma_main.o hns3_udma_cmd.o \
			hns3_udma_hem.o
			hns3_udma_hem.o hns3_udma_qp.o

obj-$(CONFIG_UB_UDMA_HNS3) := hns3_udma.o
+25 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@
#define PG_SHIFT_OFFSET				(PAGE_SHIFT - 12)
#define UDMA_MAX_IRQ_NUM			128
#define UDMA_QP_BANK_NUM			8
#define QP_BANKID_SHIFT				3
#define QP_BANKID_MASK				GENMASK(2, 0)
#define UDMA_QPC_SZ				512
#define UDMA_CQE_SZ				64
#define UDMA_SCCC_SZ				64
@@ -57,6 +59,7 @@

#define UDMA_MAX_BT_REGION			3
#define UDMA_MAX_BT_LEVEL			3
#define UDMA_DEFAULT_MAX_JETTY_X_SHIFT	8

enum udma_reset_stage {
	UDMA_STATE_RST_DOWN = 2,
@@ -452,6 +455,11 @@ struct udma_qp_table {
	struct udma_idx_table	idx_table;
};

struct udma_eq_table {
	uint32_t	*idx_table;
	struct udma_eq	*eq;
};

struct udma_jfc_table {
	struct xarray		xa;
	struct udma_hem_table	table;
@@ -470,6 +478,11 @@ struct udma_jfr_table {
	struct udma_ida		jfr_ida;
};

struct udma_jetty_table {
	struct xarray		xa;
	struct udma_ida		jetty_ida;
};

struct udma_seg_table {
	struct udma_ida		seg_ida;
	struct udma_hem_table	table;
@@ -484,6 +497,9 @@ struct udma_dev {
	bool				dis_db;
	uint64_t			reset_cnt;
	struct udma_netdev		uboe;

	struct list_head		pgdir_list;
	struct mutex			pgdir_mutex;
	uint8_t __iomem			*reg_base;
	struct udma_caps		caps;

@@ -498,14 +514,21 @@ struct udma_dev {
	uint16_t			func_id;
	uint32_t			func_num;
	uint32_t			cong_algo_tmpl_id;
	struct udma_ida			uar_ida;
	struct udma_jfs_table		jfs_table;
	struct udma_jfr_table		jfr_table;
	struct udma_jetty_table		jetty_table;
	struct udma_seg_table		seg_table;
	struct udma_jfc_table		jfc_table;
	struct udma_qp_table		qp_table;
	struct udma_eq_table		eq_table;
	struct udma_hem_table		qpc_timer_table;
	struct udma_hem_table		cqc_timer_table;
	struct udma_hem_table		gmv_table;
	struct list_head		qp_list;
	spinlock_t			qp_list_lock;
	struct list_head		dip_list;
	spinlock_t			dip_list_lock;
};

static inline uint64_t to_hr_hw_page_addr(uint64_t addr)
@@ -550,6 +573,8 @@ int udma_mtr_create(struct udma_dev *udma_dev, struct udma_mtr *mtr,
		    struct udma_buf_attr *buf_attr, uint32_t ba_page_shift,
		    uint64_t user_addr, bool is_user);
void udma_mtr_destroy(struct udma_dev *udma_dev, struct udma_mtr *mtr);
int udma_init_qp_table(struct udma_dev *udma_dev);
void udma_cleanup_qp_table(struct udma_dev *udma_dev);
void udma_cleanup_common_hem(struct udma_dev *udma_dev);
int udma_init_common_hem(struct udma_dev *udma_dev);

+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#include <linux/slab.h>
#include <linux/scatterlist.h>
#include "hns3_udma_device.h"

#define HEM_HOP_STEP_DIRECT 0xff
#define HEM_INDEX_BUF BIT(0)
#define HEM_INDEX_L0 BIT(1)
+11 −0
Original line number Diff line number Diff line
@@ -162,6 +162,16 @@ static int udma_set_vf_switch_param(struct udma_dev *udma_dev)
	return 0;
}

static void set_default_jetty_caps(struct udma_dev *dev)
{
	struct udma_caps *caps = &dev->caps;

	caps->num_jfc_shift = UDMA_DEFAULT_MAX_JETTY_X_SHIFT;
	caps->num_jfs_shift = UDMA_DEFAULT_MAX_JETTY_X_SHIFT;
	caps->num_jfr_shift = UDMA_DEFAULT_MAX_JETTY_X_SHIFT;
	caps->num_jetty_shift = UDMA_DEFAULT_MAX_JETTY_X_SHIFT;
}

static int udma_query_caps(struct udma_dev *udma_dev)
{
	enum udma_opcode_type opcode = UDMA_OPC_QUERY_PF_CAPS_NUM;
@@ -337,6 +347,7 @@ static int udma_query_caps(struct udma_dev *udma_dev)
					      QUERY_PF_CAPS_D_RQWQE_HOP_NUM_M,
					      QUERY_PF_CAPS_D_RQWQE_HOP_NUM_S);

	set_default_jetty_caps(udma_dev);
	return 0;
}

+26 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Huawei UDMA Linux driver
 * Copyright (c) 2023-2023 Hisilicon Limited.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 */

#ifndef _UDMA_JFC_H
#define _UDMA_JFC_H

#include "hns3_udma_device.h"
static inline uint8_t get_jfc_bankid(uint64_t cqn)
{
	/* The lower 2 bits of CQN are used to hash to different banks */
	return (uint8_t)(cqn & GENMASK(1, 0));
}

#endif /* _UDMA_JFC_H */
Loading