mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: Paolo Abeni <pabeni@redhat.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>
Cc: <shaojijie@huawei.com>, <shenjian15@huawei.com>,
	<wangpeiyang1@huawei.com>, <liuyonglong@huawei.com>,
	<chenhao418@huawei.com>, <sudongming1@huawei.com>,
	<xujunsheng@huawei.com>, <shiyongbang@huawei.com>,
	<libaihan@huawei.com>, <andrew@lunn.ch>, <jdamato@fastly.com>,
	<horms@kernel.org>, <jonathan.cameron@huawei.com>,
	<shameerali.kolothum.thodi@huawei.com>, <salil.mehta@huawei.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V6 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function
Date: Tue, 3 Sep 2024 22:41:57 +0800	[thread overview]
Message-ID: <55fbd21f-ac81-465f-b164-7e5b6c0ca7d9@huawei.com> (raw)
In-Reply-To: <2bc090db-7bc1-4810-80c7-61218fb49acf@redhat.com>


on 2024/9/3 21:31, Paolo Abeni wrote:
> On 8/30/24 14:15, Jijie Shao wrote:
>> +netdev_tx_t hbg_net_start_xmit(struct sk_buff *skb, struct 
>> net_device *net_dev)
>> +{
>> +    struct hbg_ring *ring = netdev_get_tx_ring(net_dev);
>> +    struct hbg_priv *priv = netdev_priv(net_dev);
>> +    /* This smp_load_acquire() pairs with smp_store_release() in
>> +     * hbg_tx_buffer_recycle() called in tx interrupt handle process.
>> +     */
>> +    u32 ntc = smp_load_acquire(&ring->ntc);
>> +    struct hbg_buffer *buffer;
>> +    struct hbg_tx_desc tx_desc;
>> +    u32 ntu = ring->ntu;
>> +
>> +    if (unlikely(!hbg_nic_is_open(priv))) {
>> +        dev_kfree_skb_any(skb);
>> +        return NETDEV_TX_OK;
>> +    }
>> +
>> +    if (unlikely(!skb->len ||
>> +             skb->len > hbg_spec_max_frame_len(priv, HBG_DIR_TX))) {
>> +        dev_kfree_skb_any(skb);
>> +        net_dev->stats.tx_errors++;
>> +        return NETDEV_TX_OK;
>> +    }
>> +
>> +    if (unlikely(hbg_queue_is_full(ntc, ntu, ring) ||
>> +             hbg_fifo_is_full(ring->priv, ring->dir))) {
>> +        netif_stop_queue(net_dev);
>> +        return NETDEV_TX_BUSY;
>> +    }
>> +
>> +    buffer = &ring->queue[ntu];
>> +    buffer->skb = skb;
>> +    buffer->skb_len = skb->len;
>> +    if (unlikely(hbg_dma_map(buffer))) {
>> +        dev_kfree_skb_any(skb);
>> +        return NETDEV_TX_OK;
>> +    }
>> +
>> +    buffer->state = HBG_TX_STATE_START;
>> +    hbg_init_tx_desc(buffer, &tx_desc);
>> +    hbg_hw_set_tx_desc(priv, &tx_desc);
>> +
>> +    /* This smp_store_release() pairs with smp_load_acquire() in
>> +     * hbg_tx_buffer_recycle() called in tx interrupt handle process.
>> +     */
>> +    smp_store_release(&ring->ntu, hbg_queue_next_prt(ntu, ring));
>
> Here you should probably check for netif_txq_maybe_stop()
>
>> +    net_dev->stats.tx_bytes += skb->len;
>> +    net_dev->stats.tx_packets++;
>
> Try to avoid 'dev->stats' usage. Instead you could use per napi stats 
> accounting (no contention).

use dev_sw_netstats_tx_add() or dev_sw_netstats_rx_add() ?

>
> Side note: 'net_dev' is quite an unusual variable name for a network 
> device.

sure, 'dev' is ok.
	
	Thanks,
	Jijie Shao


  reply	other threads:[~2024-09-03 14:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 12:15 [PATCH V6 net-next 00/11] Add support of HIBMCGE Ethernet Driver Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 01/11] net: hibmcge: Add pci table supported in this module Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 02/11] net: hibmcge: Add read/write registers supported through the bar space Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module Jijie Shao
2024-09-03 11:59   ` Paolo Abeni
2024-09-03 12:13     ` Jijie Shao
2024-09-03 13:15       ` Andrew Lunn
2024-09-03 14:42         ` Jijie Shao
2024-09-03 17:44       ` Jakub Kicinski
2024-09-04  1:34         ` Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 04/11] net: hibmcge: Add interrupt " Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 05/11] net: hibmcge: Implement some .ndo functions Jijie Shao
2024-08-30 12:15 ` [PATCH V6 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function Jijie Shao
2024-09-03 13:31   ` Paolo Abeni
2024-09-03 14:41     ` Jijie Shao [this message]
2024-08-30 12:16 ` [PATCH V6 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets Jijie Shao
2024-09-03 12:08   ` Paolo Abeni
2024-09-03 12:57     ` Jijie Shao
2024-08-30 12:16 ` [PATCH V6 net-next 08/11] net: hibmcge: Implement some ethtool_ops functions Jijie Shao
2024-08-30 12:16 ` [PATCH V6 net-next 09/11] net: hibmcge: Add a Makefile and update Kconfig for hibmcge Jijie Shao
2024-08-30 12:16 ` [PATCH V6 net-next 10/11] net: hibmcge: Add maintainer " Jijie Shao
2024-08-30 12:16 ` [PATCH V6 net-next 11/11] net: add ndo_validate_addr check in dev_set_mac_address Jijie Shao

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=55fbd21f-ac81-465f-b164-7e5b6c0ca7d9@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kuba@kernel.org \
    --cc=libaihan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=salil.mehta@huawei.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=shiyongbang@huawei.com \
    --cc=sudongming1@huawei.com \
    --cc=wangpeiyang1@huawei.com \
    --cc=xujunsheng@huawei.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®