Commit 62589808 authored by Jesse Brandeburg's avatar Jesse Brandeburg Committed by Tony Nguyen

i40e: field get conversion

Refactor the i40e driver to use FIELD_GET() for mask and shift reads,
which reduces lines of code and adds clarity of intent.

This code was generated by the following coccinelle/spatch script and
then manually repaired.

While making one of the conversions, an if() check was inverted to
return early and avoid un-necessary indentation of the remainder of the
function. In some other cases a stack variable was moved inside the
block where it was used while doing cleanups/review.

A couple places were changed to use le16_get_bits() instead of FIELD_GET
with a le16_to_cpu combination.

@get@
constant shift,mask;
metavariable type T;
expression a;
@@
-(((T)(a) & mask) >> shift)
+FIELD_GET(mask, a)

and applied via:
spatch --sp-file field_prep.cocci --in-place --dir \
 drivers/net/ethernet/intel/

Cc: Julia Lawall <Julia.Lawall@inria.fr>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: default avatarMarcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent a8e0c7a6
...@@ -664,11 +664,11 @@ int i40e_init_shared_code(struct i40e_hw *hw) ...@@ -664,11 +664,11 @@ int i40e_init_shared_code(struct i40e_hw *hw)
hw->phy.get_link_info = true; hw->phy.get_link_info = true;
/* Determine port number and PF number*/ /* Determine port number and PF number*/
port = (rd32(hw, I40E_PFGEN_PORTNUM) & I40E_PFGEN_PORTNUM_PORT_NUM_MASK) port = FIELD_GET(I40E_PFGEN_PORTNUM_PORT_NUM_MASK,
>> I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT; rd32(hw, I40E_PFGEN_PORTNUM));
hw->port = (u8)port; hw->port = (u8)port;
ari = (rd32(hw, I40E_GLPCI_CAPSUP) & I40E_GLPCI_CAPSUP_ARI_EN_MASK) >> ari = FIELD_GET(I40E_GLPCI_CAPSUP_ARI_EN_MASK,
I40E_GLPCI_CAPSUP_ARI_EN_SHIFT; rd32(hw, I40E_GLPCI_CAPSUP));
func_rid = rd32(hw, I40E_PF_FUNC_RID); func_rid = rd32(hw, I40E_PF_FUNC_RID);
if (ari) if (ari)
hw->pf_id = (u8)(func_rid & 0xff); hw->pf_id = (u8)(func_rid & 0xff);
...@@ -986,9 +986,8 @@ int i40e_pf_reset(struct i40e_hw *hw) ...@@ -986,9 +986,8 @@ int i40e_pf_reset(struct i40e_hw *hw)
* The grst delay value is in 100ms units, and we'll wait a * The grst delay value is in 100ms units, and we'll wait a
* couple counts longer to be sure we don't just miss the end. * couple counts longer to be sure we don't just miss the end.
*/ */
grst_del = (rd32(hw, I40E_GLGEN_RSTCTL) & grst_del = FIELD_GET(I40E_GLGEN_RSTCTL_GRSTDEL_MASK,
I40E_GLGEN_RSTCTL_GRSTDEL_MASK) >> rd32(hw, I40E_GLGEN_RSTCTL));
I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
/* It can take upto 15 secs for GRST steady state. /* It can take upto 15 secs for GRST steady state.
* Bump it to 16 secs max to be safe. * Bump it to 16 secs max to be safe.
...@@ -1080,26 +1079,20 @@ void i40e_clear_hw(struct i40e_hw *hw) ...@@ -1080,26 +1079,20 @@ void i40e_clear_hw(struct i40e_hw *hw)
/* get number of interrupts, queues, and VFs */ /* get number of interrupts, queues, and VFs */
val = rd32(hw, I40E_GLPCI_CNF2); val = rd32(hw, I40E_GLPCI_CNF2);
num_pf_int = (val & I40E_GLPCI_CNF2_MSI_X_PF_N_MASK) >> num_pf_int = FIELD_GET(I40E_GLPCI_CNF2_MSI_X_PF_N_MASK, val);
I40E_GLPCI_CNF2_MSI_X_PF_N_SHIFT; num_vf_int = FIELD_GET(I40E_GLPCI_CNF2_MSI_X_VF_N_MASK, val);
num_vf_int = (val & I40E_GLPCI_CNF2_MSI_X_VF_N_MASK) >>
I40E_GLPCI_CNF2_MSI_X_VF_N_SHIFT;
val = rd32(hw, I40E_PFLAN_QALLOC); val = rd32(hw, I40E_PFLAN_QALLOC);
base_queue = (val & I40E_PFLAN_QALLOC_FIRSTQ_MASK) >> base_queue = FIELD_GET(I40E_PFLAN_QALLOC_FIRSTQ_MASK, val);
I40E_PFLAN_QALLOC_FIRSTQ_SHIFT; j = FIELD_GET(I40E_PFLAN_QALLOC_LASTQ_MASK, val);
j = (val & I40E_PFLAN_QALLOC_LASTQ_MASK) >>
I40E_PFLAN_QALLOC_LASTQ_SHIFT;
if (val & I40E_PFLAN_QALLOC_VALID_MASK && j >= base_queue) if (val & I40E_PFLAN_QALLOC_VALID_MASK && j >= base_queue)
num_queues = (j - base_queue) + 1; num_queues = (j - base_queue) + 1;
else else
num_queues = 0; num_queues = 0;
val = rd32(hw, I40E_PF_VT_PFALLOC); val = rd32(hw, I40E_PF_VT_PFALLOC);
i = (val & I40E_PF_VT_PFALLOC_FIRSTVF_MASK) >> i = FIELD_GET(I40E_PF_VT_PFALLOC_FIRSTVF_MASK, val);
I40E_PF_VT_PFALLOC_FIRSTVF_SHIFT; j = FIELD_GET(I40E_PF_VT_PFALLOC_LASTVF_MASK, val);
j = (val & I40E_PF_VT_PFALLOC_LASTVF_MASK) >>
I40E_PF_VT_PFALLOC_LASTVF_SHIFT;
if (val & I40E_PF_VT_PFALLOC_VALID_MASK && j >= i) if (val & I40E_PF_VT_PFALLOC_VALID_MASK && j >= i)
num_vfs = (j - i) + 1; num_vfs = (j - i) + 1;
else else
...@@ -1194,8 +1187,7 @@ static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx) ...@@ -1194,8 +1187,7 @@ static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx)
!hw->func_caps.led[idx]) !hw->func_caps.led[idx])
return 0; return 0;
gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx)); gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx));
port = (gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK) >> port = FIELD_GET(I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK, gpio_val);
I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT;
/* if PRT_NUM_NA is 1 then this LED is not port specific, OR /* if PRT_NUM_NA is 1 then this LED is not port specific, OR
* if it is not our port then ignore * if it is not our port then ignore
...@@ -1239,8 +1231,7 @@ u32 i40e_led_get(struct i40e_hw *hw) ...@@ -1239,8 +1231,7 @@ u32 i40e_led_get(struct i40e_hw *hw)
if (!gpio_val) if (!gpio_val)
continue; continue;
mode = (gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >> mode = FIELD_GET(I40E_GLGEN_GPIO_CTL_LED_MODE_MASK, gpio_val);
I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT;
break; break;
} }
...@@ -4190,8 +4181,7 @@ i40e_validate_filter_settings(struct i40e_hw *hw, ...@@ -4190,8 +4181,7 @@ i40e_validate_filter_settings(struct i40e_hw *hw,
/* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */ /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */
val = rd32(hw, I40E_GLHMC_FCOEFMAX); val = rd32(hw, I40E_GLHMC_FCOEFMAX);
fcoe_fmax = (val & I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK) fcoe_fmax = FIELD_GET(I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK, val);
>> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT;
if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax) if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax)
return -EINVAL; return -EINVAL;
...@@ -4646,8 +4636,7 @@ int i40e_read_phy_register_clause22(struct i40e_hw *hw, ...@@ -4646,8 +4636,7 @@ int i40e_read_phy_register_clause22(struct i40e_hw *hw,
"PHY: Can't write command to external PHY.\n"); "PHY: Can't write command to external PHY.\n");
} else { } else {
command = rd32(hw, I40E_GLGEN_MSRWD(port_num)); command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
*value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >> *value = FIELD_GET(I40E_GLGEN_MSRWD_MDIRDDATA_MASK, command);
I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
} }
return status; return status;
...@@ -4756,8 +4745,7 @@ int i40e_read_phy_register_clause45(struct i40e_hw *hw, ...@@ -4756,8 +4745,7 @@ int i40e_read_phy_register_clause45(struct i40e_hw *hw,
if (!status) { if (!status) {
command = rd32(hw, I40E_GLGEN_MSRWD(port_num)); command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
*value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >> *value = FIELD_GET(I40E_GLGEN_MSRWD_MDIRDDATA_MASK, command);
I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
} else { } else {
i40e_debug(hw, I40E_DEBUG_PHY, i40e_debug(hw, I40E_DEBUG_PHY,
"PHY: Can't read register value from external PHY.\n"); "PHY: Can't read register value from external PHY.\n");
...@@ -5902,9 +5890,8 @@ i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid, ...@@ -5902,9 +5890,8 @@ i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
u16 tnl_type; u16 tnl_type;
u32 ti; u32 ti;
tnl_type = (le16_to_cpu(filters[i].element.flags) & tnl_type = le16_get_bits(filters[i].element.flags,
I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >> I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK);
I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
/* Due to hardware eccentricities, the VNI for Geneve is shifted /* Due to hardware eccentricities, the VNI for Geneve is shifted
* one more byte further than normally used for Tenant ID in * one more byte further than normally used for Tenant ID in
...@@ -5996,9 +5983,8 @@ i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid, ...@@ -5996,9 +5983,8 @@ i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
u16 tnl_type; u16 tnl_type;
u32 ti; u32 ti;
tnl_type = (le16_to_cpu(filters[i].element.flags) & tnl_type = le16_get_bits(filters[i].element.flags,
I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >> I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK);
I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
/* Due to hardware eccentricities, the VNI for Geneve is shifted /* Due to hardware eccentricities, the VNI for Geneve is shifted
* one more byte further than normally used for Tenant ID in * one more byte further than normally used for Tenant ID in
......
This diff is collapsed.
...@@ -21,8 +21,7 @@ static void i40e_get_pfc_delay(struct i40e_hw *hw, u16 *delay) ...@@ -21,8 +21,7 @@ static void i40e_get_pfc_delay(struct i40e_hw *hw, u16 *delay)
u32 val; u32 val;
val = rd32(hw, I40E_PRTDCB_GENC); val = rd32(hw, I40E_PRTDCB_GENC);
*delay = (u16)((val & I40E_PRTDCB_GENC_PFCLDA_MASK) >> *delay = FIELD_GET(I40E_PRTDCB_GENC_PFCLDA_MASK, val);
I40E_PRTDCB_GENC_PFCLDA_SHIFT);
} }
/** /**
......
...@@ -81,8 +81,8 @@ static int i40e_ddp_does_profile_exist(struct i40e_hw *hw, ...@@ -81,8 +81,8 @@ static int i40e_ddp_does_profile_exist(struct i40e_hw *hw,
static bool i40e_ddp_profiles_overlap(struct i40e_profile_info *new, static bool i40e_ddp_profiles_overlap(struct i40e_profile_info *new,
struct i40e_profile_info *old) struct i40e_profile_info *old)
{ {
unsigned int group_id_old = (u8)((old->track_id & 0x00FF0000) >> 16); unsigned int group_id_old = FIELD_GET(0x00FF0000, old->track_id);
unsigned int group_id_new = (u8)((new->track_id & 0x00FF0000) >> 16); unsigned int group_id_new = FIELD_GET(0x00FF0000, new->track_id);
/* 0x00 group must be only the first */ /* 0x00 group must be only the first */
if (group_id_new == 0) if (group_id_new == 0)
......
...@@ -1952,9 +1952,8 @@ static int i40e_get_eeprom_len(struct net_device *netdev) ...@@ -1952,9 +1952,8 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
val = X722_EEPROM_SCOPE_LIMIT + 1; val = X722_EEPROM_SCOPE_LIMIT + 1;
return val; return val;
} }
val = (rd32(hw, I40E_GLPCI_LBARCTRL) val = FIELD_GET(I40E_GLPCI_LBARCTRL_FL_SIZE_MASK,
& I40E_GLPCI_LBARCTRL_FL_SIZE_MASK) rd32(hw, I40E_GLPCI_LBARCTRL));
>> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
/* register returns value in power of 2, 64Kbyte chunks. */ /* register returns value in power of 2, 64Kbyte chunks. */
val = (64 * 1024) * BIT(val); val = (64 * 1024) * BIT(val);
return val; return val;
...@@ -3284,7 +3283,7 @@ static int i40e_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp, ...@@ -3284,7 +3283,7 @@ static int i40e_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,
} else if (valid) { } else if (valid) {
data->flex_word = value & I40E_USERDEF_FLEX_WORD; data->flex_word = value & I40E_USERDEF_FLEX_WORD;
data->flex_offset = data->flex_offset =
(value & I40E_USERDEF_FLEX_OFFSET) >> 16; FIELD_GET(I40E_USERDEF_FLEX_OFFSET, value);
data->flex_filter = true; data->flex_filter = true;
} }
......
...@@ -1197,11 +1197,9 @@ static void i40e_update_pf_stats(struct i40e_pf *pf) ...@@ -1197,11 +1197,9 @@ static void i40e_update_pf_stats(struct i40e_pf *pf)
val = rd32(hw, I40E_PRTPM_EEE_STAT); val = rd32(hw, I40E_PRTPM_EEE_STAT);
nsd->tx_lpi_status = nsd->tx_lpi_status =
(val & I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK) >> FIELD_GET(I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK, val);
I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_SHIFT;
nsd->rx_lpi_status = nsd->rx_lpi_status =
(val & I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK) >> FIELD_GET(I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK, val);
I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_SHIFT;
i40e_stat_update32(hw, I40E_PRTPM_TLPIC, i40e_stat_update32(hw, I40E_PRTPM_TLPIC,
pf->stat_offsets_loaded, pf->stat_offsets_loaded,
&osd->tx_lpi_count, &nsd->tx_lpi_count); &osd->tx_lpi_count, &nsd->tx_lpi_count);
...@@ -4340,8 +4338,7 @@ static irqreturn_t i40e_intr(int irq, void *data) ...@@ -4340,8 +4338,7 @@ static irqreturn_t i40e_intr(int irq, void *data)
set_bit(__I40E_RESET_INTR_RECEIVED, pf->state); set_bit(__I40E_RESET_INTR_RECEIVED, pf->state);
ena_mask &= ~I40E_PFINT_ICR0_ENA_GRST_MASK; ena_mask &= ~I40E_PFINT_ICR0_ENA_GRST_MASK;
val = rd32(hw, I40E_GLGEN_RSTAT); val = rd32(hw, I40E_GLGEN_RSTAT);
val = (val & I40E_GLGEN_RSTAT_RESET_TYPE_MASK) val = FIELD_GET(I40E_GLGEN_RSTAT_RESET_TYPE_MASK, val);
>> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT;
if (val == I40E_RESET_CORER) { if (val == I40E_RESET_CORER) {
pf->corer_count++; pf->corer_count++;
} else if (val == I40E_RESET_GLOBR) { } else if (val == I40E_RESET_GLOBR) {
...@@ -5003,8 +5000,8 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi) ...@@ -5003,8 +5000,8 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi)
* next_q field of the registers. * next_q field of the registers.
*/ */
val = rd32(hw, I40E_PFINT_LNKLSTN(vector - 1)); val = rd32(hw, I40E_PFINT_LNKLSTN(vector - 1));
qp = (val & I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK) qp = FIELD_GET(I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK,
>> I40E_PFINT_LNKLSTN_FIRSTQ_INDX_SHIFT; val);
val |= I40E_QUEUE_END_OF_LIST val |= I40E_QUEUE_END_OF_LIST
<< I40E_PFINT_LNKLSTN_FIRSTQ_INDX_SHIFT; << I40E_PFINT_LNKLSTN_FIRSTQ_INDX_SHIFT;
wr32(hw, I40E_PFINT_LNKLSTN(vector - 1), val); wr32(hw, I40E_PFINT_LNKLSTN(vector - 1), val);
...@@ -5026,8 +5023,8 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi) ...@@ -5026,8 +5023,8 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi)
val = rd32(hw, I40E_QINT_TQCTL(qp)); val = rd32(hw, I40E_QINT_TQCTL(qp));
next = (val & I40E_QINT_TQCTL_NEXTQ_INDX_MASK) next = FIELD_GET(I40E_QINT_TQCTL_NEXTQ_INDX_MASK,
>> I40E_QINT_TQCTL_NEXTQ_INDX_SHIFT; val);
val &= ~(I40E_QINT_TQCTL_MSIX_INDX_MASK | val &= ~(I40E_QINT_TQCTL_MSIX_INDX_MASK |
I40E_QINT_TQCTL_MSIX0_INDX_MASK | I40E_QINT_TQCTL_MSIX0_INDX_MASK |
...@@ -5045,8 +5042,7 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi) ...@@ -5045,8 +5042,7 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi)
free_irq(pf->pdev->irq, pf); free_irq(pf->pdev->irq, pf);
val = rd32(hw, I40E_PFINT_LNKLST0); val = rd32(hw, I40E_PFINT_LNKLST0);
qp = (val & I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK) qp = FIELD_GET(I40E_PFINT_LNKLSTN_FIRSTQ_INDX_MASK, val);
>> I40E_PFINT_LNKLSTN_FIRSTQ_INDX_SHIFT;
val |= I40E_QUEUE_END_OF_LIST val |= I40E_QUEUE_END_OF_LIST
<< I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT; << I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT;
wr32(hw, I40E_PFINT_LNKLST0, val); wr32(hw, I40E_PFINT_LNKLST0, val);
...@@ -9549,18 +9545,18 @@ static void i40e_handle_lan_overflow_event(struct i40e_pf *pf, ...@@ -9549,18 +9545,18 @@ static void i40e_handle_lan_overflow_event(struct i40e_pf *pf,
dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n", dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n",
queue, qtx_ctl); queue, qtx_ctl);
if (FIELD_GET(I40E_QTX_CTL_PFVF_Q_MASK, qtx_ctl) !=
I40E_QTX_CTL_VF_QUEUE)
return;
/* Queue belongs to VF, find the VF and issue VF reset */ /* Queue belongs to VF, find the VF and issue VF reset */
if (((qtx_ctl & I40E_QTX_CTL_PFVF_Q_MASK) vf_id = FIELD_GET(I40E_QTX_CTL_VFVM_INDX_MASK, qtx_ctl);
>> I40E_QTX_CTL_PFVF_Q_SHIFT) == I40E_QTX_CTL_VF_QUEUE) { vf_id -= hw->func_caps.vf_base_id;
vf_id = (u16)((qtx_ctl & I40E_QTX_CTL_VFVM_INDX_MASK) vf = &pf->vf[vf_id];
>> I40E_QTX_CTL_VFVM_INDX_SHIFT); i40e_vc_notify_vf_reset(vf);
vf_id -= hw->func_caps.vf_base_id; /* Allow VF to process pending reset notification */
vf = &pf->vf[vf_id]; msleep(20);
i40e_vc_notify_vf_reset(vf); i40e_reset_vf(vf, false);
/* Allow VF to process pending reset notification */
msleep(20);
i40e_reset_vf(vf, false);
}
} }
/** /**
...@@ -9586,8 +9582,7 @@ u32 i40e_get_current_fd_count(struct i40e_pf *pf) ...@@ -9586,8 +9582,7 @@ u32 i40e_get_current_fd_count(struct i40e_pf *pf)
val = rd32(&pf->hw, I40E_PFQF_FDSTAT); val = rd32(&pf->hw, I40E_PFQF_FDSTAT);
fcnt_prog = (val & I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) + fcnt_prog = (val & I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) +
((val & I40E_PFQF_FDSTAT_BEST_CNT_MASK) >> FIELD_GET(I40E_PFQF_FDSTAT_BEST_CNT_MASK, val);
I40E_PFQF_FDSTAT_BEST_CNT_SHIFT);
return fcnt_prog; return fcnt_prog;
} }
...@@ -9601,8 +9596,7 @@ u32 i40e_get_global_fd_count(struct i40e_pf *pf) ...@@ -9601,8 +9596,7 @@ u32 i40e_get_global_fd_count(struct i40e_pf *pf)
val = rd32(&pf->hw, I40E_GLQF_FDCNT_0); val = rd32(&pf->hw, I40E_GLQF_FDCNT_0);
fcnt_prog = (val & I40E_GLQF_FDCNT_0_GUARANT_CNT_MASK) + fcnt_prog = (val & I40E_GLQF_FDCNT_0_GUARANT_CNT_MASK) +
((val & I40E_GLQF_FDCNT_0_BESTCNT_MASK) >> FIELD_GET(I40E_GLQF_FDCNT_0_BESTCNT_MASK, val);
I40E_GLQF_FDCNT_0_BESTCNT_SHIFT);
return fcnt_prog; return fcnt_prog;
} }
...@@ -11184,14 +11178,10 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf) ...@@ -11184,14 +11178,10 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
/* find what triggered the MDD event */ /* find what triggered the MDD event */
reg = rd32(hw, I40E_GL_MDET_TX); reg = rd32(hw, I40E_GL_MDET_TX);
if (reg & I40E_GL_MDET_TX_VALID_MASK) { if (reg & I40E_GL_MDET_TX_VALID_MASK) {
u8 pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> u8 pf_num = FIELD_GET(I40E_GL_MDET_TX_PF_NUM_MASK, reg);
I40E_GL_MDET_TX_PF_NUM_SHIFT; u16 vf_num = FIELD_GET(I40E_GL_MDET_TX_VF_NUM_MASK, reg);
u16 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> u8 event = FIELD_GET(I40E_GL_MDET_TX_EVENT_MASK, reg);
I40E_GL_MDET_TX_VF_NUM_SHIFT; u16 queue = FIELD_GET(I40E_GL_MDET_TX_QUEUE_MASK, reg) -
u8 event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
I40E_GL_MDET_TX_EVENT_SHIFT;
u16 queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
I40E_GL_MDET_TX_QUEUE_SHIFT) -
pf->hw.func_caps.base_queue; pf->hw.func_caps.base_queue;
if (netif_msg_tx_err(pf)) if (netif_msg_tx_err(pf))
dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on TX queue %d PF number 0x%02x VF number 0x%02x\n", dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on TX queue %d PF number 0x%02x VF number 0x%02x\n",
...@@ -11201,12 +11191,9 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf) ...@@ -11201,12 +11191,9 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
} }
reg = rd32(hw, I40E_GL_MDET_RX); reg = rd32(hw, I40E_GL_MDET_RX);
if (reg & I40E_GL_MDET_RX_VALID_MASK) { if (reg & I40E_GL_MDET_RX_VALID_MASK) {
u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> u8 func = FIELD_GET(I40E_GL_MDET_RX_FUNCTION_MASK, reg);
I40E_GL_MDET_RX_FUNCTION_SHIFT; u8 event = FIELD_GET(I40E_GL_MDET_RX_EVENT_MASK, reg);
u8 event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> u16 queue = FIELD_GET(I40E_GL_MDET_RX_QUEUE_MASK, reg) -
I40E_GL_MDET_RX_EVENT_SHIFT;
u16 queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
I40E_GL_MDET_RX_QUEUE_SHIFT) -
pf->hw.func_caps.base_queue; pf->hw.func_caps.base_queue;
if (netif_msg_rx_err(pf)) if (netif_msg_rx_err(pf))
dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02x\n", dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02x\n",
...@@ -16170,8 +16157,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -16170,8 +16157,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* make sure the MFS hasn't been set lower than the default */ /* make sure the MFS hasn't been set lower than the default */
#define MAX_FRAME_SIZE_DEFAULT 0x2600 #define MAX_FRAME_SIZE_DEFAULT 0x2600
val = (rd32(&pf->hw, I40E_PRTGL_SAH) & val = FIELD_GET(I40E_PRTGL_SAH_MFS_MASK,
I40E_PRTGL_SAH_MFS_MASK) >> I40E_PRTGL_SAH_MFS_SHIFT; rd32(&pf->hw, I40E_PRTGL_SAH));
if (val < MAX_FRAME_SIZE_DEFAULT) if (val < MAX_FRAME_SIZE_DEFAULT)
dev_warn(&pdev->dev, "MFS for port %x has been set below the default: %x\n", dev_warn(&pdev->dev, "MFS for port %x has been set below the default: %x\n",
pf->hw.port, val); pf->hw.port, val);
......
...@@ -27,8 +27,7 @@ int i40e_init_nvm(struct i40e_hw *hw) ...@@ -27,8 +27,7 @@ int i40e_init_nvm(struct i40e_hw *hw)
* as the blank mode may be used in the factory line. * as the blank mode may be used in the factory line.
*/ */
gens = rd32(hw, I40E_GLNVM_GENS); gens = rd32(hw, I40E_GLNVM_GENS);
sr_size = ((gens & I40E_GLNVM_GENS_SR_SIZE_MASK) >> sr_size = FIELD_GET(I40E_GLNVM_GENS_SR_SIZE_MASK, gens);
I40E_GLNVM_GENS_SR_SIZE_SHIFT);
/* Switching to words (sr_size contains power of 2KB) */ /* Switching to words (sr_size contains power of 2KB) */
nvm->sr_size = BIT(sr_size) * I40E_SR_WORDS_IN_1KB; nvm->sr_size = BIT(sr_size) * I40E_SR_WORDS_IN_1KB;
...@@ -194,9 +193,8 @@ static int i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset, ...@@ -194,9 +193,8 @@ static int i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset,
ret_code = i40e_poll_sr_srctl_done_bit(hw); ret_code = i40e_poll_sr_srctl_done_bit(hw);
if (!ret_code) { if (!ret_code) {
sr_reg = rd32(hw, I40E_GLNVM_SRDATA); sr_reg = rd32(hw, I40E_GLNVM_SRDATA);
*data = (u16)((sr_reg & *data = FIELD_GET(I40E_GLNVM_SRDATA_RDDATA_MASK,
I40E_GLNVM_SRDATA_RDDATA_MASK) sr_reg);
>> I40E_GLNVM_SRDATA_RDDATA_SHIFT);
} }
} }
if (ret_code) if (ret_code)
...@@ -772,13 +770,12 @@ static inline u8 i40e_nvmupd_get_module(u32 val) ...@@ -772,13 +770,12 @@ static inline u8 i40e_nvmupd_get_module(u32 val)
} }
static inline u8 i40e_nvmupd_get_transaction(u32 val) static inline u8 i40e_nvmupd_get_transaction(u32 val)
{ {
return (u8)((val & I40E_NVM_TRANS_MASK) >> I40E_NVM_TRANS_SHIFT); return FIELD_GET(I40E_NVM_TRANS_MASK, val);
} }
static inline u8 i40e_nvmupd_get_preservation_flags(u32 val) static inline u8 i40e_nvmupd_get_preservation_flags(u32 val)
{ {
return (u8)((val & I40E_NVM_PRESERVATION_FLAGS_MASK) >> return FIELD_GET(I40E_NVM_PRESERVATION_FLAGS_MASK, val);
I40E_NVM_PRESERVATION_FLAGS_SHIFT);
} }
static const char * const i40e_nvm_update_state_str[] = { static const char * const i40e_nvm_update_state_str[] = {
......
...@@ -1480,8 +1480,8 @@ void i40e_ptp_init(struct i40e_pf *pf) ...@@ -1480,8 +1480,8 @@ void i40e_ptp_init(struct i40e_pf *pf)
/* Only one PF is assigned to control 1588 logic per port. Do not /* Only one PF is assigned to control 1588 logic per port. Do not
* enable any support for PFs not assigned via PRTTSYN_CTL0.PF_ID * enable any support for PFs not assigned via PRTTSYN_CTL0.PF_ID
*/ */
pf_id = (rd32(hw, I40E_PRTTSYN_CTL0) & I40E_PRTTSYN_CTL0_PF_ID_MASK) >> pf_id = FIELD_GET(I40E_PRTTSYN_CTL0_PF_ID_MASK,
I40E_PRTTSYN_CTL0_PF_ID_SHIFT; rd32(hw, I40E_PRTTSYN_CTL0));
if (hw->pf_id != pf_id) { if (hw->pf_id != pf_id) {
clear_bit(I40E_FLAG_PTP_ENA, pf->flags); clear_bit(I40E_FLAG_PTP_ENA, pf->flags);
dev_info(&pf->pdev->dev, "%s: PTP not supported on %s\n", dev_info(&pf->pdev->dev, "%s: PTP not supported on %s\n",
......
...@@ -686,8 +686,7 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring, u64 qword0_raw, ...@@ -686,8 +686,7 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring, u64 qword0_raw,
u32 error; u32 error;
qw0 = (struct i40e_16b_rx_wb_qw0 *)&qword0_raw; qw0 = (struct i40e_16b_rx_wb_qw0 *)&qword0_raw;
error = (qword1 & I40E_RX_PROG_STATUS_DESC_QW1_ERROR_MASK) >> error = FIELD_GET(I40E_RX_PROG_STATUS_DESC_QW1_ERROR_MASK, qword1);
I40E_RX_PROG_STATUS_DESC_QW1_ERROR_SHIFT;
if (error == BIT(I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT)) { if (error == BIT(I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT)) {
pf->fd_inv = le32_to_cpu(qw0->hi_dword.fd_id); pf->fd_inv = le32_to_cpu(qw0->hi_dword.fd_id);
...@@ -1398,8 +1397,7 @@ void i40e_clean_programming_status(struct i40e_ring *rx_ring, u64 qword0_raw, ...@@ -1398,8 +1397,7 @@ void i40e_clean_programming_status(struct i40e_ring *rx_ring, u64 qword0_raw,
{ {
u8 id; u8 id;
id = (qword1 & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >> id = FIELD_GET(I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK, qword1);
I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
if (id == I40E_RX_PROG_STATUS_DESC_FD_FILTER_STATUS) if (id == I40E_RX_PROG_STATUS_DESC_FD_FILTER_STATUS)
i40e_fd_handle_status(rx_ring, qword0_raw, qword1, id); i40e_fd_handle_status(rx_ring, qword0_raw, qword1, id);
...@@ -1759,11 +1757,9 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi, ...@@ -1759,11 +1757,9 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
u64 qword; u64 qword;
qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len); qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
ptype = (qword & I40E_RXD_QW1_PTYPE_MASK) >> I40E_RXD_QW1_PTYPE_SHIFT; ptype = FIELD_GET(I40E_RXD_QW1_PTYPE_MASK, qword);
rx_error = (qword & I40E_RXD_QW1_ERROR_MASK) >> rx_error = FIELD_GET(I40E_RXD_QW1_ERROR_MASK, qword);
I40E_RXD_QW1_ERROR_SHIFT; rx_status = FIELD_GET(I40E_RXD_QW1_STATUS_MASK, qword);
rx_status = (qword & I40E_RXD_QW1_STATUS_MASK) >>
I40E_RXD_QW1_STATUS_SHIFT;
decoded = decode_rx_desc_ptype(ptype); decoded = decode_rx_desc_ptype(ptype);
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
...@@ -1896,13 +1892,10 @@ void i40e_process_skb_fields(struct i40e_ring *rx_ring, ...@@ -1896,13 +1892,10 @@ void i40e_process_skb_fields(struct i40e_ring *rx_ring,
union i40e_rx_desc *rx_desc, struct sk_buff *skb) union i40e_rx_desc *rx_desc, struct sk_buff *skb)
{ {
u64 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len); u64 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
u32 rx_status = (qword & I40E_RXD_QW1_STATUS_MASK) >> u32 rx_status = FIELD_GET(I40E_RXD_QW1_STATUS_MASK, qword);
I40E_RXD_QW1_STATUS_SHIFT;
u32 tsynvalid = rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK; u32 tsynvalid = rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK;
u32 tsyn = (rx_status & I40E_RXD_QW1_STATUS_TSYNINDX_MASK) >> u32 tsyn = FIELD_GET(I40E_RXD_QW1_STATUS_TSYNINDX_MASK, rx_status);
I40E_RXD_QW1_STATUS_TSYNINDX_SHIFT; u8 rx_ptype = FIELD_GET(I40E_RXD_QW1_PTYPE_MASK, qword);
u8 rx_ptype = (qword & I40E_RXD_QW1_PTYPE_MASK) >>
I40E_RXD_QW1_PTYPE_SHIFT;
if (unlikely(tsynvalid)) if (unlikely(tsynvalid))
i40e_ptp_rx_hwtstamp(rx_ring->vsi->back, skb, tsyn); i40e_ptp_rx_hwtstamp(rx_ring->vsi->back, skb, tsyn);
...@@ -2549,8 +2542,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget, ...@@ -2549,8 +2542,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget,
continue; continue;
} }
size = (qword & I40E_RXD_QW1_LENGTH_PBUF_MASK) >> size = FIELD_GET(I40E_RXD_QW1_LENGTH_PBUF_MASK, qword);
I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
if (!size) if (!size)
break; break;
...@@ -3594,8 +3586,7 @@ static inline int i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, ...@@ -3594,8 +3586,7 @@ static inline int i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
if (tx_flags & I40E_TX_FLAGS_HW_VLAN) { if (tx_flags & I40E_TX_FLAGS_HW_VLAN) {
td_cmd |= I40E_TX_DESC_CMD_IL2TAG1; td_cmd |= I40E_TX_DESC_CMD_IL2TAG1;
td_tag = (tx_flags & I40E_TX_FLAGS_VLAN_MASK) >> td_tag = FIELD_GET(I40E_TX_FLAGS_VLAN_MASK, tx_flags);
I40E_TX_FLAGS_VLAN_SHIFT;
} }
first->tx_flags = tx_flags; first->tx_flags = tx_flags;
......
...@@ -474,10 +474,10 @@ static void i40e_release_rdma_qvlist(struct i40e_vf *vf) ...@@ -474,10 +474,10 @@ static void i40e_release_rdma_qvlist(struct i40e_vf *vf)
*/ */
reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx; reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx;
reg = rd32(hw, I40E_VPINT_CEQCTL(reg_idx)); reg = rd32(hw, I40E_VPINT_CEQCTL(reg_idx));
next_q_index = (reg & I40E_VPINT_CEQCTL_NEXTQ_INDX_MASK) next_q_index = FIELD_GET(I40E_VPINT_CEQCTL_NEXTQ_INDX_MASK,
>> I40E_VPINT_CEQCTL_NEXTQ_INDX_SHIFT; reg);
next_q_type = (reg & I40E_VPINT_CEQCTL_NEXTQ_TYPE_MASK) next_q_type = FIELD_GET(I40E_VPINT_CEQCTL_NEXTQ_TYPE_MASK,
>> I40E_VPINT_CEQCTL_NEXTQ_TYPE_SHIFT; reg);
reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1); reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1);
reg = (next_q_index & reg = (next_q_index &
...@@ -555,10 +555,10 @@ i40e_config_rdma_qvlist(struct i40e_vf *vf, ...@@ -555,10 +555,10 @@ i40e_config_rdma_qvlist(struct i40e_vf *vf,
* queue on top. Also link it with the new queue in CEQCTL. * queue on top. Also link it with the new queue in CEQCTL.
*/ */
reg = rd32(hw, I40E_VPINT_LNKLSTN(reg_idx)); reg = rd32(hw, I40E_VPINT_LNKLSTN(reg_idx));
next_q_idx = ((reg & I40E_VPINT_LNKLSTN_FIRSTQ_INDX_MASK) >> next_q_idx = FIELD_GET(I40E_VPINT_LNKLSTN_FIRSTQ_INDX_MASK,
I40E_VPINT_LNKLSTN_FIRSTQ_INDX_SHIFT); reg);
next_q_type = ((reg & I40E_VPINT_LNKLSTN_FIRSTQ_TYPE_MASK) >> next_q_type = FIELD_GET(I40E_VPINT_LNKLSTN_FIRSTQ_TYPE_MASK,
I40E_VPINT_LNKLSTN_FIRSTQ_TYPE_SHIFT); reg);
if (qv_info->ceq_idx != I40E_QUEUE_INVALID_IDX) { if (qv_info->ceq_idx != I40E_QUEUE_INVALID_IDX) {
reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx; reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx;
...@@ -4673,9 +4673,8 @@ int i40e_ndo_get_vf_config(struct net_device *netdev, ...@@ -4673,9 +4673,8 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
ivi->max_tx_rate = vf->tx_rate; ivi->max_tx_rate = vf->tx_rate;
ivi->min_tx_rate = 0; ivi->min_tx_rate = 0;
ivi->vlan = le16_to_cpu(vsi->info.pvid) & I40E_VLAN_MASK; ivi->vlan = le16_get_bits(vsi->info.pvid, I40E_VLAN_MASK);
ivi->qos = (le16_to_cpu(vsi->info.pvid) & I40E_PRIORITY_MASK) >> ivi->qos = le16_get_bits(vsi->info.pvid, I40E_PRIORITY_MASK);
I40E_VLAN_PRIORITY_SHIFT;
if (vf->link_forced == false) if (vf->link_forced == false)
ivi->linkstate = IFLA_VF_LINK_STATE_AUTO; ivi->linkstate = IFLA_VF_LINK_STATE_AUTO;
else if (vf->link_up == true) else if (vf->link_up == true)
......
...@@ -476,8 +476,7 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget) ...@@ -476,8 +476,7 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
continue; continue;
} }
size = (qword & I40E_RXD_QW1_LENGTH_PBUF_MASK) >> size = FIELD_GET(I40E_RXD_QW1_LENGTH_PBUF_MASK, qword);
I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
if (!size) if (!size)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment