Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* QLogic qed NIC Driver
0003  * Copyright (c) 2015-2017  QLogic Corporation
0004  * Copyright (c) 2019-2020 Marvell International Ltd.
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     /* Indirection table consist of rx queue handles */
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, /* Delete all MACs and add new one instead */
0056     QED_FILTER_FLUSH,   /* Removes all filters */
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     /* MOVE is not supported for multicast */
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  * qed_eth_rx_queue_stop(): This ramrod closes an Rx queue.
0096  *
0097  * @p_hwfn: HW device data.
0098  * @p_rxq: Handler of queue to close
0099  * @eq_completion_only: If True completion will be on
0100  *                      EQe, if False completion will be
0101  *                      on EQe if p_hwfn opaque
0102  *                      different from the RXQ opaque
0103  *                      otherwise on CQe.
0104  * @cqe_completion: If True completion will be receive on CQe.
0105  *
0106  * Return: Int.
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  * qed_eth_tx_queue_stop(): Closes a Tx queue.
0115  *
0116  * @p_hwfn: HW device data.
0117  * @p_txq: handle to Tx queue needed to be closed.
0118  *
0119  * Return: Int.
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  * qed_sp_vport_stop: This ramrod closes a VPort after all its
0208  *                    RX and TX queues are terminated.
0209  *                    An Assert is generated if any queues are left open.
0210  *
0211  * @p_hwfn: HW device data.
0212  * @opaque_fid: Opaque FID
0213  * @vport_id: VPort ID.
0214  *
0215  * Return: Int.
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  * qed_sp_eth_rx_queues_update(): This ramrod updates an RX queue.
0227  *                                It is used for setting the active state
0228  *                                of the queue and updating the TPA and
0229  *                                SGE parameters.
0230  * @p_hwfn: HW device data.
0231  * @pp_rxq_handlers: An array of queue handlers to be updated.
0232  * @num_rxqs: number of queues to update.
0233  * @complete_cqe_flg: Post completion to the CQE Ring if set.
0234  * @complete_event_flg: Post completion to the Event Ring if set.
0235  * @comp_mode: Comp mode.
0236  * @p_comp_data: Pointer Comp data.
0237  *
0238  * Return: Int.
0239  *
0240  * Note At the moment - only used by non-linux VFs.
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  * qed_arfs_mode_configure(): Enable or disable rfs mode.
0258  *                            It must accept at least one of tcp or udp true
0259  *                            and at least one of ipv4 or ipv6 true to enable
0260  *                            rfs mode.
0261  *
0262  * @p_hwfn: HW device data.
0263  * @p_ptt: P_ptt.
0264  * @p_cfg_params: arfs mode configuration parameters.
0265  *
0266  * Return. Void.
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  * qed_configure_rfs_ntuple_filter(): This ramrod should be used to add
0274  *                                     or remove arfs hw filter
0275  *
0276  * @p_hwfn: HW device data.
0277  * @p_cb: Used for QED_SPQ_MODE_CB,where client would initialize
0278  *        it with cookie and callback function address, if not
0279  *        using this mode then client must pass NULL.
0280  * @p_params: Pointer to params.
0281  *
0282  * Return: Void.
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 /* Almost identical to the qed_queue_start_common_params,
0293  * but here we maintain the SB index in IGU CAM.
0294  */
0295 struct qed_queue_cid_params {
0296     u8 vport_id;
0297     u16 queue_id;
0298     u8 stats_id;
0299 };
0300 
0301 /* Additional parameters required for initialization of the queue_cid
0302  * and are relevant only for a PF initializing one for its VFs.
0303  */
0304 struct qed_queue_cid_vf_params {
0305     /* Should match the VF's relative index */
0306     u8 vfid;
0307 
0308     /* 0-based queue index. Should reflect the relative qzone the
0309      * VF thinks is associated with it [in its range].
0310      */
0311     u8 vf_qid;
0312 
0313     /* Indicates a VF is legacy, making it differ in several things:
0314      *  - Producers would be placed in a different place.
0315      *  - Makes assumptions regarding the CIDs.
0316      */
0317     u8 vf_legacy;
0318 
0319     u8 qid_usage_idx;
0320 };
0321 
0322 struct qed_queue_cid {
0323     /* For stats-id, the `rel' is actually absolute as well */
0324     struct qed_queue_cid_params rel;
0325     struct qed_queue_cid_params abs;
0326 
0327     /* These have no 'relative' meaning */
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     /* VFs queues are mapped differently, so we need to know the
0337      * relative queue associated with them [0-based].
0338      * Notice this is relevant on the *PF* queue-cid of its VF's queues,
0339      * and not on the VF itself.
0340      */
0341     u8 vfid;
0342     u8 vf_qid;
0343 
0344     /* We need an additional index to differentiate between queues opened
0345      * for same queue-zone, as VFs would have to communicate the info
0346      * to the PF [otherwise PF has no way to differentiate].
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  * qed_eth_rxq_start_ramrod(): Starts an Rx queue, when queue_cid is
0377  *                             already prepared
0378  *
0379  * @p_hwfn: HW device data.
0380  * @p_cid: Pointer CID.
0381  * @bd_max_bytes: Max bytes.
0382  * @bd_chain_phys_addr: Chain physcial address.
0383  * @cqe_pbl_addr: PBL address.
0384  * @cqe_pbl_size: PBL size.
0385  *
0386  * Return: Int.
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  * qed_eth_txq_start_ramrod(): Starts a Tx queue, where queue_cid is
0397  *                             already prepared
0398  *
0399  * @p_hwfn: HW device data.
0400  * @p_cid: Pointer CID.
0401  * @pbl_addr: PBL address.
0402  * @pbl_size: PBL size.
0403  * @pq_id: Parameters for choosing the PQ for this Tx queue.
0404  *
0405  * Return: Int.
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