From: Andrew Lunn <andrew@lunn.ch>
To: Wei Fang <wei.fang@nxp.com>
Cc: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, christophe.leroy@csgroup.eu,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev
Subject: Re: [PATCH net-next 01/13] net: enetc: add initial netc-lib driver to support NTMP
Date: Fri, 3 Jan 2025 17:20:35 +0100 [thread overview]
Message-ID: <829ccd93-8b4e-4dd9-bd15-58d345797aca@lunn.ch> (raw)
In-Reply-To: <20250103060610.2233908-2-wei.fang@nxp.com>
> +#define NTMP_FILL_CRD(crd, tblv, qa, ua) \
> +({ \
> + typeof(crd) _crd = (crd); \
> + (_crd)->update_act = cpu_to_le16(ua); \
> + (_crd)->tblv_qact = NTMP_TBLV_QACT(tblv, qa); \
> +})
> +
> +#define NTMP_FILL_CRD_EID(req, tblv, qa, ua, eid) \
> +({ \
> + typeof(req) _req = (req); \
> + NTMP_FILL_CRD(&(_req)->crd, tblv, qa, ua); \
> + (_req)->entry_id = cpu_to_le32(eid); \
> +})
These are pretty complex for #defines. Can they be made into
functions? That will get you type checking, finding bugs where
parameters are swapped.
> +int netc_setup_cbdr(struct device *dev, int cbd_num,
> + struct netc_cbdr_regs *regs,
> + struct netc_cbdr *cbdr)
> +{
> + int size;
> +
> + size = cbd_num * sizeof(union netc_cbd) + NTMP_BASE_ADDR_ALIGN;
> +
> + cbdr->addr_base = dma_alloc_coherent(dev, size, &cbdr->dma_base,
> + GFP_KERNEL);
> + if (!cbdr->addr_base)
> + return -ENOMEM;
> +
> + cbdr->dma_size = size;
> + cbdr->bd_num = cbd_num;
> + cbdr->regs = *regs;
> +
> + /* The base address of the Control BD Ring must be 128 bytes aligned */
> + cbdr->dma_base_align = ALIGN(cbdr->dma_base, NTMP_BASE_ADDR_ALIGN);
> + cbdr->addr_base_align = PTR_ALIGN(cbdr->addr_base,
> + NTMP_BASE_ADDR_ALIGN);
> +
> + cbdr->next_to_clean = 0;
> + cbdr->next_to_use = 0;
> + spin_lock_init(&cbdr->ring_lock);
> +
> + /* Step 1: Configure the base address of the Control BD Ring */
> + netc_write(cbdr->regs.bar0, lower_32_bits(cbdr->dma_base_align));
> + netc_write(cbdr->regs.bar1, upper_32_bits(cbdr->dma_base_align));
> +
> + /* Step 2: Configure the producer index register */
> + netc_write(cbdr->regs.pir, cbdr->next_to_clean);
> +
> + /* Step 3: Configure the consumer index register */
> + netc_write(cbdr->regs.cir, cbdr->next_to_use);
> +
> + /* Step4: Configure the number of BDs of the Control BD Ring */
> + netc_write(cbdr->regs.lenr, cbdr->bd_num);
> +
> + /* Step 5: Enable the Control BD Ring */
> + netc_write(cbdr->regs.mr, NETC_CBDR_MR_EN);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(netc_setup_cbdr);
I assume there is a version 3 in development, which will need a
different library, or at least different symbols. Maybe you should
think about the naming issues now?
> diff --git a/include/linux/fsl/ntmp.h b/include/linux/fsl/ntmp.h
> new file mode 100644
> index 000000000000..7cf322a1c8e3
> --- /dev/null
> +++ b/include/linux/fsl/ntmp.h
> @@ -0,0 +1,178 @@
> +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
> +/* Copyright 2025 NXP */
> +#ifndef __NETC_NTMP_H
> +#define __NETC_NTMP_H
Does this header need to be global? What else will use it outside of
drivers/net/ethernet/freescale/enetc?
Andrew
next prev parent reply other threads:[~2025-01-03 16:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 6:05 [PATCH net-next 00/13] Add more feautues for ENETC v4 - round 2 Wei Fang
2025-01-03 6:05 ` [PATCH net-next 01/13] net: enetc: add initial netc-lib driver to support NTMP Wei Fang
2025-01-03 16:20 ` Andrew Lunn [this message]
2025-01-06 2:45 ` Wei Fang
2025-01-03 6:05 ` [PATCH net-next 02/13] net: enetc: add command BD ring support for i.MX95 ENETC Wei Fang
2025-01-03 6:05 ` [PATCH net-next 03/13] net: enetc: move generic MAC filterng interfaces to enetc-core Wei Fang
2025-01-03 6:06 ` [PATCH net-next 04/13] net: enetc: add MAC filter for i.MX95 ENETC PF Wei Fang
2025-01-05 1:45 ` Jakub Kicinski
2025-01-03 6:06 ` [PATCH net-next 05/13] net: enetc: add debugfs interface to dump MAC filter Wei Fang
2025-01-03 16:25 ` Andrew Lunn
2025-01-06 2:19 ` Wei Fang
2025-01-03 6:06 ` [PATCH net-next 06/13] net: enetc: make enetc_set_rxfh() and enetc_get_rxfh() reusable Wei Fang
2025-01-03 6:06 ` [PATCH net-next 07/13] net: enetc: add RSS support for i.MX95 ENETC PF Wei Fang
2025-01-03 6:06 ` [PATCH net-next 08/13] net: enetc: enable RSS feature by default Wei Fang
2025-01-03 6:06 ` [PATCH net-next 09/13] net: enetc: move generic VLAN filter interfaces to enetc-core Wei Fang
2025-01-03 6:06 ` [PATCH net-next 10/13] net: enetc: move generic VLAN hash filter functions to enetc_pf_common.c Wei Fang
2025-01-03 6:06 ` [PATCH net-next 11/13] net: enetc: add VLAN filtering support for i.MX95 ENETC PF Wei Fang
2025-01-03 6:06 ` [PATCH net-next 12/13] net: enetc: add loopback " Wei Fang
2025-01-03 6:06 ` [PATCH net-next 13/13] MAINTAINERS: add new file ntmp.h to ENETC driver Wei Fang
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=829ccd93-8b4e-4dd9-bd15-58d345797aca@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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®