mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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>
This commit is contained in:
parent
877253d2cb
commit
a9843689e2
7 changed files with 101 additions and 4 deletions
|
@ -282,6 +282,15 @@ static void wx_clear_vmvir(struct wx *wx, u32 vf)
|
|||
wr32(wx, WX_TDM_VLAN_INS(vf), 0);
|
||||
}
|
||||
|
||||
static void wx_ping_vf(struct wx *wx, int vf)
|
||||
{
|
||||
u32 ping = WX_PF_CONTROL_MSG;
|
||||
|
||||
if (wx->vfinfo[vf].clear_to_send)
|
||||
ping |= WX_VT_MSGTYPE_CTS;
|
||||
wx_write_mbx_pf(wx, &ping, 1, vf);
|
||||
}
|
||||
|
||||
static void wx_set_vf_rx_tx(struct wx *wx, int vf)
|
||||
{
|
||||
u32 index = WX_VF_REG_OFFSET(vf), vf_bit = WX_VF_IND_SHIFT(vf);
|
||||
|
@ -865,3 +874,36 @@ void wx_ping_all_vfs_with_link_status(struct wx *wx, bool link_up)
|
|||
}
|
||||
}
|
||||
EXPORT_SYMBOL(wx_ping_all_vfs_with_link_status);
|
||||
|
||||
static void wx_set_vf_link_state(struct wx *wx, int vf, int state)
|
||||
{
|
||||
wx->vfinfo[vf].link_state = state;
|
||||
switch (state) {
|
||||
case IFLA_VF_LINK_STATE_AUTO:
|
||||
if (netif_running(wx->netdev))
|
||||
wx->vfinfo[vf].link_enable = true;
|
||||
else
|
||||
wx->vfinfo[vf].link_enable = false;
|
||||
break;
|
||||
case IFLA_VF_LINK_STATE_ENABLE:
|
||||
wx->vfinfo[vf].link_enable = true;
|
||||
break;
|
||||
case IFLA_VF_LINK_STATE_DISABLE:
|
||||
wx->vfinfo[vf].link_enable = false;
|
||||
break;
|
||||
}
|
||||
/* restart the VF */
|
||||
wx->vfinfo[vf].clear_to_send = false;
|
||||
wx_ping_vf(wx, vf);
|
||||
|
||||
wx_set_vf_rx_tx(wx, vf);
|
||||
}
|
||||
|
||||
void wx_set_all_vfs(struct wx *wx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < wx->num_vfs; i++)
|
||||
wx_set_vf_link_state(wx, i, wx->vfinfo[i].link_state);
|
||||
}
|
||||
EXPORT_SYMBOL(wx_set_all_vfs);
|
||||
|
|
|
@ -13,5 +13,6 @@ int wx_pci_sriov_configure(struct pci_dev *pdev, int num_vfs);
|
|||
void wx_msg_task(struct wx *wx);
|
||||
void wx_disable_vf_rx_tx(struct wx *wx);
|
||||
void wx_ping_all_vfs_with_link_status(struct wx *wx, bool link_up);
|
||||
void wx_set_all_vfs(struct wx *wx);
|
||||
|
||||
#endif /* _WX_SRIOV_H_ */
|
||||
|
|
|
@ -1173,6 +1173,7 @@ struct vf_data_storage {
|
|||
u16 vf_mc_hashes[WX_MAX_VF_MC_ENTRIES];
|
||||
u16 num_vf_mc_hashes;
|
||||
u16 vlan_count;
|
||||
int link_state;
|
||||
};
|
||||
|
||||
struct vf_macvlans {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../libwx/wx_type.h"
|
||||
#include "../libwx/wx_lib.h"
|
||||
#include "../libwx/wx_hw.h"
|
||||
#include "../libwx/wx_sriov.h"
|
||||
#include "txgbe_type.h"
|
||||
#include "txgbe_phy.h"
|
||||
#include "txgbe_irq.h"
|
||||
|
@ -109,8 +110,17 @@ static irqreturn_t txgbe_misc_irq_handle(int irq, void *data)
|
|||
struct wx *wx = txgbe->wx;
|
||||
u32 eicr;
|
||||
|
||||
if (wx->pdev->msix_enabled)
|
||||
if (wx->pdev->msix_enabled) {
|
||||
eicr = wx_misc_isb(wx, WX_ISB_MISC);
|
||||
if (!eicr)
|
||||
return IRQ_NONE;
|
||||
txgbe->eicr = eicr;
|
||||
if (eicr & TXGBE_PX_MISC_IC_VF_MBOX) {
|
||||
wx_msg_task(txgbe->wx);
|
||||
wx_intr_enable(wx, TXGBE_INTR_MISC);
|
||||
}
|
||||
return IRQ_WAKE_THREAD;
|
||||
}
|
||||
|
||||
eicr = wx_misc_isb(wx, WX_ISB_VEC0);
|
||||
if (!eicr) {
|
||||
|
@ -129,6 +139,11 @@ static irqreturn_t txgbe_misc_irq_handle(int irq, void *data)
|
|||
q_vector = wx->q_vector[0];
|
||||
napi_schedule_irqoff(&q_vector->napi);
|
||||
|
||||
eicr = wx_misc_isb(wx, WX_ISB_MISC);
|
||||
if (!eicr)
|
||||
return IRQ_NONE;
|
||||
txgbe->eicr = eicr;
|
||||
|
||||
return IRQ_WAKE_THREAD;
|
||||
}
|
||||
|
||||
|
@ -140,7 +155,7 @@ static irqreturn_t txgbe_misc_irq_thread_fn(int irq, void *data)
|
|||
unsigned int sub_irq;
|
||||
u32 eicr;
|
||||
|
||||
eicr = wx_misc_isb(wx, WX_ISB_MISC);
|
||||
eicr = txgbe->eicr;
|
||||
if (eicr & (TXGBE_PX_MISC_ETH_LK | TXGBE_PX_MISC_ETH_LKDN |
|
||||
TXGBE_PX_MISC_ETH_AN)) {
|
||||
sub_irq = irq_find_mapping(txgbe->misc.domain, TXGBE_IRQ_LINK);
|
||||
|
@ -183,7 +198,7 @@ int txgbe_setup_misc_irq(struct txgbe *txgbe)
|
|||
if (wx->mac.type == wx_mac_aml)
|
||||
goto skip_sp_irq;
|
||||
|
||||
txgbe->misc.nirqs = 1;
|
||||
txgbe->misc.nirqs = TXGBE_IRQ_MAX;
|
||||
txgbe->misc.domain = irq_domain_add_simple(NULL, txgbe->misc.nirqs, 0,
|
||||
&txgbe_misc_irq_domain_ops, txgbe);
|
||||
if (!txgbe->misc.domain)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "../libwx/wx_lib.h"
|
||||
#include "../libwx/wx_ptp.h"
|
||||
#include "../libwx/wx_hw.h"
|
||||
#include "../libwx/wx_mbx.h"
|
||||
#include "../libwx/wx_sriov.h"
|
||||
#include "txgbe_type.h"
|
||||
#include "txgbe_hw.h"
|
||||
#include "txgbe_phy.h"
|
||||
|
@ -117,6 +119,12 @@ static void txgbe_up_complete(struct wx *wx)
|
|||
|
||||
/* enable transmits */
|
||||
netif_tx_start_all_queues(netdev);
|
||||
|
||||
/* Set PF Reset Done bit so PF/VF Mail Ops can work */
|
||||
wr32m(wx, WX_CFG_PORT_CTL, WX_CFG_PORT_CTL_PFRSTD,
|
||||
WX_CFG_PORT_CTL_PFRSTD);
|
||||
/* update setting rx tx for all active vfs */
|
||||
wx_set_all_vfs(wx);
|
||||
}
|
||||
|
||||
static void txgbe_reset(struct wx *wx)
|
||||
|
@ -165,6 +173,16 @@ static void txgbe_disable_device(struct wx *wx)
|
|||
wx_err(wx, "%s: invalid bus lan id %d\n",
|
||||
__func__, wx->bus.func);
|
||||
|
||||
if (wx->num_vfs) {
|
||||
/* Clear EITR Select mapping */
|
||||
wr32(wx, WX_PX_ITRSEL, 0);
|
||||
/* Mark all the VFs as inactive */
|
||||
for (i = 0; i < wx->num_vfs; i++)
|
||||
wx->vfinfo[i].clear_to_send = 0;
|
||||
/* update setting rx tx for all active vfs */
|
||||
wx_set_all_vfs(wx);
|
||||
}
|
||||
|
||||
if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) ||
|
||||
((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) {
|
||||
/* disable mac transmiter */
|
||||
|
@ -307,12 +325,15 @@ static int txgbe_sw_init(struct wx *wx)
|
|||
/* set default ring sizes */
|
||||
wx->tx_ring_count = TXGBE_DEFAULT_TXD;
|
||||
wx->rx_ring_count = TXGBE_DEFAULT_RXD;
|
||||
wx->mbx.size = WX_VXMAILBOX_SIZE;
|
||||
|
||||
/* set default work limits */
|
||||
wx->tx_work_limit = TXGBE_DEFAULT_TX_WORK;
|
||||
wx->rx_work_limit = TXGBE_DEFAULT_RX_WORK;
|
||||
|
||||
wx->setup_tc = txgbe_setup_tc;
|
||||
wx->do_reset = txgbe_do_reset;
|
||||
set_bit(0, &wx->fwd_bitmask);
|
||||
|
||||
switch (wx->mac.type) {
|
||||
case wx_mac_sp:
|
||||
|
@ -604,6 +625,10 @@ static int txgbe_probe(struct pci_dev *pdev,
|
|||
goto err_pci_release_regions;
|
||||
}
|
||||
|
||||
/* The sapphire supports up to 63 VFs per pf, but physical
|
||||
* function also need one pool for basic networking.
|
||||
*/
|
||||
pci_sriov_set_totalvfs(pdev, TXGBE_MAX_VFS_DRV_LIMIT);
|
||||
wx->driver_name = txgbe_driver_name;
|
||||
txgbe_set_ethtool_ops(netdev);
|
||||
netdev->netdev_ops = &txgbe_netdev_ops;
|
||||
|
@ -794,6 +819,7 @@ static void txgbe_remove(struct pci_dev *pdev)
|
|||
struct net_device *netdev;
|
||||
|
||||
netdev = wx->netdev;
|
||||
wx_disable_sriov(wx);
|
||||
unregister_netdev(netdev);
|
||||
|
||||
txgbe_remove_phy(txgbe);
|
||||
|
@ -816,6 +842,7 @@ static struct pci_driver txgbe_driver = {
|
|||
.probe = txgbe_probe,
|
||||
.remove = txgbe_remove,
|
||||
.shutdown = txgbe_shutdown,
|
||||
.sriov_configure = wx_pci_sriov_configure,
|
||||
};
|
||||
|
||||
module_pci_driver(txgbe_driver);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "../libwx/wx_type.h"
|
||||
#include "../libwx/wx_lib.h"
|
||||
#include "../libwx/wx_ptp.h"
|
||||
#include "../libwx/wx_sriov.h"
|
||||
#include "../libwx/wx_mbx.h"
|
||||
#include "../libwx/wx_hw.h"
|
||||
#include "txgbe_type.h"
|
||||
#include "txgbe_phy.h"
|
||||
|
@ -184,6 +186,8 @@ static void txgbe_mac_link_down(struct phylink_config *config,
|
|||
wx->speed = SPEED_UNKNOWN;
|
||||
if (test_bit(WX_STATE_PTP_RUNNING, wx->state))
|
||||
wx_ptp_reset_cyclecounter(wx);
|
||||
/* ping all the active vfs to let them know we are going down */
|
||||
wx_ping_all_vfs_with_link_status(wx, false);
|
||||
}
|
||||
|
||||
static void txgbe_mac_link_up(struct phylink_config *config,
|
||||
|
@ -225,6 +229,8 @@ static void txgbe_mac_link_up(struct phylink_config *config,
|
|||
wx->last_rx_ptp_check = jiffies;
|
||||
if (test_bit(WX_STATE_PTP_RUNNING, wx->state))
|
||||
wx_ptp_reset_cyclecounter(wx);
|
||||
/* ping all the active vfs to let them know we are going up */
|
||||
wx_ping_all_vfs_with_link_status(wx, true);
|
||||
}
|
||||
|
||||
static int txgbe_mac_prepare(struct phylink_config *config, unsigned int mode,
|
||||
|
|
|
@ -77,11 +77,13 @@
|
|||
#define TXGBE_PX_MISC_ETH_LK BIT(18)
|
||||
#define TXGBE_PX_MISC_ETH_AN BIT(19)
|
||||
#define TXGBE_PX_MISC_INT_ERR BIT(20)
|
||||
#define TXGBE_PX_MISC_IC_VF_MBOX BIT(23)
|
||||
#define TXGBE_PX_MISC_GPIO BIT(26)
|
||||
#define TXGBE_PX_MISC_IEN_MASK \
|
||||
(TXGBE_PX_MISC_ETH_LKDN | TXGBE_PX_MISC_DEV_RST | \
|
||||
TXGBE_PX_MISC_ETH_EVENT | TXGBE_PX_MISC_ETH_LK | \
|
||||
TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR)
|
||||
TXGBE_PX_MISC_ETH_AN | TXGBE_PX_MISC_INT_ERR | \
|
||||
TXGBE_PX_MISC_IC_VF_MBOX)
|
||||
|
||||
/* Port cfg registers */
|
||||
#define TXGBE_CFG_PORT_ST 0x14404
|
||||
|
@ -174,6 +176,8 @@
|
|||
#define TXGBE_SP_RX_PB_SIZE 512
|
||||
#define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */
|
||||
|
||||
#define TXGBE_MAX_VFS_DRV_LIMIT 63
|
||||
|
||||
#define TXGBE_DEFAULT_ATR_SAMPLE_RATE 20
|
||||
|
||||
/* Software ATR hash keys */
|
||||
|
@ -348,6 +352,7 @@ struct txgbe {
|
|||
struct clk *clk;
|
||||
struct gpio_chip *gpio;
|
||||
unsigned int link_irq;
|
||||
u32 eicr;
|
||||
|
||||
/* flow director */
|
||||
struct hlist_head fdir_filter_list;
|
||||
|
|
Loading…
Add table
Reference in a new issue