selq.h (1336B)
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 9struct mlx5e_selq_params; 10 11struct 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 18struct mlx5e_params; 19struct net_device; 20struct sk_buff; 21 22int mlx5e_selq_init(struct mlx5e_selq *selq, struct mutex *state_lock); 23void mlx5e_selq_cleanup(struct mlx5e_selq *selq); 24void mlx5e_selq_prepare(struct mlx5e_selq *selq, struct mlx5e_params *params, bool htb); 25void mlx5e_selq_apply(struct mlx5e_selq *selq); 26void mlx5e_selq_cancel(struct mlx5e_selq *selq); 27 28static 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 35static 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 48u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, 49 struct net_device *sb_dev); 50 51#endif /* __MLX5_EN_SELQ_H__ */