brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · 7bff60f Raw
92 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/* Copyright 2014 Cisco Systems, Inc.  All rights reserved. */3 4#ifndef _VNIC_INTR_H_5#define _VNIC_INTR_H_6 7#include <linux/pci.h>8#include "vnic_dev.h"9 10#define VNIC_INTR_TIMER_MAX		0xffff11 12#define VNIC_INTR_TIMER_TYPE_ABS	013#define VNIC_INTR_TIMER_TYPE_QUIET	114 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 void40svnic_intr_unmask(struct vnic_intr *intr)41{42	iowrite32(0, &intr->ctrl->mask);43}44 45static inline void46svnic_intr_mask(struct vnic_intr *intr)47{48	iowrite32(1, &intr->ctrl->mask);49}50 51static inline void52svnic_intr_return_credits(struct vnic_intr *intr,53			  unsigned int credits,54			  int unmask,55			  int reset_timer)56{57#define VNIC_INTR_UNMASK_SHIFT		1658#define VNIC_INTR_RESET_TIMER_SHIFT	1759 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 int68svnic_intr_credits(struct vnic_intr *intr)69{70	return ioread32(&intr->ctrl->int_credits);71}72 73static inline void74svnic_intr_return_all_credits(struct vnic_intr *intr)75{76	unsigned int credits = svnic_intr_credits(intr);77	int unmask = 1;78	int reset_timer = 1;79 80	svnic_intr_return_credits(intr, credits, unmask, reset_timer);81}82 83void svnic_intr_free(struct vnic_intr *);84int svnic_intr_alloc(struct vnic_dev *, struct vnic_intr *, unsigned int);85void svnic_intr_init(struct vnic_intr *intr,86		     unsigned int coalescing_timer,87		     unsigned int coalescing_type,88		     unsigned int mask_on_assertion);89void svnic_intr_clean(struct vnic_intr *);90 91#endif /* _VNIC_INTR_H_ */92