Back to home page

OSCL-LXR

 
 

    


0001 /**********************************************************************
0002  * Author: Cavium, Inc.
0003  *
0004  * Contact: support@cavium.com
0005  *          Please include "LiquidIO" in the subject.
0006  *
0007  * Copyright (c) 2003-2016 Cavium, Inc.
0008  *
0009  * This file is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License, Version 2, as
0011  * published by the Free Software Foundation.
0012  *
0013  * This file is distributed in the hope that it will be useful, but
0014  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
0015  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
0016  * NONINFRINGEMENT.  See the GNU General Public License for more details.
0017  ***********************************************************************/
0018 #ifndef __MAILBOX_H__
0019 #define __MAILBOX_H__
0020 
0021 /* Macros for Mail Box Communication */
0022 
0023 #define OCTEON_MBOX_DATA_MAX        32
0024 
0025 #define OCTEON_VF_ACTIVE        0x1
0026 #define OCTEON_VF_FLR_REQUEST       0x2
0027 #define OCTEON_PF_CHANGED_VF_MACADDR    0x4
0028 #define OCTEON_GET_VF_STATS     0x8
0029 
0030 /*Macro for Read acknowldgement*/
0031 #define OCTEON_PFVFACK          0xffffffffffffffffULL
0032 #define OCTEON_PFVFSIG          0x1122334455667788ULL
0033 #define OCTEON_PFVFERR          0xDEADDEADDEADDEADULL
0034 
0035 #define LIO_MBOX_WRITE_WAIT_CNT         1000
0036 #define LIO_MBOX_WRITE_WAIT_TIME        msecs_to_jiffies(1)
0037 
0038 enum octeon_mbox_cmd_status {
0039     OCTEON_MBOX_STATUS_SUCCESS = 0,
0040     OCTEON_MBOX_STATUS_FAILED = 1,
0041     OCTEON_MBOX_STATUS_BUSY = 2
0042 };
0043 
0044 enum octeon_mbox_message_type {
0045     OCTEON_MBOX_REQUEST = 0,
0046     OCTEON_MBOX_RESPONSE = 1
0047 };
0048 
0049 union octeon_mbox_message {
0050     u64 u64;
0051     struct {
0052         u16 type : 1;
0053         u16 resp_needed : 1;
0054         u16 cmd : 6;
0055         u16 len : 8;
0056         u8 params[6];
0057     } s;
0058 };
0059 
0060 typedef void (*octeon_mbox_callback_t)(void *, void *, void *);
0061 
0062 struct octeon_mbox_cmd {
0063     union octeon_mbox_message msg;
0064     u64 data[OCTEON_MBOX_DATA_MAX];
0065     u32 q_no;
0066     u32 recv_len;
0067     u32 recv_status;
0068     octeon_mbox_callback_t fn;
0069     void *fn_arg;
0070 };
0071 
0072 enum octeon_mbox_state {
0073     OCTEON_MBOX_STATE_IDLE = 1,
0074     OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2,
0075     OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
0076     OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
0077     OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
0078     OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
0079     OCTEON_MBOX_STATE_ERROR = 64
0080 };
0081 
0082 struct octeon_mbox {
0083     /** A spinlock to protect access to this q_mbox. */
0084     spinlock_t lock;
0085 
0086     struct octeon_device *oct_dev;
0087 
0088     u32 q_no;
0089 
0090     enum octeon_mbox_state state;
0091 
0092     struct cavium_wk mbox_poll_wk;
0093 
0094     /** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
0095     void *mbox_int_reg;
0096 
0097     /** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
0098      */
0099     void *mbox_write_reg;
0100 
0101     /** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
0102      */
0103     void *mbox_read_reg;
0104 
0105     struct octeon_mbox_cmd mbox_req;
0106 
0107     struct octeon_mbox_cmd mbox_resp;
0108 
0109 };
0110 
0111 struct oct_vf_stats_ctx {
0112     atomic_t status;
0113     struct oct_vf_stats *stats;
0114 };
0115 
0116 int octeon_mbox_read(struct octeon_mbox *mbox);
0117 int octeon_mbox_write(struct octeon_device *oct,
0118               struct octeon_mbox_cmd *mbox_cmd);
0119 int octeon_mbox_process_message(struct octeon_mbox *mbox);
0120 int octeon_mbox_cancel(struct octeon_device *oct, int q_no);
0121 
0122 #endif