net: hinic3: Add a driver for Huawei 3rd gen NIC - sw and hw initialization
Subsystems (4)
Fan Gong
maintainerv4 cover net: hinic3: Add a driver for Huawei 3rd gen NIC - sw and hw initialization
This is [3/3] part of hinic3 Ethernet driver initial submission. With this patch hinic3 becomes a functional Ethernet driver.
The driver parts contained in this patch:
Memory allocation and initialization of the driver structures. Management interfaces initialization.
HW capabilities probing, initialization and setup using management interfaces.
Net device open/stop implementation and data queues initialization. Register VID:DID in PCI id_table.
Fix netif_queue_set_napi usage.
Changes:
PATCH 03 V01: https://lore.kernel.org/netdev/[email protected]
* Remove extra memset 0 after kzalloc (Vadim Fedorenko)
* Remove another init function in hinic3_init_hwdev/hwif/nic_io (Vadim Fedorenko)
* Create a new separate patch of fixing code style (Vadim Fedorenko)
* Use bitmap_free instead of kfree (ALOK TIWARI)
* Add prefix "hinic3" to non-static functions and parse_* functions (Vadim Fedorenko)
* Init func_tbl_cfg to {} (Vadim Fedorenko)
* Extract endianess improvement from queue pair resource initialization (Vadim Fedorenko)
* Use kmalloc_array before overwrite rss_hkey on the very next line (Vadim Fedorenko)
* Remove extra key copy about hinic3_rss_set_hash_key (Vadim Fedorenko)
* Use netdev_rss_key_fill instead of static rss hash key for safety (Eric Dumazet)
PATCH 03 V02: https://lore.kernel.org/netdev/[email protected]
* Modify get_hwif_attr function for improving readability (Vadim Fedorenko)
* Add HINIC3_PCIE_LINK_DOWN errorcode to init_hwif_attr error handling (Vadim Fedorenko)
PATCH 03 V03: https://lore.kernel.org/netdev/[email protected]
* Use pci_enable_msix_range instead of pci_alloc_irq_vectors (Jakub Kicinski)
* Move defensive codes to place that they are set/loaded (Jakub Kicinski)
* Code format fixes: remove empty lines between error handling path (Jakub Kicinski)
* Remove redundant waiting sleep in hinic3_rx_tx_flush (Jakub Kicinski)
* Use ethtool_rxfh_indir_default for standalizing codes (Jakub Kicinski)
* Use netif_get_num_default_rss_queues instead of driver-local logic (Jakub Kicinski)
* Use netif_set_real_num_queues to set both TX and RX queues (Jakub Kicinski)
PATCH 03 V04:
Fan Gong (14):
hinic3: HW initialization
hinic3: HW management interfaces
hinic3: HW common function initialization
hinic3: HW capability initialization
hinic3: Command Queue flush interfaces
hinic3: Nic_io initialization
hinic3: Queue pair endianness improvements
hinic3: Queue pair resource initialization
hinic3: Queue pair context initialization
hinic3: Tx & Rx configuration
hinic3: Add Rss function
hinic3: Add port management
hinic3: Fix missing napi->dev in netif_queue_set_napi
hinic3: Fix code style (Missing a blank line before return)
drivers/net/ethernet/huawei/hinic3/Makefile | 2 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 168 ++++ .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 4 + .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 361 ++++++++ .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 21 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 121 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 541 ++++++++++- .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 281 ++++++ .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 16 + .../net/ethernet/huawei/hinic3/hinic3_irq.c | 2 +- .../net/ethernet/huawei/hinic3/hinic3_lld.c | 9 +- .../net/ethernet/huawei/hinic3/hinic3_main.c | 8 +- .../net/ethernet/huawei/hinic3/hinic3_mgmt.c | 21 + .../net/ethernet/huawei/hinic3/hinic3_mgmt.h | 2 + .../huawei/hinic3/hinic3_mgmt_interface.h | 119 +++ .../huawei/hinic3/hinic3_netdev_ops.c | 425 ++++++++- .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 152 +++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 20 + .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 5 + .../ethernet/huawei/hinic3/hinic3_nic_io.c | 870 +++++++++++++++++- .../ethernet/huawei/hinic3/hinic3_nic_io.h | 39 +- .../huawei/hinic3/hinic3_pci_id_tbl.h | 9 + .../net/ethernet/huawei/hinic3/hinic3_rss.c | 336 +++++++ .../net/ethernet/huawei/hinic3/hinic3_rss.h | 14 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 226 ++++- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 38 +- .../net/ethernet/huawei/hinic3/hinic3_tx.c | 184 +++- .../net/ethernet/huawei/hinic3/hinic3_tx.h | 30 +- 28 files changed, 3938 insertions(+), 86 deletions(-) create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_pci_id_tbl.h create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rss.c create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_rss.h
base-commit: b1c92cdf5af3198e8fbc1345a80e2a1dff386c02
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 1/14 hinic3: HW initialization
Add the hardware resource data structures, functions for HW initialization, configuration and releasement.
--- .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 52 +++- .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 243 ++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 13 + .../net/ethernet/huawei/hinic3/hinic3_lld.c | 3 +- .../huawei/hinic3/hinic3_pci_id_tbl.h | 9 + 5 files changed, 316 insertions(+), 4 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +49 -3
@@ -7,15 +7,61 @@#include "hinic3_mbox.h" #include "hinic3_mgmt.h" +#define HINIC3_HWDEV_WQ_NAME "hinic3_hardware" +#define HINIC3_WQ_MAX_REQ 10 + +enum hinic3_hwdev_init_state { +HINIC3_HWDEV_MBOX_INITED =2 , +HINIC3_HWDEV_CMDQ_INITED =3 , +}; +int hinic3_init_hwdev (struct pci_dev *pdev) { -/* Completed by later submission due to LoC limit. */ -return -EFAULT ; +struct hinic3_pcidev *pci_adapter =pci_get_drvdata (pdev); +struct hinic3_hwdev *hwdev; +int err; + + hwdev =kzalloc (sizeof (*hwdev),GFP_KERNEL ); +if (!hwdev) +return -ENOMEM ; + + pci_adapter->hwdev = hwdev; + hwdev->adapter = pci_adapter; + hwdev->pdev = pci_adapter->pdev; + hwdev->dev = &pci_adapter->pdev->dev; + hwdev->func_state =0 ; +spin_lock_init (&hwdev->channel_lock); + + err =hinic3_init_hwif (hwdev); +if (err) { +dev_err (hwdev->dev,"Failed to init hwif\n" ); + goto err_free_hwdev; + } + + hwdev->workq =alloc_workqueue (HINIC3_HWDEV_WQ_NAME ,WQ_MEM_RECLAIM , +HINIC3_WQ_MAX_REQ ); +if (!hwdev->workq) { +dev_err (hwdev->dev,"Failed to alloc hardware workq\n" ); + err = -ENOMEM ; + goto err_free_hwif; + } + +return 0 ; + +err_free_hwif: +hinic3_free_hwif (hwdev); +err_free_hwdev: + pci_adapter->hwdev =NULL ; +kfree (hwdev); + +return err; }void hinic3_free_hwdev (struct hinic3_hwdev *hwdev) { -/* Completed by later submission due to LoC limit. */ +destroy_workqueue (hwdev->workq); +hinic3_free_hwif (hwdev); +kfree (hwdev); }void hinic3_set_api_stop (struct hinic3_hwdev *hwdev)
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +243 -0
273 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.h +13 -0
@@ -45,6 +45,16 @@ struct hinic3_hwif {struct hinic3_func_attr attr; }; +enum hinic3_outbound_ctrl { +ENABLE_OUTBOUND =0x0 , +DISABLE_OUTBOUND =0x1 , +}; + +enum hinic3_doorbell_ctrl { +ENABLE_DOORBELL =0 , +DISABLE_DOORBELL =1 , +}; +enum hinic3_msix_state {HINIC3_MSIX_ENABLE ,HINIC3_MSIX_DISABLE ,
@@ -62,6 +72,9 @@ int hinic3_alloc_db_addr(struct hinic3_hwdev *hwdev, void __iomem **db_base, void __iomem **dwqe_base);void hinic3_free_db_addr (struct hinic3_hwdev *hwdev,const u8 __iomem *db_base); +int hinic3_init_hwif (struct hinic3_hwdev *hwdev); +void hinic3_free_hwif (struct hinic3_hwdev *hwdev); +void hinic3_set_msix_state (struct hinic3_hwdev *hwdev,u16 msix_idx,enum hinic3_msix_state flag); void hinic3_msix_intr_clear_resend_bit(struct hinic3_hwdev *hwdev, u16 msix_idx,
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c +2 -1
@@ -8,6 +8,7 @@#include "hinic3_hwdev.h" #include "hinic3_lld.h" #include "hinic3_mgmt.h" +#include "hinic3_pci_id_tbl.h" #define HINIC3_VF_PCI_CFG_REG_BAR 0#define HINIC3_PCI_INTR_REG_BAR 2
@@ -377,7 +378,7 @@ static void hinic3_remove(struct pci_dev *pdev) }static const struct pci_device_id hinic3_pci_table[] = { -/* Completed by later submission due to LoC limit. */ + {PCI_VDEVICE (HUAWEI ,PCI_DEV_ID_HINIC3_VF ),0 }, {0 ,0 } };
drivers/net/ethernet/huawei/hinic3/hinic3_pci_id_tbl.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. */ + +#ifndef _HINIC3_PCI_ID_TBL_H_ +#define _HINIC3_PCI_ID_TBL_H_ + +#define PCI_DEV_ID_HINIC3_VF 0x375F + +#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 2/14 hinic3: HW management interfaces
In reply to Fan GongInitialize hardware management config of irq, aeq and ceq. These will send hardware messages to driver.
--- drivers/net/ethernet/huawei/hinic3/Makefile | 1 + .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 102 ++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 3 + .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 10 ++ .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 12 +++ .../net/ethernet/huawei/hinic3/hinic3_lld.c | 1 + .../net/ethernet/huawei/hinic3/hinic3_mgmt.c | 21 ++++ .../net/ethernet/huawei/hinic3/hinic3_mgmt.h | 2 + 8 files changed, 152 insertions(+)
drivers/net/ethernet/huawei/hinic3/Makefile +1 -0
@@ -14,6 +14,7 @@ hinic3-objs := hinic3_cmdq.o \ hinic3_lld.o \ hinic3_main.o \ hinic3_mbox.o \ + hinic3_mgmt.o \ hinic3_netdev_ops.o \ hinic3_nic_cfg.o \ hinic3_nic_io.o \
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c +102 -0
108 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h +3 -0
@@ -42,6 +42,9 @@ struct hinic3_cfg_mgmt_info {struct hinic3_dev_cap cap; }; +int hinic3_init_cfg_mgmt (struct hinic3_hwdev *hwdev); +void hinic3_free_cfg_mgmt (struct hinic3_hwdev *hwdev); +int hinic3_alloc_irqs (struct hinic3_hwdev *hwdev,u16 num,struct msix_entry *alloc_arr,u16 *act_num);void hinic3_free_irq (struct hinic3_hwdev *hwdev,u32 irq_id);
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +10 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. +#include "hinic3_eqs.h" #include "hinic3_hw_comm.h" #include "hinic3_hwdev.h" #include "hinic3_hwif.h"
@@ -46,8 +47,16 @@ int hinic3_init_hwdev(struct pci_dev *pdev) goto err_free_hwif; } + err =hinic3_init_cfg_mgmt (hwdev); +if (err) { +dev_err (hwdev->dev,"Failed to init config mgmt\n" ); + goto err_destroy_workqueue; + } +return 0 ; +err_destroy_workqueue: +destroy_workqueue (hwdev->workq); err_free_hwif:hinic3_free_hwif (hwdev); err_free_hwdev:
@@ -59,6 +68,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev)void hinic3_free_hwdev (struct hinic3_hwdev *hwdev) { +hinic3_free_cfg_mgmt (hwdev);destroy_workqueue (hwdev->workq);hinic3_free_hwif (hwdev);kfree (hwdev);
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +12 -0
@@ -144,6 +144,18 @@ static int init_hwif_attr(struct hinic3_hwdev *hwdev)set_hwif_attr (&hwif->attr, attr0, attr1, attr2, attr3, attr6); +if (!hwif->attr.num_ceqs) { +dev_err (hwdev->dev,"Ceq num cfg in fw is zero\n" ); +return -EFAULT ; + } + +if (!hwif->attr.num_irqs) { +dev_err (hwdev->dev, +"Irq num cfg in fw is zero, msix_flex_en %d\n" , + hwif->attr.msix_flex_en); +return -EFAULT ; + } +return 0 ; }
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c +1 -0
@@ -308,6 +308,7 @@ static void hinic3_func_uninit(struct pci_dev *pdev) {struct hinic3_pcidev *pci_adapter =pci_get_drvdata (pdev); +hinic3_flush_mgmt_workq (pci_adapter->hwdev);hinic3_detach_aux_devices (pci_adapter->hwdev);hinic3_free_hwdev (pci_adapter->hwdev); }
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + +#include "hinic3_eqs.h" +#include "hinic3_hwdev.h" +#include "hinic3_mbox.h" +#include "hinic3_mgmt.h" + +void hinic3_flush_mgmt_workq (struct hinic3_hwdev *hwdev) +{ +if (hwdev->aeqs) +flush_workqueue (hwdev->aeqs->workq); +} + +void hinic3_mgmt_msg_aeqe_handler (struct hinic3_hwdev *hwdev,u8 *header, +u8 size) +{ +if (MBOX_MSG_HEADER_GET (*(__force __le64 *)header,SOURCE ) == +MBOX_MSG_FROM_MBOX ) +hinic3_mbox_func_aeqe_handler (hwdev, header, size); +}
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.h +2 -0
@@ -9,5 +9,7 @@struct hinic3_hwdev ;void hinic3_flush_mgmt_workq (struct hinic3_hwdev *hwdev); +void hinic3_mgmt_msg_aeqe_handler (struct hinic3_hwdev *hwdev, +u8 *header,u8 size);#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 3/14 hinic3: HW common function initialization
In reply to Fan GongAdd initialization for data structures and functions(cmdq ceq mbox ceq) that interact with hardware.
--- .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 174 +++++++ .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 17 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 67 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 457 +++++++++++++++++- 4 files changed, 714 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +174 -0
@@ -3,6 +3,7 @@#include <linux/delay.h> +#include "hinic3_cmdq.h" #include "hinic3_hw_comm.h" #include "hinic3_hwdev.h" #include "hinic3_hwif.h"
@@ -61,3 +62,176 @@ int hinic3_func_reset(struct hinic3_hwdev *hwdev, u16 func_id, u64 reset_flag)return 0 ; } + +static int hinic3_comm_features_nego (struct hinic3_hwdev *hwdev,u8 opcode, +u64 *s_feature,u16 size) +{ +struct comm_cmd_feature_nego feature_nego = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + feature_nego.func_id =hinic3_global_func_id (hwdev); + feature_nego.opcode = opcode; +if (opcode ==MGMT_MSG_CMD_OP_SET ) +memcpy (feature_nego.s_feature, s_feature, (size *sizeof (u64))); + +mgmt_msg_params_init_default (&msg_params, &feature_nego, +sizeof (feature_nego)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_FEATURE_NEGO , &msg_params); +if (err || feature_nego.head.status) { +dev_err (hwdev->dev,"Failed to negotiate feature, err: %d, status: 0x%x\n" , + err, feature_nego.head.status); +return -EINVAL ; + } + +if (opcode ==MGMT_MSG_CMD_OP_GET ) +memcpy (s_feature, feature_nego.s_feature, (size *sizeof (u64))); + +return 0 ; +} + +int hinic3_get_comm_features (struct hinic3_hwdev *hwdev,u64 *s_feature, +u16 size) +{ +return hinic3_comm_features_nego (hwdev,MGMT_MSG_CMD_OP_GET , s_feature, + size); +} + +int hinic3_set_comm_features (struct hinic3_hwdev *hwdev,u64 *s_feature, +u16 size) +{ +return hinic3_comm_features_nego (hwdev,MGMT_MSG_CMD_OP_SET , s_feature, + size); +} + +int hinic3_get_global_attr (struct hinic3_hwdev *hwdev, +struct comm_global_attr *attr) +{ +struct comm_cmd_get_glb_attr get_attr = {}; +struct mgmt_msg_params msg_params = {}; +int err; + +mgmt_msg_params_init_default (&msg_params, &get_attr,sizeof (get_attr)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_GET_GLOBAL_ATTR , &msg_params); +if (err || get_attr.head.status) { +dev_err (hwdev->dev, +"Failed to get global attribute, err: %d, status: 0x%x\n" , + err, get_attr.head.status); +return -EIO ; + } + +memcpy (attr, &get_attr.attr,sizeof (*attr)); + +return 0 ; +} + +int hinic3_set_func_svc_used_state (struct hinic3_hwdev *hwdev,u16 svc_type, +u8 state) +{ +struct comm_cmd_set_func_svc_used_state used_state = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + used_state.func_id =hinic3_global_func_id (hwdev); + used_state.svc_type = svc_type; + used_state.used_state = state; + +mgmt_msg_params_init_default (&msg_params, &used_state, +sizeof (used_state)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_SET_FUNC_SVC_USED_STATE , + &msg_params); +if (err || used_state.head.status) { +dev_err (hwdev->dev, +"Failed to set func service used state, err: %d, status: 0x%x\n" , + err, used_state.head.status); +return -EIO ; + } + +return 0 ; +} + +int hinic3_set_dma_attr_tbl (struct hinic3_hwdev *hwdev,u8 entry_idx,u8 st, +u8 at,u8 ph,u8 no_snooping,u8 tph_en) +{ +struct comm_cmd_set_dma_attr dma_attr = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + dma_attr.func_id =hinic3_global_func_id (hwdev); + dma_attr.entry_idx = entry_idx; + dma_attr.st = st; + dma_attr.at = at; + dma_attr.ph = ph; + dma_attr.no_snooping = no_snooping; + dma_attr.tph_en = tph_en; + +mgmt_msg_params_init_default (&msg_params, &dma_attr,sizeof (dma_attr)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_SET_DMA_ATTR , &msg_params); +if (err || dma_attr.head.status) { +dev_err (hwdev->dev,"Failed to set dma attr, err: %d, status: 0x%x\n" , + err, dma_attr.head.status); +return -EIO ; + } + +return 0 ; +} + +int hinic3_set_wq_page_size (struct hinic3_hwdev *hwdev,u16 func_idx, +u32 page_size) +{ +struct comm_cmd_cfg_wq_page_size page_size_info = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + page_size_info.func_id = func_idx; + page_size_info.page_size =ilog2 (page_size /HINIC3_MIN_PAGE_SIZE ); + page_size_info.opcode =MGMT_MSG_CMD_OP_SET ; + +mgmt_msg_params_init_default (&msg_params, &page_size_info, +sizeof (page_size_info)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_CFG_PAGESIZE , &msg_params); +if (err || page_size_info.head.status) { +dev_err (hwdev->dev, +"Failed to set wq page size, err: %d, status: 0x%x\n" , + err, page_size_info.head.status); +return -EFAULT ; + } + +return 0 ; +} + +int hinic3_set_cmdq_depth (struct hinic3_hwdev *hwdev,u16 cmdq_depth) +{ +struct comm_cmd_set_root_ctxt root_ctxt = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + root_ctxt.func_id =hinic3_global_func_id (hwdev); + + root_ctxt.set_cmdq_depth =1 ; + root_ctxt.cmdq_depth =ilog2 (cmdq_depth); + +mgmt_msg_params_init_default (&msg_params, &root_ctxt, +sizeof (root_ctxt)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_SET_VAT , &msg_params); +if (err || root_ctxt.head.status) { +dev_err (hwdev->dev, +"Failed to set cmdq depth, err: %d, status: 0x%x\n" , + err, root_ctxt.head.status); +return -EFAULT ; + } + +return 0 ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h +17 -0
@@ -8,6 +8,8 @@struct hinic3_hwdev ; +#define HINIC3_WQ_PAGE_SIZE_ORDER 8 +struct hinic3_interrupt_info {u32 lli_set;u32 interrupt_coalesc_set;
@@ -23,4 +25,19 @@ int hinic3_set_interrupt_cfg_direct(struct hinic3_hwdev *hwdev, const struct hinic3_interrupt_info *info);int hinic3_func_reset (struct hinic3_hwdev *hwdev,u16 func_id,u64 reset_flag); +int hinic3_get_comm_features (struct hinic3_hwdev *hwdev,u64 *s_feature, +u16 size); +int hinic3_set_comm_features (struct hinic3_hwdev *hwdev,u64 *s_feature, +u16 size); +int hinic3_get_global_attr (struct hinic3_hwdev *hwdev, +struct comm_global_attr *attr); +int hinic3_set_func_svc_used_state (struct hinic3_hwdev *hwdev,u16 svc_type, +u8 state); +int hinic3_set_dma_attr_tbl (struct hinic3_hwdev *hwdev,u8 entry_idx,u8 st, +u8 at,u8 ph,u8 no_snooping,u8 tph_en); + +int hinic3_set_wq_page_size (struct hinic3_hwdev *hwdev,u16 func_idx, +u32 page_size); +int hinic3_set_cmdq_depth (struct hinic3_hwdev *hwdev,u16 cmdq_depth); +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +67 -0
85 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +456 -1
493 lines not on this page · raw message
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 4/14 hinic3: HW capability initialization
In reply to Fan GongUse mailbox to get device capability for initializing driver capability.
--- .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 66 +++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 1 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 42 ++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 6 ++ 4 files changed, 115 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c +66 -0
@@ -8,6 +8,67 @@#include "hinic3_hwif.h" #include "hinic3_mbox.h" +#define HINIC3_CFG_MAX_QP 256 + +static void hinic3_parse_pub_res_cap (struct hinic3_hwdev *hwdev, +struct hinic3_dev_cap *cap, +const struct cfg_cmd_dev_cap *dev_cap, +enum hinic3_func_type type) +{ + cap->port_id = dev_cap->port_id; + cap->supp_svcs_bitmap = dev_cap->svc_cap_en; +} + +static void hinic3_parse_l2nic_res_cap (struct hinic3_hwdev *hwdev, +struct hinic3_dev_cap *cap, +const struct cfg_cmd_dev_cap *dev_cap, +enum hinic3_func_type type) +{ +struct hinic3_nic_service_cap *nic_svc_cap = &cap->nic_svc_cap; + + nic_svc_cap->max_sqs =min (dev_cap->nic_max_sq_id +1 , +HINIC3_CFG_MAX_QP ); +} + +static void hinic3_parse_dev_cap (struct hinic3_hwdev *hwdev, +const struct cfg_cmd_dev_cap *dev_cap, +enum hinic3_func_type type) +{ +struct hinic3_dev_cap *cap = &hwdev->cfg_mgmt->cap; + +/* Public resource */ +hinic3_parse_pub_res_cap (hwdev, cap, dev_cap, type); + +/* L2 NIC resource */ +if (hinic3_support_nic (hwdev)) +hinic3_parse_l2nic_res_cap (hwdev, cap, dev_cap, type); +} + +static int get_cap_from_fw (struct hinic3_hwdev *hwdev, +enum hinic3_func_type type) +{ +struct mgmt_msg_params msg_params = {}; +struct cfg_cmd_dev_cap dev_cap = {}; +int err; + + dev_cap.func_id =hinic3_global_func_id (hwdev); + +mgmt_msg_params_init_default (&msg_params, &dev_cap,sizeof (dev_cap)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_CFGM , +CFG_CMD_GET_DEV_CAP , &msg_params); +if (err || dev_cap.head.status) { +dev_err (hwdev->dev, +"Failed to get capability from FW, err: %d, status: 0x%x\n" , + err, dev_cap.head.status); +return -EIO ; + } + +hinic3_parse_dev_cap (hwdev, &dev_cap, type); + +return 0 ; +} +static int hinic3_init_irq_info (struct hinic3_hwdev *hwdev) {struct hinic3_cfg_mgmt_info *cfg_mgmt = hwdev->cfg_mgmt;
@@ -153,6 +214,11 @@ void hinic3_free_irq(struct hinic3_hwdev *hwdev, u32 irq_id)mutex_unlock (&irq_info->irq_mutex); } +int hinic3_init_capability (struct hinic3_hwdev *hwdev) +{ +return get_cap_from_fw (hwdev,HINIC3_FUNC_TYPE_VF ); +} +bool hinic3_support_nic (struct hinic3_hwdev *hwdev) { return hwdev->cfg_mgmt->cap.supp_svcs_bitmap &
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h +1 -0
@@ -49,6 +49,7 @@ int hinic3_alloc_irqs(struct hinic3_hwdev *hwdev, u16 num, struct msix_entry *alloc_arr, u16 *act_num);void hinic3_free_irq (struct hinic3_hwdev *hwdev,u32 irq_id); +int hinic3_init_capability (struct hinic3_hwdev *hwdev);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);
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +42 -0
48 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +6 -0
@@ -479,6 +479,12 @@ int hinic3_init_hwdev(struct pci_dev *pdev) goto err_free_cfg_mgmt; } + err =hinic3_init_capability (hwdev); +if (err) { +dev_err (hwdev->dev,"Failed to init capability\n" ); + goto err_uninit_comm_ch; + } + err =hinic3_set_comm_features (hwdev, hwdev->features,COMM_MAX_FEATURE_QWORD );if (err) {
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 5/14 hinic3: Command Queue flush interfaces
In reply to Fan GongAdd the data structures and functions for command queue flushing.
--- .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 99 +++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 1 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 12 +++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 1 + .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 26 +++++ .../net/ethernet/huawei/hinic3/hinic3_hwif.h | 3 + 6 files changed, 142 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +99 -0
@@ -235,3 +235,102 @@ int hinic3_set_cmdq_depth(struct hinic3_hwdev *hwdev, u16 cmdq_depth)return 0 ; } + +#define HINIC3_WAIT_CMDQ_IDLE_TIMEOUT 5000 + +static enum hinic3_wait_return check_cmdq_stop_handler (void *priv_data) +{ +struct hinic3_hwdev *hwdev = priv_data; +enum hinic3_cmdq_type cmdq_type; +struct hinic3_cmdqs *cmdqs; + + cmdqs = hwdev->cmdqs; +for (cmdq_type =0 ; cmdq_type < cmdqs->cmdq_num; cmdq_type++) { +if (!hinic3_cmdq_idle (&cmdqs->cmdq[cmdq_type])) +return HINIC3_WAIT_PROCESS_WAITING ; + } + +return HINIC3_WAIT_PROCESS_CPL ; +} + +static int wait_cmdq_stop (struct hinic3_hwdev *hwdev) +{ +struct hinic3_cmdqs *cmdqs = hwdev->cmdqs; +enum hinic3_cmdq_type cmdq_type; +int err; + +if (!(cmdqs->status &HINIC3_CMDQ_ENABLE )) +return 0 ; + + cmdqs->status &= ~HINIC3_CMDQ_ENABLE ; + err =hinic3_wait_for_timeout (hwdev, check_cmdq_stop_handler, +HINIC3_WAIT_CMDQ_IDLE_TIMEOUT , +USEC_PER_MSEC ); + +if (err) + goto err_reenable_cmdq; + +return 0 ; + +err_reenable_cmdq: +for (cmdq_type =0 ; cmdq_type < cmdqs->cmdq_num; cmdq_type++) { +if (!hinic3_cmdq_idle (&cmdqs->cmdq[cmdq_type])) +dev_err (hwdev->dev,"Cmdq %d is busy\n" , cmdq_type); + } + cmdqs->status |=HINIC3_CMDQ_ENABLE ; + +return err; +} + +int hinic3_func_rx_tx_flush (struct hinic3_hwdev *hwdev) +{ +struct comm_cmd_clear_doorbell clear_db = {}; +struct comm_cmd_clear_resource clr_res = {}; +struct hinic3_hwif *hwif = hwdev->hwif; +struct mgmt_msg_params msg_params = {}; +int ret =0 ; +int err; + + err =wait_cmdq_stop (hwdev); +if (err) { +dev_warn (hwdev->dev,"CMDQ is still working, CMDQ timeout value is unreasonable\n" ); + ret = err; + } + +hinic3_disable_doorbell (hwif); + + clear_db.func_id = hwif->attr.func_global_idx; +mgmt_msg_params_init_default (&msg_params, &clear_db,sizeof (clear_db)); + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_FLUSH_DOORBELL , &msg_params); +if (err || clear_db.head.status) { +dev_warn (hwdev->dev,"Failed to flush doorbell, err: %d, status: 0x%x\n" , + err, clear_db.head.status); +if (err) + ret = err; +else + ret = -EFAULT ; + } + + clr_res.func_id = hwif->attr.func_global_idx; + msg_params.buf_in = &clr_res; + msg_params.in_size =sizeof (clr_res); + err =hinic3_send_mbox_to_mgmt_no_ack (hwdev,MGMT_MOD_COMM , +COMM_CMD_START_FLUSH , + &msg_params); +if (err) { +dev_warn (hwdev->dev,"Failed to notice flush message, err: %d\n" , + err); + ret = err; + } + +hinic3_enable_doorbell (hwif); + + err =hinic3_reinit_cmdq_ctxts (hwdev); +if (err) { +dev_warn (hwdev->dev,"Failed to reinit cmdq\n" ); + ret = err; + } + +return ret; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h +1 -0
@@ -39,5 +39,6 @@ int hinic3_set_dma_attr_tbl(struct hinic3_hwdev *hwdev, u8 entry_idx, u8 st,int hinic3_set_wq_page_size (struct hinic3_hwdev *hwdev,u16 func_idx,u32 page_size);int hinic3_set_cmdq_depth (struct hinic3_hwdev *hwdev,u16 cmdq_depth); +int hinic3_func_rx_tx_flush (struct hinic3_hwdev *hwdev);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +12 -0
@@ -245,6 +245,18 @@ struct comm_cmd_set_cmdq_ctxt {struct comm_cmdq_ctxt_info ctxt; }; +struct comm_cmd_clear_doorbell { +struct mgmt_msg_head head; +u16 func_id; +u16 rsvd1[3 ]; +}; + +struct comm_cmd_clear_resource { +struct mgmt_msg_head head; +u16 func_id; +u16 rsvd1[3 ]; +}; +/* Services supported by HW. HW uses these values when delivering events. * HW supports multiple services that are not yet supported by driver * (e.g. RoCE).
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +1 -0
@@ -514,6 +514,7 @@ void hinic3_free_hwdev(struct hinic3_hwdev *hwdev)u64 drv_features[COMM_MAX_FEATURE_QWORD ] = {};hinic3_set_comm_features (hwdev, drv_features,COMM_MAX_FEATURE_QWORD ); +hinic3_func_rx_tx_flush (hwdev);hinic3_uninit_comm_ch (hwdev);hinic3_free_cfg_mgmt (hwdev);destroy_workqueue (hwdev->workq);
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +26 -0
@@ -173,6 +173,32 @@ static enum hinic3_outbound_ctrl hinic3_get_outbound_ctrl_status(struct hinic3_hreturn HINIC3_AF5_GET (attr5,OUTBOUND_CTRL ); } +void hinic3_enable_doorbell (struct hinic3_hwif *hwif) +{ +u32 addr, attr4; + + addr =HINIC3_CSR_FUNC_ATTR4_ADDR ; + attr4 =hinic3_hwif_read_reg (hwif, addr); + + attr4 &= ~HINIC3_AF4_DOORBELL_CTRL_MASK ; + attr4 |=HINIC3_AF4_SET (ENABLE_DOORBELL ,DOORBELL_CTRL ); + +hinic3_hwif_write_reg (hwif, addr, attr4); +} + +void hinic3_disable_doorbell (struct hinic3_hwif *hwif) +{ +u32 addr, attr4; + + addr =HINIC3_CSR_FUNC_ATTR4_ADDR ; + attr4 =hinic3_hwif_read_reg (hwif, addr); + + attr4 &= ~HINIC3_AF4_DOORBELL_CTRL_MASK ; + attr4 |=HINIC3_AF4_SET (DISABLE_DOORBELL ,DOORBELL_CTRL ); + +hinic3_hwif_write_reg (hwif, addr, attr4); +} +static int db_area_idx_init (struct hinic3_hwif *hwif,u64 db_base_phy,u8 __iomem *db_base,u64 db_dwqe_len) {
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.h +3 -0
@@ -68,6 +68,9 @@ enum hinic3_msix_auto_mask {u32 hinic3_hwif_read_reg (struct hinic3_hwif *hwif,u32 reg);void hinic3_hwif_write_reg (struct hinic3_hwif *hwif,u32 reg,u32 val); +void hinic3_disable_doorbell (struct hinic3_hwif *hwif); +void hinic3_enable_doorbell (struct hinic3_hwif *hwif); +int hinic3_alloc_db_addr (struct hinic3_hwdev *hwdev,void __iomem **db_base,void __iomem **dwqe_base);void hinic3_free_db_addr (struct hinic3_hwdev *hwdev,const u8 __iomem *db_base);
Signature · 1 line
2.43.0
Re: [PATCH net-next v04 05/14] hinic3: Command Queue flush interfaces
On 05/09/2025 09:28, Fan Gong wrote:
[...]
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h struct comm_cmd_set_cmdq_ctxt { · line 258
Quoted 11 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +11
-0+struct comm_cmd_clear_doorbell { +struct mgmt_msg_head head; +u16 func_id; +u16 rsvd1[3 ]; +}; + +struct comm_cmd_clear_resource { +struct mgmt_msg_head head; +u16 func_id; +u16 rsvd1[3 ]; +};
I don't see any difference in these 2 structures. And the code implementation doesn't check types. Probably it's better to refactor things and try to implement it using common thing.
[...]
Quoted 15 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +15
-0+void hinic3_enable_doorbell (struct hinic3_hwif *hwif) +{ +u32 addr, attr4; + + addr =HINIC3_CSR_FUNC_ATTR4_ADDR ; + attr4 =hinic3_hwif_read_reg (hwif, addr); + + attr4 &= ~HINIC3_AF4_DOORBELL_CTRL_MASK ; + attr4 |=HINIC3_AF4_SET (ENABLE_DOORBELL ,DOORBELL_CTRL ); + +hinic3_hwif_write_reg (hwif, addr, attr4); +} + +void hinic3_disable_doorbell (struct hinic3_hwif *hwif) +{
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c static enum hinic3_outbound_ctrl hinic3_get_outbound_ctrl_status(struct hinic3_h · line 200
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +10
-0+u32 addr, attr4; + + addr =HINIC3_CSR_FUNC_ATTR4_ADDR ; + attr4 =hinic3_hwif_read_reg (hwif, addr); + + attr4 &= ~HINIC3_AF4_DOORBELL_CTRL_MASK ; + attr4 |=HINIC3_AF4_SET (DISABLE_DOORBELL ,DOORBELL_CTRL ); + +hinic3_hwif_write_reg (hwif, addr, attr4); +}
These 2 functions differ only in one bit. It might be better to implement it once and use extra boolean parameter?
Fan Gong
maintainerPATCH v4 6/14 hinic3: Nic_io initialization
In reply to Fan GongAdd nic_io initialization to enable NIC service, initialize function table and negotiate activation of NIC features.
--- .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 15 ++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 23 +++++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 2 + .../ethernet/huawei/hinic3/hinic3_nic_io.c | 51 +++++++++++++++++-- 4 files changed, 88 insertions(+), 3 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +15 -0
@@ -436,6 +436,18 @@ static void hinic3_uninit_comm_ch(struct hinic3_hwdev *hwdev)free_base_mgmt_channel (hwdev); } +static DEFINE_IDA (hinic3_adev_ida); + +static int hinic3_adev_idx_alloc (void ) +{ +return ida_alloc (&hinic3_adev_ida,GFP_KERNEL ); +} + +static void hinic3_adev_idx_free (int id) +{ +ida_free (&hinic3_adev_ida, id); +} +int hinic3_init_hwdev (struct pci_dev *pdev) {struct hinic3_pcidev *pci_adapter =pci_get_drvdata (pdev);
@@ -451,6 +463,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev) hwdev->pdev = pci_adapter->pdev; hwdev->dev = &pci_adapter->pdev->dev; hwdev->func_state =0 ; + hwdev->dev_id =hinic3_adev_idx_alloc ();spin_lock_init (&hwdev->channel_lock); err =hinic3_init_hwif (hwdev);
@@ -504,6 +517,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev)hinic3_free_hwif (hwdev); err_free_hwdev: pci_adapter->hwdev =NULL ; +hinic3_adev_idx_free (hwdev->dev_id);kfree (hwdev);return err;
@@ -519,6 +533,7 @@ void hinic3_free_hwdev(struct hinic3_hwdev *hwdev)hinic3_free_cfg_mgmt (hwdev);destroy_workqueue (hwdev->workq);hinic3_free_hwif (hwdev); +hinic3_adev_idx_free (hwdev->dev_id);kfree (hwdev); }
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +23 -0
@@ -39,6 +39,12 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,return 0 ; } +int hinic3_get_nic_feature_from_hw (struct hinic3_nic_dev *nic_dev) +{ +return hinic3_feature_nego (nic_dev->hwdev,MGMT_MSG_CMD_OP_GET , + &nic_dev->nic_io->feature_cap,1 ); +} +int hinic3_set_nic_feature_to_hw (struct hinic3_nic_dev *nic_dev) { return hinic3_feature_nego(nic_dev->hwdev, MGMT_MSG_CMD_OP_SET,
@@ -82,6 +88,23 @@ static int hinic3_set_function_table(struct hinic3_hwdev *hwdev, u32 cfg_bitmap,return 0 ; } +int hinic3_init_function_table (struct hinic3_nic_dev *nic_dev) +{ +struct hinic3_nic_io *nic_io = nic_dev->nic_io; +struct l2nic_func_tbl_cfg func_tbl_cfg = {}; +u32 cfg_bitmap; + + func_tbl_cfg.mtu =0x3FFF ;/* default, max mtu */ + func_tbl_cfg.rx_wqe_buf_size = nic_io->rx_buf_len; + + cfg_bitmap =BIT (L2NIC_FUNC_TBL_CFG_INIT ) | +BIT (L2NIC_FUNC_TBL_CFG_MTU ) | +BIT (L2NIC_FUNC_TBL_CFG_RX_BUF_SIZE ); + +return hinic3_set_function_table (nic_dev->hwdev, cfg_bitmap, + &func_tbl_cfg); +} +int hinic3_set_port_mtu (struct net_device *netdev,u16 new_mtu) {struct hinic3_nic_dev *nic_dev =netdev_priv (netdev);
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +2 -0
@@ -22,11 +22,13 @@ enum hinic3_nic_event_type { HINIC3_NIC_EVENT_LINK_UP = 1, }; +int hinic3_get_nic_feature_from_hw (struct hinic3_nic_dev *nic_dev);int hinic3_set_nic_feature_to_hw (struct hinic3_nic_dev *nic_dev);bool hinic3_test_support (struct hinic3_nic_dev *nic_dev,enum hinic3_nic_feature_cap feature_bits);void hinic3_update_nic_feature (struct hinic3_nic_dev *nic_dev,u64 feature_cap); +int hinic3_init_function_table (struct hinic3_nic_dev *nic_dev);int hinic3_set_port_mtu (struct net_device *netdev,u16 new_mtu); int hinic3_set_mac(struct hinic3_hwdev *hwdev, const u8 *mac_addr, u16 vlan_id,
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c +48 -3
59 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next v04 06/14] hinic3: Nic_io initialization
Quoted 2 lines · Fan Gong
Add
nic_ioinitialization to enable NIC service, initialize function table and negotiate activation of NIC features.
[...]
Quoted 16 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +12
-0+static DEFINE_IDA (hinic3_adev_ida); + +static int hinic3_adev_idx_alloc (void ) +{ +return ida_alloc (&hinic3_adev_ida,GFP_KERNEL ); +} + +static void hinic3_adev_idx_free (int id) +{ +ida_free (&hinic3_adev_ida, id); +} +int hinic3_init_hwdev (struct pci_dev *pdev) {struct hinic3_pcidev *pci_adapter =pci_get_drvdata (pdev);
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c int hinic3_init_hwdev(struct pci_dev *pdev) · line 466
Quoted 4 lines
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +1
-0@@ -451,6 +463,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev) hwdev->pdev = pci_adapter->pdev; hwdev->dev = &pci_adapter->pdev->dev; hwdev->func_state =0 ; + hwdev->dev_id =hinic3_adev_idx_alloc ();
Why do you need dev_id? It's not used anywhere in the patchset. The commit doesn't explain it neither...
Fan Gong
maintainerRe: [PATCH net-next v04 06/14] hinic3: Nic_io initialization
Quoted 11 lines · Vadim Fedorenko
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c int hinic3_init_hwdev(struct pci_dev *pdev) · line 466
Quoted 8 lines
int hinic3_init_hwdev(struct pci_dev *pdev) { struct hinic3_pcidev *pci_adapter = pci_get_drvdata(pdev);drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +1
-0@@ -451,6 +463,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev) hwdev->pdev = pci_adapter->pdev; hwdev->dev = &pci_adapter->pdev->dev; hwdev->func_state =0 ; + hwdev->dev_id =hinic3_adev_idx_alloc ();Why do you need
dev_id? It's not used anywhere in the patchset. The commit doesn't explain it neither...
Thanks for your commit.
This is the code to refine the first patchset of hinic3 driver. In hinic3_lld.c, we use "hadev->adev.id = hwdev->dev_id;" and dev_id is temporarily set to default value 0. In this patchset we complete hwdev's initialization.
I will update this commit message to explain this modification.
Fan Gong
maintainerPATCH v4 7/14 hinic3: Queue pair endianness improvements
In reply to Fan GongExplicitly use little-endian & big-endian structs to support big endian hosts.
--- .../ethernet/huawei/hinic3/hinic3_nic_io.h | 15 ++-- .../net/ethernet/huawei/hinic3/hinic3_rx.c | 10 +-- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 24 +++--- .../net/ethernet/huawei/hinic3/hinic3_tx.c | 81 ++++++++++--------- .../net/ethernet/huawei/hinic3/hinic3_tx.h | 18 ++--- 5 files changed, 79 insertions(+), 69 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h +8 -7
@@ -75,8 +75,8 @@ static inline u16 hinic3_get_sq_hw_ci(const struct hinic3_io_queue *sq)#define DB_CFLAG_DP_RQ 1struct hinic3_nic_db { -u32 db_info; -u32 pi_hi; +__le32 db_info; +__le32 pi_hi; }; static inline void hinic3_write_db(struct hinic3_io_queue *queue, int cos,
@@ -84,11 +84,12 @@ static inline void hinic3_write_db(struct hinic3_io_queue *queue, int cos, {struct hinic3_nic_db db; - db.db_info =DB_INFO_SET (DB_SRC_TYPE ,TYPE ) | -DB_INFO_SET (cflag,CFLAG ) | -DB_INFO_SET (cos,COS ) | -DB_INFO_SET (queue->q_id,QID ); - db.pi_hi =DB_PI_HIGH (pi); + db.db_info = +cpu_to_le32 (DB_INFO_SET (DB_SRC_TYPE ,TYPE ) | +DB_INFO_SET (cflag,CFLAG ) | +DB_INFO_SET (cos,COS ) | +DB_INFO_SET (queue->q_id,QID )); + db.pi_hi =cpu_to_le32 (DB_PI_HIGH (pi));writeq (*((u64 *)&db),DB_ADDR (queue, pi)); }
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +5 -5
@@ -66,8 +66,8 @@ static void rq_wqe_buf_set(struct hinic3_io_queue *rq, uint32_t wqe_idx,struct hinic3_rq_wqe *rq_wqe; rq_wqe =get_q_element (&rq->wq.qpages, wqe_idx,NULL ); - rq_wqe->buf_hi_addr =upper_32_bits (dma_addr); - rq_wqe->buf_lo_addr =lower_32_bits (dma_addr); + rq_wqe->buf_hi_addr =cpu_to_le32 (upper_32_bits (dma_addr)); + rq_wqe->buf_lo_addr =cpu_to_le32 (lower_32_bits (dma_addr)); }static u32 hinic3_rx_fill_buffers (struct hinic3_rxq *rxq)
@@ -279,7 +279,7 @@ static int recv_one_pkt(struct hinic3_rxq *rxq, struct hinic3_rq_cqe *rx_cqe,if (skb_is_nonlinear (skb))hinic3_pull_tail (skb); - offload_type = rx_cqe->offload_type; + offload_type =le32_to_cpu (rx_cqe->offload_type);hinic3_rx_csum (rxq, offload_type, status, skb); num_lro =RQ_CQE_STATUS_GET (status,NUM_LRO );
@@ -311,14 +311,14 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)while (likely (nr_pkts < budget)) { sw_ci = rxq->cons_idx & rxq->q_mask; rx_cqe = rxq->cqe_arr + sw_ci; - status = rx_cqe->status; + status =le32_to_cpu (rx_cqe->status);if (!RQ_CQE_STATUS_GET (status,RXDONE ))break ;/* make sure we read rx_done before packet length */ rmb (); - vlan_len = rx_cqe->vlan_len; + vlan_len =le32_to_cpu (rx_cqe->vlan_len); pkt_len =RQ_CQE_SGE_GET (vlan_len,LEN );if (recv_one_pkt (rxq, rx_cqe, pkt_len, vlan_len, status))break ;
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h +12 -12
@@ -27,21 +27,21 @@/* RX Completion information that is provided by HW for a specific RX WQE */ struct hinic3_rq_cqe { -u32 status; -u32 vlan_len; -u32 offload_type; -u32 rsvd3; -u32 rsvd4; -u32 rsvd5; -u32 rsvd6; -u32 pkt_info; +__le32 status; +__le32 vlan_len; +__le32 offload_type; +__le32 rsvd3; +__le32 rsvd4; +__le32 rsvd5; +__le32 rsvd6; +__le32 pkt_info; };struct hinic3_rq_wqe { -u32 buf_hi_addr; -u32 buf_lo_addr; -u32 cqe_hi_addr; -u32 cqe_lo_addr; +__le32 buf_hi_addr; +__le32 buf_lo_addr; +__le32 cqe_hi_addr; +__le32 cqe_lo_addr; };struct hinic3_rx_info {
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +45 -36
181 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_tx.h +9 -9
@@ -58,7 +58,7 @@ enum hinic3_tx_offload_type {#define SQ_CTRL_QUEUE_INFO_SET (val, member) \ FIELD_PREP(SQ_CTRL_QUEUE_INFO_##member##_MASK, val)#define SQ_CTRL_QUEUE_INFO_GET (val, member) \ - FIELD_GET(SQ_CTRL_QUEUE_INFO_##member##_MASK, val) + FIELD_GET(SQ_CTRL_QUEUE_INFO_##member##_MASK, le32_to_cpu(val))#define SQ_CTRL_MAX_PLDOFF 221
@@ -77,17 +77,17 @@ enum hinic3_tx_offload_type { FIELD_PREP(SQ_TASK_INFO3_##member##_MASK, val)struct hinic3_sq_wqe_desc { -u32 ctrl_len; -u32 queue_info; -u32 hi_addr; -u32 lo_addr; +__le32 ctrl_len; +__le32 queue_info; +__le32 hi_addr; +__le32 lo_addr; };struct hinic3_sq_task { -u32 pkt_info0; -u32 ip_identify; -u32 rsvd; -u32 vlan_offload; +__le32 pkt_info0; +__le32 ip_identify; +__le32 rsvd; +__le32 vlan_offload; };struct hinic3_sq_wqe_combo {
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 8/14 hinic3: Queue pair resource initialization
In reply to Fan GongAdd Tx & Rx queue resources and functions for packet transmission and reception.
--- .../huawei/hinic3/hinic3_netdev_ops.c | 251 +++++++++++++++++- .../ethernet/huawei/hinic3/hinic3_nic_io.c | 240 +++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_nic_io.h | 21 ++ .../net/ethernet/huawei/hinic3/hinic3_rx.c | 152 ++++++++++- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 12 + .../net/ethernet/huawei/hinic3/hinic3_tx.c | 69 +++++ .../net/ethernet/huawei/hinic3/hinic3_tx.h | 10 + 7 files changed, 748 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +247 -4
@@ -11,16 +11,259 @@#include "hinic3_rx.h" #include "hinic3_tx.h" +/* try to modify the number of irq to the target number, +* and return the actual number of irq. +*/ +static u16 hinic3_qp_irq_change (struct net_device *netdev, +u16 dst_num_qp_irq) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct msix_entry *qps_msix_entries; +u16 resp_irq_num, irq_num_gap, i; +u16 idx; +int err; + + qps_msix_entries = nic_dev->qps_msix_entries; +if (dst_num_qp_irq > nic_dev->num_qp_irq) { + irq_num_gap = dst_num_qp_irq - nic_dev->num_qp_irq; + err =hinic3_alloc_irqs (nic_dev->hwdev, irq_num_gap, + &qps_msix_entries[nic_dev->num_qp_irq], + &resp_irq_num); +if (err) { +netdev_err (netdev,"Failed to alloc irqs\n" ); +return nic_dev->num_qp_irq; + } + + nic_dev->num_qp_irq += resp_irq_num; + }else if (dst_num_qp_irq < nic_dev->num_qp_irq) { + irq_num_gap = nic_dev->num_qp_irq - dst_num_qp_irq; +for (i =0 ; i < irq_num_gap; i++) { + idx = (nic_dev->num_qp_irq - i) -1 ; +hinic3_free_irq (nic_dev->hwdev, + qps_msix_entries[idx].vector); + qps_msix_entries[idx].vector =0 ; + qps_msix_entries[idx].entry =0 ; + } + nic_dev->num_qp_irq = dst_num_qp_irq; + } + +return nic_dev->num_qp_irq; +} + +static void hinic3_config_num_qps (struct net_device *netdev, +struct hinic3_dyna_txrxq_params *q_params) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u16 alloc_num_irq, cur_num_irq; +u16 dst_num_irq; + +if (!test_bit (HINIC3_RSS_ENABLE , &nic_dev->flags)) + q_params->num_qps =1 ; + +if (nic_dev->num_qp_irq >= q_params->num_qps) + goto out; + + cur_num_irq = nic_dev->num_qp_irq; + + alloc_num_irq =hinic3_qp_irq_change (netdev, q_params->num_qps); +if (alloc_num_irq < q_params->num_qps) { + q_params->num_qps = alloc_num_irq; +netdev_warn (netdev,"Can not get enough irqs, adjust num_qps to %u\n" , + q_params->num_qps); + +/* The current irq may be in use, we must keep it */ + dst_num_irq =max_t (u16, cur_num_irq, q_params->num_qps); +hinic3_qp_irq_change (netdev, dst_num_irq); + } + +out: +netdev_dbg (netdev,"Finally num_qps: %u\n" , q_params->num_qps); +} + +static int hinic3_setup_num_qps (struct net_device *netdev) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); + + nic_dev->num_qp_irq =0 ; + + nic_dev->qps_msix_entries =kcalloc (nic_dev->max_qps, +sizeof (struct msix_entry ), +GFP_KERNEL ); +if (!nic_dev->qps_msix_entries) +return -ENOMEM ; + +hinic3_config_num_qps (netdev, &nic_dev->q_params); + +return 0 ; +} + +static void hinic3_destroy_num_qps (struct net_device *netdev) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u16 i; + +for (i =0 ; i < nic_dev->num_qp_irq; i++) +hinic3_free_irq (nic_dev->hwdev, + nic_dev->qps_msix_entries[i].vector); + +kfree (nic_dev->qps_msix_entries); +} + +static int hinic3_alloc_txrxq_resources (struct net_device *netdev, +struct hinic3_dyna_txrxq_params *q_params) +{ +int err; + + q_params->txqs_res =kcalloc (q_params->num_qps, +sizeof (*q_params->txqs_res),GFP_KERNEL ); +if (!q_params->txqs_res) +return -ENOMEM ; + + q_params->rxqs_res =kcalloc (q_params->num_qps, +sizeof (*q_params->rxqs_res),GFP_KERNEL ); +if (!q_params->rxqs_res) { + err = -ENOMEM ; + goto err_free_txqs_res_arr; + } + + q_params->irq_cfg =kcalloc (q_params->num_qps, +sizeof (*q_params->irq_cfg),GFP_KERNEL ); +if (!q_params->irq_cfg) { + err = -ENOMEM ; + goto err_free_rxqs_res_arr; + } + + err =hinic3_alloc_txqs_res (netdev, q_params->num_qps, + q_params->sq_depth, q_params->txqs_res); +if (err) { +netdev_err (netdev,"Failed to alloc txqs resource\n" ); + goto err_free_irq_cfg; + } + + err =hinic3_alloc_rxqs_res (netdev, q_params->num_qps, + q_params->rq_depth, q_params->rxqs_res); +if (err) { +netdev_err (netdev,"Failed to alloc rxqs resource\n" ); + goto err_free_txqs_res; + } + +return 0 ; + +err_free_txqs_res: +hinic3_free_txqs_res (netdev, q_params->num_qps, q_params->sq_depth, + q_params->txqs_res); +err_free_irq_cfg: +kfree (q_params->irq_cfg); + q_params->irq_cfg =NULL ; +err_free_rxqs_res_arr: +kfree (q_params->rxqs_res); + q_params->rxqs_res =NULL ; +err_free_txqs_res_arr: +kfree (q_params->txqs_res); + q_params->txqs_res =NULL ; + +return err; +} + +static void hinic3_free_txrxq_resources (struct net_device *netdev, +struct hinic3_dyna_txrxq_params *q_params) +{ +hinic3_free_rxqs_res (netdev, q_params->num_qps, q_params->rq_depth, + q_params->rxqs_res); +hinic3_free_txqs_res (netdev, q_params->num_qps, q_params->sq_depth, + q_params->txqs_res); + +kfree (q_params->irq_cfg); + q_params->irq_cfg =NULL ; + +kfree (q_params->rxqs_res); + q_params->rxqs_res =NULL ; + +kfree (q_params->txqs_res); + q_params->txqs_res =NULL ; +} + +static int hinic3_alloc_channel_resources (struct net_device *netdev, +struct hinic3_dyna_qp_params *qp_params, +struct hinic3_dyna_txrxq_params *trxq_params) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +int err; + + qp_params->num_qps = trxq_params->num_qps; + qp_params->sq_depth = trxq_params->sq_depth; + qp_params->rq_depth = trxq_params->rq_depth; + + err =hinic3_alloc_qps (nic_dev, qp_params); +if (err) { +netdev_err (netdev,"Failed to alloc qps\n" ); +return err; + } + + err =hinic3_alloc_txrxq_resources (netdev, trxq_params); +if (err) { +netdev_err (netdev,"Failed to alloc txrxq resources\n" ); +hinic3_free_qps (nic_dev, qp_params); +return err; + } + +return 0 ; +} + +static void hinic3_free_channel_resources (struct net_device *netdev, +struct hinic3_dyna_qp_params *qp_params, +struct hinic3_dyna_txrxq_params *trxq_params) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); + +hinic3_free_txrxq_resources (netdev, trxq_params); +hinic3_free_qps (nic_dev, qp_params); +} +static int hinic3_open (struct net_device *netdev) { -/* Completed by later submission due to LoC limit. */ -return -EFAULT ; +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_dyna_qp_params qp_params; +int err; + + err =hinic3_init_nicio_res (nic_dev); +if (err) { +netdev_err (netdev,"Failed to init nicio resources\n" ); +return err; + } + + err =hinic3_setup_num_qps (netdev); +if (err) { +netdev_err (netdev,"Failed to setup num_qps\n" ); + goto err_free_nicio_res; + } + + err =hinic3_alloc_channel_resources (netdev, &qp_params, + &nic_dev->q_params); +if (err) + goto err_destroy_num_qps; + +hinic3_init_qps (nic_dev, &qp_params); + +return 0 ; + +err_destroy_num_qps: +hinic3_destroy_num_qps (netdev); +err_free_nicio_res: +hinic3_free_nicio_res (nic_dev); + +return err; }static int hinic3_close (struct net_device *netdev) { -/* Completed by later submission due to LoC limit. */ -return -EFAULT ; +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_dyna_qp_params qp_params; + +hinic3_uninit_qps (nic_dev, &qp_params); +hinic3_free_channel_resources (netdev, &qp_params, &nic_dev->q_params); + +return 0 ; }static int hinic3_change_mtu (struct net_device *netdev,int new_mtu)
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c +240 -0
249 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h +21 -0
@@ -94,6 +94,15 @@ static inline void hinic3_write_db(struct hinic3_io_queue *queue, int cos,writeq (*((u64 *)&db),DB_ADDR (queue, pi)); } +struct hinic3_dyna_qp_params { +u16 num_qps; +u32 sq_depth; +u32 rq_depth; + +struct hinic3_io_queue *sqs; +struct hinic3_io_queue *rqs; +}; +struct hinic3_nic_io {struct hinic3_io_queue *sq;struct hinic3_io_queue *rq;
@@ -118,4 +127,16 @@ struct hinic3_nic_io {int hinic3_init_nic_io (struct hinic3_nic_dev *nic_dev);void hinic3_free_nic_io (struct hinic3_nic_dev *nic_dev); +int hinic3_init_nicio_res (struct hinic3_nic_dev *nic_dev); +void hinic3_free_nicio_res (struct hinic3_nic_dev *nic_dev); + +int hinic3_alloc_qps (struct hinic3_nic_dev *nic_dev, +struct hinic3_dyna_qp_params *qp_params); +void hinic3_free_qps (struct hinic3_nic_dev *nic_dev, +struct hinic3_dyna_qp_params *qp_params); +void hinic3_init_qps (struct hinic3_nic_dev *nic_dev, +struct hinic3_dyna_qp_params *qp_params); +void hinic3_uninit_qps (struct hinic3_nic_dev *nic_dev, +struct hinic3_dyna_qp_params *qp_params); +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +149 -3
180 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h +12 -0
@@ -82,9 +82,21 @@ struct hinic3_rxq { dma_addr_t cqe_start_paddr; }____cacheline_aligned ; +struct hinic3_dyna_rxq_res { +u16 next_to_alloc; +struct hinic3_rx_info *rx_info; +dma_addr_t cqe_start_paddr; +void *cqe_start_vaddr; +struct page_pool *page_pool; +}; +int hinic3_alloc_rxqs (struct net_device *netdev);void hinic3_free_rxqs (struct net_device *netdev); +int hinic3_alloc_rxqs_res (struct net_device *netdev,u16 num_rq, +u32 rq_depth,struct hinic3_dyna_rxq_res *rxqs_res); +void hinic3_free_rxqs_res (struct net_device *netdev,u16 num_rq, +u32 rq_depth,struct hinic3_dyna_rxq_res *rxqs_res);int hinic3_rx_poll (struct hinic3_rxq *rxq,int budget);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +69 -0
81 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_tx.h +10 -0
@@ -125,9 +125,19 @@ struct hinic3_txq {struct hinic3_io_queue *sq; }____cacheline_aligned ; +struct hinic3_dyna_txq_res { +struct hinic3_tx_info *tx_info; +struct hinic3_dma_info *bds; +}; +int hinic3_alloc_txqs (struct net_device *netdev);void hinic3_free_txqs (struct net_device *netdev); +int hinic3_alloc_txqs_res (struct net_device *netdev,u16 num_sq, +u32 sq_depth,struct hinic3_dyna_txq_res *txqs_res); +void hinic3_free_txqs_res (struct net_device *netdev,u16 num_sq, +u32 sq_depth,struct hinic3_dyna_txq_res *txqs_res); +netdev_tx_t hinic3_xmit_frame (struct sk_buff *skb,struct net_device *netdev);bool hinic3_tx_poll (struct hinic3_txq *txq,int budget);void hinic3_flush_txqs (struct net_device *netdev);
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 9/14 hinic3: Queue pair context initialization
In reply to Fan GongInitialize queue pair context of hardware interaction.
--- .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 88 +++ .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 3 + .../huawei/hinic3/hinic3_mgmt_interface.h | 20 + .../huawei/hinic3/hinic3_netdev_ops.c | 42 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 35 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 12 + .../ethernet/huawei/hinic3/hinic3_nic_io.c | 579 ++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_nic_io.h | 3 + 8 files changed, 782 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +88 -0
@@ -334,3 +334,91 @@ int hinic3_func_rx_tx_flush(struct hinic3_hwdev *hwdev)return ret; } + +static int get_hw_rx_buf_size_idx (int rx_buf_sz,u16 *buf_sz_idx) +{ +/* Supported RX buffer sizes in bytes. Configured by array index. */ +static const int supported_sizes[16 ] = { + [0 ] =32 , [1 ] =64 , [2 ] =96 , [3 ] =128 , + [4 ] =192 , [5 ] =256 , [6 ] =384 , [7 ] =512 , + [8 ] =768 , [9 ] =1024 , [10 ] =1536 , [11 ] =2048 , + [12 ] =3072 , [13 ] =4096 , [14 ] =8192 , [15 ] =16384 , + }; +u16 idx; + +/* Scan from biggest to smallest. Choose supported size that is equal or +* smaller. For smaller value HW will under-utilize posted buffers. For +* bigger value HW may overrun posted buffers. +*/ + idx =ARRAY_SIZE (supported_sizes); +while (idx >0 ) { + idx--; +if (supported_sizes[idx] <= rx_buf_sz) { + *buf_sz_idx = idx; +return 0 ; + } + } + +return -EINVAL ; +} + +int hinic3_set_root_ctxt (struct hinic3_hwdev *hwdev,u32 rq_depth,u32 sq_depth, +int rx_buf_sz) +{ +struct comm_cmd_set_root_ctxt root_ctxt = {}; +struct mgmt_msg_params msg_params = {}; +u16 buf_sz_idx; +int err; + + err =get_hw_rx_buf_size_idx (rx_buf_sz, &buf_sz_idx); +if (err) +return err; + + root_ctxt.func_id =hinic3_global_func_id (hwdev); + + root_ctxt.set_cmdq_depth =0 ; + root_ctxt.cmdq_depth =0 ; + + root_ctxt.lro_en =1 ; + + root_ctxt.rq_depth =ilog2 (rq_depth); + root_ctxt.rx_buf_sz = buf_sz_idx; + root_ctxt.sq_depth =ilog2 (sq_depth); + +mgmt_msg_params_init_default (&msg_params, &root_ctxt, +sizeof (root_ctxt)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_SET_VAT , &msg_params); +if (err || root_ctxt.head.status) { +dev_err (hwdev->dev, +"Failed to set root context, err: %d, status: 0x%x\n" , + err, root_ctxt.head.status); +return -EFAULT ; + } + +return 0 ; +} + +int hinic3_clean_root_ctxt (struct hinic3_hwdev *hwdev) +{ +struct comm_cmd_set_root_ctxt root_ctxt = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + root_ctxt.func_id =hinic3_global_func_id (hwdev); + +mgmt_msg_params_init_default (&msg_params, &root_ctxt, +sizeof (root_ctxt)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_SET_VAT , &msg_params); +if (err || root_ctxt.head.status) { +dev_err (hwdev->dev, +"Failed to set root context, err: %d, status: 0x%x\n" , + err, root_ctxt.head.status); +return -EFAULT ; + } + +return 0 ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h +3 -0
@@ -40,5 +40,8 @@ int hinic3_set_wq_page_size(struct hinic3_hwdev *hwdev, u16 func_idx, u32 page_size);int hinic3_set_cmdq_depth (struct hinic3_hwdev *hwdev,u16 cmdq_depth);int hinic3_func_rx_tx_flush (struct hinic3_hwdev *hwdev); +int hinic3_set_root_ctxt (struct hinic3_hwdev *hwdev,u32 rq_depth,u32 sq_depth, +int rx_buf_sz); +int hinic3_clean_root_ctxt (struct hinic3_hwdev *hwdev);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +20 -0
@@ -56,6 +56,19 @@ struct l2nic_cmd_update_mac {u8 new_mac[ETH_ALEN ]; }; +struct l2nic_cmd_set_ci_attr { +struct mgmt_msg_head msg_head; +u16 func_idx; +u8 dma_attr_off; +u8 pending_limit; +u8 coalescing_time; +u8 intr_en; +u16 intr_idx; +u32 l2nic_sqn; +u32 rsvd; +u64 ci_addr; +}; +struct l2nic_cmd_force_pkt_drop {struct mgmt_msg_head msg_head;u8 port;
@@ -82,6 +95,13 @@ enum l2nic_cmd { L2NIC_CMD_MAX = 256, }; +/* NIC CMDQ MODE */ +enum l2nic_ucode_cmd { +L2NIC_UCODE_CMD_MODIFY_QUEUE_CTX =0 , +L2NIC_UCODE_CMD_CLEAN_QUEUE_CTX =1 , +L2NIC_UCODE_CMD_SET_RSS_INDIR_TBL =4 , +}; +enum hinic3_nic_feature_cap {HINIC3_NIC_F_CSUM =BIT (0 ),HINIC3_NIC_F_SCTP_CRC =BIT (1 ),
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +42 -0
62 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +35 -0
@@ -229,6 +229,41 @@ int hinic3_update_mac(struct hinic3_hwdev *hwdev, const u8 *old_mac, err, mac_info.msg_head.status);return -EIO ; } + +return 0 ; +} + +int hinic3_set_ci_table (struct hinic3_hwdev *hwdev,struct hinic3_sq_attr *attr) +{ +struct l2nic_cmd_set_ci_attr cons_idx_attr = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + cons_idx_attr.func_idx =hinic3_global_func_id (hwdev); + cons_idx_attr.dma_attr_off = attr->dma_attr_off; + cons_idx_attr.pending_limit = attr->pending_limit; + cons_idx_attr.coalescing_time = attr->coalescing_time; + +if (attr->intr_en) { + cons_idx_attr.intr_en = attr->intr_en; + cons_idx_attr.intr_idx = attr->intr_idx; + } + + cons_idx_attr.l2nic_sqn = attr->l2nic_sqn; + cons_idx_attr.ci_addr = attr->ci_dma_base; + +mgmt_msg_params_init_default (&msg_params, &cons_idx_attr, +sizeof (cons_idx_attr)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_L2NIC , +L2NIC_CMD_SET_SQ_CI_ATTR , &msg_params); +if (err || cons_idx_attr.msg_head.status) { +dev_err (hwdev->dev, +"Failed to set ci attribute table, err: %d, status: 0x%x\n" , + err, cons_idx_attr.msg_head.status); +return -EFAULT ; + } +return 0 ; }
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +12 -0
@@ -22,6 +22,16 @@ enum hinic3_nic_event_type { HINIC3_NIC_EVENT_LINK_UP = 1, }; +struct hinic3_sq_attr { +u8 dma_attr_off; +u8 pending_limit; +u8 coalescing_time; +u8 intr_en; +u16 intr_idx; +u32 l2nic_sqn; +u64 ci_dma_base; +}; +int hinic3_get_nic_feature_from_hw (struct hinic3_nic_dev *nic_dev);int hinic3_set_nic_feature_to_hw (struct hinic3_nic_dev *nic_dev); bool hinic3_test_support(struct hinic3_nic_dev *nic_dev,
@@ -38,6 +48,8 @@ int hinic3_del_mac(struct hinic3_hwdev *hwdev, const u8 *mac_addr, u16 vlan_id,int hinic3_update_mac (struct hinic3_hwdev *hwdev,const u8 *old_mac,u8 *new_mac,u16 vlan_id,u16 func_id); +int hinic3_set_ci_table (struct hinic3_hwdev *hwdev, +struct hinic3_sq_attr *attr);int hinic3_force_drop_tx_pkt (struct hinic3_hwdev *hwdev);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c +579 -0
600 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h +3 -0
@@ -139,4 +139,7 @@ void hinic3_init_qps(struct hinic3_nic_dev *nic_dev,void hinic3_uninit_qps (struct hinic3_nic_dev *nic_dev,struct hinic3_dyna_qp_params *qp_params); +int hinic3_init_qp_ctxts (struct hinic3_nic_dev *nic_dev); +void hinic3_free_qp_ctxts (struct hinic3_nic_dev *nic_dev); +#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 10/14 hinic3: Tx & Rx configuration
In reply to Fan GongConfigure Tx & Rx queue common attributes.
--- .../huawei/hinic3/hinic3_mgmt_interface.h | 15 +++++ .../huawei/hinic3/hinic3_netdev_ops.c | 56 +++++++++++++++- .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 25 ++++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 2 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 64 +++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rx.h | 2 + .../net/ethernet/huawei/hinic3/hinic3_tx.c | 32 ++++++++++ .../net/ethernet/huawei/hinic3/hinic3_tx.h | 2 + 8 files changed, 197 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +15 -0
@@ -75,6 +75,21 @@ struct l2nic_cmd_force_pkt_drop {u8 rsvd1[3 ]; }; +struct l2nic_cmd_set_dcb_state { +struct mgmt_msg_head head; +u16 func_id; +/* 0 - get dcb state, 1 - set dcb state */ +u8 op_code; +/* 0 - disable, 1 - enable dcb */ +u8 state; +/* 0 - disable, 1 - enable dcb */ +u8 port_state; +u8 rsvd[7 ]; +}; + +/* IEEE 802.1Qaz std */ +#define L2NIC_DCB_COS_MAX 0x8 +/* Commands between NIC to fw */ enum l2nic_cmd {/* FUNC CFG */
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +55 -1
82 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +25 -0
@@ -289,3 +289,28 @@ int hinic3_force_drop_tx_pkt(struct hinic3_hwdev *hwdev)return pkt_drop.msg_head.status; } + +int hinic3_sync_dcb_state (struct hinic3_hwdev *hwdev,u8 op_code,u8 state) +{ +struct l2nic_cmd_set_dcb_state dcb_state = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + dcb_state.op_code = op_code; + dcb_state.state = state; + dcb_state.func_id =hinic3_global_func_id (hwdev); + +mgmt_msg_params_init_default (&msg_params, &dcb_state, +sizeof (dcb_state)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_L2NIC , +L2NIC_CMD_QOS_DCB_STATE , &msg_params); +if (err || dcb_state.head.status) { +dev_err (hwdev->dev, +"Failed to set dcb state, err: %d, status: 0x%x\n" , + err, dcb_state.head.status); +return -EFAULT ; + } + +return 0 ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +2 -0
@@ -52,4 +52,6 @@ int hinic3_set_ci_table(struct hinic3_hwdev *hwdev, struct hinic3_sq_attr *attr);int hinic3_force_drop_tx_pkt (struct hinic3_hwdev *hwdev); +int hinic3_sync_dcb_state (struct hinic3_hwdev *hwdev,u8 op_code,u8 state); +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +64 -0
76 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h +2 -0
@@ -97,6 +97,8 @@ int hinic3_alloc_rxqs_res(struct net_device *netdev, u16 num_rq, u32 rq_depth, struct hinic3_dyna_rxq_res *rxqs_res);void hinic3_free_rxqs_res (struct net_device *netdev,u16 num_rq,u32 rq_depth,struct hinic3_dyna_rxq_res *rxqs_res); +int hinic3_configure_rxqs (struct net_device *netdev,u16 num_rq, +u32 rq_depth,struct hinic3_dyna_rxq_res *rxqs_res);int hinic3_rx_poll (struct hinic3_rxq *rxq,int budget);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +32 -0
@@ -702,6 +702,38 @@ void hinic3_free_txqs_res(struct net_device *netdev, u16 num_sq, } } +int hinic3_configure_txqs (struct net_device *netdev,u16 num_sq, +u32 sq_depth,struct hinic3_dyna_txq_res *txqs_res) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_dyna_txq_res *tqres; +struct hinic3_txq *txq; +u16 q_id; +u32 idx; + +for (q_id =0 ; q_id < num_sq; q_id++) { + txq = &nic_dev->txqs[q_id]; + tqres = &txqs_res[q_id]; + + txq->q_depth = sq_depth; + txq->q_mask = sq_depth -1 ; + + txq->tx_stop_thrs =min (HINIC3_DEFAULT_STOP_THRS , + sq_depth /20 ); + txq->tx_start_thrs =min (HINIC3_DEFAULT_START_THRS , + sq_depth /10 ); + + txq->tx_info = tqres->tx_info; +for (idx =0 ; idx < sq_depth; idx++) + txq->tx_info[idx].dma_info = + &tqres->bds[idx *HINIC3_BDS_PER_SQ_WQEBB ]; + + txq->sq = &nic_dev->nic_io->sq[q_id]; + } + +return 0 ; +} +bool hinic3_tx_poll (struct hinic3_txq *txq,int budget) {struct net_device *netdev = txq->netdev;
drivers/net/ethernet/huawei/hinic3/hinic3_tx.h +2 -0
@@ -137,6 +137,8 @@ int hinic3_alloc_txqs_res(struct net_device *netdev, u16 num_sq, u32 sq_depth, struct hinic3_dyna_txq_res *txqs_res);void hinic3_free_txqs_res (struct net_device *netdev,u16 num_sq,u32 sq_depth,struct hinic3_dyna_txq_res *txqs_res); +int hinic3_configure_txqs (struct net_device *netdev,u16 num_sq, +u32 sq_depth,struct hinic3_dyna_txq_res *txqs_res);netdev_tx_t hinic3_xmit_frame (struct sk_buff *skb,struct net_device *netdev);bool hinic3_tx_poll (struct hinic3_txq *txq,int budget);
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 11/14 hinic3: Add Rss function
In reply to Fan GongInitialize rss functions. Configure rss hash data and HW resources.
--- drivers/net/ethernet/huawei/hinic3/Makefile | 1 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 8 +- .../huawei/hinic3/hinic3_mgmt_interface.h | 55 +++ .../huawei/hinic3/hinic3_netdev_ops.c | 18 + .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 5 + .../net/ethernet/huawei/hinic3/hinic3_rss.c | 336 ++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rss.h | 14 + 7 files changed, 436 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/Makefile +1 -0
@@ -19,6 +19,7 @@ hinic3-objs := hinic3_cmdq.o \ hinic3_nic_cfg.o \ hinic3_nic_io.o \ hinic3_queue_common.o \ + hinic3_rss.o \ hinic3_rx.o \ hinic3_tx.o \ hinic3_wq.o
drivers/net/ethernet/huawei/hinic3/hinic3_main.c +7 -1
@@ -12,6 +12,7 @@#include "hinic3_nic_cfg.h" #include "hinic3_nic_dev.h" #include "hinic3_nic_io.h" +#include "hinic3_rss.h" #include "hinic3_rx.h" #include "hinic3_tx.h"
@@ -134,6 +135,8 @@ static int hinic3_sw_init(struct net_device *netdev) nic_dev->q_params.sq_depth =HINIC3_SQ_DEPTH ; nic_dev->q_params.rq_depth =HINIC3_RQ_DEPTH ; +hinic3_try_to_enable_rss (netdev); +/* VF driver always uses random MAC address. During VM migration to a * new device, the new device should learn the VMs old MAC rather than * provide its own MAC. The product design assumes that every VF is
@@ -145,7 +148,7 @@ static int hinic3_sw_init(struct net_device *netdev) hinic3_global_func_id(hwdev));if (err) {dev_err (hwdev->dev,"Failed to set default MAC\n" ); -return err; + goto err_clear_rss_config; } err =hinic3_alloc_txrxqs (netdev);
@@ -159,6 +162,8 @@ static int hinic3_sw_init(struct net_device *netdev) err_del_mac:hinic3_del_mac (hwdev, netdev->dev_addr,0 ,hinic3_global_func_id (hwdev)); +err_clear_rss_config: +hinic3_clear_rss_config (netdev);return err; }
@@ -170,6 +175,7 @@ static void hinic3_sw_uninit(struct net_device *netdev)hinic3_free_txrxqs (netdev);hinic3_del_mac (nic_dev->hwdev, netdev->dev_addr,0 ,hinic3_global_func_id (nic_dev->hwdev)); +hinic3_clear_rss_config (netdev); }static void hinic3_assign_netdev_ops (struct net_device *netdev)
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +55 -0
70 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +18 -0
@@ -8,6 +8,7 @@#include "hinic3_nic_cfg.h" #include "hinic3_nic_dev.h" #include "hinic3_nic_io.h" +#include "hinic3_rss.h" #include "hinic3_rx.h" #include "hinic3_tx.h"
@@ -221,9 +222,25 @@ static int hinic3_configure(struct net_device *netdev)/* Ensure DCB is disabled */ hinic3_sync_dcb_state (nic_dev->hwdev,1 ,0 ); +if (test_bit (HINIC3_RSS_ENABLE , &nic_dev->flags)) { + err =hinic3_rss_init (netdev); +if (err) { +netdev_err (netdev,"Failed to init rss\n" ); +return err; + } + } +return 0 ; } +static void hinic3_remove_configure (struct net_device *netdev) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); + +if (test_bit (HINIC3_RSS_ENABLE , &nic_dev->flags)) +hinic3_rss_uninit (netdev); +} +static int hinic3_alloc_channel_resources (struct net_device *netdev,struct hinic3_dyna_qp_params *qp_params,struct hinic3_dyna_txrxq_params *trxq_params)
@@ -304,6 +321,7 @@ static void hinic3_close_channel(struct net_device *netdev) {struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +hinic3_remove_configure (netdev);hinic3_qps_irq_uninit (netdev);hinic3_free_qp_ctxts (nic_dev); }
drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h +5 -0
@@ -73,6 +73,11 @@ struct hinic3_nic_dev {struct hinic3_txq *txqs;struct hinic3_rxq *rxqs; +enum hinic3_rss_hash_type rss_hash_type; +struct hinic3_rss_type rss_type; +u8 *rss_hkey; +u16 *rss_indir; +u16 num_qp_irq;struct msix_entry *qps_msix_entries;
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c new file +336 -0
336 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rss.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. */ + +#ifndef _HINIC3_RSS_H_ +#define _HINIC3_RSS_H_ + +#include <linux/netdevice.h> + +int hinic3_rss_init (struct net_device *netdev); +void hinic3_rss_uninit (struct net_device *netdev); +void hinic3_try_to_enable_rss (struct net_device *netdev); +void hinic3_clear_rss_config (struct net_device *netdev); + +#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 12/14 hinic3: Add port management
In reply to Fan GongAdd port management of enable/disable/query/flush function.
--- .../huawei/hinic3/hinic3_mgmt_interface.h | 29 ++++++++ .../huawei/hinic3/hinic3_netdev_ops.c | 60 ++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 68 +++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 4 ++ 4 files changed, 161 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +29 -0
@@ -69,12 +69,27 @@ struct l2nic_cmd_set_ci_attr {u64 ci_addr; }; +struct l2nic_cmd_clear_qp_resource { +struct mgmt_msg_head msg_head; +u16 func_id; +u16 rsvd1; +}; +struct l2nic_cmd_force_pkt_drop {struct mgmt_msg_head msg_head;u8 port;u8 rsvd1[3 ]; }; +struct l2nic_cmd_set_vport_state { +struct mgmt_msg_head msg_head; +u16 func_id; +u16 rsvd1; +/* 0--disable, 1--enable */ +u8 state; +u8 rsvd2[3 ]; +}; +struct l2nic_cmd_set_dcb_state {struct mgmt_msg_head head;u16 func_id;
@@ -172,6 +187,20 @@ enum l2nic_ucode_cmd { L2NIC_UCODE_CMD_SET_RSS_INDIR_TBL = 4, }; +/* hilink mac group command */ +enum mag_cmd { +MAG_CMD_GET_LINK_STATUS =7 , +}; + +/* firmware also use this cmd report link event to driver */ +struct mag_cmd_get_link_status { +struct mgmt_msg_head head; +u8 port_id; +/* 0:link down 1:link up */ +u8 status; +u8 rsvd0[2 ]; +}; +enum hinic3_nic_feature_cap {HINIC3_NIC_F_CSUM =BIT (0 ),HINIC3_NIC_F_SCTP_CRC =BIT (1 ),
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +60 -0
80 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +68 -0
77 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +4 -0
@@ -50,8 +50,12 @@ int hinic3_update_mac(struct hinic3_hwdev *hwdev, const u8 *old_mac,int hinic3_set_ci_table (struct hinic3_hwdev *hwdev,struct hinic3_sq_attr *attr); +int hinic3_flush_qps_res (struct hinic3_hwdev *hwdev);int hinic3_force_drop_tx_pkt (struct hinic3_hwdev *hwdev);int hinic3_sync_dcb_state (struct hinic3_hwdev *hwdev,u8 op_code,u8 state); +int hinic3_get_link_status (struct hinic3_hwdev *hwdev,bool *link_status_up); +int hinic3_set_vport_enable (struct hinic3_hwdev *hwdev,u16 func_id, +bool enable);#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 13/14 hinic3: Fix missing napi->dev in netif_queue_set_napi
In reply to Fan GongAs netif_queue_set_napi checks napi->dev, if it doesn't have it and it will warn_on and return. So we should use netif_napi_add before netif_queue_set_napi because netif_napi_add has "napi->dev = dev".
--- drivers/net/ethernet/huawei/hinic3/hinic3_irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_irq.c +1 -1
@@ -42,11 +42,11 @@ static void qp_add_napi(struct hinic3_irq_cfg *irq_cfg) {struct hinic3_nic_dev *nic_dev =netdev_priv (irq_cfg->netdev); +netif_napi_add (nic_dev->netdev, &irq_cfg->napi, hinic3_poll);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); }
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH v4 14/14 hinic3: Fix code style (Missing a blank line before return)
In reply to Fan GongFix code style of missing a blank line before return.
--- drivers/net/ethernet/huawei/hinic3/hinic3_lld.c | 5 +++++ drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 1 + drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 2 ++ 3 files changed, 8 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c +5 -0
@@ -122,6 +122,7 @@ static int hinic3_attach_aux_devices(struct hinic3_hwdev *hwdev) goto err_del_adevs; }mutex_unlock (&pci_adapter->pdev_mutex); +return 0 ; err_del_adevs:
@@ -133,6 +134,7 @@ static int hinic3_attach_aux_devices(struct hinic3_hwdev *hwdev) } }mutex_unlock (&pci_adapter->pdev_mutex); +return -ENOMEM ; }
@@ -154,6 +156,7 @@ struct hinic3_hwdev *hinic3_adev_get_hwdev(struct auxiliary_device *adev)struct hinic3_adev *hadev; hadev = container_of(adev, struct hinic3_adev, adev); +return hadev->hwdev; }
@@ -335,6 +338,7 @@ static int hinic3_probe_func(struct hinic3_pcidev *pci_adapter) err_out:dev_err (&pdev->dev,"PCIe device probe function failed\n" ); +return err; }
@@ -367,6 +371,7 @@ static int hinic3_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_out:dev_err (&pdev->dev,"PCIe device probe failed\n" ); +return err; }
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +1 -0
@@ -112,6 +112,7 @@ int hinic3_set_port_mtu(struct net_device *netdev, u16 new_mtu)struct hinic3_hwdev *hwdev = nic_dev->hwdev; func_tbl_cfg.mtu = new_mtu; +return hinic3_set_function_table (hwdev,BIT (L2NIC_FUNC_TBL_CFG_MTU ), &func_tbl_cfg); }
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +2 -0
@@ -116,6 +116,7 @@ static int hinic3_tx_map_skb(struct net_device *netdev, struct sk_buff *skb, }dma_unmap_single (&pdev->dev, dma_info[0 ].dma, dma_info[0 ].len,DMA_TO_DEVICE ); +return err; }
@@ -601,6 +602,7 @@ netdev_tx_t hinic3_xmit_frame(struct sk_buff *skb, struct net_device *netdev) err_drop_pkt:dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; }
Signature · 1 line
2.43.0