Fix 5 bugs: 1. Fix array bounds error in ethtool get_link_ksettings 2. Fix ethtool loopback command failure 3. Fix xor checksum error when sending a non 4B-aligned message to firmware 4. Fix an error when netdev failed to link up 5. Reduce the timeout of the channel between driver and firmware
Yanling Song (5): net/spnic: Fix array bounds error in ethtool get_link_ksettings net/spnic: Fix ethtool loopback command failure net/spnic: Fix xor checksum error when sending a non 4B-aligned message to firmware net/spnic: Fix an error when netdev failed to link up net/spnic: Reduce the timeout of the channel between driver and firmware
.../net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 2 +- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 10 ++-- .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c | 2 +- .../ramaxel/spnic/spnic_ethtool_stats.c | 4 +- .../ethernet/ramaxel/spnic/spnic_mag_cfg.c | 2 +- .../ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c | 49 ++++++++++++------- 6 files changed, 41 insertions(+), 28 deletions(-)
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TPKM CVE: NA
-----------------------------------------------
Replace hw_link_mode by link_mode in ethtool get_link_ksettings
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: wenliang wenliang@ramaxel.com --- drivers/net/ethernet/ramaxel/spnic/spnic_ethtool_stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_ethtool_stats.c b/drivers/net/ethernet/ramaxel/spnic/spnic_ethtool_stats.c index 8a5073a20f0b..5a830e3454d4 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_ethtool_stats.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_ethtool_stats.c @@ -745,9 +745,9 @@ spnic_add_ethtool_link_mode(struct cmd_link_settings *link_settings, u32 hw_link for (link_mode = 0; link_mode < LINK_MODE_MAX_NUMBERS; link_mode++) { if (hw_link_mode & BIT(link_mode)) { if (name == GET_SUPPORTED_MODE) - ETHTOOL_ADD_SUPPORTED_SPEED_LINK_MODE(link_settings, hw_link_mode); + ETHTOOL_ADD_SUPPORTED_SPEED_LINK_MODE(link_settings, link_mode); else - ETHTOOL_ADD_ADVERTISED_SPEED_LINK_MODE(link_settings, hw_link_mode); + ETHTOOL_ADD_ADVERTISED_SPEED_LINK_MODE(link_settings, link_mode); } } }
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TPKM CVE: NA
-----------------------------------------------
Fix ethtool loopback command failure
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: wenliang wenliang@ramaxel.com --- drivers/net/ethernet/ramaxel/spnic/spnic_mag_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_mag_cfg.c b/drivers/net/ethernet/ramaxel/spnic/spnic_mag_cfg.c index 2f73f4e6cbfa..d0448d1a6bd3 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_mag_cfg.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_mag_cfg.c @@ -178,7 +178,7 @@ int spnic_set_loopback_mode(void *hwdev, u8 mode, u8 enable) return -EINVAL; }
- return spnic_cfg_loopback_mode(nic_cfg, MGMT_MSG_CMD_OP_GET, &mode, &enable); + return spnic_cfg_loopback_mode(nic_cfg, MGMT_MSG_CMD_OP_SET, &mode, &enable); }
int spnic_set_led_status(void *hwdev, enum mag_led_type type, enum mag_led_mode mode)
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TPKM CVE: NA
-----------------------------------------------
Hardware calcaulats xor by 4B-aligned. When sending a non 4B-aligned message to firmware, the message has to be rounded up as 4B-aligned.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: wenliang wenliang@ramaxel.com --- drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c index 8abb47422bdd..7631b17a2944 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c @@ -860,6 +860,7 @@ static int mbox_prepare_dma_entry(struct sphw_mbox *func_to_func, struct mbox_dm struct mbox_dma_msg *dma_msg, void *msg, u16 msg_len) { u64 dma_addr, offset; + void *dma_vaddr;
if (IS_MSG_QUEUE_FULL(mq)) { sdk_err(func_to_func->hwdev->dev_hdl, "Mbox sync message queue is busy, pi: %u, ci: %u\n", @@ -869,12 +870,13 @@ static int mbox_prepare_dma_entry(struct sphw_mbox *func_to_func, struct mbox_dm
/* copy data to DMA buffer */ offset = mq->prod_idx * MBOX_MAX_BUF_SZ; - memcpy((u8 *)mq->dma_buff_vaddr + offset, msg, msg_len); + dma_vaddr = (u8 *)mq->dma_buff_vaddr + offset; + memcpy(dma_vaddr, msg, msg_len); dma_addr = mq->dma_buff_paddr + offset; dma_msg->dma_addr_high = upper_32_bits(dma_addr); dma_msg->dma_addr_low = lower_32_bits(dma_addr); dma_msg->msg_len = msg_len; - dma_msg->xor = mbox_dma_msg_xor(msg, msg_len); + dma_msg->xor = mbox_dma_msg_xor(dma_vaddr, ALIGN(msg_len, sizeof(u32)));
mq->prod_idx++; mq->prod_idx = MQ_ID_MASK(mq, mq->prod_idx);
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TPKM CVE: NA
-----------------------------------------------
In the case of no VF, spnic_pf_event_handler/spnic_pf_mag_event_handler should be registered too.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: wenliang wenliang@ramaxel.com --- .../ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c index 53410b2423c8..634f82153dff 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c @@ -523,14 +523,26 @@ static int pf_init_vf_infos(struct spnic_nic_cfg *nic_cfg) int err; u16 i;
+ err = sphw_register_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC, nic_cfg, + spnic_pf_event_handler); + if (err) + return err; + + err = sphw_register_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_HILINK, nic_cfg, + spnic_pf_mag_event_handler); + if (err) + goto register_mag_mgmt_cb_err; + nic_cfg->max_vfs = sphw_func_max_vf(nic_cfg->hwdev); size = sizeof(*nic_cfg->vf_infos) * nic_cfg->max_vfs; if (!size) return 0;
nic_cfg->vf_infos = kzalloc(size, GFP_KERNEL); - if (!nic_cfg->vf_infos) - return -ENOMEM; + if (!nic_cfg->vf_infos) { + err = -ENOMEM; + goto alloc_vf_infos_err; + }
for (i = 0; i < nic_cfg->max_vfs; i++) { err = spnic_init_vf_infos(nic_cfg, i); @@ -538,36 +550,31 @@ static int pf_init_vf_infos(struct spnic_nic_cfg *nic_cfg) goto init_vf_infos_err; }
- err = sphw_register_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC, nic_cfg, - spnic_pf_event_handler); - if (err) - goto register_mgmt_cb_err; - err = sphw_register_pf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC, nic_cfg, spnic_pf_mbox_handler); if (err) - goto register_pf_mbox_cb_err; - - err = sphw_register_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_HILINK, nic_cfg, - spnic_pf_mag_event_handler); - if (err) - goto register_mgmt_cb_err; + goto register_nic_mbox_cb_err;
err = sphw_register_pf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_HILINK, nic_cfg, spnic_pf_mag_mbox_handler); if (err) - goto register_pf_mag_mbox_cb_err; + goto register_mag_mbox_cb_err;
return 0;
-register_pf_mag_mbox_cb_err: +register_mag_mbox_cb_err: sphw_unregister_pf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); -register_pf_mbox_cb_err: - sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); -register_mgmt_cb_err: + +register_nic_mbox_cb_err: init_vf_infos_err: kfree(nic_cfg->vf_infos);
+alloc_vf_infos_err: + sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_HILINK); + +register_mag_mgmt_cb_err: + sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); + return err; }
@@ -596,13 +603,17 @@ void spnic_vf_func_free(struct spnic_nic_cfg *nic_cfg) err, unregister.msg_head.status, out_size);
sphw_unregister_vf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); + sphw_unregister_vf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_HILINK); } else { if (nic_cfg->vf_infos) { - sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); sphw_unregister_pf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); + sphw_unregister_pf_mbox_cb(nic_cfg->hwdev, SPHW_MOD_HILINK); spnic_clear_vfs_info(nic_cfg->hwdev); kfree(nic_cfg->vf_infos); } + + sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_L2NIC); + sphw_unregister_mgmt_msg_cb(nic_cfg->hwdev, SPHW_MOD_HILINK); } }
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TPKM CVE: NA
-----------------------------------------------
Reduce the timeout of the channel between driver and firmware
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: wenliang wenliang@ramaxel.com --- drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 2 +- drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 4 ++-- drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c index 5421b813d484..9ebff6f8ac97 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c @@ -30,7 +30,7 @@ #define SPHW_CMDQ_MAX_DATA_SIZE \ (SPHW_CMDQ_BUF_SIZE - SPHW_CMDQ_BUF_HW_RSVD)
-#define CMDQ_CMD_TIMEOUT 300000 /* millisecond */ +#define CMDQ_CMD_TIMEOUT 5000 /* millisecond */
#define UPPER_8_BITS(data) (((data) >> 8) & 0xFF) #define LOWER_8_BITS(data) ((data) & 0xFF) diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c index 7631b17a2944..694463ca0a93 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c @@ -61,8 +61,8 @@ enum sphw_mbox_tx_status {
#define MBOX_SEGLEN_MASK SPHW_MSG_HEADER_SET(SPHW_MSG_HEADER_SEG_LEN_MASK, SEG_LEN)
-#define MBOX_MSG_POLLING_TIMEOUT 300000 -#define SPHW_MBOX_COMP_TIME 300000U +#define MBOX_MSG_POLLING_TIMEOUT 8000 +#define SPHW_MBOX_COMP_TIME 25000U
#define MBOX_MAX_BUF_SZ 2048U #define MBOX_HEADER_SZ 8 diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c index 01e88535a0ab..a66f40635963 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c @@ -50,7 +50,7 @@
#define MSG_NO_RESP 0xFFFF
-#define MGMT_MSG_TIMEOUT 300000 /* millisecond */ +#define MGMT_MSG_TIMEOUT 20000 /* millisecond */
#define SYNC_MSG_ID(pf_to_mgmt) ((pf_to_mgmt)->sync_msg_id)
For this series, Acked-by: Xie XiuQi xiexiuqi@huawei.com
On 2022/2/22 16:36, Yanling Song wrote:
Fix 5 bugs:
- Fix array bounds error in ethtool get_link_ksettings
- Fix ethtool loopback command failure
- Fix xor checksum error when sending a non 4B-aligned message to firmware
- Fix an error when netdev failed to link up
- Reduce the timeout of the channel between driver and firmware
Yanling Song (5): net/spnic: Fix array bounds error in ethtool get_link_ksettings net/spnic: Fix ethtool loopback command failure net/spnic: Fix xor checksum error when sending a non 4B-aligned message to firmware net/spnic: Fix an error when netdev failed to link up net/spnic: Reduce the timeout of the channel between driver and firmware
.../net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 2 +- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 10 ++-- .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c | 2 +- .../ramaxel/spnic/spnic_ethtool_stats.c | 4 +- .../ethernet/ramaxel/spnic/spnic_mag_cfg.c | 2 +- .../ethernet/ramaxel/spnic/spnic_nic_cfg_vf.c | 49 ++++++++++++------- 6 files changed, 41 insertions(+), 28 deletions(-)