aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/enic/enic_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/enic/enic_main.c')
-rw-r--r--drivers/net/enic/enic_main.c226
1 files changed, 171 insertions, 55 deletions
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index d7434b7b4c52..9e0580531143 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -145,15 +145,25 @@ static int enic_get_settings(struct net_device *netdev,
145 return 0; 145 return 0;
146} 146}
147 147
148static int enic_dev_fw_info(struct enic *enic,
149 struct vnic_devcmd_fw_info **fw_info)
150{
151 int err;
152
153 spin_lock(&enic->devcmd_lock);
154 err = vnic_dev_fw_info(enic->vdev, fw_info);
155 spin_unlock(&enic->devcmd_lock);
156
157 return err;
158}
159
148static void enic_get_drvinfo(struct net_device *netdev, 160static void enic_get_drvinfo(struct net_device *netdev,
149 struct ethtool_drvinfo *drvinfo) 161 struct ethtool_drvinfo *drvinfo)
150{ 162{
151 struct enic *enic = netdev_priv(netdev); 163 struct enic *enic = netdev_priv(netdev);
152 struct vnic_devcmd_fw_info *fw_info; 164 struct vnic_devcmd_fw_info *fw_info;
153 165
154 spin_lock(&enic->devcmd_lock); 166 enic_dev_fw_info(enic, &fw_info);
155 vnic_dev_fw_info(enic->vdev, &fw_info);
156 spin_unlock(&enic->devcmd_lock);
157 167
158 strncpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); 168 strncpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
159 strncpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); 169 strncpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version));
@@ -191,6 +201,17 @@ static int enic_get_sset_count(struct net_device *netdev, int sset)
191 } 201 }
192} 202}
193 203
204static int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats)
205{
206 int err;
207
208 spin_lock(&enic->devcmd_lock);
209 err = vnic_dev_stats_dump(enic->vdev, vstats);
210 spin_unlock(&enic->devcmd_lock);
211
212 return err;
213}
214
194static void enic_get_ethtool_stats(struct net_device *netdev, 215static void enic_get_ethtool_stats(struct net_device *netdev,
195 struct ethtool_stats *stats, u64 *data) 216 struct ethtool_stats *stats, u64 *data)
196{ 217{
@@ -198,9 +219,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
198 struct vnic_stats *vstats; 219 struct vnic_stats *vstats;
199 unsigned int i; 220 unsigned int i;
200 221
201 spin_lock(&enic->devcmd_lock); 222 enic_dev_stats_dump(enic, &vstats);
202 vnic_dev_stats_dump(enic->vdev, &vstats);
203 spin_unlock(&enic->devcmd_lock);
204 223
205 for (i = 0; i < enic_n_tx_stats; i++) 224 for (i = 0; i < enic_n_tx_stats; i++)
206 *(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].offset]; 225 *(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].offset];
@@ -411,17 +430,14 @@ static void enic_log_q_error(struct enic *enic)
411 } 430 }
412} 431}
413 432
414static void enic_link_check(struct enic *enic) 433static void enic_msglvl_check(struct enic *enic)
415{ 434{
416 int link_status = vnic_dev_link_status(enic->vdev); 435 u32 msg_enable = vnic_dev_msg_lvl(enic->vdev);
417 int carrier_ok = netif_carrier_ok(enic->netdev);
418 436
419 if (link_status && !carrier_ok) { 437 if (msg_enable != enic->msg_enable) {
420 printk(KERN_INFO PFX "%s: Link UP\n", enic->netdev->name); 438 printk(KERN_INFO PFX "%s: msg lvl changed from 0x%x to 0x%x\n",
421 netif_carrier_on(enic->netdev); 439 enic->netdev->name, enic->msg_enable, msg_enable);
422 } else if (!link_status && carrier_ok) { 440 enic->msg_enable = msg_enable;
423 printk(KERN_INFO PFX "%s: Link DOWN\n", enic->netdev->name);
424 netif_carrier_off(enic->netdev);
425 } 441 }
426} 442}
427 443
@@ -439,14 +455,17 @@ static void enic_mtu_check(struct enic *enic)
439 } 455 }
440} 456}
441 457
442static void enic_msglvl_check(struct enic *enic) 458static void enic_link_check(struct enic *enic)
443{ 459{
444 u32 msg_enable = vnic_dev_msg_lvl(enic->vdev); 460 int link_status = vnic_dev_link_status(enic->vdev);
461 int carrier_ok = netif_carrier_ok(enic->netdev);
445 462
446 if (msg_enable != enic->msg_enable) { 463 if (link_status && !carrier_ok) {
447 printk(KERN_INFO PFX "%s: msg lvl changed from 0x%x to 0x%x\n", 464 printk(KERN_INFO PFX "%s: Link UP\n", enic->netdev->name);
448 enic->netdev->name, enic->msg_enable, msg_enable); 465 netif_carrier_on(enic->netdev);
449 enic->msg_enable = msg_enable; 466 } else if (!link_status && carrier_ok) {
467 printk(KERN_INFO PFX "%s: Link DOWN\n", enic->netdev->name);
468 netif_carrier_off(enic->netdev);
450 } 469 }
451} 470}
452 471
@@ -792,9 +811,7 @@ static struct net_device_stats *enic_get_stats(struct net_device *netdev)
792 struct net_device_stats *net_stats = &netdev->stats; 811 struct net_device_stats *net_stats = &netdev->stats;
793 struct vnic_stats *stats; 812 struct vnic_stats *stats;
794 813
795 spin_lock(&enic->devcmd_lock); 814 enic_dev_stats_dump(enic, &stats);
796 vnic_dev_stats_dump(enic->vdev, &stats);
797 spin_unlock(&enic->devcmd_lock);
798 815
799 net_stats->tx_packets = stats->tx.tx_frames_ok; 816 net_stats->tx_packets = stats->tx.tx_frames_ok;
800 net_stats->tx_bytes = stats->tx.tx_bytes_ok; 817 net_stats->tx_bytes = stats->tx.tx_bytes_ok;
@@ -892,6 +909,41 @@ static int enic_set_mac_address(struct net_device *netdev, void *p)
892 return -EOPNOTSUPP; 909 return -EOPNOTSUPP;
893} 910}
894 911
912static int enic_dev_packet_filter(struct enic *enic, int directed,
913 int multicast, int broadcast, int promisc, int allmulti)
914{
915 int err;
916
917 spin_lock(&enic->devcmd_lock);
918 err = vnic_dev_packet_filter(enic->vdev, directed,
919 multicast, broadcast, promisc, allmulti);
920 spin_unlock(&enic->devcmd_lock);
921
922 return err;
923}
924
925static int enic_dev_add_multicast_addr(struct enic *enic, u8 *addr)
926{
927 int err;
928
929 spin_lock(&enic->devcmd_lock);
930 err = vnic_dev_add_addr(enic->vdev, addr);
931 spin_unlock(&enic->devcmd_lock);
932
933 return err;
934}
935
936static int enic_dev_del_multicast_addr(struct enic *enic, u8 *addr)
937{
938 int err;
939
940 spin_lock(&enic->devcmd_lock);
941 err = vnic_dev_del_addr(enic->vdev, addr);
942 spin_unlock(&enic->devcmd_lock);
943
944 return err;
945}
946
895/* netif_tx_lock held, BHs disabled */ 947/* netif_tx_lock held, BHs disabled */
896static void enic_set_multicast_list(struct net_device *netdev) 948static void enic_set_multicast_list(struct net_device *netdev)
897{ 949{
@@ -911,11 +963,9 @@ static void enic_set_multicast_list(struct net_device *netdev)
911 if (mc_count > ENIC_MULTICAST_PERFECT_FILTERS) 963 if (mc_count > ENIC_MULTICAST_PERFECT_FILTERS)
912 mc_count = ENIC_MULTICAST_PERFECT_FILTERS; 964 mc_count = ENIC_MULTICAST_PERFECT_FILTERS;
913 965
914 spin_lock(&enic->devcmd_lock);
915
916 if (enic->flags != flags) { 966 if (enic->flags != flags) {
917 enic->flags = flags; 967 enic->flags = flags;
918 vnic_dev_packet_filter(enic->vdev, directed, 968 enic_dev_packet_filter(enic, directed,
919 multicast, broadcast, promisc, allmulti); 969 multicast, broadcast, promisc, allmulti);
920 } 970 }
921 971
@@ -938,7 +988,7 @@ static void enic_set_multicast_list(struct net_device *netdev)
938 mc_addr[j]) == 0) 988 mc_addr[j]) == 0)
939 break; 989 break;
940 if (j == mc_count) 990 if (j == mc_count)
941 enic_del_multicast_addr(enic, enic->mc_addr[i]); 991 enic_dev_del_multicast_addr(enic, enic->mc_addr[i]);
942 } 992 }
943 993
944 for (i = 0; i < mc_count; i++) { 994 for (i = 0; i < mc_count; i++) {
@@ -947,7 +997,7 @@ static void enic_set_multicast_list(struct net_device *netdev)
947 enic->mc_addr[j]) == 0) 997 enic->mc_addr[j]) == 0)
948 break; 998 break;
949 if (j == enic->mc_count) 999 if (j == enic->mc_count)
950 enic_add_multicast_addr(enic, mc_addr[i]); 1000 enic_dev_add_multicast_addr(enic, mc_addr[i]);
951 } 1001 }
952 1002
953 /* Save the list to compare against next time 1003 /* Save the list to compare against next time
@@ -957,8 +1007,6 @@ static void enic_set_multicast_list(struct net_device *netdev)
957 memcpy(enic->mc_addr[i], mc_addr[i], ETH_ALEN); 1007 memcpy(enic->mc_addr[i], mc_addr[i], ETH_ALEN);
958 1008
959 enic->mc_count = mc_count; 1009 enic->mc_count = mc_count;
960
961 spin_unlock(&enic->devcmd_lock);
962} 1010}
963 1011
964/* rtnl lock is held */ 1012/* rtnl lock is held */
@@ -1264,12 +1312,24 @@ static int enic_rq_alloc_buf_a1(struct vnic_rq *rq)
1264 return 0; 1312 return 0;
1265} 1313}
1266 1314
1315static int enic_dev_hw_version(struct enic *enic,
1316 enum vnic_dev_hw_version *hw_ver)
1317{
1318 int err;
1319
1320 spin_lock(&enic->devcmd_lock);
1321 err = vnic_dev_hw_version(enic->vdev, hw_ver);
1322 spin_unlock(&enic->devcmd_lock);
1323
1324 return err;
1325}
1326
1267static int enic_set_rq_alloc_buf(struct enic *enic) 1327static int enic_set_rq_alloc_buf(struct enic *enic)
1268{ 1328{
1269 enum vnic_dev_hw_version hw_ver; 1329 enum vnic_dev_hw_version hw_ver;
1270 int err; 1330 int err;
1271 1331
1272 err = vnic_dev_hw_version(enic->vdev, &hw_ver); 1332 err = enic_dev_hw_version(enic, &hw_ver);
1273 if (err) 1333 if (err)
1274 return err; 1334 return err;
1275 1335
@@ -1603,7 +1663,7 @@ static void enic_synchronize_irqs(struct enic *enic)
1603 } 1663 }
1604} 1664}
1605 1665
1606static int enic_notify_set(struct enic *enic) 1666static int enic_dev_notify_set(struct enic *enic)
1607{ 1667{
1608 int err; 1668 int err;
1609 1669
@@ -1624,6 +1684,39 @@ static int enic_notify_set(struct enic *enic)
1624 return err; 1684 return err;
1625} 1685}
1626 1686
1687static int enic_dev_notify_unset(struct enic *enic)
1688{
1689 int err;
1690
1691 spin_lock(&enic->devcmd_lock);
1692 err = vnic_dev_notify_unset(enic->vdev);
1693 spin_unlock(&enic->devcmd_lock);
1694
1695 return err;
1696}
1697
1698static int enic_dev_enable(struct enic *enic)
1699{
1700 int err;
1701
1702 spin_lock(&enic->devcmd_lock);
1703 err = vnic_dev_enable(enic->vdev);
1704 spin_unlock(&enic->devcmd_lock);
1705
1706 return err;
1707}
1708
1709static int enic_dev_disable(struct enic *enic)
1710{
1711 int err;
1712
1713 spin_lock(&enic->devcmd_lock);
1714 err = vnic_dev_disable(enic->vdev);
1715 spin_unlock(&enic->devcmd_lock);
1716
1717 return err;
1718}
1719
1627static void enic_notify_timer_start(struct enic *enic) 1720static void enic_notify_timer_start(struct enic *enic)
1628{ 1721{
1629 switch (vnic_dev_get_intr_mode(enic->vdev)) { 1722 switch (vnic_dev_get_intr_mode(enic->vdev)) {
@@ -1650,7 +1743,7 @@ static int enic_open(struct net_device *netdev)
1650 return err; 1743 return err;
1651 } 1744 }
1652 1745
1653 err = enic_notify_set(enic); 1746 err = enic_dev_notify_set(enic);
1654 if (err) { 1747 if (err) {
1655 printk(KERN_ERR PFX 1748 printk(KERN_ERR PFX
1656 "%s: Failed to alloc notify buffer, aborting.\n", 1749 "%s: Failed to alloc notify buffer, aborting.\n",
@@ -1680,9 +1773,7 @@ static int enic_open(struct net_device *netdev)
1680 1773
1681 netif_wake_queue(netdev); 1774 netif_wake_queue(netdev);
1682 napi_enable(&enic->napi); 1775 napi_enable(&enic->napi);
1683 spin_lock(&enic->devcmd_lock); 1776 enic_dev_enable(enic);
1684 vnic_dev_enable(enic->vdev);
1685 spin_unlock(&enic->devcmd_lock);
1686 1777
1687 for (i = 0; i < enic->intr_count; i++) 1778 for (i = 0; i < enic->intr_count; i++)
1688 vnic_intr_unmask(&enic->intr[i]); 1779 vnic_intr_unmask(&enic->intr[i]);
@@ -1692,9 +1783,7 @@ static int enic_open(struct net_device *netdev)
1692 return 0; 1783 return 0;
1693 1784
1694err_out_notify_unset: 1785err_out_notify_unset:
1695 spin_lock(&enic->devcmd_lock); 1786 enic_dev_notify_unset(enic);
1696 vnic_dev_notify_unset(enic->vdev);
1697 spin_unlock(&enic->devcmd_lock);
1698err_out_free_intr: 1787err_out_free_intr:
1699 enic_free_intr(enic); 1788 enic_free_intr(enic);
1700 1789
@@ -1715,9 +1804,7 @@ static int enic_stop(struct net_device *netdev)
1715 1804
1716 del_timer_sync(&enic->notify_timer); 1805 del_timer_sync(&enic->notify_timer);
1717 1806
1718 spin_lock(&enic->devcmd_lock); 1807 enic_dev_disable(enic);
1719 vnic_dev_disable(enic->vdev);
1720 spin_unlock(&enic->devcmd_lock);
1721 napi_disable(&enic->napi); 1808 napi_disable(&enic->napi);
1722 netif_carrier_off(netdev); 1809 netif_carrier_off(netdev);
1723 netif_tx_disable(netdev); 1810 netif_tx_disable(netdev);
@@ -1735,9 +1822,7 @@ static int enic_stop(struct net_device *netdev)
1735 return err; 1822 return err;
1736 } 1823 }
1737 1824
1738 spin_lock(&enic->devcmd_lock); 1825 enic_dev_notify_unset(enic);
1739 vnic_dev_notify_unset(enic->vdev);
1740 spin_unlock(&enic->devcmd_lock);
1741 enic_free_intr(enic); 1826 enic_free_intr(enic);
1742 1827
1743 for (i = 0; i < enic->wq_count; i++) 1828 for (i = 0; i < enic->wq_count; i++)
@@ -1870,15 +1955,31 @@ static int enic_set_niccfg(struct enic *enic)
1870 const u8 rss_enable = 0; 1955 const u8 rss_enable = 0;
1871 const u8 tso_ipid_split_en = 0; 1956 const u8 tso_ipid_split_en = 0;
1872 const u8 ig_vlan_strip_en = 1; 1957 const u8 ig_vlan_strip_en = 1;
1958 int err;
1873 1959
1874 /* Enable VLAN tag stripping. RSS not enabled (yet). 1960 /* Enable VLAN tag stripping. RSS not enabled (yet).
1875 */ 1961 */
1876 1962
1877 return enic_set_nic_cfg(enic, 1963 spin_lock(&enic->devcmd_lock);
1964 err = enic_set_nic_cfg(enic,
1878 rss_default_cpu, rss_hash_type, 1965 rss_default_cpu, rss_hash_type,
1879 rss_hash_bits, rss_base_cpu, 1966 rss_hash_bits, rss_base_cpu,
1880 rss_enable, tso_ipid_split_en, 1967 rss_enable, tso_ipid_split_en,
1881 ig_vlan_strip_en); 1968 ig_vlan_strip_en);
1969 spin_unlock(&enic->devcmd_lock);
1970
1971 return err;
1972}
1973
1974static int enic_dev_hang_notify(struct enic *enic)
1975{
1976 int err;
1977
1978 spin_lock(&enic->devcmd_lock);
1979 err = vnic_dev_hang_notify(enic->vdev);
1980 spin_unlock(&enic->devcmd_lock);
1981
1982 return err;
1882} 1983}
1883 1984
1884int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic) 1985int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic)
@@ -1902,10 +2003,7 @@ static void enic_reset(struct work_struct *work)
1902 2003
1903 rtnl_lock(); 2004 rtnl_lock();
1904 2005
1905 spin_lock(&enic->devcmd_lock); 2006 enic_dev_hang_notify(enic);
1906 vnic_dev_hang_notify(enic->vdev);
1907 spin_unlock(&enic->devcmd_lock);
1908
1909 enic_stop(enic->netdev); 2007 enic_stop(enic->netdev);
1910 enic_dev_hang_reset(enic); 2008 enic_dev_hang_reset(enic);
1911 enic_reset_multicast_list(enic); 2009 enic_reset_multicast_list(enic);
@@ -2047,8 +2145,8 @@ static const struct net_device_ops enic_netdev_ops = {
2047 .ndo_start_xmit = enic_hard_start_xmit, 2145 .ndo_start_xmit = enic_hard_start_xmit,
2048 .ndo_get_stats = enic_get_stats, 2146 .ndo_get_stats = enic_get_stats,
2049 .ndo_validate_addr = eth_validate_addr, 2147 .ndo_validate_addr = eth_validate_addr,
2050 .ndo_set_multicast_list = enic_set_multicast_list,
2051 .ndo_set_mac_address = enic_set_mac_address, 2148 .ndo_set_mac_address = enic_set_mac_address,
2149 .ndo_set_multicast_list = enic_set_multicast_list,
2052 .ndo_change_mtu = enic_change_mtu, 2150 .ndo_change_mtu = enic_change_mtu,
2053 .ndo_vlan_rx_register = enic_vlan_rx_register, 2151 .ndo_vlan_rx_register = enic_vlan_rx_register,
2054 .ndo_vlan_rx_add_vid = enic_vlan_rx_add_vid, 2152 .ndo_vlan_rx_add_vid = enic_vlan_rx_add_vid,
@@ -2066,6 +2164,17 @@ void enic_dev_deinit(struct enic *enic)
2066 enic_clear_intr_mode(enic); 2164 enic_clear_intr_mode(enic);
2067} 2165}
2068 2166
2167static int enic_dev_stats_clear(struct enic *enic)
2168{
2169 int err;
2170
2171 spin_lock(&enic->devcmd_lock);
2172 err = vnic_dev_stats_clear(enic->vdev);
2173 spin_unlock(&enic->devcmd_lock);
2174
2175 return err;
2176}
2177
2069int enic_dev_init(struct enic *enic) 2178int enic_dev_init(struct enic *enic)
2070{ 2179{
2071 struct net_device *netdev = enic->netdev; 2180 struct net_device *netdev = enic->netdev;
@@ -2110,6 +2219,10 @@ int enic_dev_init(struct enic *enic)
2110 2219
2111 enic_init_vnic_resources(enic); 2220 enic_init_vnic_resources(enic);
2112 2221
2222 /* Clear LIF stats
2223 */
2224 enic_dev_stats_clear(enic);
2225
2113 err = enic_set_rq_alloc_buf(enic); 2226 err = enic_set_rq_alloc_buf(enic);
2114 if (err) { 2227 if (err) {
2115 printk(KERN_ERR PFX 2228 printk(KERN_ERR PFX
@@ -2293,6 +2406,11 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2293 } 2406 }
2294 } 2407 }
2295 2408
2409 /* Setup devcmd lock
2410 */
2411
2412 spin_lock_init(&enic->devcmd_lock);
2413
2296 err = enic_dev_init(enic); 2414 err = enic_dev_init(enic);
2297 if (err) { 2415 if (err) {
2298 printk(KERN_ERR PFX 2416 printk(KERN_ERR PFX
@@ -2300,7 +2418,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2300 goto err_out_dev_close; 2418 goto err_out_dev_close;
2301 } 2419 }
2302 2420
2303 /* Setup notification timer, HW reset task, and locks 2421 /* Setup notification timer, HW reset task, and wq locks
2304 */ 2422 */
2305 2423
2306 init_timer(&enic->notify_timer); 2424 init_timer(&enic->notify_timer);
@@ -2312,8 +2430,6 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2312 for (i = 0; i < enic->wq_count; i++) 2430 for (i = 0; i < enic->wq_count; i++)
2313 spin_lock_init(&enic->wq_lock[i]); 2431 spin_lock_init(&enic->wq_lock[i]);
2314 2432
2315 spin_lock_init(&enic->devcmd_lock);
2316
2317 /* Register net device 2433 /* Register net device
2318 */ 2434 */
2319 2435