net/hns3: fix hard-coded default value of UMV space
PATCH 1/1 net/hns3: fix hard-coded default value of UMV space
Currently, the driver obtains the PF's UMV (unicast MAC VLAN) table space from the board configuration, and falls back to the hard-coded default value HNS3_DEFAULT_UMV_SPACE_PER_PF (384 = 3072 / 8) when the firmware reports an empty umv_space field.
The hard-coded value is only accurate for chips with a 3072-entry UMV table. On chips whose total UMV table size is smaller than 3072, every PF still requests 384 entries: the first initialized PF occupies the whole table while the others get nothing, which makes adding unicast MAC or VLAN entries fail on those ports.
Fix this by obtaining the UMV size from the device specifications command, whose umv_size field is the default value allocated by the firmware policy. The requested size is determined at allocation time in hns3_init_umv_space(), in the following priority:
1. pf->cfg_umv_size, the user specified value from the board configuration
2. pf->def_umv_size, the default value reported by the firmware
3. the hard-coded default, as the last fallback for old firmware
--- drivers/net/hns3/hns3_cmd.h | 6 ++++-- drivers/net/hns3/hns3_common.c | 1 + drivers/net/hns3/hns3_ethdev.c | 19 ++++++++++++------- drivers/net/hns3/hns3_ethdev.h | 3 ++- 4 files changed, 19 insertions(+), 10 deletions(-)
drivers/net/hns3/hns3_cmd.h +4 -2
@@ -1008,9 +1008,11 @@ struct hns3_dev_specs_0_cmd { };struct hns3_dev_specs_1_cmd { -uint8_t rsv0[12 ]; +uint8_t rsv0[8 ]; +uint16_t umv_size; +uint8_t rsv1[2 ];uint8_t min_tx_pkt_len; -uint8_t rsv1[11 ]; +uint8_t rsv2[11 ]; };struct hns3_query_rpu_cmd {
drivers/net/hns3/hns3_common.c +1 -0
@@ -997,6 +997,7 @@ hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc)return ; hw->max_tm_rate =rte_le_to_cpu_32 (req0->max_tm_rate); + hns->pf.def_umv_size =rte_le_to_cpu_16 (req1->umv_size); } static int
drivers/net/hns3/hns3_ethdev.c +12 -7
@@ -1330,19 +1330,26 @@ hns3_init_umv_space(struct hns3_hw *hw)struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw);struct hns3_pf *pf = &hns->pf;uint16_t allocated_size =0 ; +uint16_t wanted_umv_size;int ret; - ret =hns3_set_umv_space (hw, pf->wanted_umv_size, &allocated_size, + wanted_umv_size = pf->cfg_umv_size; +if (wanted_umv_size ==0 ) + wanted_umv_size = pf->def_umv_size; +if (wanted_umv_size ==0 ) + wanted_umv_size =HNS3_DEFAULT_UMV_SPACE_PER_PF ; + + ret =hns3_set_umv_space (hw, wanted_umv_size, &allocated_size, true);if (ret)return ret; -if (allocated_size < pf->wanted_umv_size) +if (allocated_size < wanted_umv_size)PMD_INIT_LOG (WARNING ,"Alloc umv space failed, want %u, get %u" , - pf->wanted_umv_size, allocated_size); + wanted_umv_size, allocated_size); pf->max_umv_size = (!!allocated_size) ? allocated_size : - pf->wanted_umv_size; + wanted_umv_size; pf->used_umv_size =0 ;return 0 ; }
@@ -2560,8 +2567,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) cfg->umv_space =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]),HNS3_CFG_UMV_TBL_SPACE_M ,HNS3_CFG_UMV_TBL_SPACE_S ); -if (!cfg->umv_space) - cfg->umv_space =HNS3_DEFAULT_UMV_SPACE_PER_PF ; ext_rss_size_max = hns3_get_field(rte_le_to_cpu_32(req->param[2]), HNS3_CFG_EXT_RSS_SIZE_M,
@@ -2792,7 +2797,7 @@ hns3_get_board_configuration(struct hns3_hw *hw)hns3_set_bit (hw->dcb_info.hw_tc_map,0 ,1 ); pf->tx_sch_mode =HNS3_FLAG_TC_BASE_SCH_MODE ; - pf->wanted_umv_size = cfg.umv_space; + pf->cfg_umv_size = cfg.umv_space;return ret; }
drivers/net/hns3/hns3_ethdev.h +2 -1
@@ -841,7 +841,8 @@ struct hns3_pf {bool support_fc_autoneg;/* support FC autonegotiate */ bool support_multi_tc_pause; -uint16_t wanted_umv_size; +uint16_t cfg_umv_size; +uint16_t def_umv_size;uint16_t max_umv_size;uint16_t used_umv_size;
Signature · 1 line
2.33.0
Quoted 132 lines · Shuaisong Yang
Currently, the driver obtains the PF's UMV (unicast MAC VLAN) table space from the board configuration, and falls back to the hard-coded default value
HNS3_DEFAULT_UMV_SPACE_PER_PF(384 = 3072 / 8) when the firmware reports an emptyumv_spacefield.The hard-coded value is only accurate for chips with a 3072-entry UMV table. On chips whose total UMV table size is smaller than 3072, every PF still requests 384 entries: the first initialized PF occupies the whole table while the others get nothing, which makes adding unicast MAC or VLAN entries fail on those ports.
Fix this by obtaining the UMV size from the device specifications command, whose
umv_sizefield is the default value allocated by the firmware policy. The requested size is determined at allocation time inhns3_init_umv_space(), in the following priority:
1.pf->cfg_umv_size, the user specified value from the board configuration
2.pf->def_umv_size, the default value reported by the firmware
3. the hard-coded default, as the last fallback for old firmwareFixes d51867db65 ("net/hns3: add initialization")Signed-off-by Shuaisong Yang <[email protected]>--- drivers/net/hns3/hns3_cmd.h | 6 ++++-- drivers/net/hns3/hns3_common.c | 1 + drivers/net/hns3/hns3_ethdev.c | 19 ++++++++++++------- drivers/net/hns3/hns3_ethdev.h | 3 ++- 4 files changed, 19 insertions(+), 10 deletions(-)drivers/net/hns3/hns3_cmd.h +4
-2@@ -1008,9 +1008,11 @@ struct hns3_dev_specs_0_cmd { };struct hns3_dev_specs_1_cmd { -uint8_t rsv0[12 ]; +uint8_t rsv0[8 ]; +uint16_t umv_size; +uint8_t rsv1[2 ];uint8_t min_tx_pkt_len; -uint8_t rsv1[11 ]; +uint8_t rsv2[11 ]; };struct hns3_query_rpu_cmd {drivers/net/hns3/hns3_common.c +1
-0@@ -997,6 +997,7 @@ hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc)return ; hw->max_tm_rate =rte_le_to_cpu_32 (req0->max_tm_rate); + hns->pf.def_umv_size =rte_le_to_cpu_16 (req1->umv_size); } static intdrivers/net/hns3/hns3_ethdev.c +12
-7@@ -1330,19 +1330,26 @@ hns3_init_umv_space(struct hns3_hw *hw)struct hns3_adapter *hns =HNS3_DEV_HW_TO_ADAPTER (hw);struct hns3_pf *pf = &hns->pf;uint16_t allocated_size =0 ; +uint16_t wanted_umv_size;int ret; - ret =hns3_set_umv_space (hw, pf->wanted_umv_size, &allocated_size, + wanted_umv_size = pf->cfg_umv_size; +if (wanted_umv_size ==0 ) + wanted_umv_size = pf->def_umv_size; +if (wanted_umv_size ==0 ) + wanted_umv_size =HNS3_DEFAULT_UMV_SPACE_PER_PF ; + + ret =hns3_set_umv_space (hw, wanted_umv_size, &allocated_size, true);if (ret)return ret; -if (allocated_size < pf->wanted_umv_size) +if (allocated_size < wanted_umv_size)PMD_INIT_LOG (WARNING ,"Alloc umv space failed, want %u, get %u" , - pf->wanted_umv_size, allocated_size); + wanted_umv_size, allocated_size); pf->max_umv_size = (!!allocated_size) ? allocated_size : - pf->wanted_umv_size; + wanted_umv_size; pf->used_umv_size =0 ;return 0 ; }@@ -2560,8 +2567,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) cfg->umv_space =hns3_get_field (rte_le_to_cpu_32 (req->param[1 ]),HNS3_CFG_UMV_TBL_SPACE_M ,HNS3_CFG_UMV_TBL_SPACE_S ); -if (!cfg->umv_space) - cfg->umv_space =HNS3_DEFAULT_UMV_SPACE_PER_PF ; ext_rss_size_max = hns3_get_field(rte_le_to_cpu_32(req->param[2]), HNS3_CFG_EXT_RSS_SIZE_M,@@ -2792,7 +2797,7 @@ hns3_get_board_configuration(struct hns3_hw *hw)hns3_set_bit (hw->dcb_info.hw_tc_map,0 ,1 ); pf->tx_sch_mode =HNS3_FLAG_TC_BASE_SCH_MODE ; - pf->wanted_umv_size = cfg.umv_space; + pf->cfg_umv_size = cfg.umv_space;return ret; }drivers/net/hns3/hns3_ethdev.h +2
-1@@ -841,7 +841,8 @@ struct hns3_pf {bool support_fc_autoneg;/* support FC autonegotiate */ bool support_multi_tc_pause; -uint16_t wanted_umv_size; +uint16_t cfg_umv_size; +uint16_t def_umv_size;uint16_t max_umv_size;uint16_t used_umv_size;Signature · 1 line
2.33.0
Quoted 2 lines · On Wed, 04 Nov 2026 13:04:37 +0000 [email protected] wrote:
Acked-by Chengwen Feng <[email protected] mailto:[email protected] >
Mail address got garbled in your Acked-by. Fixed during merge
Quoted 20 lines · On Wed, 4 Nov 2026 20:40:33 +0800 Shuaisong Yang…
Currently, the driver obtains the PF's UMV (unicast MAC VLAN) table space from the board configuration, and falls back to the hard-coded default value
HNS3_DEFAULT_UMV_SPACE_PER_PF(384 = 3072 / 8) when the firmware reports an emptyumv_spacefield.The hard-coded value is only accurate for chips with a 3072-entry UMV table. On chips whose total UMV table size is smaller than 3072, every PF still requests 384 entries: the first initialized PF occupies the whole table while the others get nothing, which makes adding unicast MAC or VLAN entries fail on those ports.
Fix this by obtaining the UMV size from the device specifications command, whose
umv_sizefield is the default value allocated by the firmware policy. The requested size is determined at allocation time inhns3_init_umv_space(), in the following priority:
1.pf->cfg_umv_size, the user specified value from the board configuration
2.pf->def_umv_size, the default value reported by the firmware
3. the hard-coded default, as the last fallback for old firmware
Quoted 5 lines
Fixes d51867db65 ("net/hns3: add initialization")Signed-off-by Shuaisong Yang <[email protected]>---
Looks ok, I will correct the Fixes line during merge to next-net. Current process needs longer hash value
Stephen Hemminger
AppliedQuoted 4 lines · On Wed, 4 Nov 2026 20:40:33 +0800 Shuaisong Yang…
Fixes d51867db65 ("net/hns3: add initialization")Signed-off-by Shuaisong Yang <[email protected]>
Applied to next-net. Corrected the Fixes line to use 12 character hash as required now.