atlx: use embedded net_device_stats
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 atlx: use embedded net_device_stats
There is now a net_device_stats structure inside net_device that should be used if possible by devices. Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>
drivers/net/atlx/atl1.c +21 -22
@@ -1662,6 +1662,7 @@ static void atl1_via_workaround(struct astatic void atl1_inc_smb (struct atl1_adapter *adapter) { +struct net_device *netdev = adapter->netdev;struct stats_msg_block *smb = adapter->smb.smb;/* Fill out the OS statistics structure */
@@ -1704,30 +1705,30 @@ static void atl1_inc_smb(struct atl1_ada adapter->soft_stats.tx_trunc += smb->tx_trunc; adapter->soft_stats.tx_pause += smb->tx_pause; - adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets; - adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets; - adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes; - adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes; - adapter->net_stats.multicast = adapter->soft_stats.multicast; - adapter->net_stats.collisions = adapter->soft_stats.collisions; - adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors; - adapter->net_stats.rx_over_errors = + netdev->stats.rx_packets = adapter->soft_stats.rx_packets; + netdev->stats.tx_packets = adapter->soft_stats.tx_packets; + netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes; + netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes; + netdev->stats.multicast = adapter->soft_stats.multicast; + netdev->stats.collisions = adapter->soft_stats.collisions; + netdev->stats.rx_errors = adapter->soft_stats.rx_errors; + netdev->stats.rx_over_errors = adapter->soft_stats.rx_missed_errors; - adapter->net_stats.rx_length_errors = + netdev->stats.rx_length_errors = adapter->soft_stats.rx_length_errors; - adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; - adapter->net_stats.rx_frame_errors = + netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; + netdev->stats.rx_frame_errors = adapter->soft_stats.rx_frame_errors; - adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; - adapter->net_stats.rx_missed_errors = + netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; + netdev->stats.rx_missed_errors = adapter->soft_stats.rx_missed_errors; - adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors; - adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; - adapter->net_stats.tx_aborted_errors = + netdev->stats.tx_errors = adapter->soft_stats.tx_errors; + netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; + netdev->stats.tx_aborted_errors = adapter->soft_stats.tx_aborted_errors; - adapter->net_stats.tx_window_errors = + netdev->stats.tx_window_errors = adapter->soft_stats.tx_window_errors; - adapter->net_stats.tx_carrier_errors = + netdev->stats.tx_carrier_errors = adapter->soft_stats.tx_carrier_errors; }
@@ -1860,7 +1861,7 @@ static u16 atl1_alloc_rx_buffers(struct adapter->rx_buffer_len + NET_IP_ALIGN);if (unlikely (!skb)) {/* Better luck next round */ - adapter->net_stats.rx_dropped++; + adapter->netdev->stats.rx_dropped++;break ; }
@@ -2982,7 +2983,7 @@ static int __devinit atl1_probe(struct p netdev->open = &atl1_open; netdev->stop = &atl1_close; netdev->hard_start_xmit = &atl1_xmit_frame; - netdev->get_stats = &atlx_get_stats; + netdev->set_multicast_list = &atlx_set_multi; netdev->set_mac_address = &atl1_set_mac; netdev->change_mtu = &atl1_change_mtu;
@@ -3172,8 +3173,6 @@ static struct atl1_stats atl1_gstrings_s {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)}, {"rx_errors", ATL1_STAT(soft_stats.rx_errors)}, {"tx_errors", ATL1_STAT(soft_stats.tx_errors)}, - {"rx_dropped", ATL1_STAT(net_stats.rx_dropped)}, - {"tx_dropped", ATL1_STAT(net_stats.tx_dropped)}, {"multicast", ATL1_STAT(soft_stats.multicast)}, {"collisions", ATL1_STAT(soft_stats.collisions)}, {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)},
drivers/net/atlx/atl1.h +1 -1
@@ -754,7 +754,7 @@ struct atl1_hw {struct atl1_adapter {struct net_device *netdev;struct pci_dev *pdev; -struct net_device_stats net_stats; +struct atl1_sft_stats soft_stats;struct vlan_group *vlgrp;u32 rx_buffer_len;
drivers/net/atlx/atl2.c +22 -33
124 lines not on this page · raw message
drivers/net/atlx/atl2.h +0 -1
@@ -453,7 +453,6 @@ struct atl2_adapter {/* OS defined structs */ struct net_device *netdev;struct pci_dev *pdev; -struct net_device_stats net_stats;#ifdef NETIF_F_HW_VLAN_TX struct vlan_group *vlgrp;#endif
drivers/net/atlx/atlx.c +0 -13
@@ -182,19 +182,6 @@ static void atlx_clear_phy_int(struct at }/* -* atlx_get_stats - Get System Network Statistics -* @netdev: network interface device structure -* -* Returns the address of the device statistics structure. -* The statistics are actually updated from the timer callback. -*/ -static struct net_device_stats *atlx_get_stats (struct net_device *netdev) -{ -struct atlx_adapter *adapter =netdev_priv (netdev); -return &adapter->net_stats; -} - -/* * atlx_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure */
Quoted 4 lines · Stephen Hemminger
There is now a
net_device_statsstructure insidenet_devicethat should be used if possible by devices. Compile tested only.Signed-off-by Stephen Hemminger <[email protected]>
applied 1-2
PATCH 2/2 atlx: timer cleanup
In reply to a message not in the archiveDo some cleanup on timer usage in this driver:
* Use round_jiffies to align wakeups and reduce power.
* Remove atl1_watchdog which does nothing but rearm itself
* Use setup_timer() function
Signed-off-by Stephen Hemminger <[email protected]>
drivers/net/atlx/atl1.c +4 -21
@@ -1390,7 +1390,8 @@ static u32 atl1_check_link(struct atl1_a/* auto-neg, insert timer to re-config phy */ if (!adapter->phy_timer_pending) { adapter->phy_timer_pending = true; -mod_timer (&adapter->phy_config_timer, jiffies +3 *HZ ); +mod_timer (&adapter->phy_config_timer, +round_jiffies (jiffies +3 *HZ )); }return 0 ;
@@ -2524,17 +2525,6 @@ static irqreturn_t atl1_intr(int irq, voreturn IRQ_HANDLED ; } -/* -* atl1_watchdog - Timer Call-back -* @data: pointer to netdev cast into an unsigned long -*/ -static void atl1_watchdog (unsigned long data) -{ -struct atl1_adapter *adapter = (struct atl1_adapter *)data; - -/* Reset the timer */ -mod_timer (&adapter->watchdog_timer, jiffies +2 *HZ ); -}/* * atl1_phy_config - Timer Call-back
@@ -2607,7 +2597,6 @@ static s32 atl1_up(struct atl1_adapter *if (unlikely (err)) goto err_up; -mod_timer (&adapter->watchdog_timer, jiffies);atlx_irq_enable (adapter);atl1_check_link (adapter);netif_start_queue (netdev);
@@ -2625,7 +2614,6 @@ static void atl1_down(struct atl1_adaptestruct net_device *netdev = adapter->netdev;netif_stop_queue (netdev); -del_timer_sync (&adapter->watchdog_timer);del_timer_sync (&adapter->phy_config_timer); adapter->phy_timer_pending = false;
@@ -3049,13 +3037,8 @@ static int __devinit atl1_probe(struct pnetif_carrier_off (netdev);netif_stop_queue (netdev); -init_timer (&adapter->watchdog_timer); - adapter->watchdog_timer.function = &atl1_watchdog; - adapter->watchdog_timer.data = (unsigned long )adapter; - -init_timer (&adapter->phy_config_timer); - adapter->phy_config_timer.function = &atl1_phy_config; - adapter->phy_config_timer.data = (unsigned long )adapter; +setup_timer (&adapter->phy_config_timer, &atl1_phy_config, + (unsigned long )adapter); adapter->phy_timer_pending = false;INIT_WORK (&adapter->tx_timeout_task, atl1_tx_timeout_task);
drivers/net/atlx/atl1.h +1 -1
@@ -765,7 +765,7 @@ struct atl1_adapter {struct work_struct tx_timeout_task;struct work_struct link_chg_task;struct work_struct pcie_dma_to_rst_task; -struct timer_list watchdog_timer; +struct timer_list phy_config_timer;bool phy_timer_pending;
drivers/net/atlx/atl2.c +5 -3
@@ -724,7 +724,7 @@ static int atl2_open(struct net_device *clear_bit (__ATL2_DOWN, &adapter->flags); -mod_timer (&adapter->watchdog_timer, jiffies +4 *HZ ); +mod_timer (&adapter->watchdog_timer,round_jiffies (jiffies +4 *HZ )); val =ATL2_READ_REG (&adapter->hw,REG_MASTER_CTRL ); ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL,
@@ -1051,7 +1051,8 @@ static void atl2_watchdog(unsigned long adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs;/* Reset the timer */ -mod_timer (&adapter->watchdog_timer, jiffies +4 *HZ ); +mod_timer (&adapter->watchdog_timer, +round_jiffies (jiffies +4 *HZ )); } }
@@ -1255,7 +1256,8 @@ static int atl2_check_link(struct atl2_a* (if interval smaller than 5 seconds, something strange) */ if (!test_bit (__ATL2_DOWN, &adapter->flags)) {if (!test_and_set_bit (0 , &adapter->cfg_phy)) -mod_timer (&adapter->phy_config_timer, jiffies +5 *HZ ); +mod_timer (&adapter->phy_config_timer, +round_jiffies (jiffies +5 *HZ )); }return 0 ;