Skip to content

Commit

Permalink
net: Use queue aware tests throughout.
Browse files Browse the repository at this point in the history
This effectively "flips the switch" by making the core networking
and multiqueue-aware drivers use the new TX multiqueue structures.

Non-multiqueue drivers need no changes.  The interfaces they use such
as netif_stop_queue() degenerate into an operation on TX queue zero.
So everything "just works" for them.

Code that really wants to do "X" to all TX queues now invokes a
routine that does so, such as netif_tx_wake_all_queues(),
netif_tx_stop_all_queues(), etc.

pktgen and netpoll required a little bit more surgery than the others.

In particular the pktgen changes, whilst functional, could be largely
improved.  The initial check in pktgen_xmit() will sometimes check the
wrong queue, which is mostly harmless.  The thing to do is probably to
invoke fill_packet() earlier.

The bulk of the netpoll changes is to make the code operate solely on
the TX queue indicated by by the SKB queue mapping.

Setting of the SKB queue mapping is entirely confined inside of
net/core/dev.c:dev_pick_tx().  If we end up needing any kind of
special semantics (drops, for example) it will be implemented here.

Finally, we now have a "real_num_tx_queues" which is where the driver
indicates how many TX queues are actually active.

With IGB changes from Jeff Kirsher.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 18, 2008
1 parent 24344d2 commit fd2ea0a
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 143 deletions.
20 changes: 8 additions & 12 deletions drivers/net/cpmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static int cpmac_poll(struct napi_struct *napi, int budget)

spin_unlock(&priv->rx_lock);
netif_rx_complete(priv->dev, napi);
netif_stop_queue(priv->dev);
netif_tx_stop_all_queues(priv->dev);
napi_disable(&priv->napi);

atomic_inc(&priv->reset_pending);
Expand Down Expand Up @@ -750,9 +750,7 @@ static void cpmac_hw_error(struct work_struct *work)
barrier();
atomic_dec(&priv->reset_pending);

for (i = 0; i < CPMAC_QUEUES; i++)
netif_wake_subqueue(priv->dev, i);
netif_wake_queue(priv->dev);
netif_tx_wake_all_queues(priv->dev);
cpmac_write(priv->regs, CPMAC_MAC_INT_ENABLE, 3);
}

Expand Down Expand Up @@ -781,7 +779,7 @@ static void cpmac_check_status(struct net_device *dev)
dev->name, tx_code, tx_channel, macstatus);
}

netif_stop_queue(dev);
netif_tx_stop_all_queues(dev);
cpmac_hw_stop(dev);
if (schedule_work(&priv->reset_work))
atomic_inc(&priv->reset_pending);
Expand Down Expand Up @@ -842,9 +840,7 @@ static void cpmac_tx_timeout(struct net_device *dev)
barrier();
atomic_dec(&priv->reset_pending);

netif_wake_queue(priv->dev);
for (i = 0; i < CPMAC_QUEUES; i++)
netif_wake_subqueue(dev, i);
netif_tx_wake_all_queues(priv->dev);
}

static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
Expand Down Expand Up @@ -935,7 +931,7 @@ static void cpmac_adjust_link(struct net_device *dev)

spin_lock(&priv->lock);
if (priv->phy->link) {
netif_start_queue(dev);
netif_tx_start_all_queues(dev);
if (priv->phy->duplex != priv->oldduplex) {
new_state = 1;
priv->oldduplex = priv->phy->duplex;
Expand All @@ -949,10 +945,10 @@ static void cpmac_adjust_link(struct net_device *dev)
if (!priv->oldlink) {
new_state = 1;
priv->oldlink = 1;
netif_schedule(dev);
netif_tx_schedule_all(dev);
}
} else if (priv->oldlink) {
netif_stop_queue(dev);
netif_tx_stop_all_queues(dev);
new_state = 1;
priv->oldlink = 0;
priv->oldspeed = 0;
Expand Down Expand Up @@ -1072,7 +1068,7 @@ static int cpmac_stop(struct net_device *dev)
struct cpmac_priv *priv = netdev_priv(dev);
struct resource *mem;

netif_stop_queue(dev);
netif_tx_stop_all_queues(dev);

cancel_work_sync(&priv->reset_work);
napi_disable(&priv->napi);
Expand Down
19 changes: 5 additions & 14 deletions drivers/net/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter)
adapter->flags |= IGB_FLAG_HAS_MSI;

/* Notify the stack of the (possibly) reduced Tx Queue count. */
adapter->netdev->egress_subqueue_count = adapter->num_tx_queues;
adapter->netdev->real_num_tx_queues = adapter->num_tx_queues;
return;
}

