From: Andrew Lunn <andrew@lunn.ch>
To: filipp.dunsky@gmail.com
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Hans Ulli Kroll <ulli.kroll@googlemail.com>,
Russell King <linux@armlinux.org.uk>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v6 2/3] net: cortina: Add CS7542 CPU network datapath
Date: Wed, 2 Dec 2026 03:08:02 +0100 [thread overview]
Message-ID: <8fc46e0b-0b85-4bad-9c78-58cb5f2dd2d3@lunn.ch> (raw)
In-Reply-To: <20261202-b4-cs7542-ethernet-v6-2-a8c1905efa9f@gmail.com>
> + ret = read_poll_timeout(readl, val,
> + !(val & FE_HASH_STATUS_INIT_IN_PROGRESS),
> + FE_HASH_INIT_POLL_US, FE_HASH_INIT_TIMEOUT_US,
> + true, fe + FETOP_HASH_STATUS);
> + if (ret) {
> + dev_err(dev, "FE hash init timeout: 0x%08x\n", val);
> + return ret;
> + }
> +
> + return 0;
This can be simplified to:
> + if (ret)
> + dev_err(dev, "FE hash init timeout: 0x%08x\n", val);
> +
> + return ret;
> + }
> +static int fe_class_write(struct device *dev, void __iomem *fe,
> + unsigned int idx, unsigned int sdb_idx,
> + unsigned int lspid, unsigned int lspid_mask,
> + unsigned int rule_priority)
> +{
> + u32 data[20];
> + unsigned int i;
Reverse Christmas tree.
> +static int cs_ne_ni_init(struct cs_ne *ne)
> +{
> + u32 val;
> + int ret, i;
Ditto
> +/* Probe errors run before any RX address is published to hardware. */
> +static void cs_ne_rx_cleanup(void *data)
> +{
> + struct cs_ne *ne = data;
> + struct cs_ne_rx_buf *buf;
> + unsigned long index;
> +static void cs_ne_tx_reap(struct cs_ne *ne);
No forward declarations. Put the functions in the correct order.
> +
> +static int cs_ne_rx_poll(struct napi_struct *napi, int budget)
> +{
> + struct cs_ne_port *port = container_of(napi, struct cs_ne_port, napi);
> + struct cs_ne *ne = port->ne;
> + struct net_device *ndev = port->ndev;
> + struct cs_ne_rx_buf *bufs[CS_NE_RX_MAX_BUFS];
> + dma_addr_t dma[CS_NE_RX_MAX_BUFS];
> + void __iomem *desc;
> + struct sk_buff *skb;
> + void *data;
> + u32 wr, rd, next, w1, hdre_hi, hdre_lo, pkt_size;
> + u32 off, total, dma_bytes, seg, nbufs, remaining;
> + unsigned int i;
> + int done = 0;
> + bool valid, retry = false, defer = false;
> + unsigned long flags;
More Reverse Christmas.
Also, given the number of local variables here, maybe this function
needs breaking up into helpers.
https://www.kernel.org/doc/html/latest/process/coding-style.html#functions
> +static netdev_tx_t cs_ne_xmit_sg(struct sk_buff *skb, struct net_device *ndev)
> +{
> + struct cs_ne_port *port = netdev_priv(ndev);
> + struct cs_ne *ne = port->ne;
> + struct cs_ne_txq *txq = &ne->txq;
> + int nfrags = skb_shinfo(skb)->nr_frags;
> + u16 first = txq->head;
> + struct cs_ne_tx_buf *buf;
> + dma_addr_t dma;
> + u32 free, len;
> + int i;
> +static int cs_ne_stop(struct net_device *ndev)
Probably should be a void function. If anything goes wrong, there is
not much you can do about it.
> +static int cs_ne_set_mac_address(struct net_device *ndev, void *addr)
> +{
> + struct cs_ne_port *port = netdev_priv(ndev);
> + struct cs_ne *ne = port->ne;
> + struct sockaddr *sa = addr;
> + int ret, i;
> +
> + ret = eth_prepare_mac_addr_change(ndev, addr);
> + if (ret)
> + return ret;
> + /* NI_MAC_ADDR0/1 are shared; only the last byte is per-port. */
Can you explain that a bit more.
"ip link set address" lets you set the address on an interface, and
each interface should be independent of other interfaces.
> + if (!ret) {
> + if (fixed && memcmp(base, ne->addresses[id], ETH_ALEN - 1)) {
> + of_node_put(np);
> + return dev_err_probe(ne->dev, -EINVAL,
> + "MACs must share their first five bytes\n");
Why? Is the hardware broken?
> +static int cs_ne_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *np;
> + struct cs_ne *ne;
> + int ret, i, nports = 0;
Andrew
next prev parent reply other threads:[~2026-12-02 2:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:36 [PATCH net-next v6 0/3] Add Cortina Systems CS7542 network engine support Fil Dunsky via B4 Relay
2026-12-01 23:36 ` [PATCH net-next v6 1/3] dt-bindings: net: Add Cortina CS7542 network engine Fil Dunsky via B4 Relay
2026-12-01 23:36 ` [PATCH net-next v6 2/3] net: cortina: Add CS7542 CPU network datapath Fil Dunsky via B4 Relay
2026-12-02 2:08 ` Andrew Lunn [this message]
2026-12-01 23:36 ` [PATCH net-next v6 3/3] MAINTAINERS: Add CS7542 network engine support Fil Dunsky via B4 Relay
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=8fc46e0b-0b85-4bad-9c78-58cb5f2dd2d3@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=filipp.dunsky@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=ulli.kroll@googlemail.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