2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2013 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Intel MIC Host driver.
25 * The minimum number of msix vectors required for normal operation.
26 * 3 for virtio network, console and block devices.
27 * 1 for card shutdown notifications.
29 #define MIC_MIN_MSIX 4
30 #define MIC_NUM_OFFSETS 32
33 * mic_intr_source - The type of source that will generate
34 * the interrupt.The number of types needs to be in sync with
37 * MIC_INTR_DB: The source is a doorbell
38 * MIC_INTR_DMA: The source is a DMA channel
39 * MIC_INTR_ERR: The source is an error interrupt e.g. SBOX ERR
40 * MIC_NUM_INTR_TYPES: Total number of interrupt sources.
50 * struct mic_intr_info - Contains h/w specific interrupt sources
53 * @intr_start_idx: Contains the starting indexes of the
55 * @intr_len: Contains the length of the interrupt types.
57 struct mic_intr_info
{
58 u16 intr_start_idx
[MIC_NUM_INTR_TYPES
];
59 u16 intr_len
[MIC_NUM_INTR_TYPES
];
63 * struct mic_irq_info - OS specific irq information
65 * @next_avail_src: next available doorbell that can be assigned.
66 * @msix_entries: msix entries allocated while setting up MSI-x
67 * @mic_msi_map: The MSI/MSI-x mapping information.
68 * @num_vectors: The number of MSI/MSI-x vectors that have been allocated.
69 * @cb_ida: callback ID allocator to track the callbacks registered.
70 * @mic_intr_lock: spinlock to protect the interrupt callback list.
71 * @cb_list: Array of callback lists one for each source.
75 struct msix_entry
*msix_entries
;
79 spinlock_t mic_intr_lock
;
80 struct list_head
*cb_list
;
84 * struct mic_intr_cb - Interrupt callback structure.
86 * @func: The callback function
87 * @data: Private data of the requester.
88 * @cb_id: The callback id. Identifies this callback.
89 * @list: list head pointing to the next callback structure.
92 irqreturn_t (*func
) (int irq
, void *data
);
95 struct list_head list
;
99 * struct mic_irq - opaque pointer used as cookie
103 /* Forward declaration */
107 * struct mic_hw_intr_ops: MIC HW specific interrupt operations
108 * @intr_init: Initialize H/W specific interrupt information.
109 * @enable_interrupts: Enable interrupts from the hardware.
110 * @disable_interrupts: Disable interrupts from the hardware.
111 * @program_msi_to_src_map: Update MSI mapping registers with
113 * @read_msi_to_src_map: Read MSI mapping registers containing
116 struct mic_hw_intr_ops
{
117 void (*intr_init
)(struct mic_device
*mdev
);
118 void (*enable_interrupts
)(struct mic_device
*mdev
);
119 void (*disable_interrupts
)(struct mic_device
*mdev
);
120 void (*program_msi_to_src_map
) (struct mic_device
*mdev
,
121 int idx
, int intr_src
, bool set
);
122 u32 (*read_msi_to_src_map
) (struct mic_device
*mdev
,
126 int mic_next_db(struct mic_device
*mdev
);
127 struct mic_irq
*mic_request_irq(struct mic_device
*mdev
,
128 irqreturn_t (*func
)(int irq
, void *data
),
129 const char *name
, void *data
, int intr_src
,
130 enum mic_intr_type type
);
132 void mic_free_irq(struct mic_device
*mdev
,
133 struct mic_irq
*cookie
, void *data
);
134 int mic_setup_interrupts(struct mic_device
*mdev
, struct pci_dev
*pdev
);
135 void mic_free_interrupts(struct mic_device
*mdev
, struct pci_dev
*pdev
);
136 void mic_intr_restore(struct mic_device
*mdev
);