Re: drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c:170 ipsec_fs_roce_rx_rule_setup() warn: missing error code 'err'

From: Leon Romanovsky
Date: Mon Jan 29 2024 - 04:07:54 EST


On Mon, Jan 22, 2024 at 10:17:26AM +0300, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 80fc600fafee8ba981da6ed41a572800c8e11de6
> commit: f2f0231cfe8905af217e5bf1a08bfb8e4d3b74fb net/mlx5: Configure IPsec steering for ingress RoCEv2 MPV traffic
> config: x86_64-randconfig-161-20240120 (https://download.01.org/0day-ci/archive/20240121/202401210739.xiykyqPN-lkp@xxxxxxxxx/config)
> compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202401210739.xiykyqPN-lkp@xxxxxxxxx/
>
> smatch warnings:
> drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c:170 ipsec_fs_roce_rx_rule_setup() warn: missing error code 'err'
>
> vim +/err +170 drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c
>
> 899577600b25b3 Mark Zhang 2023-01-04 122 static int
> 899577600b25b3 Mark Zhang 2023-01-04 123 ipsec_fs_roce_rx_rule_setup(struct mlx5_core_dev *mdev,
> 899577600b25b3 Mark Zhang 2023-01-04 124 struct mlx5_flow_destination *default_dst,
> 899577600b25b3 Mark Zhang 2023-01-04 125 struct mlx5_ipsec_rx_roce *roce)
> 899577600b25b3 Mark Zhang 2023-01-04 126 {
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 127 bool is_mpv_slave = mlx5_core_is_mp_slave(mdev);
> 899577600b25b3 Mark Zhang 2023-01-04 128 struct mlx5_flow_destination dst = {};
> 899577600b25b3 Mark Zhang 2023-01-04 129 MLX5_DECLARE_FLOW_ACT(flow_act);
> 899577600b25b3 Mark Zhang 2023-01-04 130 struct mlx5_flow_handle *rule;
> 899577600b25b3 Mark Zhang 2023-01-04 131 struct mlx5_flow_spec *spec;
> 899577600b25b3 Mark Zhang 2023-01-04 132 int err = 0;
> 899577600b25b3 Mark Zhang 2023-01-04 133
> 899577600b25b3 Mark Zhang 2023-01-04 134 spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
> 899577600b25b3 Mark Zhang 2023-01-04 135 if (!spec)
> 899577600b25b3 Mark Zhang 2023-01-04 136 return -ENOMEM;
> 899577600b25b3 Mark Zhang 2023-01-04 137
> 899577600b25b3 Mark Zhang 2023-01-04 138 ipsec_fs_roce_setup_udp_dport(spec, ROCE_V2_UDP_DPORT);
> 899577600b25b3 Mark Zhang 2023-01-04 139
> 899577600b25b3 Mark Zhang 2023-01-04 140 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 141 if (is_mpv_slave) {
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 142 dst.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 143 dst.ft = roce->goto_alias_ft;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 144 } else {
> 899577600b25b3 Mark Zhang 2023-01-04 145 dst.type = MLX5_FLOW_DESTINATION_TYPE_TABLE_TYPE;
> 899577600b25b3 Mark Zhang 2023-01-04 146 dst.ft = roce->ft_rdma;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 147 }
> 899577600b25b3 Mark Zhang 2023-01-04 148 rule = mlx5_add_flow_rules(roce->ft, spec, &flow_act, &dst, 1);
> 899577600b25b3 Mark Zhang 2023-01-04 149 if (IS_ERR(rule)) {
> 899577600b25b3 Mark Zhang 2023-01-04 150 err = PTR_ERR(rule);
> 899577600b25b3 Mark Zhang 2023-01-04 151 mlx5_core_err(mdev, "Fail to add RX RoCE IPsec rule err=%d\n",
> 899577600b25b3 Mark Zhang 2023-01-04 152 err);
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 153 goto out;
> 899577600b25b3 Mark Zhang 2023-01-04 154 }
> 899577600b25b3 Mark Zhang 2023-01-04 155
> 899577600b25b3 Mark Zhang 2023-01-04 156 roce->rule = rule;
> 899577600b25b3 Mark Zhang 2023-01-04 157
> 899577600b25b3 Mark Zhang 2023-01-04 158 memset(spec, 0, sizeof(*spec));
> 899577600b25b3 Mark Zhang 2023-01-04 159 rule = mlx5_add_flow_rules(roce->ft, spec, &flow_act, default_dst, 1);
> 899577600b25b3 Mark Zhang 2023-01-04 160 if (IS_ERR(rule)) {
> 899577600b25b3 Mark Zhang 2023-01-04 161 err = PTR_ERR(rule);
> 899577600b25b3 Mark Zhang 2023-01-04 162 mlx5_core_err(mdev, "Fail to add RX RoCE IPsec miss rule err=%d\n",
> 899577600b25b3 Mark Zhang 2023-01-04 163 err);
> 899577600b25b3 Mark Zhang 2023-01-04 164 goto fail_add_default_rule;
> 899577600b25b3 Mark Zhang 2023-01-04 165 }
> 899577600b25b3 Mark Zhang 2023-01-04 166
> 899577600b25b3 Mark Zhang 2023-01-04 167 roce->roce_miss.rule = rule;
> 899577600b25b3 Mark Zhang 2023-01-04 168
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 169 if (!is_mpv_slave)
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 @170 goto out;
>
> error code here? Or perhaps if not an error code, then a comment?

It is not an error and right behavior. MPV is special device which is
combination of two devices: master and slave. So is_mpv_slave is the
best comment for everyone who touches flow steering logic :).

Thanks

>
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 171
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 172 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 173 dst.type = MLX5_FLOW_DESTINATION_TYPE_TABLE_TYPE;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 174 dst.ft = roce->ft_rdma;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 175 rule = mlx5_add_flow_rules(roce->nic_master_ft, NULL, &flow_act, &dst,
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 176 1);
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 177 if (IS_ERR(rule)) {
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 178 err = PTR_ERR(rule);
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 179 mlx5_core_err(mdev, "Fail to add RX RoCE IPsec rule for alias err=%d\n",
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 180 err);
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 181 goto fail_add_nic_master_rule;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 182 }
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 183 roce->nic_master_rule = rule;
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 184
> 899577600b25b3 Mark Zhang 2023-01-04 185 kvfree(spec);
> 899577600b25b3 Mark Zhang 2023-01-04 186 return 0;
> 899577600b25b3 Mark Zhang 2023-01-04 187
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 188 fail_add_nic_master_rule:
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 189 mlx5_del_flow_rules(roce->roce_miss.rule);
> 899577600b25b3 Mark Zhang 2023-01-04 190 fail_add_default_rule:
> 899577600b25b3 Mark Zhang 2023-01-04 191 mlx5_del_flow_rules(roce->rule);
> f2f0231cfe8905 Patrisious Haddad 2023-09-21 192 out:
> 899577600b25b3 Mark Zhang 2023-01-04 193 kvfree(spec);
> 899577600b25b3 Mark Zhang 2023-01-04 194 return err;
> 899577600b25b3 Mark Zhang 2023-01-04 195 }
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>