From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Andrew Lunn'" <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, <mengyuanlou@net-swift.com>
Subject: RE: [PATCH net-next v2 02/16] net: txgbe: Reset hardware
Date: Wed, 31 Aug 2022 10:54:40 +0800 [thread overview]
Message-ID: <025801d8bce5$0423b010$0c6b1030$@trustnetic.com> (raw)
In-Reply-To: <Yw6tsmufKFoHzu4M@lunn.ch>
On Wednesday, August 31, 2022 8:39 AM, Andrew Lunn wrote:
> n Tue, Aug 30, 2022 at 03:04:40PM +0800, Jiawen Wu wrote:
> > /* struct txgbe_mac_operations */
> > +static int txgbe_stop_adapter_dummy(struct txgbe_hw *TUP0) {
> > + return -EPERM;
>
> This is a bit of an odd error code. -EOPNOTSUPP would be more normal.
>
> I do wonder what all this dummy stuff is for...
>
Okay, I just think that this way I don't need to determine whether the
function pointer is NULL every time it is called.
> > +/**
> > + * txgbe_stop_adapter - Generic stop Tx/Rx units
> > + * @hw: pointer to hardware structure
> > + *
> > + * Sets the adapter_stopped flag within txgbe_hw struct. Clears
> > +interrupts,
> > + * disables transmit and receive units. The adapter_stopped flag is
> > +used by
> > + * the shared code and drivers to determine if the adapter is in a
> > +stopped
> > + * state and should not touch the hardware.
> > + **/
> > +int txgbe_stop_adapter(struct txgbe_hw *hw) {
> > + u16 i;
> > +
> > + /* Set the adapter_stopped flag so other driver functions stop
touching
> > + * the hardware
> > + */
> > + hw->adapter_stopped = true;
> > +
> > + /* Disable the receive unit */
> > + hw->mac.ops.disable_rx(hw);
> > +
> > + /* Set interrupt mask to stop interrupts from being generated */
> > + txgbe_intr_disable(hw, TXGBE_INTR_ALL);
> > +
> > + /* Clear any pending interrupts, flush previous writes */
> > + wr32(hw, TXGBE_PX_MISC_IC, 0xffffffff);
> > + wr32(hw, TXGBE_BME_CTL, 0x3);
> > +
> > + /* Disable the transmit unit. Each queue must be disabled. */
> > + for (i = 0; i < hw->mac.max_tx_queues; i++) {
> > + wr32m(hw, TXGBE_PX_TR_CFG(i),
> > + TXGBE_PX_TR_CFG_SWFLSH | TXGBE_PX_TR_CFG_ENABLE,
> > + TXGBE_PX_TR_CFG_SWFLSH);
> > + }
> > +
> > + /* Disable the receive unit by stopping each queue */
> > + for (i = 0; i < hw->mac.max_rx_queues; i++) {
> > + wr32m(hw, TXGBE_PX_RR_CFG(i),
> > + TXGBE_PX_RR_CFG_RR_EN, 0);
> > + }
> > +
> > + /* flush all queues disables */
> > + TXGBE_WRITE_FLUSH(hw);
> > +
> > + /* Prevent the PCI-E bus from hanging by disabling PCI-E master
> > + * access and verify no pending requests
> > + */
> > + return txgbe_disable_pcie_master(hw);
>
> Interesting. You use it here....
>
> > +}
> > +
> > +/**
> > + * txgbe_disable_pcie_master - Disable PCI-express master access
> > + * @hw: pointer to hardware structure
> > + *
> > + * Disables PCI-Express master access and verifies there are no
> > +pending
> > + * requests. TXGBE_ERR_MASTER_REQUESTS_PENDING is returned if
> master
> > +disable
> > + * bit hasn't caused the master requests to be disabled, else 0
> > + * is returned signifying master requests disabled.
> > + **/
> > +int txgbe_disable_pcie_master(struct txgbe_hw *hw) {
> > + struct txgbe_adapter *adapter = container_of(hw, struct
txgbe_adapter,
> hw);
> > + int status = 0;
> > + u32 val;
>
> But define it here, afterwards. Wrong order. Swap this around, and remove
the
> forward reference. And should this also be static? Is it used in any other
object
> file?
>
> Because you have it in the wrong order, the compiler cannot easily inline
it. The
> optimised won't do as good a job as if it had seen it first before it was
also used.
> Also, because it is not static, the compiler needs to keep a copy around
for the
> linker to use with another object file.
>
> So....
>
> Define functions before you use them.
>
> Make them static if possible.
>
> Header files should only contain definitions of functions which are used
> between object files, not within an object file.
>
There are indeed a lot of order errors in the code, I'll try to fix it.
When making the patch, I cut out every piece of functionality from the full
driver.
So there are some functions called later in other files, which currently
seems like a silly design.
next prev parent reply other threads:[~2022-08-31 2:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 7:04 [PATCH net-next v2 00/16] net: WangXun txgbe ethernet driver Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 01/16] net: txgbe: Store PCI info Jiawen Wu
2022-08-31 0:06 ` Andrew Lunn
2022-08-31 2:20 ` Jiawen Wu
2022-08-31 23:59 ` Andrew Lunn
2022-08-30 7:04 ` [PATCH net-next v2 02/16] net: txgbe: Reset hardware Jiawen Wu
2022-08-31 0:39 ` Andrew Lunn
2022-08-31 2:54 ` Jiawen Wu [this message]
2022-09-01 0:03 ` Andrew Lunn
2022-08-30 7:04 ` [PATCH net-next v2 03/16] net: txgbe: Set MAC address and register netdev Jiawen Wu
2022-08-31 1:02 ` Andrew Lunn
2022-09-22 9:58 ` Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 04/16] net: txgbe: Add operations to interact with firmware Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 05/16] net: txgbe: Identify PHY and SFP module Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 06/16] net: txgbe: Initialize service task Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 07/16] net: txgbe: Support to setup link Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 08/16] net: txgbe: Add interrupt support Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 09/16] net: txgbe: Handle various event interrupts Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 10/16] net: txgbe: Configure Rx and Tx unit of the MAC Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 11/16] net: txgbe: Allocate Rx and Tx resources Jiawen Wu
2022-08-30 23:31 ` kernel test robot
2022-08-30 7:04 ` [PATCH net-next v2 12/16] net: txgbe: Add Rx and Tx cleanup routine Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 13/16] net: txgbe: Add device Rx features Jiawen Wu
2022-09-03 19:50 ` kernel test robot
2022-08-30 7:04 ` [PATCH net-next v2 14/16] net: txgbe: Add transmit path to process packets Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 15/16] net: txgbe: Support to get system network statistics Jiawen Wu
2022-08-30 7:04 ` [PATCH net-next v2 16/16] net: txgbe: support to respond Tx hang Jiawen Wu
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='025801d8bce5$0423b010$0c6b1030$@trustnetic.com' \
--to=jiawenwu@trustnetic.com \
--cc=andrew@lunn.ch \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@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).