On 26/08/2025 10:05, Fan Gong wrote:
Add nic_io initialization to enable NIC service, initialize function table and negotiate activation of NIC features. Co-developed-by: Xin Guo <guoxin09@xxxxxxxxxx> Signed-off-by: Xin Guo <guoxin09@xxxxxxxxxx> Co-developed-by: Zhu Yikai <zhuyikai1@xxxxxxxxxxxxxx> Signed-off-by: Zhu Yikai <zhuyikai1@xxxxxxxxxxxxxx> Signed-off-by: Fan Gong <gongfan1@xxxxxxxxxx> --- .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 15 +++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 24 ++++++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 2 + .../ethernet/huawei/hinic3/hinic3_nic_io.c | 61 ++++++++++++++++++- 4 files changed, 99 insertions(+), 3 deletions(-)
[...]
+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;
func_tbl_cfg can still have garbage in rsvd field, which then will be passed down to FW. Better to init it to 0 to avoid exposing data.
+ + 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); +} +
[...]
+static int init_nic_io(struct hinic3_nic_io **nic_io) +{ + *nic_io = kzalloc(sizeof(**nic_io), GFP_KERNEL); + if (!(*nic_io)) + return -ENOMEM; + + return 0; +} + int hinic3_init_nic_io(struct hinic3_nic_dev *nic_dev) { - /* Completed by later submission due to LoC limit. */ - return -EFAULT; + struct hinic3_hwdev *hwdev = nic_dev->hwdev; + struct hinic3_nic_io *nic_io; + int err; + + err = init_nic_io(&nic_io); + if (err) + return err;
there is no need for init_nic_io(). you can call kzalloc() directly in hinic3_init_nic_io() and return -ENOMEM in case of NULL return
+ + nic_dev->nic_io = nic_io; +