Skip to content

Commit 5a259f8

Browse files
jbrandebanguy11
authored andcommitted
ice: field get conversion
Refactor the ice 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. @get@ constant shift,mask; 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: Alexander Lobakin <[email protected]> Cc: Julia Lawall <[email protected]> Reviewed-by: Marcin Szycik <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Jesse Brandeburg <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 65db56d commit 5a259f8

File tree

13 files changed

+82
-121
lines changed

13 files changed

+82
-121
lines changed

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,10 @@ static void ice_cfg_itr_gran(struct ice_hw *hw)
232232

233233
/* no need to update global register if ITR gran is already set */
234234
if (!(regval & GLINT_CTL_DIS_AUTOMASK_M) &&
235-
(((regval & GLINT_CTL_ITR_GRAN_200_M) >>
236-
GLINT_CTL_ITR_GRAN_200_S) == ICE_ITR_GRAN_US) &&
237-
(((regval & GLINT_CTL_ITR_GRAN_100_M) >>
238-
GLINT_CTL_ITR_GRAN_100_S) == ICE_ITR_GRAN_US) &&
239-
(((regval & GLINT_CTL_ITR_GRAN_50_M) >>
240-
GLINT_CTL_ITR_GRAN_50_S) == ICE_ITR_GRAN_US) &&
241-
(((regval & GLINT_CTL_ITR_GRAN_25_M) >>
242-
GLINT_CTL_ITR_GRAN_25_S) == ICE_ITR_GRAN_US))
235+
(FIELD_GET(GLINT_CTL_ITR_GRAN_200_M, regval) == ICE_ITR_GRAN_US) &&
236+
(FIELD_GET(GLINT_CTL_ITR_GRAN_100_M, regval) == ICE_ITR_GRAN_US) &&
237+
(FIELD_GET(GLINT_CTL_ITR_GRAN_50_M, regval) == ICE_ITR_GRAN_US) &&
238+
(FIELD_GET(GLINT_CTL_ITR_GRAN_25_M, regval) == ICE_ITR_GRAN_US))
243239
return;
244240

