net: hinic3: Add a driver for Huawei 3rd gen NIC
Subsystems (4)
v4 cover net: hinic3: Add a driver for Huawei 3rd gen NIC
This is the 1/3 patch of the patch-set described below.
The patch-set contains driver for Huawei's 3rd generation HiNIC Ethernet device that will be available in the future.
This is an SRIOV device, designed for data centers. Initially, the driver only supports VFs.
Following the discussion over RFC01, the code will be submitted in separate smaller patches where until the last patch the driver is non-functional. The RFC02 submission contains overall view of the entire driver but every patch will be posted as a standalone submission.
Changes:
RFC V01: https://lore.kernel.org/netdev/[email protected]
RFC V02: https://lore.kernel.org/netdev/[email protected]
* Reduce overall line of code by removing optional functionality.
* Break down into smaller patches.
PATCH 01 V01: https://lore.kernel.org/netdev/[email protected]
* Documentation style and consistency fixes (from Bjorn Helgaas)
* Use ipoll instead of custom code (from Andrew Lunn)
* Move dev_set_drvdata up in initialization order (from Andrew Lunn)
* Use netdev's max_mtu, min_mtu (from Andrew Lunn)
* Fix variable 'xxx' set but not used warnings (from Linux patchwork)
PATCH 01 V02: https://lore.kernel.org/netdev/[email protected]
* Add comment regarding usage of random MAC. (Andrew Lunn)
* Add COMPILE_TEST to Kconfig (Jakub Kicinski)
PATCH 01 V03: https://lore.kernel.org/netdev/[email protected]
* Rephrase Kconfig comment (Jakub Kicinski)
* Kconfig: add 'select AUXILIARY_BUS' (Kernel test robot)
* ARCH=um: missing include 'net/ip6_checksum.h' (Kernel test robot)
PATCH 01 V04:
* Improve naming consistency, missing hinic3 prefixes (Suman Ghosh)
* Change hinic3_remove_func to void (Suman Ghosh)
* Add adev_event_unregister (Suman Ghosh)
* Add comment for service types enum (Suman Ghosh)
gongfan (1):
hinic3: module initialization and tx/rx logic
.../device_drivers/ethernet/huawei/hinic3.rst | 137 ++++ MAINTAINERS | 7 + drivers/net/ethernet/huawei/Kconfig | 1 + drivers/net/ethernet/huawei/Makefile | 1 + drivers/net/ethernet/huawei/hinic3/Kconfig | 18 + drivers/net/ethernet/huawei/hinic3/Makefile | 21 + .../ethernet/huawei/hinic3/hinic3_common.c | 53 ++ .../ethernet/huawei/hinic3/hinic3_common.h | 27 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 30 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 58 ++ .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 37 + .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 13 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 88 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_hwdev.h | 82 +++ .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 15 + .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 50 ++ .../net/ethernet/huawei/hinic3/hinic3_lld.c | 416 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_lld.h | 21 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 418 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 17 + .../net/ethernet/huawei/hinic3/hinic3_mbox.h | 16 + .../net/ethernet/huawei/hinic3/hinic3_mgmt.h | 13 + .../huawei/hinic3/hinic3_mgmt_interface.h | 111 +++ .../huawei/hinic3/hinic3_netdev_ops.c | 77 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 254 +++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 45 ++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 100 +++ .../ethernet/huawei/hinic3/hinic3_nic_io.c | 21 + .../ethernet/huawei/hinic3/hinic3_nic_io.h | 117 +++ .../huawei/hinic3/hinic3_queue_common.c | 65 ++ .../huawei/hinic3/hinic3_queue_common.h | 51 ++ .../net/ethernet/huawei/hinic3/hinic3_rss.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_rss.h | 12 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 401 ++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rx.h | 91 +++ .../net/ethernet/huawei/hinic3/hinic3_tx.c | 692 ++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_tx.h | 129 ++++ .../net/ethernet/huawei/hinic3/hinic3_wq.c | 29 + .../net/ethernet/huawei/hinic3/hinic3_wq.h | 75 ++ 40 files changed, 3857 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst create mode 100644 drivers/net/ethernet/huawei/hinic3/Kconfig create mode 100644 drivers/net/ethernet/huawei/hinic3/Makefile create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_common.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_common.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_hwif.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_lld.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_lld.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_main.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rss.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rss.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rx.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rx.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_tx.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_tx.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_wq.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_wq.h
base-commit: 7a1723d3b230765dc025401db8308937e4c4fb13
Signature · 1 line
2.45.2
PATCH v4 1/1 hinic3: module initialization and tx/rx logic
From: gongfan <[email protected]>
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.
--- .../device_drivers/ethernet/huawei/hinic3.rst | 137 ++++ MAINTAINERS | 7 + drivers/net/ethernet/huawei/Kconfig | 1 + drivers/net/ethernet/huawei/Makefile | 1 + drivers/net/ethernet/huawei/hinic3/Kconfig | 18 + drivers/net/ethernet/huawei/hinic3/Makefile | 21 + .../ethernet/huawei/hinic3/hinic3_common.c | 53 ++ .../ethernet/huawei/hinic3/hinic3_common.h | 27 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 30 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 58 ++ .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 37 + .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 13 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 88 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_hwdev.h | 82 +++ .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 15 + .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 50 ++ .../net/ethernet/huawei/hinic3/hinic3_lld.c | 416 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_lld.h | 21 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 418 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 17 + .../net/ethernet/huawei/hinic3/hinic3_mbox.h | 16 + .../net/ethernet/huawei/hinic3/hinic3_mgmt.h | 13 + .../huawei/hinic3/hinic3_mgmt_interface.h | 111 +++ .../huawei/hinic3/hinic3_netdev_ops.c | 77 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 254 +++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 45 ++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 100 +++ .../ethernet/huawei/hinic3/hinic3_nic_io.c | 21 + .../ethernet/huawei/hinic3/hinic3_nic_io.h | 117 +++ .../huawei/hinic3/hinic3_queue_common.c | 65 ++ .../huawei/hinic3/hinic3_queue_common.h | 51 ++ .../net/ethernet/huawei/hinic3/hinic3_rss.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_rss.h | 12 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 401 ++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rx.h | 91 +++ .../net/ethernet/huawei/hinic3/hinic3_tx.c | 692 ++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_tx.h | 129 ++++ .../net/ethernet/huawei/hinic3/hinic3_wq.c | 29 + .../net/ethernet/huawei/hinic3/hinic3_wq.h | 75 ++ 40 files changed, 3857 insertions(+)
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +137 -0
@@ -0,0 +1,137 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================================================================== +Linux kernel driver for Huawei Ethernet Device Driver (hinic3) family +===================================================================== + +Overview +======== + +The hinic3 is a network interface card (NIC) for Data Center. It supports +a range of link-speed devices (10GE, 25GE, 100GE, etc.). The hinic3 +devices can have multiple physical forms (LOM NIC, PCIe standard NIC, +OCP NIC etc.). + +The hinic3 driver supports the following features: +- IPv4/IPv6 TCP/UDP checksum offload +- TSO (TCP Segmentation Offload), LRO (Large Receive Offload) +- RSS (Receive Side Scaling) +- MSI-X interrupt aggregation configuration and interrupt adaptation. +- SR-IOV (Single Root I/O Virtualization). + +Content +======= + +- Supported PCI vendor ID/device IDs +- Source Code Structure of Hinic3 Driver +- Management Interface + +Supported PCI vendor ID/device IDs +================================== + +19e5:0222 - hinic3 PF/PPF +19e5:375F - hinic3 VF + +Prime Physical Function (PPF) is responsible for the management of the +whole NIC card. For example, clock synchronization between the NIC and +the host. Any PF may serve as a PPF. The PPF is selected dynamically. + +Source Code Structure of Hinic3 Driver +====================================== + +======================== ================================================ +hinic3_pci_id_tbl.h Supported device IDs +hinic3_hw_intf.h Interface between HW and driver +hinic3_queue_common.[ch] Common structures and methods for NIC queues +hinic3_common.[ch] Encapsulation of memory operations in Linux +hinic3_csr.h Register definitions in the BAR +hinic3_hwif.[ch] Interface for BAR +hinic3_eqs.[ch] Interface for AEQs and CEQs +hinic3_mbox.[ch] Interface for mailbox +hinic3_mgmt.[ch] Management interface based on mailbox and AEQ +hinic3_wq.[ch] Work queue data structures and interface +hinic3_cmdq.[ch] Command queue is used to post command to HW +hinic3_hwdev.[ch] HW structures and methods abstractions +hinic3_lld.[ch] Auxiliary driver adaptation layer +hinic3_hw_comm.[ch] Interface for common HW operations +hinic3_mgmt_interface.h Interface between firmware and driver +hinic3_hw_cfg.[ch] Interface for HW configuration +hinic3_irq.c Interrupt request +hinic3_netdev_ops.c Operations registered to Linux kernel stack +hinic3_nic_dev.h NIC structures and methods abstractions +hinic3_main.c Main Linux kernel driver +hinic3_nic_cfg.[ch] NIC service configuration +hinic3_nic_io.[ch] Management plane interface for TX and RX +hinic3_rss.[ch] Interface for Receive Side Scaling (RSS) +hinic3_rx.[ch] Interface for transmit +hinic3_tx.[ch] Interface for receive +hinic3_ethtool.c Interface for ethtool operations (ops) +hinic3_filter.c Interface for MAC address +======================== ================================================ + +Management Interface +==================== + +Asynchronous Event Queue (AEQ) +------------------------------ + +AEQ receives high priority events from the HW over a descriptor queue. +Every descriptor is a fixed size of 64 bytes. AEQ can receive solicited or +unsolicited events. Every device, VF or PF, can have up to 4 AEQs. +Every AEQ is associated to a dedicated IRQ. AEQ can receive multiple types +of events, but in practice the hinic3 driver ignores all events except for +2 mailbox related events. + +Mailbox +------- + +Mailbox is a communication mechanism between the hinic3 driver and the HW. +Each device has an independent mailbox. Driver can use the mailbox to send +requests to management. Driver receives mailbox messages, such as responses +to requests, over the AEQ (using event HINIC3_AEQ_FOR_MBOX). Due to the +limited size of mailbox data register, mailbox messages are sent +segment-by-segment. + +Every device can use its mailbox to post request to firmware. The mailbox +can also be used to post requests and responses between the PF and its VFs. + +Completion Event Queue (CEQ) +-------------------------- + +The implementation of CEQ is the same as AEQ. It receives completion events +from HW over a fixed size descriptor of 32 bits. Every device can have up +to 32 CEQs. Every CEQ has a dedicated IRQ. CEQ only receives solicited +events that are responses to requests from the driver. CEQ can receive +multiple types of events, but in practice the hinic3 driver ignores all +events except for HINIC3_CMDQ that represents completion of previously +posted commands on a cmdq. + +Command Queue (cmdq) +-------------------- + +Every cmdq has a dedicated work queue on which commands are posted. +Commands on the work queue are fixed size descriptor of size 64 bytes. +Completion of a command will be indicated using ctrl bits in the +descriptor that carried the command. Notification of command completions +will also be provided via event on CEQ. Every device has 4 command queues +that are initialized as a set (called cmdqs), each with its own type. +Hinic3 driver only uses type HINIC3_CMDQ_SYNC. + +Work Queues(WQ) +--------------- + +Work queues are logical arrays of fixed size WQEs. The array may be spread +over multiple non-contiguous pages using indirection table. Work queues are +used by I/O queues and command queues. + +Global function ID +------------------ + +Every function, PF or VF, has a unique ordinal identification within the device. +Many commands to management (mbox or cmdq) contain this ID so HW can apply the +command effect to the right function. + +PF is allowed to post management commands to a subordinate VF by specifying the +VFs ID. A VF must provide its own ID. Anti-spoofing in the HW will cause +command from a VF to fail if it contains the wrong ID. +
MAINTAINERS +7 -0
@@ -10600,6 +10600,13 @@ S: Maintained F: Documentation/networking/device_drivers/ethernet/huawei/hinic.rst F: drivers/net/ethernet/huawei/hinic/ +HUAWEI 3RD GEN ETHERNET DRIVER +M: gongfan <[email protected]> +L: [email protected] +S: Supported +F: Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst +F: drivers/net/ethernet/huawei/hinic3/ + HUGETLB SUBSYSTEM M: Muchun Song <[email protected]> L: [email protected]
drivers/net/ethernet/huawei/Kconfig +1 -0
@@ -16,5 +16,6 @@ config NET_VENDOR_HUAWEI if NET_VENDOR_HUAWEI source "drivers/net/ethernet/huawei/hinic/Kconfig" +source "drivers/net/ethernet/huawei/hinic3/Kconfig" endif # NET_VENDOR_HUAWEI
drivers/net/ethernet/huawei/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_HINIC) += hinic/ +obj-$(CONFIG_HINIC3) += hinic3/
drivers/net/ethernet/huawei/hinic3/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Huawei driver configuration +# + +config HINIC3 + tristate "Huawei Intelligent Network Interface Card 3rd" + # Fields of HW and management structures are little endian and are + # currently not converted + depends on !CPU_BIG_ENDIAN + depends on X86 || ARM64 || COMPILE_TEST + depends on PCI_MSI && 64BIT + select AUXILIARY_BUS + help + This driver supports HiNIC PCIE Ethernet cards. + To compile this driver as part of the kernel, choose Y here. + If unsure, choose N. + The default is N.
drivers/net/ethernet/huawei/hinic3/Makefile new file +21 -0
@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +obj-$(CONFIG_HINIC3) += hinic3.o + +hinic3-objs := hinic3_hwdev.o \ + hinic3_lld.o \ + hinic3_common.o \ + hinic3_hwif.o \ + hinic3_hw_cfg.o \ + hinic3_queue_common.o \ + hinic3_mbox.o \ + hinic3_hw_comm.o \ + hinic3_wq.o \ + hinic3_nic_io.o \ + hinic3_nic_cfg.o \ + hinic3_tx.o \ + hinic3_rx.o \ + hinic3_netdev_ops.o \ + hinic3_rss.o \ + hinic3_main.o
drivers/net/ethernet/huawei/hinic3/hinic3_common.c new file +53 -0
53 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_common.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_COMMON_H +#define HINIC3_COMMON_H + +#include <linux/device.h> + +#define HINIC3_MIN_PAGE_SIZE 0x1000 + +struct hinic3_dma_addr_align { +u32 real_size; + +void *ori_vaddr; +dma_addr_t ori_paddr; + +void *align_vaddr; +dma_addr_t align_paddr; +}; + +int hinic3_dma_zalloc_coherent_align (struct device *dev,u32 size,u32 align, +gfp_t flag, +struct hinic3_dma_addr_align *mem_align); +void hinic3_dma_free_coherent_align (struct device *dev, +struct hinic3_dma_addr_align *mem_align); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/device.h> + +#include "hinic3_hw_cfg.h" +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_hwif.h" + +#define IS_NIC_TYPE (hwdev) \ + (((u32)(hwdev)->cfg_mgmt->svc_cap.chip_svc_type) & BIT(HINIC3_SERVICE_T_NIC)) + +bool hinic3_support_nic (struct hinic3_hwdev *hwdev) +{ +if (!IS_NIC_TYPE (hwdev)) +return false; + +return true; +} + +u16 hinic3_func_max_qnum (struct hinic3_hwdev *hwdev) +{ +return hwdev->cfg_mgmt->svc_cap.nic_cap.max_sqs; +} + +u8 hinic3_physical_port_id (struct hinic3_hwdev *hwdev) +{ +return hwdev->cfg_mgmt->svc_cap.port_id; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h new file +58 -0
58 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/delay.h> + +#include "hinic3_hw_comm.h" +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_hwif.h" + +static int comm_msg_to_mgmt_sync (struct hinic3_hwdev *hwdev,u16 cmd,const void *buf_in, +u32 in_size,void *buf_out,u32 *out_size) +{ +return hinic3_send_mbox_to_mgmt (hwdev,HINIC3_MOD_COMM , cmd, buf_in, + in_size, buf_out, out_size,0 ); +} + +int hinic3_func_reset (struct hinic3_hwdev *hwdev,u16 func_id,u64 reset_flag) +{ +struct comm_cmd_func_reset func_reset; +u32 out_size =sizeof (func_reset); +int err; + +memset (&func_reset,0 ,sizeof (func_reset)); + func_reset.func_id = func_id; + func_reset.reset_flag = reset_flag; + err =comm_msg_to_mgmt_sync (hwdev,COMM_MGMT_CMD_FUNC_RESET , + &func_reset,sizeof (func_reset), + &func_reset, &out_size); +if (err || !out_size || func_reset.head.status) { +dev_err (hwdev->dev,"Failed to reset func resources, reset_flag 0x%llx, err: %d, status: 0x%x, out_size: 0x%x\n" , + reset_flag, err, func_reset.head.status, out_size); +return -EIO ; + } + +return 0 ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_HW_COMM_H +#define HINIC3_HW_COMM_H + +#include "hinic3_hw_intf.h" + +struct hinic3_hwdev ; + +int hinic3_func_reset (struct hinic3_hwdev *hwdev,u16 func_id,u64 reset_flag); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h new file +88 -0
88 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c new file +24 -0
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_mgmt.h" +#include "hinic3_hw_comm.h" +#include "hinic3_hwif.h" + +int hinic3_init_hwdev (struct pci_dev *pdev) +{ +/* Completed by later submission due to LoC limit. */ +return -EFAULT ; +} + +void hinic3_free_hwdev (struct hinic3_hwdev *hwdev) +{ +/* Completed by later submission due to LoC limit. */ +} + +void hinic3_set_api_stop (struct hinic3_hwdev *hwdev) +{ +/* Completed by later submission due to LoC limit. */ +}
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.h new file +82 -0
82 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/device.h> +#include <linux/io.h> +#include <linux/bitfield.h> + +#include "hinic3_hwdev.h" +#include "hinic3_common.h" +#include "hinic3_hwif.h" + +u16 hinic3_global_func_id (struct hinic3_hwdev *hwdev) +{ +return hwdev->hwif->attr.func_global_idx; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.h new file +50 -0
50 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c new file +416 -0
416 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_lld.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_LLD_H +#define HINIC3_LLD_H + +#include <linux/auxiliary_bus.h> + +struct hinic3_event_info ; + +#define HINIC3_NIC_DRV_NAME "hinic3" + +int hinic3_lld_init (void ); +void hinic3_lld_exit (void ); +void hinic3_adev_event_register (struct auxiliary_device *adev, +void (*event_handler)(struct auxiliary_device *adev, +struct hinic3_event_info *event)); +void hinic3_adev_event_unregister (struct auxiliary_device *adev); +struct hinic3_hwdev *adev_get_hwdev (struct auxiliary_device *adev); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_main.c new file +418 -0
418 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/dma-mapping.h> + +#include "hinic3_mbox.h" +#include "hinic3_common.h" +#include "hinic3_hwdev.h" +#include "hinic3_hwif.h" + +int hinic3_send_mbox_to_mgmt (struct hinic3_hwdev *hwdev,u8 mod,u16 cmd, +const void *buf_in,u32 in_size,void *buf_out, +u32 *out_size,u32 timeout) +{ +/* Completed by later submission due to LoC limit. */ +return -EFAULT ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_MBOX_H +#define HINIC3_MBOX_H + +#include <linux/mutex.h> +#include <linux/bitfield.h> + +struct hinic3_hwdev ; + +int hinic3_send_mbox_to_mgmt (struct hinic3_hwdev *hwdev,u8 mod,u16 cmd, +const void *buf_in,u32 in_size,void *buf_out, +u32 *out_size,u32 timeout); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_MGMT_H +#define HINIC3_MGMT_H + +#include <linux/types.h> + +struct hinic3_hwdev ; + +void hinic3_flush_mgmt_workq (struct hinic3_hwdev *hwdev); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h new file +111 -0
111 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c new file +77 -0
77 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c new file +254 -0
254 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h new file +45 -0
45 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h new file +100 -0
100 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include "hinic3_nic_io.h" +#include "hinic3_hwdev.h" +#include "hinic3_nic_cfg.h" +#include "hinic3_nic_dev.h" +#include "hinic3_hw_comm.h" +#include "hinic3_hw_intf.h" +#include "hinic3_hwif.h" + +int hinic3_init_nic_io (struct hinic3_nic_dev *nic_dev) +{ +/* Completed by later submission due to LoC limit. */ +return -EFAULT ; +} + +void hinic3_free_nic_io (struct hinic3_nic_dev *nic_dev) +{ +/* Completed by later submission due to LoC limit. */ +}
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h new file +117 -0
117 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c new file +65 -0
65 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h new file +51 -0
51 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c new file +24 -0
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include "hinic3_rss.h" +#include "hinic3_hwdev.h" +#include "hinic3_nic_dev.h" +#include "hinic3_nic_cfg.h" +#include "hinic3_hwif.h" + +void hinic3_clear_rss_config (struct net_device *netdev) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); + +kfree (nic_dev->rss_hkey); + nic_dev->rss_hkey =NULL ; + +kfree (nic_dev->rss_indir); + nic_dev->rss_indir =NULL ; +} + +void hinic3_try_to_enable_rss (struct net_device *netdev) +{ +/* Completed by later submission due to LoC limit. */ +}
drivers/net/ethernet/huawei/hinic3/hinic3_rss.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_RSS_H +#define HINIC3_RSS_H + +#include <linux/netdevice.h> + +void hinic3_try_to_enable_rss (struct net_device *netdev); +void hinic3_clear_rss_config (struct net_device *netdev); + +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c new file +401 -0
401 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h new file +91 -0
91 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c new file +692 -0
54 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_tx.h new file +129 -0
129 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_wq.c new file +29 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/huawei/hinic3/hinic3_wq.h new file +75 -0
75 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.45.2
Part of the diff is not shown here. View the raw message.
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 5 lines · Gur Stavi
From: gongfan <[email protected]>
This is [1/3] part of hinic3 Ethernet driver initial submission. With this patch hinic3 is a valid kernel module but non-functional driver.
not very impressive for 3.8k new lines
please split it into more patches, say it should take at most an hour to read a single patch
You should also explain (in the cover letter) how different is this device from your previous generations, and in general you should strive to deduplicate the code.
Quoted 4 lines
The driver parts contained in this patch:
Module initialization.
PCI driver registration but with emptyid_table.
you have PCI IDs in the doc, why to not put them in the actual code? This driver should be loaded by you on your "pre market" HW.
Quoted 3 lines
Auxiliary driver registration.
Netdevice_opsregistration but open/stop are empty stubs. tx/rx logic.
Take care for spelling: Tx/Rx; HW (just below).
Quoted 6 lines
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.
Submitted-by Gur Stavi <[email protected]>
this tag is not needed
Quoted 1 line
Signed-off-by Gur Stavi <[email protected]>
your tag should be last
Quoted 1 line
Signed-off-by Xin Guo <[email protected]>
no idea what Xin did, if you want to give credit to someone you could use Co-developed-by: tag (put it just above the SoB)
Quoted 1 line
Signed-off-by gongfan <[email protected]>
It would be much appricieated if you will spell the full name for gongfan, at least two parts (like you did for the rest), especially for someone you put into the MAINTAINERS file. OTOH, please keep in mind that maintainer should be active on the mailing list (regarding this driver).
Quoted 52 lines
--- .../device_drivers/ethernet/huawei/hinic3.rst | 137 ++++ MAINTAINERS | 7 + drivers/net/ethernet/huawei/Kconfig | 1 + drivers/net/ethernet/huawei/Makefile | 1 + drivers/net/ethernet/huawei/hinic3/Kconfig | 18 + drivers/net/ethernet/huawei/hinic3/Makefile | 21 + .../ethernet/huawei/hinic3/hinic3_common.c | 53 ++ .../ethernet/huawei/hinic3/hinic3_common.h | 27 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 30 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 58 ++ .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 37 + .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 13 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 88 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_hwdev.h | 82 +++ .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 15 + .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 50 ++ .../net/ethernet/huawei/hinic3/hinic3_lld.c | 416 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_lld.h | 21 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 418 +++++++++++ .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 17 + .../net/ethernet/huawei/hinic3/hinic3_mbox.h | 16 + .../net/ethernet/huawei/hinic3/hinic3_mgmt.h | 13 + .../huawei/hinic3/hinic3_mgmt_interface.h | 111 +++ .../huawei/hinic3/hinic3_netdev_ops.c | 77 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 254 +++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 45 ++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 100 +++ .../ethernet/huawei/hinic3/hinic3_nic_io.c | 21 + .../ethernet/huawei/hinic3/hinic3_nic_io.h | 117 +++ .../huawei/hinic3/hinic3_queue_common.c | 65 ++ .../huawei/hinic3/hinic3_queue_common.h | 51 ++ .../net/ethernet/huawei/hinic3/hinic3_rss.c | 24 + .../net/ethernet/huawei/hinic3/hinic3_rss.h | 12 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 401 ++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rx.h | 91 +++ .../net/ethernet/huawei/hinic3/hinic3_tx.c | 692 ++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_tx.h | 129 ++++ .../net/ethernet/huawei/hinic3/hinic3_wq.c | 29 + .../net/ethernet/huawei/hinic3/hinic3_wq.h | 75 ++ 40 files changed, 3857 insertions(+)Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +3
-0@@ -0,0 +1,137 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=====================================================================
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst line 13
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +10
-0+Linux kernel driver for Huawei Ethernet Device Driver (hinic3) family +===================================================================== + +Overview +======== + +The hinic3 is a network interface card (NIC) for Data Center. It supports +a range of link-speed devices (10GE, 25GE, 100GE, etc.). The hinic3 +devices can have multiple physical forms (LOM NIC, PCIe standard NIC, +OCP NIC etc.).
please spell OCP out
Quoted 99 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +99
-0+ +The hinic3 driver supports the following features: +- IPv4/IPv6 TCP/UDP checksum offload +- TSO (TCP Segmentation Offload), LRO (Large Receive Offload) +- RSS (Receive Side Scaling) +- MSI-X interrupt aggregation configuration and interrupt adaptation. +- SR-IOV (Single Root I/O Virtualization). + +Content +======= + +- Supported PCI vendor ID/device IDs +- Source Code Structure of Hinic3 Driver +- Management Interface + +Supported PCI vendor ID/device IDs +================================== + +19e5:0222 - hinic3 PF/PPF +19e5:375F - hinic3 VF + +Prime Physical Function (PPF) is responsible for the management of the +whole NIC card. For example, clock synchronization between the NIC and +the host. Any PF may serve as a PPF. The PPF is selected dynamically. + +Source Code Structure of Hinic3 Driver +====================================== + +======================== ================================================ +hinic3_pci_id_tbl.h Supported device IDs +hinic3_hw_intf.h Interface between HW and driver +hinic3_queue_common.[ch] Common structures and methods for NIC queues +hinic3_common.[ch] Encapsulation of memory operations in Linux +hinic3_csr.h Register definitions in the BAR +hinic3_hwif.[ch] Interface for BAR +hinic3_eqs.[ch] Interface for AEQs and CEQs +hinic3_mbox.[ch] Interface for mailbox +hinic3_mgmt.[ch] Management interface based on mailbox and AEQ +hinic3_wq.[ch] Work queue data structures and interface +hinic3_cmdq.[ch] Command queue is used to post command to HW +hinic3_hwdev.[ch] HW structures and methods abstractions +hinic3_lld.[ch] Auxiliary driver adaptation layer +hinic3_hw_comm.[ch] Interface for common HW operations +hinic3_mgmt_interface.h Interface between firmware and driver +hinic3_hw_cfg.[ch] Interface for HW configuration +hinic3_irq.c Interrupt request +hinic3_netdev_ops.c Operations registered to Linux kernel stack +hinic3_nic_dev.h NIC structures and methods abstractions +hinic3_main.c Main Linux kernel driver +hinic3_nic_cfg.[ch] NIC service configuration +hinic3_nic_io.[ch] Management plane interface for TX and RX +hinic3_rss.[ch] Interface for Receive Side Scaling (RSS) +hinic3_rx.[ch] Interface for transmit +hinic3_tx.[ch] Interface for receive +hinic3_ethtool.c Interface for ethtool operations (ops) +hinic3_filter.c Interface for MAC address +======================== ================================================ + +Management Interface +==================== + +Asynchronous Event Queue (AEQ) +------------------------------ + +AEQ receives high priority events from the HW over a descriptor queue. +Every descriptor is a fixed size of 64 bytes. AEQ can receive solicited or +unsolicited events. Every device, VF or PF, can have up to 4 AEQs. +Every AEQ is associated to a dedicated IRQ. AEQ can receive multiple types +of events, but in practice the hinic3 driver ignores all events except for +2 mailbox related events. + +Mailbox +------- + +Mailbox is a communication mechanism between the hinic3 driver and the HW. +Each device has an independent mailbox. Driver can use the mailbox to send +requests to management. Driver receives mailbox messages, such as responses +to requests, over the AEQ (using event HINIC3_AEQ_FOR_MBOX). Due to the +limited size of mailbox data register, mailbox messages are sent +segment-by-segment. + +Every device can use its mailbox to post request to firmware. The mailbox +can also be used to post requests and responses between the PF and its VFs. + +Completion Event Queue (CEQ) +-------------------------- + +The implementation of CEQ is the same as AEQ. It receives completion events +from HW over a fixed size descriptor of 32 bits. Every device can have up +to 32 CEQs. Every CEQ has a dedicated IRQ. CEQ only receives solicited +events that are responses to requests from the driver. CEQ can receive +multiple types of events, but in practice the hinic3 driver ignores all +events except for HINIC3_CMDQ that represents completion of previously +posted commands on a cmdq. + +Command Queue (cmdq) +-------------------- + +Every cmdq has a dedicated work queue on which commands are posted.
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst line 122
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +10
-0+Commands on the work queue are fixed size descriptor of size 64 bytes. +Completion of a command will be indicated using ctrl bits in the +descriptor that carried the command. Notification of command completions +will also be provided via event on CEQ. Every device has 4 command queues +that are initialized as a set (called cmdqs), each with its own type. +Hinic3 driver only uses type HINIC3_CMDQ_SYNC. + +Work Queues(WQ) +--------------- +
in kernel "work queues" are already a thing, would be good to avoid the name clash
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst line 131
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +9
-0+Work queues are logical arrays of fixed size WQEs. The array may be spread +over multiple non-contiguous pages using indirection table. Work queues are +used by I/O queues and command queues. + +Global function ID +------------------ + +Every function, PF or VF, has a unique ordinal identification within the device. +Many commands to management (mbox or cmdq) contain this ID so HW can apply the
s/commands to management/management commands/
Quoted 11 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +6
-0+command effect to the right function. + +PF is allowed to post management commands to a subordinate VF by specifying the +VFs ID. A VF must provide its own ID. Anti-spoofing in the HW will cause +command from a VF to fail if it contains the wrong ID. +MAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 10604
Quoted 5 lines
MAINTAINERS +2
-0@@ -10600,6 +10600,13 @@ S: Maintained F: Documentation/networking/device_drivers/ethernet/huawei/hinic.rst F: drivers/net/ethernet/huawei/hinic/ +HUAWEI 3RD GEN ETHERNET DRIVER +M: gongfan <[email protected]>
again, must be a real person, that participates on the list wrt the driver, with a full name spelled out
MAINTAINERS S: Maintained · line 10606
Quoted 2 lines
MAINTAINERS +2
-0+L: [email protected] +S: Supported
there is a (relatively new) requirement that the device needs to report to the netdev CI to have an "S" here, so for now you should use "M"
Quoted 32 lines
MAINTAINERS +3
-0+F: Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst +F: drivers/net/ethernet/huawei/hinic3/ + HUGETLB SUBSYSTEM M: Muchun Song <[email protected]> L: [email protected]drivers/net/ethernet/huawei/Kconfig +1
-0@@ -16,5 +16,6 @@ config NET_VENDOR_HUAWEI if NET_VENDOR_HUAWEI source "drivers/net/ethernet/huawei/hinic/Kconfig" +source "drivers/net/ethernet/huawei/hinic3/Kconfig" endif # NET_VENDOR_HUAWEIdrivers/net/ethernet/huawei/Makefile +1
-0@@ -4,3 +4,4 @@ # obj-$(CONFIG_HINIC) += hinic/ +obj-$(CONFIG_HINIC3) += hinic3/drivers/net/ethernet/huawei/hinic3/Kconfig new file +0
-0
drivers/net/ethernet/huawei/hinic3/Kconfig line 7
Quoted 7 lines
drivers/net/ethernet/huawei/hinic3/Kconfig new file +7
-0@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Huawei driver configuration +# + +config HINIC3 + tristate "Huawei Intelligent Network Interface Card 3rd"
what do you mean by Intelligent?
drivers/net/ethernet/huawei/hinic3/Kconfig line 18
Quoted 11 lines
drivers/net/ethernet/huawei/hinic3/Kconfig new file +11
-0+ # Fields of HW and management structures are little endian and are + # currently not converted + depends on !CPU_BIG_ENDIAN + depends on X86 || ARM64 || COMPILE_TEST + depends on PCI_MSI && 64BIT + select AUXILIARY_BUS + help + This driver supports HiNIC PCIE Ethernet cards. + To compile this driver as part of the kernel, choose Y here. + If unsure, choose N. + The default is N.
the last 3 lines are very much obvious/redundant
drivers/net/ethernet/huawei/hinic3/Makefile line 2
Quoted 8 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +2
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
too late
Quoted 9 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +9
-0+ +obj-$(CONFIG_HINIC3) += hinic3.o + +hinic3-objs := hinic3_hwdev.o \ + hinic3_lld.o \ + hinic3_common.o \ + hinic3_hwif.o \ + hinic3_hw_cfg.o \ + hinic3_queue_common.o \
drivers/net/ethernet/huawei/hinic3/Makefile line 21
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +10
-0+ hinic3_mbox.o \ + hinic3_hw_comm.o \ + hinic3_wq.o \ + hinic3_nic_io.o \ + hinic3_nic_cfg.o \ + hinic3_tx.o \ + hinic3_rx.o \ + hinic3_netdev_ops.o \ + hinic3_rss.o \ + hinic3_main.o
in general, any list of random things could be sorted (to ease out git merges in the future)
Quoted 99 lines
drivers/net/ethernet/huawei/hinic3/hinic3_common.c new file +53
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/dma-mapping.h> +#include <linux/delay.h> + +#include "hinic3_common.h" + +int hinic3_dma_zalloc_coherent_align (struct device *dev,u32 size,u32 align, +gfp_t flag, +struct hinic3_dma_addr_align *mem_align) +{ +dma_addr_t paddr, align_paddr; +void *vaddr, *align_vaddr; +u32 real_size = size; + + vaddr =dma_alloc_coherent (dev, real_size, &paddr, flag); +if (!vaddr) +return -ENOMEM ; + + align_paddr =ALIGN (paddr, align); +if (align_paddr == paddr) { + align_vaddr = vaddr; + goto out; + } + +dma_free_coherent (dev, real_size, vaddr, paddr); + +/* realloc memory for align */ + real_size = size + align; + vaddr =dma_alloc_coherent (dev, real_size, &paddr, flag); +if (!vaddr) +return -ENOMEM ; + + align_paddr =ALIGN (paddr, align); + align_vaddr = vaddr + (align_paddr - paddr); + +out: + mem_align->real_size = real_size; + mem_align->ori_vaddr = vaddr; + mem_align->ori_paddr = paddr; + mem_align->align_vaddr = align_vaddr; + mem_align->align_paddr = align_paddr; + +return 0 ; +} + +void hinic3_dma_free_coherent_align (struct device *dev, +struct hinic3_dma_addr_align *mem_align) +{ +dma_free_coherent (dev, mem_align->real_size, + mem_align->ori_vaddr, mem_align->ori_paddr); +}drivers/net/ethernet/huawei/hinic3/hinic3_common.h new file +27
-0@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_COMMON_H +#define HINIC3_COMMON_H + +#include <linux/device.h> + +#define HINIC3_MIN_PAGE_SIZE 0x1000 + +struct hinic3_dma_addr_align { +u32 real_size; + +void *ori_vaddr; +dma_addr_t ori_paddr; + +void *align_vaddr; +dma_addr_t align_paddr; +}; + +int hinic3_dma_zalloc_coherent_align (struct device *dev,u32 size,u32 align, +gfp_t flag, +struct hinic3_dma_addr_align *mem_align); +void hinic3_dma_free_coherent_align (struct device *dev, +struct hinic3_dma_addr_align *mem_align); + +#endif drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c new file +1
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c line 11
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c new file +10
-0+// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/device.h> + +#include "hinic3_hw_cfg.h" +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_hwif.h" + +#define IS_NIC_TYPE (hwdev) \
you have to prefix names of all of your types, macros, functions with your driver
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c line 19
Quoted 8 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c new file +8
-0+ (((u32)(hwdev)->cfg_mgmt->svc_cap.chip_svc_type) & BIT(HINIC3_SERVICE_T_NIC)) + +bool hinic3_support_nic (struct hinic3_hwdev *hwdev) +{ +if (!IS_NIC_TYPE (hwdev)) +return false; + +return true;
this is just:
return IS_NIC_TYPE(hwdev);
Quoted 25 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c new file +11
-0+} + +u16 hinic3_func_max_qnum (struct hinic3_hwdev *hwdev) +{ +return hwdev->cfg_mgmt->svc_cap.nic_cap.max_sqs; +} + +u8 hinic3_physical_port_id (struct hinic3_hwdev *hwdev) +{ +return hwdev->cfg_mgmt->svc_cap.port_id; +}drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h new file +8
-0@@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_HW_CFG_H +#define HINIC3_HW_CFG_H + +#include <linux/mutex.h> +
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h line 18
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h new file +10
-0+struct hinic3_hwdev ; + +struct irq_info { +u16 msix_entry_idx; +/* provided by OS */ +u32 irq_id; +}; + +struct cfg_irq_alloc_info { +bool allocated;
in general it is a good practice to don't introduce holes into your structs when there is no reason to do so (and reminder for the prefix in the struct names)
Quoted 56 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h new file +40
-0+ struct irq_info info; +}; + +struct cfg_irq_info { +struct cfg_irq_alloc_info *alloc_info; +u16 num_irq; +/* device max irq number */ +u16 num_irq_hw; +/* protect irq alloc and free */ +struct mutex irq_mutex; +}; + +struct nic_service_cap { +u16 max_sqs; +}; + +/* device capability */ +struct service_cap { +/* HW supported service type, reference to service_bit_define */ +u16 chip_svc_type; +/* physical port */ +u8 port_id; +/* NIC capability */ +struct nic_service_cap nic_cap; +}; + +struct cfg_mgmt_info { +struct cfg_irq_info irq_info; +struct service_cap svc_cap; +}; + +int hinic3_alloc_irqs (struct hinic3_hwdev *hwdev,u16 num, +struct irq_info *alloc_arr,u16 *act_num); +void hinic3_free_irq (struct hinic3_hwdev *hwdev,u32 irq_id); + +bool hinic3_support_nic (struct hinic3_hwdev *hwdev); +u16 hinic3_func_max_qnum (struct hinic3_hwdev *hwdev); +u8 hinic3_physical_port_id (struct hinic3_hwdev *hwdev); + +#endif drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +10
-0@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. + +#include <linux/delay.h> + +#include "hinic3_hw_comm.h" +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_hwif.h" +
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c line 20
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +10
-0+static int comm_msg_to_mgmt_sync (struct hinic3_hwdev *hwdev,u16 cmd,const void *buf_in, +u32 in_size,void *buf_out,u32 *out_size) +{ +return hinic3_send_mbox_to_mgmt (hwdev,HINIC3_MOD_COMM , cmd, buf_in, + in_size, buf_out, out_size,0 ); +} + +int hinic3_func_reset (struct hinic3_hwdev *hwdev,u16 func_id,u64 reset_flag) +{ +struct comm_cmd_func_reset func_reset;
= {}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c line 24
Quoted 4 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +4
-0+u32 out_size =sizeof (func_reset); +int err; + +memset (&func_reset,0 ,sizeof (func_reset));
with "= {}" above, memset() could be eliminated
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c line 26
Quoted 2 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +2
-0+ func_reset.func_id = func_id; + func_reset.reset_flag = reset_flag;
alternative would be
struct comm_cmd_func_reset func_reset = {
.func_id = func_id,
.reset_flag = reset_flag,
};drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c line 29
Quoted 3 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +3
-0+ err =comm_msg_to_mgmt_sync (hwdev,COMM_MGMT_CMD_FUNC_RESET , + &func_reset,sizeof (func_reset), + &func_reset, &out_size);
it's not typical to have a function that gets given pointer twice
Quoted 33 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c new file +8
-0+if (err || !out_size || func_reset.head.status) { +dev_err (hwdev->dev,"Failed to reset func resources, reset_flag 0x%llx, err: %d, status: 0x%x, out_size: 0x%x\n" , + reset_flag, err, func_reset.head.status, out_size); +return -EIO ; + } + +return 0 ; +}drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_HW_COMM_H +#define HINIC3_HW_COMM_H + +#include "hinic3_hw_intf.h" + +struct hinic3_hwdev ; + +int hinic3_func_reset (struct hinic3_hwdev *hwdev,u16 func_id,u64 reset_flag); + +#endif drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h new file +0
-0
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h line 4
Quoted 4 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h new file +4
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_HW_INTF_H
please add two underscores to the header guards
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h line 9
Quoted 5 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h new file +5
-0+#define HINIC3_HW_INTF_H + +#include <linux/types.h> +#include <linux/bits.h> +
please sort the headers
please adhere to IWYU
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h line 14
Quoted 5 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h new file +5
-0+ +int hinic3_init_hwdev (struct pci_dev *pdev) +{ +/* Completed by later submission due to LoC limit. */ +return -EFAULT ;
please split series into proper patches, and fill this out, the driver should be able to tx/rx with the series applied
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 5 lines
Quoted 3 lines
Auxiliary driver registration.
Netdevice_opsregistration but open/stop are empty stubs. tx/rx logic.Take care for spelling: Tx/Rx; HW (just below).
Please elaborate. Spelling of what?
Quoted 19 lines
Quoted 7 lines
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.
Submitted-by Gur Stavi <[email protected]>this tag is not needed
Quoted 1 line
Signed-off-by Gur Stavi <[email protected]>your tag should be last
Quoted 1 line
Signed-off-by Xin Guo <[email protected]>no idea what Xin did, if you want to give credit to someone you could use Co-developed-by: tag (put it just above the SoB)
Quoted 8 lines
Quoted 1 line
Signed-off-by gongfan <[email protected]>It would be much appricieated if you will spell the full name for gongfan, at least two parts (like you did for the rest), especially for someone you put into the
MAINTAINERSfile. OTOH, please keep in mind that maintainer should be active on the mailing list (regarding this driver).
Ack
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst line 131
Quoted 6 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst new file +6
-0+ +Global function ID +------------------ + +Every function, PF or VF, has a unique ordinal identification within the device. +Many commands to management (mbox or cmdq) contain this ID so HW can apply thes/commands to management/management commands/
Ack
Quoted 6 lines
MAINTAINERS S: Maintained · line 10606
Quoted 2 lines
MAINTAINERS +2
-0+L: [email protected] +S: Supportedthere is a (relatively new) requirement that the device needs to report to the netdev CI to have an "S" here, so for now you should use "M"
Ack
Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/huawei/hinic3/Kconfig new file +5
-0+ # Fields of HW and management structures are little endian and are + # currently not converted + depends on !CPU_BIG_ENDIAN + depends on X86 || ARM64 || COMPILE_TEST + depends on PCI_MSI && 64BIT
Quoted 9 lines
drivers/net/ethernet/huawei/hinic3/Kconfig line 18
Quoted 6 lines
drivers/net/ethernet/huawei/hinic3/Kconfig new file +6
-0+ select AUXILIARY_BUS + help + This driver supports HiNIC PCIE Ethernet cards. + To compile this driver as part of the kernel, choose Y here. + If unsure, choose N. + The default is N.the last 3 lines are very much obvious/redundant
Ack
Quoted 11 lines
drivers/net/ethernet/huawei/hinic3/Makefile line 2
Quoted 8 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +2
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.too late
Ack
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +14
-0+ +obj-$(CONFIG_HINIC3) += hinic3.o + +hinic3-objs := hinic3_hwdev.o \ + hinic3_lld.o \ + hinic3_common.o \ + hinic3_hwif.o \ + hinic3_hw_cfg.o \ + hinic3_queue_common.o \ + hinic3_mbox.o \ + hinic3_hw_comm.o \ + hinic3_wq.o \ + hinic3_nic_io.o \ + hinic3_nic_cfg.o \
Quoted 9 lines
drivers/net/ethernet/huawei/hinic3/Makefile line 21
Quoted 5 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +5
-0+ hinic3_tx.o \ + hinic3_rx.o \ + hinic3_netdev_ops.o \ + hinic3_rss.o \ + hinic3_main.oin general, any list of random things could be sorted (to ease out git merges in the future)
Ack
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/Makefile
Quoted 8 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +8
-0+ (((u32)(hwdev)->cfg_mgmt->svc_cap.chip_svc_type) & BIT(HINIC3_SERVICE_T_NIC)) + +bool hinic3_support_nic(struct hinic3_hwdev *hwdev) +{ + if (!IS_NIC_TYPE(hwdev)) + return false; + + return true;this is just:
Quoted 2 lines
return IS_NIC_TYPE(hwdev);
Ack
Quoted 20 lines
drivers/net/ethernet/huawei/hinic3/Makefile
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +10
-0+static int comm_msg_to_mgmt_sync(struct hinic3_hwdev *hwdev, u16 cmd, const void *buf_in, + u32 in_size, void *buf_out, u32 *out_size) +{ + return hinic3_send_mbox_to_mgmt(hwdev, HINIC3_MOD_COMM, cmd, buf_in, + in_size, buf_out, out_size, 0); +} + +int hinic3_func_reset(struct hinic3_hwdev *hwdev, u16 func_id, u64 reset_flag) +{ + struct comm_cmd_func_reset func_reset;= {}
drivers/net/ethernet/huawei/hinic3/Makefile
Quoted 4 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +4
-0+ u32 out_size = sizeof(func_reset); + int err; + + memset(&func_reset, 0, sizeof(func_reset));with "= {}" above,
memset()could be eliminated
Quoted 9 lines
drivers/net/ethernet/huawei/hinic3/Makefile
Quoted 2 lines
drivers/net/ethernet/huawei/hinic3/Makefile new file +2
-0+ func_reset.func_id = func_id; + func_reset.reset_flag = reset_flag;alternative would be
struct comm_cmd_func_reset func_reset = { .func_id = func_id, .reset_flag = reset_flag, };
Ack
Quoted 9 lines
drivers/net/ethernet/huawei/hinic3/Makefile line 4
Quoted 6 lines
+++
b/drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.hdrivers/net/ethernet/huawei/hinic3/Makefile new file +4
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved. */ + +#ifndef HINIC3_HW_INTF_Hplease add two underscores to the header guards
Ack
Quoted 1 line
Quoted 1 line
drivers/net/ethernet/huawei/hinic3/Makefile new file +1
-0+#define HINIC3_HW_INTF_H
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 7 lines · Gur Stavi
Quoted 5 lines
Quoted 3 lines
Auxiliary driver registration.
Netdevice_opsregistration but open/stop are empty stubs. tx/rx logic.Take care for spelling: Tx/Rx; HW (just below).
Please elaborate. Spelling of what?
In all code comments and commit messages the acronyms and abbreviations have their proper spelling, like "Tx", "Rx", "HW', "SW", "ID".
of course lowercase names are still allowed for variables/fields
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
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.
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Auxiliary driver registration.
Netdevice_opsregistration but open/stop are empty stubs. tx/rx logic.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Take care for spelling: Tx/Rx; HW (just below).
Please elaborate. Spelling of what?
In all code comments and commit messages the acronyms and abbreviations have their proper spelling, like "Tx", "Rx", "HW', "SW", "ID".
of course lowercase names are still allowed for variables/fields
Grepped drivers/net/ethernet (whole word only):
hw 34681 HW 3708 Hw 170 sw 1198 SW 675 Sw 3 rx 5913 RX 4042 Rx 4042 tx 5424 TX 4095 Tx 4907 id 5545 ID 1967 Id 56
I don't know a quick way to separate variables from comments but I believe that there are very few hw and sw variables and most tx, rx related variables will have some prefix or suffix so lots of the whole-word-only come from comments.
Can we agree that while Hw, Sw and Id are improper, the remaining forms are acceptable?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
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.
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 22 lines · Gur Stavi
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Auxiliary driver registration.
Netdevice_opsregistration but open/stop are empty stubs. tx/rx logic.Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Take care for spelling: Tx/Rx; HW (just below).
Please elaborate. Spelling of what?
In all code comments and commit messages the acronyms and abbreviations have their proper spelling, like "Tx", "Rx", "HW', "SW", "ID".
of course lowercase names are still allowed for variables/fields
Grepped
drivers/net/ethernet(whole word only):hw 34681 HW 3708 Hw 170 sw 1198 SW 675 Sw 3 rx 5913 RX 4042 Rx 4042 tx 5424 TX 4095 Tx 4907 id 5545 ID 1967 Id 56
Quoted 6 lines
I don't know a quick way to separate variables from comments but I believe that there are very few hw and sw variables and most tx, rx related variables will have some prefix or suffix so lots of the whole-word-only come from comments.
Can we agree that while Hw, Sw and Id are improper, the remaining forms are acceptable?
"tx", "rx", "hw" are very common variable/field names, "sw" could be also a shortcut for "switch"
If you want to argue, the stats should be only for the comments, and excluding things like "@hw" from the kdoc.
But then, anyway, "current code misspells a lot" is not a reason to continue the practice.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
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.
Simon Horman
reviewerRe: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
In reply to Gur StaviQuoted 21 lines · Gur Stavi
From: gongfan <[email protected]>
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 emptyid_table. Auxiliary driver registration.
Netdevice_opsregistration 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.
Submitted-by Gur Stavi <[email protected]>Signed-off-by Gur Stavi <[email protected]>Signed-off-by Xin Guo <[email protected]>Signed-off-by gongfan <[email protected]>
...
Quoted 1 line
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst +0
-0
...
Quoted 2 lines
+Completion Event Queue (CEQ)
+--------------------------
nit: the length of the "---" line doesn't match that of the line above it.
...
Re: [PATCH net-next v04 1/1] hinic3: module initialization and tx/rx logic
Quoted 9 lines
Quoted 2 lines
Documentation/networking/device_drivers/ethernet/huawei/hinic3.rst +0
-0...
Quoted 2 lines
+Completion Event Queue (CEQ)
+--------------------------nit: the length of the "---" line doesn't match that of the line above it.
Ack
Quoted 2 lines
...