1 From 4973056cceacc70966396039fae99867dfafd796 Mon Sep 17 00:00:00 2001
2 From: Sean Anderson <sean.anderson@seco.com>
3 Date: Fri, 22 Oct 2021 18:41:04 -0400
4 Subject: [PATCH] net: convert users of bitmap_foo() to linkmode_foo()
6 This converts instances of
7 bitmap_foo(args..., __ETHTOOL_LINK_MODE_MASK_NBITS)
11 I manually fixed up some lines to prevent them from being excessively
12 long. Otherwise, this change was generated with the following semantic
16 // echo linux/linkmode.h > includes
17 // git grep -Flf includes include/ | cut -f 2- -d / | cat includes - \
18 // | sort | uniq | tee new_includes | wc -l && mv new_includes includes
19 // and repeating until the number stopped going up
24 #include <linux/acpi_mdio.h>
26 #include <linux/brcmphy.h>
28 #include <linux/dsa/loop.h>
30 #include <linux/dsa/sja1105.h>
32 #include <linux/ethtool.h>
34 #include <linux/ethtool_netlink.h>
36 #include <linux/fec.h>
38 #include <linux/fs_enet_pd.h>
40 #include <linux/fsl/enetc_mdio.h>
42 #include <linux/fwnode_mdio.h>
44 #include <linux/linkmode.h>
46 #include <linux/lsm_audit.h>
48 #include <linux/mdio-bitbang.h>
50 #include <linux/mdio.h>
52 #include <linux/mdio-mux.h>
54 #include <linux/mii.h>
56 #include <linux/mii_timestamper.h>
58 #include <linux/mlx5/accel.h>
60 #include <linux/mlx5/cq.h>
62 #include <linux/mlx5/device.h>
64 #include <linux/mlx5/driver.h>
66 #include <linux/mlx5/eswitch.h>
68 #include <linux/mlx5/fs.h>
70 #include <linux/mlx5/port.h>
72 #include <linux/mlx5/qp.h>
74 #include <linux/mlx5/rsc_dump.h>
76 #include <linux/mlx5/transobj.h>
78 #include <linux/mlx5/vport.h>
80 #include <linux/of_mdio.h>
82 #include <linux/of_net.h>
84 #include <linux/pcs-lynx.h>
86 #include <linux/pcs/pcs-xpcs.h>
88 #include <linux/phy.h>
90 #include <linux/phy_led_triggers.h>
92 #include <linux/phylink.h>
94 #include <linux/platform_data/bcmgenet.h>
96 #include <linux/platform_data/xilinx-ll-temac.h>
98 #include <linux/pxa168_eth.h>
100 #include <linux/qed/qed_eth_if.h>
102 #include <linux/qed/qed_fcoe_if.h>
104 #include <linux/qed/qed_if.h>
106 #include <linux/qed/qed_iov_if.h>
108 #include <linux/qed/qed_iscsi_if.h>
110 #include <linux/qed/qed_ll2_if.h>
112 #include <linux/qed/qed_nvmetcp_if.h>
114 #include <linux/qed/qed_rdma_if.h>
116 #include <linux/sfp.h>
118 #include <linux/sh_eth.h>
120 #include <linux/smsc911x.h>
122 #include <linux/soc/nxp/lpc32xx-misc.h>
124 #include <linux/stmmac.h>
126 #include <linux/sunrpc/svc_rdma.h>
128 #include <linux/sxgbe_platform.h>
130 #include <net/cfg80211.h>
134 #include <net/mac80211.h>
136 #include <net/selftests.h>
138 #include <rdma/ib_addr.h>
140 #include <rdma/ib_cache.h>
142 #include <rdma/ib_cm.h>
144 #include <rdma/ib_hdrs.h>
146 #include <rdma/ib_mad.h>
148 #include <rdma/ib_marshall.h>
150 #include <rdma/ib_pack.h>
152 #include <rdma/ib_pma.h>
154 #include <rdma/ib_sa.h>
156 #include <rdma/ib_smi.h>
158 #include <rdma/ib_umem.h>
160 #include <rdma/ib_umem_odp.h>
162 #include <rdma/ib_verbs.h>
164 #include <rdma/iw_cm.h>
166 #include <rdma/mr_pool.h>
168 #include <rdma/opa_addr.h>
170 #include <rdma/opa_port_info.h>
172 #include <rdma/opa_smi.h>
174 #include <rdma/opa_vnic.h>
176 #include <rdma/rdma_cm.h>
178 #include <rdma/rdma_cm_ib.h>
180 #include <rdma/rdmavt_cq.h>
182 #include <rdma/rdma_vt.h>
184 #include <rdma/rdmavt_qp.h>
188 #include <rdma/tid_rdma_defs.h>
190 #include <rdma/uverbs_ioctl.h>
192 #include <rdma/uverbs_named_ioctl.h>
194 #include <rdma/uverbs_std_types.h>
196 #include <rdma/uverbs_types.h>
198 #include <soc/mscc/ocelot.h>
200 #include <soc/mscc/ocelot_ptp.h>
202 #include <soc/mscc/ocelot_vcap.h>
204 #include <trace/events/ib_mad.h>
206 #include <trace/events/rdma_core.h>
208 #include <trace/events/rdma.h>
210 #include <trace/events/rpcrdma.h>
212 #include <uapi/linux/ethtool.h>
214 #include <uapi/linux/ethtool_netlink.h>
216 #include <uapi/linux/mdio.h>
218 #include <uapi/linux/mii.h>
222 expression list args;
226 - bitmap_zero(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
227 + linkmode_zero(args)
229 - bitmap_copy(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
230 + linkmode_copy(args)
232 - bitmap_and(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
235 - bitmap_or(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
238 - bitmap_empty(args, ETHTOOL_LINK_MODE_MASK_NBITS)
239 + linkmode_empty(args)
241 - bitmap_andnot(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
242 + linkmode_andnot(args)
244 - bitmap_equal(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
245 + linkmode_equal(args)
247 - bitmap_intersects(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
248 + linkmode_intersects(args)
250 - bitmap_subset(args, __ETHTOOL_LINK_MODE_MASK_NBITS)
251 + linkmode_subset(args)
254 Add missing linux/mii.h include to mellanox. -DaveM
256 Signed-off-by: Sean Anderson <sean.anderson@seco.com>
257 Signed-off-by: David S. Miller <davem@davemloft.net>
259 drivers/net/dsa/b53/b53_common.c | 6 ++----
260 drivers/net/dsa/bcm_sf2.c | 8 +++----
261 drivers/net/dsa/hirschmann/hellcreek.c | 6 ++----
262 drivers/net/dsa/lantiq_gswip.c | 14 ++++++-------
263 drivers/net/dsa/microchip/ksz8795.c | 8 +++----
264 drivers/net/dsa/mv88e6xxx/chip.c | 5 ++---
265 drivers/net/dsa/ocelot/felix_vsc9959.c | 8 +++----
266 drivers/net/dsa/ocelot/seville_vsc9953.c | 8 +++----
267 drivers/net/dsa/qca/ar9331.c | 10 ++++-----
268 drivers/net/dsa/sja1105/sja1105_main.c | 7 +++----
269 drivers/net/dsa/xrs700x/xrs700x.c | 8 +++----
270 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 8 +++----
271 drivers/net/ethernet/atheros/ag71xx.c | 8 +++----
272 drivers/net/ethernet/cadence/macb_main.c | 11 +++++-----
273 .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +++----
274 .../net/ethernet/huawei/hinic/hinic_ethtool.c | 10 ++++-----
275 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 ++---
276 drivers/net/ethernet/marvell/mvneta.c | 10 ++++-----
277 .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 7 +++----
278 .../marvell/octeontx2/nic/otx2_ethtool.c | 5 ++---
279 drivers/net/ethernet/marvell/pxa168_eth.c | 3 +--
280 .../net/ethernet/mellanox/mlx4/en_ethtool.c | 21 +++++++------------
281 .../microchip/sparx5/sparx5_phylink.c | 7 +++----
282 drivers/net/ethernet/mscc/ocelot_net.c | 7 +++----
283 .../ethernet/pensando/ionic/ionic_ethtool.c | 3 +--
284 .../net/ethernet/xilinx/xilinx_axienet_main.c | 8 +++----
285 drivers/net/pcs/pcs-xpcs.c | 2 +-
286 drivers/net/phy/sfp-bus.c | 2 +-
287 net/ethtool/ioctl.c | 7 +++----
288 29 files changed, 87 insertions(+), 133 deletions(-)
290 --- a/drivers/net/dsa/b53/b53_common.c
291 +++ b/drivers/net/dsa/b53/b53_common.c
292 @@ -1349,10 +1349,8 @@ void b53_phylink_validate(struct dsa_swi
293 phylink_set(mask, 100baseT_Full);
296 - bitmap_and(supported, supported, mask,
297 - __ETHTOOL_LINK_MODE_MASK_NBITS);
298 - bitmap_and(state->advertising, state->advertising, mask,
299 - __ETHTOOL_LINK_MODE_MASK_NBITS);
300 + linkmode_and(supported, supported, mask);
301 + linkmode_and(state->advertising, state->advertising, mask);
303 phylink_helper_basex_speed(state);
305 --- a/drivers/net/dsa/bcm_sf2.c
306 +++ b/drivers/net/dsa/bcm_sf2.c
307 @@ -692,7 +692,7 @@ static void bcm_sf2_sw_validate(struct d
308 state->interface != PHY_INTERFACE_MODE_GMII &&
309 state->interface != PHY_INTERFACE_MODE_INTERNAL &&
310 state->interface != PHY_INTERFACE_MODE_MOCA) {
311 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
312 + linkmode_zero(supported);
313 if (port != core_readl(priv, CORE_IMP0_PRT_ID))
315 "Unsupported interface: %d for port %d\n",
316 @@ -720,10 +720,8 @@ static void bcm_sf2_sw_validate(struct d
317 phylink_set(mask, 100baseT_Half);
318 phylink_set(mask, 100baseT_Full);
320 - bitmap_and(supported, supported, mask,
321 - __ETHTOOL_LINK_MODE_MASK_NBITS);
322 - bitmap_and(state->advertising, state->advertising, mask,
323 - __ETHTOOL_LINK_MODE_MASK_NBITS);
324 + linkmode_and(supported, supported, mask);
325 + linkmode_and(state->advertising, state->advertising, mask);
328 static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
329 --- a/drivers/net/dsa/hirschmann/hellcreek.c
330 +++ b/drivers/net/dsa/hirschmann/hellcreek.c
331 @@ -1476,10 +1476,8 @@ static void hellcreek_phylink_validate(s
333 phylink_set(mask, 1000baseT_Full);
335 - bitmap_and(supported, supported, mask,
336 - __ETHTOOL_LINK_MODE_MASK_NBITS);
337 - bitmap_and(state->advertising, state->advertising, mask,
338 - __ETHTOOL_LINK_MODE_MASK_NBITS);
339 + linkmode_and(supported, supported, mask);
340 + linkmode_and(state->advertising, state->advertising, mask);
344 --- a/drivers/net/dsa/lantiq_gswip.c
345 +++ b/drivers/net/dsa/lantiq_gswip.c
346 @@ -1452,10 +1452,8 @@ static void gswip_phylink_set_capab(unsi
347 phylink_set(mask, 100baseT_Half);
348 phylink_set(mask, 100baseT_Full);
350 - bitmap_and(supported, supported, mask,
351 - __ETHTOOL_LINK_MODE_MASK_NBITS);
352 - bitmap_and(state->advertising, state->advertising, mask,
353 - __ETHTOOL_LINK_MODE_MASK_NBITS);
354 + linkmode_and(supported, supported, mask);
355 + linkmode_and(state->advertising, state->advertising, mask);
358 static void gswip_xrx200_phylink_validate(struct dsa_switch *ds, int port,
359 @@ -1483,7 +1481,7 @@ static void gswip_xrx200_phylink_validat
363 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
364 + linkmode_zero(supported);
365 dev_err(ds->dev, "Unsupported port: %i\n", port);
368 @@ -1493,7 +1491,7 @@ static void gswip_xrx200_phylink_validat
372 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
373 + linkmode_zero(supported);
374 dev_err(ds->dev, "Unsupported interface '%s' for port %d\n",
375 phy_modes(state->interface), port);
377 @@ -1523,7 +1521,7 @@ static void gswip_xrx300_phylink_validat
381 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
382 + linkmode_zero(supported);
383 dev_err(ds->dev, "Unsupported port: %i\n", port);
386 @@ -1533,7 +1531,7 @@ static void gswip_xrx300_phylink_validat
390 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
391 + linkmode_zero(supported);
392 dev_err(ds->dev, "Unsupported interface '%s' for port %d\n",
393 phy_modes(state->interface), port);
395 --- a/drivers/net/dsa/microchip/ksz8795.c
396 +++ b/drivers/net/dsa/microchip/ksz8795.c
397 @@ -1542,15 +1542,13 @@ static void ksz8_validate(struct dsa_swi
398 phylink_set(mask, 100baseT_Half);
399 phylink_set(mask, 100baseT_Full);
401 - bitmap_and(supported, supported, mask,
402 - __ETHTOOL_LINK_MODE_MASK_NBITS);
403 - bitmap_and(state->advertising, state->advertising, mask,
404 - __ETHTOOL_LINK_MODE_MASK_NBITS);
405 + linkmode_and(supported, supported, mask);
406 + linkmode_and(state->advertising, state->advertising, mask);
411 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
412 + linkmode_zero(supported);
413 dev_err(ds->dev, "Unsupported interface: %s, port: %d\n",
414 phy_modes(state->interface), port);
416 --- a/drivers/net/dsa/mv88e6xxx/chip.c
417 +++ b/drivers/net/dsa/mv88e6xxx/chip.c
418 @@ -683,9 +683,8 @@ static void mv88e6xxx_validate(struct ds
419 if (chip->info->ops->phylink_validate)
420 chip->info->ops->phylink_validate(chip, port, mask, state);
422 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
423 - bitmap_and(state->advertising, state->advertising, mask,
424 - __ETHTOOL_LINK_MODE_MASK_NBITS);
425 + linkmode_and(supported, supported, mask);
426 + linkmode_and(state->advertising, state->advertising, mask);
428 /* We can only operate at 2500BaseX or 1000BaseX. If requested
429 * to advertise both, only report advertising at 2500BaseX.
430 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
431 +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
432 @@ -944,7 +944,7 @@ static void vsc9959_phylink_validate(str
434 if (state->interface != PHY_INTERFACE_MODE_NA &&
435 state->interface != ocelot_port->phy_mode) {
436 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
437 + linkmode_zero(supported);
441 @@ -966,10 +966,8 @@ static void vsc9959_phylink_validate(str
442 phylink_set(mask, 2500baseX_Full);
445 - bitmap_and(supported, supported, mask,
446 - __ETHTOOL_LINK_MODE_MASK_NBITS);
447 - bitmap_and(state->advertising, state->advertising, mask,
448 - __ETHTOOL_LINK_MODE_MASK_NBITS);
449 + linkmode_and(supported, supported, mask);
450 + linkmode_and(state->advertising, state->advertising, mask);
453 static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
454 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c
455 +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
456 @@ -1000,7 +1000,7 @@ static void vsc9953_phylink_validate(str
458 if (state->interface != PHY_INTERFACE_MODE_NA &&
459 state->interface != ocelot_port->phy_mode) {
460 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
461 + linkmode_zero(supported);
465 @@ -1019,10 +1019,8 @@ static void vsc9953_phylink_validate(str
466 phylink_set(mask, 2500baseX_Full);
469 - bitmap_and(supported, supported, mask,
470 - __ETHTOOL_LINK_MODE_MASK_NBITS);
471 - bitmap_and(state->advertising, state->advertising, mask,
472 - __ETHTOOL_LINK_MODE_MASK_NBITS);
473 + linkmode_and(supported, supported, mask);
474 + linkmode_and(state->advertising, state->advertising, mask);
477 static int vsc9953_prevalidate_phy_mode(struct ocelot *ocelot, int port,
478 --- a/drivers/net/dsa/qca/ar9331.c
479 +++ b/drivers/net/dsa/qca/ar9331.c
480 @@ -522,7 +522,7 @@ static void ar9331_sw_phylink_validate(s
484 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
485 + linkmode_zero(supported);
486 dev_err(ds->dev, "Unsupported port: %i\n", port);
489 @@ -536,15 +536,13 @@ static void ar9331_sw_phylink_validate(s
490 phylink_set(mask, 100baseT_Half);
491 phylink_set(mask, 100baseT_Full);
493 - bitmap_and(supported, supported, mask,
494 - __ETHTOOL_LINK_MODE_MASK_NBITS);
495 - bitmap_and(state->advertising, state->advertising, mask,
496 - __ETHTOOL_LINK_MODE_MASK_NBITS);
497 + linkmode_and(supported, supported, mask);
498 + linkmode_and(state->advertising, state->advertising, mask);
503 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
504 + linkmode_zero(supported);
505 dev_err(ds->dev, "Unsupported interface: %d, port: %d\n",
506 state->interface, port);
508 --- a/drivers/net/dsa/sja1105/sja1105_main.c
509 +++ b/drivers/net/dsa/sja1105/sja1105_main.c
510 @@ -1360,7 +1360,7 @@ static void sja1105_phylink_validate(str
512 if (state->interface != PHY_INTERFACE_MODE_NA &&
513 sja1105_phy_mode_mismatch(priv, port, state->interface)) {
514 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
515 + linkmode_zero(supported);
519 @@ -1380,9 +1380,8 @@ static void sja1105_phylink_validate(str
520 phylink_set(mask, 2500baseX_Full);
523 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
524 - bitmap_and(state->advertising, state->advertising, mask,
525 - __ETHTOOL_LINK_MODE_MASK_NBITS);
526 + linkmode_and(supported, supported, mask);
527 + linkmode_and(state->advertising, state->advertising, mask);
531 --- a/drivers/net/dsa/xrs700x/xrs700x.c
532 +++ b/drivers/net/dsa/xrs700x/xrs700x.c
533 @@ -457,7 +457,7 @@ static void xrs700x_phylink_validate(str
534 phylink_set(mask, 1000baseT_Full);
537 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
538 + linkmode_zero(supported);
539 dev_err(ds->dev, "Unsupported port: %i\n", port);
542 @@ -468,10 +468,8 @@ static void xrs700x_phylink_validate(str
543 phylink_set(mask, 10baseT_Full);
544 phylink_set(mask, 100baseT_Full);
546 - bitmap_and(supported, supported, mask,
547 - __ETHTOOL_LINK_MODE_MASK_NBITS);
548 - bitmap_and(state->advertising, state->advertising, mask,
549 - __ETHTOOL_LINK_MODE_MASK_NBITS);
550 + linkmode_and(supported, supported, mask);
551 + linkmode_and(state->advertising, state->advertising, mask);
554 static void xrs700x_mac_link_up(struct dsa_switch *ds, int port,
555 --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
556 +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
557 @@ -374,9 +374,8 @@ static int xgbe_set_link_ksettings(struc
558 __ETHTOOL_LINK_MODE_MASK_NBITS, cmd->link_modes.advertising,
559 __ETHTOOL_LINK_MODE_MASK_NBITS, lks->link_modes.supported);
561 - bitmap_and(advertising,
562 - cmd->link_modes.advertising, lks->link_modes.supported,
563 - __ETHTOOL_LINK_MODE_MASK_NBITS);
564 + linkmode_and(advertising, cmd->link_modes.advertising,
565 + lks->link_modes.supported);
567 if ((cmd->base.autoneg == AUTONEG_ENABLE) &&
568 bitmap_empty(advertising, __ETHTOOL_LINK_MODE_MASK_NBITS)) {
569 @@ -389,8 +388,7 @@ static int xgbe_set_link_ksettings(struc
570 pdata->phy.autoneg = cmd->base.autoneg;
571 pdata->phy.speed = speed;
572 pdata->phy.duplex = cmd->base.duplex;
573 - bitmap_copy(lks->link_modes.advertising, advertising,
574 - __ETHTOOL_LINK_MODE_MASK_NBITS);
575 + linkmode_copy(lks->link_modes.advertising, advertising);
577 if (cmd->base.autoneg == AUTONEG_ENABLE)
578 XGBE_SET_ADV(lks, Autoneg);
579 --- a/drivers/net/ethernet/atheros/ag71xx.c
580 +++ b/drivers/net/ethernet/atheros/ag71xx.c
581 @@ -1082,14 +1082,12 @@ static void ag71xx_mac_validate(struct p
582 phylink_set(mask, 1000baseX_Full);
585 - bitmap_and(supported, supported, mask,
586 - __ETHTOOL_LINK_MODE_MASK_NBITS);
587 - bitmap_and(state->advertising, state->advertising, mask,
588 - __ETHTOOL_LINK_MODE_MASK_NBITS);
589 + linkmode_and(supported, supported, mask);
590 + linkmode_and(state->advertising, state->advertising, mask);
594 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
595 + linkmode_zero(supported);
598 static void ag71xx_mac_pcs_get_state(struct phylink_config *config,
599 --- a/drivers/net/ethernet/cadence/macb_main.c
600 +++ b/drivers/net/ethernet/cadence/macb_main.c
601 @@ -523,21 +523,21 @@ static void macb_validate(struct phylink
602 state->interface != PHY_INTERFACE_MODE_SGMII &&
603 state->interface != PHY_INTERFACE_MODE_10GBASER &&
604 !phy_interface_mode_is_rgmii(state->interface)) {
605 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
606 + linkmode_zero(supported);
610 if (!macb_is_gem(bp) &&
611 (state->interface == PHY_INTERFACE_MODE_GMII ||
612 phy_interface_mode_is_rgmii(state->interface))) {
613 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
614 + linkmode_zero(supported);
618 if (state->interface == PHY_INTERFACE_MODE_10GBASER &&
619 !(bp->caps & MACB_CAPS_HIGH_SPEED &&
620 bp->caps & MACB_CAPS_PCS)) {
621 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
622 + linkmode_zero(supported);
626 @@ -576,9 +576,8 @@ static void macb_validate(struct phylink
627 phylink_set(mask, 1000baseT_Half);
630 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
631 - bitmap_and(state->advertising, state->advertising, mask,
632 - __ETHTOOL_LINK_MODE_MASK_NBITS);
633 + linkmode_and(supported, supported, mask);
634 + linkmode_and(state->advertising, state->advertising, mask);
637 static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
638 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
639 +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
640 @@ -965,7 +965,7 @@ static void enetc_pl_mac_validate(struct
641 state->interface != PHY_INTERFACE_MODE_2500BASEX &&
642 state->interface != PHY_INTERFACE_MODE_USXGMII &&
643 !phy_interface_mode_is_rgmii(state->interface)) {
644 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
645 + linkmode_zero(supported);
649 @@ -988,10 +988,8 @@ static void enetc_pl_mac_validate(struct
650 phylink_set(mask, 2500baseX_Full);
653 - bitmap_and(supported, supported, mask,
654 - __ETHTOOL_LINK_MODE_MASK_NBITS);
655 - bitmap_and(state->advertising, state->advertising, mask,
656 - __ETHTOOL_LINK_MODE_MASK_NBITS);
657 + linkmode_and(supported, supported, mask);
658 + linkmode_and(state->advertising, state->advertising, mask);
661 static void enetc_pl_mac_config(struct phylink_config *config,
662 --- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
663 +++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
664 @@ -322,12 +322,10 @@ static int hinic_get_link_ksettings(stru
668 - bitmap_copy(link_ksettings->link_modes.supported,
669 - (unsigned long *)&settings.supported,
670 - __ETHTOOL_LINK_MODE_MASK_NBITS);
671 - bitmap_copy(link_ksettings->link_modes.advertising,
672 - (unsigned long *)&settings.advertising,
673 - __ETHTOOL_LINK_MODE_MASK_NBITS);
674 + linkmode_copy(link_ksettings->link_modes.supported,
675 + (unsigned long *)&settings.supported);
676 + linkmode_copy(link_ksettings->link_modes.advertising,
677 + (unsigned long *)&settings.advertising);
681 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
682 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
683 @@ -467,9 +467,8 @@ static int ixgbe_set_link_ksettings(stru
684 * this function does not support duplex forcing, but can
685 * limit the advertising of the adapter to the specified speed
687 - if (!bitmap_subset(cmd->link_modes.advertising,
688 - cmd->link_modes.supported,
689 - __ETHTOOL_LINK_MODE_MASK_NBITS))
690 + if (!linkmode_subset(cmd->link_modes.advertising,
691 + cmd->link_modes.supported))
694 /* only allow one speed at a time if no autoneg */
695 --- a/drivers/net/ethernet/marvell/mvneta.c
696 +++ b/drivers/net/ethernet/marvell/mvneta.c
697 @@ -3835,14 +3835,14 @@ static void mvneta_validate(struct phyli
699 if (phy_interface_mode_is_8023z(state->interface)) {
700 if (!phylink_test(state->advertising, Autoneg)) {
701 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
702 + linkmode_zero(supported);
705 } else if (state->interface != PHY_INTERFACE_MODE_NA &&
706 state->interface != PHY_INTERFACE_MODE_QSGMII &&
707 state->interface != PHY_INTERFACE_MODE_SGMII &&
708 !phy_interface_mode_is_rgmii(state->interface)) {
709 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
710 + linkmode_zero(supported);
714 @@ -3871,10 +3871,8 @@ static void mvneta_validate(struct phyli
715 phylink_set(mask, 100baseT_Full);
718 - bitmap_and(supported, supported, mask,
719 - __ETHTOOL_LINK_MODE_MASK_NBITS);
720 - bitmap_and(state->advertising, state->advertising, mask,
721 - __ETHTOOL_LINK_MODE_MASK_NBITS);
722 + linkmode_and(supported, supported, mask);
723 + linkmode_and(state->advertising, state->advertising, mask);
725 /* We can only operate at 2500BaseX or 1000BaseX. If requested
726 * to advertise both, only report advertising at 2500BaseX.
727 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
728 +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
729 @@ -6352,15 +6352,14 @@ static void mvpp2_phylink_validate(struc
733 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
734 - bitmap_and(state->advertising, state->advertising, mask,
735 - __ETHTOOL_LINK_MODE_MASK_NBITS);
736 + linkmode_and(supported, supported, mask);
737 + linkmode_and(state->advertising, state->advertising, mask);
739 phylink_helper_basex_speed(state);
743 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
744 + linkmode_zero(supported);
747 static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
748 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
749 +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
750 @@ -1168,9 +1168,8 @@ static int otx2_set_link_ksettings(struc
751 otx2_get_link_ksettings(netdev, &cur_ks);
753 /* Check requested modes against supported modes by hardware */
754 - if (!bitmap_subset(cmd->link_modes.advertising,
755 - cur_ks.link_modes.supported,
756 - __ETHTOOL_LINK_MODE_MASK_NBITS))
757 + if (!linkmode_subset(cmd->link_modes.advertising,
758 + cur_ks.link_modes.supported))
761 mutex_lock(&mbox->lock);
762 --- a/drivers/net/ethernet/marvell/pxa168_eth.c
763 +++ b/drivers/net/ethernet/marvell/pxa168_eth.c
764 @@ -977,8 +977,7 @@ static int pxa168_init_phy(struct net_de
765 cmd.base.phy_address = pep->phy_addr;
766 cmd.base.speed = pep->phy_speed;
767 cmd.base.duplex = pep->phy_duplex;
768 - bitmap_copy(cmd.link_modes.advertising, PHY_BASIC_FEATURES,
769 - __ETHTOOL_LINK_MODE_MASK_NBITS);
770 + linkmode_copy(cmd.link_modes.advertising, PHY_BASIC_FEATURES);
771 cmd.base.autoneg = AUTONEG_ENABLE;
773 if (cmd.base.speed != 0)
774 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
775 +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
777 #include <linux/in.h>
779 #include <linux/bitmap.h>
780 +#include <linux/mii.h>
784 @@ -643,10 +644,8 @@ static unsigned long *ptys2ethtool_link_
786 cfg = &ptys2ethtool_map[reg_]; \
787 cfg->speed = speed_; \
788 - bitmap_zero(cfg->supported, \
789 - __ETHTOOL_LINK_MODE_MASK_NBITS); \
790 - bitmap_zero(cfg->advertised, \
791 - __ETHTOOL_LINK_MODE_MASK_NBITS); \
792 + linkmode_zero(cfg->supported); \
793 + linkmode_zero(cfg->advertised); \
794 for (i = 0 ; i < ARRAY_SIZE(modes) ; ++i) { \
795 __set_bit(modes[i], cfg->supported); \
796 __set_bit(modes[i], cfg->advertised); \
797 @@ -702,10 +701,8 @@ static void ptys2ethtool_update_link_mod
799 for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
800 if (eth_proto & MLX4_PROT_MASK(i))
801 - bitmap_or(link_modes, link_modes,
802 - ptys2ethtool_link_mode(&ptys2ethtool_map[i],
804 - __ETHTOOL_LINK_MODE_MASK_NBITS);
805 + linkmode_or(link_modes, link_modes,
806 + ptys2ethtool_link_mode(&ptys2ethtool_map[i], report));
810 @@ -716,11 +713,9 @@ static u32 ethtool2ptys_link_modes(const
813 for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
814 - if (bitmap_intersects(
815 - ptys2ethtool_link_mode(&ptys2ethtool_map[i],
818 - __ETHTOOL_LINK_MODE_MASK_NBITS))
819 + ulong *map_mode = ptys2ethtool_link_mode(&ptys2ethtool_map[i],
821 + if (linkmode_intersects(map_mode, link_modes))
822 ptys_modes |= 1 << i;
825 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c
826 +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c
827 @@ -92,12 +92,11 @@ static void sparx5_phylink_validate(stru
831 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
832 + linkmode_zero(supported);
835 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
836 - bitmap_and(state->advertising, state->advertising, mask,
837 - __ETHTOOL_LINK_MODE_MASK_NBITS);
838 + linkmode_and(supported, supported, mask);
839 + linkmode_and(state->advertising, state->advertising, mask);
842 static void sparx5_phylink_mac_config(struct phylink_config *config,
843 --- a/drivers/net/ethernet/mscc/ocelot_net.c
844 +++ b/drivers/net/ethernet/mscc/ocelot_net.c
845 @@ -1509,7 +1509,7 @@ static void vsc7514_phylink_validate(str
847 if (state->interface != PHY_INTERFACE_MODE_NA &&
848 state->interface != ocelot_port->phy_mode) {
849 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
850 + linkmode_zero(supported);
854 @@ -1528,9 +1528,8 @@ static void vsc7514_phylink_validate(str
855 phylink_set(mask, 2500baseT_Full);
856 phylink_set(mask, 2500baseX_Full);
858 - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
859 - bitmap_and(state->advertising, state->advertising, mask,
860 - __ETHTOOL_LINK_MODE_MASK_NBITS);
861 + linkmode_and(supported, supported, mask);
862 + linkmode_and(state->advertising, state->advertising, mask);
865 static void vsc7514_phylink_mac_config(struct phylink_config *config,
866 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
867 +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
868 @@ -228,8 +228,7 @@ static int ionic_get_link_ksettings(stru
872 - bitmap_copy(ks->link_modes.advertising, ks->link_modes.supported,
873 - __ETHTOOL_LINK_MODE_MASK_NBITS);
874 + linkmode_copy(ks->link_modes.advertising, ks->link_modes.supported);
876 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);
877 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);
878 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
879 +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
880 @@ -1565,7 +1565,7 @@ static void axienet_validate(struct phyl
881 netdev_warn(ndev, "Cannot use PHY mode %s, supported: %s\n",
882 phy_modes(state->interface),
883 phy_modes(lp->phy_mode));
884 - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
885 + linkmode_zero(supported);
889 @@ -1598,10 +1598,8 @@ static void axienet_validate(struct phyl
893 - bitmap_and(supported, supported, mask,
894 - __ETHTOOL_LINK_MODE_MASK_NBITS);
895 - bitmap_and(state->advertising, state->advertising, mask,
896 - __ETHTOOL_LINK_MODE_MASK_NBITS);
897 + linkmode_and(supported, supported, mask);
898 + linkmode_and(state->advertising, state->advertising, mask);
901 static void axienet_mac_pcs_get_state(struct phylink_config *config,
902 --- a/drivers/net/pcs/pcs-xpcs.c
903 +++ b/drivers/net/pcs/pcs-xpcs.c
904 @@ -637,7 +637,7 @@ void xpcs_validate(struct dw_xpcs *xpcs,
905 if (state->interface == PHY_INTERFACE_MODE_NA)
908 - bitmap_zero(xpcs_supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
909 + linkmode_zero(xpcs_supported);
911 compat = xpcs_find_compat(xpcs->id, state->interface);
913 --- a/drivers/net/phy/sfp-bus.c
914 +++ b/drivers/net/phy/sfp-bus.c
915 @@ -379,7 +379,7 @@ void sfp_parse_support(struct sfp_bus *b
917 bus->sfp_quirk->modes(id, modes);
919 - bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS);
920 + linkmode_or(support, support, modes);
922 phylink_set(support, Autoneg);
923 phylink_set(support, Pause);
924 --- a/net/ethtool/ioctl.c
925 +++ b/net/ethtool/ioctl.c
926 @@ -335,7 +335,7 @@ EXPORT_SYMBOL(ethtool_intersect_link_mas
927 void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
930 - bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS);
931 + linkmode_zero(dst);
934 EXPORT_SYMBOL(ethtool_convert_legacy_u32_to_link_mode);
935 @@ -350,11 +350,10 @@ bool ethtool_convert_link_mode_to_legacy
936 if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) {
937 __ETHTOOL_DECLARE_LINK_MODE_MASK(ext);
939 - bitmap_zero(ext, __ETHTOOL_LINK_MODE_MASK_NBITS);
940 + linkmode_zero(ext);
941 bitmap_fill(ext, 32);
942 bitmap_complement(ext, ext, __ETHTOOL_LINK_MODE_MASK_NBITS);
943 - if (bitmap_intersects(ext, src,
944 - __ETHTOOL_LINK_MODE_MASK_NBITS)) {
945 + if (linkmode_intersects(ext, src)) {
946 /* src mask goes beyond bit 31 */