]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/net/enic/base/vnic_intr.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / enic / base / vnic_intr.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
7c673cae 3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
7c673cae
FG
4 */
5
6#ifndef _VNIC_INTR_H_
7#define _VNIC_INTR_H_
8
9
10#include "vnic_dev.h"
11
12#define VNIC_INTR_TIMER_TYPE_ABS 0
13#define VNIC_INTR_TIMER_TYPE_QUIET 1
14
15/* Interrupt control */
16struct vnic_intr_ctrl {
17 u32 coalescing_timer; /* 0x00 */
18 u32 pad0;
19 u32 coalescing_value; /* 0x08 */
20 u32 pad1;
21 u32 coalescing_type; /* 0x10 */
22 u32 pad2;
23 u32 mask_on_assertion; /* 0x18 */
24 u32 pad3;
25 u32 mask; /* 0x20 */
26 u32 pad4;
27 u32 int_credits; /* 0x28 */
28 u32 pad5;
29 u32 int_credit_return; /* 0x30 */
30 u32 pad6;
31};
32
33struct vnic_intr {
34 unsigned int index;
35 struct vnic_dev *vdev;
36 struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */
37};
38
39static inline void vnic_intr_unmask(struct vnic_intr *intr)
40{
41 iowrite32(0, &intr->ctrl->mask);
42}
43
44static inline void vnic_intr_mask(struct vnic_intr *intr)
45{
46 iowrite32(1, &intr->ctrl->mask);
47}
48
49static inline int vnic_intr_masked(struct vnic_intr *intr)
50{
51 return ioread32(&intr->ctrl->mask);
52}
53
54static inline void vnic_intr_return_credits(struct vnic_intr *intr,
55 unsigned int credits, int unmask, int reset_timer)
56{
57#define VNIC_INTR_UNMASK_SHIFT 16
58#define VNIC_INTR_RESET_TIMER_SHIFT 17
59
60 u32 int_credit_return = (credits & 0xffff) |
61 (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) |
62 (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0);
63
64 iowrite32(int_credit_return, &intr->ctrl->int_credit_return);
65}
66
67static inline unsigned int vnic_intr_credits(struct vnic_intr *intr)
68{
69 return ioread32(&intr->ctrl->int_credits);
70}
71
72static inline void vnic_intr_return_all_credits(struct vnic_intr *intr)
73{
74 unsigned int credits = vnic_intr_credits(intr);
75 int unmask = 1;
76 int reset_timer = 1;
77
78 vnic_intr_return_credits(intr, credits, unmask, reset_timer);
79}
80
81static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
82{
83 /* read PBA without clearing */
84 return ioread32(legacy_pba);
85}
86
87void vnic_intr_free(struct vnic_intr *intr);
88int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
89 unsigned int index);
90void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
91 unsigned int coalescing_type, unsigned int mask_on_assertion);
92void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
93 u32 coalescing_timer);
94void vnic_intr_clean(struct vnic_intr *intr);
95
96#endif /* _VNIC_INTR_H_ */