mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

This is [1/3] part of hinic3 Ethernet driver initial submission. With this patch hinic3 is a valid kernel module but non-functional driver. The driver parts contained in this patch: Module initialization. PCI driver registration but with empty id_table. Auxiliary driver registration. Net device_ops registration but open/stop are empty stubs. tx/rx logic. All major data structures of the driver are fully introduced with the code that uses them but without their initialization code that requires management interface with the hw. Co-developed-by: Xin Guo <guoxin09@huawei.com> Signed-off-by: Xin Guo <guoxin09@huawei.com> Signed-off-by: Fan Gong <gongfan1@huawei.com> Co-developed-by: Gur Stavi <gur.stavi@huawei.com> Signed-off-by: Gur Stavi <gur.stavi@huawei.com> Link: https://patch.msgid.link/76a137ffdfe115c737c2c224f0c93b60ba53cc16.1747736586.git.gur.stavi@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
62 lines
1.7 KiB
C
62 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include "hinic3_hw_comm.h"
|
|
#include "hinic3_hwdev.h"
|
|
#include "hinic3_hwif.h"
|
|
#include "hinic3_nic_dev.h"
|
|
#include "hinic3_rx.h"
|
|
#include "hinic3_tx.h"
|
|
|
|
static int hinic3_poll(struct napi_struct *napi, int budget)
|
|
{
|
|
struct hinic3_irq_cfg *irq_cfg =
|
|
container_of(napi, struct hinic3_irq_cfg, napi);
|
|
struct hinic3_nic_dev *nic_dev;
|
|
bool busy = false;
|
|
int work_done;
|
|
|
|
nic_dev = netdev_priv(irq_cfg->netdev);
|
|
|
|
busy |= hinic3_tx_poll(irq_cfg->txq, budget);
|
|
|
|
if (unlikely(!budget))
|
|
return 0;
|
|
|
|
work_done = hinic3_rx_poll(irq_cfg->rxq, budget);
|
|
busy |= work_done >= budget;
|
|
|
|
if (busy)
|
|
return budget;
|
|
|
|
if (likely(napi_complete_done(napi, work_done)))
|
|
hinic3_set_msix_state(nic_dev->hwdev, irq_cfg->msix_entry_idx,
|
|
HINIC3_MSIX_ENABLE);
|
|
|
|
return work_done;
|
|
}
|
|
|
|
void qp_add_napi(struct hinic3_irq_cfg *irq_cfg)
|
|
{
|
|
struct hinic3_nic_dev *nic_dev = netdev_priv(irq_cfg->netdev);
|
|
|
|
netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
|
|
NETDEV_QUEUE_TYPE_RX, &irq_cfg->napi);
|
|
netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
|
|
NETDEV_QUEUE_TYPE_TX, &irq_cfg->napi);
|
|
netif_napi_add(nic_dev->netdev, &irq_cfg->napi, hinic3_poll);
|
|
napi_enable(&irq_cfg->napi);
|
|
}
|
|
|
|
void qp_del_napi(struct hinic3_irq_cfg *irq_cfg)
|
|
{
|
|
napi_disable(&irq_cfg->napi);
|
|
netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
|
|
NETDEV_QUEUE_TYPE_RX, NULL);
|
|
netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
|
|
NETDEV_QUEUE_TYPE_TX, NULL);
|
|
netif_stop_subqueue(irq_cfg->netdev, irq_cfg->irq_id);
|
|
netif_napi_del(&irq_cfg->napi);
|
|
}
|