Branch data Line data Source code
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 : : 26 : 0 : void svnic_intr_free(struct vnic_intr *intr) 27 : : { 28 : 0 : intr->ctrl = NULL; 29 : 0 : } 30 : : 31 : 0 : int svnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, 32 : : unsigned int index) 33 : : { 34 : 0 : intr->index = index; 35 : 0 : intr->vdev = vdev; 36 : : 37 : 0 : intr->ctrl = svnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index); 38 [ # # ]: 0 : if (!intr->ctrl) { 39 : 0 : pr_err("Failed to hook INTR[%d].ctrl resource\n", 40 : : index); 41 : 0 : return -EINVAL; 42 : : } 43 : : 44 : : return 0; 45 : : } 46 : : 47 : 0 : void svnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, 48 : : unsigned int coalescing_type, unsigned int mask_on_assertion) 49 : : { 50 : 0 : iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer); 51 : 0 : iowrite32(coalescing_type, &intr->ctrl->coalescing_type); 52 : 0 : iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion); 53 : 0 : iowrite32(0, &intr->ctrl->int_credits); 54 : 0 : } 55 : : 56 : 0 : void svnic_intr_clean(struct vnic_intr *intr) 57 : : { 58 : 0 : iowrite32(0, &intr->ctrl->int_credits); 59 : 0 : }