18c978d05SRaghu Vatsavayi /********************************************************************** 28c978d05SRaghu Vatsavayi * Author: Cavium, Inc. 38c978d05SRaghu Vatsavayi * 48c978d05SRaghu Vatsavayi * Contact: support@cavium.com 58c978d05SRaghu Vatsavayi * Please include "LiquidIO" in the subject. 68c978d05SRaghu Vatsavayi * 78c978d05SRaghu Vatsavayi * Copyright (c) 2003-2016 Cavium, Inc. 88c978d05SRaghu Vatsavayi * 98c978d05SRaghu Vatsavayi * This file is free software; you can redistribute it and/or modify 108c978d05SRaghu Vatsavayi * it under the terms of the GNU General Public License, Version 2, as 118c978d05SRaghu Vatsavayi * published by the Free Software Foundation. 128c978d05SRaghu Vatsavayi * 138c978d05SRaghu Vatsavayi * This file is distributed in the hope that it will be useful, but 148c978d05SRaghu Vatsavayi * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 158c978d05SRaghu Vatsavayi * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 168c978d05SRaghu Vatsavayi * NONINFRINGEMENT. See the GNU General Public License for more details. 178c978d05SRaghu Vatsavayi ***********************************************************************/ 188c978d05SRaghu Vatsavayi #ifndef __MAILBOX_H__ 198c978d05SRaghu Vatsavayi #define __MAILBOX_H__ 208c978d05SRaghu Vatsavayi 218c978d05SRaghu Vatsavayi /* Macros for Mail Box Communication */ 228c978d05SRaghu Vatsavayi 238c978d05SRaghu Vatsavayi #define OCTEON_MBOX_DATA_MAX 32 248c978d05SRaghu Vatsavayi 258c978d05SRaghu Vatsavayi #define OCTEON_VF_ACTIVE 0x1 268c978d05SRaghu Vatsavayi #define OCTEON_VF_FLR_REQUEST 0x2 278c978d05SRaghu Vatsavayi #define OCTEON_PF_CHANGED_VF_MACADDR 0x4 28cea395acSIntiyaz Basha #define OCTEON_GET_VF_STATS 0x8 298c978d05SRaghu Vatsavayi 308c978d05SRaghu Vatsavayi /*Macro for Read acknowldgement*/ 31d5c7d9b9SPrasad Kanneganti #define OCTEON_PFVFACK 0xffffffffffffffffULL 32d5c7d9b9SPrasad Kanneganti #define OCTEON_PFVFSIG 0x1122334455667788ULL 33d5c7d9b9SPrasad Kanneganti #define OCTEON_PFVFERR 0xDEADDEADDEADDEADULL 348c978d05SRaghu Vatsavayi 358c978d05SRaghu Vatsavayi #define LIO_MBOX_WRITE_WAIT_CNT 1000 36a8ac1a55SPrasad Kanneganti #define LIO_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1) 378c978d05SRaghu Vatsavayi 388c978d05SRaghu Vatsavayi enum octeon_mbox_cmd_status { 398c978d05SRaghu Vatsavayi OCTEON_MBOX_STATUS_SUCCESS = 0, 408c978d05SRaghu Vatsavayi OCTEON_MBOX_STATUS_FAILED = 1, 418c978d05SRaghu Vatsavayi OCTEON_MBOX_STATUS_BUSY = 2 428c978d05SRaghu Vatsavayi }; 438c978d05SRaghu Vatsavayi 448c978d05SRaghu Vatsavayi enum octeon_mbox_message_type { 458c978d05SRaghu Vatsavayi OCTEON_MBOX_REQUEST = 0, 468c978d05SRaghu Vatsavayi OCTEON_MBOX_RESPONSE = 1 478c978d05SRaghu Vatsavayi }; 488c978d05SRaghu Vatsavayi 498c978d05SRaghu Vatsavayi union octeon_mbox_message { 508c978d05SRaghu Vatsavayi u64 u64; 518c978d05SRaghu Vatsavayi struct { 528c978d05SRaghu Vatsavayi u16 type : 1; 538c978d05SRaghu Vatsavayi u16 resp_needed : 1; 548c978d05SRaghu Vatsavayi u16 cmd : 6; 558c978d05SRaghu Vatsavayi u16 len : 8; 568c978d05SRaghu Vatsavayi u8 params[6]; 578c978d05SRaghu Vatsavayi } s; 588c978d05SRaghu Vatsavayi }; 598c978d05SRaghu Vatsavayi 608c978d05SRaghu Vatsavayi typedef void (*octeon_mbox_callback_t)(void *, void *, void *); 618c978d05SRaghu Vatsavayi 628c978d05SRaghu Vatsavayi struct octeon_mbox_cmd { 638c978d05SRaghu Vatsavayi union octeon_mbox_message msg; 648c978d05SRaghu Vatsavayi u64 data[OCTEON_MBOX_DATA_MAX]; 658c978d05SRaghu Vatsavayi u32 q_no; 668c978d05SRaghu Vatsavayi u32 recv_len; 678c978d05SRaghu Vatsavayi u32 recv_status; 688c978d05SRaghu Vatsavayi octeon_mbox_callback_t fn; 698c978d05SRaghu Vatsavayi void *fn_arg; 708c978d05SRaghu Vatsavayi }; 718c978d05SRaghu Vatsavayi 728c978d05SRaghu Vatsavayi enum octeon_mbox_state { 738c978d05SRaghu Vatsavayi OCTEON_MBOX_STATE_IDLE = 1, 748c978d05SRaghu Vatsavayi OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2, 758c978d05SRaghu Vatsavayi OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4, 768c978d05SRaghu Vatsavayi OCTEON_MBOX_STATE_RESPONSE_PENDING = 8, 778c978d05SRaghu Vatsavayi OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16, 78d5c7d9b9SPrasad Kanneganti OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32, 79d5c7d9b9SPrasad Kanneganti OCTEON_MBOX_STATE_ERROR = 64 808c978d05SRaghu Vatsavayi }; 818c978d05SRaghu Vatsavayi 828c978d05SRaghu Vatsavayi struct octeon_mbox { 838c978d05SRaghu Vatsavayi /** A spinlock to protect access to this q_mbox. */ 848c978d05SRaghu Vatsavayi spinlock_t lock; 858c978d05SRaghu Vatsavayi 868c978d05SRaghu Vatsavayi struct octeon_device *oct_dev; 878c978d05SRaghu Vatsavayi 888c978d05SRaghu Vatsavayi u32 q_no; 898c978d05SRaghu Vatsavayi 908c978d05SRaghu Vatsavayi enum octeon_mbox_state state; 918c978d05SRaghu Vatsavayi 928c978d05SRaghu Vatsavayi struct cavium_wk mbox_poll_wk; 938c978d05SRaghu Vatsavayi 948c978d05SRaghu Vatsavayi /** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */ 958c978d05SRaghu Vatsavayi void *mbox_int_reg; 968c978d05SRaghu Vatsavayi 978c978d05SRaghu Vatsavayi /** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF. 988c978d05SRaghu Vatsavayi */ 998c978d05SRaghu Vatsavayi void *mbox_write_reg; 1008c978d05SRaghu Vatsavayi 1018c978d05SRaghu Vatsavayi /** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF. 1028c978d05SRaghu Vatsavayi */ 1038c978d05SRaghu Vatsavayi void *mbox_read_reg; 1048c978d05SRaghu Vatsavayi 1058c978d05SRaghu Vatsavayi struct octeon_mbox_cmd mbox_req; 1068c978d05SRaghu Vatsavayi 1078c978d05SRaghu Vatsavayi struct octeon_mbox_cmd mbox_resp; 1088c978d05SRaghu Vatsavayi 1098c978d05SRaghu Vatsavayi }; 1108c978d05SRaghu Vatsavayi 111cea395acSIntiyaz Basha struct oct_vf_stats_ctx { 112cea395acSIntiyaz Basha atomic_t status; 113cea395acSIntiyaz Basha struct oct_vf_stats *stats; 114cea395acSIntiyaz Basha }; 115cea395acSIntiyaz Basha 1168c978d05SRaghu Vatsavayi int octeon_mbox_read(struct octeon_mbox *mbox); 1178c978d05SRaghu Vatsavayi int octeon_mbox_write(struct octeon_device *oct, 1188c978d05SRaghu Vatsavayi struct octeon_mbox_cmd *mbox_cmd); 1198c978d05SRaghu Vatsavayi int octeon_mbox_process_message(struct octeon_mbox *mbox); 120cea395acSIntiyaz Basha int octeon_mbox_cancel(struct octeon_device *oct, int q_no); 1218c978d05SRaghu Vatsavayi 1228c978d05SRaghu Vatsavayi #endif 123