2019-02-28 15:24:22 -08:00
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2019, Intel Corporation. */
# ifndef _ICE_DCB_LIB_H_
# define _ICE_DCB_LIB_H_
# include "ice.h"
2019-10-24 01:11:17 -07:00
# include "ice_base.h"
2019-02-28 15:24:22 -08:00
# include "ice_lib.h"
# ifdef CONFIG_DCB
2019-11-06 02:05:29 -08:00
# define ICE_TC_MAX_BW 100 /* Default Max BW percentage */
# define ICE_DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
# define ICE_DCB_NO_HW_CHG 1 /* DCB configuration did not change */
# define ICE_DCB_HW_CHG 2 /* DCB configuration changed, no reset */
2019-02-28 15:24:30 -08:00
void ice_dcb_rebuild ( struct ice_pf * pf ) ;
2019-02-28 15:24:24 -08:00
u8 ice_dcb_get_ena_tc ( struct ice_dcbx_cfg * dcbcfg ) ;
u8 ice_dcb_get_num_tc ( struct ice_dcbx_cfg * dcbcfg ) ;
2020-05-07 17:41:00 -07:00
void ice_vsi_set_dcb_tc_cfg ( struct ice_vsi * vsi ) ;
bool ice_is_pfc_causing_hung_q ( struct ice_pf * pf , unsigned int txqueue ) ;
2019-11-06 02:05:28 -08:00
u8 ice_dcb_get_tc ( struct ice_vsi * vsi , int queue_index ) ;
2019-11-06 02:05:29 -08:00
int
ice_pf_dcb_cfg ( struct ice_pf * pf , struct ice_dcbx_cfg * new_cfg , bool locked ) ;
2020-02-13 13:30:59 -08:00
int ice_dcb_bwchk ( struct ice_pf * pf , struct ice_dcbx_cfg * dcbcfg ) ;
2019-11-08 06:23:29 -08:00
void ice_pf_dcb_recfg ( struct ice_pf * pf ) ;
2019-02-28 15:24:27 -08:00
void ice_vsi_cfg_dcb_rings ( struct ice_vsi * vsi ) ;
2019-04-16 10:24:29 -07:00
int ice_init_pf_dcb ( struct ice_pf * pf , bool locked ) ;
2019-02-28 15:24:29 -08:00
void ice_update_dcb_stats ( struct ice_pf * pf ) ;
2020-05-15 17:51:19 -07:00
void
2019-02-28 15:24:28 -08:00
ice_tx_prepare_vlan_flags_dcb ( struct ice_ring * tx_ring ,
struct ice_tx_buf * first ) ;
2019-02-28 15:24:26 -08:00
void
ice_dcb_process_lldp_set_mib_change ( struct ice_pf * pf ,
struct ice_rq_event_info * event ) ;
2019-09-09 06:47:46 -07:00
void ice_vsi_cfg_netdev_tc ( struct ice_vsi * vsi , u8 ena_tc ) ;
2020-05-07 17:41:00 -07:00
/**
* ice_find_q_in_range
* @ low : start of queue range for a TC i . e . offset of TC
* @ high : start of queue for next TC
* @ tx_q : hung_queue / tx_queue
*
* finds if queue ' tx_q ' falls between the two offsets of any given TC
*/
static inline bool ice_find_q_in_range ( u16 low , u16 high , unsigned int tx_q )
{
return ( tx_q > = low ) & & ( tx_q < high ) ;
}
2019-02-28 15:24:27 -08:00
static inline void
ice_set_cgd_num ( struct ice_tlan_ctx * tlan_ctx , struct ice_ring * ring )
{
tlan_ctx - > cgd_num = ring - > dcb_tc ;
}
2020-07-13 13:53:04 -07:00
static inline bool ice_is_dcb_active ( struct ice_pf * pf )
{
return ( test_bit ( ICE_FLAG_FW_LLDP_AGENT , pf - > flags ) | |
test_bit ( ICE_FLAG_DCB_ENA , pf - > flags ) ) ;
}
2019-02-28 15:24:22 -08:00
# else
2019-02-28 15:24:30 -08:00
# define ice_dcb_rebuild(pf) do {} while (0)
2019-02-28 15:24:24 -08:00
static inline u8 ice_dcb_get_ena_tc ( struct ice_dcbx_cfg __always_unused * dcbcfg )
{
return ICE_DFLT_TRAFFIC_CLASS ;
}
static inline u8 ice_dcb_get_num_tc ( struct ice_dcbx_cfg __always_unused * dcbcfg )
{
return 1 ;
}
2019-11-06 02:05:28 -08:00
static inline u8
ice_dcb_get_tc ( struct ice_vsi __always_unused * vsi ,
int __always_unused queue_index )
{
return 0 ;
}
2019-04-16 10:24:29 -07:00
static inline int
ice_init_pf_dcb ( struct ice_pf * pf , bool __always_unused locked )
2019-02-28 15:24:22 -08:00
{
2019-11-08 06:23:26 -08:00
dev_dbg ( ice_pf_to_dev ( pf ) , " DCB not supported \n " ) ;
2019-02-28 15:24:22 -08:00
return - EOPNOTSUPP ;
}
2019-02-28 15:24:24 -08:00
2019-11-06 02:05:29 -08:00
static inline int
ice_pf_dcb_cfg ( struct ice_pf __always_unused * pf ,
struct ice_dcbx_cfg __always_unused * new_cfg ,
bool __always_unused locked )
{
return - EOPNOTSUPP ;
}
2019-02-28 15:24:28 -08:00
static inline int
ice_tx_prepare_vlan_flags_dcb ( struct ice_ring __always_unused * tx_ring ,
struct ice_tx_buf __always_unused * first )
{
return 0 ;
}
2020-07-13 13:53:04 -07:00
static inline bool ice_is_dcb_active ( struct ice_pf __always_unused * pf )
{
return false ;
}
2020-05-07 17:41:00 -07:00
static inline bool
ice_is_pfc_causing_hung_q ( struct ice_pf __always_unused * pf ,
unsigned int __always_unused txqueue )
{
return false ;
}
2019-02-28 15:24:29 -08:00
# define ice_update_dcb_stats(pf) do {} while (0)
2019-11-08 06:23:29 -08:00
# define ice_pf_dcb_recfg(pf) do {} while (0)
2019-02-28 15:24:27 -08:00
# define ice_vsi_cfg_dcb_rings(vsi) do {} while (0)
2019-02-28 15:24:26 -08:00
# define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0)
2019-02-28 15:24:27 -08:00
# define ice_set_cgd_num(tlan_ctx, ring) do {} while (0)
2019-09-09 06:47:46 -07:00
# define ice_vsi_cfg_netdev_tc(vsi, ena_tc) do {} while (0)
2019-02-28 15:24:22 -08:00
# endif /* CONFIG_DCB */
# endif /* _ICE_DCB_LIB_H_ */