Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2008-2010 Cisco Systems, Inc.  All rights reserved.
0004  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
0005  */
0006 
0007 #ifndef _VNIC_INTR_H_
0008 #define _VNIC_INTR_H_
0009 
0010 #include <linux/pci.h>
0011 
0012 #include "vnic_dev.h"
0013 
0014 #define VNIC_INTR_TIMER_TYPE_ABS    0
0015 #define VNIC_INTR_TIMER_TYPE_QUIET  1
0016 
0017 /* Interrupt control */
0018 struct vnic_intr_ctrl {
0019     u32 coalescing_timer;       /* 0x00 */
0020     u32 pad0;
0021     u32 coalescing_value;       /* 0x08 */
0022     u32 pad1;
0023     u32 coalescing_type;        /* 0x10 */
0024     u32 pad2;
0025     u32 mask_on_assertion;      /* 0x18 */
0026     u32 pad3;
0027     u32 mask;           /* 0x20 */
0028     u32 pad4;
0029     u32 int_credits;        /* 0x28 */
0030     u32 pad5;
0031     u32 int_credit_return;      /* 0x30 */
0032     u32 pad6;
0033 };
0034 
0035 struct vnic_intr {
0036     unsigned int index;
0037     struct vnic_dev *vdev;
0038     struct vnic_intr_ctrl __iomem *ctrl;        /* memory-mapped */
0039 };
0040 
0041 static inline void vnic_intr_unmask(struct vnic_intr *intr)
0042 {
0043     iowrite32(0, &intr->ctrl->mask);
0044 }
0045 
0046 static inline void vnic_intr_mask(struct vnic_intr *intr)
0047 {
0048     iowrite32(1, &intr->ctrl->mask);
0049 }
0050 
0051 static inline int vnic_intr_masked(struct vnic_intr *intr)
0052 {
0053     return ioread32(&intr->ctrl->mask);
0054 }
0055 
0056 static inline void vnic_intr_return_credits(struct vnic_intr *intr,
0057     unsigned int credits, int unmask, int reset_timer)
0058 {
0059 #define VNIC_INTR_UNMASK_SHIFT      16
0060 #define VNIC_INTR_RESET_TIMER_SHIFT 17
0061 
0062     u32 int_credit_return = (credits & 0xffff) |
0063         (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) |
0064         (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0);
0065 
0066     iowrite32(int_credit_return, &intr->ctrl->int_credit_return);
0067 }
0068 
0069 static inline unsigned int vnic_intr_credits(struct vnic_intr *intr)
0070 {
0071     return ioread32(&intr->ctrl->int_credits);
0072 }
0073 
0074 static inline void vnic_intr_return_all_credits(struct vnic_intr *intr)
0075 {
0076     unsigned int credits = vnic_intr_credits(intr);
0077     int unmask = 1;
0078     int reset_timer = 1;
0079 
0080     vnic_intr_return_credits(intr, credits, unmask, reset_timer);
0081 }
0082 
0083 static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
0084 {
0085     /* read PBA without clearing */
0086     return ioread32(legacy_pba);
0087 }
0088 
0089 void vnic_intr_free(struct vnic_intr *intr);
0090 int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
0091     unsigned int index);
0092 void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
0093     unsigned int coalescing_type, unsigned int mask_on_assertion);
0094 void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
0095     u32 coalescing_timer);
0096 void vnic_intr_clean(struct vnic_intr *intr);
0097 
0098 #endif /* _VNIC_INTR_H_ */