1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* Copyright 2021 Marvell. All rights reserved. */
4 #ifndef _QED_NVMETCP_IF_H
5 #define _QED_NVMETCP_IF_H
6 #include <linux/types.h>
7 #include <linux/qed/qed_if.h>
9 #define QED_NVMETCP_MAX_IO_SIZE 0x800000
11 typedef int (*nvmetcp_event_cb_t
) (void *context
,
12 u8 fw_event_code
, void *fw_handle
);
14 struct qed_dev_nvmetcp_info
{
15 struct qed_dev_info common
;
16 u8 port_id
; /* Physical port */
20 #define MAX_TID_BLOCKS_NVMETCP (512)
21 struct qed_nvmetcp_tid
{
22 u32 size
; /* In bytes per task */
23 u32 num_tids_per_block
;
24 u8
*blocks
[MAX_TID_BLOCKS_NVMETCP
];
27 struct qed_nvmetcp_id_params
{
33 struct qed_nvmetcp_params_offload
{
34 /* FW initializations */
35 dma_addr_t sq_pbl_addr
;
36 dma_addr_t nvmetcp_cccid_itid_table_addr
;
37 u16 nvmetcp_cccid_max_range
;
40 /* Networking and TCP stack initializations */
41 struct qed_nvmetcp_id_params src
;
42 struct qed_nvmetcp_id_params dst
;
51 bool tcp_keep_alive_en
;
60 struct qed_nvmetcp_params_update
{
62 u32 max_recv_pdu_length
;
63 u32 max_send_pdu_length
;
65 /* Placeholder: pfv, cpda, hpda */
71 struct qed_nvmetcp_cb_ops
{
72 struct qed_common_cb_ops common
;
76 * struct qed_nvmetcp_ops - qed NVMeTCP operations.
77 * @common: common operations pointer
78 * @ll2: light L2 operations pointer
79 * @fill_dev_info: fills NVMeTCP specific information
82 * @return 0 on success, otherwise error value.
83 * @register_ops: register nvmetcp operations
85 * @param ops - specified using qed_nvmetcp_cb_ops
86 * @param cookie - driver private
87 * @start: nvmetcp in FW
89 * @param tasks - qed will fill information about tasks
90 * return 0 on success, otherwise error value.
91 * @stop: nvmetcp in FW
93 * return 0 on success, otherwise error value.
94 * @acquire_conn: acquire a new nvmetcp connection
96 * @param handle - qed will fill handle that should be
97 * used henceforth as identifier of the
99 * @param p_doorbell - qed will fill the address of the
101 * @return 0 on sucesss, otherwise error value.
102 * @release_conn: release a previously acquired nvmetcp connection
104 * @param handle - the connection handle.
105 * @return 0 on success, otherwise error value.
106 * @offload_conn: configures an offloaded connection
108 * @param handle - the connection handle.
109 * @param conn_info - the configuration to use for the
111 * @return 0 on success, otherwise error value.
112 * @update_conn: updates an offloaded connection
114 * @param handle - the connection handle.
115 * @param conn_info - the configuration to use for the
117 * @return 0 on success, otherwise error value.
118 * @destroy_conn: stops an offloaded connection
120 * @param handle - the connection handle.
121 * @return 0 on success, otherwise error value.
122 * @clear_sq: clear all task in sq
124 * @param handle - the connection handle.
125 * @return 0 on success, otherwise error value.
126 * @add_src_tcp_port_filter: Add source tcp port filter
129 * @remove_src_tcp_port_filter: Remove source tcp port filter
132 * @add_dst_tcp_port_filter: Add destination tcp port filter
135 * @remove_dst_tcp_port_filter: Remove destination tcp port filter
138 * @clear_all_filters: Clear all filters.
141 struct qed_nvmetcp_ops
{
142 const struct qed_common_ops
*common
;
144 const struct qed_ll2_ops
*ll2
;
146 int (*fill_dev_info
)(struct qed_dev
*cdev
,
147 struct qed_dev_nvmetcp_info
*info
);
149 void (*register_ops
)(struct qed_dev
*cdev
,
150 struct qed_nvmetcp_cb_ops
*ops
, void *cookie
);
152 int (*start
)(struct qed_dev
*cdev
,
153 struct qed_nvmetcp_tid
*tasks
,
154 void *event_context
, nvmetcp_event_cb_t async_event_cb
);
156 int (*stop
)(struct qed_dev
*cdev
);
158 int (*acquire_conn
)(struct qed_dev
*cdev
,
160 u32
*fw_cid
, void __iomem
**p_doorbell
);
162 int (*release_conn
)(struct qed_dev
*cdev
, u32 handle
);
164 int (*offload_conn
)(struct qed_dev
*cdev
,
166 struct qed_nvmetcp_params_offload
*conn_info
);
168 int (*update_conn
)(struct qed_dev
*cdev
,
170 struct qed_nvmetcp_params_update
*conn_info
);
172 int (*destroy_conn
)(struct qed_dev
*cdev
, u32 handle
, u8 abrt_conn
);
174 int (*clear_sq
)(struct qed_dev
*cdev
, u32 handle
);
176 int (*add_src_tcp_port_filter
)(struct qed_dev
*cdev
, u16 src_port
);
178 void (*remove_src_tcp_port_filter
)(struct qed_dev
*cdev
, u16 src_port
);
180 int (*add_dst_tcp_port_filter
)(struct qed_dev
*cdev
, u16 dest_port
);
182 void (*remove_dst_tcp_port_filter
)(struct qed_dev
*cdev
, u16 dest_port
);
184 void (*clear_all_filters
)(struct qed_dev
*cdev
);
187 const struct qed_nvmetcp_ops
*qed_get_nvmetcp_ops(void);
188 void qed_put_nvmetcp_ops(void);