linux/drivers/net/ethernet/intel/ice/ice_dcb_lib.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/* Copyright (c) 2019, Intel Corporation. */
   3
   4#ifndef _ICE_DCB_LIB_H_
   5#define _ICE_DCB_LIB_H_
   6
   7#include "ice.h"
   8#include "ice_base.h"
   9#include "ice_lib.h"
  10
  11#ifdef CONFIG_DCB
  12#define ICE_TC_MAX_BW           100 /* Default Max BW percentage */
  13#define ICE_DCB_HW_CHG_RST      0 /* DCB configuration changed with reset */
  14#define ICE_DCB_NO_HW_CHG       1 /* DCB configuration did not change */
  15#define ICE_DCB_HW_CHG          2 /* DCB configuration changed, no reset */
  16
  17void ice_dcb_rebuild(struct ice_pf *pf);
  18u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg);
  19u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg);
  20void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi);
  21bool ice_is_pfc_causing_hung_q(struct ice_pf *pf, unsigned int txqueue);
  22u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index);
  23int
  24ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked);
  25int ice_dcb_bwchk(struct ice_pf *pf, struct ice_dcbx_cfg *dcbcfg);
  26void ice_pf_dcb_recfg(struct ice_pf *pf);
  27void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
  28int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
  29void ice_update_dcb_stats(struct ice_pf *pf);
  30void
  31ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
  32                              struct ice_tx_buf *first);
  33void
  34ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
  35                                    struct ice_rq_event_info *event);
  36void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
  37
  38/**
  39 * ice_find_q_in_range
  40 * @low: start of queue range for a TC i.e. offset of TC
  41 * @high: start of queue for next TC
  42 * @tx_q: hung_queue/tx_queue
  43 *
  44 * finds if queue 'tx_q' falls between the two offsets of any given TC
  45 */
  46static inline bool ice_find_q_in_range(u16 low, u16 high, unsigned int tx_q)
  47{
  48        return (tx_q >= low) && (tx_q < high);
  49}
  50
  51static inline void
  52ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring)
  53{
  54        tlan_ctx->cgd_num = ring->dcb_tc;
  55}
  56
  57static inline bool ice_is_dcb_active(struct ice_pf *pf)
  58{
  59        return (test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags) ||
  60                test_bit(ICE_FLAG_DCB_ENA, pf->flags));
  61}
  62#else
  63static inline void ice_dcb_rebuild(struct ice_pf *pf) { }
  64
  65static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
  66{
  67        return ICE_DFLT_TRAFFIC_CLASS;
  68}
  69
  70static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
  71{
  72        return 1;
  73}
  74
  75static inline u8
  76ice_dcb_get_tc(struct ice_vsi __always_unused *vsi,
  77               int __always_unused queue_index)
  78{
  79        return 0;
  80}
  81
  82static inline int
  83ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
  84{
  85        dev_dbg(ice_pf_to_dev(pf), "DCB not supported\n");
  86        return -EOPNOTSUPP;
  87}
  88
  89static inline int
  90ice_pf_dcb_cfg(struct ice_pf __always_unused *pf,
  91               struct ice_dcbx_cfg __always_unused *new_cfg,
  92               bool __always_unused locked)
  93{
  94        return -EOPNOTSUPP;
  95}
  96
  97static inline int
  98ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring,
  99                              struct ice_tx_buf __always_unused *first)
 100{
 101        return 0;
 102}
 103
 104static inline bool ice_is_dcb_active(struct ice_pf __always_unused *pf)
 105{
 106        return false;
 107}
 108
 109static inline bool
 110ice_is_pfc_causing_hung_q(struct ice_pf __always_unused *pf,
 111                          unsigned int __always_unused txqueue)
 112{
 113        return false;
 114}
 115
 116static inline void ice_pf_dcb_recfg(struct ice_pf *pf) { }
 117static inline void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi) { }
 118static inline void ice_update_dcb_stats(struct ice_pf *pf) { }
 119static inline void
 120ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, struct ice_rq_event_info *event) { }
 121static inline void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc) { }
 122static inline void ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring) { }
 123#endif /* CONFIG_DCB */
 124#endif /* _ICE_DCB_LIB_H_ */
 125