mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Gur Stavi <gur.stavi@huawei.com>
Cc: gongfan <gongfan1@huawei.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	linux-doc@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Cai Huoqing <cai.huoqing@linux.dev>,
	Xin Guo <guoxin09@huawei.com>,
	Shen Chenyang <shenchenyang1@hisilicon.com>,
	Zhou Shuai <zhoushuai28@huawei.com>, Wu Like <wulike1@huawei.com>,
	Shi Jing <shijing34@huawei.com>,
	Meny Yossefi <meny.yossefi@huawei.com>
Subject: Re: [RFC net-next v02 1/3] net: hinic3: module initialization and tx/rx logic
Date: Thu, 12 Dec 2024 18:41:44 +0100	[thread overview]
Message-ID: <b794027a-ef3b-4262-a952-db249a840e89@lunn.ch> (raw)
In-Reply-To: <7d62ca11c809ac646c2fd8613fd48729061c22b3.1733990727.git.gur.stavi@huawei.com>

> +static void hinic3_del_one_adev(struct hinic3_hwdev *hwdev,
> +				enum hinic3_service_type svc_type)
> +{
> +	struct hinic3_pcidev *pci_adapter = hwdev->adapter;
> +	struct hinic3_adev *hadev;
> +	bool timeout = true;
> +	unsigned long end;
> +
> +	end = jiffies + msecs_to_jiffies(HINIC3_EVENT_PROCESS_TIMEOUT);
> +	do {
> +		if (!test_and_set_bit(svc_type, &pci_adapter->state)) {
> +			timeout = false;
> +			break;
> +		}
> +		usleep_range(900, 1000);
> +	} while (time_before(jiffies, end));
> +
> +	if (timeout && !test_and_set_bit(svc_type, &pci_adapter->state))
> +		timeout = false;

Please look at using iopoll.h

> +static int hinic3_sw_init(struct net_device *netdev)
> +{
> +	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +	int err;
> +
> +	nic_dev->q_params.sq_depth = HINIC3_SQ_DEPTH;
> +	nic_dev->q_params.rq_depth = HINIC3_RQ_DEPTH;
> +
> +	hinic3_try_to_enable_rss(netdev);
> +
> +	eth_hw_addr_random(netdev);

Is using a random MAC just a temporary thing until more code is added
to access an OTP?

> +	err = register_netdev(netdev);
> +	if (err) {
> +		err = -ENOMEM;
> +		goto err_netdev;
> +	}
> +
> +	netif_carrier_off(netdev);
> +
> +	dev_set_drvdata(&adev->dev, nic_dev);

Is this used anywhere in the driver? Calling register_netdev() makes
the interface live, even before it returns. If you have NFS root for
example, it could be sending packets, etc, before drvdata is set.

> +int hinic3_set_port_mtu(struct net_device *netdev, u16 new_mtu)
> +{
> +	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> +	struct hinic3_func_tbl_cfg func_tbl_cfg = {};
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +
> +	if (new_mtu < HINIC3_MIN_MTU_SIZE) {
> +		dev_err(hwdev->dev,
> +			"Invalid mtu size: %ubytes, mtu size < %ubytes\n",
> +			new_mtu, HINIC3_MIN_MTU_SIZE);
> +		return -EINVAL;
> +	}
> +
> +	if (new_mtu > HINIC3_MAX_JUMBO_FRAME_SIZE) {
> +		dev_err(hwdev->dev, "Invalid mtu size: %ubytes, mtu size > %ubytes\n",
> +			new_mtu, HINIC3_MAX_JUMBO_FRAME_SIZE);
> +		return -EINVAL;
> +	}

The core can do this validation for you, if you set ndev->max_mtu,
ndev->min_mtu.


    Andrew

---
pw-bot: cr

  parent reply	other threads:[~2024-12-12 17:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 12:04 [RFC net-next v02 0/3] net: hinic3: Add a driver for Huawei 3rd gen NIC Gur Stavi
2024-12-12 12:04 ` [RFC net-next v02 1/3] net: hinic3: module initialization and tx/rx logic Gur Stavi
2024-12-12 17:02   ` Bjorn Helgaas
2024-12-15  8:59     ` Gur Stavi
2024-12-12 17:41   ` Andrew Lunn [this message]
2024-12-19  8:55     ` Gur Stavi
2024-12-19  8:46       ` Andrew Lunn
2024-12-19  9:28         ` Gur Stavi
2024-12-12 12:04 ` [RFC net-next v02 2/3] net: hinic3: management interfaces Gur Stavi
2024-12-12 12:04 ` [RFC net-next v02 3/3] net: hinic3: sw and hw initialization code Gur Stavi

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=b794027a-ef3b-4262-a952-db249a840e89@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andrew+netdev@lunn.ch \
    --cc=cai.huoqing@linux.dev \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gongfan1@huawei.com \
    --cc=guoxin09@huawei.com \
    --cc=gur.stavi@huawei.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meny.yossefi@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shenchenyang1@hisilicon.com \
    --cc=shijing34@huawei.com \
    --cc=wulike1@huawei.com \
    --cc=zhoushuai28@huawei.com \
    /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

all inboxes | Powered by JetHome®