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