lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALs4sv3s4bA7E5FV2GrCZb7m_0rs5AXjOXO7p-GqKvMudi_dNA@mail.gmail.com>
Date:   Wed, 19 Apr 2023 16:00:19 +0530
From:   Pavan Chebbi <pavan.chebbi@...adcom.com>
To:     Alex Berliner <alexberliner@...gle.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        Jeroen de Borst <jeroendb@...gle.com>
Subject: Re: [PATCH net-next] gve: Add modify ring size support

On Wed, Apr 19, 2023 at 3:45 AM Alex Berliner <alexberliner@...gle.com> wrote:
>
> +static int gve_set_ringparam(struct net_device *netdev,
> +                            struct ethtool_ringparam *cmd,
> +                            struct kernel_ethtool_ringparam *kernel_cmd,
> +                            struct netlink_ext_ack *extack)
> +{
> +       struct gve_priv *priv = netdev_priv(netdev);
> +       int old_rx_desc_cnt = priv->rx_desc_cnt;
> +       int old_tx_desc_cnt = priv->tx_desc_cnt;
> +       int new_tx_desc_cnt = cmd->tx_pending;
> +       int new_rx_desc_cnt = cmd->rx_pending;
> +       int new_max_registered_pages =
> +               new_rx_desc_cnt * gve_num_rx_qpls(priv) +
> +                       GVE_TX_PAGE_COUNT * gve_num_tx_qpls(priv);
> +
> +       if (!priv->modify_ringsize_enabled) {
> +               dev_err(&priv->pdev->dev, "Modify ringsize disabled\n");
> +               return -EINVAL;
> +       }
> +
> +       if (new_tx_desc_cnt < GVE_RING_LENGTH_LIMIT_MIN ||
> +               new_rx_desc_cnt < GVE_RING_LENGTH_LIMIT_MIN) {
> +               dev_err(&priv->pdev->dev, "Ring size cannot be less than %d\n",
> +                       GVE_RING_LENGTH_LIMIT_MIN);
> +               return -EINVAL;
> +       }
> +
> +       if (new_tx_desc_cnt > GVE_RING_LENGTH_LIMIT_MAX ||
> +               new_rx_desc_cnt > GVE_RING_LENGTH_LIMIT_MAX) {
> +               dev_err(&priv->pdev->dev,
> +                       "Ring size cannot be greater than %d\n",
> +                       GVE_RING_LENGTH_LIMIT_MAX);
> +               return -EINVAL;
> +       }
> +
> +       /* Ring size must be a power of 2, will fail if passed values are not
> +        * In the future we may want to update to round down to the
> +        * closest valid ring size
> +        */
> +       if ((new_tx_desc_cnt & (new_tx_desc_cnt - 1)) != 0 ||
> +               (new_rx_desc_cnt & (new_rx_desc_cnt - 1)) != 0) {
> +               dev_err(&priv->pdev->dev, "Ring size must be a power of 2\n");
> +               return -EINVAL;
> +       }
> +
> +       if (new_tx_desc_cnt > priv->max_tx_desc_cnt) {
> +               dev_err(&priv->pdev->dev,
> +                       "Tx ring size passed %d is larger than max tx ring size %u\n",
> +                       new_tx_desc_cnt, priv->max_tx_desc_cnt);
> +               return -EINVAL;
> +       }
> +
> +       if (new_rx_desc_cnt > priv->max_rx_desc_cnt) {
> +               dev_err(&priv->pdev->dev,
> +                       "Rx ring size passed %d is larger than max rx ring size %u\n",
> +                       new_rx_desc_cnt, priv->max_rx_desc_cnt);
> +               return -EINVAL;
> +       }
> +
> +       if (new_max_registered_pages > priv->max_registered_pages) {
> +               dev_err(&priv->pdev->dev,
> +                               "Allocating too many pages %d; max %llu",
> +                               new_max_registered_pages,
> +                               priv->max_registered_pages);
> +               return -EINVAL;
> +       }
> +
> +       // Nothing to change return success

I think we should have /* */ comments?
Also, as is evident from the checkpatch report, the alignment of the
parenthesis needs to be fixed.

> +       if (new_tx_desc_cnt == old_tx_desc_cnt && new_rx_desc_cnt == old_rx_desc_cnt)
> +               return 0;

Having this condition right at the beginning can avoid unnecessary checks?

> +
> +       return gve_adjust_ring_sizes(priv, new_tx_desc_cnt, new_rx_desc_cnt);
> +}
> --
> 2.40.0.634.g4ca3ef3211-goog
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