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.

net: txgbe: add sriov function support

Add sriov_configure for driver ops.
Add mailbox handler wx_msg_task for txgbe.

Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
Link: https://patch.msgid.link/ECDC57CF4F2316B9+20250408091556.9640-7-mengyuanlou@net-swift.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Mengyuan Lou and committed by
Jakub Kicinski
a9843689 877253d2

+101 -4
+42
drivers/net/ethernet/wangxun/libwx/wx_sriov.c
··· 282 282 wr32(wx, WX_TDM_VLAN_INS(vf), 0); 283 283 } 284 284 285 + static void wx_ping_vf(struct wx *wx, int vf) 286 + { 287 + u32 ping = WX_PF_CONTROL_MSG; 288 + 289 + if (wx->vfinfo[vf].clear_to_send) 290 + ping |= WX_VT_MSGTYPE_CTS; 291 + wx_write_mbx_pf(wx, &ping, 1, vf); 292 + } 293 + 285 294 static void wx_set_vf_rx_tx(struct wx *wx, int vf) 286 295 { 287 296 u32 index = WX_VF_REG_OFFSET(vf), vf_bit = WX_VF_IND_SHIFT(vf); ··· 874 865 } 875 866 } 876 867 EXPORT_SYMBOL(wx_ping_all_vfs_with_link_status); 868 + 869 + static void wx_set_vf_link_state(struct wx *wx, int vf, int state) 870 + { 871 + wx->vfinfo[vf].link_state = state; 872 + switch (state) { 873 + case IFLA_VF_LINK_STATE_AUTO: 874 + if (netif_running(wx->netdev)) 875 + wx->vfinfo[vf].link_enable = true; 876 + else 877 + wx->vfinfo[vf].link_enable = false; 878 + break; 879 + case IFLA_VF_LINK_STATE_ENABLE: 880 + wx->vfinfo[vf].link_enable = true; 881 + break; 882 + case IFLA_VF_LINK_STATE_DISABLE: 883 + wx->vfinfo[vf].link_enable = false; 884 + break; 885 + } 886 + /* restart the VF */ 887 + wx->vfinfo[vf].clear_to_send = false; 888 + wx_ping_vf(wx, vf); 889 + 890 + wx_set_vf_rx_tx(wx, vf); 891 + } 892 + 893 + void wx_set_all_vfs(struct wx *wx) 894 + { 895 + int i; 896 + 897 + for (i = 0; i < wx->num_vfs; i++) 898 + wx_set_vf_link_state(wx, i, wx->vfinfo[i].link_state); 899 + } 900 + EXPORT_SYMBOL(wx_set_all_vfs);
+1
drivers/net/ethernet/wangxun/libwx/wx_sriov.h
··· 13 13 void wx_msg_task(struct wx *wx); 14 14 void wx_disable_vf_rx_tx(struct wx *wx); 15 15 void wx_ping_all_vfs_with_link_status(struct wx *wx, bool link_up); 16 + void wx_set_all_vfs(struct wx *wx); 16 17 17 18 #endif /* _WX_SRIOV_H_ */
+1
drivers/net/ethernet/wangxun/libwx/wx_type.h
··· 1173 1173 u16 vf_mc_hashes[WX_MAX_VF_MC_ENTRIES]; 1174 1174 u16 num_vf_mc_hashes; 1175 1175 u16 vlan_count; 1176 + int link_state; 1176 1177 }; 1177 1178 1178 1179 struct vf_macvlans {
+18 -3
drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c
··· 7 7 #include "../libwx/wx_type.h" 8 8 #include "../libwx/wx_lib.h" 9 9 #include "../libwx/wx_hw.h" 10 + #include "../libwx/wx_sriov.h" 10 11 #include "txgbe_type.h" 11 12 #include "txgbe_phy.h" 12 13 #include "txgbe_irq.h" ··· 110 109 struct wx *wx = txgbe->wx; 111 110 u32 eicr; 112 111 113 - if (wx->pdev->msix_enabled) 112 + if (wx->pdev->msix_enabled) { 113 + eicr = wx_misc_isb(wx, WX_ISB_MISC); 114 + if (!eicr) 115 + return IRQ_NONE; 116 + txgbe->eicr = eicr; 117 + if (eicr & TXGBE_PX_MISC_IC_VF_MBOX) { 118 + wx_msg_task(txgbe->wx); 119 + wx_intr_enable(wx, TXGBE_INTR_MISC); 120 + } 114 121 return IRQ_WAKE_THREAD; 122 + } 115 123 116 124 eicr = wx_misc_isb(wx, WX_ISB_VEC0); 117 125 if (!eicr) { ··· 139 129 q_vector = wx->q_vector[0]; 140 130 napi_schedule_irqoff(&q_vector->napi); 141 131 132 + eicr = wx_misc_isb(wx, WX_ISB_MISC); 133 + if (!eicr) 134 + return IRQ_NONE; 135 + txgbe->eicr = eicr; 136 + 142 137 return IRQ_WAKE_THREAD; 143 138 } 144 139 ··· 155 140 unsigned int sub_irq; 156 141 u32 eicr; 157 142 158 - eicr = wx_misc_isb(wx, WX_ISB_MISC); 143 + eicr = txgbe->eicr; 159 144 if (eicr & (TXGBE_PX_MISC_ETH_LK | TXGBE_PX_MISC_ETH_LKDN | 160 145 TXGBE_PX_MISC_ETH_AN)) { 161 146 sub_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_LINK); ··· 198 183 if (wx->mac.type == wx_mac_aml) 199 184 goto skip_sp_irq; 200 185 201 - txgbe->misc.nirqs = 1; 186 + txgbe->misc.nirqs = TXGBE_IRQ_MAX; 202 187 txgbe->misc.domain = irq_domain_add_simple(NULL, txgbe->misc.nirqs, 0, 203 188 &txgbe_misc_irq_domain_ops, txgbe); 204 189 if (!txgbe->misc.domain)
+27
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
··· 15 15 #include "../libwx/wx_lib.h" 16 16 #include "../libwx/wx_ptp.h" 17 17 #include "../libwx/wx_hw.h" 18 + #include "../libwx/wx_mbx.h" 19 + #include "../libwx/wx_sriov.h" 18 20 #include "txgbe_type.h" 19 21 #include "txgbe_hw.h" 20 22 #include "txgbe_phy.h" ··· 119 117 120 118 /* enable transmits */ 121 119 netif_tx_start_all_queues(netdev); 120 + 121 + /* Set PF Reset Done bit so PF/VF Mail Ops can work */ 122 + wr32m(wx, WX_CFG_PORT_CTL, WX_CFG_PORT_CTL_PFRSTD, 123 + WX_CFG_PORT_CTL_PFRSTD); 124 + /* update setting rx tx for all active vfs */ 125 + wx_set_all_vfs(wx); 122 126 } 123 127 124 128 static void txgbe_reset(struct wx *wx) ··· 172 164 else 173 165 wx_err(wx, "%s: invalid bus lan id %d\n", 174 166 __func__, wx->bus.func); 167 + 168 + if (wx->num_vfs) { 169 + /* Clear EITR Select mapping */ 170 + wr32(wx, WX_PX_ITRSEL, 0); 171 + /* Mark all the VFs as inactive */ 172 + for (i = 0; i < wx->num_vfs; i++) 173 + wx->vfinfo[i].clear_to_send = 0; 174 + /* update setting rx tx for all active vfs */ 175 + wx_set_all_vfs(wx); 176 + } 175 177 176 178 if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || 177 179 ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { ··· 325 307 /* set default ring sizes */ 326 308 wx->tx_ring_count = TXGBE_DEFAULT_TXD; 327 309 wx->rx_ring_count = TXGBE_DEFAULT_RXD; 310 + wx->mbx.size = WX_VXMAILBOX_SIZE; 328 311 329 312 /* set default work limits */ 330 313 wx->tx_work_limit = TXGBE_DEFAULT_TX_WORK; 331 314 wx->rx_work_limit = TXGBE_DEFAULT_RX_WORK; 332 315 316 + wx->setup_tc = txgbe_setup_tc; 333 317 wx->do_reset = txgbe_do_reset; 318 + set_bit(0, &wx->fwd_bitmask); 334 319 335 320 switch (wx->mac.type) { 336 321 case wx_mac_sp: ··· 625 604 goto err_pci_release_regions; 626 605 } 627 606 607 + /* The sapphire supports up to 63 VFs per pf, but physical 608 + * function also need one pool for basic networking. 609 + */ 610 + pci_sriov_set_totalvfs(pdev, TXGBE_MAX_VFS_DRV_LIMIT); 628 611 wx->driver_name = txgbe_driver_name; 629 612 txgbe_set_ethtool_ops(netdev); 630 613 netdev->netdev_ops = &txgbe_netdev_ops; ··· 819 794 struct net_device *netdev; 820 795 821 796 netdev = wx->netdev; 797 + wx_disable_sriov(wx); 822 798 unregister_netdev(netdev); 823 799 824 800 txgbe_remove_phy(txgbe); ··· 842 816 .probe = txgbe_probe, 843 817 .remove = txgbe_remove, 844 818 .shutdown = txgbe_shutdown, 819 + .sriov_configure = wx_pci_sriov_configure, 845 820 }; 846 821 847 822 module_pci_driver(txgbe_driver);
+6
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
··· 16 16 #include "../libwx/wx_type.h" 17 17 #include "../libwx/wx_lib.h" 18 18 #include "../libwx/wx_ptp.h" 19 + #include "../libwx/wx_sriov.h" 20 + #include "../libwx/wx_mbx.h" 19 21 #include "../libwx/wx_hw.h" 20 22 #include "txgbe_type.h" 21 23 #include "txgbe_phy.h" ··· 186 184 wx->speed = SPEED_UNKNOWN; 187 185 if (test_bit(WX_STATE_PTP_RUNNING, wx->state)) 188 186 wx_ptp_reset_cyclecounter(wx); 187 + /* ping all the active vfs to let them know we are going down */ 188 + wx_ping_all_vfs_with_link_status(wx, false); 189 189 } 190 190 191 191 static void txgbe_mac_link_up(struct phylink_config *config, ··· 229 225 wx->last_rx_ptp_check = jiffies; 230 226 if (test_bit(WX_STATE_PTP_RUNNING, wx->state)) 231 227 wx_ptp_reset_cyclecounter(wx); 228 + /* ping all the active vfs to let them know we are going up */ 229 + wx_ping_all_vfs_with_link_status(wx, true); 232 230 } 233 231 234 232 static int txgbe_mac_prepare(struct phylink_config *config, unsigned int mode,
+6 -1
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
··· 77 77 #define TXGBE_PX_MISC_ETH_LK BIT(18) 78 78 #define TXGBE_PX_MISC_ETH_AN BIT(19) 79 79 #define TXGBE_PX_MISC_INT_ERR BIT(20) 80 + #define TXGBE_PX_MISC_IC_VF_MBOX BIT(23) 80 81 #define TXGBE_PX_MISC_GPIO BIT(26) 81 82 #define TXGBE_PX_MISC_IEN_MASK \ 82 83 (TXGBE_PX_MISC_ETH_LKDN | TXGBE_PX_MISC_DEV_RST | \ 83 84 TXGBE_PX_MISC_ETH_EVENT | TXGBE_PX_MISC_ETH_LK | \ 84 - TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR) 85 + TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR | \ 86 + TXGBE_PX_MISC_IC_VF_MBOX) 85 87 86 88 /* Port cfg registers */ 87 89 #define TXGBE_CFG_PORT_ST 0x14404 ··· 175 173 #define TXGBE_SP_VFT_TBL_SIZE 128 176 174 #define TXGBE_SP_RX_PB_SIZE 512 177 175 #define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */ 176 + 177 + #define TXGBE_MAX_VFS_DRV_LIMIT 63 178 178 179 179 #define TXGBE_DEFAULT_ATR_SAMPLE_RATE 20 180 180 ··· 352 348 struct clk *clk; 353 349 struct gpio_chip *gpio; 354 350 unsigned int link_irq; 351 + u32 eicr; 355 352 356 353 /* flow director */ 357 354 struct hlist_head fdir_filter_list;