1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ 3 4 #ifndef __MLX5_EN_SELQ_H__ 5 #define __MLX5_EN_SELQ_H__ 6 7 #include <linux/kernel.h> 8 9 struct mlx5e_selq_params; 10 11 struct mlx5e_selq { 12 struct mlx5e_selq_params __rcu *active; 13 struct mlx5e_selq_params *standby; 14 struct mutex *state_lock; /* points to priv->state_lock */ 15 bool is_prepared; 16 }; 17 18 struct mlx5e_params; 19 struct net_device; 20 struct sk_buff; 21 22 int mlx5e_selq_init(struct mlx5e_selq *selq, struct mutex *state_lock); 23 void mlx5e_selq_cleanup(struct mlx5e_selq *selq); 24 void mlx5e_selq_prepare(struct mlx5e_selq *selq, struct mlx5e_params *params, bool htb); 25 void mlx5e_selq_apply(struct mlx5e_selq *selq); 26 void mlx5e_selq_cancel(struct mlx5e_selq *selq); 27 28 static inline u16 mlx5e_txq_to_ch_ix(u16 txq, u16 num_channels) 29 { 30 while (unlikely(txq >= num_channels)) 31 txq -= num_channels; 32 return txq; 33 } 34 35 static inline u16 mlx5e_txq_to_ch_ix_htb(u16 txq, u16 num_channels) 36 { 37 if (unlikely(txq >= num_channels)) { 38 if (unlikely(txq >= num_channels << 3)) 39 txq %= num_channels; 40 else 41 do 42 txq -= num_channels; 43 while (txq >= num_channels); 44 } 45 return txq; 46 } 47 48 u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, 49 struct net_device *sb_dev); 50 51 #endif /* __MLX5_EN_SELQ_H__ */ 52