0001
0002
0003
0004
0005
0006
0007 #ifndef _QED_LL2_H
0008 #define _QED_LL2_H
0009
0010 #include <linux/types.h>
0011 #include <linux/kernel.h>
0012 #include <linux/list.h>
0013 #include <linux/mutex.h>
0014 #include <linux/slab.h>
0015 #include <linux/spinlock.h>
0016 #include <linux/qed/qed_chain.h>
0017 #include <linux/qed/qed_ll2_if.h>
0018 #include "qed.h"
0019 #include "qed_hsi.h"
0020 #include "qed_sp.h"
0021
0022 #define QED_MAX_NUM_OF_LL2_CONNECTIONS (4)
0023
0024
0025
0026 #define QED_MAX_NUM_OF_LL2_CONNS_PF (4)
0027 #define QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF (3)
0028
0029 #define QED_MAX_NUM_OF_CTX_LL2_CONNS_PF \
0030 (QED_MAX_NUM_OF_LL2_CONNS_PF - QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF)
0031
0032 #define QED_LL2_LEGACY_CONN_BASE_PF 0
0033 #define QED_LL2_CTX_CONN_BASE_PF QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF
0034
0035 struct qed_ll2_rx_packet {
0036 struct list_head list_entry;
0037 struct core_rx_bd_with_buff_len *rxq_bd;
0038 dma_addr_t rx_buf_addr;
0039 u16 buf_length;
0040 void *cookie;
0041 u8 placement_offset;
0042 u16 parse_flags;
0043 u16 packet_length;
0044 u16 vlan;
0045 u32 opaque_data[2];
0046 };
0047
0048 struct qed_ll2_tx_packet {
0049 struct list_head list_entry;
0050 u16 bd_used;
0051 bool notify_fw;
0052 void *cookie;
0053
0054 struct {
0055 struct core_tx_bd *txq_bd;
0056 dma_addr_t tx_frag;
0057 u16 frag_len;
0058 } bds_set[];
0059 };
0060
0061 struct qed_ll2_rx_queue {
0062
0063 spinlock_t lock;
0064 struct qed_chain rxq_chain;
0065 struct qed_chain rcq_chain;
0066 u8 rx_sb_index;
0067 u8 ctx_based;
0068 bool b_cb_registered;
0069 __le16 *p_fw_cons;
0070 struct list_head active_descq;
0071 struct list_head free_descq;
0072 struct list_head posting_descq;
0073 struct qed_ll2_rx_packet *descq_array;
0074 void __iomem *set_prod_addr;
0075 struct core_pwm_prod_update_data db_data;
0076 };
0077
0078 struct qed_ll2_tx_queue {
0079
0080 spinlock_t lock;
0081 struct qed_chain txq_chain;
0082 u8 tx_sb_index;
0083 bool b_cb_registered;
0084 __le16 *p_fw_cons;
0085 struct list_head active_descq;
0086 struct list_head free_descq;
0087 struct list_head sending_descq;
0088 u16 cur_completing_bd_idx;
0089 void __iomem *doorbell_addr;
0090 struct core_db_data db_msg;
0091 u16 bds_idx;
0092 u16 cur_send_frag_num;
0093 u16 cur_completing_frag_num;
0094 bool b_completing_packet;
0095 void *descq_mem;
0096 struct qed_ll2_tx_packet *cur_send_packet;
0097 struct qed_ll2_tx_packet cur_completing_packet;
0098 };
0099
0100 struct qed_ll2_info {
0101
0102 struct mutex mutex;
0103
0104 struct qed_ll2_acquire_data_inputs input;
0105 u32 cid;
0106 u8 my_id;
0107 u8 queue_id;
0108 u8 tx_stats_id;
0109 bool b_active;
0110 enum core_tx_dest tx_dest;
0111 u8 tx_stats_en;
0112 bool main_func_queue;
0113 struct qed_ll2_rx_queue rx_queue;
0114 struct qed_ll2_tx_queue tx_queue;
0115 struct qed_ll2_cbs cbs;
0116 };
0117
0118 extern const struct qed_ll2_ops qed_ll2_ops_pass;
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 int qed_ll2_acquire_connection(void *cxt, struct qed_ll2_acquire_data *data);
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 int qed_ll2_establish_connection(void *cxt, u8 connection_handle);
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 int qed_ll2_post_rx_buffer(void *cxt,
0158 u8 connection_handle,
0159 dma_addr_t addr,
0160 u16 buf_len, void *cookie, u8 notify_fw);
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 int qed_ll2_prepare_tx_packet(void *cxt,
0174 u8 connection_handle,
0175 struct qed_ll2_tx_pkt_info *pkt,
0176 bool notify_fw);
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188 void qed_ll2_release_connection(void *cxt, u8 connection_handle);
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203 int qed_ll2_set_fragment_of_tx_packet(void *cxt,
0204 u8 connection_handle,
0205 dma_addr_t addr, u16 nbytes);
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 int qed_ll2_terminate_connection(void *cxt, u8 connection_handle);
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228 int qed_ll2_get_stats(void *cxt,
0229 u8 connection_handle, struct qed_ll2_stats *p_stats);
0230
0231
0232
0233
0234
0235
0236
0237
0238 int qed_ll2_alloc(struct qed_hwfn *p_hwfn);
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248 void qed_ll2_setup(struct qed_hwfn *p_hwfn);
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258 void qed_ll2_free(struct qed_hwfn *p_hwfn);
0259
0260 #endif