~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/mlx4/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <linux/pci.h>
40
40
#include <linux/dma-mapping.h>
41
41
#include <linux/slab.h>
 
42
#include <linux/io-mapping.h>
42
43
 
43
44
#include <linux/mlx4/device.h>
44
45
#include <linux/mlx4/doorbell.h>
227
228
        dev->caps.stat_rate_support  = dev_cap->stat_rate_support;
228
229
        dev->caps.udp_rss            = dev_cap->udp_rss;
229
230
        dev->caps.loopback_support   = dev_cap->loopback_support;
 
231
        dev->caps.vep_uc_steering    = dev_cap->vep_uc_steering;
 
232
        dev->caps.vep_mc_steering    = dev_cap->vep_mc_steering;
 
233
        dev->caps.wol                = dev_cap->wol;
230
234
        dev->caps.max_gso_sz         = dev_cap->max_gso_sz;
231
235
 
232
236
        dev->caps.log_num_macs  = log_num_mac;
718
722
        mlx4_free_icm(dev, priv->fw.aux_icm, 0);
719
723
}
720
724
 
 
725
static int map_bf_area(struct mlx4_dev *dev)
 
726
{
 
727
        struct mlx4_priv *priv = mlx4_priv(dev);
 
728
        resource_size_t bf_start;
 
729
        resource_size_t bf_len;
 
730
        int err = 0;
 
731
 
 
732
        bf_start = pci_resource_start(dev->pdev, 2) + (dev->caps.num_uars << PAGE_SHIFT);
 
733
        bf_len = pci_resource_len(dev->pdev, 2) - (dev->caps.num_uars << PAGE_SHIFT);
 
734
        priv->bf_mapping = io_mapping_create_wc(bf_start, bf_len);
 
735
        if (!priv->bf_mapping)
 
736
                err = -ENOMEM;
 
737
 
 
738
        return err;
 
739
}
 
740
 
 
741
static void unmap_bf_area(struct mlx4_dev *dev)
 
742
{
 
743
        if (mlx4_priv(dev)->bf_mapping)
 
744
                io_mapping_free(mlx4_priv(dev)->bf_mapping);
 
745
}
 
746
 
721
747
static void mlx4_close_hca(struct mlx4_dev *dev)
722
748
{
 
749
        unmap_bf_area(dev);
723
750
        mlx4_CLOSE_HCA(dev, 0);
724
751
        mlx4_free_icms(dev);
725
752
        mlx4_UNMAP_FA(dev);
772
799
                goto err_stop_fw;
773
800
        }
774
801
 
 
802
        if (map_bf_area(dev))
 
803
                mlx4_dbg(dev, "Failed to map blue flame area\n");
 
804
 
775
805
        init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
776
806
 
777
807
        err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
802
832
        mlx4_free_icms(dev);
803
833
 
804
834
err_stop_fw:
 
835
        unmap_bf_area(dev);
805
836
        mlx4_UNMAP_FA(dev);
806
837
        mlx4_free_icm(dev, priv->fw.fw_icm, 0);
807
838
 
913
944
        }
914
945
 
915
946
        for (port = 1; port <= dev->caps.num_ports; port++) {
 
947
                enum mlx4_port_type port_type = 0;
 
948
                mlx4_SENSE_PORT(dev, port, &port_type);
 
949
                if (port_type)
 
950
                        dev->caps.port_type[port] = port_type;
916
951
                ib_port_default_caps = 0;
917
952
                err = mlx4_get_port_ib_caps(dev, port, &ib_port_default_caps);
918
953
                if (err)
927
962
                        goto err_mcg_table_free;
928
963
                }
929
964
        }
 
965
        mlx4_set_port_mask(dev);
930
966
 
931
967
        return 0;
932
968
 
969
1005
{
970
1006
        struct mlx4_priv *priv = mlx4_priv(dev);
971
1007
        struct msix_entry *entries;
972
 
        int nreq;
 
1008
        int nreq = min_t(int, dev->caps.num_ports *
 
1009
                         min_t(int, num_online_cpus() + 1, MAX_MSIX_P_PORT)
 
1010
                                + MSIX_LEGACY_SZ, MAX_MSIX);
973
1011
        int err;
974
1012
        int i;
975
1013
 
976
1014
        if (msi_x) {
977
1015
                nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
978
 
                             num_possible_cpus() + 1);
 
1016
                             nreq);
979
1017
                entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
980
1018
                if (!entries)
981
1019
                        goto no_msi;
998
1036
                        goto no_msi;
999
1037
                }
1000
1038
 
1001
 
                dev->caps.num_comp_vectors = nreq - 1;
 
1039
                if (nreq <
 
1040
                    MSIX_LEGACY_SZ + dev->caps.num_ports * MIN_MSIX_P_PORT) {
 
1041
                        /*Working in legacy mode , all EQ's shared*/
 
1042
                        dev->caps.comp_pool           = 0;
 
1043
                        dev->caps.num_comp_vectors = nreq - 1;
 
1044
                } else {
 
1045
                        dev->caps.comp_pool           = nreq - MSIX_LEGACY_SZ;
 
1046
                        dev->caps.num_comp_vectors = MSIX_LEGACY_SZ - 1;
 
1047
                }
1002
1048
                for (i = 0; i < nreq; ++i)
1003
1049
                        priv->eq_table.eq[i].irq = entries[i].vector;
1004
1050
 
1010
1056
 
1011
1057
no_msi:
1012
1058
        dev->caps.num_comp_vectors = 1;
 
1059
        dev->caps.comp_pool        = 0;
1013
1060
 
