Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nfp: ethtool: support TX/RX pause frame on/off

Add support for ethtool -A tx on/off and rx on/off.

Signed-off-by: Yu Xiao <yu.xiao@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20231127055116.6668-1-louis.peens@corigine.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Yu Xiao and committed by
Jakub Kicinski
4540c29a a3799729

+124 -4
+29 -3
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
··· 2235 2235 return nfp_net_set_num_rings(nn, total_rx, total_tx); 2236 2236 } 2237 2237 2238 + static int nfp_port_set_pauseparam(struct net_device *netdev, 2239 + struct ethtool_pauseparam *pause) 2240 + { 2241 + struct nfp_eth_table_port *eth_port; 2242 + struct nfp_port *port; 2243 + int err; 2244 + 2245 + port = nfp_port_from_netdev(netdev); 2246 + eth_port = nfp_port_get_eth_port(port); 2247 + if (!eth_port) 2248 + return -EOPNOTSUPP; 2249 + 2250 + if (pause->autoneg != AUTONEG_DISABLE) 2251 + return -EOPNOTSUPP; 2252 + 2253 + err = nfp_eth_set_pauseparam(port->app->cpp, eth_port->index, 2254 + pause->tx_pause, pause->rx_pause); 2255 + if (!err) 2256 + /* Only refresh if we did something */ 2257 + nfp_net_refresh_port_table(port); 2258 + 2259 + return err < 0 ? err : 0; 2260 + } 2261 + 2238 2262 static void nfp_port_get_pauseparam(struct net_device *netdev, 2239 2263 struct ethtool_pauseparam *pause) 2240 2264 { ··· 2270 2246 if (!eth_port) 2271 2247 return; 2272 2248 2273 - /* Currently pause frame support is fixed */ 2249 + /* Currently pause frame autoneg is fixed */ 2274 2250 pause->autoneg = AUTONEG_DISABLE; 2275 - pause->rx_pause = 1; 2276 - pause->tx_pause = 1; 2251 + pause->rx_pause = eth_port->rx_pause; 2252 + pause->tx_pause = eth_port->tx_pause; 2277 2253 } 2278 2254 2279 2255 static int nfp_net_set_phys_id(struct net_device *netdev, ··· 2499 2475 .set_link_ksettings = nfp_net_set_link_ksettings, 2500 2476 .get_fecparam = nfp_port_get_fecparam, 2501 2477 .set_fecparam = nfp_port_set_fecparam, 2478 + .set_pauseparam = nfp_port_set_pauseparam, 2502 2479 .get_pauseparam = nfp_port_get_pauseparam, 2503 2480 .set_phys_id = nfp_net_set_phys_id, 2504 2481 }; ··· 2524 2499 .set_link_ksettings = nfp_net_set_link_ksettings, 2525 2500 .get_fecparam = nfp_port_get_fecparam, 2526 2501 .set_fecparam = nfp_port_set_fecparam, 2502 + .set_pauseparam = nfp_port_set_pauseparam, 2527 2503 .get_pauseparam = nfp_port_get_pauseparam, 2528 2504 .set_phys_id = nfp_net_set_phys_id, 2529 2505 };
+6
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
··· 189 189 * @ports.enabled: is enabled? 190 190 * @ports.tx_enabled: is TX enabled? 191 191 * @ports.rx_enabled: is RX enabled? 192 + * @ports.rx_pause: Switch of RX pause frame 193 + * @ports.tx_pause: Switch of Tx pause frame 192 194 * @ports.override_changed: is media reconfig pending? 193 195 * 194 196 * @ports.port_type: one of %PORT_* defines for ethtool ··· 229 227 bool tx_enabled; 230 228 bool rx_enabled; 231 229 bool supp_aneg; 230 + bool rx_pause; 231 + bool tx_pause; 232 232 233 233 bool override_changed; 234 234 ··· 259 255 nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode); 260 256 261 257 int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state); 258 + int nfp_eth_set_pauseparam(struct nfp_cpp *cpp, unsigned int idx, 259 + unsigned int tx_pause, unsigned int rx_pause); 262 260 263 261 static inline bool nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port) 264 262 {
+89 -1
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
··· 42 42 #define NSP_ETH_STATE_ANEG GENMASK_ULL(25, 23) 43 43 #define NSP_ETH_STATE_FEC GENMASK_ULL(27, 26) 44 44 #define NSP_ETH_STATE_ACT_FEC GENMASK_ULL(29, 28) 45 + #define NSP_ETH_STATE_TX_PAUSE BIT_ULL(31) 46 + #define NSP_ETH_STATE_RX_PAUSE BIT_ULL(32) 45 47 46 48 #define NSP_ETH_CTRL_CONFIGURED BIT_ULL(0) 47 49 #define NSP_ETH_CTRL_ENABLED BIT_ULL(1) ··· 54 52 #define NSP_ETH_CTRL_SET_ANEG BIT_ULL(6) 55 53 #define NSP_ETH_CTRL_SET_FEC BIT_ULL(7) 56 54 #define NSP_ETH_CTRL_SET_IDMODE BIT_ULL(8) 55 + #define NSP_ETH_CTRL_SET_TX_PAUSE BIT_ULL(10) 56 + #define NSP_ETH_CTRL_SET_RX_PAUSE BIT_ULL(11) 57 57 58 58 enum nfp_eth_raw { 59 59 NSP_ETH_RAW_PORT = 0, ··· 184 180 185 181 dst->act_fec = FIELD_GET(NSP_ETH_STATE_ACT_FEC, state); 186 182 dst->supp_aneg = FIELD_GET(NSP_ETH_PORT_SUPP_ANEG, port); 183 + 184 + if (nfp_nsp_get_abi_ver_minor(nsp) < 37) { 185 + dst->tx_pause = true; 186 + dst->rx_pause = true; 187 + return; 188 + } 189 + 190 + dst->tx_pause = FIELD_GET(NSP_ETH_STATE_TX_PAUSE, state); 191 + dst->rx_pause = FIELD_GET(NSP_ETH_STATE_RX_PAUSE, state); 187 192 } 188 193 189 194 static void ··· 510 497 static int 511 498 nfp_eth_set_bit_config(struct nfp_nsp *nsp, unsigned int raw_idx, 512 499 const u64 mask, const unsigned int shift, 513 - unsigned int val, const u64 ctrl_bit) 500 + u64 val, const u64 ctrl_bit) 514 501 { 515 502 union eth_table_entry *entries = nfp_nsp_config_entries(nsp); 516 503 unsigned int idx = nfp_nsp_config_idx(nsp); ··· 634 621 return PTR_ERR(nsp); 635 622 636 623 err = __nfp_eth_set_fec(nsp, mode); 624 + if (err) { 625 + nfp_eth_config_cleanup_end(nsp); 626 + return err; 627 + } 628 + 629 + return nfp_eth_config_commit_end(nsp); 630 + } 631 + 632 + /** 633 + * __nfp_eth_set_txpause() - set tx pause control bit 634 + * @nsp: NFP NSP handle returned from nfp_eth_config_start() 635 + * @tx_pause: TX pause switch 636 + * 637 + * Set TX pause switch. 638 + * 639 + * Return: 0 or -ERRNO. 640 + */ 641 + static int __nfp_eth_set_txpause(struct nfp_nsp *nsp, unsigned int tx_pause) 642 + { 643 + return NFP_ETH_SET_BIT_CONFIG(nsp, NSP_ETH_RAW_STATE, NSP_ETH_STATE_TX_PAUSE, 644 + tx_pause, NSP_ETH_CTRL_SET_TX_PAUSE); 645 + } 646 + 647 + /** 648 + * __nfp_eth_set_rxpause() - set rx pause control bit 649 + * @nsp: NFP NSP handle returned from nfp_eth_config_start() 650 + * @rx_pause: RX pause switch 651 + * 652 + * Set RX pause switch. 653 + * 654 + * Return: 0 or -ERRNO. 655 + */ 656 + static int __nfp_eth_set_rxpause(struct nfp_nsp *nsp, unsigned int rx_pause) 657 + { 658 + return NFP_ETH_SET_BIT_CONFIG(nsp, NSP_ETH_RAW_STATE, NSP_ETH_STATE_RX_PAUSE, 659 + rx_pause, NSP_ETH_CTRL_SET_RX_PAUSE); 660 + } 661 + 662 + /** 663 + * nfp_eth_set_pauseparam() - Set TX/RX pause switch. 664 + * @cpp: NFP CPP handle 665 + * @idx: NFP chip-wide port index 666 + * @tx_pause: TX pause switch 667 + * @rx_pause: RX pause switch 668 + * 669 + * Return: 670 + * 0 - configuration successful; 671 + * 1 - no changes were needed; 672 + * -ERRNO - configuration failed. 673 + */ 674 + int 675 + nfp_eth_set_pauseparam(struct nfp_cpp *cpp, unsigned int idx, 676 + unsigned int tx_pause, unsigned int rx_pause) 677 + { 678 + struct nfp_nsp *nsp; 679 + int err; 680 + 681 + nsp = nfp_eth_config_start(cpp, idx); 682 + if (IS_ERR(nsp)) 683 + return PTR_ERR(nsp); 684 + 685 + if (nfp_nsp_get_abi_ver_minor(nsp) < 37) { 686 + nfp_err(nfp_nsp_cpp(nsp), 687 + "set pause parameter operation not supported, please update flash\n"); 688 + nfp_eth_config_cleanup_end(nsp); 689 + return -EOPNOTSUPP; 690 + } 691 + 692 + err = __nfp_eth_set_txpause(nsp, tx_pause); 693 + if (err) { 694 + nfp_eth_config_cleanup_end(nsp); 695 + return err; 696 + } 697 + 698 + err = __nfp_eth_set_rxpause(nsp, rx_pause); 637 699 if (err) { 638 700 nfp_eth_config_cleanup_end(nsp); 639 701 return err;