summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/huawei/hinic3/hinic3_hwif.h
blob: 513c9680e6b61374eaaecd599439a73093114502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. */

#ifndef _HINIC3_HWIF_H_
#define _HINIC3_HWIF_H_

#include <linux/build_bug.h>
#include <linux/spinlock_types.h>

struct hinic3_hwdev;

enum hinic3_func_type {
	HINIC3_FUNC_TYPE_VF = 1,
};

struct hinic3_db_area {
	unsigned long *db_bitmap_array;
	u32           db_max_areas;
	/* protect doorbell area alloc and free */
	spinlock_t    idx_lock;
};

struct hinic3_func_attr {
	enum hinic3_func_type func_type;
	u16                   func_global_idx;
	u16                   global_vf_id_of_pf;
	u16                   num_irqs;
	u16                   num_sq;
	u8                    port_to_port_idx;
	u8                    pci_intf_idx;
	u8                    ppf_idx;
	u8                    num_aeqs;
	u8                    num_ceqs;
	u8                    msix_flex_en;
};

static_assert(sizeof(struct hinic3_func_attr) == 20);

struct hinic3_hwif {
	u8 __iomem              *cfg_regs_base;
	u64                     db_base_phy;
	u64                     db_dwqe_len;
	u8 __iomem              *db_base;
	struct hinic3_db_area   db_area;
	struct hinic3_func_attr attr;
};

enum hinic3_msix_state {
	HINIC3_MSIX_ENABLE,
	HINIC3_MSIX_DISABLE,
};

void hinic3_set_msix_state(struct hinic3_hwdev *hwdev, u16 msix_idx,
			   enum hinic3_msix_state flag);

u16 hinic3_global_func_id(struct hinic3_hwdev *hwdev);

#endif