From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C5B2817 for ; Tue, 3 Sep 2024 13:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725370300; cv=none; b=EA2bYpQfgmencx4y2ml6SCa4VLmw+nLe8MNjxxWCcSoSaqmPw1uo1JrzHqjEKhPQR+d7r09U3GpUgqCX6NfmE1V7h36NI6tGMsIifVBOe4TYypQX04LdKrqoEAY0XO+N7Ri1z6ALinvpeQq9ATKxl7voFZtGLsCdHy/1h9VYHMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725370300; c=relaxed/simple; bh=T4fDoJoecViVmQNPo2yZrHSz6QgMk+lBYHN95sXQCDI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=svCiQHmPNBLTjlwyrxS/2zTTCGCsJOUhvI+zvqctIRD1St40yu/vUFMzgnO9NO4wTjkNYDvpzrxHEaOAYg5mdvtphE9ZRuR1pSN8jgtVqVYVuWrhicpw8jSJNjFmGUZLOnxbjS7XNcMf4pCbHYgfVA/sCCq7x15baoV7kZ8ziB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=V2GVUHuC; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V2GVUHuC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725370298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TT0mRqhaXKCd2CqytOnVTAv17c3Kp2T7BKqKGi1Nz7Q=; b=V2GVUHuCWv+ptEVuB8HsKgnVnowIwE0F7sVrfuiPfWymKaVfKqtpQhztvBGIgP833cZ9xK agFlT8biZzMJQvtx160t8J3ZnHindVcefK9Cw5eZsU9Aa062Qt+Uo9GTtWGHFmDINHTIjZ pd5tAEmOZDm3Pfuy1NyIIvR4kj/T9qw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-94iz-17oPgC7mW3iFpfPQQ-1; Tue, 03 Sep 2024 09:31:37 -0400 X-MC-Unique: 94iz-17oPgC7mW3iFpfPQQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-374c90d24e3so2029267f8f.0 for ; Tue, 03 Sep 2024 06:31:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725370296; x=1725975096; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TT0mRqhaXKCd2CqytOnVTAv17c3Kp2T7BKqKGi1Nz7Q=; b=sFXa0AaJjZ7ueAJPiZFsm8dmIJ2nfYhyRxv+zoyMUeRmqa/YntwtXM5PvffmxeJdLk dCJhcrQCMJ0Ve+NAS4XbhNSEw1GFRjWnSp13pyRNfs6uTQMucQSgPWqII0zoOwsr9z1T swK40FD9w24FtfUzSCME/rIpqFOXJ9RLRfQrV1DTBFDVJP/b9UKBNUFNZ89puUQLwG1X D3osoy7bzwl0L6ID83NHbu5Kxl105zXIJOEm7tLZsHsvWECN+KyasRcm74Ea2LJX/QWp OAXWxRhbp9hBzNA+LXDv2w4jIaeqad658UBbFRqDqlNgCB535bt8mouwopphCEpERC2q 9KZw== X-Forwarded-Encrypted: i=1; AJvYcCUnDcpfX8G8Bw5BTL581dQ8plfUc0fENphhPkmI8O8WRosLLVmYGXinKwApz2xtz5CckUAylzvuwhfifwY=@vger.kernel.org X-Gm-Message-State: AOJu0YzQa9295o+AAM3N0dYpVcbekujkoBWpt6boyurzE2or+tPuJAO5 n3aFeAC7rznU8bIr4U8jhTStCKGgMDntmNvrSr0/JRvVHiOiisqnu9rVBIECpNXfH9nHpU/XddC JFRVbpYbRYIqp8xXAEbAEGEXCqadHr3tWKCwHkwj/FZo7mLhLkcROx+MsLYICsw== X-Received: by 2002:a05:6000:1543:b0:374:d29e:6db8 with SMTP id ffacd0b85a97d-374d29e6e46mr3758620f8f.16.1725370295661; Tue, 03 Sep 2024 06:31:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqsEsAzk28PCAKiuT1J68bc+3njl09O+FreZRAVr0nLTh3+4A6lAl/kcqqbuaWg6B53QFsug== X-Received: by 2002:a05:6000:1543:b0:374:d29e:6db8 with SMTP id ffacd0b85a97d-374d29e6e46mr3758540f8f.16.1725370294504; Tue, 03 Sep 2024 06:31:34 -0700 (PDT) Received: from [192.168.88.27] (146-241-55-250.dyn.eolo.it. [146.241.55.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6e33b41sm171403835e9.40.2024.09.03.06.31.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Sep 2024 06:31:34 -0700 (PDT) Message-ID: <2bc090db-7bc1-4810-80c7-61218fb49acf@redhat.com> Date: Tue, 3 Sep 2024 15:31:32 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V6 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function To: Jijie Shao , davem@davemloft.net, edumazet@google.com, kuba@kernel.org Cc: 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 References: <20240830121604.2250904-1-shaojijie@huawei.com> <20240830121604.2250904-7-shaojijie@huawei.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20240830121604.2250904-7-shaojijie@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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). Side note: 'net_dev' is quite an unusual variable name for a network device. Cheers, Paolo