diff options
63 files changed, 996 insertions, 492 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index b29f0280d712..8c4be1f301cf 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -601,6 +601,7 @@ config CAVIUM_OCTEON_SIMULATOR | |||
601 | select SYS_SUPPORTS_64BIT_KERNEL | 601 | select SYS_SUPPORTS_64BIT_KERNEL |
602 | select SYS_SUPPORTS_BIG_ENDIAN | 602 | select SYS_SUPPORTS_BIG_ENDIAN |
603 | select SYS_SUPPORTS_HIGHMEM | 603 | select SYS_SUPPORTS_HIGHMEM |
604 | select SYS_SUPPORTS_HOTPLUG_CPU | ||
604 | select SYS_HAS_CPU_CAVIUM_OCTEON | 605 | select SYS_HAS_CPU_CAVIUM_OCTEON |
605 | help | 606 | help |
606 | The Octeon simulator is software performance model of the Cavium | 607 | The Octeon simulator is software performance model of the Cavium |
@@ -615,6 +616,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD | |||
615 | select SYS_SUPPORTS_64BIT_KERNEL | 616 | select SYS_SUPPORTS_64BIT_KERNEL |
616 | select SYS_SUPPORTS_BIG_ENDIAN | 617 | select SYS_SUPPORTS_BIG_ENDIAN |
617 | select SYS_SUPPORTS_HIGHMEM | 618 | select SYS_SUPPORTS_HIGHMEM |
619 | select SYS_SUPPORTS_HOTPLUG_CPU | ||
618 | select SYS_HAS_EARLY_PRINTK | 620 | select SYS_HAS_EARLY_PRINTK |
619 | select SYS_HAS_CPU_CAVIUM_OCTEON | 621 | select SYS_HAS_CPU_CAVIUM_OCTEON |
620 | select SWAP_IO_SPACE | 622 | select SWAP_IO_SPACE |
@@ -784,8 +786,17 @@ config SYS_HAS_EARLY_PRINTK | |||
784 | bool | 786 | bool |
785 | 787 | ||
786 | config HOTPLUG_CPU | 788 | config HOTPLUG_CPU |
789 | bool "Support for hot-pluggable CPUs" | ||
790 | depends on SMP && HOTPLUG && SYS_SUPPORTS_HOTPLUG_CPU | ||
791 | help | ||
792 | Say Y here to allow turning CPUs off and on. CPUs can be | ||
793 | controlled through /sys/devices/system/cpu. | ||
794 | (Note: power management support will enable this option | ||
795 | automatically on SMP systems. ) | ||
796 | Say N if you want to disable CPU hotplug. | ||
797 | |||
798 | config SYS_SUPPORTS_HOTPLUG_CPU | ||
787 | bool | 799 | bool |
788 | default n | ||
789 | 800 | ||
790 | config I8259 | 801 | config I8259 |
791 | bool | 802 | bool |
@@ -2136,11 +2147,11 @@ menu "Power management options" | |||
2136 | 2147 | ||
2137 | config ARCH_HIBERNATION_POSSIBLE | 2148 | config ARCH_HIBERNATION_POSSIBLE |
2138 | def_bool y | 2149 | def_bool y |
2139 | depends on !SMP | 2150 | depends on SYS_SUPPORTS_HOTPLUG_CPU |
2140 | 2151 | ||
2141 | config ARCH_SUSPEND_POSSIBLE | 2152 | config ARCH_SUSPEND_POSSIBLE |
2142 | def_bool y | 2153 | def_bool y |
2143 | depends on !SMP | 2154 | depends on SYS_SUPPORTS_HOTPLUG_CPU |
2144 | 2155 | ||
2145 | source "kernel/power/Kconfig" | 2156 | source "kernel/power/Kconfig" |
2146 | 2157 | ||
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c index 8dfa009e0070..384f1842bfb1 100644 --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/irq.h> | 8 | #include <linux/irq.h> |
9 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
10 | #include <linux/hardirq.h> | 10 | #include <linux/smp.h> |
11 | 11 | ||
12 | #include <asm/octeon/octeon.h> | 12 | #include <asm/octeon/octeon.h> |
13 | #include <asm/octeon/cvmx-pexp-defs.h> | 13 | #include <asm/octeon/cvmx-pexp-defs.h> |
@@ -501,3 +501,62 @@ asmlinkage void plat_irq_dispatch(void) | |||
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | |||
505 | #ifdef CONFIG_HOTPLUG_CPU | ||
506 | static int is_irq_enabled_on_cpu(unsigned int irq, unsigned int cpu) | ||
507 | { | ||
508 | unsigned int isset; | ||
509 | #ifdef CONFIG_SMP | ||
510 | int coreid = cpu_logical_map(cpu); | ||
511 | #else | ||
512 | int coreid = cvmx_get_core_num(); | ||
513 | #endif | ||
514 | int bit = (irq < OCTEON_IRQ_WDOG0) ? | ||
515 | irq - OCTEON_IRQ_WORKQ0 : irq - OCTEON_IRQ_WDOG0; | ||
516 | if (irq < 64) { | ||
517 | isset = (cvmx_read_csr(CVMX_CIU_INTX_EN0(coreid * 2)) & | ||
518 | (1ull << bit)) >> bit; | ||
519 | } else { | ||
520 | isset = (cvmx_read_csr(CVMX_CIU_INTX_EN1(coreid * 2 + 1)) & | ||
521 | (1ull << bit)) >> bit; | ||
522 | } | ||
523 | return isset; | ||
524 | } | ||
525 | |||
526 | void fixup_irqs(void) | ||
527 | { | ||
528 | int irq; | ||
529 | |||
530 | for (irq = OCTEON_IRQ_SW0; irq <= OCTEON_IRQ_TIMER; irq++) | ||
531 | octeon_irq_core_disable_local(irq); | ||
532 | |||
533 | for (irq = OCTEON_IRQ_WORKQ0; irq <= OCTEON_IRQ_GPIO15; irq++) { | ||
534 | if (is_irq_enabled_on_cpu(irq, smp_processor_id())) { | ||
535 | /* ciu irq migrates to next cpu */ | ||
536 | octeon_irq_chip_ciu0.disable(irq); | ||
537 | octeon_irq_ciu0_set_affinity(irq, &cpu_online_map); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | #if 0 | ||
542 | for (irq = OCTEON_IRQ_MBOX0; irq <= OCTEON_IRQ_MBOX1; irq++) | ||
543 | octeon_irq_mailbox_mask(irq); | ||
544 | #endif | ||
545 | for (irq = OCTEON_IRQ_UART0; irq <= OCTEON_IRQ_BOOTDMA; irq++) { | ||
546 | if (is_irq_enabled_on_cpu(irq, smp_processor_id())) { | ||
547 | /* ciu irq migrates to next cpu */ | ||
548 | octeon_irq_chip_ciu0.disable(irq); | ||
549 | octeon_irq_ciu0_set_affinity(irq, &cpu_online_map); | ||
550 | } | ||
551 | } | ||
552 | |||
553 | for (irq = OCTEON_IRQ_UART2; irq <= OCTEON_IRQ_RESERVED135; irq++) { | ||
554 | if (is_irq_enabled_on_cpu(irq, smp_processor_id())) { | ||
555 | /* ciu irq migrates to next cpu */ | ||
556 | octeon_irq_chip_ciu1.disable(irq); | ||
557 | octeon_irq_ciu1_set_affinity(irq, &cpu_online_map); | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | |||
562 | #endif /* CONFIG_HOTPLUG_CPU */ | ||
diff --git a/arch/mips/cavium-octeon/octeon_boot.h b/arch/mips/cavium-octeon/octeon_boot.h new file mode 100644 index 000000000000..0f7f84accf9a --- /dev/null +++ b/arch/mips/cavium-octeon/octeon_boot.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * (C) Copyright 2004, 2005 Cavium Networks | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 of | ||
7 | * the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
17 | * MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #ifndef __OCTEON_BOOT_H__ | ||
21 | #define __OCTEON_BOOT_H__ | ||
22 | |||
23 | #include <linux/types.h> | ||
24 | |||
25 | struct boot_init_vector { | ||
26 | uint32_t stack_addr; | ||
27 | uint32_t code_addr; | ||
28 | uint32_t app_start_func_addr; | ||
29 | uint32_t k0_val; | ||
30 | uint32_t flags; | ||
31 | uint32_t boot_info_addr; | ||
32 | uint32_t pad; | ||
33 | uint32_t pad2; | ||
34 | }; | ||
35 | |||
36 | /* similar to bootloader's linux_app_boot_info but without global data */ | ||
37 | struct linux_app_boot_info { | ||
38 | uint32_t labi_signature; | ||
39 | uint32_t start_core0_addr; | ||
40 | uint32_t avail_coremask; | ||
41 | uint32_t pci_console_active; | ||
42 | uint32_t icache_prefetch_disable; | ||
43 | uint32_t InitTLBStart_addr; | ||
44 | uint32_t start_app_addr; | ||
45 | uint32_t cur_exception_base; | ||
46 | uint32_t no_mark_private_data; | ||
47 | uint32_t compact_flash_common_base_addr; | ||
48 | uint32_t compact_flash_attribute_base_addr; | ||
49 | uint32_t led_display_base_addr; | ||
50 | }; | ||
51 | |||
52 | /* If not to copy a lot of bootloader's structures | ||
53 | here is only offset of requested member */ | ||
54 | #define AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK 0x765c | ||
55 | |||
56 | /* hardcoded in bootloader */ | ||
57 | #define LABI_ADDR_IN_BOOTLOADER 0x700 | ||
58 | |||
59 | #define LINUX_APP_BOOT_BLOCK_NAME "linux-app-boot" | ||
60 | |||
61 | #define LABI_SIGNATURE 0xAABBCCDD | ||
62 | |||
63 | /* from uboot-headers/octeon_mem_map.h */ | ||
64 | #define EXCEPTION_BASE_INCR (4 * 1024) | ||
65 | /* Increment size for exception base addresses (4k minimum) */ | ||
66 | #define EXCEPTION_BASE_BASE 0 | ||
67 | #define BOOTLOADER_PRIV_DATA_BASE (EXCEPTION_BASE_BASE + 0x800) | ||
68 | #define BOOTLOADER_BOOT_VECTOR (BOOTLOADER_PRIV_DATA_BASE) | ||
69 | |||
70 | #endif /* __OCTEON_BOOT_H__ */ | ||
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c index 5f4e49ba4713..da559249cc2f 100644 --- a/arch/mips/cavium-octeon/setup.c +++ b/arch/mips/cavium-octeon/setup.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/irq.h> | 14 | #include <linux/irq.h> |
15 | #include <linux/serial.h> | 15 | #include <linux/serial.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/types.h> | 17 | #include <linux/types.h> |
17 | #include <linux/string.h> /* for memset */ | 18 | #include <linux/string.h> /* for memset */ |
18 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c index 24e0ad63980a..0b891a9c6253 100644 --- a/arch/mips/cavium-octeon/smp.c +++ b/arch/mips/cavium-octeon/smp.c | |||
@@ -5,6 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2004-2008 Cavium Networks | 6 | * Copyright (C) 2004-2008 Cavium Networks |
7 | */ | 7 | */ |
8 | #include <linux/cpu.h> | ||
8 | #include <linux/init.h> | 9 | #include <linux/init.h> |
9 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
10 | #include <linux/smp.h> | 11 | #include <linux/smp.h> |
@@ -19,10 +20,16 @@ | |||
19 | 20 | ||
20 | #include <asm/octeon/octeon.h> | 21 | #include <asm/octeon/octeon.h> |
21 | 22 | ||
23 | #include "octeon_boot.h" | ||
24 | |||
22 | volatile unsigned long octeon_processor_boot = 0xff; | 25 | volatile unsigned long octeon_processor_boot = 0xff; |
23 | volatile unsigned long octeon_processor_sp; | 26 | volatile unsigned long octeon_processor_sp; |
24 | volatile unsigned long octeon_processor_gp; | 27 | volatile unsigned long octeon_processor_gp; |
25 | 28 | ||
29 | #ifdef CONFIG_HOTPLUG_CPU | ||
30 | static unsigned int InitTLBStart_addr; | ||
31 | #endif | ||
32 | |||
26 | static irqreturn_t mailbox_interrupt(int irq, void *dev_id) | 33 | static irqreturn_t mailbox_interrupt(int irq, void *dev_id) |
27 | { | 34 | { |
28 | const int coreid = cvmx_get_core_num(); | 35 | const int coreid = cvmx_get_core_num(); |
@@ -67,8 +74,28 @@ static inline void octeon_send_ipi_mask(cpumask_t mask, unsigned int action) | |||
67 | } | 74 | } |
68 | 75 | ||
69 | /** | 76 | /** |
70 | * Detect available CPUs, populate phys_cpu_present_map | 77 | * Detect available CPUs, populate cpu_possible_map |
71 | */ | 78 | */ |
79 | static void octeon_smp_hotplug_setup(void) | ||
80 | { | ||
81 | #ifdef CONFIG_HOTPLUG_CPU | ||
82 | uint32_t labi_signature; | ||
83 | |||
84 | labi_signature = | ||
85 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
86 | LABI_ADDR_IN_BOOTLOADER + | ||
87 | offsetof(struct linux_app_boot_info, | ||
88 | labi_signature))); | ||
89 | if (labi_signature != LABI_SIGNATURE) | ||
90 | pr_err("The bootloader version on this board is incorrect\n"); | ||
91 | InitTLBStart_addr = | ||
92 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
93 | LABI_ADDR_IN_BOOTLOADER + | ||
94 | offsetof(struct linux_app_boot_info, | ||
95 | InitTLBStart_addr))); | ||
96 | #endif | ||
97 | } | ||
98 | |||
72 | static void octeon_smp_setup(void) | 99 | static void octeon_smp_setup(void) |
73 | { | 100 | { |
74 | const int coreid = cvmx_get_core_num(); | 101 | const int coreid = cvmx_get_core_num(); |
@@ -91,6 +118,9 @@ static void octeon_smp_setup(void) | |||
91 | cpus++; | 118 | cpus++; |
92 | } | 119 | } |
93 | } | 120 | } |
121 | cpu_present_map = cpu_possible_map; | ||
122 | |||
123 | octeon_smp_hotplug_setup(); | ||
94 | } | 124 | } |
95 | 125 | ||
96 | /** | 126 | /** |
@@ -128,6 +158,17 @@ static void octeon_init_secondary(void) | |||
128 | const int coreid = cvmx_get_core_num(); | 158 | const int coreid = cvmx_get_core_num(); |
129 | union cvmx_ciu_intx_sum0 interrupt_enable; | 159 | union cvmx_ciu_intx_sum0 interrupt_enable; |
130 | 160 | ||
161 | #ifdef CONFIG_HOTPLUG_CPU | ||
162 | unsigned int cur_exception_base; | ||
163 | |||
164 | cur_exception_base = cvmx_read64_uint32( | ||
165 | CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
166 | LABI_ADDR_IN_BOOTLOADER + | ||
167 | offsetof(struct linux_app_boot_info, | ||
168 | cur_exception_base))); | ||
169 | /* cur_exception_base is incremented in bootloader after setting */ | ||
170 | write_c0_ebase((unsigned int)(cur_exception_base - EXCEPTION_BASE_INCR)); | ||
171 | #endif | ||
131 | octeon_check_cpu_bist(); | 172 | octeon_check_cpu_bist(); |
132 | octeon_init_cvmcount(); | 173 | octeon_init_cvmcount(); |
133 | /* | 174 | /* |
@@ -199,6 +240,193 @@ static void octeon_cpus_done(void) | |||
199 | #endif | 240 | #endif |
200 | } | 241 | } |
201 | 242 | ||
243 | #ifdef CONFIG_HOTPLUG_CPU | ||
244 | |||
245 | /* State of each CPU. */ | ||
246 | DEFINE_PER_CPU(int, cpu_state); | ||
247 | |||
248 | extern void fixup_irqs(void); | ||
249 | |||
250 | static DEFINE_SPINLOCK(smp_reserve_lock); | ||
251 | |||
252 | static int octeon_cpu_disable(void) | ||
253 | { | ||
254 | unsigned int cpu = smp_processor_id(); | ||
255 | |||
256 | if (cpu == 0) | ||
257 | return -EBUSY; | ||
258 | |||
259 | spin_lock(&smp_reserve_lock); | ||
260 | |||
261 | cpu_clear(cpu, cpu_online_map); | ||
262 | cpu_clear(cpu, cpu_callin_map); | ||
263 | local_irq_disable(); | ||
264 | fixup_irqs(); | ||
265 | local_irq_enable(); | ||
266 | |||
267 | flush_cache_all(); | ||
268 | local_flush_tlb_all(); | ||
269 | |||
270 | spin_unlock(&smp_reserve_lock); | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | static void octeon_cpu_die(unsigned int cpu) | ||
276 | { | ||
277 | int coreid = cpu_logical_map(cpu); | ||
278 | uint32_t avail_coremask; | ||
279 | struct cvmx_bootmem_named_block_desc *block_desc; | ||
280 | |||
281 | #ifdef CONFIG_CAVIUM_OCTEON_WATCHDOG | ||
282 | /* Disable the watchdog */ | ||
283 | cvmx_ciu_wdogx_t ciu_wdog; | ||
284 | ciu_wdog.u64 = cvmx_read_csr(CVMX_CIU_WDOGX(cpu)); | ||
285 | ciu_wdog.s.mode = 0; | ||
286 | cvmx_write_csr(CVMX_CIU_WDOGX(cpu), ciu_wdog.u64); | ||
287 | #endif | ||
288 | |||
289 | while (per_cpu(cpu_state, cpu) != CPU_DEAD) | ||
290 | cpu_relax(); | ||
291 | |||
292 | /* | ||
293 | * This is a bit complicated strategics of getting/settig available | ||
294 | * cores mask, copied from bootloader | ||
295 | */ | ||
296 | /* LINUX_APP_BOOT_BLOCK is initialized in bootoct binary */ | ||
297 | block_desc = cvmx_bootmem_find_named_block(LINUX_APP_BOOT_BLOCK_NAME); | ||
298 | |||
299 | if (!block_desc) { | ||
300 | avail_coremask = | ||
301 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
302 | LABI_ADDR_IN_BOOTLOADER + | ||
303 | offsetof | ||
304 | (struct linux_app_boot_info, | ||
305 | avail_coremask))); | ||
306 | } else { /* alternative, already initialized */ | ||
307 | avail_coremask = | ||
308 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
309 | block_desc->base_addr + | ||
310 | AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK)); | ||
311 | } | ||
312 | |||
313 | avail_coremask |= 1 << coreid; | ||
314 | |||
315 | /* Setting avail_coremask for bootoct binary */ | ||
316 | if (!block_desc) { | ||
317 | cvmx_write64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
318 | LABI_ADDR_IN_BOOTLOADER + | ||
319 | offsetof(struct linux_app_boot_info, | ||
320 | avail_coremask)), | ||
321 | avail_coremask); | ||
322 | } else { | ||
323 | cvmx_write64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
324 | block_desc->base_addr + | ||
325 | AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK), | ||
326 | avail_coremask); | ||
327 | } | ||
328 | |||
329 | pr_info("Reset core %d. Available Coremask = %x \n", coreid, | ||
330 | avail_coremask); | ||
331 | cvmx_write_csr(CVMX_CIU_PP_RST, 1 << coreid); | ||
332 | cvmx_write_csr(CVMX_CIU_PP_RST, 0); | ||
333 | } | ||
334 | |||
335 | void play_dead(void) | ||
336 | { | ||
337 | int coreid = cvmx_get_core_num(); | ||
338 | |||
339 | idle_task_exit(); | ||
340 | octeon_processor_boot = 0xff; | ||
341 | per_cpu(cpu_state, coreid) = CPU_DEAD; | ||
342 | |||
343 | while (1) /* core will be reset here */ | ||
344 | ; | ||
345 | } | ||
346 | |||
347 | extern void kernel_entry(unsigned long arg1, ...); | ||
348 | |||
349 | static void start_after_reset(void) | ||
350 | { | ||
351 | kernel_entry(0, 0, 0); /* set a2 = 0 for secondary core */ | ||
352 | } | ||
353 | |||
354 | int octeon_update_boot_vector(unsigned int cpu) | ||
355 | { | ||
356 | |||
357 | int coreid = cpu_logical_map(cpu); | ||
358 | unsigned int avail_coremask; | ||
359 | struct cvmx_bootmem_named_block_desc *block_desc; | ||
360 | struct boot_init_vector *boot_vect = | ||
361 | (struct boot_init_vector *) cvmx_phys_to_ptr(0x0 + | ||
362 | BOOTLOADER_BOOT_VECTOR); | ||
363 | |||
364 | block_desc = cvmx_bootmem_find_named_block(LINUX_APP_BOOT_BLOCK_NAME); | ||
365 | |||
366 | if (!block_desc) { | ||
367 | avail_coremask = | ||
368 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
369 | LABI_ADDR_IN_BOOTLOADER + | ||
370 | offsetof(struct linux_app_boot_info, | ||
371 | avail_coremask))); | ||
372 | } else { /* alternative, already initialized */ | ||
373 | avail_coremask = | ||
374 | cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, | ||
375 | block_desc->base_addr + | ||
376 | AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK)); | ||
377 | } | ||
378 | |||
379 | if (!(avail_coremask & (1 << coreid))) { | ||
380 | /* core not available, assume, that catched by simple-executive */ | ||
381 | cvmx_write_csr(CVMX_CIU_PP_RST, 1 << coreid); | ||
382 | cvmx_write_csr(CVMX_CIU_PP_RST, 0); | ||
383 | } | ||
384 | |||
385 | boot_vect[coreid].app_start_func_addr = | ||
386 | (uint32_t) (unsigned long) start_after_reset; | ||
387 | boot_vect[coreid].code_addr = InitTLBStart_addr; | ||
388 | |||
389 | CVMX_SYNC; | ||
390 | |||
391 | cvmx_write_csr(CVMX_CIU_NMI, (1 << coreid) & avail_coremask); | ||
392 | |||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb, | ||
397 | unsigned long action, void *hcpu) | ||
398 | { | ||
399 | unsigned int cpu = (unsigned long)hcpu; | ||
400 | |||
401 | switch (action) { | ||
402 | case CPU_UP_PREPARE: | ||
403 | octeon_update_boot_vector(cpu); | ||
404 | break; | ||
405 | case CPU_ONLINE: | ||
406 | pr_info("Cpu %d online\n", cpu); | ||
407 | break; | ||
408 | case CPU_DEAD: | ||
409 | break; | ||
410 | } | ||
411 | |||
412 | return NOTIFY_OK; | ||
413 | } | ||
414 | |||
415 | static struct notifier_block __cpuinitdata octeon_cpu_notifier = { | ||
416 | .notifier_call = octeon_cpu_callback, | ||
417 | }; | ||
418 | |||
419 | static int __cpuinit register_cavium_notifier(void) | ||
420 | { | ||
421 | register_hotcpu_notifier(&octeon_cpu_notifier); | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | late_initcall(register_cavium_notifier); | ||
427 | |||
428 | #endif /* CONFIG_HOTPLUG_CPU */ | ||
429 | |||
202 | struct plat_smp_ops octeon_smp_ops = { | 430 | struct plat_smp_ops octeon_smp_ops = { |
203 | .send_ipi_single = octeon_send_ipi_single, | 431 | .send_ipi_single = octeon_send_ipi_single, |
204 | .send_ipi_mask = octeon_send_ipi_mask, | 432 | .send_ipi_mask = octeon_send_ipi_mask, |
@@ -208,4 +436,8 @@ struct plat_smp_ops octeon_smp_ops = { | |||
208 | .boot_secondary = octeon_boot_secondary, | 436 | .boot_secondary = octeon_boot_secondary, |
209 | .smp_setup = octeon_smp_setup, | 437 | .smp_setup = octeon_smp_setup, |
210 | .prepare_cpus = octeon_prepare_cpus, | 438 | .prepare_cpus = octeon_prepare_cpus, |
439 | #ifdef CONFIG_HOTPLUG_CPU | ||
440 | .cpu_disable = octeon_cpu_disable, | ||
441 | .cpu_die = octeon_cpu_die, | ||
442 | #endif | ||
211 | }; | 443 | }; |
diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h index 08ea46863fe5..6cf29c26e873 100644 --- a/arch/mips/include/asm/bug.h +++ b/arch/mips/include/asm/bug.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __ASM_BUG_H | 1 | #ifndef __ASM_BUG_H |
2 | #define __ASM_BUG_H | 2 | #define __ASM_BUG_H |
3 | 3 | ||
4 | #include <linux/compiler.h> | ||
4 | #include <asm/sgidefs.h> | 5 | #include <asm/sgidefs.h> |
5 | 6 | ||
6 | #ifdef CONFIG_BUG | 7 | #ifdef CONFIG_BUG |
diff --git a/arch/mips/include/asm/bugs.h b/arch/mips/include/asm/bugs.h index 9dc10df32078..b160a706795d 100644 --- a/arch/mips/include/asm/bugs.h +++ b/arch/mips/include/asm/bugs.h | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/bug.h> | 12 | #include <linux/bug.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/smp.h> | ||
14 | 15 | ||
15 | #include <asm/cpu.h> | 16 | #include <asm/cpu.h> |
16 | #include <asm/cpu-info.h> | 17 | #include <asm/cpu-info.h> |
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h index 4f1eed107b08..09b08d05ff72 100644 --- a/arch/mips/include/asm/irq.h +++ b/arch/mips/include/asm/irq.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define _ASM_IRQ_H | 10 | #define _ASM_IRQ_H |
11 | 11 | ||
12 | #include <linux/linkage.h> | 12 | #include <linux/linkage.h> |
13 | #include <linux/smp.h> | ||
13 | 14 | ||
14 | #include <asm/mipsmtregs.h> | 15 | #include <asm/mipsmtregs.h> |
15 | 16 | ||
diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index d7f3eb03ad12..d3bea88d8744 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
17 | #include <asm/cacheflush.h> | 18 | #include <asm/cacheflush.h> |
18 | #include <asm/tlbflush.h> | 19 | #include <asm/tlbflush.h> |
diff --git a/arch/mips/include/asm/smp-ops.h b/arch/mips/include/asm/smp-ops.h index 64ffc0290b84..fd545547b8aa 100644 --- a/arch/mips/include/asm/smp-ops.h +++ b/arch/mips/include/asm/smp-ops.h | |||
@@ -26,6 +26,10 @@ struct plat_smp_ops { | |||
26 | void (*boot_secondary)(int cpu, struct task_struct *idle); | 26 | void (*boot_secondary)(int cpu, struct task_struct *idle); |
27 | void (*smp_setup)(void); | 27 | void (*smp_setup)(void); |
28 | void (*prepare_cpus)(unsigned int max_cpus); | 28 | void (*prepare_cpus)(unsigned int max_cpus); |
29 | #ifdef CONFIG_HOTPLUG_CPU | ||
30 | int (*cpu_disable)(void); | ||
31 | void (*cpu_die)(unsigned int cpu); | ||
32 | #endif | ||
29 | }; | 33 | }; |
30 | 34 | ||
31 | extern void register_smp_ops(struct plat_smp_ops *ops); | 35 | extern void register_smp_ops(struct plat_smp_ops *ops); |
diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 40e5ef1d4d26..aaa2d4ab26dc 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/bitops.h> | 14 | #include <linux/bitops.h> |
15 | #include <linux/linkage.h> | 15 | #include <linux/linkage.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/threads.h> | 17 | #include <linux/threads.h> |
17 | #include <linux/cpumask.h> | 18 | #include <linux/cpumask.h> |
18 | 19 | ||
@@ -40,6 +41,7 @@ extern int __cpu_logical_map[NR_CPUS]; | |||
40 | /* Octeon - Tell another core to flush its icache */ | 41 | /* Octeon - Tell another core to flush its icache */ |
41 | #define SMP_ICACHE_FLUSH 0x4 | 42 | #define SMP_ICACHE_FLUSH 0x4 |
42 | 43 | ||
44 | extern volatile cpumask_t cpu_callin_map; | ||
43 | 45 | ||
44 | extern void asmlinkage smp_bootstrap(void); | 46 | extern void asmlinkage smp_bootstrap(void); |
45 | 47 | ||
@@ -55,6 +57,24 @@ static inline void smp_send_reschedule(int cpu) | |||
55 | mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF); | 57 | mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF); |
56 | } | 58 | } |
57 | 59 | ||
60 | #ifdef CONFIG_HOTPLUG_CPU | ||
61 | static inline int __cpu_disable(void) | ||
62 | { | ||
63 | extern struct plat_smp_ops *mp_ops; /* private */ | ||
64 | |||
65 | return mp_ops->cpu_disable(); | ||
66 | } | ||
67 | |||
68 | static inline void __cpu_die(unsigned int cpu) | ||
69 | { | ||
70 | extern struct plat_smp_ops *mp_ops; /* private */ | ||
71 | |||
72 | mp_ops->cpu_die(cpu); | ||
73 | } | ||
74 | |||
75 | extern void play_dead(void); | ||
76 | #endif | ||
77 | |||
58 | extern asmlinkage void smp_call_function_interrupt(void); | 78 | extern asmlinkage void smp_call_function_interrupt(void); |
59 | 79 | ||
60 | extern void arch_send_call_function_single_ipi(int cpu); | 80 | extern void arch_send_call_function_single_ipi(int cpu); |
diff --git a/arch/mips/include/asm/sn/addrs.h b/arch/mips/include/asm/sn/addrs.h index 3a56d90abfa6..2367b56dcdef 100644 --- a/arch/mips/include/asm/sn/addrs.h +++ b/arch/mips/include/asm/sn/addrs.h | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | #ifndef __ASSEMBLY__ | 13 | #ifndef __ASSEMBLY__ |
14 | #include <linux/smp.h> | ||
14 | #include <linux/types.h> | 15 | #include <linux/types.h> |
15 | #endif /* !__ASSEMBLY__ */ | 16 | #endif /* !__ASSEMBLY__ */ |
16 | 17 | ||
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c index d9b6a5b5399d..7fd170d007e7 100644 --- a/arch/mips/jazz/irq.c +++ b/arch/mips/jazz/irq.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/smp.h> | ||
13 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
14 | 15 | ||
15 | #include <asm/irq_cpu.h> | 16 | #include <asm/irq_cpu.h> |
diff --git a/arch/mips/kernel/cevt-bcm1480.c b/arch/mips/kernel/cevt-bcm1480.c index a5182a207696..e02f79b1eb51 100644 --- a/arch/mips/kernel/cevt-bcm1480.c +++ b/arch/mips/kernel/cevt-bcm1480.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/clockchips.h> | 18 | #include <linux/clockchips.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/percpu.h> | 20 | #include <linux/percpu.h> |
21 | #include <linux/smp.h> | ||
21 | 22 | ||
22 | #include <asm/addrspace.h> | 23 | #include <asm/addrspace.h> |
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index 0015e442572b..2652362ce047 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/clockchips.h> | 9 | #include <linux/clockchips.h> |
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/percpu.h> | 11 | #include <linux/percpu.h> |
12 | #include <linux/smp.h> | ||
12 | 13 | ||
13 | #include <asm/smtc_ipi.h> | 14 | #include <asm/smtc_ipi.h> |
14 | #include <asm/time.h> | 15 | #include <asm/time.h> |
diff --git a/arch/mips/kernel/cevt-sb1250.c b/arch/mips/kernel/cevt-sb1250.c index 340f53e5c6b1..ac5903d1b20e 100644 --- a/arch/mips/kernel/cevt-sb1250.c +++ b/arch/mips/kernel/cevt-sb1250.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/clockchips.h> | 18 | #include <linux/clockchips.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/percpu.h> | 20 | #include <linux/percpu.h> |
21 | #include <linux/smp.h> | ||
21 | 22 | ||
22 | #include <asm/addrspace.h> | 23 | #include <asm/addrspace.h> |
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c index df6f5bc60572..98bd7de75778 100644 --- a/arch/mips/kernel/cevt-smtc.c +++ b/arch/mips/kernel/cevt-smtc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/clockchips.h> | 10 | #include <linux/clockchips.h> |
11 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
12 | #include <linux/percpu.h> | 12 | #include <linux/percpu.h> |
13 | #include <linux/smp.h> | ||
13 | 14 | ||
14 | #include <asm/smtc_ipi.h> | 15 | #include <asm/smtc_ipi.h> |
15 | #include <asm/time.h> | 16 | #include <asm/time.h> |
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index b13b8eb30596..1abe9905c9c1 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/ptrace.h> | 16 | #include <linux/ptrace.h> |
17 | #include <linux/smp.h> | ||
17 | #include <linux/stddef.h> | 18 | #include <linux/stddef.h> |
18 | 19 | ||
19 | #include <asm/bugs.h> | 20 | #include <asm/bugs.h> |
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c index ed20e7fe65e3..f7d8d5d0ddbf 100644 --- a/arch/mips/kernel/i8253.c +++ b/arch/mips/kernel/i8253.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/interrupt.h> | 7 | #include <linux/interrupt.h> |
8 | #include <linux/jiffies.h> | 8 | #include <linux/jiffies.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/smp.h> | ||
10 | #include <linux/spinlock.h> | 11 | #include <linux/spinlock.h> |
11 | 12 | ||
12 | #include <asm/delay.h> | 13 | #include <asm/delay.h> |
diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c index 3f43c2e3aa5a..39000f103f2c 100644 --- a/arch/mips/kernel/irq-gic.c +++ b/arch/mips/kernel/irq-gic.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include <linux/bitmap.h> | 3 | #include <linux/bitmap.h> |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | #include <linux/smp.h> | ||
5 | 6 | ||
6 | #include <asm/io.h> | 7 | #include <asm/io.h> |
7 | #include <asm/gic.h> | 8 | #include <asm/gic.h> |
diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c index 6e152c80cd4a..50c9bb880667 100644 --- a/arch/mips/kernel/kgdb.c +++ b/arch/mips/kernel/kgdb.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/kgdb.h> | 26 | #include <linux/kgdb.h> |
27 | #include <linux/kdebug.h> | 27 | #include <linux/kdebug.h> |
28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
29 | #include <linux/smp.h> | ||
29 | #include <asm/inst.h> | 30 | #include <asm/inst.h> |
30 | #include <asm/fpu.h> | 31 | #include <asm/fpu.h> |
31 | #include <asm/cacheflush.h> | 32 | #include <asm/cacheflush.h> |
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 1eaaa450e20c..c09d681b7181 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -50,10 +50,15 @@ | |||
50 | */ | 50 | */ |
51 | void __noreturn cpu_idle(void) | 51 | void __noreturn cpu_idle(void) |
52 | { | 52 | { |
53 | int cpu; | ||
54 | |||
55 | /* CPU is going idle. */ | ||
56 | cpu = smp_processor_id(); | ||
57 | |||
53 | /* endless idle loop with no priority at all */ | 58 | /* endless idle loop with no priority at all */ |
54 | while (1) { | 59 | while (1) { |
55 | tick_nohz_stop_sched_tick(1); | 60 | tick_nohz_stop_sched_tick(1); |
56 | while (!need_resched()) { | 61 | while (!need_resched() && cpu_online(cpu)) { |
57 | #ifdef CONFIG_MIPS_MT_SMTC | 62 | #ifdef CONFIG_MIPS_MT_SMTC |
58 | extern void smtc_idle_loop_hook(void); | 63 | extern void smtc_idle_loop_hook(void); |
59 | 64 | ||
@@ -62,6 +67,12 @@ void __noreturn cpu_idle(void) | |||
62 | if (cpu_wait) | 67 | if (cpu_wait) |
63 | (*cpu_wait)(); | 68 | (*cpu_wait)(); |
64 | } | 69 | } |
70 | #ifdef CONFIG_HOTPLUG_CPU | ||
71 | if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) && | ||
72 | (system_state == SYSTEM_RUNNING || | ||
73 | system_state == SYSTEM_BOOTING)) | ||
74 | play_dead(); | ||
75 | #endif | ||
65 | tick_nohz_restart_sched_tick(); | 76 | tick_nohz_restart_sched_tick(); |
66 | preempt_enable_no_resched(); | 77 | preempt_enable_no_resched(); |
67 | schedule(); | 78 | schedule(); |
diff --git a/arch/mips/kernel/smp-cmp.c b/arch/mips/kernel/smp-cmp.c index f27beca4b26d..653be061b9ec 100644 --- a/arch/mips/kernel/smp-cmp.c +++ b/arch/mips/kernel/smp-cmp.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/smp.h> | ||
23 | #include <linux/cpumask.h> | 24 | #include <linux/cpumask.h> |
24 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
25 | #include <linux/compiler.h> | 26 | #include <linux/compiler.h> |
diff --git a/arch/mips/kernel/smp-up.c b/arch/mips/kernel/smp-up.c index 878e3733bbb2..2508d55d68fd 100644 --- a/arch/mips/kernel/smp-up.c +++ b/arch/mips/kernel/smp-up.c | |||
@@ -55,6 +55,18 @@ static void __init up_prepare_cpus(unsigned int max_cpus) | |||
55 | { | 55 | { |
56 | } | 56 | } |
57 | 57 | ||
58 | #ifdef CONFIG_HOTPLUG_CPU | ||
59 | static int up_cpu_disable(void) | ||
60 | { | ||
61 | return -ENOSYS; | ||
62 | } | ||
63 | |||
64 | static void up_cpu_die(unsigned int cpu) | ||
65 | { | ||
66 | BUG(); | ||
67 | } | ||
68 | #endif | ||
69 | |||
58 | struct plat_smp_ops up_smp_ops = { | 70 | struct plat_smp_ops up_smp_ops = { |
59 | .send_ipi_single = up_send_ipi_single, | 71 | .send_ipi_single = up_send_ipi_single, |
60 | .send_ipi_mask = up_send_ipi_mask, | 72 | .send_ipi_mask = up_send_ipi_mask, |
@@ -64,4 +76,8 @@ struct plat_smp_ops up_smp_ops = { | |||
64 | .boot_secondary = up_boot_secondary, | 76 | .boot_secondary = up_boot_secondary, |
65 | .smp_setup = up_smp_setup, | 77 | .smp_setup = up_smp_setup, |
66 | .prepare_cpus = up_prepare_cpus, | 78 | .prepare_cpus = up_prepare_cpus, |
79 | #ifdef CONFIG_HOTPLUG_CPU | ||
80 | .cpu_disable = up_cpu_disable, | ||
81 | .cpu_die = up_cpu_die, | ||
82 | #endif | ||
67 | }; | 83 | }; |
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index c937506a03aa..bc7d9b05e2f4 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/smp.h> | ||
25 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
26 | #include <linux/threads.h> | 27 | #include <linux/threads.h> |
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
@@ -44,7 +45,7 @@ | |||
44 | #include <asm/mipsmtregs.h> | 45 | #include <asm/mipsmtregs.h> |
45 | #endif /* CONFIG_MIPS_MT_SMTC */ | 46 | #endif /* CONFIG_MIPS_MT_SMTC */ |
46 | 47 | ||
47 | static volatile cpumask_t cpu_callin_map; /* Bitmask of started secondaries */ | 48 | volatile cpumask_t cpu_callin_map; /* Bitmask of started secondaries */ |
48 | int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ | 49 | int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ |
49 | int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ | 50 | int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ |
50 | 51 | ||
@@ -200,6 +201,8 @@ void __devinit smp_prepare_boot_cpu(void) | |||
200 | * and keep control until "cpu_online(cpu)" is set. Note: cpu is | 201 | * and keep control until "cpu_online(cpu)" is set. Note: cpu is |
201 | * physical, not logical. | 202 | * physical, not logical. |
202 | */ | 203 | */ |
204 | static struct task_struct *cpu_idle_thread[NR_CPUS]; | ||
205 | |||
203 | int __cpuinit __cpu_up(unsigned int cpu) | 206 | int __cpuinit __cpu_up(unsigned int cpu) |
204 | { | 207 | { |
205 | struct task_struct *idle; | 208 | struct task_struct *idle; |
@@ -209,9 +212,16 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
209 | * The following code is purely to make sure | 212 | * The following code is purely to make sure |
210 | * Linux can schedule processes on this slave. | 213 | * Linux can schedule processes on this slave. |
211 | */ | 214 | */ |
212 | idle = fork_idle(cpu); | 215 | if (!cpu_idle_thread[cpu]) { |
213 | if (IS_ERR(idle)) | 216 | idle = fork_idle(cpu); |
214 | panic(KERN_ERR "Fork failed for CPU %d", cpu); | 217 | cpu_idle_thread[cpu] = idle; |
218 | |||
219 | if (IS_ERR(idle)) | ||
220 | panic(KERN_ERR "Fork failed for CPU %d", cpu); | ||
221 | } else { | ||
222 | idle = cpu_idle_thread[cpu]; | ||
223 | init_idle(idle, cpu); | ||
224 | } | ||
215 | 225 | ||
216 | mp_ops->boot_secondary(cpu, idle); | 226 | mp_ops->boot_secondary(cpu, idle); |
217 | 227 | ||
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c index 37d51cd124e9..8a0626cbb108 100644 --- a/arch/mips/kernel/smtc.c +++ b/arch/mips/kernel/smtc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/clockchips.h> | 20 | #include <linux/clockchips.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/smp.h> | ||
23 | #include <linux/cpumask.h> | 24 | #include <linux/cpumask.h> |
24 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
25 | #include <linux/kernel_stat.h> | 26 | #include <linux/kernel_stat.h> |
diff --git a/arch/mips/kernel/topology.c b/arch/mips/kernel/topology.c index 660e44ed44d7..cf3eb61fad12 100644 --- a/arch/mips/kernel/topology.c +++ b/arch/mips/kernel/topology.c | |||
@@ -17,7 +17,10 @@ static int __init topology_init(void) | |||
17 | #endif /* CONFIG_NUMA */ | 17 | #endif /* CONFIG_NUMA */ |
18 | 18 | ||
19 | for_each_present_cpu(i) { | 19 | for_each_present_cpu(i) { |
20 | ret = register_cpu(&per_cpu(cpu_devices, i), i); | 20 | struct cpu *c = &per_cpu(cpu_devices, i); |
21 | |||
22 | c->hotpluggable = 1; | ||
23 | ret = register_cpu(c, i); | ||
21 | if (ret) | 24 | if (ret) |
22 | printk(KERN_WARNING "topology_init: register_cpu %d " | 25 | printk(KERN_WARNING "topology_init: register_cpu %d " |
23 | "failed (%d)\n", i, ret); | 26 | "failed (%d)\n", i, ret); |
diff --git a/arch/mips/mipssim/sim_time.c b/arch/mips/mipssim/sim_time.c index 881ecbc1fa23..0cea932f1241 100644 --- a/arch/mips/mipssim/sim_time.c +++ b/arch/mips/mipssim/sim_time.c | |||
@@ -91,6 +91,7 @@ unsigned __cpuinit get_c0_compare_int(void) | |||
91 | mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR; | 91 | mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR; |
92 | } else { | 92 | } else { |
93 | #endif | 93 | #endif |
94 | { | ||
94 | if (cpu_has_vint) | 95 | if (cpu_has_vint) |
95 | set_vi_handler(cp0_compare_irq, mips_timer_dispatch); | 96 | set_vi_handler(cp0_compare_irq, mips_timer_dispatch); |
96 | mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; | 97 | mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; |
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index 44d01a0a8490..b165cdcb2818 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/smp.h> | ||
11 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
12 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
13 | #include <linux/cpu.h> | 14 | #include <linux/cpu.h> |
diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c index 5500c20c79ae..54e5f7b9f440 100644 --- a/arch/mips/mm/c-r3k.c +++ b/arch/mips/mm/c-r3k.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/smp.h> | ||
15 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
16 | 17 | ||
17 | #include <asm/page.h> | 18 | #include <asm/page.h> |
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 71fe4cb778cd..6721ee2b1e8b 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/linkage.h> | 14 | #include <linux/linkage.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
18 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c index f7c8f9ce39c1..6515b4418714 100644 --- a/arch/mips/mm/c-tx39.c +++ b/arch/mips/mm/c-tx39.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/smp.h> | ||
14 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
15 | 16 | ||
16 | #include <asm/cacheops.h> | 17 | #include <asm/cacheops.h> |
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c index 2b1309b2580a..e274fda329f4 100644 --- a/arch/mips/mm/highmem.c +++ b/arch/mips/mm/highmem.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/highmem.h> | 2 | #include <linux/highmem.h> |
3 | #include <linux/smp.h> | ||
3 | #include <asm/fixmap.h> | 4 | #include <asm/fixmap.h> |
4 | #include <asm/tlbflush.h> | 5 | #include <asm/tlbflush.h> |
5 | 6 | ||
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index c5511294a9ee..0e820508ff23 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/signal.h> | 14 | #include <linux/signal.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
18 | #include <linux/string.h> | 19 | #include <linux/string.h> |
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c index 48060c635acd..f5c73754d664 100644 --- a/arch/mips/mm/page.c +++ b/arch/mips/mm/page.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/smp.h> | ||
13 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 1c0048a6f5cf..0f5ab236ab69 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/smp.h> | ||
16 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
17 | 18 | ||
18 | #include <asm/page.h> | 19 | #include <asm/page.h> |
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index f60fe513eb60..cee502caf398 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/smp.h> | ||
13 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
14 | #include <linux/hugetlb.h> | 15 | #include <linux/hugetlb.h> |
15 | 16 | ||
diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c index 4ec95cc2df2f..2b82f23df1a1 100644 --- a/arch/mips/mm/tlb-r8k.c +++ b/arch/mips/mm/tlb-r8k.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/smp.h> | ||
13 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
14 | 15 | ||
15 | #include <asm/cpu.h> | 16 | #include <asm/cpu.h> |
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 8f606ead826e..9a17bf8395df 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/bug.h> | 23 | #include <linux/bug.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/smp.h> | ||
26 | #include <linux/string.h> | 27 | #include <linux/string.h> |
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | 29 | ||
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c index ea176113fea9..b4eaf137e4a7 100644 --- a/arch/mips/mti-malta/malta-int.c +++ b/arch/mips/mti-malta/malta-int.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/smp.h> | ||
27 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
28 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
29 | #include <linux/io.h> | 30 | #include <linux/io.h> |
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c index dda6f2058665..a0e726eb039a 100644 --- a/arch/mips/pci/pci-ip27.c +++ b/arch/mips/pci/pci-ip27.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/smp.h> | ||
13 | #include <asm/sn/arch.h> | 14 | #include <asm/sn/arch.h> |
14 | #include <asm/pci/bridge.h> | 15 | #include <asm/pci/bridge.h> |
15 | #include <asm/paccess.h> | 16 | #include <asm/paccess.h> |
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c index f78c29b68d77..8ace27716232 100644 --- a/arch/mips/pmc-sierra/yosemite/smp.c +++ b/arch/mips/pmc-sierra/yosemite/smp.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/linkage.h> | 1 | #include <linux/linkage.h> |
2 | #include <linux/sched.h> | 2 | #include <linux/sched.h> |
3 | #include <linux/smp.h> | ||
3 | 4 | ||
4 | #include <asm/pmon.h> | 5 | #include <asm/pmon.h> |
5 | #include <asm/titan_dep.h> | 6 | #include <asm/titan_dep.h> |
diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S index 486bd3fd01a1..4b8174b382d7 100644 --- a/arch/mips/power/hibernate.S +++ b/arch/mips/power/hibernate.S | |||
@@ -43,15 +43,6 @@ LEAF(swsusp_arch_resume) | |||
43 | bne t1, t3, 1b | 43 | bne t1, t3, 1b |
44 | PTR_L t0, PBE_NEXT(t0) | 44 | PTR_L t0, PBE_NEXT(t0) |
45 | bnez t0, 0b | 45 | bnez t0, 0b |
46 | /* flush caches to make sure context is in memory */ | ||
47 | PTR_L t0, __flush_cache_all | ||
48 | jalr t0 | ||
49 | /* flush tlb entries */ | ||
50 | #ifdef CONFIG_SMP | ||
51 | jal flush_tlb_all | ||
52 | #else | ||
53 | jal local_flush_tlb_all | ||
54 | #endif | ||
55 | PTR_LA t0, saved_regs | 46 | PTR_LA t0, saved_regs |
56 | PTR_L ra, PT_R31(t0) | 47 | PTR_L ra, PT_R31(t0) |
57 | PTR_L sp, PT_R29(t0) | 48 | PTR_L sp, PT_R29(t0) |
diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c index 4a500e8cd3cc..51d3a4f2d7e1 100644 --- a/arch/mips/sgi-ip27/ip27-init.c +++ b/arch/mips/sgi-ip27/ip27-init.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/smp.h> | ||
12 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <linux/cpumask.h> | 15 | #include <linux/cpumask.h> |
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c index 1bb692a3b319..c1c8e40d65d6 100644 --- a/arch/mips/sgi-ip27/ip27-irq.c +++ b/arch/mips/sgi-ip27/ip27-irq.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
19 | #include <linux/timex.h> | 19 | #include <linux/timex.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/smp.h> | ||
21 | #include <linux/random.h> | 22 | #include <linux/random.h> |
22 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
23 | #include <linux/kernel_stat.h> | 24 | #include <linux/kernel_stat.h> |
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c index f10a7cd64f7e..6d0e59ffba2e 100644 --- a/arch/mips/sgi-ip27/ip27-timer.c +++ b/arch/mips/sgi-ip27/ip27-timer.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/kernel_stat.h> | 11 | #include <linux/kernel_stat.h> |
12 | #include <linux/param.h> | 12 | #include <linux/param.h> |
13 | #include <linux/smp.h> | ||
13 | #include <linux/time.h> | 14 | #include <linux/time.h> |
14 | #include <linux/timex.h> | 15 | #include <linux/timex.h> |
15 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
diff --git a/arch/mips/sgi-ip27/ip27-xtalk.c b/arch/mips/sgi-ip27/ip27-xtalk.c index 6ae64e8dfc40..5e871e75a8d9 100644 --- a/arch/mips/sgi-ip27/ip27-xtalk.c +++ b/arch/mips/sgi-ip27/ip27-xtalk.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/smp.h> | ||
12 | #include <asm/sn/types.h> | 13 | #include <asm/sn/types.h> |
13 | #include <asm/sn/klconfig.h> | 14 | #include <asm/sn/klconfig.h> |
14 | #include <asm/sn/hub.h> | 15 | #include <asm/sn/hub.h> |
diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c index 690de06bde90..ba59839a021e 100644 --- a/arch/mips/sibyte/bcm1480/irq.c +++ b/arch/mips/sibyte/bcm1480/irq.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/linkage.h> | 20 | #include <linux/linkage.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/smp.h> | ||
22 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
23 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
diff --git a/arch/mips/sibyte/common/cfe_console.c b/arch/mips/sibyte/common/cfe_console.c index 81e3d54376e9..1ad2da103fe9 100644 --- a/arch/mips/sibyte/common/cfe_console.c +++ b/arch/mips/sibyte/common/cfe_console.c | |||
@@ -51,12 +51,13 @@ static int cfe_console_setup(struct console *cons, char *str) | |||
51 | setleds("u0cn"); | 51 | setleds("u0cn"); |
52 | } else if (!strcmp(consdev, "uart1")) { | 52 | } else if (!strcmp(consdev, "uart1")) { |
53 | setleds("u1cn"); | 53 | setleds("u1cn"); |
54 | } else | ||
54 | #endif | 55 | #endif |
55 | #ifdef CONFIG_VGA_CONSOLE | 56 | #ifdef CONFIG_VGA_CONSOLE |
56 | } else if (!strcmp(consdev, "pcconsole0")) { | 57 | if (!strcmp(consdev, "pcconsole0")) { |
57 | setleds("pccn"); | 58 | setleds("pccn"); |
58 | #endif | ||
59 | } else | 59 | } else |
60 | #endif | ||
60 | return -ENODEV; | 61 | return -ENODEV; |
61 | } | 62 | } |
62 | return 0; | 63 | return 0; |
diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c index 69f5f88711cc..0d9ec1a5c24a 100644 --- a/arch/mips/sni/time.c +++ b/arch/mips/sni/time.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/interrupt.h> | 2 | #include <linux/interrupt.h> |
3 | #include <linux/smp.h> | ||
3 | #include <linux/time.h> | 4 | #include <linux/time.h> |
4 | #include <linux/clockchips.h> | 5 | #include <linux/clockchips.h> |
5 | 6 | ||
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index 9aa9ea9822c8..88dab52926f4 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -432,23 +432,27 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc, | |||
432 | list_splice_init(&txd->tx_list, &dc->free_list); | 432 | list_splice_init(&txd->tx_list, &dc->free_list); |
433 | list_move(&desc->desc_node, &dc->free_list); | 433 | list_move(&desc->desc_node, &dc->free_list); |
434 | 434 | ||
435 | /* | ||
436 | * We use dma_unmap_page() regardless of how the buffers were | ||
437 | * mapped before they were submitted... | ||
438 | */ | ||
439 | if (!ds) { | 435 | if (!ds) { |
440 | dma_addr_t dmaaddr; | 436 | dma_addr_t dmaaddr; |
441 | if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) { | 437 | if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) { |
442 | dmaaddr = is_dmac64(dc) ? | 438 | dmaaddr = is_dmac64(dc) ? |
443 | desc->hwdesc.DAR : desc->hwdesc32.DAR; | 439 | desc->hwdesc.DAR : desc->hwdesc32.DAR; |
444 | dma_unmap_page(chan2parent(&dc->chan), dmaaddr, | 440 | if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE) |
445 | desc->len, DMA_FROM_DEVICE); | 441 | dma_unmap_single(chan2parent(&dc->chan), |
442 | dmaaddr, desc->len, DMA_FROM_DEVICE); | ||
443 | else | ||
444 | dma_unmap_page(chan2parent(&dc->chan), | ||
445 | dmaaddr, desc->len, DMA_FROM_DEVICE); | ||
446 | } | 446 | } |
447 | if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) { | 447 | if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) { |
448 | dmaaddr = is_dmac64(dc) ? | 448 | dmaaddr = is_dmac64(dc) ? |
449 | desc->hwdesc.SAR : desc->hwdesc32.SAR; | 449 | desc->hwdesc.SAR : desc->hwdesc32.SAR; |
450 | dma_unmap_page(chan2parent(&dc->chan), dmaaddr, | 450 | if (txd->flags & DMA_COMPL_SRC_UNMAP_SINGLE) |
451 | desc->len, DMA_TO_DEVICE); | 451 | dma_unmap_single(chan2parent(&dc->chan), |
452 | dmaaddr, desc->len, DMA_TO_DEVICE); | ||
453 | else | ||
454 | dma_unmap_page(chan2parent(&dc->chan), | ||
455 | dmaaddr, desc->len, DMA_TO_DEVICE); | ||
452 | } | 456 | } |
453 | } | 457 | } |
454 | 458 | ||
diff --git a/drivers/staging/octeon/Makefile b/drivers/staging/octeon/Makefile index 3c839e37d37f..c0a583cc2227 100644 --- a/drivers/staging/octeon/Makefile +++ b/drivers/staging/octeon/Makefile | |||
@@ -12,7 +12,6 @@ | |||
12 | obj-${CONFIG_OCTEON_ETHERNET} := octeon-ethernet.o | 12 | obj-${CONFIG_OCTEON_ETHERNET} := octeon-ethernet.o |
13 | 13 | ||
14 | octeon-ethernet-objs := ethernet.o | 14 | octeon-ethernet-objs := ethernet.o |
15 | octeon-ethernet-objs += ethernet-common.o | ||
16 | octeon-ethernet-objs += ethernet-mdio.o | 15 | octeon-ethernet-objs += ethernet-mdio.o |
17 | octeon-ethernet-objs += ethernet-mem.o | 16 | octeon-ethernet-objs += ethernet-mem.o |
18 | octeon-ethernet-objs += ethernet-proc.o | 17 | octeon-ethernet-objs += ethernet-proc.o |
diff --git a/drivers/staging/octeon/ethernet-common.c b/drivers/staging/octeon/ethernet-common.c deleted file mode 100644 index 3e6f5b8cc63d..000000000000 --- a/drivers/staging/octeon/ethernet-common.c +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | * Author: Cavium Networks | ||
3 | * | ||
4 | * Contact: support@caviumnetworks.com | ||
5 | * This file is part of the OCTEON SDK | ||
6 | * | ||
7 | * Copyright (c) 2003-2007 Cavium Networks | ||
8 | * | ||
9 | * This file is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License, Version 2, as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This file is distributed in the hope that it will be useful, but | ||
14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty | ||
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or | ||
16 | * NONINFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this file; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | * or visit http://www.gnu.org/licenses/. | ||
23 | * | ||
24 | * This file may also be available under a different license from Cavium. | ||
25 | * Contact Cavium Networks for more information | ||
26 | **********************************************************************/ | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/mii.h> | ||
29 | #include <net/dst.h> | ||
30 | |||
31 | #include <asm/atomic.h> | ||
32 | #include <asm/octeon/octeon.h> | ||
33 | |||
34 | #include "ethernet-defines.h" | ||
35 | #include "ethernet-tx.h" | ||
36 | #include "ethernet-mdio.h" | ||
37 | #include "ethernet-util.h" | ||
38 | #include "octeon-ethernet.h" | ||
39 | #include "ethernet-common.h" | ||
40 | |||
41 | #include "cvmx-pip.h" | ||
42 | #include "cvmx-pko.h" | ||
43 | #include "cvmx-fau.h" | ||
44 | #include "cvmx-helper.h" | ||
45 | |||
46 | #include "cvmx-gmxx-defs.h" | ||
47 | |||
48 | /** | ||
49 | * Get the low level ethernet statistics | ||
50 | * | ||
51 | * @dev: Device to get the statistics from | ||
52 | * Returns Pointer to the statistics | ||
53 | */ | ||
54 | static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev) | ||
55 | { | ||
56 | cvmx_pip_port_status_t rx_status; | ||
57 | cvmx_pko_port_status_t tx_status; | ||
58 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
59 | |||
60 | if (priv->port < CVMX_PIP_NUM_INPUT_PORTS) { | ||
61 | if (octeon_is_simulation()) { | ||
62 | /* The simulator doesn't support statistics */ | ||
63 | memset(&rx_status, 0, sizeof(rx_status)); | ||
64 | memset(&tx_status, 0, sizeof(tx_status)); | ||
65 | } else { | ||
66 | cvmx_pip_get_port_status(priv->port, 1, &rx_status); | ||
67 | cvmx_pko_get_port_status(priv->port, 1, &tx_status); | ||
68 | } | ||
69 | |||
70 | priv->stats.rx_packets += rx_status.inb_packets; | ||
71 | priv->stats.tx_packets += tx_status.packets; | ||
72 | priv->stats.rx_bytes += rx_status.inb_octets; | ||
73 | priv->stats.tx_bytes += tx_status.octets; | ||
74 | priv->stats.multicast += rx_status.multicast_packets; | ||
75 | priv->stats.rx_crc_errors += rx_status.inb_errors; | ||
76 | priv->stats.rx_frame_errors += rx_status.fcs_align_err_packets; | ||
77 | |||
78 | /* | ||
79 | * The drop counter must be incremented atomically | ||
80 | * since the RX tasklet also increments it. | ||
81 | */ | ||
82 | #ifdef CONFIG_64BIT | ||
83 | atomic64_add(rx_status.dropped_packets, | ||
84 | (atomic64_t *)&priv->stats.rx_dropped); | ||
85 | #else | ||
86 | atomic_add(rx_status.dropped_packets, | ||
87 | (atomic_t *)&priv->stats.rx_dropped); | ||
88 | #endif | ||
89 | } | ||
90 | |||
91 | return &priv->stats; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * Set the multicast list. Currently unimplemented. | ||
96 | * | ||
97 | * @dev: Device to work on | ||
98 | */ | ||
99 | static void cvm_oct_common_set_multicast_list(struct net_device *dev) | ||
100 | { | ||
101 | union cvmx_gmxx_prtx_cfg gmx_cfg; | ||
102 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
103 | int interface = INTERFACE(priv->port); | ||
104 | int index = INDEX(priv->port); | ||
105 | |||
106 | if ((interface < 2) | ||
107 | && (cvmx_helper_interface_get_mode(interface) != | ||
108 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
109 | union cvmx_gmxx_rxx_adr_ctl control; | ||
110 | control.u64 = 0; | ||
111 | control.s.bcst = 1; /* Allow broadcast MAC addresses */ | ||
112 | |||
113 | if (dev->mc_list || (dev->flags & IFF_ALLMULTI) || | ||
114 | (dev->flags & IFF_PROMISC)) | ||
115 | /* Force accept multicast packets */ | ||
116 | control.s.mcst = 2; | ||
117 | else | ||
118 | /* Force reject multicat packets */ | ||
119 | control.s.mcst = 1; | ||
120 | |||
121 | if (dev->flags & IFF_PROMISC) | ||
122 | /* | ||
123 | * Reject matches if promisc. Since CAM is | ||
124 | * shut off, should accept everything. | ||
125 | */ | ||
126 | control.s.cam_mode = 0; | ||
127 | else | ||
128 | /* Filter packets based on the CAM */ | ||
129 | control.s.cam_mode = 1; | ||
130 | |||
131 | gmx_cfg.u64 = | ||
132 | cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); | ||
133 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
134 | gmx_cfg.u64 & ~1ull); | ||
135 | |||
136 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CTL(index, interface), | ||
137 | control.u64); | ||
138 | if (dev->flags & IFF_PROMISC) | ||
139 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN | ||
140 | (index, interface), 0); | ||
141 | else | ||
142 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN | ||
143 | (index, interface), 1); | ||
144 | |||
145 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
146 | gmx_cfg.u64); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * Set the hardware MAC address for a device | ||
152 | * | ||
153 | * @dev: Device to change the MAC address for | ||
154 | * @addr: Address structure to change it too. MAC address is addr + 2. | ||
155 | * Returns Zero on success | ||
156 | */ | ||
157 | static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr) | ||
158 | { | ||
159 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
160 | union cvmx_gmxx_prtx_cfg gmx_cfg; | ||
161 | int interface = INTERFACE(priv->port); | ||
162 | int index = INDEX(priv->port); | ||
163 | |||
164 | memcpy(dev->dev_addr, addr + 2, 6); | ||
165 | |||
166 | if ((interface < 2) | ||
167 | && (cvmx_helper_interface_get_mode(interface) != | ||
168 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
169 | int i; | ||
170 | uint8_t *ptr = addr; | ||
171 | uint64_t mac = 0; | ||
172 | for (i = 0; i < 6; i++) | ||
173 | mac = (mac << 8) | (uint64_t) (ptr[i + 2]); | ||
174 | |||
175 | gmx_cfg.u64 = | ||
176 | cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); | ||
177 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
178 | gmx_cfg.u64 & ~1ull); | ||
179 | |||
180 | cvmx_write_csr(CVMX_GMXX_SMACX(index, interface), mac); | ||
181 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM0(index, interface), | ||
182 | ptr[2]); | ||
183 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM1(index, interface), | ||
184 | ptr[3]); | ||
185 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM2(index, interface), | ||
186 | ptr[4]); | ||
187 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM3(index, interface), | ||
188 | ptr[5]); | ||
189 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM4(index, interface), | ||
190 | ptr[6]); | ||
191 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM5(index, interface), | ||
192 | ptr[7]); | ||
193 | cvm_oct_common_set_multicast_list(dev); | ||
194 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
195 | gmx_cfg.u64); | ||
196 | } | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Change the link MTU. Unimplemented | ||
202 | * | ||
203 | * @dev: Device to change | ||
204 | * @new_mtu: The new MTU | ||
205 | * | ||
206 | * Returns Zero on success | ||
207 | */ | ||
208 | static int cvm_oct_common_change_mtu(struct net_device *dev, int new_mtu) | ||
209 | { | ||
210 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
211 | int interface = INTERFACE(priv->port); | ||
212 | int index = INDEX(priv->port); | ||
213 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | ||
214 | int vlan_bytes = 4; | ||
215 | #else | ||
216 | int vlan_bytes = 0; | ||
217 | #endif | ||
218 | |||
219 | /* | ||
220 | * Limit the MTU to make sure the ethernet packets are between | ||
221 | * 64 bytes and 65535 bytes. | ||
222 | */ | ||
223 | if ((new_mtu + 14 + 4 + vlan_bytes < 64) | ||
224 | || (new_mtu + 14 + 4 + vlan_bytes > 65392)) { | ||
225 | pr_err("MTU must be between %d and %d.\n", | ||
226 | 64 - 14 - 4 - vlan_bytes, 65392 - 14 - 4 - vlan_bytes); | ||
227 | return -EINVAL; | ||
228 | } | ||
229 | dev->mtu = new_mtu; | ||
230 | |||
231 | if ((interface < 2) | ||
232 | && (cvmx_helper_interface_get_mode(interface) != | ||
233 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
234 | /* Add ethernet header and FCS, and VLAN if configured. */ | ||
235 | int max_packet = new_mtu + 14 + 4 + vlan_bytes; | ||
236 | |||
237 | if (OCTEON_IS_MODEL(OCTEON_CN3XXX) | ||
238 | || OCTEON_IS_MODEL(OCTEON_CN58XX)) { | ||
239 | /* Signal errors on packets larger than the MTU */ | ||
240 | cvmx_write_csr(CVMX_GMXX_RXX_FRM_MAX(index, interface), | ||
241 | max_packet); | ||
242 | } else { | ||
243 | /* | ||
244 | * Set the hardware to truncate packets larger | ||
245 | * than the MTU and smaller the 64 bytes. | ||
246 | */ | ||
247 | union cvmx_pip_frm_len_chkx frm_len_chk; | ||
248 | frm_len_chk.u64 = 0; | ||
249 | frm_len_chk.s.minlen = 64; | ||
250 | frm_len_chk.s.maxlen = max_packet; | ||
251 | cvmx_write_csr(CVMX_PIP_FRM_LEN_CHKX(interface), | ||
252 | frm_len_chk.u64); | ||
253 | } | ||
254 | /* | ||
255 | * Set the hardware to truncate packets larger than | ||
256 | * the MTU. The jabber register must be set to a | ||
257 | * multiple of 8 bytes, so round up. | ||
258 | */ | ||
259 | cvmx_write_csr(CVMX_GMXX_RXX_JABBER(index, interface), | ||
260 | (max_packet + 7) & ~7u); | ||
261 | } | ||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | /** | ||
266 | * Per network device initialization | ||
267 | * | ||
268 | * @dev: Device to initialize | ||
269 | * Returns Zero on success | ||
270 | */ | ||
271 | int cvm_oct_common_init(struct net_device *dev) | ||
272 | { | ||
273 | static int count; | ||
274 | char mac[8] = { 0x00, 0x00, | ||
275 | octeon_bootinfo->mac_addr_base[0], | ||
276 | octeon_bootinfo->mac_addr_base[1], | ||
277 | octeon_bootinfo->mac_addr_base[2], | ||
278 | octeon_bootinfo->mac_addr_base[3], | ||
279 | octeon_bootinfo->mac_addr_base[4], | ||
280 | octeon_bootinfo->mac_addr_base[5] + count | ||
281 | }; | ||
282 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
283 | |||
284 | /* | ||
285 | * Force the interface to use the POW send if always_use_pow | ||
286 | * was specified or it is in the pow send list. | ||
287 | */ | ||
288 | if ((pow_send_group != -1) | ||
289 | && (always_use_pow || strstr(pow_send_list, dev->name))) | ||
290 | priv->queue = -1; | ||
291 | |||
292 | if (priv->queue != -1) { | ||
293 | dev->hard_start_xmit = cvm_oct_xmit; | ||
294 | if (USE_HW_TCPUDP_CHECKSUM) | ||
295 | dev->features |= NETIF_F_IP_CSUM; | ||
296 | } else | ||
297 | dev->hard_start_xmit = cvm_oct_xmit_pow; | ||
298 | count++; | ||
299 | |||
300 | dev->get_stats = cvm_oct_common_get_stats; | ||
301 | dev->set_mac_address = cvm_oct_common_set_mac_address; | ||
302 | dev->set_multicast_list = cvm_oct_common_set_multicast_list; | ||
303 | dev->change_mtu = cvm_oct_common_change_mtu; | ||
304 | dev->do_ioctl = cvm_oct_ioctl; | ||
305 | /* We do our own locking, Linux doesn't need to */ | ||
306 | dev->features |= NETIF_F_LLTX; | ||
307 | SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops); | ||
308 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
309 | dev->poll_controller = cvm_oct_poll_controller; | ||
310 | #endif | ||
311 | |||
312 | cvm_oct_mdio_setup_device(dev); | ||
313 | dev->set_mac_address(dev, mac); | ||
314 | dev->change_mtu(dev, dev->mtu); | ||
315 | |||
316 | /* | ||
317 | * Zero out stats for port so we won't mistakenly show | ||
318 | * counters from the bootloader. | ||
319 | */ | ||
320 | memset(dev->get_stats(dev), 0, sizeof(struct net_device_stats)); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | void cvm_oct_common_uninit(struct net_device *dev) | ||
326 | { | ||
327 | /* Currently nothing to do */ | ||
328 | } | ||
diff --git a/drivers/staging/octeon/ethernet-common.h b/drivers/staging/octeon/ethernet-common.h deleted file mode 100644 index 2bd9cd76a398..000000000000 --- a/drivers/staging/octeon/ethernet-common.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /********************************************************************* | ||
2 | * Author: Cavium Networks | ||
3 | * | ||
4 | * Contact: support@caviumnetworks.com | ||
5 | * This file is part of the OCTEON SDK | ||
6 | * | ||
7 | * Copyright (c) 2003-2007 Cavium Networks | ||
8 | * | ||
9 | * This file is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License, Version 2, as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This file is distributed in the hope that it will be useful, but | ||
14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty | ||
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or | ||
16 | * NONINFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this file; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | * or visit http://www.gnu.org/licenses/. | ||
23 | * | ||
24 | * This file may also be available under a different license from Cavium. | ||
25 | * Contact Cavium Networks for more information | ||
26 | *********************************************************************/ | ||
27 | |||
28 | int cvm_oct_common_init(struct net_device *dev); | ||
29 | void cvm_oct_common_uninit(struct net_device *dev); | ||
diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index 8f7374e7664c..f13131b03c33 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h | |||
@@ -117,6 +117,8 @@ | |||
117 | 117 | ||
118 | /* Maximum number of packets to process per interrupt. */ | 118 | /* Maximum number of packets to process per interrupt. */ |
119 | #define MAX_RX_PACKETS 120 | 119 | #define MAX_RX_PACKETS 120 |
120 | /* Maximum number of SKBs to try to free per xmit packet. */ | ||
121 | #define MAX_SKB_TO_FREE 10 | ||
120 | #define MAX_OUT_QUEUE_DEPTH 1000 | 122 | #define MAX_OUT_QUEUE_DEPTH 1000 |
121 | 123 | ||
122 | #ifndef CONFIG_SMP | 124 | #ifndef CONFIG_SMP |
diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index 8579f1670d1e..8704133fe127 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include "ethernet-defines.h" | 34 | #include "ethernet-defines.h" |
35 | #include "octeon-ethernet.h" | 35 | #include "octeon-ethernet.h" |
36 | #include "ethernet-common.h" | ||
37 | #include "ethernet-util.h" | 36 | #include "ethernet-util.h" |
38 | 37 | ||
39 | #include "cvmx-helper.h" | 38 | #include "cvmx-helper.h" |
@@ -265,7 +264,7 @@ static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id) | |||
265 | return return_status; | 264 | return return_status; |
266 | } | 265 | } |
267 | 266 | ||
268 | static int cvm_oct_rgmii_open(struct net_device *dev) | 267 | int cvm_oct_rgmii_open(struct net_device *dev) |
269 | { | 268 | { |
270 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 269 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
271 | struct octeon_ethernet *priv = netdev_priv(dev); | 270 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -286,7 +285,7 @@ static int cvm_oct_rgmii_open(struct net_device *dev) | |||
286 | return 0; | 285 | return 0; |
287 | } | 286 | } |
288 | 287 | ||
289 | static int cvm_oct_rgmii_stop(struct net_device *dev) | 288 | int cvm_oct_rgmii_stop(struct net_device *dev) |
290 | { | 289 | { |
291 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 290 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
292 | struct octeon_ethernet *priv = netdev_priv(dev); | 291 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -305,9 +304,7 @@ int cvm_oct_rgmii_init(struct net_device *dev) | |||
305 | int r; | 304 | int r; |
306 | 305 | ||
307 | cvm_oct_common_init(dev); | 306 | cvm_oct_common_init(dev); |
308 | dev->open = cvm_oct_rgmii_open; | 307 | dev->netdev_ops->ndo_stop(dev); |
309 | dev->stop = cvm_oct_rgmii_stop; | ||
310 | dev->stop(dev); | ||
311 | 308 | ||
312 | /* | 309 | /* |
313 | * Due to GMX errata in CN3XXX series chips, it is necessary | 310 | * Due to GMX errata in CN3XXX series chips, it is necessary |
diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 58fa39c1d675..2b54996bd85d 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c | |||
@@ -34,13 +34,12 @@ | |||
34 | #include "ethernet-defines.h" | 34 | #include "ethernet-defines.h" |
35 | #include "octeon-ethernet.h" | 35 | #include "octeon-ethernet.h" |
36 | #include "ethernet-util.h" | 36 | #include "ethernet-util.h" |
37 | #include "ethernet-common.h" | ||
38 | 37 | ||
39 | #include "cvmx-helper.h" | 38 | #include "cvmx-helper.h" |
40 | 39 | ||
41 | #include "cvmx-gmxx-defs.h" | 40 | #include "cvmx-gmxx-defs.h" |
42 | 41 | ||
43 | static int cvm_oct_sgmii_open(struct net_device *dev) | 42 | int cvm_oct_sgmii_open(struct net_device *dev) |
44 | { | 43 | { |
45 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 44 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
46 | struct octeon_ethernet *priv = netdev_priv(dev); | 45 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -61,7 +60,7 @@ static int cvm_oct_sgmii_open(struct net_device *dev) | |||
61 | return 0; | 60 | return 0; |
62 | } | 61 | } |
63 | 62 | ||
64 | static int cvm_oct_sgmii_stop(struct net_device *dev) | 63 | int cvm_oct_sgmii_stop(struct net_device *dev) |
65 | { | 64 | { |
66 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 65 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
67 | struct octeon_ethernet *priv = netdev_priv(dev); | 66 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -113,9 +112,7 @@ int cvm_oct_sgmii_init(struct net_device *dev) | |||
113 | { | 112 | { |
114 | struct octeon_ethernet *priv = netdev_priv(dev); | 113 | struct octeon_ethernet *priv = netdev_priv(dev); |
115 | cvm_oct_common_init(dev); | 114 | cvm_oct_common_init(dev); |
116 | dev->open = cvm_oct_sgmii_open; | 115 | dev->netdev_ops->ndo_stop(dev); |
117 | dev->stop = cvm_oct_sgmii_stop; | ||
118 | dev->stop(dev); | ||
119 | if (!octeon_is_simulation()) | 116 | if (!octeon_is_simulation()) |
120 | priv->poll = cvm_oct_sgmii_poll; | 117 | priv->poll = cvm_oct_sgmii_poll; |
121 | 118 | ||
diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c index e0971bbe4ddc..66190b0cb68f 100644 --- a/drivers/staging/octeon/ethernet-spi.c +++ b/drivers/staging/octeon/ethernet-spi.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include "ethernet-defines.h" | 34 | #include "ethernet-defines.h" |
35 | #include "octeon-ethernet.h" | 35 | #include "octeon-ethernet.h" |
36 | #include "ethernet-common.h" | ||
37 | #include "ethernet-util.h" | 36 | #include "ethernet-util.h" |
38 | 37 | ||
39 | #include "cvmx-spi.h" | 38 | #include "cvmx-spi.h" |
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 77b7122c8fdb..81a851390f1b 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c | |||
@@ -47,6 +47,7 @@ | |||
47 | 47 | ||
48 | #include "ethernet-defines.h" | 48 | #include "ethernet-defines.h" |
49 | #include "octeon-ethernet.h" | 49 | #include "octeon-ethernet.h" |
50 | #include "ethernet-tx.h" | ||
50 | #include "ethernet-util.h" | 51 | #include "ethernet-util.h" |
51 | 52 | ||
52 | #include "cvmx-wqe.h" | 53 | #include "cvmx-wqe.h" |
@@ -82,8 +83,10 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) | |||
82 | uint64_t old_scratch2; | 83 | uint64_t old_scratch2; |
83 | int dropped; | 84 | int dropped; |
84 | int qos; | 85 | int qos; |
86 | int queue_it_up; | ||
85 | struct octeon_ethernet *priv = netdev_priv(dev); | 87 | struct octeon_ethernet *priv = netdev_priv(dev); |
86 | int32_t in_use; | 88 | int32_t skb_to_free; |
89 | int32_t undo; | ||
87 | int32_t buffers_to_free; | 90 | int32_t buffers_to_free; |
88 | #if REUSE_SKBUFFS_WITHOUT_FREE | 91 | #if REUSE_SKBUFFS_WITHOUT_FREE |
89 | unsigned char *fpa_head; | 92 | unsigned char *fpa_head; |
@@ -120,15 +123,15 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) | |||
120 | old_scratch2 = cvmx_scratch_read64(CVMX_SCR_SCRATCH + 8); | 123 | old_scratch2 = cvmx_scratch_read64(CVMX_SCR_SCRATCH + 8); |
121 | 124 | ||
122 | /* | 125 | /* |
123 | * Assume we're going to be able t osend this | 126 | * Fetch and increment the number of packets to be |
124 | * packet. Fetch and increment the number of pending | 127 | * freed. |
125 | * packets for output. | ||
126 | */ | 128 | */ |
127 | cvmx_fau_async_fetch_and_add32(CVMX_SCR_SCRATCH + 8, | 129 | cvmx_fau_async_fetch_and_add32(CVMX_SCR_SCRATCH + 8, |
128 | FAU_NUM_PACKET_BUFFERS_TO_FREE, | 130 | FAU_NUM_PACKET_BUFFERS_TO_FREE, |
129 | 0); | 131 | 0); |
130 | cvmx_fau_async_fetch_and_add32(CVMX_SCR_SCRATCH, | 132 | cvmx_fau_async_fetch_and_add32(CVMX_SCR_SCRATCH, |
131 | priv->fau + qos * 4, 1); | 133 | priv->fau + qos * 4, |
134 | MAX_SKB_TO_FREE); | ||
132 | } | 135 | } |
133 | 136 | ||
134 | /* | 137 | /* |
@@ -253,10 +256,10 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) | |||
253 | 256 | ||
254 | /* | 257 | /* |
255 | * The skbuff will be reused without ever being freed. We must | 258 | * The skbuff will be reused without ever being freed. We must |
256 | * cleanup a bunch of Linux stuff. | 259 | * cleanup a bunch of core things. |
257 | */ | 260 | */ |
258 | dst_release(skb->dst); | 261 | dst_release(skb_dst(skb)); |
259 | skb->dst = NULL; | 262 | skb_dst_set(skb, NULL); |
260 | #ifdef CONFIG_XFRM | 263 | #ifdef CONFIG_XFRM |
261 | secpath_put(skb->sp); | 264 | secpath_put(skb->sp); |
262 | skb->sp = NULL; | 265 | skb->sp = NULL; |
@@ -286,16 +289,30 @@ dont_put_skbuff_in_hw: | |||
286 | if (USE_ASYNC_IOBDMA) { | 289 | if (USE_ASYNC_IOBDMA) { |
287 | /* Get the number of skbuffs in use by the hardware */ | 290 | /* Get the number of skbuffs in use by the hardware */ |
288 | CVMX_SYNCIOBDMA; | 291 | CVMX_SYNCIOBDMA; |
289 | in_use = cvmx_scratch_read64(CVMX_SCR_SCRATCH); | 292 | skb_to_free = cvmx_scratch_read64(CVMX_SCR_SCRATCH); |
290 | buffers_to_free = cvmx_scratch_read64(CVMX_SCR_SCRATCH + 8); | 293 | buffers_to_free = cvmx_scratch_read64(CVMX_SCR_SCRATCH + 8); |
291 | } else { | 294 | } else { |
292 | /* Get the number of skbuffs in use by the hardware */ | 295 | /* Get the number of skbuffs in use by the hardware */ |
293 | in_use = cvmx_fau_fetch_and_add32(priv->fau + qos * 4, 1); | 296 | skb_to_free = cvmx_fau_fetch_and_add32(priv->fau + qos * 4, |
297 | MAX_SKB_TO_FREE); | ||
294 | buffers_to_free = | 298 | buffers_to_free = |
295 | cvmx_fau_fetch_and_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0); | 299 | cvmx_fau_fetch_and_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0); |
296 | } | 300 | } |
297 | 301 | ||
298 | /* | 302 | /* |
303 | * We try to claim MAX_SKB_TO_FREE buffers. If there were not | ||
304 | * that many available, we have to un-claim (undo) any that | ||
305 | * were in excess. If skb_to_free is positive we will free | ||
306 | * that many buffers. | ||
307 | */ | ||
308 | undo = skb_to_free > 0 ? | ||
309 | MAX_SKB_TO_FREE : skb_to_free + MAX_SKB_TO_FREE; | ||
310 | if (undo > 0) | ||
311 | cvmx_fau_atomic_add32(priv->fau+qos*4, -undo); | ||
312 | skb_to_free = -skb_to_free > MAX_SKB_TO_FREE ? | ||
313 | MAX_SKB_TO_FREE : -skb_to_free; | ||
314 | |||
315 | /* | ||
299 | * If we're sending faster than the receive can free them then | 316 | * If we're sending faster than the receive can free them then |
300 | * don't do the HW free. | 317 | * don't do the HW free. |
301 | */ | 318 | */ |
@@ -330,38 +347,31 @@ dont_put_skbuff_in_hw: | |||
330 | cvmx_scratch_write64(CVMX_SCR_SCRATCH + 8, old_scratch2); | 347 | cvmx_scratch_write64(CVMX_SCR_SCRATCH + 8, old_scratch2); |
331 | } | 348 | } |
332 | 349 | ||
350 | queue_it_up = 0; | ||
333 | if (unlikely(dropped)) { | 351 | if (unlikely(dropped)) { |
334 | dev_kfree_skb_any(skb); | 352 | dev_kfree_skb_any(skb); |
335 | cvmx_fau_atomic_add32(priv->fau + qos * 4, -1); | ||
336 | priv->stats.tx_dropped++; | 353 | priv->stats.tx_dropped++; |
337 | } else { | 354 | } else { |
338 | if (USE_SKBUFFS_IN_HW) { | 355 | if (USE_SKBUFFS_IN_HW) { |
339 | /* Put this packet on the queue to be freed later */ | 356 | /* Put this packet on the queue to be freed later */ |
340 | if (pko_command.s.dontfree) | 357 | if (pko_command.s.dontfree) |
341 | skb_queue_tail(&priv->tx_free_list[qos], skb); | 358 | queue_it_up = 1; |
342 | else { | 359 | else |
343 | cvmx_fau_atomic_add32 | 360 | cvmx_fau_atomic_add32 |
344 | (FAU_NUM_PACKET_BUFFERS_TO_FREE, -1); | 361 | (FAU_NUM_PACKET_BUFFERS_TO_FREE, -1); |
345 | cvmx_fau_atomic_add32(priv->fau + qos * 4, -1); | ||
346 | } | ||
347 | } else { | 362 | } else { |
348 | /* Put this packet on the queue to be freed later */ | 363 | /* Put this packet on the queue to be freed later */ |
349 | skb_queue_tail(&priv->tx_free_list[qos], skb); | 364 | queue_it_up = 1; |
350 | } | 365 | } |
351 | } | 366 | } |
352 | 367 | ||
353 | /* Free skbuffs not in use by the hardware, possibly two at a time */ | 368 | if (queue_it_up) { |
354 | if (skb_queue_len(&priv->tx_free_list[qos]) > in_use) { | ||
355 | spin_lock(&priv->tx_free_list[qos].lock); | 369 | spin_lock(&priv->tx_free_list[qos].lock); |
356 | /* | 370 | __skb_queue_tail(&priv->tx_free_list[qos], skb); |
357 | * Check again now that we have the lock. It might | 371 | cvm_oct_free_tx_skbs(priv, skb_to_free, qos, 0); |
358 | * have changed. | ||
359 | */ | ||
360 | if (skb_queue_len(&priv->tx_free_list[qos]) > in_use) | ||
361 | dev_kfree_skb(__skb_dequeue(&priv->tx_free_list[qos])); | ||
362 | if (skb_queue_len(&priv->tx_free_list[qos]) > in_use) | ||
363 | dev_kfree_skb(__skb_dequeue(&priv->tx_free_list[qos])); | ||
364 | spin_unlock(&priv->tx_free_list[qos].lock); | 372 | spin_unlock(&priv->tx_free_list[qos].lock); |
373 | } else { | ||
374 | cvm_oct_free_tx_skbs(priv, skb_to_free, qos, 1); | ||
365 | } | 375 | } |
366 | 376 | ||
367 | return 0; | 377 | return 0; |
diff --git a/drivers/staging/octeon/ethernet-tx.h b/drivers/staging/octeon/ethernet-tx.h index 5106236fe981..c0bebf750bc0 100644 --- a/drivers/staging/octeon/ethernet-tx.h +++ b/drivers/staging/octeon/ethernet-tx.h | |||
@@ -30,3 +30,28 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev); | |||
30 | int cvm_oct_transmit_qos(struct net_device *dev, void *work_queue_entry, | 30 | int cvm_oct_transmit_qos(struct net_device *dev, void *work_queue_entry, |
31 | int do_free, int qos); | 31 | int do_free, int qos); |
32 | void cvm_oct_tx_shutdown(struct net_device *dev); | 32 | void cvm_oct_tx_shutdown(struct net_device *dev); |
33 | |||
34 | /** | ||
35 | * Free dead transmit skbs. | ||
36 | * | ||
37 | * @priv: The driver data | ||
38 | * @skb_to_free: The number of SKBs to free (free none if negative). | ||
39 | * @qos: The queue to free from. | ||
40 | * @take_lock: If true, acquire the skb list lock. | ||
41 | */ | ||
42 | static inline void cvm_oct_free_tx_skbs(struct octeon_ethernet *priv, | ||
43 | int skb_to_free, | ||
44 | int qos, int take_lock) | ||
45 | { | ||
46 | /* Free skbuffs not in use by the hardware. */ | ||
47 | if (skb_to_free > 0) { | ||
48 | if (take_lock) | ||
49 | spin_lock(&priv->tx_free_list[qos].lock); | ||
50 | while (skb_to_free > 0) { | ||
51 | dev_kfree_skb(__skb_dequeue(&priv->tx_free_list[qos])); | ||
52 | skb_to_free--; | ||
53 | } | ||
54 | if (take_lock) | ||
55 | spin_unlock(&priv->tx_free_list[qos].lock); | ||
56 | } | ||
57 | } | ||
diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index f08eb32e04fc..0c2e7cc40f35 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c | |||
@@ -33,14 +33,13 @@ | |||
33 | 33 | ||
34 | #include "ethernet-defines.h" | 34 | #include "ethernet-defines.h" |
35 | #include "octeon-ethernet.h" | 35 | #include "octeon-ethernet.h" |
36 | #include "ethernet-common.h" | ||
37 | #include "ethernet-util.h" | 36 | #include "ethernet-util.h" |
38 | 37 | ||
39 | #include "cvmx-helper.h" | 38 | #include "cvmx-helper.h" |
40 | 39 | ||
41 | #include "cvmx-gmxx-defs.h" | 40 | #include "cvmx-gmxx-defs.h" |
42 | 41 | ||
43 | static int cvm_oct_xaui_open(struct net_device *dev) | 42 | int cvm_oct_xaui_open(struct net_device *dev) |
44 | { | 43 | { |
45 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 44 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
46 | struct octeon_ethernet *priv = netdev_priv(dev); | 45 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -60,7 +59,7 @@ static int cvm_oct_xaui_open(struct net_device *dev) | |||
60 | return 0; | 59 | return 0; |
61 | } | 60 | } |
62 | 61 | ||
63 | static int cvm_oct_xaui_stop(struct net_device *dev) | 62 | int cvm_oct_xaui_stop(struct net_device *dev) |
64 | { | 63 | { |
65 | union cvmx_gmxx_prtx_cfg gmx_cfg; | 64 | union cvmx_gmxx_prtx_cfg gmx_cfg; |
66 | struct octeon_ethernet *priv = netdev_priv(dev); | 65 | struct octeon_ethernet *priv = netdev_priv(dev); |
@@ -112,9 +111,7 @@ int cvm_oct_xaui_init(struct net_device *dev) | |||
112 | { | 111 | { |
113 | struct octeon_ethernet *priv = netdev_priv(dev); | 112 | struct octeon_ethernet *priv = netdev_priv(dev); |
114 | cvm_oct_common_init(dev); | 113 | cvm_oct_common_init(dev); |
115 | dev->open = cvm_oct_xaui_open; | 114 | dev->netdev_ops->ndo_stop(dev); |
116 | dev->stop = cvm_oct_xaui_stop; | ||
117 | dev->stop(dev); | ||
118 | if (!octeon_is_simulation()) | 115 | if (!octeon_is_simulation()) |
119 | priv->poll = cvm_oct_xaui_poll; | 116 | priv->poll = cvm_oct_xaui_poll; |
120 | 117 | ||
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index e8ef9e0b791f..b8479517dce2 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c | |||
@@ -37,13 +37,14 @@ | |||
37 | #include <asm/octeon/octeon.h> | 37 | #include <asm/octeon/octeon.h> |
38 | 38 | ||
39 | #include "ethernet-defines.h" | 39 | #include "ethernet-defines.h" |
40 | #include "octeon-ethernet.h" | ||
40 | #include "ethernet-mem.h" | 41 | #include "ethernet-mem.h" |
41 | #include "ethernet-rx.h" | 42 | #include "ethernet-rx.h" |
42 | #include "ethernet-tx.h" | 43 | #include "ethernet-tx.h" |
44 | #include "ethernet-mdio.h" | ||
43 | #include "ethernet-util.h" | 45 | #include "ethernet-util.h" |
44 | #include "ethernet-proc.h" | 46 | #include "ethernet-proc.h" |
45 | #include "ethernet-common.h" | 47 | |
46 | #include "octeon-ethernet.h" | ||
47 | 48 | ||
48 | #include "cvmx-pip.h" | 49 | #include "cvmx-pip.h" |
49 | #include "cvmx-pko.h" | 50 | #include "cvmx-pko.h" |
@@ -51,6 +52,7 @@ | |||
51 | #include "cvmx-ipd.h" | 52 | #include "cvmx-ipd.h" |
52 | #include "cvmx-helper.h" | 53 | #include "cvmx-helper.h" |
53 | 54 | ||
55 | #include "cvmx-gmxx-defs.h" | ||
54 | #include "cvmx-smix-defs.h" | 56 | #include "cvmx-smix-defs.h" |
55 | 57 | ||
56 | #if defined(CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS) \ | 58 | #if defined(CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS) \ |
@@ -129,53 +131,55 @@ extern struct semaphore mdio_sem; | |||
129 | */ | 131 | */ |
130 | static void cvm_do_timer(unsigned long arg) | 132 | static void cvm_do_timer(unsigned long arg) |
131 | { | 133 | { |
134 | int32_t skb_to_free, undo; | ||
135 | int queues_per_port; | ||
136 | int qos; | ||
137 | struct octeon_ethernet *priv; | ||
132 | static int port; | 138 | static int port; |
133 | if (port < CVMX_PIP_NUM_INPUT_PORTS) { | ||
134 | if (cvm_oct_device[port]) { | ||
135 | int queues_per_port; | ||
136 | int qos; | ||
137 | struct octeon_ethernet *priv = | ||
138 | netdev_priv(cvm_oct_device[port]); | ||
139 | if (priv->poll) { | ||
140 | /* skip polling if we don't get the lock */ | ||
141 | if (!down_trylock(&mdio_sem)) { | ||
142 | priv->poll(cvm_oct_device[port]); | ||
143 | up(&mdio_sem); | ||
144 | } | ||
145 | } | ||
146 | 139 | ||
147 | queues_per_port = cvmx_pko_get_num_queues(port); | 140 | if (port >= CVMX_PIP_NUM_INPUT_PORTS) { |
148 | /* Drain any pending packets in the free list */ | 141 | /* |
149 | for (qos = 0; qos < queues_per_port; qos++) { | 142 | * All ports have been polled. Start the next |
150 | if (skb_queue_len(&priv->tx_free_list[qos])) { | 143 | * iteration through the ports in one second. |
151 | spin_lock(&priv->tx_free_list[qos]. | 144 | */ |
152 | lock); | ||
153 | while (skb_queue_len | ||
154 | (&priv->tx_free_list[qos]) > | ||
155 | cvmx_fau_fetch_and_add32(priv-> | ||
156 | fau + | ||
157 | qos * 4, | ||
158 | 0)) | ||
159 | dev_kfree_skb(__skb_dequeue | ||
160 | (&priv-> | ||
161 | tx_free_list | ||
162 | [qos])); | ||
163 | spin_unlock(&priv->tx_free_list[qos]. | ||
164 | lock); | ||
165 | } | ||
166 | } | ||
167 | cvm_oct_device[port]->get_stats(cvm_oct_device[port]); | ||
168 | } | ||
169 | port++; | ||
170 | /* Poll the next port in a 50th of a second. | ||
171 | This spreads the polling of ports out a little bit */ | ||
172 | mod_timer(&cvm_oct_poll_timer, jiffies + HZ / 50); | ||
173 | } else { | ||
174 | port = 0; | 145 | port = 0; |
175 | /* All ports have been polled. Start the next iteration through | ||
176 | the ports in one second */ | ||
177 | mod_timer(&cvm_oct_poll_timer, jiffies + HZ); | 146 | mod_timer(&cvm_oct_poll_timer, jiffies + HZ); |
147 | return; | ||
148 | } | ||
149 | if (!cvm_oct_device[port]) | ||
150 | goto out; | ||
151 | |||
152 | priv = netdev_priv(cvm_oct_device[port]); | ||
153 | if (priv->poll) { | ||
154 | /* skip polling if we don't get the lock */ | ||
155 | if (!down_trylock(&mdio_sem)) { | ||
156 | priv->poll(cvm_oct_device[port]); | ||
157 | up(&mdio_sem); | ||
158 | } | ||
178 | } | 159 | } |
160 | |||
161 | queues_per_port = cvmx_pko_get_num_queues(port); | ||
162 | /* Drain any pending packets in the free list */ | ||
163 | for (qos = 0; qos < queues_per_port; qos++) { | ||
164 | if (skb_queue_len(&priv->tx_free_list[qos]) == 0) | ||
165 | continue; | ||
166 | skb_to_free = cvmx_fau_fetch_and_add32(priv->fau + qos * 4, | ||
167 | MAX_SKB_TO_FREE); | ||
168 | undo = skb_to_free > 0 ? | ||
169 | MAX_SKB_TO_FREE : skb_to_free + MAX_SKB_TO_FREE; | ||
170 | if (undo > 0) | ||
171 | cvmx_fau_atomic_add32(priv->fau+qos*4, -undo); | ||
172 | skb_to_free = -skb_to_free > MAX_SKB_TO_FREE ? | ||
173 | MAX_SKB_TO_FREE : -skb_to_free; | ||
174 | cvm_oct_free_tx_skbs(priv, skb_to_free, qos, 1); | ||
175 | } | ||
176 | cvm_oct_device[port]->netdev_ops->ndo_get_stats(cvm_oct_device[port]); | ||
177 | |||
178 | out: | ||
179 | port++; | ||
180 | /* Poll the next port in a 50th of a second. | ||
181 | This spreads the polling of ports out a little bit */ | ||
182 | mod_timer(&cvm_oct_poll_timer, jiffies + HZ / 50); | ||
179 | } | 183 | } |
180 | 184 | ||
181 | /** | 185 | /** |
@@ -246,6 +250,362 @@ int cvm_oct_free_work(void *work_queue_entry) | |||
246 | EXPORT_SYMBOL(cvm_oct_free_work); | 250 | EXPORT_SYMBOL(cvm_oct_free_work); |
247 | 251 | ||
248 | /** | 252 | /** |
253 | * Get the low level ethernet statistics | ||
254 | * | ||
255 | * @dev: Device to get the statistics from | ||
256 | * Returns Pointer to the statistics | ||
257 | */ | ||
258 | static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev) | ||
259 | { | ||
260 | cvmx_pip_port_status_t rx_status; | ||
261 | cvmx_pko_port_status_t tx_status; | ||
262 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
263 | |||
264 | if (priv->port < CVMX_PIP_NUM_INPUT_PORTS) { | ||
265 | if (octeon_is_simulation()) { | ||
266 | /* The simulator doesn't support statistics */ | ||
267 | memset(&rx_status, 0, sizeof(rx_status)); | ||
268 | memset(&tx_status, 0, sizeof(tx_status)); | ||
269 | } else { | ||
270 | cvmx_pip_get_port_status(priv->port, 1, &rx_status); | ||
271 | cvmx_pko_get_port_status(priv->port, 1, &tx_status); | ||
272 | } | ||
273 | |||
274 | priv->stats.rx_packets += rx_status.inb_packets; | ||
275 | priv->stats.tx_packets += tx_status.packets; | ||
276 | priv->stats.rx_bytes += rx_status.inb_octets; | ||
277 | priv->stats.tx_bytes += tx_status.octets; | ||
278 | priv->stats.multicast += rx_status.multicast_packets; | ||
279 | priv->stats.rx_crc_errors += rx_status.inb_errors; | ||
280 | priv->stats.rx_frame_errors += rx_status.fcs_align_err_packets; | ||
281 | |||
282 | /* | ||
283 | * The drop counter must be incremented atomically | ||
284 | * since the RX tasklet also increments it. | ||
285 | */ | ||
286 | #ifdef CONFIG_64BIT | ||
287 | atomic64_add(rx_status.dropped_packets, | ||
288 | (atomic64_t *)&priv->stats.rx_dropped); | ||
289 | #else | ||
290 | atomic_add(rx_status.dropped_packets, | ||
291 | (atomic_t *)&priv->stats.rx_dropped); | ||
292 | #endif | ||
293 | } | ||
294 | |||
295 | return &priv->stats; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * Change the link MTU. Unimplemented | ||
300 | * | ||
301 | * @dev: Device to change | ||
302 | * @new_mtu: The new MTU | ||
303 | * | ||
304 | * Returns Zero on success | ||
305 | */ | ||
306 | static int cvm_oct_common_change_mtu(struct net_device *dev, int new_mtu) | ||
307 | { | ||
308 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
309 | int interface = INTERFACE(priv->port); | ||
310 | int index = INDEX(priv->port); | ||
311 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | ||
312 | int vlan_bytes = 4; | ||
313 | #else | ||
314 | int vlan_bytes = 0; | ||
315 | #endif | ||
316 | |||
317 | /* | ||
318 | * Limit the MTU to make sure the ethernet packets are between | ||
319 | * 64 bytes and 65535 bytes. | ||
320 | */ | ||
321 | if ((new_mtu + 14 + 4 + vlan_bytes < 64) | ||
322 | || (new_mtu + 14 + 4 + vlan_bytes > 65392)) { | ||
323 | pr_err("MTU must be between %d and %d.\n", | ||
324 | 64 - 14 - 4 - vlan_bytes, 65392 - 14 - 4 - vlan_bytes); | ||
325 | return -EINVAL; | ||
326 | } | ||
327 | dev->mtu = new_mtu; | ||
328 | |||
329 | if ((interface < 2) | ||
330 | && (cvmx_helper_interface_get_mode(interface) != | ||
331 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
332 | /* Add ethernet header and FCS, and VLAN if configured. */ | ||
333 | int max_packet = new_mtu + 14 + 4 + vlan_bytes; | ||
334 | |||
335 | if (OCTEON_IS_MODEL(OCTEON_CN3XXX) | ||
336 | || OCTEON_IS_MODEL(OCTEON_CN58XX)) { | ||
337 | /* Signal errors on packets larger than the MTU */ | ||
338 | cvmx_write_csr(CVMX_GMXX_RXX_FRM_MAX(index, interface), | ||
339 | max_packet); | ||
340 | } else { | ||
341 | /* | ||
342 | * Set the hardware to truncate packets larger | ||
343 | * than the MTU and smaller the 64 bytes. | ||
344 | */ | ||
345 | union cvmx_pip_frm_len_chkx frm_len_chk; | ||
346 | frm_len_chk.u64 = 0; | ||
347 | frm_len_chk.s.minlen = 64; | ||
348 | frm_len_chk.s.maxlen = max_packet; | ||
349 | cvmx_write_csr(CVMX_PIP_FRM_LEN_CHKX(interface), | ||
350 | frm_len_chk.u64); | ||
351 | } | ||
352 | /* | ||
353 | * Set the hardware to truncate packets larger than | ||
354 | * the MTU. The jabber register must be set to a | ||
355 | * multiple of 8 bytes, so round up. | ||
356 | */ | ||
357 | cvmx_write_csr(CVMX_GMXX_RXX_JABBER(index, interface), | ||
358 | (max_packet + 7) & ~7u); | ||
359 | } | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Set the multicast list. Currently unimplemented. | ||
365 | * | ||
366 | * @dev: Device to work on | ||
367 | */ | ||
368 | static void cvm_oct_common_set_multicast_list(struct net_device *dev) | ||
369 | { | ||
370 | union cvmx_gmxx_prtx_cfg gmx_cfg; | ||
371 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
372 | int interface = INTERFACE(priv->port); | ||
373 | int index = INDEX(priv->port); | ||
374 | |||
375 | if ((interface < 2) | ||
376 | && (cvmx_helper_interface_get_mode(interface) != | ||
377 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
378 | union cvmx_gmxx_rxx_adr_ctl control; | ||
379 | control.u64 = 0; | ||
380 | control.s.bcst = 1; /* Allow broadcast MAC addresses */ | ||
381 | |||
382 | if (dev->mc_list || (dev->flags & IFF_ALLMULTI) || | ||
383 | (dev->flags & IFF_PROMISC)) | ||
384 | /* Force accept multicast packets */ | ||
385 | control.s.mcst = 2; | ||
386 | else | ||
387 | /* Force reject multicat packets */ | ||
388 | control.s.mcst = 1; | ||
389 | |||
390 | if (dev->flags & IFF_PROMISC) | ||
391 | /* | ||
392 | * Reject matches if promisc. Since CAM is | ||
393 | * shut off, should accept everything. | ||
394 | */ | ||
395 | control.s.cam_mode = 0; | ||
396 | else | ||
397 | /* Filter packets based on the CAM */ | ||
398 | control.s.cam_mode = 1; | ||
399 | |||
400 | gmx_cfg.u64 = | ||
401 | cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); | ||
402 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
403 | gmx_cfg.u64 & ~1ull); | ||
404 | |||
405 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CTL(index, interface), | ||
406 | control.u64); | ||
407 | if (dev->flags & IFF_PROMISC) | ||
408 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN | ||
409 | (index, interface), 0); | ||
410 | else | ||
411 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN | ||
412 | (index, interface), 1); | ||
413 | |||
414 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
415 | gmx_cfg.u64); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Set the hardware MAC address for a device | ||
421 | * | ||
422 | * @dev: Device to change the MAC address for | ||
423 | * @addr: Address structure to change it too. MAC address is addr + 2. | ||
424 | * Returns Zero on success | ||
425 | */ | ||
426 | static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr) | ||
427 | { | ||
428 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
429 | union cvmx_gmxx_prtx_cfg gmx_cfg; | ||
430 | int interface = INTERFACE(priv->port); | ||
431 | int index = INDEX(priv->port); | ||
432 | |||
433 | memcpy(dev->dev_addr, addr + 2, 6); | ||
434 | |||
435 | if ((interface < 2) | ||
436 | && (cvmx_helper_interface_get_mode(interface) != | ||
437 | CVMX_HELPER_INTERFACE_MODE_SPI)) { | ||
438 | int i; | ||
439 | uint8_t *ptr = addr; | ||
440 | uint64_t mac = 0; | ||
441 | for (i = 0; i < 6; i++) | ||
442 | mac = (mac << 8) | (uint64_t) (ptr[i + 2]); | ||
443 | |||
444 | gmx_cfg.u64 = | ||
445 | cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); | ||
446 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
447 | gmx_cfg.u64 & ~1ull); | ||
448 | |||
449 | cvmx_write_csr(CVMX_GMXX_SMACX(index, interface), mac); | ||
450 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM0(index, interface), | ||
451 | ptr[2]); | ||
452 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM1(index, interface), | ||
453 | ptr[3]); | ||
454 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM2(index, interface), | ||
455 | ptr[4]); | ||
456 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM3(index, interface), | ||
457 | ptr[5]); | ||
458 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM4(index, interface), | ||
459 | ptr[6]); | ||
460 | cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM5(index, interface), | ||
461 | ptr[7]); | ||
462 | cvm_oct_common_set_multicast_list(dev); | ||
463 | cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), | ||
464 | gmx_cfg.u64); | ||
465 | } | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | /** | ||
470 | * Per network device initialization | ||
471 | * | ||
472 | * @dev: Device to initialize | ||
473 | * Returns Zero on success | ||
474 | */ | ||
475 | int cvm_oct_common_init(struct net_device *dev) | ||
476 | { | ||
477 | static int count; | ||
478 | char mac[8] = { 0x00, 0x00, | ||
479 | octeon_bootinfo->mac_addr_base[0], | ||
480 | octeon_bootinfo->mac_addr_base[1], | ||
481 | octeon_bootinfo->mac_addr_base[2], | ||
482 | octeon_bootinfo->mac_addr_base[3], | ||
483 | octeon_bootinfo->mac_addr_base[4], | ||
484 | octeon_bootinfo->mac_addr_base[5] + count | ||
485 | }; | ||
486 | struct octeon_ethernet *priv = netdev_priv(dev); | ||
487 | |||
488 | /* | ||
489 | * Force the interface to use the POW send if always_use_pow | ||
490 | * was specified or it is in the pow send list. | ||
491 | */ | ||
492 | if ((pow_send_group != -1) | ||
493 | && (always_use_pow || strstr(pow_send_list, dev->name))) | ||
494 | priv->queue = -1; | ||
495 | |||
496 | if (priv->queue != -1 && USE_HW_TCPUDP_CHECKSUM) | ||
497 | dev->features |= NETIF_F_IP_CSUM; | ||
498 | |||
499 | count++; | ||
500 | |||
501 | /* We do our own locking, Linux doesn't need to */ | ||
502 | dev->features |= NETIF_F_LLTX; | ||
503 | SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops); | ||
504 | |||
505 | cvm_oct_mdio_setup_device(dev); | ||
506 | dev->netdev_ops->ndo_set_mac_address(dev, mac); | ||
507 | dev->netdev_ops->ndo_change_mtu(dev, dev->mtu); | ||
508 | |||
509 | /* | ||
510 | * Zero out stats for port so we won't mistakenly show | ||
511 | * counters from the bootloader. | ||
512 | */ | ||
513 | memset(dev->netdev_ops->ndo_get_stats(dev), 0, | ||
514 | sizeof(struct net_device_stats)); | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | void cvm_oct_common_uninit(struct net_device *dev) | ||
520 | { | ||
521 | /* Currently nothing to do */ | ||
522 | } | ||
523 | |||
524 | static const struct net_device_ops cvm_oct_npi_netdev_ops = { | ||
525 | .ndo_init = cvm_oct_common_init, | ||
526 | .ndo_uninit = cvm_oct_common_uninit, | ||
527 | .ndo_start_xmit = cvm_oct_xmit, | ||
528 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
529 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
530 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
531 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
532 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
533 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
534 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
535 | #endif | ||
536 | }; | ||
537 | static const struct net_device_ops cvm_oct_xaui_netdev_ops = { | ||
538 | .ndo_init = cvm_oct_xaui_init, | ||
539 | .ndo_uninit = cvm_oct_xaui_uninit, | ||
540 | .ndo_open = cvm_oct_xaui_open, | ||
541 | .ndo_stop = cvm_oct_xaui_stop, | ||
542 | .ndo_start_xmit = cvm_oct_xmit, | ||
543 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
544 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
545 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
546 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
547 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
548 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
549 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
550 | #endif | ||
551 | }; | ||
552 | static const struct net_device_ops cvm_oct_sgmii_netdev_ops = { | ||
553 | .ndo_init = cvm_oct_sgmii_init, | ||
554 | .ndo_uninit = cvm_oct_sgmii_uninit, | ||
555 | .ndo_open = cvm_oct_sgmii_open, | ||
556 | .ndo_stop = cvm_oct_sgmii_stop, | ||
557 | .ndo_start_xmit = cvm_oct_xmit, | ||
558 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
559 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
560 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
561 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
562 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
563 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
564 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
565 | #endif | ||
566 | }; | ||
567 | static const struct net_device_ops cvm_oct_spi_netdev_ops = { | ||
568 | .ndo_init = cvm_oct_spi_init, | ||
569 | .ndo_uninit = cvm_oct_spi_uninit, | ||
570 | .ndo_start_xmit = cvm_oct_xmit, | ||
571 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
572 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
573 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
574 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
575 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
576 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
577 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
578 | #endif | ||
579 | }; | ||
580 | static const struct net_device_ops cvm_oct_rgmii_netdev_ops = { | ||
581 | .ndo_init = cvm_oct_rgmii_init, | ||
582 | .ndo_uninit = cvm_oct_rgmii_uninit, | ||
583 | .ndo_open = cvm_oct_rgmii_open, | ||
584 | .ndo_stop = cvm_oct_rgmii_stop, | ||
585 | .ndo_start_xmit = cvm_oct_xmit, | ||
586 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
587 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
588 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
589 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
590 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
591 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
592 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
593 | #endif | ||
594 | }; | ||
595 | static const struct net_device_ops cvm_oct_pow_netdev_ops = { | ||
596 | .ndo_init = cvm_oct_common_init, | ||
597 | .ndo_start_xmit = cvm_oct_xmit_pow, | ||
598 | .ndo_set_multicast_list = cvm_oct_common_set_multicast_list, | ||
599 | .ndo_set_mac_address = cvm_oct_common_set_mac_address, | ||
600 | .ndo_do_ioctl = cvm_oct_ioctl, | ||
601 | .ndo_change_mtu = cvm_oct_common_change_mtu, | ||
602 | .ndo_get_stats = cvm_oct_common_get_stats, | ||
603 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
604 | .ndo_poll_controller = cvm_oct_poll_controller, | ||
605 | #endif | ||
606 | }; | ||
607 | |||
608 | /** | ||
249 | * Module/ driver initialization. Creates the linux network | 609 | * Module/ driver initialization. Creates the linux network |
250 | * devices. | 610 | * devices. |
251 | * | 611 | * |
@@ -303,7 +663,7 @@ static int __init cvm_oct_init_module(void) | |||
303 | struct octeon_ethernet *priv = netdev_priv(dev); | 663 | struct octeon_ethernet *priv = netdev_priv(dev); |
304 | memset(priv, 0, sizeof(struct octeon_ethernet)); | 664 | memset(priv, 0, sizeof(struct octeon_ethernet)); |
305 | 665 | ||
306 | dev->init = cvm_oct_common_init; | 666 | dev->netdev_ops = &cvm_oct_pow_netdev_ops; |
307 | priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; | 667 | priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; |
308 | priv->port = CVMX_PIP_NUM_INPUT_PORTS; | 668 | priv->port = CVMX_PIP_NUM_INPUT_PORTS; |
309 | priv->queue = -1; | 669 | priv->queue = -1; |
@@ -372,44 +732,38 @@ static int __init cvm_oct_init_module(void) | |||
372 | break; | 732 | break; |
373 | 733 | ||
374 | case CVMX_HELPER_INTERFACE_MODE_NPI: | 734 | case CVMX_HELPER_INTERFACE_MODE_NPI: |
375 | dev->init = cvm_oct_common_init; | 735 | dev->netdev_ops = &cvm_oct_npi_netdev_ops; |
376 | dev->uninit = cvm_oct_common_uninit; | ||
377 | strcpy(dev->name, "npi%d"); | 736 | strcpy(dev->name, "npi%d"); |
378 | break; | 737 | break; |
379 | 738 | ||
380 | case CVMX_HELPER_INTERFACE_MODE_XAUI: | 739 | case CVMX_HELPER_INTERFACE_MODE_XAUI: |
381 | dev->init = cvm_oct_xaui_init; | 740 | dev->netdev_ops = &cvm_oct_xaui_netdev_ops; |
382 | dev->uninit = cvm_oct_xaui_uninit; | ||
383 | strcpy(dev->name, "xaui%d"); | 741 | strcpy(dev->name, "xaui%d"); |
384 | break; | 742 | break; |
385 | 743 | ||
386 | case CVMX_HELPER_INTERFACE_MODE_LOOP: | 744 | case CVMX_HELPER_INTERFACE_MODE_LOOP: |
387 | dev->init = cvm_oct_common_init; | 745 | dev->netdev_ops = &cvm_oct_npi_netdev_ops; |
388 | dev->uninit = cvm_oct_common_uninit; | ||
389 | strcpy(dev->name, "loop%d"); | 746 | strcpy(dev->name, "loop%d"); |
390 | break; | 747 | break; |
391 | 748 | ||
392 | case CVMX_HELPER_INTERFACE_MODE_SGMII: | 749 | case CVMX_HELPER_INTERFACE_MODE_SGMII: |
393 | dev->init = cvm_oct_sgmii_init; | 750 | dev->netdev_ops = &cvm_oct_sgmii_netdev_ops; |
394 | dev->uninit = cvm_oct_sgmii_uninit; | ||
395 | strcpy(dev->name, "eth%d"); | 751 | strcpy(dev->name, "eth%d"); |
396 | break; | 752 | break; |
397 | 753 | ||
398 | case CVMX_HELPER_INTERFACE_MODE_SPI: | 754 | case CVMX_HELPER_INTERFACE_MODE_SPI: |
399 | dev->init = cvm_oct_spi_init; | 755 | dev->netdev_ops = &cvm_oct_spi_netdev_ops; |
400 | dev->uninit = cvm_oct_spi_uninit; | ||
401 | strcpy(dev->name, "spi%d"); | 756 | strcpy(dev->name, "spi%d"); |
402 | break; | 757 | break; |
403 | 758 | ||
404 | case CVMX_HELPER_INTERFACE_MODE_RGMII: | 759 | case CVMX_HELPER_INTERFACE_MODE_RGMII: |
405 | case CVMX_HELPER_INTERFACE_MODE_GMII: | 760 | case CVMX_HELPER_INTERFACE_MODE_GMII: |
406 | dev->init = cvm_oct_rgmii_init; | 761 | dev->netdev_ops = &cvm_oct_rgmii_netdev_ops; |
407 | dev->uninit = cvm_oct_rgmii_uninit; | ||
408 | strcpy(dev->name, "eth%d"); | 762 | strcpy(dev->name, "eth%d"); |
409 | break; | 763 | break; |
410 | } | 764 | } |
411 | 765 | ||
412 | if (!dev->init) { | 766 | if (!dev->netdev_ops) { |
413 | kfree(dev); | 767 | kfree(dev); |
414 | } else if (register_netdev(dev) < 0) { | 768 | } else if (register_netdev(dev) < 0) { |
415 | pr_err("Failed to register ethernet device " | 769 | pr_err("Failed to register ethernet device " |
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index b3199076ef5e..3aef9878fc0a 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h | |||
@@ -111,12 +111,23 @@ static inline int cvm_oct_transmit(struct net_device *dev, | |||
111 | 111 | ||
112 | extern int cvm_oct_rgmii_init(struct net_device *dev); | 112 | extern int cvm_oct_rgmii_init(struct net_device *dev); |
113 | extern void cvm_oct_rgmii_uninit(struct net_device *dev); | 113 | extern void cvm_oct_rgmii_uninit(struct net_device *dev); |
114 | extern int cvm_oct_rgmii_open(struct net_device *dev); | ||
115 | extern int cvm_oct_rgmii_stop(struct net_device *dev); | ||
116 | |||
114 | extern int cvm_oct_sgmii_init(struct net_device *dev); | 117 | extern int cvm_oct_sgmii_init(struct net_device *dev); |
115 | extern void cvm_oct_sgmii_uninit(struct net_device *dev); | 118 | extern void cvm_oct_sgmii_uninit(struct net_device *dev); |
119 | extern int cvm_oct_sgmii_open(struct net_device *dev); | ||
120 | extern int cvm_oct_sgmii_stop(struct net_device *dev); | ||
121 | |||
116 | extern int cvm_oct_spi_init(struct net_device *dev); | 122 | extern int cvm_oct_spi_init(struct net_device *dev); |
117 | extern void cvm_oct_spi_uninit(struct net_device *dev); | 123 | extern void cvm_oct_spi_uninit(struct net_device *dev); |
118 | extern int cvm_oct_xaui_init(struct net_device *dev); | 124 | extern int cvm_oct_xaui_init(struct net_device *dev); |
119 | extern void cvm_oct_xaui_uninit(struct net_device *dev); | 125 | extern void cvm_oct_xaui_uninit(struct net_device *dev); |
126 | extern int cvm_oct_xaui_open(struct net_device *dev); | ||
127 | extern int cvm_oct_xaui_stop(struct net_device *dev); | ||
128 | |||
129 | extern int cvm_oct_common_init(struct net_device *dev); | ||
130 | extern void cvm_oct_common_uninit(struct net_device *dev); | ||
120 | 131 | ||
121 | extern int always_use_pow; | 132 | extern int always_use_pow; |
122 | extern int pow_send_group; | 133 | extern int pow_send_group; |