0001
0002
0003
0004
0005
0006
0007 #ifndef _QED_L2_H
0008 #define _QED_L2_H
0009 #include <linux/types.h>
0010 #include <linux/io.h>
0011 #include <linux/kernel.h>
0012 #include <linux/slab.h>
0013 #include <linux/qed/qed_eth_if.h>
0014 #include "qed.h"
0015 #include "qed_hw.h"
0016 #include "qed_sp.h"
0017 struct qed_rss_params {
0018 u8 update_rss_config;
0019 u8 rss_enable;
0020 u8 rss_eng_id;
0021 u8 update_rss_capabilities;
0022 u8 update_rss_ind_table;
0023 u8 update_rss_key;
0024 u8 rss_caps;
0025 u8 rss_table_size_log;
0026
0027
0028 void *rss_ind_table[QED_RSS_IND_TABLE_SIZE];
0029 u32 rss_key[QED_RSS_KEY_SIZE];
0030 };
0031
0032 struct qed_sge_tpa_params {
0033 u8 max_buffers_per_cqe;
0034
0035 u8 update_tpa_en_flg;
0036 u8 tpa_ipv4_en_flg;
0037 u8 tpa_ipv6_en_flg;
0038 u8 tpa_ipv4_tunn_en_flg;
0039 u8 tpa_ipv6_tunn_en_flg;
0040
0041 u8 update_tpa_param_flg;
0042 u8 tpa_pkt_split_flg;
0043 u8 tpa_hdr_data_split_flg;
0044 u8 tpa_gro_consistent_flg;
0045 u8 tpa_max_aggs_num;
0046 u16 tpa_max_size;
0047 u16 tpa_min_size_to_start;
0048 u16 tpa_min_size_to_cont;
0049 };
0050
0051 enum qed_filter_opcode {
0052 QED_FILTER_ADD,
0053 QED_FILTER_REMOVE,
0054 QED_FILTER_MOVE,
0055 QED_FILTER_REPLACE,
0056 QED_FILTER_FLUSH,
0057 };
0058
0059 enum qed_filter_ucast_type {
0060 QED_FILTER_MAC,
0061 QED_FILTER_VLAN,
0062 QED_FILTER_MAC_VLAN,
0063 QED_FILTER_INNER_MAC,
0064 QED_FILTER_INNER_VLAN,
0065 QED_FILTER_INNER_PAIR,
0066 QED_FILTER_INNER_MAC_VNI_PAIR,
0067 QED_FILTER_MAC_VNI_PAIR,
0068 QED_FILTER_VNI,
0069 };
0070
0071 struct qed_filter_ucast {
0072 enum qed_filter_opcode opcode;
0073 enum qed_filter_ucast_type type;
0074 u8 is_rx_filter;
0075 u8 is_tx_filter;
0076 u8 vport_to_add_to;
0077 u8 vport_to_remove_from;
0078 unsigned char mac[ETH_ALEN];
0079 u8 assert_on_error;
0080 u16 vlan;
0081 u32 vni;
0082 };
0083
0084 struct qed_filter_mcast {
0085
0086 enum qed_filter_opcode opcode;
0087 u8 vport_to_add_to;
0088 u8 vport_to_remove_from;
0089 u8 num_mc_addrs;
0090 #define QED_MAX_MC_ADDRS 64
0091 unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
0092 };
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108 int
0109 qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
0110 void *p_rxq,
0111 bool eq_completion_only, bool cqe_completion);
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);
0122
0123 enum qed_tpa_mode {
0124 QED_TPA_MODE_NONE,
0125 QED_TPA_MODE_UNUSED,
0126 QED_TPA_MODE_GRO,
0127 QED_TPA_MODE_MAX
0128 };
0129
0130 struct qed_sp_vport_start_params {
0131 enum qed_tpa_mode tpa_mode;
0132 bool remove_inner_vlan;
0133 bool tx_switching;
0134 bool handle_ptp_pkts;
0135 bool only_untagged;
0136 bool drop_ttl0;
0137 u8 max_buffers_per_cqe;
0138 u32 concrete_fid;
0139 u16 opaque_fid;
0140 u8 vport_id;
0141 u16 mtu;
0142 bool check_mac;
0143 bool check_ethtype;
0144 };
0145
0146 int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
0147 struct qed_sp_vport_start_params *p_params);
0148
0149 struct qed_filter_accept_flags {
0150 u8 update_rx_mode_config;
0151 u8 update_tx_mode_config;
0152 u8 rx_accept_filter;
0153 u8 tx_accept_filter;
0154 #define QED_ACCEPT_NONE 0x01
0155 #define QED_ACCEPT_UCAST_MATCHED 0x02
0156 #define QED_ACCEPT_UCAST_UNMATCHED 0x04
0157 #define QED_ACCEPT_MCAST_MATCHED 0x08
0158 #define QED_ACCEPT_MCAST_UNMATCHED 0x10
0159 #define QED_ACCEPT_BCAST 0x20
0160 #define QED_ACCEPT_ANY_VNI 0x40
0161 };
0162
0163 struct qed_arfs_config_params {
0164 bool tcp;
0165 bool udp;
0166 bool ipv4;
0167 bool ipv6;
0168 enum qed_filter_config_mode mode;
0169 };
0170
0171 struct qed_sp_vport_update_params {
0172 u16 opaque_fid;
0173 u8 vport_id;
0174 u8 update_vport_active_rx_flg;
0175 u8 vport_active_rx_flg;
0176 u8 update_vport_active_tx_flg;
0177 u8 vport_active_tx_flg;
0178 u8 update_inner_vlan_removal_flg;
0179 u8 inner_vlan_removal_flg;
0180 u8 silent_vlan_removal_flg;
0181 u8 update_default_vlan_enable_flg;
0182 u8 default_vlan_enable_flg;
0183 u8 update_default_vlan_flg;
0184 u16 default_vlan;
0185 u8 update_tx_switching_flg;
0186 u8 tx_switching_flg;
0187 u8 update_approx_mcast_flg;
0188 u8 update_anti_spoofing_en_flg;
0189 u8 anti_spoofing_en;
0190 u8 update_accept_any_vlan_flg;
0191 u8 accept_any_vlan;
0192 u32 bins[8];
0193 struct qed_rss_params *rss_params;
0194 struct qed_filter_accept_flags accept_flags;
0195 struct qed_sge_tpa_params *sge_tpa_params;
0196 u8 update_ctl_frame_check;
0197 u8 mac_chk_en;
0198 u8 ethtype_chk_en;
0199 };
0200
0201 int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
0202 struct qed_sp_vport_update_params *p_params,
0203 enum spq_mode comp_mode,
0204 struct qed_spq_comp_cb *p_comp_data);
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217 int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
0218
0219 int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
0220 u16 opaque_fid,
0221 struct qed_filter_ucast *p_filter_cmd,
0222 enum spq_mode comp_mode,
0223 struct qed_spq_comp_cb *p_comp_data);
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 int
0244 qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
0245 void **pp_rxq_handlers,
0246 u8 num_rxqs,
0247 u8 complete_cqe_flg,
0248 u8 complete_event_flg,
0249 enum spq_mode comp_mode,
0250 struct qed_spq_comp_cb *p_comp_data);
0251
0252 void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
0253
0254 void qed_reset_vport_stats(struct qed_dev *cdev);
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268 void qed_arfs_mode_configure(struct qed_hwfn *p_hwfn,
0269 struct qed_ptt *p_ptt,
0270 struct qed_arfs_config_params *p_cfg_params);
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284 int
0285 qed_configure_rfs_ntuple_filter(struct qed_hwfn *p_hwfn,
0286 struct qed_spq_comp_cb *p_cb,
0287 struct qed_ntuple_filter_params *p_params);
0288
0289 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
0290 #define QED_QUEUE_CID_SELF (0xff)
0291
0292
0293
0294
0295 struct qed_queue_cid_params {
0296 u8 vport_id;
0297 u16 queue_id;
0298 u8 stats_id;
0299 };
0300
0301
0302
0303
0304 struct qed_queue_cid_vf_params {
0305
0306 u8 vfid;
0307
0308
0309
0310
0311 u8 vf_qid;
0312
0313
0314
0315
0316
0317 u8 vf_legacy;
0318
0319 u8 qid_usage_idx;
0320 };
0321
0322 struct qed_queue_cid {
0323
0324 struct qed_queue_cid_params rel;
0325 struct qed_queue_cid_params abs;
0326
0327
0328 u16 sb_igu_id;
0329 u8 sb_idx;
0330
0331 u32 cid;
0332 u16 opaque_fid;
0333
0334 bool b_is_rx;
0335
0336
0337
0338
0339
0340
0341 u8 vfid;
0342 u8 vf_qid;
0343
0344
0345
0346
0347
0348 u8 qid_usage_idx;
0349
0350 u8 vf_legacy;
0351 #define QED_QCID_LEGACY_VF_RX_PROD (BIT(0))
0352 #define QED_QCID_LEGACY_VF_CID (BIT(1))
0353
0354 struct qed_hwfn *p_owner;
0355 };
0356
0357 int qed_l2_alloc(struct qed_hwfn *p_hwfn);
0358 void qed_l2_setup(struct qed_hwfn *p_hwfn);
0359 void qed_l2_free(struct qed_hwfn *p_hwfn);
0360
0361 void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
0362 struct qed_queue_cid *p_cid);
0363
0364 struct qed_queue_cid *
0365 qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
0366 u16 opaque_fid,
0367 struct qed_queue_start_common_params *p_params,
0368 bool b_is_rx,
0369 struct qed_queue_cid_vf_params *p_vf_params);
0370
0371 int
0372 qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
0373 struct qed_sp_vport_start_params *p_params);
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388 int
0389 qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
0390 struct qed_queue_cid *p_cid,
0391 u16 bd_max_bytes,
0392 dma_addr_t bd_chain_phys_addr,
0393 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407 int
0408 qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
0409 struct qed_queue_cid *p_cid,
0410 dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);
0411
0412 u8 qed_mcast_bin_from_mac(u8 *mac);
0413
0414 int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn,
0415 struct qed_ptt *p_ptt,
0416 u16 coalesce, struct qed_queue_cid *p_cid);
0417
0418 int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn,
0419 struct qed_ptt *p_ptt,
0420 u16 coalesce, struct qed_queue_cid *p_cid);
0421
0422 int qed_get_rxq_coalesce(struct qed_hwfn *p_hwfn,
0423 struct qed_ptt *p_ptt,
0424 struct qed_queue_cid *p_cid, u16 *p_hw_coal);
0425
0426 int qed_get_txq_coalesce(struct qed_hwfn *p_hwfn,
0427 struct qed_ptt *p_ptt,
0428 struct qed_queue_cid *p_cid, u16 *p_hw_coal);
0429
0430 #endif