From: Vladimir Oltean <olteanv@gmail.com>
To: Furong Xu <0x1207@gmail.com>
Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Simon Horman <horms@kernel.org>,
Serge Semin <fancer.lancer@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
xfr@outlook.com
Subject: Re: [PATCH net-next v2 1/8] net: stmmac: Introduce separate files for FPE implementation
Date: Fri, 18 Oct 2024 12:21:38 +0300 [thread overview]
Message-ID: <20241018092138.xo2zoadx2jng27rp@skbuf> (raw)
In-Reply-To: <a5c4bc8682a6ff108d4721e46f08dc0ac799ffcd.1729233020.git.0x1207@gmail.com>
On Fri, Oct 18, 2024 at 02:39:07PM +0800, Furong Xu wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h
> new file mode 100644
> index 000000000000..d4d46a07d6a7
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h
> @@ -0,0 +1,54 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2024 Furong Xu <0x1207@gmail.com>
> + * stmmac FPE(802.3 Qbu) handling
> + */
> +#include "stmmac.h"
> +
> +#define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3
> +#define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128
> +
> +#define MAC_FPE_CTRL_STS 0x00000234
> +#define TRSP BIT(19)
> +#define TVER BIT(18)
> +#define RRSP BIT(17)
> +#define RVER BIT(16)
> +#define SRSP BIT(2)
> +#define SVER BIT(1)
> +#define EFPE BIT(0)
> +
> +#define MTL_FPE_CTRL_STS 0x00000c90
> +/* Preemption Classification */
> +#define DWMAC5_PREEMPTION_CLASS GENMASK(15, 8)
> +/* Additional Fragment Size of preempted frames */
> +#define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0)
> +
> +#define XGMAC_FPE_CTRL_STS 0x00000280
> +#define XGMAC_EFPE BIT(0)
> +
> +/* FPE link-partner hand-shaking mPacket type */
> +enum stmmac_mpacket_type {
> + MPACKET_VERIFY = 0,
> + MPACKET_RESPONSE = 1,
> +};
> +
> +void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up);
> +void stmmac_fpe_event_status(struct stmmac_priv *priv, int status);
> +void stmmac_fpe_init(struct stmmac_priv *priv);
> +void stmmac_fpe_apply(struct stmmac_priv *priv);
> +
> +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg,
> + u32 num_txq, u32 num_rxq,
> + bool tx_enable, bool pmac_enable);
> +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr,
> + struct stmmac_fpe_cfg *cfg,
> + enum stmmac_mpacket_type type);
> +int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev);
> +int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr);
> +void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size);
> +int dwmac5_fpe_map_preemption_class(struct net_device *ndev,
> + struct netlink_ext_ack *extack, u32 pclass);
> +
> +void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg,
> + u32 num_txq, u32 num_rxq,
> + bool tx_enable, bool pmac_enable);
2 comments about this header:
- it would be good if it contained a "#pragma once" equivalent, in case
other headers include it (#ifndef STMMAC_FPE_H #define STMMAC_FPE_H).
- it is good practice to only keep inside the header those definitions
which are truly exported by stmmac_fpe.c towards external callers.
That means that the #defines which are only used within stmmac_fpe.c
shouldn't be here, but inside that C file.
- You could remove the dependency upon the giant #include "stmmac.h" and
just provide those definitions necessary for this header to be
self-consistent. By self-consistent I mean that a dummy C file
containing just #include "stmmac_fpe.h" should compile without errors.
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 7e46dca90628..3fe0a555aa9a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
- stmmac_xdp.o stmmac_est.o stmmac_fpe.o \
+ stmmac_xdp.o stmmac_est.o stmmac_fpe.o dummy.o \
$(stmmac-y)
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dummy.c b/drivers/net/ethernet/stmicro/stmmac/dummy.c
new file mode 100644
index 000000000000..fc976afd5e40
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dummy.c
@@ -0,0 +1 @@
+#include "stmmac_fpe.h"
The current stmmac_fpe.h as you've posted it does pass the dummy test,
but I think it can be further minimized. Having headers larger than they
need to be will increase build time, little by little.
Well, those were 3 comments :(
next prev parent reply other threads:[~2024-10-18 9:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 6:39 [PATCH net-next v2 0/8] net: stmmac: Refactor FPE as a separate module Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 1/8] net: stmmac: Introduce separate files for FPE implementation Furong Xu
2024-10-18 9:21 ` Vladimir Oltean [this message]
2024-10-18 6:39 ` [PATCH net-next v2 2/8] net: stmmac: Introduce stmmac_fpe_ops for gmac4 and xgmac Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 3/8] net: stmmac: Rework macro definitions " Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 4/8] net: stmmac: Refactor stmmac_fpe_ops functions for reuse Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 5/8] net: stmmac: xgmac: Rename XGMAC_RQ to XGMAC_FPRQ Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 6/8] net: stmmac: xgmac: Switch to common_fpe_configure() Furong Xu
2024-10-18 6:39 ` [PATCH net-next v2 7/8] net: stmmac: xgmac: Complete FPE support Furong Xu
2024-10-18 9:13 ` Vladimir Oltean
2024-10-18 9:31 ` Russell King (Oracle)
2024-10-18 10:00 ` Furong Xu
2024-10-18 16:59 ` Andrew Lunn
2024-10-18 6:39 ` [PATCH net-next v2 8/8] net: stmmac: xgmac: Enable FPE for tc-mqprio/tc-taprio Furong Xu
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=20241018092138.xo2zoadx2jng27rp@skbuf \
--to=olteanv@gmail.com \
--cc=0x1207@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fancer.lancer@gmail.com \
--cc=horms@kernel.org \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xfr@outlook.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