1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2018 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #ifndef _FLCNABLE_NVSWITCH_H_ 25 #define _FLCNABLE_NVSWITCH_H_ 26 27 /*! 28 * @file flcnable_nvswitch.h 29 * @brief Provides definitions for all FLCNABLE data structures and interfaces. 30 */ 31 32 #include "flcn/haldefs_flcnable_nvswitch.h" 33 34 #include "flcnifcmn.h" 35 36 #include "nvlink_errors.h" 37 38 struct nvswitch_device; 39 struct FLCN; 40 struct FALCON_EXTERNAL_CONFIG; 41 struct FLCN_QMGR_SEQ_INFO; 42 union RM_FLCN_MSG; 43 union RM_FLCN_CMD; 44 struct ENGINE_DESCRIPTOR_TYPE; 45 46 /*! 47 * Defines the structure used to contain all generic information related to 48 * the FLCNABLE. 49 */ 50 typedef struct FLCNABLE 51 { 52 // pointer to our function table - should always be the first thing in any object 53 flcnable_hal *pHal; 54 // we don't have a parent class, so we go straight to our members 55 56 /* Pointer to FLCN object for the object represented by this FLCNABLE */ 57 struct FLCN *pFlcn; 58 59 } FLCNABLE, *PFLCNABLE; 60 61 NvlStatus flcnableInit(struct nvswitch_device *device, PFLCNABLE pFlcnable, NvU32 pci_device_id); 62 void flcnableDestroy(struct nvswitch_device *device, PFLCNABLE pFlcnable); 63 64 /*! 65 * Utility to get the FLCN object for the engine 66 */ 67 #define ENG_GET_FLCN(pObj) (((PFLCNABLE)pObj)->pFlcn) 68 69 /*! 70 * Safe (from NULL parent) version of utility to get the FLCN object for the engine 71 */ 72 #define ENG_GET_FLCN_IFF(pObj) ((NULL!=(pObj))?ENG_GET_FLCN(pObj):NULL) 73 74 // hal functions 75 NvU8 flcnableReadCoreRev (struct nvswitch_device *device, PFLCNABLE); 76 void flcnableGetExternalConfig (struct nvswitch_device *device, PFLCNABLE, struct FALCON_EXTERNAL_CONFIG *); 77 void flcnableEmemCopyFrom (struct nvswitch_device *device, PFLCNABLE, NvU32, NvU8 *, NvU32, NvU8); 78 void flcnableEmemCopyTo (struct nvswitch_device *device, PFLCNABLE, NvU32, NvU8 *, NvU32, NvU8); 79 NV_STATUS flcnableHandleInitEvent (struct nvswitch_device *device, PFLCNABLE, union RM_FLCN_MSG *); 80 struct FLCN_QMGR_SEQ_INFO * flcnableQueueSeqInfoGet (struct nvswitch_device *device, PFLCNABLE, NvU32); 81 void flcnableQueueSeqInfoClear (struct nvswitch_device *device, PFLCNABLE, struct FLCN_QMGR_SEQ_INFO *); 82 void flcnableQueueSeqInfoFree (struct nvswitch_device *device, PFLCNABLE, struct FLCN_QMGR_SEQ_INFO *); 83 NvBool flcnableQueueCmdValidate (struct nvswitch_device *device, PFLCNABLE, union RM_FLCN_CMD *, union RM_FLCN_MSG *, void *, NvU32); 84 NV_STATUS flcnableQueueCmdPostExtension (struct nvswitch_device *device, PFLCNABLE, union RM_FLCN_CMD *, union RM_FLCN_MSG *, void *, struct NVSWITCH_TIMEOUT *, struct FLCN_QMGR_SEQ_INFO *); 85 void flcnablePostDiscoveryInit (struct nvswitch_device *device, PFLCNABLE); 86 87 NV_STATUS flcnableConstruct_HAL (struct nvswitch_device *device, PFLCNABLE); 88 void flcnableDestruct_HAL (struct nvswitch_device *device, PFLCNABLE); 89 90 void flcnableFetchEngines_HAL (struct nvswitch_device *device, PFLCNABLE, struct ENGINE_DESCRIPTOR_TYPE *, struct ENGINE_DESCRIPTOR_TYPE *); 91 92 93 #endif // _FLCNABLE_NVSWITCH_H_ 94