1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _QED_FCOE_IF_H
3 #define _QED_FCOE_IF_H
4 #include <linux/types.h>
5 #include <linux/qed/qed_if.h>
6 struct qed_fcoe_stats {
7 	u64 fcoe_rx_byte_cnt;
8 	u64 fcoe_rx_data_pkt_cnt;
9 	u64 fcoe_rx_xfer_pkt_cnt;
10 	u64 fcoe_rx_other_pkt_cnt;
11 	u32 fcoe_silent_drop_pkt_cmdq_full_cnt;
12 	u32 fcoe_silent_drop_pkt_rq_full_cnt;
13 	u32 fcoe_silent_drop_pkt_crc_error_cnt;
14 	u32 fcoe_silent_drop_pkt_task_invalid_cnt;
15 	u32 fcoe_silent_drop_total_pkt_cnt;
16 
17 	u64 fcoe_tx_byte_cnt;
18 	u64 fcoe_tx_data_pkt_cnt;
19 	u64 fcoe_tx_xfer_pkt_cnt;
20 	u64 fcoe_tx_other_pkt_cnt;
21 };
22 
23 struct qed_dev_fcoe_info {
24 	struct qed_dev_info common;
25 
26 	void __iomem *primary_dbq_rq_addr;
27 	void __iomem *secondary_bdq_rq_addr;
28 
29 	u64 wwpn;
30 	u64 wwnn;
31 
32 	u8 num_cqs;
33 };
34 
35 struct qed_fcoe_params_offload {
36 	dma_addr_t sq_pbl_addr;
37 	dma_addr_t sq_curr_page_addr;
38 	dma_addr_t sq_next_page_addr;
39 
40 	u8 src_mac[ETH_ALEN];
41 	u8 dst_mac[ETH_ALEN];
42 
43 	u16 tx_max_fc_pay_len;
44 	u16 e_d_tov_timer_val;
45 	u16 rec_tov_timer_val;
46 	u16 rx_max_fc_pay_len;
47 	u16 vlan_tag;
48 
49 	struct fc_addr_nw s_id;
50 	u8 max_conc_seqs_c3;
51 	struct fc_addr_nw d_id;
52 	u8 flags;
53 	u8 def_q_idx;
54 };
55 
56 #define MAX_TID_BLOCKS_FCOE (512)
57 struct qed_fcoe_tid {
58 	u32 size;		/* In bytes per task */
59 	u32 num_tids_per_block;
60 	u8 *blocks[MAX_TID_BLOCKS_FCOE];
61 };
62 
63 struct qed_fcoe_cb_ops {
64 	struct qed_common_cb_ops common;
65 	 u32 (*get_login_failures)(void *cookie);
66 };
67 
68 void qed_fcoe_set_pf_params(struct qed_dev *cdev,
69 			    struct qed_fcoe_pf_params *params);
70 
71 /**
72  * struct qed_fcoe_ops - qed FCoE operations.
73  * @common:		common operations pointer
74  * @fill_dev_info:	fills FCoE specific information
75  *			@param cdev
76  *			@param info
77  *			@return 0 on sucesss, otherwise error value.
78  * @register_ops:	register FCoE operations
79  *			@param cdev
80  *			@param ops - specified using qed_iscsi_cb_ops
81  *			@param cookie - driver private
82  * @ll2:		light L2 operations pointer
83  * @start:		fcoe in FW
84  *			@param cdev
85  *			@param tasks - qed will fill information about tasks
86  *			return 0 on success, otherwise error value.
87  * @stop:		stops fcoe in FW
88  *			@param cdev
89  *			return 0 on success, otherwise error value.
90  * @acquire_conn:	acquire a new fcoe connection
91  *			@param cdev
92  *			@param handle - qed will fill handle that should be
93  *				used henceforth as identifier of the
94  *				connection.
95  *			@param p_doorbell - qed will fill the address of the
96  *				doorbell.
97  *			return 0 on sucesss, otherwise error value.
98  * @release_conn:	release a previously acquired fcoe connection
99  *			@param cdev
100  *			@param handle - the connection handle.
101  *			return 0 on success, otherwise error value.
102  * @offload_conn:	configures an offloaded connection
103  *			@param cdev
104  *			@param handle - the connection handle.
105  *			@param conn_info - the configuration to use for the
106  *				offload.
107  *			return 0 on success, otherwise error value.
108  * @destroy_conn:	stops an offloaded connection
109  *			@param cdev
110  *			@param handle - the connection handle.
111  *			@param terminate_params
112  *			return 0 on success, otherwise error value.
113  * @get_stats:		gets FCoE related statistics
114  *			@param cdev
115  *			@param stats - pointer to struck that would be filled
116  *				we stats
117  *			return 0 on success, error otherwise.
118  */
119 struct qed_fcoe_ops {
120 	const struct qed_common_ops *common;
121 
122 	int (*fill_dev_info)(struct qed_dev *cdev,
123 			     struct qed_dev_fcoe_info *info);
124 
125 	void (*register_ops)(struct qed_dev *cdev,
126 			     struct qed_fcoe_cb_ops *ops, void *cookie);
127 
128 	const struct qed_ll2_ops *ll2;
129 
130 	int (*start)(struct qed_dev *cdev, struct qed_fcoe_tid *tasks);
131 
132 	int (*stop)(struct qed_dev *cdev);
133 
134 	int (*acquire_conn)(struct qed_dev *cdev,
135 			    u32 *handle,
136 			    u32 *fw_cid, void __iomem **p_doorbell);
137 
138 	int (*release_conn)(struct qed_dev *cdev, u32 handle);
139 
140 	int (*offload_conn)(struct qed_dev *cdev,
141 			    u32 handle,
142 			    struct qed_fcoe_params_offload *conn_info);
143 	int (*destroy_conn)(struct qed_dev *cdev,
144 			    u32 handle, dma_addr_t terminate_params);
145 
146 	int (*get_stats)(struct qed_dev *cdev, struct qed_fcoe_stats *stats);
147 };
148 
149 const struct qed_fcoe_ops *qed_get_fcoe_ops(void);
150 void qed_put_fcoe_ops(void);
151 #endif
152