diff options
author | Philippe Reynes <tremyfr@gmail.com> | 2016-12-14 18:12:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-17 21:31:41 -0500 |
commit | 7cafe8f82438ced6de4c6f17b872a02c10f7a63a (patch) | |
tree | 6da370cdcbbcb622741df27ce8313aa3c816a436 | |
parent | 99bff5ee44f32c3ca5115922e487b067d9c3dd6b (diff) |
net: sfc: use new api ethtool_{get|set}_link_ksettings
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Tested-by: Bert Kenward <bkenward@solarflare.com>
Acked-by: Bert Kenward <bkenward@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/sfc/ethtool.c | 35 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/mcdi_port.c | 60 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 12 |
3 files changed, 65 insertions, 42 deletions
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index f644216eda1b..87bdc56b4e3a 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c | |||
@@ -120,44 +120,53 @@ static int efx_ethtool_phys_id(struct net_device *net_dev, | |||
120 | } | 120 | } |
121 | 121 | ||
122 | /* This must be called with rtnl_lock held. */ | 122 | /* This must be called with rtnl_lock held. */ |
123 | static int efx_ethtool_get_settings(struct net_device *net_dev, | 123 | static int |
124 | struct ethtool_cmd *ecmd) | 124 | efx_ethtool_get_link_ksettings(struct net_device *net_dev, |
125 | struct ethtool_link_ksettings *cmd) | ||
125 | { | 126 | { |
126 | struct efx_nic *efx = netdev_priv(net_dev); | 127 | struct efx_nic *efx = netdev_priv(net_dev); |
127 | struct efx_link_state *link_state = &efx->link_state; | 128 | struct efx_link_state *link_state = &efx->link_state; |
129 | u32 supported; | ||
128 | 130 | ||
129 | mutex_lock(&efx->mac_lock); | 131 | mutex_lock(&efx->mac_lock); |
130 | efx->phy_op->get_settings(efx, ecmd); | 132 | efx->phy_op->get_link_ksettings(efx, cmd); |
131 | mutex_unlock(&efx->mac_lock); | 133 | mutex_unlock(&efx->mac_lock); |
132 | 134 | ||
133 | /* Both MACs support pause frames (bidirectional and respond-only) */ | 135 | /* Both MACs support pause frames (bidirectional and respond-only) */ |
134 | ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; | 136 | ethtool_convert_link_mode_to_legacy_u32(&supported, |
137 | cmd->link_modes.supported); | ||
138 | |||
139 | supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; | ||
140 | |||
141 | ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, | ||
142 | supported); | ||
135 | 143 | ||
136 | if (LOOPBACK_INTERNAL(efx)) { | 144 | if (LOOPBACK_INTERNAL(efx)) { |
137 | ethtool_cmd_speed_set(ecmd, link_state->speed); | 145 | cmd->base.speed = link_state->speed; |
138 | ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; | 146 | cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; |
139 | } | 147 | } |
140 | 148 | ||
141 | return 0; | 149 | return 0; |
142 | } | 150 | } |
143 | 151 | ||
144 | /* This must be called with rtnl_lock held. */ | 152 | /* This must be called with rtnl_lock held. */ |
145 | static int efx_ethtool_set_settings(struct net_device *net_dev, | 153 | static int |
146 | struct ethtool_cmd *ecmd) | 154 | efx_ethtool_set_link_ksettings(struct net_device *net_dev, |
155 | const struct ethtool_link_ksettings *cmd) | ||
147 | { | 156 | { |
148 | struct efx_nic *efx = netdev_priv(net_dev); | 157 | struct efx_nic *efx = netdev_priv(net_dev); |
149 | int rc; | 158 | int rc; |
150 | 159 | ||
151 | /* GMAC does not support 1000Mbps HD */ | 160 | /* GMAC does not support 1000Mbps HD */ |
152 | if ((ethtool_cmd_speed(ecmd) == SPEED_1000) && | 161 | if ((cmd->base.speed == SPEED_1000) && |
153 | (ecmd->duplex != DUPLEX_FULL)) { | 162 | (cmd->base.duplex != DUPLEX_FULL)) { |
154 | netif_dbg(efx, drv, efx->net_dev, | 163 | netif_dbg(efx, drv, efx->net_dev, |
155 | "rejecting unsupported 1000Mbps HD setting\n"); | 164 | "rejecting unsupported 1000Mbps HD setting\n"); |
156 | return -EINVAL; | 165 | return -EINVAL; |
157 | } | 166 | } |
158 | 167 | ||
159 | mutex_lock(&efx->mac_lock); | 168 | mutex_lock(&efx->mac_lock); |
160 | rc = efx->phy_op->set_settings(efx, ecmd); | 169 | rc = efx->phy_op->set_link_ksettings(efx, cmd); |
161 | mutex_unlock(&efx->mac_lock); | 170 | mutex_unlock(&efx->mac_lock); |
162 | return rc; | 171 | return rc; |
163 | } | 172 | } |
@@ -1342,8 +1351,6 @@ static int efx_ethtool_get_module_info(struct net_device *net_dev, | |||
1342 | } | 1351 | } |
1343 | 1352 | ||
1344 | const struct ethtool_ops efx_ethtool_ops = { | 1353 | const struct ethtool_ops efx_ethtool_ops = { |
1345 | .get_settings = efx_ethtool_get_settings, | ||
1346 | .set_settings = efx_ethtool_set_settings, | ||
1347 | .get_drvinfo = efx_ethtool_get_drvinfo, | 1354 | .get_drvinfo = efx_ethtool_get_drvinfo, |
1348 | .get_regs_len = efx_ethtool_get_regs_len, | 1355 | .get_regs_len = efx_ethtool_get_regs_len, |
1349 | .get_regs = efx_ethtool_get_regs, | 1356 | .get_regs = efx_ethtool_get_regs, |
@@ -1373,4 +1380,6 @@ const struct ethtool_ops efx_ethtool_ops = { | |||
1373 | .get_ts_info = efx_ethtool_get_ts_info, | 1380 | .get_ts_info = efx_ethtool_get_ts_info, |
1374 | .get_module_info = efx_ethtool_get_module_info, | 1381 | .get_module_info = efx_ethtool_get_module_info, |
1375 | .get_module_eeprom = efx_ethtool_get_module_eeprom, | 1382 | .get_module_eeprom = efx_ethtool_get_module_eeprom, |
1383 | .get_link_ksettings = efx_ethtool_get_link_ksettings, | ||
1384 | .set_link_ksettings = efx_ethtool_set_link_ksettings, | ||
1376 | }; | 1385 | }; |
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c index 9dcd396784ae..c905971c5f3a 100644 --- a/drivers/net/ethernet/sfc/mcdi_port.c +++ b/drivers/net/ethernet/sfc/mcdi_port.c | |||
@@ -503,45 +503,59 @@ static void efx_mcdi_phy_remove(struct efx_nic *efx) | |||
503 | kfree(phy_data); | 503 | kfree(phy_data); |
504 | } | 504 | } |
505 | 505 | ||
506 | static void efx_mcdi_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 506 | static void efx_mcdi_phy_get_link_ksettings(struct efx_nic *efx, |
507 | struct ethtool_link_ksettings *cmd) | ||
507 | { | 508 | { |
508 | struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; | 509 | struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; |
509 | MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN); | 510 | MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN); |
510 | int rc; | 511 | int rc; |
511 | 512 | u32 supported, advertising, lp_advertising; | |
512 | ecmd->supported = | 513 | |
513 | mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap); | 514 | supported = mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap); |
514 | ecmd->advertising = efx->link_advertising; | 515 | advertising = efx->link_advertising; |
515 | ethtool_cmd_speed_set(ecmd, efx->link_state.speed); | 516 | cmd->base.speed = efx->link_state.speed; |
516 | ecmd->duplex = efx->link_state.fd; | 517 | cmd->base.duplex = efx->link_state.fd; |
517 | ecmd->port = mcdi_to_ethtool_media(phy_cfg->media); | 518 | cmd->base.port = mcdi_to_ethtool_media(phy_cfg->media); |
518 | ecmd->phy_address = phy_cfg->port; | 519 | cmd->base.phy_address = phy_cfg->port; |
519 | ecmd->transceiver = XCVR_INTERNAL; | 520 | cmd->base.autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg); |
520 | ecmd->autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg); | 521 | cmd->base.mdio_support = (efx->mdio.mode_support & |
521 | ecmd->mdio_support = (efx->mdio.mode_support & | ||
522 | (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22)); | 522 | (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22)); |
523 | 523 | ||
524 | ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, | ||
525 | supported); | ||
526 | ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, | ||
527 | advertising); | ||
528 | |||
524 | BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0); | 529 | BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0); |
525 | rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, | 530 | rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, |
526 | outbuf, sizeof(outbuf), NULL); | 531 | outbuf, sizeof(outbuf), NULL); |
527 | if (rc) | 532 | if (rc) |
528 | return; | 533 | return; |
529 | ecmd->lp_advertising = | 534 | lp_advertising = |
530 | mcdi_to_ethtool_cap(phy_cfg->media, | 535 | mcdi_to_ethtool_cap(phy_cfg->media, |
531 | MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP)); | 536 | MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP)); |
537 | |||
538 | ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising, | ||
539 | lp_advertising); | ||
532 | } | 540 | } |
533 | 541 | ||
534 | static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 542 | static int |
543 | efx_mcdi_phy_set_link_ksettings(struct efx_nic *efx, | ||
544 | const struct ethtool_link_ksettings *cmd) | ||
535 | { | 545 | { |
536 | struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; | 546 | struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; |
537 | u32 caps; | 547 | u32 caps; |
538 | int rc; | 548 | int rc; |
549 | u32 advertising; | ||
550 | |||
551 | ethtool_convert_link_mode_to_legacy_u32(&advertising, | ||
552 | cmd->link_modes.advertising); | ||
539 | 553 | ||
540 | if (ecmd->autoneg) { | 554 | if (cmd->base.autoneg) { |
541 | caps = (ethtool_to_mcdi_cap(ecmd->advertising) | | 555 | caps = (ethtool_to_mcdi_cap(advertising) | |
542 | 1 << MC_CMD_PHY_CAP_AN_LBN); | 556 | 1 << MC_CMD_PHY_CAP_AN_LBN); |
543 | } else if (ecmd->duplex) { | 557 | } else if (cmd->base.duplex) { |
544 | switch (ethtool_cmd_speed(ecmd)) { | 558 | switch (cmd->base.speed) { |
545 | case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break; | 559 | case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break; |
546 | case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; | 560 | case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; |
547 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; | 561 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; |
@@ -550,7 +564,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec | |||
550 | default: return -EINVAL; | 564 | default: return -EINVAL; |
551 | } | 565 | } |
552 | } else { | 566 | } else { |
553 | switch (ethtool_cmd_speed(ecmd)) { | 567 | switch (cmd->base.speed) { |
554 | case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break; | 568 | case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break; |
555 | case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break; | 569 | case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break; |
556 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break; | 570 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break; |
@@ -563,9 +577,9 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec | |||
563 | if (rc) | 577 | if (rc) |
564 | return rc; | 578 | return rc; |
565 | 579 | ||
566 | if (ecmd->autoneg) { | 580 | if (cmd->base.autoneg) { |
567 | efx_link_set_advertising( | 581 | efx_link_set_advertising( |
568 | efx, ecmd->advertising | ADVERTISED_Autoneg); | 582 | efx, advertising | ADVERTISED_Autoneg); |
569 | phy_cfg->forced_cap = 0; | 583 | phy_cfg->forced_cap = 0; |
570 | } else { | 584 | } else { |
571 | efx_link_set_advertising(efx, 0); | 585 | efx_link_set_advertising(efx, 0); |
@@ -812,8 +826,8 @@ static const struct efx_phy_operations efx_mcdi_phy_ops = { | |||
812 | .poll = efx_mcdi_phy_poll, | 826 | .poll = efx_mcdi_phy_poll, |
813 | .fini = efx_port_dummy_op_void, | 827 | .fini = efx_port_dummy_op_void, |
814 | .remove = efx_mcdi_phy_remove, | 828 | .remove = efx_mcdi_phy_remove, |
815 | .get_settings = efx_mcdi_phy_get_settings, | 829 | .get_link_ksettings = efx_mcdi_phy_get_link_ksettings, |
816 | .set_settings = efx_mcdi_phy_set_settings, | 830 | .set_link_ksettings = efx_mcdi_phy_set_link_ksettings, |
817 | .test_alive = efx_mcdi_phy_test_alive, | 831 | .test_alive = efx_mcdi_phy_test_alive, |
818 | .run_tests = efx_mcdi_phy_run_tests, | 832 | .run_tests = efx_mcdi_phy_run_tests, |
819 | .test_name = efx_mcdi_phy_test_name, | 833 | .test_name = efx_mcdi_phy_test_name, |
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 8692e829b40f..1a635ced62d0 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -720,8 +720,8 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left, | |||
720 | * @reconfigure: Reconfigure PHY (e.g. for new link parameters) | 720 | * @reconfigure: Reconfigure PHY (e.g. for new link parameters) |
721 | * @poll: Update @link_state and report whether it changed. | 721 | * @poll: Update @link_state and report whether it changed. |
722 | * Serialised by the mac_lock. | 722 | * Serialised by the mac_lock. |
723 | * @get_settings: Get ethtool settings. Serialised by the mac_lock. | 723 | * @get_link_ksettings: Get ethtool settings. Serialised by the mac_lock. |
724 | * @set_settings: Set ethtool settings. Serialised by the mac_lock. | 724 | * @set_link_ksettings: Set ethtool settings. Serialised by the mac_lock. |
725 | * @set_npage_adv: Set abilities advertised in (Extended) Next Page | 725 | * @set_npage_adv: Set abilities advertised in (Extended) Next Page |
726 | * (only needed where AN bit is set in mmds) | 726 | * (only needed where AN bit is set in mmds) |
727 | * @test_alive: Test that PHY is 'alive' (online) | 727 | * @test_alive: Test that PHY is 'alive' (online) |
@@ -736,10 +736,10 @@ struct efx_phy_operations { | |||
736 | void (*remove) (struct efx_nic *efx); | 736 | void (*remove) (struct efx_nic *efx); |
737 | int (*reconfigure) (struct efx_nic *efx); | 737 | int (*reconfigure) (struct efx_nic *efx); |
738 | bool (*poll) (struct efx_nic *efx); | 738 | bool (*poll) (struct efx_nic *efx); |
739 | void (*get_settings) (struct efx_nic *efx, | 739 | void (*get_link_ksettings)(struct efx_nic *efx, |
740 | struct ethtool_cmd *ecmd); | 740 | struct ethtool_link_ksettings *cmd); |
741 | int (*set_settings) (struct efx_nic *efx, | 741 | int (*set_link_ksettings)(struct efx_nic *efx, |
742 | struct ethtool_cmd *ecmd); | 742 | const struct ethtool_link_ksettings *cmd); |
743 | void (*set_npage_adv) (struct efx_nic *efx, u32); | 743 | void (*set_npage_adv) (struct efx_nic *efx, u32); |
744 | int (*test_alive) (struct efx_nic *efx); | 744 | int (*test_alive) (struct efx_nic *efx); |
745 | const char *(*test_name) (struct efx_nic *efx, unsigned int index); | 745 | const char *(*test_name) (struct efx_nic *efx, unsigned int index); |