245241
regval = FIELD_PREP(GLINT_CTL_ITR_GRAN_200_M, ICE_ITR_GRAN_US) |

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,8 @@ static void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw)
942942
*/
943943
static void ice_get_itr_intrl_gran(struct ice_hw *hw)
944944
{
945-
u8 max_agg_bw = (rd32(hw, GL_PWR_MODE_CTL) &
946-
GL_PWR_MODE_CTL_CAR_MAX_BW_M) >>
947-
GL_PWR_MODE_CTL_CAR_MAX_BW_S;
945+
u8 max_agg_bw = FIELD_GET(GL_PWR_MODE_CTL_CAR_MAX_BW_M,
946+
rd32(hw, GL_PWR_MODE_CTL));
948947

949948
switch (max_agg_bw) {
950949
case ICE_MAX_AGG_BW_200G:
@@ -976,9 +975,7 @@ int ice_init_hw(struct ice_hw *hw)
976975
if (status)
977976
return status;
978977

979-
hw->pf_id = (u8)(rd32(hw, PF_FUNC_RID) &
980-
PF_FUNC_RID_FUNC_NUM_M) >>
981-
PF_FUNC_RID_FUNC_NUM_S;
978+
hw->pf_id = FIELD_GET(PF_FUNC_RID_FUNC_NUM_M, rd32(hw, PF_FUNC_RID));
982979

983980
status = ice_reset(hw, ICE_RESET_PFR);
984981
if (status)
@@ -1163,8 +1160,8 @@ int ice_check_reset(struct ice_hw *hw)
11631160
* or EMPR has occurred. The grst delay value is in 100ms units.
11641161
* Add 1sec for outstanding AQ commands that can take a long time.
11651162
*/
1166-
grst_timeout = ((rd32(hw, GLGEN_RSTCTL) & GLGEN_RSTCTL_GRSTDEL_M) >>
1167-
GLGEN_RSTCTL_GRSTDEL_S) + 10;
1163+
grst_timeout = FIELD_GET(GLGEN_RSTCTL_GRSTDEL_M,
1164+
rd32(hw, GLGEN_RSTCTL)) + 10;
11681165

11691166
for (cnt = 0; cnt < grst_timeout; cnt++) {
11701167
mdelay(100);
@@ -2248,7 +2245,7 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
22482245
info->tmr_index_owned = ((number & ICE_TS_TMR_IDX_OWND_M) != 0);
22492246
info->tmr_index_assoc = ((number & ICE_TS_TMR_IDX_ASSOC_M) != 0);
22502247

2251-
info->clk_freq = (number & ICE_TS_CLK_FREQ_M) >> ICE_TS_CLK_FREQ_S;
2248+
info->clk_freq = FIELD_GET(ICE_TS_CLK_FREQ_M, number);
22522249
info->clk_src = ((number & ICE_TS_CLK_SRC_M) != 0);
22532250

22542251
if (info->clk_freq < NUM_ICE_TIME_REF_FREQ) {
@@ -2449,7 +2446,7 @@ ice_parse_1588_dev_caps(struct ice_hw *hw, struct ice_hw_dev_caps *dev_p,
24492446
info->tmr0_owned = ((number & ICE_TS_TMR0_OWND_M) != 0);
24502447
info->tmr0_ena = ((number & ICE_TS_TMR0_ENA_M) != 0);
24512448

2452-
info->tmr1_owner = (number & ICE_TS_TMR1_OWNR_M) >> ICE_TS_TMR1_OWNR_S;
2449+
info->tmr1_owner = FIELD_GET(ICE_TS_TMR1_OWNR_M, number);
24532450
info->tmr1_owned = ((number & ICE_TS_TMR1_OWND_M) != 0);
24542451
info->tmr1_ena = ((number & ICE_TS_TMR1_ENA_M) != 0);
24552452

@@ -5773,7 +5770,7 @@ ice_get_link_default_override(struct ice_link_default_override_tlv *ldo,
57735770
ice_debug(hw, ICE_DBG_INIT, "Failed to read override link options.\n");
57745771
return status;
57755772
}
5776-
ldo->options = buf & ICE_LINK_OVERRIDE_OPT_M;
5773+
ldo->options = FIELD_GET(ICE_LINK_OVERRIDE_OPT_M, buf);
57775774
ldo->phy_config = (buf & ICE_LINK_OVERRIDE_PHY_CFG_M) >>
57785775
ICE_LINK_OVERRIDE_PHY_CFG_S;
57795776

drivers/net/ethernet/intel/ice/ice_dcb.c

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ static u8 ice_get_dcbx_status(struct ice_hw *hw)
146146
u32 reg;
147147

148148
reg = rd32(hw, PRTDCB_GENS);
149-
return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >>
150-
PRTDCB_GENS_DCBX_STATUS_S);
149+
return FIELD_GET(PRTDCB_GENS_DCBX_STATUS_M, reg);
151150
}
152151

153152
/**
@@ -173,11 +172,9 @@ ice_parse_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
173172
*/
174173
for (i = 0; i < 4; i++) {
175174
ets_cfg->prio_table[i * 2] =
176-
((buf[offset] & ICE_IEEE_ETS_PRIO_1_M) >>
177-
ICE_IEEE_ETS_PRIO_1_S);
175+
FIELD_GET(ICE_IEEE_ETS_PRIO_1_M, buf[offset]);
178176
ets_cfg->prio_table[i * 2 + 1] =
179-
((buf[offset] & ICE_IEEE_ETS_PRIO_0_M) >>
180-
ICE_IEEE_ETS_PRIO_0_S);
177+
FIELD_GET(ICE_IEEE_ETS_PRIO_0_M, buf[offset]);
181178
offset++;
182179
}
183180

@@ -221,11 +218,9 @@ ice_parse_ieee_etscfg_tlv(struct ice_lldp_org_tlv *tlv,
221218
* |1bit | 1bit|3 bits|3bits|
222219
*/
223220
etscfg = &dcbcfg->etscfg;
224-
etscfg->willing = ((buf[0] & ICE_IEEE_ETS_WILLING_M) >>
225-
ICE_IEEE_ETS_WILLING_S);
226-
etscfg->cbs = ((buf[0] & ICE_IEEE_ETS_CBS_M) >> ICE_IEEE_ETS_CBS_S);
227-
etscfg->maxtcs = ((buf[0] & ICE_IEEE_ETS_MAXTC_M) >>
228-
ICE_IEEE_ETS_MAXTC_S);
221+
etscfg->willing = FIELD_GET(ICE_IEEE_ETS_WILLING_M, buf[0]);
222+
etscfg->cbs = FIELD_GET(ICE_IEEE_ETS_CBS_M, buf[0]);
223+
etscfg->maxtcs = FIELD_GET(ICE_IEEE_ETS_MAXTC_M, buf[0]);
229224

230225
/* Begin parsing at Priority Assignment Table (offset 1 in buf) */
231226
ice_parse_ieee_ets_common_tlv(&buf[1], etscfg);
@@ -267,11 +262,9 @@ ice_parse_ieee_pfccfg_tlv(struct ice_lldp_org_tlv *tlv,
267262
* -----------------------------------------
268263
* |1bit | 1bit|2 bits|4bits| 1 octet |
269264
*/
270-
dcbcfg->pfc.willing = ((buf[0] & ICE_IEEE_PFC_WILLING_M) >>
271-
ICE_IEEE_PFC_WILLING_S);
272-
dcbcfg->pfc.mbc = ((buf[0] & ICE_IEEE_PFC_MBC_M) >> ICE_IEEE_PFC_MBC_S);
273-
dcbcfg->pfc.pfccap = ((buf[0] & ICE_IEEE_PFC_CAP_M) >>
274-
ICE_IEEE_PFC_CAP_S);
265+
dcbcfg->pfc.willing = FIELD_GET(ICE_IEEE_PFC_WILLING_M, buf[0]);
266+
dcbcfg->pfc.mbc = FIELD_GET(ICE_IEEE_PFC_MBC_M, buf[0]);
267+
dcbcfg->pfc.pfccap = FIELD_GET(ICE_IEEE_PFC_CAP_M, buf[0]);
275268
dcbcfg->pfc.pfcena = buf[1];
276269
}
277270

@@ -293,7 +286,7 @@ ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv,
293286
u8 *buf;
294287

295288
typelen = ntohs(tlv->typelen);
296-
len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
289+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
297290
buf = tlv->tlvinfo;
298291

299292
/* Removing sizeof(ouisubtype) and reserved byte from len.
@@ -313,12 +306,10 @@ ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv,
313306
* -----------------------------------------
314307
*/
315308
while (offset < len) {
316-
dcbcfg->app[i].priority = ((buf[offset] &
317-
ICE_IEEE_APP_PRIO_M) >>
318-
ICE_IEEE_APP_PRIO_S);
319-
dcbcfg->app[i].selector = ((buf[offset] &
320-
ICE_IEEE_APP_SEL_M) >>
321-
ICE_IEEE_APP_SEL_S);
309+
dcbcfg->app[i].priority = FIELD_GET(ICE_IEEE_APP_PRIO_M,
310+
buf[offset]);
311+
dcbcfg->app[i].selector = FIELD_GET(ICE_IEEE_APP_SEL_M,
312+
buf[offset]);
322313
dcbcfg->app[i].prot_id = (buf[offset + 1] << 0x8) |
323314
buf[offset + 2];
324315
/* Move to next app */
@@ -346,8 +337,7 @@ ice_parse_ieee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
346337
u8 subtype;
347338

348339
ouisubtype = ntohl(tlv->ouisubtype);
349-
subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
350-
ICE_LLDP_TLV_SUBTYPE_S);
340+
subtype = FIELD_GET(ICE_LLDP_TLV_SUBTYPE_M, ouisubtype);
351341
switch (subtype) {
352342
case ICE_IEEE_SUBTYPE_ETS_CFG:
353343
ice_parse_ieee_etscfg_tlv(tlv, dcbcfg);
@@ -398,11 +388,9 @@ ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,
398388
*/
399389
for (i = 0; i < 4; i++) {
400390
etscfg->prio_table[i * 2] =
401-
((buf[offset] & ICE_CEE_PGID_PRIO_1_M) >>
402-
ICE_CEE_PGID_PRIO_1_S);
391+
FIELD_GET(ICE_CEE_PGID_PRIO_1_M, buf[offset]);
403392
etscfg->prio_table[i * 2 + 1] =
404-
((buf[offset] & ICE_CEE_PGID_PRIO_0_M) >>
405-
ICE_CEE_PGID_PRIO_0_S);
393+
FIELD_GET(ICE_CEE_PGID_PRIO_0_M, buf[offset]);
406394
offset++;
407395
}
408396

@@ -465,7 +453,7 @@ ice_parse_cee_app_tlv(struct ice_cee_feat_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
465453
u8 i;
466454

467455
typelen = ntohs(tlv->hdr.typelen);
468-
len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
456+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
469457

470458
dcbcfg->numapps = len / sizeof(*app);
471459
if (!dcbcfg->numapps)
@@ -520,14 +508,13 @@ ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
520508
u32 ouisubtype;
521509

522510
ouisubtype = ntohl(tlv->ouisubtype);
523-
subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
524-
ICE_LLDP_TLV_SUBTYPE_S);
511+
subtype = FIELD_GET(ICE_LLDP_TLV_SUBTYPE_M, ouisubtype);
525512
/* Return if not CEE DCBX */
526513
if (subtype != ICE_CEE_DCBX_TYPE)
527514
return;
528515

529516
typelen = ntohs(tlv->typelen);
530-
tlvlen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
517+
tlvlen = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
531518
len = sizeof(tlv->typelen) + sizeof(ouisubtype) +
532519
sizeof(struct ice_cee_ctrl_tlv);
533520
/* Return if no CEE DCBX Feature TLVs */
@@ -539,9 +526,8 @@ ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
539526
u16 sublen;
540527

541528
typelen = ntohs(sub_tlv->hdr.typelen);
542-
sublen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
543-
subtype = (u8)((typelen & ICE_LLDP_TLV_TYPE_M) >>
544-
ICE_LLDP_TLV_TYPE_S);
529+
sublen = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
530+
subtype = FIELD_GET(ICE_LLDP_TLV_TYPE_M, typelen);
545531
switch (subtype) {
546532
case ICE_CEE_SUBTYPE_PG_CFG:
547533
ice_parse_cee_pgcfg_tlv(sub_tlv, dcbcfg);
@@ -578,7 +564,7 @@ ice_parse_org_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
578564
u32 oui;
579565

580566
ouisubtype = ntohl(tlv->ouisubtype);
581-
oui = ((ouisubtype & ICE_LLDP_TLV_OUI_M) >> ICE_LLDP_TLV_OUI_S);
567+
oui = FIELD_GET(ICE_LLDP_TLV_OUI_M, ouisubtype);
582568
switch (oui) {
583569
case ICE_IEEE_8021QAZ_OUI:
584570
ice_parse_ieee_tlv(tlv, dcbcfg);
@@ -615,8 +601,8 @@ static int ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg)
615601
tlv = (struct ice_lldp_org_tlv *)lldpmib;
616602
while (1) {
617603
typelen = ntohs(tlv->typelen);
618-
type = ((typelen & ICE_LLDP_TLV_TYPE_M) >> ICE_LLDP_TLV_TYPE_S);
619-
len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
604+
type = FIELD_GET(ICE_LLDP_TLV_TYPE_M, typelen);
605+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
620606
offset += sizeof(typelen) + len;
621607

622608
/* END TLV or beyond LLDPDU size */
@@ -805,11 +791,11 @@ ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
805791
*/
806792
for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
807793
dcbcfg->etscfg.prio_table[i * 2] =
808-
((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
809-
ICE_CEE_PGID_PRIO_0_S);
794+
FIELD_GET(ICE_CEE_PGID_PRIO_0_M,
795+
cee_cfg->oper_prio_tc[i]);
810796
dcbcfg->etscfg.prio_table[i * 2 + 1] =
811-
((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
812-
ICE_CEE_PGID_PRIO_1_S);
797+
FIELD_GET(ICE_CEE_PGID_PRIO_1_M,
798+
cee_cfg->oper_prio_tc[i]);
813799
}
814800

815801
ice_for_each_traffic_class(i) {
@@ -1482,7 +1468,7 @@ ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg)
14821468
while (1) {
14831469
ice_add_dcb_tlv(tlv, dcbcfg, tlvid++);
14841470
typelen = ntohs(tlv->typelen);
1485-
len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
1471+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
14861472
if (len)
14871473
offset += len + 2;
14881474
/* END TLV or beyond LLDPDU size */

drivers/net/ethernet/intel/ice/ice_dcb_nl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void ice_get_pfc_delay(struct ice_hw *hw, u16 *delay)
227227
u32 val;
228228

229229
val = rd32(hw, PRTDCB_GENC);
230-
*delay = (u16)((val & PRTDCB_GENC_PFCLDA_M) >> PRTDCB_GENC_PFCLDA_S);
230+
*delay = FIELD_GET(PRTDCB_GENC_PFCLDA_M, val);
231231
}
232232

233233
/**

drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ ice_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,
503503
return -EINVAL;
504504

505505
data->flex_word = value & ICE_USERDEF_FLEX_WORD_M;
506-
data->flex_offset = (value & ICE_USERDEF_FLEX_OFFS_M) >>
507-
ICE_USERDEF_FLEX_OFFS_S;
506+
data->flex_offset = FIELD_GET(ICE_USERDEF_FLEX_OFFS_M, value);
508507
if (data->flex_offset > ICE_USERDEF_FLEX_MAX_OFFS_VAL)
509508
return -EINVAL;
510509

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,8 @@ static void ice_set_dflt_vsi_ctx(struct ice_hw *hw, struct ice_vsi_ctx *ctxt)
974974
/* Traffic from VSI can be sent to LAN */
975975
ctxt->info.sw_flags2 = ICE_AQ_VSI_SW_FLAG_LAN_ENA;
976976
/* allow all untagged/tagged packets by default on Tx */
977-
ctxt->info.inner_vlan_flags = ((ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL &
978-
ICE_AQ_VSI_INNER_VLAN_TX_MODE_M) >>
979-
ICE_AQ_VSI_INNER_VLAN_TX_MODE_S);
977+
ctxt->info.inner_vlan_flags = FIELD_GET(ICE_AQ_VSI_INNER_VLAN_TX_MODE_M,
978+
ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL);
980979
/* SVM - by default bits 3 and 4 in inner_vlan_flags are 0's which
981980
* results in legacy behavior (show VLAN, DEI, and UP) in descriptor.
982981
*

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ static void ice_set_dflt_mib(struct ice_pf *pf)
980980
* Octets 13 - 20 are TSA values - leave as zeros
981981
*/
982982
buf[5] = 0x64;
983-
len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
983+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
984984
offset += len + 2;
985985
tlv = (struct ice_lldp_org_tlv *)
986986
((char *)tlv + sizeof(tlv->typelen) + len);
@@ -1014,7 +1014,7 @@ static void ice_set_dflt_mib(struct ice_pf *pf)
10141014

10151015
/* Octet 1 left as all zeros - PFC disabled */
10161016
buf[0] = 0x08;
1017-
len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
1017+
len = FIELD_GET(ICE_LLDP_TLV_LEN_M, typelen);
10181018
offset += len + 2;
10191019

10201020
if (ice_aq_set_lldp_mib(hw, mib_type, (void *)lldpmib, offset, NULL))
@@ -1771,14 +1771,10 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
17711771
/* find what triggered an MDD event */
17721772
reg = rd32(hw, GL_MDET_TX_PQM);
17731773
if (reg & GL_MDET_TX_PQM_VALID_M) {
1774-
u8 pf_num = (reg & GL_MDET_TX_PQM_PF_NUM_M) >>
1775-
GL_MDET_TX_PQM_PF_NUM_S;
1776-
u16 vf_num = (reg & GL_MDET_TX_PQM_VF_NUM_M) >>
1777-
GL_MDET_TX_PQM_VF_NUM_S;
1778-
u8 event = (reg & GL_MDET_TX_PQM_MAL_TYPE_M) >>
1779-
GL_MDET_TX_PQM_MAL_TYPE_S;
1780-
u16 queue = ((reg & GL_MDET_TX_PQM_QNUM_M) >>
1781-
GL_MDET_TX_PQM_QNUM_S);
1774+
u8 pf_num = FIELD_GET(GL_MDET_TX_PQM_PF_NUM_M, reg);
1775+
u16 vf_num = FIELD_GET(GL_MDET_TX_PQM_VF_NUM_M, reg);
1776+
u8 event = FIELD_GET(GL_MDET_TX_PQM_MAL_TYPE_M, reg);
1777+
u16 queue = FIELD_GET(GL_MDET_TX_PQM_QNUM_M, reg);
17821778

17831779
if (netif_msg_tx_err(pf))
17841780
dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n",
@@ -1788,14 +1784,10 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
17881784

17891785
reg = rd32(hw, GL_MDET_TX_TCLAN_BY_MAC(hw));
17901786
if (reg & GL_MDET_TX_TCLAN_VALID_M) {
1791-
u8 pf_num = (reg & GL_MDET_TX_TCLAN_PF_NUM_M) >>
1792-
GL_MDET_TX_TCLAN_PF_NUM_S;
1793-
u16 vf_num = (reg & GL_MDET_TX_TCLAN_VF_NUM_M) >>
1794-
GL_MDET_TX_TCLAN_VF_NUM_S;
1795-
u8 event = (reg & GL_MDET_TX_TCLAN_MAL_TYPE_M) >>
1796-
GL_MDET_TX_TCLAN_MAL_TYPE_S;
1797-
u16 queue = ((reg & GL_MDET_TX_TCLAN_QNUM_M) >>
1798-
GL_MDET_TX_TCLAN_QNUM_S);
1787+
u8 pf_num = FIELD_GET(GL_MDET_TX_TCLAN_PF_NUM_M, reg);
1788+
u16 vf_num = FIELD_GET(GL_MDET_TX_TCLAN_VF_NUM_M, reg);
1789+
u8 event = FIELD_GET(GL_MDET_TX_TCLAN_MAL_TYPE_M, reg);
1790+
u16 queue = FIELD_GET(GL_MDET_TX_TCLAN_QNUM_M, reg);
17991791

18001792
if (netif_msg_tx_err(pf))
18011793
dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n",
@@ -1805,14 +1797,10 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
18051797

18061798
reg = rd32(hw, GL_MDET_RX);
18071799
if (reg & GL_MDET_RX_VALID_M) {
1808-
u8 pf_num = (reg & GL_MDET_RX_PF_NUM_M) >>
1809-
GL_MDET_RX_PF_NUM_S;
1810-
u16 vf_num = (reg & GL_MDET_RX_VF_NUM_M) >>
1811-
GL_MDET_RX_VF_NUM_S;
1812-
u8 event = (reg & GL_MDET_RX_MAL_TYPE_M) >>
1813-
GL_MDET_RX_MAL_TYPE_S;
1814-
u16 queue = ((reg & GL_MDET_RX_QNUM_M) >>
1815-
GL_MDET_RX_QNUM_S);
1800+
u8 pf_num = FIELD_GET(GL_MDET_RX_PF_NUM_M, reg);
1801+
u16 vf_num = FIELD_GET(GL_MDET_RX_VF_NUM_M, reg);
1802+
u8 event = FIELD_GET(GL_MDET_RX_MAL_TYPE_M, reg);
1803+
u16 queue = FIELD_GET(GL_MDET_RX_QNUM_M, reg);
18161804

18171805
if (netif_msg_rx_err(pf))
18181806
dev_info(dev, "Malicious Driver Detection event %d on RX queue %d PF# %d VF# %d\n",
@@ -3135,8 +3123,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
31353123

31363124
/* we have a reset warning */
31373125
ena_mask &= ~PFINT_OICR_GRST_M;
3138-
reset = (rd32(hw, GLGEN_RSTAT) & GLGEN_RSTAT_RESET_TYPE_M) >>
3139-
GLGEN_RSTAT_RESET_TYPE_S;
3126+
reset = FIELD_GET(GLGEN_RSTAT_RESET_TYPE_M,
3127+
rd32(hw, GLGEN_RSTAT));
31403128

31413129
if (reset == ICE_RESET_CORER)
31423130
pf->corer_count++;
@@ -7995,8 +7983,8 @@ static void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue)
79957983
struct ice_hw *hw = &pf->hw;
79967984
u32 head, val = 0;
79977985

7998-
head = (rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue])) &
7999-
QTX_COMM_HEAD_HEAD_M) >> QTX_COMM_HEAD_HEAD_S;
7986+
head = FIELD_GET(QTX_COMM_HEAD_HEAD_M,
7987+
rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue])));
80007988
/* Read interrupt register */
80017989
val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx));
80027990

0 commit comments

Comments
 (0)