Expand Down Expand Up @@ -821,9 +821,7 @@ void igb_down(struct igb_adapter *adapter)
wr32(E1000_RCTL, rctl & ~E1000_RCTL_EN);
/* flush and sleep below */

netif_stop_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_stop_subqueue(netdev, i);
netif_tx_stop_all_queues(netdev);

/* disable transmits in the hardware */
tctl = rd32(E1000_TCTL);
Expand Down Expand Up @@ -1266,9 +1264,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,

/* tell the stack to leave us alone until igb_open() is called */
netif_carrier_off(netdev);
netif_stop_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_stop_subqueue(netdev, i);
netif_tx_stop_all_queues(netdev);

strcpy(netdev->name, "eth%d");
err = register_netdev(netdev);
Expand Down Expand Up @@ -2315,7 +2311,6 @@ static void igb_watchdog_task(struct work_struct *work)
struct e1000_mac_info *mac = &adapter->hw.mac;
u32 link;
s32 ret_val;
int i;

if ((netif_carrier_ok(netdev)) &&
(rd32(E1000_STATUS) & E1000_STATUS_LU))
Expand Down Expand Up @@ -2371,9 +2366,7 @@ static void igb_watchdog_task(struct work_struct *work)
}

netif_carrier_on(netdev);
netif_wake_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_wake_subqueue(netdev, i);
netif_tx_wake_all_queues(netdev);

if (!test_bit(__IGB_DOWN, &adapter->state))
mod_timer(&adapter->phy_info_timer,
Expand All @@ -2385,9 +2378,7 @@ static void igb_watchdog_task(struct work_struct *work)
adapter->link_duplex = 0;
dev_info(&adapter->pdev->dev, "NIC Link is Down\n");
netif_carrier_off(netdev);
netif_stop_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_stop_subqueue(netdev, i);
netif_tx_stop_all_queues(netdev);
if (!test_bit(__IGB_DOWN, &adapter->state))
mod_timer(&adapter->phy_info_timer,
round_jiffies(jiffies + 2 * HZ));
Expand Down
10 changes: 2 additions & 8 deletions drivers/net/ixgbe/ixgbe_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,10 @@ static int ixgbe_set_tso(struct net_device *netdev, u32 data)
netdev->features |= NETIF_F_TSO;
netdev->features |= NETIF_F_TSO6;
} else {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
int i;
netif_stop_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_stop_subqueue(netdev, i);
netif_tx_stop_all_queues(netdev);
netdev->features &= ~NETIF_F_TSO;
netdev->features &= ~NETIF_F_TSO6;
for (i = 0; i < adapter->num_tx_queues; i++)
netif_start_subqueue(netdev, i);
netif_start_queue(netdev);
netif_tx_start_all_queues(netdev);
}
return 0;
}
Expand Down
15 changes: 5 additions & 10 deletions drivers/net/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
del_timer_sync(&adapter->watchdog_timer);

netif_carrier_off(netdev);
netif_stop_queue(netdev);
netif_tx_stop_all_queues(netdev);

if (!pci_channel_offline(adapter->pdev))
ixgbe_reset(adapter);
Expand Down Expand Up @@ -2359,7 +2359,7 @@ static int __devinit ixgbe_set_interrupt_capability(struct ixgbe_adapter

out:
/* Notify the stack of the (possibly) reduced Tx Queue count. */
adapter->netdev->egress_subqueue_count = adapter->num_tx_queues;
adapter->netdev->real_num_tx_queues = adapter->num_tx_queues;

return err;
}
Expand Down Expand Up @@ -2896,7 +2896,6 @@ static void ixgbe_watchdog(unsigned long data)
struct net_device *netdev = adapter->netdev;
bool link_up;
u32 link_speed = 0;
int i;

