vnic_intr.c (1780B)
1/* 2 * Copyright 2014 Cisco Systems, Inc. All rights reserved. 3 * 4 * This program is free software; you may redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; version 2 of the License. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 15 * SOFTWARE. 16 */ 17 18#include <linux/kernel.h> 19#include <linux/errno.h> 20#include <linux/types.h> 21#include <linux/pci.h> 22#include <linux/delay.h> 23#include "vnic_dev.h" 24#include "vnic_intr.h" 25 26void svnic_intr_free(struct vnic_intr *intr) 27{ 28 intr->ctrl = NULL; 29} 30 31int svnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, 32 unsigned int index) 33{ 34 intr->index = index; 35 intr->vdev = vdev; 36 37 intr->ctrl = svnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index); 38 if (!intr->ctrl) { 39 pr_err("Failed to hook INTR[%d].ctrl resource\n", 40 index); 41 return -EINVAL; 42 } 43 44 return 0; 45} 46 47void svnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, 48 unsigned int coalescing_type, unsigned int mask_on_assertion) 49{ 50 iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer); 51 iowrite32(coalescing_type, &intr->ctrl->coalescing_type); 52 iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion); 53 iowrite32(0, &intr->ctrl->int_credits); 54} 55 56void svnic_intr_clean(struct vnic_intr *intr) 57{ 58 iowrite32(0, &intr->ctrl->int_credits); 59}