treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / ethernet / cavium / liquidio / octeon_mailbox.h
blobd92bd7e164775b9523430a04fa5dddfa5bbbc929
1 /**********************************************************************
2 * Author: Cavium, Inc.
4 * Contact: support@cavium.com
5 * Please include "LiquidIO" in the subject.
7 * Copyright (c) 2003-2016 Cavium, Inc.
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more details.
17 ***********************************************************************/
18 #ifndef __MAILBOX_H__
19 #define __MAILBOX_H__
21 /* Macros for Mail Box Communication */
23 #define OCTEON_MBOX_DATA_MAX 32
25 #define OCTEON_VF_ACTIVE 0x1
26 #define OCTEON_VF_FLR_REQUEST 0x2
27 #define OCTEON_PF_CHANGED_VF_MACADDR 0x4
28 #define OCTEON_GET_VF_STATS 0x8
30 /*Macro for Read acknowldgement*/
31 #define OCTEON_PFVFACK 0xffffffffffffffffULL
32 #define OCTEON_PFVFSIG 0x1122334455667788ULL
33 #define OCTEON_PFVFERR 0xDEADDEADDEADDEADULL
35 #define LIO_MBOX_WRITE_WAIT_CNT 1000
36 #define LIO_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
38 enum octeon_mbox_cmd_status {
39 OCTEON_MBOX_STATUS_SUCCESS = 0,
40 OCTEON_MBOX_STATUS_FAILED = 1,
41 OCTEON_MBOX_STATUS_BUSY = 2
44 enum octeon_mbox_message_type {
45 OCTEON_MBOX_REQUEST = 0,
46 OCTEON_MBOX_RESPONSE = 1
49 union octeon_mbox_message {
50 u64 u64;
51 struct {
52 u16 type : 1;
53 u16 resp_needed : 1;
54 u16 cmd : 6;
55 u16 len : 8;
56 u8 params[6];
57 } s;
60 typedef void (*octeon_mbox_callback_t)(void *, void *, void *);
62 struct octeon_mbox_cmd {
63 union octeon_mbox_message msg;
64 u64 data[OCTEON_MBOX_DATA_MAX];
65 u32 q_no;
66 u32 recv_len;
67 u32 recv_status;
68 octeon_mbox_callback_t fn;
69 void *fn_arg;
72 enum octeon_mbox_state {
73 OCTEON_MBOX_STATE_IDLE = 1,
74 OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2,
75 OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
76 OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
77 OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
78 OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
79 OCTEON_MBOX_STATE_ERROR = 64
82 struct octeon_mbox {
83 /** A spinlock to protect access to this q_mbox. */
84 spinlock_t lock;
86 struct octeon_device *oct_dev;
88 u32 q_no;
90 enum octeon_mbox_state state;
92 struct cavium_wk mbox_poll_wk;
94 /** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
95 void *mbox_int_reg;
97 /** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
99 void *mbox_write_reg;
101 /** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
103 void *mbox_read_reg;
105 struct octeon_mbox_cmd mbox_req;
107 struct octeon_mbox_cmd mbox_resp;
111 struct oct_vf_stats_ctx {
112 atomic_t status;
113 struct oct_vf_stats *stats;
116 int octeon_mbox_read(struct octeon_mbox *mbox);
117 int octeon_mbox_write(struct octeon_device *oct,
118 struct octeon_mbox_cmd *mbox_cmd);
119 int octeon_mbox_process_message(struct octeon_mbox *mbox);
120 int octeon_mbox_cancel(struct octeon_device *oct, int q_no);
122 #endif