cvmx-app-hotplug.h revision 232812
1215976Sjmallett/***********************license start*************** 2232812Sjmallett * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights 3215976Sjmallett * reserved. 4215976Sjmallett * 5215976Sjmallett * 6215976Sjmallett * Redistribution and use in source and binary forms, with or without 7215976Sjmallett * modification, are permitted provided that the following conditions are 8215976Sjmallett * met: 9215976Sjmallett * 10215976Sjmallett * * Redistributions of source code must retain the above copyright 11215976Sjmallett * notice, this list of conditions and the following disclaimer. 12215976Sjmallett * 13215976Sjmallett * * Redistributions in binary form must reproduce the above 14215976Sjmallett * copyright notice, this list of conditions and the following 15215976Sjmallett * disclaimer in the documentation and/or other materials provided 16215976Sjmallett * with the distribution. 17215976Sjmallett 18232812Sjmallett * * Neither the name of Cavium Inc. nor the names of 19215976Sjmallett * its contributors may be used to endorse or promote products 20215976Sjmallett * derived from this software without specific prior written 21215976Sjmallett * permission. 22215976Sjmallett 23215976Sjmallett * This Software, including technical data, may be subject to U.S. export control 24215976Sjmallett * laws, including the U.S. Export Administration Act and its associated 25215976Sjmallett * regulations, and may be subject to export or import regulations in other 26215976Sjmallett * countries. 27215976Sjmallett 28215976Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30215976Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31215976Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32215976Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33215976Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34215976Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35215976Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36215976Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37215976Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38215976Sjmallett ***********************license end**************************************/ 39215976Sjmallett 40215976Sjmallett/** 41215976Sjmallett * @file 42215976Sjmallett * 43215976Sjmallett * Header file for the hotplug APIs 44215976Sjmallett * 45215976Sjmallett * <hr>$Revision: $<hr> 46215976Sjmallett */ 47215976Sjmallett 48215976Sjmallett#ifndef __CVMX_APP_HOTPLUG_H__ 49215976Sjmallett#define __CVMX_APP_HOTPLUG_H__ 50215976Sjmallett 51232812Sjmallett#ifdef __cplusplus 52215976Sjmallettextern "C" { 53215976Sjmallett#endif 54215976Sjmallett 55215976Sjmallett#ifdef CVMX_BUILD_FOR_LINUX_KERNEL 56215976Sjmallett#include <asm/octeon/cvmx.h> 57215976Sjmallett#include <asm/octeon/cvmx-bootmem.h> 58232812Sjmallett#include <asm/octeon/cvmx-spinlock.h> 59215976Sjmallett#else 60215976Sjmallett#include "cvmx.h" 61215976Sjmallett#include "cvmx-coremask.h" 62215976Sjmallett#include "cvmx-interrupt.h" 63215976Sjmallett#include "cvmx-bootmem.h" 64232812Sjmallett#include "cvmx-spinlock.h" 65215976Sjmallett#endif 66215976Sjmallett 67215976Sjmallett#define CVMX_APP_HOTPLUG_MAX_APPS 32 68215976Sjmallett#define CVMX_APP_HOTPLUG_MAX_APPNAME_LEN 256 69215976Sjmallett 70232812Sjmallett/** 71232812Sjmallett* hotplug_start is the entry point for hot plugged cores. 72232812Sjmallett* cores_added_callback is callback which in invoked when new cores are added 73232812Sjmallett* to the application. This is invoked on all the old core 74232812Sjmallett* that existed before the current set of cores were 75232812Sjmallett* added. 76232812Sjmallett* cores_removed_callback is callback which in invoked when cores are removed 77232812Sjmallett* an application. This is invoked on all the cores that 78232812Sjmallett* exist after the set of cores being requesed are 79232812Sjmallett* removed. 80232812Sjmallett* shutdown_done_callback before the application is shutdown this callback is 81232812Sjmallett* invoked on all the cores that are part of the app. 82232812Sjmallett* unplug_callback before the cores are unplugged this callback is invoked 83232812Sjmallett* only on the cores that are being unlpuuged. 84232812Sjmallett*/ 85232812Sjmalletttypedef struct cvmx_app_hotplug_callbacks 86232812Sjmallett{ 87232812Sjmallett void (*hotplug_start)(void *ptr); 88232812Sjmallett void (*cores_added_callback) (uint32_t ,void *ptr); 89232812Sjmallett void (*cores_removed_callback) (uint32_t,void *ptr); 90232812Sjmallett void (*shutdown_callback) (void *ptr); 91232812Sjmallett void (*unplug_core_callback) (void *ptr); 92232812Sjmallett} cvmx_app_hotplug_callbacks_t; 93232812Sjmallett 94232812Sjmallett/* The size of this struct should be a fixed size of 1024 bytes. 95232812Sjmallett Additional members should be added towards the end of the 96232812Sjmallett strcuture by adjusting the size of padding */ 97215976Sjmalletttypedef struct cvmx_app_hotplug_info 98215976Sjmallett{ 99232812Sjmallett char app_name[CVMX_APP_HOTPLUG_MAX_APPNAME_LEN]; 100232812Sjmallett uint32_t coremask; 101232812Sjmallett uint32_t volatile hotplug_activated_coremask; 102232812Sjmallett int32_t valid; 103232812Sjmallett int32_t volatile shutdown_done; 104232812Sjmallett uint64_t shutdown_callback; 105232812Sjmallett uint64_t unplug_callback; 106232812Sjmallett uint64_t cores_added_callback; 107232812Sjmallett uint64_t cores_removed_callback; 108232812Sjmallett uint64_t hotplug_start; 109232812Sjmallett uint64_t data; 110232812Sjmallett uint32_t volatile hplugged_cores; 111232812Sjmallett uint32_t shutdown_cores; 112232812Sjmallett uint32_t app_shutdown; 113232812Sjmallett uint32_t unplug_cores; 114232812Sjmallett uint32_t padding[172]; 115215976Sjmallett} cvmx_app_hotplug_info_t; 116215976Sjmallett 117215976Sjmallettstruct cvmx_app_hotplug_global 118215976Sjmallett{ 119215976Sjmallett uint32_t avail_coremask; 120215976Sjmallett cvmx_app_hotplug_info_t hotplug_info_array[CVMX_APP_HOTPLUG_MAX_APPS]; 121232812Sjmallett uint32_t version; 122232812Sjmallett cvmx_spinlock_t hotplug_global_lock; 123232812Sjmallett int app_under_boot; 124232812Sjmallett int app_under_shutdown; 125215976Sjmallett}; 126215976Sjmalletttypedef struct cvmx_app_hotplug_global cvmx_app_hotplug_global_t; 127215976Sjmallett 128232812Sjmallettint is_core_being_hot_plugged(void); 129232812Sjmallettint is_app_being_booted_or_shutdown(void); 130232812Sjmallettvoid set_app_unber_boot(int val); 131232812Sjmallettvoid set_app_under_shutdown(int val); 132215976Sjmallettint cvmx_app_hotplug_shutdown_request(uint32_t, int); 133232812Sjmallettint cvmx_app_hotplug_unplug_cores(int index, uint32_t coremask, int wait); 134215976Sjmallettcvmx_app_hotplug_info_t* cvmx_app_hotplug_get_info(uint32_t); 135232812Sjmallettint cvmx_app_hotplug_get_index(uint32_t coremask); 136232812Sjmallettcvmx_app_hotplug_info_t* cvmx_app_hotplug_get_info_at_index(int index); 137232812Sjmallettint is_app_hotpluggable(int index); 138232812Sjmallettint cvmx_app_hotplug_call_add_cores_callback(int index); 139215976Sjmallett#ifndef CVMX_BUILD_FOR_LINUX_USER 140215976Sjmallettint cvmx_app_hotplug_register(void(*)(void*), void*); 141232812Sjmallettint cvmx_app_hotplug_register_cb(cvmx_app_hotplug_callbacks_t *, void*, int); 142215976Sjmallettint cvmx_app_hotplug_activate(void); 143232812Sjmallettvoid cvmx_app_hotplug_core_shutdown(void); 144215976Sjmallettvoid cvmx_app_hotplug_shutdown_disable(void); 145215976Sjmallettvoid cvmx_app_hotplug_shutdown_enable(void); 146215976Sjmallett#endif 147215976Sjmallett 148215976Sjmallett#define CVMX_APP_HOTPLUG_INFO_REGION_SIZE sizeof(cvmx_app_hotplug_global_t) 149215976Sjmallett#define CVMX_APP_HOTPLUG_INFO_REGION_NAME "cvmx-app-hotplug-block" 150215976Sjmallett 151232812Sjmallett#ifdef __cplusplus 152215976Sjmallett} 153215976Sjmallett#endif 154215976Sjmallett 155215976Sjmallett#endif /* __CVMX_APP_HOTPLUG_H__ */ 156