Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
0002 /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
0003 
0004 #ifndef __MLX5_EN_SELQ_H__
0005 #define __MLX5_EN_SELQ_H__
0006 
0007 #include <linux/kernel.h>
0008 
0009 struct mlx5e_selq_params;
0010 
0011 struct mlx5e_selq {
0012     struct mlx5e_selq_params __rcu *active;
0013     struct mlx5e_selq_params *standby;
0014     struct mutex *state_lock; /* points to priv->state_lock */
0015     bool is_prepared;
0016 };
0017 
0018 struct mlx5e_params;
0019 struct net_device;
0020 struct sk_buff;
0021 
0022 int mlx5e_selq_init(struct mlx5e_selq *selq, struct mutex *state_lock);
0023 void mlx5e_selq_cleanup(struct mlx5e_selq *selq);
0024 void mlx5e_selq_prepare_params(struct mlx5e_selq *selq, struct mlx5e_params *params);
0025 void mlx5e_selq_prepare_htb(struct mlx5e_selq *selq, u16 htb_maj_id, u16 htb_defcls);
0026 bool mlx5e_selq_is_htb_enabled(struct mlx5e_selq *selq);
0027 void mlx5e_selq_apply(struct mlx5e_selq *selq);
0028 void mlx5e_selq_cancel(struct mlx5e_selq *selq);
0029 
0030 static inline u16 mlx5e_txq_to_ch_ix(u16 txq, u16 num_channels)
0031 {
0032     while (unlikely(txq >= num_channels))
0033         txq -= num_channels;
0034     return txq;
0035 }
0036 
0037 static inline u16 mlx5e_txq_to_ch_ix_htb(u16 txq, u16 num_channels)
0038 {
0039     if (unlikely(txq >= num_channels)) {
0040         if (unlikely(txq >= num_channels << 3))
0041             txq %= num_channels;
0042         else
0043             do
0044                 txq -= num_channels;
0045             while (txq >= num_channels);
0046     }
0047     return txq;
0048 }
0049 
0050 u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
0051                struct net_device *sb_dev);
0052 
0053 #endif /* __MLX5_EN_SELQ_H__ */