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 #include "vnic_dev.h" 7 #include "vnic_intr.h" 8 9 void vnic_intr_free(struct vnic_intr *intr) 10 { 11 intr->ctrl = NULL; 12 } 13 14 int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, 15 unsigned int index) 16 { 17 intr->index = index; 18 intr->vdev = vdev; 19 20 intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index); 21 if (!intr->ctrl) { 22 pr_err("Failed to hook INTR[%d].ctrl resource\n", index); 23 return -EINVAL; 24 } 25 26 return 0; 27 } 28 29 void vnic_intr_init(struct vnic_intr *intr, uint32_t coalescing_timer, 30 unsigned int coalescing_type, unsigned int mask_on_assertion) 31 { 32 vnic_intr_coalescing_timer_set(intr, coalescing_timer); 33 iowrite32(coalescing_type, &intr->ctrl->coalescing_type); 34 iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion); 35 iowrite32(0, &intr->ctrl->int_credits); 36 } 37 38 void vnic_intr_coalescing_timer_set(struct vnic_intr *intr, 39 uint32_t coalescing_timer) 40 { 41 iowrite32(vnic_dev_intr_coal_timer_usec_to_hw(intr->vdev, 42 coalescing_timer), &intr->ctrl->coalescing_timer); 43 } 44 45 void vnic_intr_clean(struct vnic_intr *intr) 46 { 47 iowrite32(0, &intr->ctrl->int_credits); 48 } 49