diff options
author | Tariq Toukan <tariqt@mellanox.com> | 2018-02-07 07:51:45 -0500 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2018-03-27 20:17:27 -0400 |
commit | 2ccb0a79018c9fafa913654163adc9dbac1280c5 (patch) | |
tree | 8f408c2ac34e69b781f80aed17e43e7bbe611779 | |
parent | 2a0f561bf81c13d36910c7312ac8c67f83320a07 (diff) |
net/mlx5e: Add ethtool priv-flag for Striding RQ
Add a control private flag in ethtool to enable/disable
Striding RQ feature.
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 files changed, 60 insertions, 8 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 45d0c64e77e5..13dd7a97ae04 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h | |||
@@ -205,12 +205,14 @@ static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = { | |||
205 | "rx_cqe_moder", | 205 | "rx_cqe_moder", |
206 | "tx_cqe_moder", | 206 | "tx_cqe_moder", |
207 | "rx_cqe_compress", | 207 | "rx_cqe_compress", |
208 | "rx_striding_rq", | ||
208 | }; | 209 | }; |
209 | 210 | ||
210 | enum mlx5e_priv_flag { | 211 | enum mlx5e_priv_flag { |
211 | MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0), | 212 | MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0), |
212 | MLX5E_PFLAG_TX_CQE_BASED_MODER = (1 << 1), | 213 | MLX5E_PFLAG_TX_CQE_BASED_MODER = (1 << 1), |
213 | MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 2), | 214 | MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 2), |
215 | MLX5E_PFLAG_RX_STRIDING_RQ = (1 << 3), | ||
214 | }; | 216 | }; |
215 | 217 | ||
216 | #define MLX5E_SET_PFLAG(params, pflag, enable) \ | 218 | #define MLX5E_SET_PFLAG(params, pflag, enable) \ |
@@ -827,6 +829,10 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq); | |||
827 | void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq); | 829 | void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq); |
828 | void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq); | 830 | void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq); |
829 | 831 | ||
832 | bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev); | ||
833 | bool mlx5e_striding_rq_possible(struct mlx5_core_dev *mdev, | ||
834 | struct mlx5e_params *params); | ||
835 | |||
830 | void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info, | 836 | void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info, |
831 | bool recycle); | 837 | bool recycle); |
832 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); | 838 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
@@ -917,6 +923,7 @@ void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, | |||
917 | u8 cq_period_mode); | 923 | u8 cq_period_mode); |
918 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, | 924 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, |
919 | u8 cq_period_mode); | 925 | u8 cq_period_mode); |
926 | void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params); | ||
920 | void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, | 927 | void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, |
921 | struct mlx5e_params *params); | 928 | struct mlx5e_params *params); |
922 | 929 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 234b5b2ebf0f..7bfe17b7c279 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | |||
@@ -1598,6 +1598,38 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, | |||
1598 | return 0; | 1598 | return 0; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable) | ||
1602 | { | ||
1603 | struct mlx5e_priv *priv = netdev_priv(netdev); | ||
1604 | struct mlx5_core_dev *mdev = priv->mdev; | ||
1605 | struct mlx5e_channels new_channels = {}; | ||
1606 | int err; | ||
1607 | |||
1608 | if (enable) { | ||
1609 | if (!mlx5e_check_fragmented_striding_rq_cap(mdev)) | ||
1610 | return -EOPNOTSUPP; | ||
1611 | if (!mlx5e_striding_rq_possible(mdev, &priv->channels.params)) | ||
1612 | return -EINVAL; | ||
1613 | } | ||
1614 | |||
1615 | new_channels.params = priv->channels.params; | ||
1616 | |||
1617 | MLX5E_SET_PFLAG(&new_channels.params, MLX5E_PFLAG_RX_STRIDING_RQ, enable); | ||
1618 | mlx5e_set_rq_type(mdev, &new_channels.params); | ||
1619 | |||
1620 | if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { | ||
1621 | priv->channels.params = new_channels.params; | ||
1622 | return 0; | ||
1623 | } | ||
1624 | |||
1625 | err = mlx5e_open_channels(priv, &new_channels); | ||
1626 | if (err) | ||
1627 | return err; | ||
1628 | |||
1629 | mlx5e_switch_priv_channels(priv, &new_channels, NULL); | ||
1630 | return 0; | ||
1631 | } | ||
1632 | |||
1601 | static int mlx5e_handle_pflag(struct net_device *netdev, | 1633 | static int mlx5e_handle_pflag(struct net_device *netdev, |
1602 | u32 wanted_flags, | 1634 | u32 wanted_flags, |
1603 | enum mlx5e_priv_flag flag, | 1635 | enum mlx5e_priv_flag flag, |
@@ -1643,6 +1675,12 @@ static int mlx5e_set_priv_flags(struct net_device *netdev, u32 pflags) | |||
1643 | err = mlx5e_handle_pflag(netdev, pflags, | 1675 | err = mlx5e_handle_pflag(netdev, pflags, |
1644 | MLX5E_PFLAG_RX_CQE_COMPRESS, | 1676 | MLX5E_PFLAG_RX_CQE_COMPRESS, |
1645 | set_pflag_rx_cqe_compress); | 1677 | set_pflag_rx_cqe_compress); |
1678 | if (err) | ||
1679 | goto out; | ||
1680 | |||
1681 | err = mlx5e_handle_pflag(netdev, pflags, | ||
1682 | MLX5E_PFLAG_RX_STRIDING_RQ, | ||
1683 | set_pflag_rx_striding_rq); | ||
1646 | 1684 | ||
1647 | out: | 1685 | out: |
1648 | mutex_unlock(&priv->state_lock); | 1686 | mutex_unlock(&priv->state_lock); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index ffe3b2469032..7610a7916e96 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c | |||
@@ -71,7 +71,7 @@ struct mlx5e_channel_param { | |||
71 | struct mlx5e_cq_param icosq_cq; | 71 | struct mlx5e_cq_param icosq_cq; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev) | 74 | bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev) |
75 | { | 75 | { |
76 | return MLX5_CAP_GEN(mdev, striding_rq) && | 76 | return MLX5_CAP_GEN(mdev, striding_rq) && |
77 | MLX5_CAP_GEN(mdev, umr_ptr_rlky) && | 77 | MLX5_CAP_GEN(mdev, umr_ptr_rlky) && |
@@ -132,14 +132,17 @@ void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, | |||
132 | MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)); | 132 | MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)); |
133 | } | 133 | } |
134 | 134 | ||
135 | static bool slow_pci_heuristic(struct mlx5_core_dev *mdev); | 135 | bool mlx5e_striding_rq_possible(struct mlx5_core_dev *mdev, |
136 | struct mlx5e_params *params) | ||
137 | { | ||
138 | return mlx5e_check_fragmented_striding_rq_cap(mdev) && | ||
139 | !params->xdp_prog && !MLX5_IPSEC_DEV(mdev); | ||
140 | } | ||
136 | 141 | ||
137 | static void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, | 142 | void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params) |
138 | struct mlx5e_params *params) | ||
139 | { | 143 | { |
140 | params->rq_wq_type = mlx5e_check_fragmented_striding_rq_cap(mdev) && | 144 | params->rq_wq_type = mlx5e_striding_rq_possible(mdev, params) && |
141 | !slow_pci_heuristic(mdev) && | 145 | MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ) ? |
142 | !params->xdp_prog && !MLX5_IPSEC_DEV(mdev) ? | ||
143 | MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ : | 146 | MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ : |
144 | MLX5_WQ_TYPE_LINKED_LIST; | 147 | MLX5_WQ_TYPE_LINKED_LIST; |
145 | } | 148 | } |
@@ -4027,6 +4030,9 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, | |||
4027 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def); | 4030 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def); |
4028 | 4031 | ||
4029 | /* RQ */ | 4032 | /* RQ */ |
4033 | if (mlx5e_striding_rq_possible(mdev, params)) | ||
4034 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ, | ||
4035 | !slow_pci_heuristic(mdev)); | ||
4030 | mlx5e_set_rq_type(mdev, params); | 4036 | mlx5e_set_rq_type(mdev, params); |
4031 | mlx5e_init_rq_type_params(mdev, params); | 4037 | mlx5e_init_rq_type_params(mdev, params); |
4032 | 4038 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c index 870584a07c48..a35608faf8d2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | |||
@@ -56,7 +56,8 @@ static void mlx5i_build_nic_params(struct mlx5_core_dev *mdev, | |||
56 | struct mlx5e_params *params) | 56 | struct mlx5e_params *params) |
57 | { | 57 | { |
58 | /* Override RQ params as IPoIB supports only LINKED LIST RQ for now */ | 58 | /* Override RQ params as IPoIB supports only LINKED LIST RQ for now */ |
59 | params->rq_wq_type = MLX5_WQ_TYPE_LINKED_LIST; | 59 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ, false); |
60 | mlx5e_set_rq_type(mdev, params); | ||
60 | mlx5e_init_rq_type_params(mdev, params); | 61 | mlx5e_init_rq_type_params(mdev, params); |
61 | 62 | ||
62 | /* RQ size in ipoib by default is 512 */ | 63 | /* RQ size in ipoib by default is 512 */ |