linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dlinkin@nvidia.com
Cc: linux-rdma@vger.kernel.org
Subject: [bug report] net/mlx5: E-switch, Allow setting share/max tx rate limits of rate groups
Date: Wed, 25 Aug 2021 11:56:55 +0300	[thread overview]
Message-ID: <20210825085655.GA28138@kili> (raw)

Hello Dmytro Linkin,

The patch f47e04eb96e0: "net/mlx5: E-switch, Allow setting share/max
tx rate limits of rate groups" from May 31, 2021, leads to the
following Smatch static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c:483 esw_qos_create_rate_group()
	warn: passing zero to 'ERR_PTR'

drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
    434 static struct mlx5_esw_rate_group *
    435 esw_qos_create_rate_group(struct mlx5_eswitch *esw, struct netlink_ext_ack *extack)
    436 {
    437 	u32 tsar_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {};
    438 	struct mlx5_esw_rate_group *group;
    439 	u32 divider;
    440 	int err;
    441 
    442 	if (!MLX5_CAP_QOS(esw->dev, log_esw_max_sched_depth))
    443 		return ERR_PTR(-EOPNOTSUPP);
    444 
    445 	group = kzalloc(sizeof(*group), GFP_KERNEL);
    446 	if (!group)
    447 		return ERR_PTR(-ENOMEM);
    448 
    449 	MLX5_SET(scheduling_context, tsar_ctx, parent_element_id,
    450 		 esw->qos.root_tsar_ix);
    451 	err = mlx5_create_scheduling_element_cmd(esw->dev,
    452 						 SCHEDULING_HIERARCHY_E_SWITCH,
    453 						 tsar_ctx,
    454 						 &group->tsar_ix);
    455 	if (err) {
    456 		NL_SET_ERR_MSG_MOD(extack, "E-Switch create TSAR for group failed");
    457 		goto err_sched_elem;
    458 	}
    459 
    460 	list_add_tail(&group->list, &esw->qos.groups);
    461 
    462 	divider = esw_qos_calculate_min_rate_divider(esw, group, true);
    463 	if (divider) {
    464 		err = esw_qos_normalize_groups_min_rate(esw, divider, extack);
    465 		if (err) {
    466 			NL_SET_ERR_MSG_MOD(extack, "E-Switch groups normalization failed");
    467 			goto err_min_rate;

Wouldn't we want to we want to propagate this error code


    468 		}
    469 	}
    470 	trace_mlx5_esw_group_qos_create(esw->dev, group, group->tsar_ix);
    471 
    472 	return group;
    473 
    474 err_min_rate:
    475 	list_del(&group->list);
    476 	err = mlx5_destroy_scheduling_element_cmd(esw->dev,
    477 						  SCHEDULING_HIERARCHY_E_SWITCH,
    478 						  group->tsar_ix);

instead of this one?  Also if this succeeds we return succeess?

    479 	if (err)
    480 		NL_SET_ERR_MSG_MOD(extack, "E-Switch destroy TSAR for group failed");
    481 err_sched_elem:
    482 	kfree(group);
--> 483 	return ERR_PTR(err);
    484 }

regards,
dan carpenter

             reply	other threads:[~2021-08-25  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25  8:56 Dan Carpenter [this message]
2021-08-30  6:46 ` [bug report] net/mlx5: E-switch, Allow setting share/max tx rate limits of rate groups Dmytro Linkin
2021-08-30  8:45   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210825085655.GA28138@kili \
    --to=dan.carpenter@oracle.com \
    --cc=dlinkin@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).