Bug fixes for ice
Subsystems (2)
v2 cover Bug fixes for ice
This patch set fixes multiple bugs for the ice driver.
Anirudh Venkataramanan (4):
ice: Fix static analyser warning
ice: Cleanup magic number
ice: Fix bugs in control queue processing
ice: Fix couple of null pointer dereference issues
Brett Creeley (2):
ice: Don't explicitly set port_vlan_bits to 0
ice: Set VLAN flags correctly
Bruce Allan (3):
ice: Fix missing shift
ice: Update to interrupts enabled in OICR
ice: Change struct members from bool to u8
Jacob Keller (2):
ice: Report stats for allocated queues via ethtool stats
ice: Use order_base_2 to calculate higher power of 2
Jesse Brandeburg (1):
ice: Fix potential return of uninitialized value
Preethi Banala (1):
ice: Clean control queues only when they are initialized
drivers/net/ethernet/intel/ice/ice.h | 15 ++-- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 1 + drivers/net/ethernet/intel/ice/ice_controlq.c | 29 +++++--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 52 ++++++++++---- drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 8 --- drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 91 +++++++++++++++---------- drivers/net/ethernet/intel/ice/ice_switch.c | 3 +- drivers/net/ethernet/intel/ice/ice_switch.h | 6 +- drivers/net/ethernet/intel/ice/ice_txrx.h | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 16 ++--- 11 files changed, 141 insertions(+), 83 deletions(-)
Signature · 1 line
2.14.3
PATCH v2 1/13 ice: Fix static analyser warning
This patch fixes one of the smatch (a static analysis tool) warnings reported by Dan Carpenter. ICE_LG_ACT_GENERIC_OFFSET_M is the right mask to use but it appears that ICE_LG_ACT_GENERIC_VALUE_M was used instead, which resulted in the following smatch warning:
ice_add_marker_act() warn: odd binop '0x380000 & 0x7fff8'
Additionally, use a new define ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX instead of magic number '7'.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 1 + drivers/net/ethernet/intel/ice/ice_switch.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1 -0
@@ -594,6 +594,7 @@ struct ice_sw_rule_lg_act {#define ICE_LG_ACT_GENERIC_OFFSET_M (0x7 << ICE_LG_ACT_GENERIC_OFFSET_S)#define ICE_LG_ACT_GENERIC_PRIORITY_S 22#define ICE_LG_ACT_GENERIC_PRIORITY_M (0x7 << ICE_LG_ACT_GENERIC_PRIORITY_S) +#define ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX 7/* Action = 7 - Set Stat count */ #define ICE_LG_ACT_STAT_COUNT 0x7
drivers/net/ethernet/intel/ice/ice_switch.c +2 -1
@@ -645,7 +645,8 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent, act |= (1 <<ICE_LG_ACT_GENERIC_VALUE_S ) &ICE_LG_ACT_GENERIC_VALUE_M ; lg_act->pdata.lg_act.act[1 ] =cpu_to_le32 (act); - act = (7 <<ICE_LG_ACT_GENERIC_OFFSET_S ) &ICE_LG_ACT_GENERIC_VALUE_M ; + act = (ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX << +ICE_LG_ACT_GENERIC_OFFSET_S ) &ICE_LG_ACT_GENERIC_OFFSET_M ;/* Third action Marker value */ act |=ICE_LG_ACT_GENERIC ;
Signature · 1 line
2.14.3
PATCH v2 2/13 ice: Cleanup magic number
In reply to Anirudh VenkataramananUse define for the unit size shift of the Rx LAN context descriptor base address instead of the magic number 7.
--- drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h +1 -0
@@ -265,6 +265,7 @@ enum ice_rx_flex_desc_status_error_0_bits {struct ice_rlan_ctx {u16 head;u16 cpuid;/* bigger than needed, see above for reason */ +#define ICE_RLAN_BASE_S 7u64 base;u16 qlen;#define ICE_RLAN_CTX_DBUF_S 7
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3986,7 +3986,7 @@ static int ice_setup_rx_ctx(struct ice_ring *ring)/* clear the context structure first */ memset (&rlan_ctx,0 ,sizeof (rlan_ctx)); - rlan_ctx.base = ring->dma >>7 ; + rlan_ctx.base = ring->dma >>ICE_RLAN_BASE_S ; rlan_ctx.qlen = ring->count;
Signature · 1 line
2.14.3
PATCH v2 3/13 ice: Fix missing shift
In reply to Anirudh VenkataramananFrom: Bruce Allan <[email protected]>
The ITR index of the interrupt cause for OICR and FW interrupts is not being shifted correctly so when masked with PFINT_*_CTL_ITR_INDX_M it will always be zero. Luckily, ICE_RX_ITR is zero anyway so the end result is the same, but the shift should be fixed in case the value of ICE_RX_ITR ever changes or it is substituted with another value that needs to be shifted properly.
---
[Anirudh Venkataramanan <[email protected]> cleaned up commit message]
--- drivers/net/ethernet/intel/ice/ice_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +8 -6
@@ -2058,15 +2058,17 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf) skip_req_irq:ice_ena_misc_vector (pf); - val = (pf->oicr_idx &PFINT_OICR_CTL_MSIX_INDX_M ) | - (ICE_RX_ITR &PFINT_OICR_CTL_ITR_INDX_M ) | -PFINT_OICR_CTL_CAUSE_ENA_M ; + val = ((pf->oicr_idx &PFINT_OICR_CTL_MSIX_INDX_M ) | + ((ICE_RX_ITR <<PFINT_OICR_CTL_ITR_INDX_S ) & +PFINT_OICR_CTL_ITR_INDX_M ) | +PFINT_OICR_CTL_CAUSE_ENA_M );wr32 (hw,PFINT_OICR_CTL , val);/* This enables Admin queue Interrupt causes */ - val = (pf->oicr_idx &PFINT_FW_CTL_MSIX_INDX_M ) | - (ICE_RX_ITR &PFINT_FW_CTL_ITR_INDX_M ) | -PFINT_FW_CTL_CAUSE_ENA_M ; + val = ((pf->oicr_idx &PFINT_FW_CTL_MSIX_INDX_M ) | + ((ICE_RX_ITR <<PFINT_FW_CTL_ITR_INDX_S ) & +PFINT_FW_CTL_ITR_INDX_M ) | +PFINT_FW_CTL_CAUSE_ENA_M );wr32 (hw,PFINT_FW_CTL , val); itr_gran = hw->itr_gran_200;
Signature · 1 line
2.14.3
PATCH v2 4/13 ice: Report stats for allocated queues via ethtool stats
In reply to Anirudh VenkataramananFrom: Jacob Keller <[email protected]>
It is not safe to have the string table for statistics change order or size over the lifetime of a given netdevice. This is because of the nature of the 3-step process for obtaining stats. First, userspace performs a request for the size of the strings table. Second it performs a separate request for the strings themselves, after allocating space for the table. Third, it requests the stats themselves, also allocating space for the table.
If the size decreased, there is potential to see garbage data or stats values. In the worst case, we could potentially see stats values become mis-aligned with their strings, so that it looks like a statistic is being reported differently than it actually is.
Even worse, if the size increased, there is potential that the strings table or stats table was not allocated large enough and the stats code could access and write to memory it should not, potentially resulting in undefined behavior and system crashes.
It isn't even safe if the size always changes under the RTNL lock. This is because the calls take place over multiple userspace commands, so it is not possible to hold the RTNL lock for the entire duration of obtaining strings and stats. Further, not all consumers of the ethtool API are the userspace ethtool program, and it is possible that one assumes the strings will not change (valid under the current contract), and thus only requests the stats values when requesting stats in a loop.
Finally, it's not possible in the general case to detect when the size changes, because it is quite possible that one value which could impact the stat size increased, while another decreased. This would result in the same total number of stats, but reordering them so that stats no longer line up with the strings they belong to. Since only size changes aren't enough, we would need some sort of hash or token to determine when the strings no longer match. This would require extending the ethtool stats commands, but there is no more space in the relevant structures.
The real solution to resolve this would be to add a completely new API for stats, probably over netlink.
In the ice driver, the only thing impacting the stats that is not constant is the number of queues. Instead of reporting stats for each used queue, report stats for each allocated queue. We do not change the number of queues allocated for a given netdevice, as we pass this into the alloc_etherdev_mq() function to set the num_tx_queues and num_rx_queues.
This resolves the potential bugs at the slight cost of displaying many queue statistics which will not be activated.
---
[Anirudh Venkataramanan <[email protected]> cleaned up commit message]
--- drivers/net/ethernet/intel/ice/ice.h | 7 ++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 52 +++++++++++++++++++++------- 2 files changed, 46 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +7 -0
@@ -89,6 +89,13 @@ extern const char ice_drv_ver[];#define ice_for_each_rxq (vsi, i) \ for ((i) = 0; (i) < (vsi)->num_rxq; (i)++) +/* Macros for each allocated tx/rx ring whether used or not in a VSI */ +#define ice_for_each_alloc_txq (vsi, i) \ + for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++) + +#define ice_for_each_alloc_rxq (vsi, i) \ + for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++) +struct ice_tc_info {u16 qoffset;u16 qcount;
drivers/net/ethernet/intel/ice/ice_ethtool.c +39 -13
98 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v2 5/13 ice: Clean control queues only when they are initialized
In reply to Anirudh VenkataramananFrom: Preethi Banala <[email protected]>
Clean control queues only when they are initialized. One of the ways to validate if the basic initialization is done is by checking value of cq->sq.head and cq->rq.head variables that specify the register address. This patch adds a check to avoid NULL pointer dereference crash when tried to shutdown uninitialized control queue.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +16 -8
@@ -597,10 +597,14 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)return 0 ; init_ctrlq_free_rq: -ice_shutdown_rq (hw, cq); -ice_shutdown_sq (hw, cq); -mutex_destroy (&cq->sq_lock); -mutex_destroy (&cq->rq_lock); +if (cq->rq.head) { +ice_shutdown_rq (hw, cq); +mutex_destroy (&cq->rq_lock); + } +if (cq->sq.head) { +ice_shutdown_sq (hw, cq); +mutex_destroy (&cq->sq_lock); + }return status; }
@@ -706,10 +710,14 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)return ; } -ice_shutdown_sq (hw, cq); -ice_shutdown_rq (hw, cq); -mutex_destroy (&cq->sq_lock); -mutex_destroy (&cq->rq_lock); +if (cq->sq.head) { +ice_shutdown_sq (hw, cq); +mutex_destroy (&cq->sq_lock); + } +if (cq->rq.head) { +ice_shutdown_rq (hw, cq); +mutex_destroy (&cq->rq_lock); + } }/**
Signature · 1 line
2.14.3
PATCH v2 6/13 ice: Fix bugs in control queue processing
In reply to Anirudh VenkataramananThis patch is a consolidation of multiple bug fixes for control queue processing.
1) In ice_clean_adminq_subtask() remove unnecessary reads/writes to registers. The bits PFINT_FW_CTL, PFINT_MBX_CTL and PFINT_SB_CTL are not set when an interrupt arrives, which means that clearing them again can be omitted.
2) Get an accurate value in "pending" by re-reading the control queue head register from the hardware.
3) Fix a corner case involving lost control queue messages by checking for new control messages (using ice_ctrlq_pending) before exiting the cleanup routine.
--- drivers/net/ethernet/intel/ice/ice_controlq.c | 5 ++++- drivers/net/ethernet/intel/ice/ice_main.c | 26 ++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_controlq.c +4 -1
@@ -1065,8 +1065,11 @@ ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq, clean_rq_elem_out:/* Set pending if needed, unlock and return */ -if (pending) +if (pending) { +/* re-read HW head to calculate actual pending messages */ + ntu = (u16)(rd32 (hw, cq->rq.head) & cq->rq.head_mask); *pending = (u16)((ntc > ntu ? cq->rq.count :0 ) + (ntu - ntc)); + } clean_rq_elem_err:mutex_unlock (&cq->rq_lock);
drivers/net/ethernet/intel/ice/ice_main.c +22 -4
@@ -916,6 +916,21 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)return pending && (i ==ICE_DFLT_IRQ_WORK ); } +/** +* ice_ctrlq_pending - check if there is a difference between ntc and ntu +* @hw: pointer to hardware info +* @cq: control queue information +* +* returns true if there are pending messages in a queue, false if there aren't +*/ +static bool ice_ctrlq_pending (struct ice_hw *hw,struct ice_ctl_q_info *cq) +{ +u16 ntu; + + ntu = (u16)(rd32 (hw, cq->rq.head) & cq->rq.head_mask); +return cq->rq.next_to_clean != ntu; +} +/** * ice_clean_adminq_subtask - clean the AdminQ rings * @pf: board private structure
@@ -923,7 +938,6 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)static void ice_clean_adminq_subtask (struct ice_pf *pf) {struct ice_hw *hw = &pf->hw; -u32 val;if (!test_bit (__ICE_ADMINQ_EVENT_PENDING, pf->state))return ;
@@ -933,9 +947,13 @@ static void ice_clean_adminq_subtask(struct ice_pf *pf)clear_bit (__ICE_ADMINQ_EVENT_PENDING, pf->state); -/* re-enable Admin queue interrupt causes */ - val =rd32 (hw,PFINT_FW_CTL ); -wr32 (hw,PFINT_FW_CTL , (val |PFINT_FW_CTL_CAUSE_ENA_M )); +/* There might be a situation where new messages arrive to a control +* queue between processing the last message and clearing the +* EVENT_PENDING bit. So before exiting, check queue head again (using +* ice_ctrlq_pending) and process new messages if any. +*/ +if (ice_ctrlq_pending (hw, &hw->adminq)) +__ice_clean_ctrlq (pf,ICE_CTL_Q_ADMIN );ice_flush (hw); }
Signature · 1 line
2.14.3
PATCH v2 7/13 ice: Use order_base_2 to calculate higher power of 2
In reply to Anirudh VenkataramananFrom: Jacob Keller <[email protected]>
Currently, we use a combination of ilog2 and is_power_of_2() to calculate the next power of 2 for the qcount. This appears to be causing a warning on some combinations of GCC and the Linux kernel:
MODPOST 1 modules
WARNING: "____ilog2_NaN" [ice.ko] undefined!
This appears to because because GCC realizes that qcount could be zero in some circumstances and thus attempts to link against the intentionally undefined ___ilog2_NaN function.
The order_base_2 function is intentionally defined to return 0 when passed 0 as an argument, and thus will be safe to use here.
This not only fixes the warning but makes the resulting code slightly cleaner, and is really what we should have used originally.
Also update the comment to make it more clear that we are rounding up, not just incrementing the ilog2 of qcount unconditionally.
Without this patch, we get warnings when building against the upstream kernel.
---
[Anirudh Venkataramanan <[email protected]> minor cleanup for upstream submission]
--- drivers/net/ethernet/intel/ice/ice_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -5
@@ -1313,11 +1313,8 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt) qcount = numq_tc; } -/* find higher power-of-2 of qcount */ - pow =ilog2 (qcount); - -if (!is_power_of_2 (qcount)) - pow++; +/* find the (rounded up) power-of-2 of qcount */ + pow =order_base_2 (qcount);for (i =0 ; i <ICE_MAX_TRAFFIC_CLASS ; i++) {if (!(vsi->tc_cfg.ena_tc &BIT (i))) {
Signature · 1 line
2.14.3
PATCH v2 8/13 ice: Don't explicitly set port_vlan_bits to 0
In reply to Anirudh VenkataramananFrom: Brett Creeley <[email protected]>
This patch fixes the following smatch warning originally reported by Dan Carpenter:ice_set_dflt_vsi_ctx() warn: odd binop '0x0 & 0x18'
In ice_set_dflt_vsi_ctx() we clear bits 3 and 4 for legacy behavior (i.e. show VLAN, DEI and UP in the receive descriptors). However the logic to do this generated the above mentioned smatch warning.
Bits 3 and 4 in port_vlan_flags are anyway set to zero by the memset on ctxt->info field, so remove the logic to set these explicitly to 0. This fixes the smatch warning as well.
---
[Anirudh Venkataramanan <[email protected]> rewrote commit message]
--- drivers/net/ethernet/intel/ice/ice_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +4 -5
@@ -1367,14 +1367,13 @@ static void ice_set_dflt_vsi_ctx(struct ice_vsi_ctx *ctxt) ctxt->info.sw_flags =ICE_AQ_VSI_SW_FLAG_SRC_PRUNE ;/* Traffic from VSI can be sent to LAN */ ctxt->info.sw_flags2 =ICE_AQ_VSI_SW_FLAG_LAN_ENA ; -/* Allow all packets untagged/tagged */ +/* By default bits 3 and 4 in port_vlan_flags are 0's which results in +* legacy behavior (show VLAN, DEI, and UP) in descriptor. Also, allow +* all packets untagged/tagged. +*/ ctxt->info.port_vlan_flags = ((ICE_AQ_VSI_PVLAN_MODE_ALL &ICE_AQ_VSI_PVLAN_MODE_M ) >>ICE_AQ_VSI_PVLAN_MODE_S ); -/* Show VLAN/UP from packets in Rx descriptors */ - ctxt->info.port_vlan_flags |= ((ICE_AQ_VSI_PVLAN_EMOD_STR_BOTH & -ICE_AQ_VSI_PVLAN_EMOD_M ) >> -ICE_AQ_VSI_PVLAN_EMOD_S );/* Have 1:1 UP mapping for both ingress/egress tables */ table |=ICE_UP_TABLE_TRANSLATE (0 ,0 ); table |=ICE_UP_TABLE_TRANSLATE (1 ,1 );
Signature · 1 line
2.14.3
PATCH v2 9/13 ice: Set VLAN flags correctly
In reply to Anirudh VenkataramananFrom: Brett Creeley <[email protected]>
Set the ICE_AQ_VSI_PVLAN_MODE_ALL bit to allow the driver to add a VLAN tag to all packets it sends.
---
[Anirudh Venkataramanan <[email protected]> cleaned up commit message]
--- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +3 -0
@@ -3779,6 +3779,9 @@ static int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena) ctxt.info.port_vlan_flags =ICE_AQ_VSI_PVLAN_EMOD_NOTHING ; } +/* Allow all packets untagged/tagged */ + ctxt.info.port_vlan_flags |=ICE_AQ_VSI_PVLAN_MODE_ALL ; + ctxt.info.valid_sections =cpu_to_le16 (ICE_AQ_VSI_PROP_VLAN_VALID ); ctxt.vsi_num = vsi->vsi_num;
Signature · 1 line
2.14.3
PATCH v2 10/13 ice: Update to interrupts enabled in OICR
In reply to Anirudh VenkataramananFrom: Bruce Allan <[email protected]>
Remove the following interrupt causes that are not applicable or not handled:
- PFINT_OICR_HLP_RDY_M
- PFINT_OICR_CPM_RDY_M
- PFINT_OICR_GPIO_M
- PFINT_OICR_STORM_DETECT_M
Add the following interrupt cause that's actually handled in ice_misc_intr:
- PFINT_OICR_PE_CRITERR_M
---
[Anirudh Venkataramanan <[email protected]> Removed defines from ice_hw_autogen.h]
--- drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 8 -------- drivers/net/ethernet/intel/ice/ice_main.c | 9 +++------ 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +0 -8
@@ -121,10 +121,6 @@#define PFINT_FW_CTL_CAUSE_ENA_S 30#define PFINT_FW_CTL_CAUSE_ENA_M BIT(PFINT_FW_CTL_CAUSE_ENA_S)#define PFINT_OICR 0x0016CA00 -#define PFINT_OICR_HLP_RDY_S 14 -#define PFINT_OICR_HLP_RDY_M BIT(PFINT_OICR_HLP_RDY_S) -#define PFINT_OICR_CPM_RDY_S 15 -#define PFINT_OICR_CPM_RDY_M BIT(PFINT_OICR_CPM_RDY_S)#define PFINT_OICR_ECC_ERR_S 16#define PFINT_OICR_ECC_ERR_M BIT(PFINT_OICR_ECC_ERR_S)#define PFINT_OICR_MAL_DETECT_S 19
@@ -133,10 +129,6 @@#define PFINT_OICR_GRST_M BIT(PFINT_OICR_GRST_S)#define PFINT_OICR_PCI_EXCEPTION_S 21#define PFINT_OICR_PCI_EXCEPTION_M BIT(PFINT_OICR_PCI_EXCEPTION_S) -#define PFINT_OICR_GPIO_S 22 -#define PFINT_OICR_GPIO_M BIT(PFINT_OICR_GPIO_S) -#define PFINT_OICR_STORM_DETECT_S 24 -#define PFINT_OICR_STORM_DETECT_M BIT(PFINT_OICR_STORM_DETECT_S)#define PFINT_OICR_HMC_ERR_S 26#define PFINT_OICR_HMC_ERR_M BIT(PFINT_OICR_HMC_ERR_S)#define PFINT_OICR_PE_CRITERR_S 28
drivers/net/ethernet/intel/ice/ice_main.c +3 -6
@@ -1702,15 +1702,12 @@ static void ice_ena_misc_vector(struct ice_pf *pf)wr32 (hw,PFINT_OICR_ENA ,0 );/* disable all */ rd32 (hw,PFINT_OICR );/* read to clear */ - val = (PFINT_OICR_HLP_RDY_M | -PFINT_OICR_CPM_RDY_M | -PFINT_OICR_ECC_ERR_M | + val = (PFINT_OICR_ECC_ERR_M |PFINT_OICR_MAL_DETECT_M |PFINT_OICR_GRST_M |PFINT_OICR_PCI_EXCEPTION_M | -PFINT_OICR_GPIO_M | -PFINT_OICR_STORM_DETECT_M | -PFINT_OICR_HMC_ERR_M ); +PFINT_OICR_HMC_ERR_M | +PFINT_OICR_PE_CRITERR_M );wr32 (hw,PFINT_OICR_ENA , val);
Signature · 1 line
2.14.3
PATCH v2 11/13 ice: Fix couple of null pointer dereference issues
In reply to Anirudh VenkataramananWhen ice_ena_msix_range() fails to reserve vectors, a devm_kfree() warning was seen in the error flow path. So check pf->irq_tracker before use in ice_clear_interrupt_scheme().
In ice_vsi_cfg(), check vsi->netdev before use.
--- drivers/net/ethernet/intel/ice/ice_main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +10 -7
@@ -3259,8 +3259,10 @@ static void ice_clear_interrupt_scheme(struct ice_pf *pf)if (test_bit (ICE_FLAG_MSIX_ENA , pf->flags))ice_dis_msix (pf); -devm_kfree (&pf->pdev->dev, pf->irq_tracker); - pf->irq_tracker =NULL ; +if (pf->irq_tracker) { +devm_kfree (&pf->pdev->dev, pf->irq_tracker); + pf->irq_tracker =NULL ; + } }/**
@@ -4114,11 +4116,12 @@ static int ice_vsi_cfg(struct ice_vsi *vsi) {int err; -ice_set_rx_mode (vsi->netdev); - - err =ice_restore_vlan (vsi); -if (err) -return err; +if (vsi->netdev) { +ice_set_rx_mode (vsi->netdev); + err =ice_restore_vlan (vsi); +if (err) +return err; + } err =ice_vsi_cfg_txqs (vsi);if (!err)
Signature · 1 line
2.14.3
PATCH v2 12/13 ice: Fix potential return of uninitialized value
In reply to Anirudh VenkataramananFrom: Jesse Brandeburg <[email protected]>
In ice_vsi_setup_[tx|rx]_rings, err is uninitialized which can result in a garbage value return to the caller. Fix that.
---
[Anirudh Venkataramanan <[email protected]> cleaned up commit message]
--- drivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -4887,7 +4887,7 @@ int ice_down(struct ice_vsi *vsi)*/ static int ice_vsi_setup_tx_rings (struct ice_vsi *vsi) { -int i, err; +int i, err =0 ;if (!vsi->num_txq) { dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Tx queues\n",
@@ -4912,7 +4912,7 @@ static int ice_vsi_setup_tx_rings(struct ice_vsi *vsi)*/ static int ice_vsi_setup_rx_rings (struct ice_vsi *vsi) { -int i, err; +int i, err =0 ;if (!vsi->num_rxq) { dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Rx queues\n",
Signature · 1 line
2.14.3
PATCH v2 13/13 ice: Change struct members from bool to u8
In reply to Anirudh VenkataramananFrom: Bruce Allan <[email protected]>
Recent versions of checkpatch have a new warning based on a documented preference of Linus to not use bool in structures due to wasted space and the size of bool is implementation dependent. For more information, see the email thread at https://lkml.org/lkml/2017/11/21/384.
--- drivers/net/ethernet/intel/ice/ice.h | 8 ++++---- drivers/net/ethernet/intel/ice/ice_switch.h | 6 +++--- drivers/net/ethernet/intel/ice/ice_txrx.h | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +4 -4
@@ -196,9 +196,9 @@ struct ice_vsi {struct list_head tmp_sync_list;/* MAC filters to be synced */ struct list_head tmp_unsync_list;/* MAC filters to be unsynced */ -bool irqs_ready; -bool current_isup;/* Sync 'link up' logging */ -bool stat_offsets_loaded; +u8 irqs_ready; +u8 current_isup;/* Sync 'link up' logging */ +u8 stat_offsets_loaded;/* queue information */ u8 tx_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */
@@ -269,7 +269,7 @@ struct ice_pf {struct ice_hw_port_stats stats;struct ice_hw_port_stats stats_prev;struct ice_hw hw; -bool stat_prev_loaded;/* has previous stats been loaded */ +u8 stat_prev_loaded;/* has previous stats been loaded */ char int_name[ICE_INT_NAME_STR_LEN ]; };
drivers/net/ethernet/intel/ice/ice_switch.h +3 -3
@@ -17,7 +17,7 @@ struct ice_vsi_ctx {u16 vsis_unallocated;u16 flags;struct ice_aqc_vsi_props info; -bool alloc_from_pool; +u8 alloc_from_pool; };enum ice_sw_fwd_act_type {
@@ -94,8 +94,8 @@ struct ice_fltr_info {u8 qgrp_size;/* Rule creations populate these indicators basing on the switch type */ -bool lb_en;/* Indicate if packet can be looped back */ -bool lan_en;/* Indicate if packet can be forwarded to the uplink */ +u8 lb_en;/* Indicate if packet can be looped back */ +u8 lan_en;/* Indicate if packet can be forwarded to the uplink */ };/* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
drivers/net/ethernet/intel/ice/ice_txrx.h +1 -1
@@ -143,7 +143,7 @@ struct ice_ring {u16 next_to_use;u16 next_to_clean; -bool ring_active;/* is ring online or not */ +u8 ring_active;/* is ring online or not */ /* stats structs */ struct ice_q_stats stats;
drivers/net/ethernet/intel/ice/ice_type.h +8 -8
@@ -83,7 +83,7 @@ struct ice_link_status {u64 phy_type_low;u16 max_frame_size;u16 link_speed; -bool lse_ena;/* Link Status Event notification */ +u8 lse_ena;/* Link Status Event notification */ u8 link_info;u8 an_info;u8 ext_info;
@@ -101,7 +101,7 @@ struct ice_phy_info {struct ice_link_status link_info_old;u64 phy_type_low;enum ice_media_type media_type; -bool get_link_info; +u8 get_link_info; };/* Common HW capabilities for SW use */
@@ -167,7 +167,7 @@ struct ice_nvm_info {u32 oem_ver;/* OEM version info */ u16 sr_words;/* Shadow RAM size in words */ u16 ver;/* NVM package version */ -bool blank_nvm_mode;/* is NVM empty (no FW present) */ +u8 blank_nvm_mode;/* is NVM empty (no FW present) */ };/* Max number of port to queue branches w.r.t topology */
@@ -181,7 +181,7 @@ struct ice_sched_node {struct ice_aqc_txsched_elem_data info;u32 agg_id;/* aggregator group id */ u16 vsi_id; -bool in_use;/* suspended or in use */ +u8 in_use;/* suspended or in use */ u8 tx_sched_layer;/* Logical Layer (1-9) */ u8 num_children;u8 tc_num;
@@ -218,7 +218,7 @@ struct ice_sched_vsi_info {struct ice_sched_tx_policy {u16 max_num_vsis;u8 max_num_lan_qs_per_tc[ICE_MAX_TRAFFIC_CLASS ]; -bool rdma_ena; +u8 rdma_ena; };struct ice_port_info {
@@ -243,7 +243,7 @@ struct ice_port_info {struct list_head agg_list;/* lists all aggregator */ u8 lport;#define ICE_LPORT_MASK 0xff -bool is_vf; +u8 is_vf; };struct ice_switch_info {
@@ -287,7 +287,7 @@ struct ice_hw {u8 max_cgds;u8 sw_entry_point_layer; -bool evb_veb;/* true for VEB, false for VEPA */ +u8 evb_veb;/* true for VEB, false for VEPA */ struct ice_bus_info bus;struct ice_nvm_info nvm;struct ice_hw_dev_caps dev_caps;/* device capabilities */
@@ -318,7 +318,7 @@ struct ice_hw {u8 itr_gran_100;u8 itr_gran_50;u8 itr_gran_25; -bool ucast_shared;/* true if VSIs can share unicast addr */ +u8 ucast_shared;/* true if VSIs can share unicast addr */ };
Signature · 1 line
2.14.3