net/igb: fix add/delete of flex filters

Before this patch, flex_filter->index was always zero when it was read
and used after rte_zmalloc. The corresponding code was therefore moved
into the add and delete parts of the if/else statement.

Fixes: 231d43909a31 ("igb: migrate flex filter to new API")
Cc: stable@dpdk.org

Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
This commit is contained in:
Markus Theil 2017-05-22 12:17:50 +02:00 committed by Ferruh Yigit
parent 2764556a84
commit 167e7b9ae5

View File

@ -3914,10 +3914,6 @@ eth_igb_add_del_flex_filter(struct rte_eth_dev *dev,
} }
wufc = E1000_READ_REG(hw, E1000_WUFC); wufc = E1000_READ_REG(hw, E1000_WUFC);
if (flex_filter->index < E1000_MAX_FHFT)
reg_off = E1000_FHFT(flex_filter->index);
else
reg_off = E1000_FHFT_EXT(flex_filter->index - E1000_MAX_FHFT);
if (add) { if (add) {
if (eth_igb_flex_filter_lookup(&filter_info->flex_list, if (eth_igb_flex_filter_lookup(&filter_info->flex_list,
@ -3947,6 +3943,11 @@ eth_igb_add_del_flex_filter(struct rte_eth_dev *dev,
return -ENOSYS; return -ENOSYS;
} }
if (flex_filter->index < E1000_MAX_FHFT)
reg_off = E1000_FHFT(flex_filter->index);
else
reg_off = E1000_FHFT_EXT(flex_filter->index - E1000_MAX_FHFT);
E1000_WRITE_REG(hw, E1000_WUFC, wufc | E1000_WUFC_FLEX_HQ | E1000_WRITE_REG(hw, E1000_WUFC, wufc | E1000_WUFC_FLEX_HQ |
(E1000_WUFC_FLX0 << flex_filter->index)); (E1000_WUFC_FLX0 << flex_filter->index));
queueing = filter->len | queueing = filter->len |
@ -3975,6 +3976,11 @@ eth_igb_add_del_flex_filter(struct rte_eth_dev *dev,
return -ENOENT; return -ENOENT;
} }
if (it->index < E1000_MAX_FHFT)
reg_off = E1000_FHFT(it->index);
else
reg_off = E1000_FHFT_EXT(it->index - E1000_MAX_FHFT);
for (i = 0; i < E1000_FHFT_SIZE_IN_DWD; i++) for (i = 0; i < E1000_FHFT_SIZE_IN_DWD; i++)
E1000_WRITE_REG(hw, reg_off + i * sizeof(uint32_t), 0); E1000_WRITE_REG(hw, reg_off + i * sizeof(uint32_t), 0);
E1000_WRITE_REG(hw, E1000_WUFC, wufc & E1000_WRITE_REG(hw, E1000_WUFC, wufc &