]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/drivers/net/enic/base/vnic_intr.h
13637385cd8f3fb1904c8e1cbf9e95492525021b
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / enic / base / vnic_intr.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
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 */
16 struct 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
33 struct vnic_intr {
34 unsigned int index;
35 struct vnic_dev *vdev;
36 struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */
37 };
38
39 static inline void vnic_intr_unmask(struct vnic_intr *intr)
40 {
41 iowrite32(0, &intr->ctrl->mask);
42 }
43
44 static inline void vnic_intr_mask(struct vnic_intr *intr)
45 {
46 iowrite32(1, &intr->ctrl->mask);
47 }
48
49 static inline int vnic_intr_masked(struct vnic_intr *intr)
50 {
51 return ioread32(&intr->ctrl->mask);
52 }
53
54 static 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
67 static inline unsigned int vnic_intr_credits(struct vnic_intr *intr)
68 {
69 return ioread32(&intr->ctrl->int_credits);
70 }
71
72 static 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
81 static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
82 {
83 /* read PBA without clearing */
84 return ioread32(legacy_pba);
85 }
86
87 void vnic_intr_free(struct vnic_intr *intr);
88 int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
89 unsigned int index);
90 void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
91 unsigned int coalescing_type, unsigned int mask_on_assertion);
92 void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
93 u32 coalescing_timer);
94 void vnic_intr_clean(struct vnic_intr *intr);
95
96 #endif /* _VNIC_INTR_H_ */