Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
isci.h
Go to the documentation of this file.
1 /*
2  * This file is provided under a dual BSD/GPLv2 license. When using or
3  * redistributing this file, you may do so under either license.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of version 2 of the GNU General Public License as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21  * The full GNU General Public License is included in this distribution
22  * in the file called LICENSE.GPL.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
33  * * Redistributions of source code must retain the above copyright
34  * notice, this list of conditions and the following disclaimer.
35  * * Redistributions in binary form must reproduce the above copyright
36  * notice, this list of conditions and the following disclaimer in
37  * the documentation and/or other materials provided with the
38  * distribution.
39  * * Neither the name of Intel Corporation nor the names of its
40  * contributors may be used to endorse or promote products derived
41  * from this software without specific prior written permission.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54  */
55 
56 #ifndef __ISCI_H__
57 #define __ISCI_H__
58 
59 #include <linux/interrupt.h>
60 #include <linux/types.h>
61 
62 #define DRV_NAME "isci"
63 #define SCI_PCI_BAR_COUNT 2
64 #define SCI_NUM_MSI_X_INT 2
65 #define SCI_SMU_BAR 0
66 #define SCI_SMU_BAR_SIZE (16*1024)
67 #define SCI_SCU_BAR 1
68 #define SCI_SCU_BAR_SIZE (4*1024*1024)
69 #define SCI_IO_SPACE_BAR0 2
70 #define SCI_IO_SPACE_BAR1 3
71 #define ISCI_CAN_QUEUE_VAL 250 /* < SCI_MAX_IO_REQUESTS ? */
72 #define SCIC_CONTROLLER_STOP_TIMEOUT 5000
73 
74 #define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF
75 
76 #define SCI_MAX_PHYS (4UL)
77 #define SCI_MAX_PORTS SCI_MAX_PHYS
78 #define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
79 #define SCI_MAX_REMOTE_DEVICES (256UL)
80 #define SCI_MAX_IO_REQUESTS (256UL)
81 #define SCI_MAX_SEQ (16)
82 #define SCI_MAX_MSIX_MESSAGES (2)
83 #define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
84 #define SCI_MAX_CONTROLLERS 2
85 #define SCI_MAX_DOMAINS SCI_MAX_PORTS
86 
87 #define SCU_MAX_CRITICAL_NOTIFICATIONS (384)
88 #define SCU_MAX_EVENTS_SHIFT (7)
89 #define SCU_MAX_EVENTS (1 << SCU_MAX_EVENTS_SHIFT)
90 #define SCU_MAX_UNSOLICITED_FRAMES (128)
91 #define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128)
92 #define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \
93  + SCU_MAX_EVENTS \
94  + SCU_MAX_UNSOLICITED_FRAMES \
95  + SCI_MAX_IO_REQUESTS \
96  + SCU_MAX_COMPLETION_QUEUE_SCRATCH)
97 #define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES))
98 
99 #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
100 #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024U)
101 #define SCU_INVALID_FRAME_INDEX (0xFFFF)
102 
103 #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
104 #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF)
105 
106 static inline void check_sizes(void)
107 {
115 }
116 
128 
137 
145 
151 
158 
164 
169 
176 
182 
188 
194 
200 
206 
212 
219 
225 
231 
237 
243 
249 
255 
261 
267 
273 
279 
285 
291 
297 
305 
311 
317 
323 
329 
335 
341 
347 
353 
359 
364 
369 
377 
383 
389 
396 
397 };
398 
424 
426 
430 };
431 
451 
454 
455 };
456 
468 static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt)
469 {
470  u32 *dest = _dest, *src = _src;
471 
472  while (--word_cnt >= 0)
473  dest[word_cnt] = swab32(src[word_cnt]);
474 }
475 
476 extern unsigned char no_outbound_task_to;
477 extern u16 ssp_max_occ_to;
478 extern u16 stp_max_occ_to;
479 extern u16 ssp_inactive_to;
480 extern u16 stp_inactive_to;
481 extern unsigned char phy_gen;
482 extern unsigned char max_concurr_spinup;
484 
485 irqreturn_t isci_msix_isr(int vec, void *data);
486 irqreturn_t isci_intx_isr(int vec, void *data);
487 irqreturn_t isci_error_isr(int vec, void *data);
488 
489 /*
490  * Each timer is associated with a cancellation flag that is set when
491  * del_timer() is called and checked in the timer callback function. This
492  * is needed since del_timer_sync() cannot be called with sci_lock held.
493  * For deinit however, del_timer_sync() is used without holding the lock.
494  */
495 struct sci_timer {
497  bool cancel;
498 };
499 
500 static inline
501 void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long))
502 {
503  tmr->timer.function = fn;
504  tmr->timer.data = (unsigned long) tmr;
505  tmr->cancel = 0;
506  init_timer(&tmr->timer);
507 }
508 
509 static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec)
510 {
511  tmr->cancel = 0;
512  mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec));
513 }
514 
515 static inline void sci_del_timer(struct sci_timer *tmr)
516 {
517  tmr->cancel = 1;
518  del_timer(&tmr->timer);
519 }
520 
526 };
527 
529 
531  sci_state_transition_t enter_state; /* Called on state entry */
532  sci_state_transition_t exit_state; /* Called on state exit */
533 };
534 
535 extern void sci_init_sm(struct sci_base_state_machine *sm,
536  const struct sci_base_state *state_table,
537  u32 initial_state);
539 #endif /* __ISCI_H__ */