Skip to content

Commit b75a1de

Browse files
shifty91anguy11
authored andcommitted
igb: Link queues to NAPI instances
Link queues to NAPI instances via netdev-genl API. This is required to use XDP/ZC busy polling. See commit 5ef44b3 ("xsk: Bring back busy polling support") for details. This also allows users to query the info with netlink: |$ ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ | --dump queue-get --json='{"ifindex": 2}' |[{'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'rx'}, | {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'rx'}, | {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'rx'}, | {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'rx'}, | {'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'tx'}, | {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'tx'}, | {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'tx'}, | {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'tx'}] Add rtnl locking to PCI error handlers, because netif_queue_set_napi() requires the lock held. While at __igb_open() use RCT coding style. Signed-off-by: Kurt Kanzenbach <[email protected]> Reviewed-by: Joe Damato <[email protected]> Tested-by: Sweta Kumari <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 6fc54c4 commit b75a1de

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,8 @@ enum igb_boards {
722722

723723
extern char igb_driver_name[];
724724

725+
void igb_set_queue_napi(struct igb_adapter *adapter, int q_idx,
726+
struct napi_struct *napi);
725727
int igb_xmit_xdp_ring(struct igb_adapter *adapter,
726728
struct igb_ring *ring,
727729
struct xdp_frame *xdpf);

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,22 +2099,42 @@ static void igb_check_swap_media(struct igb_adapter *adapter)
20992099
wr32(E1000_CTRL_EXT, ctrl_ext);
21002100
}
21012101

2102+
void igb_set_queue_napi(struct igb_adapter *adapter, int vector,
2103+
struct napi_struct *napi)
2104+
{
2105+
struct igb_q_vector *q_vector = adapter->q_vector[vector];
2106+
2107+
if (q_vector->rx.ring)
2108+
netif_queue_set_napi(adapter->netdev,
2109+
q_vector->rx.ring->queue_index,
2110+
NETDEV_QUEUE_TYPE_RX, napi);
2111+
2112+
if (q_vector->tx.ring)
2113+
netif_queue_set_napi(adapter->netdev,
2114+
q_vector->tx.ring->queue_index,
2115+
NETDEV_QUEUE_TYPE_TX, napi);
2116+
}
2117+
21022118
/**
21032119
* igb_up - Open the interface and prepare it to handle traffic
21042120
* @adapter: board private structure
21052121
**/
21062122
int igb_up(struct igb_adapter *adapter)
21072123
{
21082124
struct e1000_hw *hw = &adapter->hw;
2125+
struct napi_struct *napi;
21092126
int i;
21102127

21112128
/* hardware has been reset, we need to reload some things */
21122129
igb_configure(adapter);
21132130

21142131
clear_bit(__IGB_DOWN, &adapter->state);
21152132

2116-
for (i = 0; i < adapter->num_q_vectors; i++)
2117-
napi_enable(&(adapter->q_vector[i]->napi));
2133+
for (i = 0; i < adapter->num_q_vectors; i++) {
2134+
napi = &adapter->q_vector[i]->napi;
2135+
napi_enable(napi);
2136+
igb_set_queue_napi(adapter, i, napi);
2137+
}
21182138

21192139
if (adapter->flags & IGB_FLAG_HAS_MSIX)
21202140
igb_configure_msix(adapter);
@@ -2184,6 +2204,7 @@ void igb_down(struct igb_adapter *adapter)
21842204
for (i = 0; i < adapter->num_q_vectors; i++) {
21852205
if (adapter->q_vector[i]) {
21862206
napi_synchronize(&adapter->q_vector[i]->napi);
2207+
igb_set_queue_napi(adapter, i, NULL);
21872208
napi_disable(&adapter->q_vector[i]->napi);
21882209
}
21892210
}
@@ -4116,8 +4137,9 @@ static int igb_sw_init(struct igb_adapter *adapter)
41164137
static int __igb_open(struct net_device *netdev, bool resuming)
41174138
{
41184139
struct igb_adapter *adapter = netdev_priv(netdev);
4119-
struct e1000_hw *hw = &adapter->hw;
41204140
struct pci_dev *pdev = adapter->pdev;
4141+
struct e1000_hw *hw = &adapter->hw;
4142+
struct napi_struct *napi;
41214143
int err;
41224144
int i;
41234145

@@ -4169,8 +4191,11 @@ static int __igb_open(struct net_device *netdev, bool resuming)
41694191
/* From here on the code is the same as igb_up() */
41704192
clear_bit(__IGB_DOWN, &adapter->state);
41714193

4172-
for (i = 0; i < adapter->num_q_vectors; i++)
4173-
napi_enable(&(adapter->q_vector[i]->napi));
4194+
for (i = 0; i < adapter->num_q_vectors; i++) {
4195+
napi = &adapter->q_vector[i]->napi;
4196+
napi_enable(napi);
4197+
igb_set_queue_napi(adapter, i, napi);
4198+
}
41744199

41754200
/* Clear any pending interrupts. */
41764201
rd32(E1000_TSICR);
@@ -9677,8 +9702,11 @@ static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
96779702
if (state == pci_channel_io_perm_failure)
96789703
return PCI_ERS_RESULT_DISCONNECT;
96799704

9705+
rtnl_lock();
96809706
if (netif_running(netdev))
96819707
igb_down(adapter);
9708+
rtnl_unlock();
9709+
96829710
pci_disable_device(pdev);
96839711

96849712
/* Request a slot reset. */
@@ -9737,16 +9765,21 @@ static void igb_io_resume(struct pci_dev *pdev)
97379765
struct net_device *netdev = pci_get_drvdata(pdev);
97389766
struct igb_adapter *adapter = netdev_priv(netdev);
97399767

9768+
rtnl_lock();
97409769
if (netif_running(netdev)) {
97419770
if (!test_bit(__IGB_DOWN, &adapter->state)) {
97429771
dev_dbg(&pdev->dev, "Resuming from non-fatal error, do nothing.\n");
9772+
rtnl_unlock();
97439773
return;
97449774
}
9775+
97459776
if (igb_up(adapter)) {
97469777
dev_err(&pdev->dev, "igb_up failed after reset\n");
9778+
rtnl_unlock();
97479779
return;
97489780
}
97499781
}
9782+
rtnl_unlock();
97509783

97519784
netif_device_attach(netdev);
97529785

0 commit comments

Comments
 (0)