From: Justin Lai <justinlai0215@realtek.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "kuba@kernel.org" <kuba@kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH net-next v7 01/13] net:ethernet:realtek:rtase: Add pci table supported in this module
Date: Thu, 14 Sep 2023 14:42:23 +0000 [thread overview]
Message-ID: <edbc001d331944f69017af67f71990ef@realtek.com> (raw)
In-Reply-To: <b655f427-0c45-4df6-be7f-6adf743ea0d4@lunn.ch>
> > +/* the table of time unit
> > + * 4b'0000: 1.024us, 4b'0001: 2.048us, 4b'0010: 4.096us,
> > + * 4b'0011: 8.192us, 4b'0100: 16.384us, 4b'0101: 32.768us,
> > + * 4b'0110: 65.536us, 4b'0111: 131.072us, 4b'1000: 252.144us,
> > + * 4b'1001: 524.288us, 4b'1010: 1048.576us, 4b'1011: 2097.152us,
> > + * 4b'1100: 4194.304us, 4b'1101: 8388.608us, 4b'1110: 16777.216us,
> > + * 4b'1111: 33554.432us
>
> This seems to be all comment. Where is the table?
>
> > + *
> > + * the table of packet number unit
> > + * 2b'00: 1,
> > + * 2b'01: 2,
> > + * 2b'10: 4,
> > + * 2b'11: 16
>
> Again, what use is this?
>
> > + *
> > + * interrupt mitigation = count * unit
> > + * example: If want to set packet number mitigation be 64
> > + * the number unit is set 3,
> > + * and the number count is set 4
> > + * If want to set time be 131.072us
> > + * the time unit is set 4,
> > + * and the time count is set 8
> > + */
>
> Rather than a comment, how about a little function which does the calculation.
> Code can be just as good at explaining something as English text.
Hi, Andrew
This calculation is a bit complicated. We will rewrite this part as a fixed-unit calculation mitigation function in the next version. The time unit will be set to 16u, and the packet number unit will be set to 16.
>
> > + if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)))
> > + dev->features |= NETIF_F_HIGHDMA;
> > + else if (dma_set_mask_and_coherent(&pdev->dev,
> DMA_BIT_MASK(32)))
> > + goto err_out_free_res;
> > + else
> > + pr_info("DMA_BIT_MASK: 32\n");
>
> dev_info(). Don't use pr_ functions if you have a struct device.
>
> > +static int rtase_init_one(struct pci_dev *pdev,
> > + const struct pci_device_id *ent) {
> > + struct net_device *dev = NULL;
> > + void __iomem *ioaddr = NULL;
> > + struct rtase_private *tp;
> > + int ret;
> > +
> > + if (!pdev->is_physfn && pdev->is_virtfn) {
> > + pr_info("This module does not support a virtual function.");
> > + return -EINVAL;
> > + }
> > +
> > + pr_info("Automotive Switch Ethernet driver loaded\n");
>
> dev_dbg(), or nothing at all.
>
> > +
> > + ret = rtase_init_board(pdev, &dev, &ioaddr);
> > + if (ret != 0)
> > + return ret;
> > +
> > + tp = netdev_priv(dev);
> > + tp->mmio_addr = ioaddr;
> > + tp->dev = dev;
> > + tp->pdev = pdev;
> > +
> > + /* identify chip attached to board */
> > + if (!rtase_check_mac_version_valid(tp)) {
> > + return dev_err_probe(&pdev->dev, -ENODEV,
> > + "unknown chip version, contact
> rtase maintainers (see MAINTAINERS file)\n");
> > + }
> > +
> > + dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
> > + if (!dev->tstats)
> > + goto err_out_1;
> > +
> > + rtase_init_software_variable(tp);
> > + rtase_init_hardware(tp);
> > +
> > + ret = rtase_alloc_interrupt(pdev, tp);
> > + if (ret < 0) {
> > + pr_err("unable to alloc MSIX/MSI\n");
> > + goto err_out_1;
> > + }
> > +
> > + rtase_init_netdev_ops(dev);
> > +
> > + dev->features |= NETIF_F_HW_VLAN_CTAG_TX |
> > + NETIF_F_HW_VLAN_CTAG_RX;
> > +
> > + dev->features |= NETIF_F_IP_CSUM;
> > + dev->features |= NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
> > + dev->features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
> > + dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO
> |
> > + NETIF_F_RXCSUM |
> NETIF_F_HW_VLAN_CTAG_TX |
> > + NETIF_F_HW_VLAN_CTAG_RX;
> > + dev->hw_features |= NETIF_F_RXALL;
> > + dev->hw_features |= NETIF_F_RXFCS;
> > + dev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
> > + dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO
> |
> > + NETIF_F_HIGHDMA;
> > + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
> > + netif_set_tso_max_size(dev, LSO_64K);
> > + netif_set_tso_max_segs(dev, NIC_MAX_PHYS_BUF_COUNT_LSO2);
> > +
> > + rtase_get_mac_address(dev);
> > +
> > + tp->tally_vaddr = dma_alloc_coherent(&pdev->dev,
> > +
> sizeof(*tp->tally_vaddr),
> > + &tp->tally_paddr,
> > + GFP_KERNEL);
> > + if (!tp->tally_vaddr) {
> > + ret = -ENOMEM;
> > + goto err_out;
> > + }
> > +
> > + rtase_tally_counter_clear(tp);
> > +
> > + pci_set_drvdata(pdev, dev);
> > +
> > + ret = register_netdev(dev);
> > + if (ret != 0)
> > + goto err_out;
> > +
> > + netdev_info(dev, "%pM, IRQ %d\n", dev->dev_addr, dev->irq);
>
> netdev_dbg(), or nothing at all.
>
> Andrew
Thank you for your suggestion, I will correct it.
next prev parent reply other threads:[~2023-09-14 14:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 9:18 [PATCH net-next v7 00/13] Add Realtek automotive PCIe driver Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 01/13] net:ethernet:realtek:rtase: Add pci table supported in this module Justin Lai
2023-09-13 21:32 ` Andrew Lunn
2023-09-14 14:42 ` Justin Lai [this message]
2023-09-12 9:18 ` [PATCH net-next v7 02/13] net:ethernet:realtek:rtase: Implement the .ndo_open function Justin Lai
2023-09-13 21:37 ` Andrew Lunn
2023-09-14 12:21 ` Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 03/13] net:ethernet:realtek:rtase: Implement the rtase_down function Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 04/13] net:ethernet:realtek:rtase: Implement the interrupt routine and rtase_poll Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 05/13] net:ethernet:realtek:rtase: Implement hardware configuration function Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 06/13] net:ethernet:realtek:rtase: Implement .ndo_start_xmit function Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 07/13] net:ethernet:realtek:rtase: Implement a function to receive packets Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 08/13] net:ethernet:realtek:rtase: Implement net_device_ops Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 09/13] net:ethernet:realtek:rtase: Implement pci_driver suspend and resume function Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 10/13] net:ethernet:realtek:rtase: Implement ethtool function Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 11/13] net:ethernet:realtek:rtase: Add a Makefile in the rtase folder Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 12/13] net:ethernet:realtek: Update the Makefile and Kconfig in the realtek folder Justin Lai
2023-09-12 9:18 ` [PATCH net-next v7 13/13] MAINTAINERS: Add the rtase ethernet driver entry Justin Lai
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=edbc001d331944f69017af67f71990ef@realtek.com \
--to=justinlai0215@realtek.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).