adapter->hw.mac.ops.check_link(&adapter->hw, &(link_speed), &link_up);

Expand All @@ -2917,9 +2916,7 @@ static void ixgbe_watchdog(unsigned long data)
(FLOW_TX ? "TX" : "None"))));

netif_carrier_on(netdev);
netif_wake_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_wake_subqueue(netdev, i);
netif_tx_wake_all_queues(netdev);
} else {
/* Force detection of hung controller */
adapter->detect_tx_hung = true;
Expand All @@ -2928,7 +2925,7 @@ static void ixgbe_watchdog(unsigned long data)
if (netif_carrier_ok(netdev)) {
DPRINTK(LINK, INFO, "NIC Link is Down\n");
netif_carrier_off(netdev);
netif_stop_queue(netdev);
netif_tx_stop_all_queues(netdev);
}
}

Expand Down Expand Up @@ -3631,9 +3628,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
ixgbe_start_hw(hw);

netif_carrier_off(netdev);
netif_stop_queue(netdev);
for (i = 0; i < adapter->num_tx_queues; i++)
netif_stop_subqueue(netdev, i);
netif_tx_stop_all_queues(netdev);

ixgbe_napi_add_all(adapter);

Expand Down
48 changes: 19 additions & 29 deletions drivers/net/s2io.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,63 +545,53 @@ static struct pci_driver s2io_driver = {
/* netqueue manipulation helper functions */
static inline void s2io_stop_all_tx_queue(struct s2io_nic *sp)
{
int i;
if (sp->config.multiq) {
for (i = 0; i < sp->config.tx_fifo_num; i++)
netif_stop_subqueue(sp->dev, i);
} else {
if (!sp->config.multiq) {
int i;

for (i = 0; i < sp->config.tx_fifo_num; i++)
sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_STOP;
netif_stop_queue(sp->dev);
}
netif_tx_stop_all_queues(sp->dev);
}

static inline void s2io_stop_tx_queue(struct s2io_nic *sp, int fifo_no)
{
if (sp->config.multiq)
netif_stop_subqueue(sp->dev, fifo_no);
else {
if (!sp->config.multiq)
sp->mac_control.fifos[fifo_no].queue_state =
FIFO_QUEUE_STOP;
netif_stop_queue(sp->dev);
}

netif_tx_stop_all_queues(sp->dev);
}

static inline void s2io_start_all_tx_queue(struct s2io_nic *sp)
{
int i;
if (sp->config.multiq) {
for (i = 0; i < sp->config.tx_fifo_num; i++)
netif_start_subqueue(sp->dev, i);
} else {
if (!sp->config.multiq) {
int i;

for (i = 0; i < sp->config.tx_fifo_num; i++)
sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_START;
netif_start_queue(sp->dev);
}
netif_tx_start_all_queues(sp->dev);
}

static inline void s2io_start_tx_queue(struct s2io_nic *sp, int fifo_no)
{
if (sp->config.multiq)
netif_start_subqueue(sp->dev, fifo_no);
else {
if (!sp->config.multiq)
sp->mac_control.fifos[fifo_no].queue_state =
FIFO_QUEUE_START;
netif_start_queue(sp->dev);
}

netif_tx_start_all_queues(sp->dev);
}

static inline void s2io_wake_all_tx_queue(struct s2io_nic *sp)
{
int i;
if (sp->config.multiq) {
for (i = 0; i < sp->config.tx_fifo_num; i++)
netif_wake_subqueue(sp->dev, i);
} else {
if (!sp->config.multiq) {
int i;

for (i = 0; i < sp->config.tx_fifo_num; i++)
sp->mac_control.fifos[i].queue_state = FIFO_QUEUE_START;
netif_wake_queue(sp->dev);
}
netif_tx_wake_all_queues(sp->dev);
}

static inline void s2io_wake_tx_queue(
Expand Down Expand Up @@ -8691,5 +8681,5 @@ static void s2io_io_resume(struct pci_dev *pdev)
}

netif_device_attach(netdev);
netif_wake_queue(netdev);
netif_tx_wake_all_queues(netdev);
}
Loading

0 comments on commit fd2ea0a

Please sign in to comment.