| .. | .. |
|---|
| 55 | 55 | /* |
|---|
| 56 | 56 | * Generic information about the driver. |
|---|
| 57 | 57 | */ |
|---|
| 58 | | -#define DRV_VERSION "2.0.0-ko" |
|---|
| 59 | 58 | #define DRV_DESC "Chelsio T4/T5/T6 Virtual Function (VF) Network Driver" |
|---|
| 60 | 59 | |
|---|
| 61 | 60 | /* |
|---|
| .. | .. |
|---|
| 155 | 154 | const char *fc; |
|---|
| 156 | 155 | const struct port_info *pi = netdev_priv(dev); |
|---|
| 157 | 156 | |
|---|
| 157 | + netif_carrier_on(dev); |
|---|
| 158 | + |
|---|
| 158 | 159 | switch (pi->link_cfg.speed) { |
|---|
| 159 | 160 | case 100: |
|---|
| 160 | 161 | s = "100Mbps"; |
|---|
| .. | .. |
|---|
| 200 | 201 | |
|---|
| 201 | 202 | netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s, fc); |
|---|
| 202 | 203 | } else { |
|---|
| 204 | + netif_carrier_off(dev); |
|---|
| 203 | 205 | netdev_info(dev, "link down\n"); |
|---|
| 204 | 206 | } |
|---|
| 205 | 207 | } |
|---|
| .. | .. |
|---|
| 236 | 238 | "inserted\n", dev->name, pi->mod_type); |
|---|
| 237 | 239 | } |
|---|
| 238 | 240 | |
|---|
| 241 | +static int cxgb4vf_set_addr_hash(struct port_info *pi) |
|---|
| 242 | +{ |
|---|
| 243 | + struct adapter *adapter = pi->adapter; |
|---|
| 244 | + u64 vec = 0; |
|---|
| 245 | + bool ucast = false; |
|---|
| 246 | + struct hash_mac_addr *entry; |
|---|
| 247 | + |
|---|
| 248 | + /* Calculate the hash vector for the updated list and program it */ |
|---|
| 249 | + list_for_each_entry(entry, &adapter->mac_hlist, list) { |
|---|
| 250 | + ucast |= is_unicast_ether_addr(entry->addr); |
|---|
| 251 | + vec |= (1ULL << hash_mac_addr(entry->addr)); |
|---|
| 252 | + } |
|---|
| 253 | + return t4vf_set_addr_hash(adapter, pi->viid, ucast, vec, false); |
|---|
| 254 | +} |
|---|
| 255 | + |
|---|
| 256 | +/** |
|---|
| 257 | + * cxgb4vf_change_mac - Update match filter for a MAC address. |
|---|
| 258 | + * @pi: the port_info |
|---|
| 259 | + * @viid: the VI id |
|---|
| 260 | + * @tcam_idx: TCAM index of existing filter for old value of MAC address, |
|---|
| 261 | + * or -1 |
|---|
| 262 | + * @addr: the new MAC address value |
|---|
| 263 | + * @persistent: whether a new MAC allocation should be persistent |
|---|
| 264 | + * |
|---|
| 265 | + * Modifies an MPS filter and sets it to the new MAC address if |
|---|
| 266 | + * @tcam_idx >= 0, or adds the MAC address to a new filter if |
|---|
| 267 | + * @tcam_idx < 0. In the latter case the address is added persistently |
|---|
| 268 | + * if @persist is %true. |
|---|
| 269 | + * Addresses are programmed to hash region, if tcam runs out of entries. |
|---|
| 270 | + * |
|---|
| 271 | + */ |
|---|
| 272 | +static int cxgb4vf_change_mac(struct port_info *pi, unsigned int viid, |
|---|
| 273 | + int *tcam_idx, const u8 *addr, bool persistent) |
|---|
| 274 | +{ |
|---|
| 275 | + struct hash_mac_addr *new_entry, *entry; |
|---|
| 276 | + struct adapter *adapter = pi->adapter; |
|---|
| 277 | + int ret; |
|---|
| 278 | + |
|---|
| 279 | + ret = t4vf_change_mac(adapter, viid, *tcam_idx, addr, persistent); |
|---|
| 280 | + /* We ran out of TCAM entries. try programming hash region. */ |
|---|
| 281 | + if (ret == -ENOMEM) { |
|---|
| 282 | + /* If the MAC address to be updated is in the hash addr |
|---|
| 283 | + * list, update it from the list |
|---|
| 284 | + */ |
|---|
| 285 | + list_for_each_entry(entry, &adapter->mac_hlist, list) { |
|---|
| 286 | + if (entry->iface_mac) { |
|---|
| 287 | + ether_addr_copy(entry->addr, addr); |
|---|
| 288 | + goto set_hash; |
|---|
| 289 | + } |
|---|
| 290 | + } |
|---|
| 291 | + new_entry = kzalloc(sizeof(*new_entry), GFP_KERNEL); |
|---|
| 292 | + if (!new_entry) |
|---|
| 293 | + return -ENOMEM; |
|---|
| 294 | + ether_addr_copy(new_entry->addr, addr); |
|---|
| 295 | + new_entry->iface_mac = true; |
|---|
| 296 | + list_add_tail(&new_entry->list, &adapter->mac_hlist); |
|---|
| 297 | +set_hash: |
|---|
| 298 | + ret = cxgb4vf_set_addr_hash(pi); |
|---|
| 299 | + } else if (ret >= 0) { |
|---|
| 300 | + *tcam_idx = ret; |
|---|
| 301 | + ret = 0; |
|---|
| 302 | + } |
|---|
| 303 | + |
|---|
| 304 | + return ret; |
|---|
| 305 | +} |
|---|
| 306 | + |
|---|
| 239 | 307 | /* |
|---|
| 240 | 308 | * Net device operations. |
|---|
| 241 | 309 | * ====================== |
|---|
| .. | .. |
|---|
| 259 | 327 | */ |
|---|
| 260 | 328 | ret = t4vf_set_rxmode(pi->adapter, pi->viid, dev->mtu, -1, -1, -1, 1, |
|---|
| 261 | 329 | true); |
|---|
| 262 | | - if (ret == 0) { |
|---|
| 263 | | - ret = t4vf_change_mac(pi->adapter, pi->viid, |
|---|
| 264 | | - pi->xact_addr_filt, dev->dev_addr, true); |
|---|
| 265 | | - if (ret >= 0) { |
|---|
| 266 | | - pi->xact_addr_filt = ret; |
|---|
| 267 | | - ret = 0; |
|---|
| 268 | | - } |
|---|
| 269 | | - } |
|---|
| 330 | + if (ret == 0) |
|---|
| 331 | + ret = cxgb4vf_change_mac(pi, pi->viid, |
|---|
| 332 | + &pi->xact_addr_filt, |
|---|
| 333 | + dev->dev_addr, true); |
|---|
| 270 | 334 | |
|---|
| 271 | 335 | /* |
|---|
| 272 | 336 | * We don't need to actually "start the link" itself since the |
|---|
| .. | .. |
|---|
| 275 | 339 | */ |
|---|
| 276 | 340 | if (ret == 0) |
|---|
| 277 | 341 | ret = t4vf_enable_pi(pi->adapter, pi, true, true); |
|---|
| 278 | | - |
|---|
| 279 | | - /* The Virtual Interfaces are connected to an internal switch on the |
|---|
| 280 | | - * chip which allows VIs attached to the same port to talk to each |
|---|
| 281 | | - * other even when the port link is down. As a result, we generally |
|---|
| 282 | | - * want to always report a VI's link as being "up", provided there are |
|---|
| 283 | | - * no errors in enabling vi. |
|---|
| 284 | | - */ |
|---|
| 285 | | - |
|---|
| 286 | | - if (ret == 0) |
|---|
| 287 | | - netif_carrier_on(dev); |
|---|
| 288 | 342 | |
|---|
| 289 | 343 | return ret; |
|---|
| 290 | 344 | } |
|---|
| .. | .. |
|---|
| 406 | 460 | * The interrupt queue doesn't use NAPI so we do the 0-increment of |
|---|
| 407 | 461 | * its Going To Sleep register here to get it started. |
|---|
| 408 | 462 | */ |
|---|
| 409 | | - if (adapter->flags & USING_MSI) |
|---|
| 463 | + if (adapter->flags & CXGB4VF_USING_MSI) |
|---|
| 410 | 464 | t4_write_reg(adapter, T4VF_SGE_BASE_ADDR + SGE_VF_GTS, |
|---|
| 411 | 465 | CIDXINC_V(0) | |
|---|
| 412 | 466 | SEINTARM_V(s->intrq.intr_params) | |
|---|
| .. | .. |
|---|
| 462 | 516 | break; |
|---|
| 463 | 517 | } |
|---|
| 464 | 518 | cpl = (void *)p; |
|---|
| 465 | | - /*FALLTHROUGH*/ |
|---|
| 466 | 519 | } |
|---|
| 520 | + fallthrough; |
|---|
| 467 | 521 | |
|---|
| 468 | 522 | case CPL_SGE_EGR_UPDATE: { |
|---|
| 469 | 523 | /* |
|---|
| .. | .. |
|---|
| 550 | 604 | * the intrq's queue ID as the interrupt forwarding queue for the |
|---|
| 551 | 605 | * subsequent calls ... |
|---|
| 552 | 606 | */ |
|---|
| 553 | | - if (adapter->flags & USING_MSI) { |
|---|
| 607 | + if (adapter->flags & CXGB4VF_USING_MSI) { |
|---|
| 554 | 608 | err = t4vf_sge_alloc_rxq(adapter, &s->intrq, false, |
|---|
| 555 | 609 | adapter->port[0], 0, NULL, NULL); |
|---|
| 556 | 610 | if (err) |
|---|
| .. | .. |
|---|
| 710 | 764 | * adapter setup. Once we've done this, many of our adapter |
|---|
| 711 | 765 | * parameters can no longer be changed ... |
|---|
| 712 | 766 | */ |
|---|
| 713 | | - if ((adapter->flags & FULL_INIT_DONE) == 0) { |
|---|
| 767 | + if ((adapter->flags & CXGB4VF_FULL_INIT_DONE) == 0) { |
|---|
| 714 | 768 | err = setup_sge_queues(adapter); |
|---|
| 715 | 769 | if (err) |
|---|
| 716 | 770 | return err; |
|---|
| .. | .. |
|---|
| 720 | 774 | return err; |
|---|
| 721 | 775 | } |
|---|
| 722 | 776 | |
|---|
| 723 | | - if (adapter->flags & USING_MSIX) |
|---|
| 777 | + if (adapter->flags & CXGB4VF_USING_MSIX) |
|---|
| 724 | 778 | name_msix_vecs(adapter); |
|---|
| 725 | 779 | |
|---|
| 726 | | - adapter->flags |= FULL_INIT_DONE; |
|---|
| 780 | + adapter->flags |= CXGB4VF_FULL_INIT_DONE; |
|---|
| 727 | 781 | } |
|---|
| 728 | 782 | |
|---|
| 729 | 783 | /* |
|---|
| 730 | 784 | * Acquire our interrupt resources. We only support MSI-X and MSI. |
|---|
| 731 | 785 | */ |
|---|
| 732 | | - BUG_ON((adapter->flags & (USING_MSIX|USING_MSI)) == 0); |
|---|
| 733 | | - if (adapter->flags & USING_MSIX) |
|---|
| 786 | + BUG_ON((adapter->flags & |
|---|
| 787 | + (CXGB4VF_USING_MSIX | CXGB4VF_USING_MSI)) == 0); |
|---|
| 788 | + if (adapter->flags & CXGB4VF_USING_MSIX) |
|---|
| 734 | 789 | err = request_msix_queue_irqs(adapter); |
|---|
| 735 | 790 | else |
|---|
| 736 | 791 | err = request_irq(adapter->pdev->irq, |
|---|
| .. | .. |
|---|
| 761 | 816 | /* |
|---|
| 762 | 817 | * Free interrupt resources. |
|---|
| 763 | 818 | */ |
|---|
| 764 | | - if (adapter->flags & USING_MSIX) |
|---|
| 819 | + if (adapter->flags & CXGB4VF_USING_MSIX) |
|---|
| 765 | 820 | free_msix_queue_irqs(adapter); |
|---|
| 766 | 821 | else |
|---|
| 767 | 822 | free_irq(adapter->pdev->irq, adapter); |
|---|
| .. | .. |
|---|
| 782 | 837 | struct adapter *adapter = pi->adapter; |
|---|
| 783 | 838 | |
|---|
| 784 | 839 | /* |
|---|
| 840 | + * If we don't have a connection to the firmware there's nothing we |
|---|
| 841 | + * can do. |
|---|
| 842 | + */ |
|---|
| 843 | + if (!(adapter->flags & CXGB4VF_FW_OK)) |
|---|
| 844 | + return -ENXIO; |
|---|
| 845 | + |
|---|
| 846 | + /* |
|---|
| 785 | 847 | * If this is the first interface that we're opening on the "adapter", |
|---|
| 786 | 848 | * bring the "adapter" up now. |
|---|
| 787 | 849 | */ |
|---|
| .. | .. |
|---|
| 790 | 852 | if (err) |
|---|
| 791 | 853 | return err; |
|---|
| 792 | 854 | } |
|---|
| 855 | + |
|---|
| 856 | + /* It's possible that the basic port information could have |
|---|
| 857 | + * changed since we first read it. |
|---|
| 858 | + */ |
|---|
| 859 | + err = t4vf_update_port_info(pi); |
|---|
| 860 | + if (err < 0) |
|---|
| 861 | + goto err_unwind; |
|---|
| 793 | 862 | |
|---|
| 794 | 863 | /* |
|---|
| 795 | 864 | * Note that this interface is up and start everything up ... |
|---|
| .. | .. |
|---|
| 861 | 930 | ns->rx_errors = stats.rx_err_frames; |
|---|
| 862 | 931 | |
|---|
| 863 | 932 | return ns; |
|---|
| 864 | | -} |
|---|
| 865 | | - |
|---|
| 866 | | -static inline int cxgb4vf_set_addr_hash(struct port_info *pi) |
|---|
| 867 | | -{ |
|---|
| 868 | | - struct adapter *adapter = pi->adapter; |
|---|
| 869 | | - u64 vec = 0; |
|---|
| 870 | | - bool ucast = false; |
|---|
| 871 | | - struct hash_mac_addr *entry; |
|---|
| 872 | | - |
|---|
| 873 | | - /* Calculate the hash vector for the updated list and program it */ |
|---|
| 874 | | - list_for_each_entry(entry, &adapter->mac_hlist, list) { |
|---|
| 875 | | - ucast |= is_unicast_ether_addr(entry->addr); |
|---|
| 876 | | - vec |= (1ULL << hash_mac_addr(entry->addr)); |
|---|
| 877 | | - } |
|---|
| 878 | | - return t4vf_set_addr_hash(adapter, pi->viid, ucast, vec, false); |
|---|
| 879 | 933 | } |
|---|
| 880 | 934 | |
|---|
| 881 | 935 | static int cxgb4vf_mac_sync(struct net_device *netdev, const u8 *mac_addr) |
|---|
| .. | .. |
|---|
| 1159 | 1213 | if (!is_valid_ether_addr(addr->sa_data)) |
|---|
| 1160 | 1214 | return -EADDRNOTAVAIL; |
|---|
| 1161 | 1215 | |
|---|
| 1162 | | - ret = t4vf_change_mac(pi->adapter, pi->viid, pi->xact_addr_filt, |
|---|
| 1163 | | - addr->sa_data, true); |
|---|
| 1216 | + ret = cxgb4vf_change_mac(pi, pi->viid, &pi->xact_addr_filt, |
|---|
| 1217 | + addr->sa_data, true); |
|---|
| 1164 | 1218 | if (ret < 0) |
|---|
| 1165 | 1219 | return ret; |
|---|
| 1166 | 1220 | |
|---|
| 1167 | 1221 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
|---|
| 1168 | | - pi->xact_addr_filt = ret; |
|---|
| 1169 | 1222 | return 0; |
|---|
| 1170 | 1223 | } |
|---|
| 1171 | 1224 | |
|---|
| .. | .. |
|---|
| 1179 | 1232 | struct port_info *pi = netdev_priv(dev); |
|---|
| 1180 | 1233 | struct adapter *adapter = pi->adapter; |
|---|
| 1181 | 1234 | |
|---|
| 1182 | | - if (adapter->flags & USING_MSIX) { |
|---|
| 1235 | + if (adapter->flags & CXGB4VF_USING_MSIX) { |
|---|
| 1183 | 1236 | struct sge_eth_rxq *rxq; |
|---|
| 1184 | 1237 | int nqsets; |
|---|
| 1185 | 1238 | |
|---|
| .. | .. |
|---|
| 1354 | 1407 | case FW_PORT_TYPE_CR4_QSFP: |
|---|
| 1355 | 1408 | SET_LMM(FIBRE); |
|---|
| 1356 | 1409 | FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full); |
|---|
| 1357 | | - FW_CAPS_TO_LMM(SPEED_10G, 10000baseSR_Full); |
|---|
| 1410 | + FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full); |
|---|
| 1358 | 1411 | FW_CAPS_TO_LMM(SPEED_40G, 40000baseSR4_Full); |
|---|
| 1359 | 1412 | FW_CAPS_TO_LMM(SPEED_25G, 25000baseCR_Full); |
|---|
| 1360 | 1413 | FW_CAPS_TO_LMM(SPEED_50G, 50000baseCR2_Full); |
|---|
| .. | .. |
|---|
| 1363 | 1416 | |
|---|
| 1364 | 1417 | default: |
|---|
| 1365 | 1418 | break; |
|---|
| 1419 | + } |
|---|
| 1420 | + |
|---|
| 1421 | + if (fw_caps & FW_PORT_CAP32_FEC_V(FW_PORT_CAP32_FEC_M)) { |
|---|
| 1422 | + FW_CAPS_TO_LMM(FEC_RS, FEC_RS); |
|---|
| 1423 | + FW_CAPS_TO_LMM(FEC_BASER_RS, FEC_BASER); |
|---|
| 1424 | + } else { |
|---|
| 1425 | + SET_LMM(FEC_NONE); |
|---|
| 1366 | 1426 | } |
|---|
| 1367 | 1427 | |
|---|
| 1368 | 1428 | FW_CAPS_TO_LMM(ANEG, Autoneg); |
|---|
| .. | .. |
|---|
| 1415 | 1475 | } else { |
|---|
| 1416 | 1476 | base->speed = SPEED_UNKNOWN; |
|---|
| 1417 | 1477 | base->duplex = DUPLEX_UNKNOWN; |
|---|
| 1418 | | - } |
|---|
| 1419 | | - |
|---|
| 1420 | | - if (pi->link_cfg.fc & PAUSE_RX) { |
|---|
| 1421 | | - if (pi->link_cfg.fc & PAUSE_TX) { |
|---|
| 1422 | | - ethtool_link_ksettings_add_link_mode(link_ksettings, |
|---|
| 1423 | | - advertising, |
|---|
| 1424 | | - Pause); |
|---|
| 1425 | | - } else { |
|---|
| 1426 | | - ethtool_link_ksettings_add_link_mode(link_ksettings, |
|---|
| 1427 | | - advertising, |
|---|
| 1428 | | - Asym_Pause); |
|---|
| 1429 | | - } |
|---|
| 1430 | | - } else if (pi->link_cfg.fc & PAUSE_TX) { |
|---|
| 1431 | | - ethtool_link_ksettings_add_link_mode(link_ksettings, |
|---|
| 1432 | | - advertising, |
|---|
| 1433 | | - Asym_Pause); |
|---|
| 1434 | 1478 | } |
|---|
| 1435 | 1479 | |
|---|
| 1436 | 1480 | base->autoneg = pi->link_cfg.autoneg; |
|---|
| .. | .. |
|---|
| 1510 | 1554 | struct adapter *adapter = netdev2adap(dev); |
|---|
| 1511 | 1555 | |
|---|
| 1512 | 1556 | strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); |
|---|
| 1513 | | - strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); |
|---|
| 1514 | 1557 | strlcpy(drvinfo->bus_info, pci_name(to_pci_dev(dev->dev.parent)), |
|---|
| 1515 | 1558 | sizeof(drvinfo->bus_info)); |
|---|
| 1516 | 1559 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
|---|
| .. | .. |
|---|
| 1587 | 1630 | rp->tx_pending < MIN_TXQ_ENTRIES) |
|---|
| 1588 | 1631 | return -EINVAL; |
|---|
| 1589 | 1632 | |
|---|
| 1590 | | - if (adapter->flags & FULL_INIT_DONE) |
|---|
| 1633 | + if (adapter->flags & CXGB4VF_FULL_INIT_DONE) |
|---|
| 1591 | 1634 | return -EBUSY; |
|---|
| 1592 | 1635 | |
|---|
| 1593 | 1636 | for (qs = pi->first_qset; qs < pi->first_qset + pi->nqsets; qs++) { |
|---|
| .. | .. |
|---|
| 1644 | 1687 | struct port_info *pi = netdev_priv(dev); |
|---|
| 1645 | 1688 | |
|---|
| 1646 | 1689 | pauseparam->autoneg = (pi->link_cfg.requested_fc & PAUSE_AUTONEG) != 0; |
|---|
| 1647 | | - pauseparam->rx_pause = (pi->link_cfg.fc & PAUSE_RX) != 0; |
|---|
| 1648 | | - pauseparam->tx_pause = (pi->link_cfg.fc & PAUSE_TX) != 0; |
|---|
| 1690 | + pauseparam->rx_pause = (pi->link_cfg.advertised_fc & PAUSE_RX) != 0; |
|---|
| 1691 | + pauseparam->tx_pause = (pi->link_cfg.advertised_fc & PAUSE_TX) != 0; |
|---|
| 1649 | 1692 | } |
|---|
| 1650 | 1693 | |
|---|
| 1651 | 1694 | /* |
|---|
| .. | .. |
|---|
| 1871 | 1914 | * TCP Segmentation Offload flags which we support. |
|---|
| 1872 | 1915 | */ |
|---|
| 1873 | 1916 | #define TSO_FLAGS (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN) |
|---|
| 1917 | +#define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | TSO_FLAGS | \ |
|---|
| 1918 | + NETIF_F_GRO | NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA) |
|---|
| 1874 | 1919 | |
|---|
| 1875 | 1920 | static const struct ethtool_ops cxgb4vf_ethtool_ops = { |
|---|
| 1921 | + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS | |
|---|
| 1922 | + ETHTOOL_COALESCE_RX_MAX_FRAMES, |
|---|
| 1876 | 1923 | .get_link_ksettings = cxgb4vf_get_link_ksettings, |
|---|
| 1877 | 1924 | .get_fecparam = cxgb4vf_get_fecparam, |
|---|
| 1878 | 1925 | .get_drvinfo = cxgb4vf_get_drvinfo, |
|---|
| .. | .. |
|---|
| 1970 | 2017 | { |
|---|
| 1971 | 2018 | } |
|---|
| 1972 | 2019 | |
|---|
| 1973 | | -static const struct seq_operations mboxlog_seq_ops = { |
|---|
| 2020 | +static const struct seq_operations mboxlog_sops = { |
|---|
| 1974 | 2021 | .start = mboxlog_start, |
|---|
| 1975 | 2022 | .next = mboxlog_next, |
|---|
| 1976 | 2023 | .stop = mboxlog_stop, |
|---|
| 1977 | 2024 | .show = mboxlog_show |
|---|
| 1978 | 2025 | }; |
|---|
| 1979 | 2026 | |
|---|
| 1980 | | -static int mboxlog_open(struct inode *inode, struct file *file) |
|---|
| 1981 | | -{ |
|---|
| 1982 | | - int res = seq_open(file, &mboxlog_seq_ops); |
|---|
| 1983 | | - |
|---|
| 1984 | | - if (!res) { |
|---|
| 1985 | | - struct seq_file *seq = file->private_data; |
|---|
| 1986 | | - |
|---|
| 1987 | | - seq->private = inode->i_private; |
|---|
| 1988 | | - } |
|---|
| 1989 | | - return res; |
|---|
| 1990 | | -} |
|---|
| 1991 | | - |
|---|
| 1992 | | -static const struct file_operations mboxlog_fops = { |
|---|
| 1993 | | - .owner = THIS_MODULE, |
|---|
| 1994 | | - .open = mboxlog_open, |
|---|
| 1995 | | - .read = seq_read, |
|---|
| 1996 | | - .llseek = seq_lseek, |
|---|
| 1997 | | - .release = seq_release, |
|---|
| 1998 | | -}; |
|---|
| 1999 | | - |
|---|
| 2027 | +DEFINE_SEQ_ATTRIBUTE(mboxlog); |
|---|
| 2000 | 2028 | /* |
|---|
| 2001 | 2029 | * Show SGE Queue Set information. We display QPL Queues Sets per line. |
|---|
| 2002 | 2030 | */ |
|---|
| .. | .. |
|---|
| 2102 | 2130 | static int sge_queue_entries(const struct adapter *adapter) |
|---|
| 2103 | 2131 | { |
|---|
| 2104 | 2132 | return DIV_ROUND_UP(adapter->sge.ethqsets, QPL) + 1 + |
|---|
| 2105 | | - ((adapter->flags & USING_MSI) != 0); |
|---|
| 2133 | + ((adapter->flags & CXGB4VF_USING_MSI) != 0); |
|---|
| 2106 | 2134 | } |
|---|
| 2107 | 2135 | |
|---|
| 2108 | 2136 | static void *sge_queue_start(struct seq_file *seq, loff_t *pos) |
|---|
| .. | .. |
|---|
| 2124 | 2152 | return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL; |
|---|
| 2125 | 2153 | } |
|---|
| 2126 | 2154 | |
|---|
| 2127 | | -static const struct seq_operations sge_qinfo_seq_ops = { |
|---|
| 2155 | +static const struct seq_operations sge_qinfo_sops = { |
|---|
| 2128 | 2156 | .start = sge_queue_start, |
|---|
| 2129 | 2157 | .next = sge_queue_next, |
|---|
| 2130 | 2158 | .stop = sge_queue_stop, |
|---|
| 2131 | 2159 | .show = sge_qinfo_show |
|---|
| 2132 | 2160 | }; |
|---|
| 2133 | 2161 | |
|---|
| 2134 | | -static int sge_qinfo_open(struct inode *inode, struct file *file) |
|---|
| 2135 | | -{ |
|---|
| 2136 | | - int res = seq_open(file, &sge_qinfo_seq_ops); |
|---|
| 2137 | | - |
|---|
| 2138 | | - if (!res) { |
|---|
| 2139 | | - struct seq_file *seq = file->private_data; |
|---|
| 2140 | | - seq->private = inode->i_private; |
|---|
| 2141 | | - } |
|---|
| 2142 | | - return res; |
|---|
| 2143 | | -} |
|---|
| 2144 | | - |
|---|
| 2145 | | -static const struct file_operations sge_qinfo_debugfs_fops = { |
|---|
| 2146 | | - .owner = THIS_MODULE, |
|---|
| 2147 | | - .open = sge_qinfo_open, |
|---|
| 2148 | | - .read = seq_read, |
|---|
| 2149 | | - .llseek = seq_lseek, |
|---|
| 2150 | | - .release = seq_release, |
|---|
| 2151 | | -}; |
|---|
| 2162 | +DEFINE_SEQ_ATTRIBUTE(sge_qinfo); |
|---|
| 2152 | 2163 | |
|---|
| 2153 | 2164 | /* |
|---|
| 2154 | 2165 | * Show SGE Queue Set statistics. We display QPL Queues Sets per line. |
|---|
| .. | .. |
|---|
| 2248 | 2259 | static int sge_qstats_entries(const struct adapter *adapter) |
|---|
| 2249 | 2260 | { |
|---|
| 2250 | 2261 | return DIV_ROUND_UP(adapter->sge.ethqsets, QPL) + 1 + |
|---|
| 2251 | | - ((adapter->flags & USING_MSI) != 0); |
|---|
| 2262 | + ((adapter->flags & CXGB4VF_USING_MSI) != 0); |
|---|
| 2252 | 2263 | } |
|---|
| 2253 | 2264 | |
|---|
| 2254 | 2265 | static void *sge_qstats_start(struct seq_file *seq, loff_t *pos) |
|---|
| .. | .. |
|---|
| 2270 | 2281 | return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL; |
|---|
| 2271 | 2282 | } |
|---|
| 2272 | 2283 | |
|---|
| 2273 | | -static const struct seq_operations sge_qstats_seq_ops = { |
|---|
| 2284 | +static const struct seq_operations sge_qstats_sops = { |
|---|
| 2274 | 2285 | .start = sge_qstats_start, |
|---|
| 2275 | 2286 | .next = sge_qstats_next, |
|---|
| 2276 | 2287 | .stop = sge_qstats_stop, |
|---|
| 2277 | 2288 | .show = sge_qstats_show |
|---|
| 2278 | 2289 | }; |
|---|
| 2279 | 2290 | |
|---|
| 2280 | | -static int sge_qstats_open(struct inode *inode, struct file *file) |
|---|
| 2281 | | -{ |
|---|
| 2282 | | - int res = seq_open(file, &sge_qstats_seq_ops); |
|---|
| 2283 | | - |
|---|
| 2284 | | - if (res == 0) { |
|---|
| 2285 | | - struct seq_file *seq = file->private_data; |
|---|
| 2286 | | - seq->private = inode->i_private; |
|---|
| 2287 | | - } |
|---|
| 2288 | | - return res; |
|---|
| 2289 | | -} |
|---|
| 2290 | | - |
|---|
| 2291 | | -static const struct file_operations sge_qstats_proc_fops = { |
|---|
| 2292 | | - .owner = THIS_MODULE, |
|---|
| 2293 | | - .open = sge_qstats_open, |
|---|
| 2294 | | - .read = seq_read, |
|---|
| 2295 | | - .llseek = seq_lseek, |
|---|
| 2296 | | - .release = seq_release, |
|---|
| 2297 | | -}; |
|---|
| 2291 | +DEFINE_SEQ_ATTRIBUTE(sge_qstats); |
|---|
| 2298 | 2292 | |
|---|
| 2299 | 2293 | /* |
|---|
| 2300 | 2294 | * Show PCI-E SR-IOV Virtual Function Resource Limits. |
|---|
| .. | .. |
|---|
| 2323 | 2317 | |
|---|
| 2324 | 2318 | return 0; |
|---|
| 2325 | 2319 | } |
|---|
| 2326 | | - |
|---|
| 2327 | | -static int resources_open(struct inode *inode, struct file *file) |
|---|
| 2328 | | -{ |
|---|
| 2329 | | - return single_open(file, resources_show, inode->i_private); |
|---|
| 2330 | | -} |
|---|
| 2331 | | - |
|---|
| 2332 | | -static const struct file_operations resources_proc_fops = { |
|---|
| 2333 | | - .owner = THIS_MODULE, |
|---|
| 2334 | | - .open = resources_open, |
|---|
| 2335 | | - .read = seq_read, |
|---|
| 2336 | | - .llseek = seq_lseek, |
|---|
| 2337 | | - .release = single_release, |
|---|
| 2338 | | -}; |
|---|
| 2320 | +DEFINE_SHOW_ATTRIBUTE(resources); |
|---|
| 2339 | 2321 | |
|---|
| 2340 | 2322 | /* |
|---|
| 2341 | 2323 | * Show Virtual Interfaces. |
|---|
| .. | .. |
|---|
| 2380 | 2362 | { |
|---|
| 2381 | 2363 | } |
|---|
| 2382 | 2364 | |
|---|
| 2383 | | -static const struct seq_operations interfaces_seq_ops = { |
|---|
| 2365 | +static const struct seq_operations interfaces_sops = { |
|---|
| 2384 | 2366 | .start = interfaces_start, |
|---|
| 2385 | 2367 | .next = interfaces_next, |
|---|
| 2386 | 2368 | .stop = interfaces_stop, |
|---|
| 2387 | 2369 | .show = interfaces_show |
|---|
| 2388 | 2370 | }; |
|---|
| 2389 | 2371 | |
|---|
| 2390 | | -static int interfaces_open(struct inode *inode, struct file *file) |
|---|
| 2391 | | -{ |
|---|
| 2392 | | - int res = seq_open(file, &interfaces_seq_ops); |
|---|
| 2393 | | - |
|---|
| 2394 | | - if (res == 0) { |
|---|
| 2395 | | - struct seq_file *seq = file->private_data; |
|---|
| 2396 | | - seq->private = inode->i_private; |
|---|
| 2397 | | - } |
|---|
| 2398 | | - return res; |
|---|
| 2399 | | -} |
|---|
| 2400 | | - |
|---|
| 2401 | | -static const struct file_operations interfaces_proc_fops = { |
|---|
| 2402 | | - .owner = THIS_MODULE, |
|---|
| 2403 | | - .open = interfaces_open, |
|---|
| 2404 | | - .read = seq_read, |
|---|
| 2405 | | - .llseek = seq_lseek, |
|---|
| 2406 | | - .release = seq_release, |
|---|
| 2407 | | -}; |
|---|
| 2372 | +DEFINE_SEQ_ATTRIBUTE(interfaces); |
|---|
| 2408 | 2373 | |
|---|
| 2409 | 2374 | /* |
|---|
| 2410 | 2375 | * /sys/kernel/debugfs/cxgb4vf/ files list. |
|---|
| .. | .. |
|---|
| 2417 | 2382 | |
|---|
| 2418 | 2383 | static struct cxgb4vf_debugfs_entry debugfs_files[] = { |
|---|
| 2419 | 2384 | { "mboxlog", 0444, &mboxlog_fops }, |
|---|
| 2420 | | - { "sge_qinfo", 0444, &sge_qinfo_debugfs_fops }, |
|---|
| 2421 | | - { "sge_qstats", 0444, &sge_qstats_proc_fops }, |
|---|
| 2422 | | - { "resources", 0444, &resources_proc_fops }, |
|---|
| 2423 | | - { "interfaces", 0444, &interfaces_proc_fops }, |
|---|
| 2385 | + { "sge_qinfo", 0444, &sge_qinfo_fops }, |
|---|
| 2386 | + { "sge_qstats", 0444, &sge_qstats_fops }, |
|---|
| 2387 | + { "resources", 0444, &resources_fops }, |
|---|
| 2388 | + { "interfaces", 0444, &interfaces_fops }, |
|---|
| 2424 | 2389 | }; |
|---|
| 2425 | 2390 | |
|---|
| 2426 | 2391 | /* |
|---|
| .. | .. |
|---|
| 2442 | 2407 | * Debugfs support is best effort. |
|---|
| 2443 | 2408 | */ |
|---|
| 2444 | 2409 | for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) |
|---|
| 2445 | | - (void)debugfs_create_file(debugfs_files[i].name, |
|---|
| 2446 | | - debugfs_files[i].mode, |
|---|
| 2447 | | - adapter->debugfs_root, |
|---|
| 2448 | | - (void *)adapter, |
|---|
| 2449 | | - debugfs_files[i].fops); |
|---|
| 2410 | + debugfs_create_file(debugfs_files[i].name, |
|---|
| 2411 | + debugfs_files[i].mode, |
|---|
| 2412 | + adapter->debugfs_root, adapter, |
|---|
| 2413 | + debugfs_files[i].fops); |
|---|
| 2450 | 2414 | |
|---|
| 2451 | 2415 | return 0; |
|---|
| 2452 | 2416 | } |
|---|
| .. | .. |
|---|
| 2669 | 2633 | */ |
|---|
| 2670 | 2634 | size_nports_qsets(adapter); |
|---|
| 2671 | 2635 | |
|---|
| 2636 | + adapter->flags |= CXGB4VF_FW_OK; |
|---|
| 2672 | 2637 | return 0; |
|---|
| 2673 | 2638 | } |
|---|
| 2674 | 2639 | |
|---|
| .. | .. |
|---|
| 2703 | 2668 | * support. In particular, this means that we need to know what kind |
|---|
| 2704 | 2669 | * of interrupts we'll be using ... |
|---|
| 2705 | 2670 | */ |
|---|
| 2706 | | - BUG_ON((adapter->flags & (USING_MSIX|USING_MSI)) == 0); |
|---|
| 2671 | + BUG_ON((adapter->flags & |
|---|
| 2672 | + (CXGB4VF_USING_MSIX | CXGB4VF_USING_MSI)) == 0); |
|---|
| 2707 | 2673 | |
|---|
| 2708 | 2674 | /* |
|---|
| 2709 | 2675 | * Count the number of 10GbE Virtual Interfaces that we have. |
|---|
| .. | .. |
|---|
| 2880 | 2846 | #endif |
|---|
| 2881 | 2847 | }; |
|---|
| 2882 | 2848 | |
|---|
| 2849 | +/** |
|---|
| 2850 | + * cxgb4vf_get_port_mask - Get port mask for the VF based on mac |
|---|
| 2851 | + * address stored on the adapter |
|---|
| 2852 | + * @adapter: The adapter |
|---|
| 2853 | + * |
|---|
| 2854 | + * Find the the port mask for the VF based on the index of mac |
|---|
| 2855 | + * address stored in the adapter. If no mac address is stored on |
|---|
| 2856 | + * the adapter for the VF, use the port mask received from the |
|---|
| 2857 | + * firmware. |
|---|
| 2858 | + */ |
|---|
| 2859 | +static unsigned int cxgb4vf_get_port_mask(struct adapter *adapter) |
|---|
| 2860 | +{ |
|---|
| 2861 | + unsigned int naddr = 1, pidx = 0; |
|---|
| 2862 | + unsigned int pmask, rmask = 0; |
|---|
| 2863 | + u8 mac[ETH_ALEN]; |
|---|
| 2864 | + int err; |
|---|
| 2865 | + |
|---|
| 2866 | + pmask = adapter->params.vfres.pmask; |
|---|
| 2867 | + while (pmask) { |
|---|
| 2868 | + if (pmask & 1) { |
|---|
| 2869 | + err = t4vf_get_vf_mac_acl(adapter, pidx, &naddr, mac); |
|---|
| 2870 | + if (!err && !is_zero_ether_addr(mac)) |
|---|
| 2871 | + rmask |= (1 << pidx); |
|---|
| 2872 | + } |
|---|
| 2873 | + pmask >>= 1; |
|---|
| 2874 | + pidx++; |
|---|
| 2875 | + } |
|---|
| 2876 | + if (!rmask) |
|---|
| 2877 | + rmask = adapter->params.vfres.pmask; |
|---|
| 2878 | + |
|---|
| 2879 | + return rmask; |
|---|
| 2880 | +} |
|---|
| 2881 | + |
|---|
| 2883 | 2882 | /* |
|---|
| 2884 | 2883 | * "Probe" a device: initialize a device and construct all kernel and driver |
|---|
| 2885 | 2884 | * state needed to manage the device. This routine is called "init_one" in |
|---|
| .. | .. |
|---|
| 2888 | 2887 | static int cxgb4vf_pci_probe(struct pci_dev *pdev, |
|---|
| 2889 | 2888 | const struct pci_device_id *ent) |
|---|
| 2890 | 2889 | { |
|---|
| 2890 | + struct adapter *adapter; |
|---|
| 2891 | + struct net_device *netdev; |
|---|
| 2892 | + struct port_info *pi; |
|---|
| 2893 | + unsigned int pmask; |
|---|
| 2891 | 2894 | int pci_using_dac; |
|---|
| 2892 | 2895 | int err, pidx; |
|---|
| 2893 | | - unsigned int pmask; |
|---|
| 2894 | | - struct adapter *adapter; |
|---|
| 2895 | | - struct port_info *pi; |
|---|
| 2896 | | - struct net_device *netdev; |
|---|
| 2897 | | - unsigned int pf; |
|---|
| 2898 | | - |
|---|
| 2899 | | - /* |
|---|
| 2900 | | - * Print our driver banner the first time we're called to initialize a |
|---|
| 2901 | | - * device. |
|---|
| 2902 | | - */ |
|---|
| 2903 | | - pr_info_once("%s - version %s\n", DRV_DESC, DRV_VERSION); |
|---|
| 2904 | 2896 | |
|---|
| 2905 | 2897 | /* |
|---|
| 2906 | 2898 | * Initialize generic PCI device state. |
|---|
| .. | .. |
|---|
| 3029 | 3021 | * using Relaxed Ordering. |
|---|
| 3030 | 3022 | */ |
|---|
| 3031 | 3023 | if (!pcie_relaxed_ordering_enabled(pdev)) |
|---|
| 3032 | | - adapter->flags |= ROOT_NO_RELAXED_ORDERING; |
|---|
| 3024 | + adapter->flags |= CXGB4VF_ROOT_NO_RELAXED_ORDERING; |
|---|
| 3033 | 3025 | |
|---|
| 3034 | 3026 | err = adap_init0(adapter); |
|---|
| 3035 | 3027 | if (err) |
|---|
| 3036 | | - goto err_unmap_bar; |
|---|
| 3028 | + dev_err(&pdev->dev, |
|---|
| 3029 | + "Adapter initialization failed, error %d. Continuing in debug mode\n", |
|---|
| 3030 | + err); |
|---|
| 3037 | 3031 | |
|---|
| 3038 | 3032 | /* Initialize hash mac addr list */ |
|---|
| 3039 | 3033 | INIT_LIST_HEAD(&adapter->mac_hlist); |
|---|
| .. | .. |
|---|
| 3041 | 3035 | /* |
|---|
| 3042 | 3036 | * Allocate our "adapter ports" and stitch everything together. |
|---|
| 3043 | 3037 | */ |
|---|
| 3044 | | - pmask = adapter->params.vfres.pmask; |
|---|
| 3045 | | - pf = t4vf_get_pf_from_vf(adapter); |
|---|
| 3038 | + pmask = cxgb4vf_get_port_mask(adapter); |
|---|
| 3046 | 3039 | for_each_port(adapter, pidx) { |
|---|
| 3047 | 3040 | int port_id, viid; |
|---|
| 3048 | 3041 | u8 mac[ETH_ALEN]; |
|---|
| .. | .. |
|---|
| 3058 | 3051 | break; |
|---|
| 3059 | 3052 | port_id = ffs(pmask) - 1; |
|---|
| 3060 | 3053 | pmask &= ~(1 << port_id); |
|---|
| 3061 | | - viid = t4vf_alloc_vi(adapter, port_id); |
|---|
| 3062 | | - if (viid < 0) { |
|---|
| 3063 | | - dev_err(&pdev->dev, "cannot allocate VI for port %d:" |
|---|
| 3064 | | - " err=%d\n", port_id, viid); |
|---|
| 3065 | | - err = viid; |
|---|
| 3066 | | - goto err_free_dev; |
|---|
| 3067 | | - } |
|---|
| 3068 | 3054 | |
|---|
| 3069 | 3055 | /* |
|---|
| 3070 | 3056 | * Allocate our network device and stitch things together. |
|---|
| .. | .. |
|---|
| 3072 | 3058 | netdev = alloc_etherdev_mq(sizeof(struct port_info), |
|---|
| 3073 | 3059 | MAX_PORT_QSETS); |
|---|
| 3074 | 3060 | if (netdev == NULL) { |
|---|
| 3075 | | - t4vf_free_vi(adapter, viid); |
|---|
| 3076 | 3061 | err = -ENOMEM; |
|---|
| 3077 | 3062 | goto err_free_dev; |
|---|
| 3078 | 3063 | } |
|---|
| .. | .. |
|---|
| 3082 | 3067 | pi->adapter = adapter; |
|---|
| 3083 | 3068 | pi->pidx = pidx; |
|---|
| 3084 | 3069 | pi->port_id = port_id; |
|---|
| 3085 | | - pi->viid = viid; |
|---|
| 3086 | 3070 | |
|---|
| 3087 | 3071 | /* |
|---|
| 3088 | 3072 | * Initialize the starting state of our "port" and register |
|---|
| 3089 | 3073 | * it. |
|---|
| 3090 | 3074 | */ |
|---|
| 3091 | 3075 | pi->xact_addr_filt = -1; |
|---|
| 3092 | | - netif_carrier_off(netdev); |
|---|
| 3093 | 3076 | netdev->irq = pdev->irq; |
|---|
| 3094 | 3077 | |
|---|
| 3095 | | - netdev->hw_features = NETIF_F_SG | TSO_FLAGS | |
|---|
| 3096 | | - NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
|---|
| 3097 | | - NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM; |
|---|
| 3098 | | - netdev->vlan_features = NETIF_F_SG | TSO_FLAGS | |
|---|
| 3099 | | - NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
|---|
| 3100 | | - NETIF_F_HIGHDMA; |
|---|
| 3101 | | - netdev->features = netdev->hw_features | |
|---|
| 3102 | | - NETIF_F_HW_VLAN_CTAG_TX; |
|---|
| 3078 | + netdev->hw_features = NETIF_F_SG | TSO_FLAGS | NETIF_F_GRO | |
|---|
| 3079 | + NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | |
|---|
| 3080 | + NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; |
|---|
| 3081 | + netdev->features = netdev->hw_features; |
|---|
| 3103 | 3082 | if (pci_using_dac) |
|---|
| 3104 | 3083 | netdev->features |= NETIF_F_HIGHDMA; |
|---|
| 3084 | + netdev->vlan_features = netdev->features & VLAN_FEAT; |
|---|
| 3105 | 3085 | |
|---|
| 3106 | 3086 | netdev->priv_flags |= IFF_UNICAST_FLT; |
|---|
| 3107 | 3087 | netdev->min_mtu = 81; |
|---|
| .. | .. |
|---|
| 3110 | 3090 | netdev->netdev_ops = &cxgb4vf_netdev_ops; |
|---|
| 3111 | 3091 | netdev->ethtool_ops = &cxgb4vf_ethtool_ops; |
|---|
| 3112 | 3092 | netdev->dev_port = pi->port_id; |
|---|
| 3093 | + |
|---|
| 3094 | + /* |
|---|
| 3095 | + * If we haven't been able to contact the firmware, there's |
|---|
| 3096 | + * nothing else we can do for this "port" ... |
|---|
| 3097 | + */ |
|---|
| 3098 | + if (!(adapter->flags & CXGB4VF_FW_OK)) |
|---|
| 3099 | + continue; |
|---|
| 3100 | + |
|---|
| 3101 | + viid = t4vf_alloc_vi(adapter, port_id); |
|---|
| 3102 | + if (viid < 0) { |
|---|
| 3103 | + dev_err(&pdev->dev, |
|---|
| 3104 | + "cannot allocate VI for port %d: err=%d\n", |
|---|
| 3105 | + port_id, viid); |
|---|
| 3106 | + err = viid; |
|---|
| 3107 | + goto err_free_dev; |
|---|
| 3108 | + } |
|---|
| 3109 | + pi->viid = viid; |
|---|
| 3113 | 3110 | |
|---|
| 3114 | 3111 | /* |
|---|
| 3115 | 3112 | * Initialize the hardware/software state for the port. |
|---|
| .. | .. |
|---|
| 3121 | 3118 | goto err_free_dev; |
|---|
| 3122 | 3119 | } |
|---|
| 3123 | 3120 | |
|---|
| 3124 | | - err = t4vf_get_vf_mac_acl(adapter, pf, &naddr, mac); |
|---|
| 3121 | + err = t4vf_get_vf_mac_acl(adapter, port_id, &naddr, mac); |
|---|
| 3125 | 3122 | if (err) { |
|---|
| 3126 | 3123 | dev_err(&pdev->dev, |
|---|
| 3127 | 3124 | "unable to determine MAC ACL address, " |
|---|
| .. | .. |
|---|
| 3148 | 3145 | * get MSI interrupts we bail with the error. |
|---|
| 3149 | 3146 | */ |
|---|
| 3150 | 3147 | if (msi == MSI_MSIX && enable_msix(adapter) == 0) |
|---|
| 3151 | | - adapter->flags |= USING_MSIX; |
|---|
| 3148 | + adapter->flags |= CXGB4VF_USING_MSIX; |
|---|
| 3152 | 3149 | else { |
|---|
| 3153 | 3150 | if (msi == MSI_MSIX) { |
|---|
| 3154 | 3151 | dev_info(adapter->pdev_dev, |
|---|
| .. | .. |
|---|
| 3168 | 3165 | " err=%d\n", err); |
|---|
| 3169 | 3166 | goto err_free_dev; |
|---|
| 3170 | 3167 | } |
|---|
| 3171 | | - adapter->flags |= USING_MSI; |
|---|
| 3168 | + adapter->flags |= CXGB4VF_USING_MSI; |
|---|
| 3172 | 3169 | } |
|---|
| 3173 | 3170 | |
|---|
| 3174 | 3171 | /* Now that we know how many "ports" we have and what interrupt |
|---|
| .. | .. |
|---|
| 3198 | 3195 | continue; |
|---|
| 3199 | 3196 | } |
|---|
| 3200 | 3197 | |
|---|
| 3198 | + netif_carrier_off(netdev); |
|---|
| 3201 | 3199 | set_bit(pidx, &adapter->registered_device_map); |
|---|
| 3202 | 3200 | } |
|---|
| 3203 | 3201 | if (adapter->registered_device_map == 0) { |
|---|
| .. | .. |
|---|
| 3212 | 3210 | adapter->debugfs_root = |
|---|
| 3213 | 3211 | debugfs_create_dir(pci_name(pdev), |
|---|
| 3214 | 3212 | cxgb4vf_debugfs_root); |
|---|
| 3215 | | - if (IS_ERR_OR_NULL(adapter->debugfs_root)) |
|---|
| 3216 | | - dev_warn(&pdev->dev, "could not create debugfs" |
|---|
| 3217 | | - " directory"); |
|---|
| 3218 | | - else |
|---|
| 3219 | | - setup_debugfs(adapter); |
|---|
| 3213 | + setup_debugfs(adapter); |
|---|
| 3220 | 3214 | } |
|---|
| 3221 | 3215 | |
|---|
| 3222 | 3216 | /* |
|---|
| .. | .. |
|---|
| 3226 | 3220 | for_each_port(adapter, pidx) { |
|---|
| 3227 | 3221 | dev_info(adapter->pdev_dev, "%s: Chelsio VF NIC PCIe %s\n", |
|---|
| 3228 | 3222 | adapter->port[pidx]->name, |
|---|
| 3229 | | - (adapter->flags & USING_MSIX) ? "MSI-X" : |
|---|
| 3230 | | - (adapter->flags & USING_MSI) ? "MSI" : ""); |
|---|
| 3223 | + (adapter->flags & CXGB4VF_USING_MSIX) ? "MSI-X" : |
|---|
| 3224 | + (adapter->flags & CXGB4VF_USING_MSI) ? "MSI" : ""); |
|---|
| 3231 | 3225 | } |
|---|
| 3232 | 3226 | |
|---|
| 3233 | 3227 | /* |
|---|
| .. | .. |
|---|
| 3240 | 3234 | * so far and return the error. |
|---|
| 3241 | 3235 | */ |
|---|
| 3242 | 3236 | err_disable_interrupts: |
|---|
| 3243 | | - if (adapter->flags & USING_MSIX) { |
|---|
| 3237 | + if (adapter->flags & CXGB4VF_USING_MSIX) { |
|---|
| 3244 | 3238 | pci_disable_msix(adapter->pdev); |
|---|
| 3245 | | - adapter->flags &= ~USING_MSIX; |
|---|
| 3246 | | - } else if (adapter->flags & USING_MSI) { |
|---|
| 3239 | + adapter->flags &= ~CXGB4VF_USING_MSIX; |
|---|
| 3240 | + } else if (adapter->flags & CXGB4VF_USING_MSI) { |
|---|
| 3247 | 3241 | pci_disable_msi(adapter->pdev); |
|---|
| 3248 | | - adapter->flags &= ~USING_MSI; |
|---|
| 3242 | + adapter->flags &= ~CXGB4VF_USING_MSI; |
|---|
| 3249 | 3243 | } |
|---|
| 3250 | 3244 | |
|---|
| 3251 | 3245 | err_free_dev: |
|---|
| .. | .. |
|---|
| 3254 | 3248 | if (netdev == NULL) |
|---|
| 3255 | 3249 | continue; |
|---|
| 3256 | 3250 | pi = netdev_priv(netdev); |
|---|
| 3257 | | - t4vf_free_vi(adapter, pi->viid); |
|---|
| 3251 | + if (pi->viid) |
|---|
| 3252 | + t4vf_free_vi(adapter, pi->viid); |
|---|
| 3258 | 3253 | if (test_bit(pidx, &adapter->registered_device_map)) |
|---|
| 3259 | 3254 | unregister_netdev(netdev); |
|---|
| 3260 | 3255 | free_netdev(netdev); |
|---|
| 3261 | 3256 | } |
|---|
| 3262 | 3257 | |
|---|
| 3263 | | -err_unmap_bar: |
|---|
| 3264 | 3258 | if (!is_t4(adapter->params.chip)) |
|---|
| 3265 | 3259 | iounmap(adapter->bar2); |
|---|
| 3266 | 3260 | |
|---|
| .. | .. |
|---|
| 3289 | 3283 | static void cxgb4vf_pci_remove(struct pci_dev *pdev) |
|---|
| 3290 | 3284 | { |
|---|
| 3291 | 3285 | struct adapter *adapter = pci_get_drvdata(pdev); |
|---|
| 3286 | + struct hash_mac_addr *entry, *tmp; |
|---|
| 3292 | 3287 | |
|---|
| 3293 | 3288 | /* |
|---|
| 3294 | 3289 | * Tear down driver state associated with device. |
|---|
| .. | .. |
|---|
| 3304 | 3299 | if (test_bit(pidx, &adapter->registered_device_map)) |
|---|
| 3305 | 3300 | unregister_netdev(adapter->port[pidx]); |
|---|
| 3306 | 3301 | t4vf_sge_stop(adapter); |
|---|
| 3307 | | - if (adapter->flags & USING_MSIX) { |
|---|
| 3302 | + if (adapter->flags & CXGB4VF_USING_MSIX) { |
|---|
| 3308 | 3303 | pci_disable_msix(adapter->pdev); |
|---|
| 3309 | | - adapter->flags &= ~USING_MSIX; |
|---|
| 3310 | | - } else if (adapter->flags & USING_MSI) { |
|---|
| 3304 | + adapter->flags &= ~CXGB4VF_USING_MSIX; |
|---|
| 3305 | + } else if (adapter->flags & CXGB4VF_USING_MSI) { |
|---|
| 3311 | 3306 | pci_disable_msi(adapter->pdev); |
|---|
| 3312 | | - adapter->flags &= ~USING_MSI; |
|---|
| 3307 | + adapter->flags &= ~CXGB4VF_USING_MSI; |
|---|
| 3313 | 3308 | } |
|---|
| 3314 | 3309 | |
|---|
| 3315 | 3310 | /* |
|---|
| .. | .. |
|---|
| 3332 | 3327 | continue; |
|---|
| 3333 | 3328 | |
|---|
| 3334 | 3329 | pi = netdev_priv(netdev); |
|---|
| 3335 | | - t4vf_free_vi(adapter, pi->viid); |
|---|
| 3330 | + if (pi->viid) |
|---|
| 3331 | + t4vf_free_vi(adapter, pi->viid); |
|---|
| 3336 | 3332 | free_netdev(netdev); |
|---|
| 3337 | 3333 | } |
|---|
| 3338 | 3334 | iounmap(adapter->regs); |
|---|
| 3339 | 3335 | if (!is_t4(adapter->params.chip)) |
|---|
| 3340 | 3336 | iounmap(adapter->bar2); |
|---|
| 3341 | 3337 | kfree(adapter->mbox_log); |
|---|
| 3338 | + list_for_each_entry_safe(entry, tmp, &adapter->mac_hlist, |
|---|
| 3339 | + list) { |
|---|
| 3340 | + list_del(&entry->list); |
|---|
| 3341 | + kfree(entry); |
|---|
| 3342 | + } |
|---|
| 3342 | 3343 | kfree(adapter); |
|---|
| 3343 | 3344 | } |
|---|
| 3344 | 3345 | |
|---|
| .. | .. |
|---|
| 3375 | 3376 | * Interrupts allowing various internal pathways to drain. |
|---|
| 3376 | 3377 | */ |
|---|
| 3377 | 3378 | t4vf_sge_stop(adapter); |
|---|
| 3378 | | - if (adapter->flags & USING_MSIX) { |
|---|
| 3379 | + if (adapter->flags & CXGB4VF_USING_MSIX) { |
|---|
| 3379 | 3380 | pci_disable_msix(adapter->pdev); |
|---|
| 3380 | | - adapter->flags &= ~USING_MSIX; |
|---|
| 3381 | | - } else if (adapter->flags & USING_MSI) { |
|---|
| 3381 | + adapter->flags &= ~CXGB4VF_USING_MSIX; |
|---|
| 3382 | + } else if (adapter->flags & CXGB4VF_USING_MSI) { |
|---|
| 3382 | 3383 | pci_disable_msi(adapter->pdev); |
|---|
| 3383 | | - adapter->flags &= ~USING_MSI; |
|---|
| 3384 | + adapter->flags &= ~CXGB4VF_USING_MSI; |
|---|
| 3384 | 3385 | } |
|---|
| 3385 | 3386 | |
|---|
| 3386 | 3387 | /* |
|---|
| .. | .. |
|---|
| 3407 | 3408 | MODULE_DESCRIPTION(DRV_DESC); |
|---|
| 3408 | 3409 | MODULE_AUTHOR("Chelsio Communications"); |
|---|
| 3409 | 3410 | MODULE_LICENSE("Dual BSD/GPL"); |
|---|
| 3410 | | -MODULE_VERSION(DRV_VERSION); |
|---|
| 3411 | 3411 | MODULE_DEVICE_TABLE(pci, cxgb4vf_pci_tbl); |
|---|
| 3412 | 3412 | |
|---|
| 3413 | 3413 | static struct pci_driver cxgb4vf_driver = { |
|---|
| .. | .. |
|---|
| 3434 | 3434 | return -EINVAL; |
|---|
| 3435 | 3435 | } |
|---|
| 3436 | 3436 | |
|---|
| 3437 | | - /* Debugfs support is optional, just warn if this fails */ |
|---|
| 3437 | + /* Debugfs support is optional, debugfs will warn if this fails */ |
|---|
| 3438 | 3438 | cxgb4vf_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
|---|
| 3439 | | - if (IS_ERR_OR_NULL(cxgb4vf_debugfs_root)) |
|---|
| 3440 | | - pr_warn("could not create debugfs entry, continuing\n"); |
|---|
| 3441 | 3439 | |
|---|
| 3442 | 3440 | ret = pci_register_driver(&cxgb4vf_driver); |
|---|
| 3443 | | - if (ret < 0 && !IS_ERR_OR_NULL(cxgb4vf_debugfs_root)) |
|---|
| 3441 | + if (ret < 0) |
|---|
| 3444 | 3442 | debugfs_remove(cxgb4vf_debugfs_root); |
|---|
| 3445 | 3443 | return ret; |
|---|
| 3446 | 3444 | } |
|---|