1014
1061
        for (i = 0; i < 2; ++i)
1015
1062
                priv->eq_table.eq[i].irq = dev->pdev->irq;
1049
1096
        device_remove_file(&info->dev->pdev->dev, &info->port_attr);
1050
1097
}
1051
1098
 
 
1099
static int mlx4_init_steering(struct mlx4_dev *dev)
 
1100
{
 
1101
        struct mlx4_priv *priv = mlx4_priv(dev);
 
1102
        int num_entries = dev->caps.num_ports;
 
1103
        int i, j;
 
1104
 
 
1105
        priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL);
 
1106
        if (!priv->steer)
 
1107
                return -ENOMEM;
 
1108
 
 
1109
        for (i = 0; i < num_entries; i++) {
 
1110
                for (j = 0; j < MLX4_NUM_STEERS; j++) {
 
1111
                        INIT_LIST_HEAD(&priv->steer[i].promisc_qps[j]);
 
1112
                        INIT_LIST_HEAD(&priv->steer[i].steer_entries[j]);
 
1113
                }
 
1114
                INIT_LIST_HEAD(&priv->steer[i].high_prios);
 
1115
        }
 
1116
        return 0;
 
1117
}
 
1118
 
 
1119
static void mlx4_clear_steering(struct mlx4_dev *dev)
 
1120
{
 
1121
        struct mlx4_priv *priv = mlx4_priv(dev);
 
1122
        struct mlx4_steer_index *entry, *tmp_entry;
 
1123
        struct mlx4_promisc_qp *pqp, *tmp_pqp;
 
1124
        int num_entries = dev->caps.num_ports;
 
1125
        int i, j;
 
1126
 
 
1127
        for (i = 0; i < num_entries; i++) {
 
1128
                for (j = 0; j < MLX4_NUM_STEERS; j++) {
 
1129
                        list_for_each_entry_safe(pqp, tmp_pqp,
 
1130
                                                 &priv->steer[i].promisc_qps[j],
 
1131
                                                 list) {
 
1132
                                list_del(&pqp->list);
 
1133
                                kfree(pqp);
 
1134
                        }
 
1135
                        list_for_each_entry_safe(entry, tmp_entry,
 
1136
                                                 &priv->steer[i].steer_entries[j],
 
1137
                                                 list) {
 
1138
                                list_del(&entry->list);
 
1139
                                list_for_each_entry_safe(pqp, tmp_pqp,
 
1140
                                                         &entry->duplicates,
 
1141
                                                         list) {
 
1142
                                        list_del(&pqp->list);
 
1143
                                        kfree(pqp);
 
1144
                                }
 
1145
                                kfree(entry);
 
1146
                        }
 
1147
                }
 
1148
        }
 
1149
        kfree(priv->steer);
 
1150
}
 
1151
 
1052
1152
static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1053
1153
{
1054
1154
        struct mlx4_priv *priv;
1109
1209
                }
1110
1210
        }
1111
1211
 
 
1212
        /* Allow large DMA segments, up to the firmware limit of 1 GB */
 
1213
        dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
 
1214
 
1112
1215
        priv = kzalloc(sizeof *priv, GFP_KERNEL);
1113
1216
        if (!priv) {
1114
1217
                dev_err(&pdev->dev, "Device struct alloc failed, "
1127
1230
        INIT_LIST_HEAD(&priv->pgdir_list);
1128
1231
        mutex_init(&priv->pgdir_mutex);
1129
1232
 
 
1233
        pci_read_config_byte(pdev, PCI_REVISION_ID, &dev->rev_id);
 
1234
 
 
1235
        INIT_LIST_HEAD(&priv->bf_list);
 
1236
        mutex_init(&priv->bf_mutex);
 
1237
 
1130
1238
        /*
1131
1239
         * Now reset the HCA before we touch the PCI capabilities or
1132
1240
         * attempt a firmware command, since a boot ROM may have left
1151
1259
        if (err)
1152
1260
                goto err_close;
1153
1261
 
 
1262
        priv->msix_ctl.pool_bm = 0;
 
1263
        spin_lock_init(&priv->msix_ctl.pool_lock);
 
1264
 
1154
1265
        mlx4_enable_msi_x(dev);
1155
1266
 
 
1267
        err = mlx4_init_steering(dev);
 
1268
        if (err)
 
1269
                goto err_free_eq;
 
1270
 
1156
1271
        err = mlx4_setup_hca(dev);
1157
1272
        if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X)) {
1158
1273
                dev->flags &= ~MLX4_FLAG_MSI_X;
1161
1276
        }
1162
1277
 
1163
1278
        if (err)
1164
 
                goto err_free_eq;
 
1279
                goto err_steer;
1165
1280
 
1166
1281
        for (port = 1; port <= dev->caps.num_ports; port++) {
1167
1282
                err = mlx4_init_port_info(dev, port);
1194
1309
        mlx4_cleanup_pd_table(dev);
1195
1310
        mlx4_cleanup_uar_table(dev);
1196
1311
 
 
1312
err_steer:
 
1313
        mlx4_clear_steering(dev);
 
1314
 
1197
1315
err_free_eq:
1198
1316
        mlx4_free_eq_table(dev);
1199
1317
 
1253
1371
                iounmap(priv->kar);
1254
1372
                mlx4_uar_free(dev, &priv->driver_uar);
1255
1373
                mlx4_cleanup_uar_table(dev);
 
1374
                mlx4_clear_steering(dev);
1256
1375
                mlx4_free_eq_table(dev);
1257
1376
                mlx4_close_hca(dev);
1258
1377
                mlx4_cmd_cleanup(dev);