1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40/** 41 * @file 42 * 43 * Header file for the hotplug APIs 44 * 45 * <hr>$Revision: $<hr> 46 */ 47 48#ifndef __CVMX_APP_HOTPLUG_H__ 49#define __CVMX_APP_HOTPLUG_H__ 50 51#ifdef __cplusplus 52extern "C" { 53#endif 54 55#ifdef CVMX_BUILD_FOR_LINUX_KERNEL 56#include <asm/octeon/cvmx.h> 57#include <asm/octeon/cvmx-bootmem.h> 58#include <asm/octeon/cvmx-spinlock.h> 59#else 60#include "cvmx.h" 61#include "cvmx-coremask.h" 62#include "cvmx-interrupt.h" 63#include "cvmx-bootmem.h" 64#include "cvmx-spinlock.h" 65#endif 66 67#define CVMX_APP_HOTPLUG_MAX_APPS 32 68#define CVMX_APP_HOTPLUG_MAX_APPNAME_LEN 256 69 70/** 71* hotplug_start is the entry point for hot plugged cores. 72* cores_added_callback is callback which in invoked when new cores are added 73* to the application. This is invoked on all the old core 74* that existed before the current set of cores were 75* added. 76* cores_removed_callback is callback which in invoked when cores are removed 77* an application. This is invoked on all the cores that 78* exist after the set of cores being requesed are 79* removed. 80* shutdown_done_callback before the application is shutdown this callback is 81* invoked on all the cores that are part of the app. 82* unplug_callback before the cores are unplugged this callback is invoked 83* only on the cores that are being unlpuuged. 84*/ 85typedef struct cvmx_app_hotplug_callbacks 86{ 87 void (*hotplug_start)(void *ptr); 88 void (*cores_added_callback) (uint32_t ,void *ptr); 89 void (*cores_removed_callback) (uint32_t,void *ptr); 90 void (*shutdown_callback) (void *ptr); 91 void (*unplug_core_callback) (void *ptr); 92} cvmx_app_hotplug_callbacks_t; 93 94/* The size of this struct should be a fixed size of 1024 bytes. 95 Additional members should be added towards the end of the 96 strcuture by adjusting the size of padding */ 97typedef struct cvmx_app_hotplug_info 98{ 99 char app_name[CVMX_APP_HOTPLUG_MAX_APPNAME_LEN]; 100 uint32_t coremask; 101 uint32_t volatile hotplug_activated_coremask; 102 int32_t valid; 103 int32_t volatile shutdown_done; 104 uint64_t shutdown_callback; 105 uint64_t unplug_callback; 106 uint64_t cores_added_callback; 107 uint64_t cores_removed_callback; 108 uint64_t hotplug_start; 109 uint64_t data; 110 uint32_t volatile hplugged_cores; 111 uint32_t shutdown_cores; 112 uint32_t app_shutdown; 113 uint32_t unplug_cores; 114 uint32_t padding[172]; 115} cvmx_app_hotplug_info_t; 116 117struct cvmx_app_hotplug_global 118{ 119 uint32_t avail_coremask; 120 cvmx_app_hotplug_info_t hotplug_info_array[CVMX_APP_HOTPLUG_MAX_APPS]; 121 uint32_t version; 122 cvmx_spinlock_t hotplug_global_lock; 123 int app_under_boot; 124 int app_under_shutdown; 125}; 126typedef struct cvmx_app_hotplug_global cvmx_app_hotplug_global_t; 127 128int is_core_being_hot_plugged(void); 129int is_app_being_booted_or_shutdown(void); 130void set_app_unber_boot(int val); 131void set_app_under_shutdown(int val); 132int cvmx_app_hotplug_shutdown_request(uint32_t, int); 133int cvmx_app_hotplug_unplug_cores(int index, uint32_t coremask, int wait); 134cvmx_app_hotplug_info_t* cvmx_app_hotplug_get_info(uint32_t); 135int cvmx_app_hotplug_get_index(uint32_t coremask); 136cvmx_app_hotplug_info_t* cvmx_app_hotplug_get_info_at_index(int index); 137int is_app_hotpluggable(int index); 138int cvmx_app_hotplug_call_add_cores_callback(int index); 139#ifndef CVMX_BUILD_FOR_LINUX_USER 140int cvmx_app_hotplug_register(void(*)(void*), void*); 141int cvmx_app_hotplug_register_cb(cvmx_app_hotplug_callbacks_t *, void*, int); 142int cvmx_app_hotplug_activate(void); 143void cvmx_app_hotplug_core_shutdown(void); 144void cvmx_app_hotplug_shutdown_disable(void); 145void cvmx_app_hotplug_shutdown_enable(void); 146#endif 147 148#define CVMX_APP_HOTPLUG_INFO_REGION_SIZE sizeof(cvmx_app_hotplug_global_t) 149#define CVMX_APP_HOTPLUG_INFO_REGION_NAME "cvmx-app-hotplug-block" 150 151#ifdef __cplusplus 152} 153#endif 154 155#endif /* __CVMX_APP_HOTPLUG_H__ */ 156