~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to drivers/net/ethernet/emulex/benet/be_cmds.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Ubuntu: 3.5.0-25.38
  • Date: 2013-02-20 22:03:31 UTC
  • mfrom: (74.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20130220220331-0ea4l33x3cr61nch
Tags: 3.5.0-220.28
* Release Tracking Bug
  - LP: #1130311

[ Paolo Pisati ]

* rebased on Ubuntu-3.5.0-25.38

[ Ubuntu: 3.5.0-25.38 ]

* Release Tracking Bug
  - LP: #1129472
* ptrace: introduce signal_wake_up_state() and ptrace_signal_wake_up()
  - LP: #1119885, #1129192
  - CVE-2013-0871
* ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL
  - LP: #1119885, #1129192
  - CVE-2013-0871
* wake_up_process() should be never used to wakeup a TASK_STOPPED/TRACED
  task
  - LP: #1119885, #1129192
  - CVE-2013-0871

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "be.h"
20
20
#include "be_cmds.h"
21
21
 
22
 
/* Must be a power of 2 or else MODULO will BUG_ON */
23
 
static int be_get_temp_freq = 64;
24
 
 
25
22
static inline void *embedded_payload(struct be_mcc_wrb *wrb)
26
23
{
27
24
        return wrb->payload.embedded_payload;
115
112
                }
116
113
        } else {
117
114
                if (opcode == OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES)
118
 
                        be_get_temp_freq = 0;
 
115
                        adapter->be_get_temp_freq = 0;
119
116
 
120
117
                if (compl_status == MCC_STATUS_NOT_SUPPORTED ||
121
118
                        compl_status == MCC_STATUS_ILLEGAL_REQUEST)
144
141
        /* When link status changes, link speed must be re-queried from FW */
145
142
        adapter->phy.link_speed = -1;
146
143
 
 
144
        /* Ignore physical link event */
 
145
        if (lancer_chip(adapter) &&
 
146
            !(evt->port_link_status & LOGICAL_LINK_STATUS_MASK))
 
147
                return;
 
148
 
147
149
        /* For the initial link status do not rely on the ASYNC event as
148
150
         * it may not be received in some cases.
149
151
         */
163
165
        }
164
166
}
165
167
 
166
 
/* Grp5 QOS Speed evt */
 
168
/* Grp5 QOS Speed evt: qos_link_speed is in units of 10 Mbps */
167
169
static void be_async_grp5_qos_speed_process(struct be_adapter *adapter,
168
170
                struct be_async_event_grp5_qos_link_speed *evt)
169
171
{
170
 
        if (evt->physical_port == adapter->port_num) {
171
 
                /* qos_link_speed is in units of 10 Mbps */
172
 
                adapter->phy.link_speed = evt->qos_link_speed * 10;
173
 
        }
 
172
        if (adapter->phy.link_speed >= 0 &&
 
173
            evt->physical_port == adapter->port_num)
 
174
                adapter->phy.link_speed = le16_to_cpu(evt->qos_link_speed) * 10;
174
175
}
175
176
 
176
177
/*Grp5 PVID evt*/
257
258
        int num = 0, status = 0;
258
259
        struct be_mcc_obj *mcc_obj = &adapter->mcc_obj;
259
260
 
260
 
        spin_lock_bh(&adapter->mcc_cq_lock);
 
261
        spin_lock(&adapter->mcc_cq_lock);
261
262
        while ((compl = be_mcc_compl_get(adapter))) {
262
263
                if (compl->flags & CQE_FLAGS_ASYNC_MASK) {
263
264
                        /* Interpret flags as an async trailer */
278
279
        if (num)
279
280
                be_cq_notify(adapter, mcc_obj->cq.id, mcc_obj->rearm_cq, num);
280
281
 
281
 
        spin_unlock_bh(&adapter->mcc_cq_lock);
 
282
        spin_unlock(&adapter->mcc_cq_lock);
282
283
        return status;
283
284
}
284
285
 
293
294
                if (be_error(adapter))
294
295
                        return -EIO;
295
296
 
 
297
                local_bh_disable();
296
298
                status = be_process_mcc(adapter);
 
299
                local_bh_enable();
297
300
 
298
301
                if (atomic_read(&mcc_obj->q.used) == 0)
299
302
                        break;
352
355
                if (msecs > 4000) {
353
356
                        dev_err(&adapter->pdev->dev, "FW not responding\n");
354
357
                        adapter->fw_timeout = true;
355
 
                        be_detect_dump_ue(adapter);
 
358
                        be_detect_error(adapter);
356
359
                        return -1;
357
360
                }
358
361
 
429
432
                return 0;
430
433
}
431
434
 
432
 
int be_cmd_POST(struct be_adapter *adapter)
 
435
int lancer_wait_ready(struct be_adapter *adapter)
 
436
{
 
437
#define SLIPORT_READY_TIMEOUT 30
 
438
        u32 sliport_status;
 
439
        int status = 0, i;
 
440
 
 
441
        for (i = 0; i < SLIPORT_READY_TIMEOUT; i++) {
 
442
                sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET);
 
443
                if (sliport_status & SLIPORT_STATUS_RDY_MASK)
 
444
                        break;
 
445
 
 
446
                msleep(1000);
 
447
        }
 
448
 
 
449
        if (i == SLIPORT_READY_TIMEOUT)
 
450
                status = -1;
 
451
 
 
452
        return status;
 
453
}
 
454
 
 
455
int lancer_test_and_set_rdy_state(struct be_adapter *adapter)
 
456
{
 
457
        int status;
 
458
        u32 sliport_status, err, reset_needed;
 
459
        status = lancer_wait_ready(adapter);
 
460
        if (!status) {
 
461
                sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET);
 
462
                err = sliport_status & SLIPORT_STATUS_ERR_MASK;
 
463
                reset_needed = sliport_status & SLIPORT_STATUS_RN_MASK;
 
464
                if (err && reset_needed) {
 
465
                        iowrite32(SLI_PORT_CONTROL_IP_MASK,
 
466
                                  adapter->db + SLIPORT_CONTROL_OFFSET);
 
467
 
 
468
                        /* check adapter has corrected the error */
 
469
                        status = lancer_wait_ready(adapter);
 
470
                        sliport_status = ioread32(adapter->db +
 
471
                                                  SLIPORT_STATUS_OFFSET);
 
472
                        sliport_status &= (SLIPORT_STATUS_ERR_MASK |
 
473
                                                SLIPORT_STATUS_RN_MASK);
 
474
                        if (status || sliport_status)
 
475
                                status = -1;
 
476
                } else if (err || reset_needed) {
 
477
                        status = -1;
 
478
                }
 
479
        }
 
480
        return status;
 
481
}
 
482
 
 
483
int be_fw_wait_ready(struct be_adapter *adapter)
433
484
{
434
485
        u16 stage;
435
486
        int status, timeout = 0;
436
487
        struct device *dev = &adapter->pdev->dev;
437
488
 
 
489
        if (lancer_chip(adapter)) {
 
490
                status = lancer_wait_ready(adapter);
 
491
                return status;
 
492
        }
 
493
 
438
494
        do {
439
495
                status = be_POST_stage_get(adapter, &stage);
440
496
                if (status) {
565
621
        u8 *wrb;
566
622
        int status;
567
623
 
 
624
        if (lancer_chip(adapter))
 
625
                return 0;
 
626
 
568
627
        if (mutex_lock_interruptible(&adapter->mbox_lock))
569
628
                return -1;
570
629
 
592
651
        u8 *wrb;
593
652
        int status;
594
653
 
 
654
        if (lancer_chip(adapter))
 
655
                return 0;
 
656
 
595
657
        if (mutex_lock_interruptible(&adapter->mbox_lock))
596
658
                return -1;
597
659
 
610
672
        mutex_unlock(&adapter->mbox_lock);
611
673
        return status;
612
674
}
 
675
 
613
676
int be_cmd_eq_create(struct be_adapter *adapter,
614
677
                struct be_queue_info *eq, int eq_delay)
615
678
{
1132
1195
 * Uses MCCQ
1133
1196
 */
1134
1197
int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1135
 
                u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain)
 
1198
                     u32 *if_handle, u32 domain)
1136
1199
{
1137
1200
        struct be_mcc_wrb *wrb;
1138
1201
        struct be_cmd_req_if_create *req;
1152
1215
        req->hdr.domain = domain;
1153
1216
        req->capability_flags = cpu_to_le32(cap_flags);
1154
1217
        req->enable_flags = cpu_to_le32(en_flags);
1155
 
        if (mac)
1156
 
                memcpy(req->mac_addr, mac, ETH_ALEN);
1157
 
        else
1158
 
                req->pmac_invalid = true;
 
1218
 
 
1219
        req->pmac_invalid = true;
1159
1220
 
1160
1221
        status = be_mcc_notify_wait(adapter);
1161
1222
        if (!status) {
1162
1223
                struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
1163
1224
                *if_handle = le32_to_cpu(resp->interface_id);
1164
 
                if (mac)
1165
 
                        *pmac_id = le32_to_cpu(resp->pmac_id);
1166
1225
        }
1167
1226
 
1168
1227
err:
1210
1269
        struct be_cmd_req_hdr *hdr;
1211
1270
        int status = 0;
1212
1271
 
1213
 
        if (MODULO(adapter->work_counter, be_get_temp_freq) == 0)
1214
 
                be_cmd_get_die_temperature(adapter);
1215
 
 
1216
1272
        spin_lock_bh(&adapter->mcc_lock);
1217
1273
 
1218
1274
        wrb = wrb_from_mccq(adapter);
1269
1325
        return status;
1270
1326
}
1271
1327
 
1272
 
/* Uses synchronous mcc */
1273
 
int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed,
1274
 
                             u16 *link_speed, u8 *link_status, u32 dom)
 
1328
static int be_mac_to_link_speed(int mac_speed)
 
1329
{
 
1330
        switch (mac_speed) {
 
1331
        case PHY_LINK_SPEED_ZERO:
 
1332
                return 0;
 
1333
        case PHY_LINK_SPEED_10MBPS:
 
1334
                return 10;
 
1335
        case PHY_LINK_SPEED_100MBPS:
 
1336
                return 100;
 
1337
        case PHY_LINK_SPEED_1GBPS:
 
1338
                return 1000;
 
1339
        case PHY_LINK_SPEED_10GBPS:
 
1340
                return 10000;
 
1341
        }
 
1342
        return 0;
 
1343
}
 
1344
 
 
1345
/* Uses synchronous mcc
 
1346
 * Returns link_speed in Mbps
 
1347
 */
 
1348
int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
 
1349
                             u8 *link_status, u32 dom)
1275
1350
{
1276
1351
        struct be_mcc_wrb *wrb;
1277
1352
        struct be_cmd_req_link_status *req;
1300
1375
        status = be_mcc_notify_wait(adapter);
1301
1376
        if (!status) {
1302
1377
                struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
1303
 
                if (resp->mac_speed != PHY_LINK_SPEED_ZERO) {
1304
 
                        if (link_speed)
1305
 
                                *link_speed = le16_to_cpu(resp->link_speed);
1306
 
                        if (mac_speed)
1307
 
                                *mac_speed = resp->mac_speed;
 
1378
                if (link_speed) {
 
1379
                        *link_speed = resp->link_speed ?
 
1380
                                      le16_to_cpu(resp->link_speed) * 10 :
 
1381
                                      be_mac_to_link_speed(resp->mac_speed);
 
1382
 
 
1383
                        if (!resp->logical_link_status)
 
1384
                                *link_speed = 0;
1308
1385
                }
1309
1386
                if (link_status)
1310
1387
                        *link_status = resp->logical_link_status;
1581
1658
                /* Reset mcast promisc mode if already set by setting mask
1582
1659
                 * and not setting flags field
1583
1660
                 */
1584
 
                req->if_flags_mask |=
 
1661
                if (!lancer_chip(adapter) || be_physfn(adapter))
 
1662
                        req->if_flags_mask |=
1585
1663
                                cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS);
1586
1664
 
1587
1665
                req->mcast_num = cpu_to_le32(netdev_mc_count(adapter->netdev));
1692
1770
        struct be_cmd_req_hdr *req;
1693
1771
        int status;
1694
1772
 
 
1773
        if (lancer_chip(adapter)) {
 
1774
                status = lancer_wait_ready(adapter);
 
1775
                if (!status) {
 
1776
                        iowrite32(SLI_PORT_CONTROL_IP_MASK,
 
1777
                                  adapter->db + SLIPORT_CONTROL_OFFSET);
 
1778
                        status = lancer_test_and_set_rdy_state(adapter);
 
1779
                }
 
1780
                if (status) {
 
1781
                        dev_err(&adapter->pdev->dev,
 
1782
                                "Adapter in non recoverable error\n");
 
1783
                }
 
1784
                return status;
 
1785
        }
 
1786
 
1695
1787
        if (mutex_lock_interruptible(&adapter->mbox_lock))
1696
1788
                return -1;
1697
1789
 
1728
1820
        req->if_id = cpu_to_le32(adapter->if_handle);
1729
1821
        req->enable_rss = cpu_to_le16(RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4 |
1730
1822
                                      RSS_ENABLE_TCP_IPV6 | RSS_ENABLE_IPV6);
 
1823
 
 
1824
        if (lancer_chip(adapter) || skyhawk_chip(adapter)) {
 
1825
                req->hdr.version = 1;
 
1826
                req->enable_rss |= cpu_to_le16(RSS_ENABLE_UDP_IPV4 |
 
1827
                                               RSS_ENABLE_UDP_IPV6);
 
1828
        }
 
1829
 
1731
1830
        req->cpu_table_size_log2 = cpu_to_le16(fls(table_size) - 1);
1732
1831
        memcpy(req->cpu_table, rsstable, table_size);
1733
1832
        memcpy(req->hash, myhash, sizeof(myhash));
1805
1904
}
1806
1905
 
1807
1906
int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
1808
 
                        u32 data_size, u32 data_offset, const char *obj_name,
1809
 
                        u32 *data_written, u8 *addn_status)
 
1907
                            u32 data_size, u32 data_offset,
 
1908
                            const char *obj_name, u32 *data_written,
 
1909
                            u8 *change_status, u8 *addn_status)
1810
1910
{
1811
1911
        struct be_mcc_wrb *wrb;
1812
1912
        struct lancer_cmd_req_write_object *req;
1862
1962
                status = adapter->flash_status;
1863
1963
 
1864
1964
        resp = embedded_payload(wrb);
1865
 
        if (!status)
 
1965
        if (!status) {
1866
1966
                *data_written = le32_to_cpu(resp->actual_write_len);
1867
 
        else
 
1967
                *change_status = resp->change_status;
 
1968
        } else {
1868
1969
                *addn_status = resp->additional_status;
 
1970
        }
1869
1971
 
1870
1972
        return status;
1871
1973
 
2330
2432
}
2331
2433
 
2332
2434
/* Uses synchronous MCCQ */
2333
 
int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2334
 
                        bool *pmac_id_active, u32 *pmac_id, u8 *mac)
 
2435
int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
 
2436
                             bool *pmac_id_active, u32 *pmac_id, u8 domain)
2335
2437
{
2336
2438
        struct be_mcc_wrb *wrb;
2337
2439
        struct be_cmd_req_get_mac_list *req;
2376
2478
                                                get_mac_list_cmd.va;
2377
2479
                mac_count = resp->true_mac_count + resp->pseudo_mac_count;
2378
2480
                /* Mac list returned could contain one or more active mac_ids
2379
 
                 * or one or more pseudo permanant mac addresses. If an active
2380
 
                 * mac_id is present, return first active mac_id found
 
2481
                 * or one or more true or pseudo permanant mac addresses.
 
2482
                 * If an active mac_id is present, return first active mac_id
 
2483
                 * found.
2381
2484
                 */
2382
2485
                for (i = 0; i < mac_count; i++) {
2383
2486
                        struct get_list_macaddr *mac_entry;
2396
2499
                                goto out;
2397
2500
                        }
2398
2501
                }
2399
 
                /* If no active mac_id found, return first pseudo mac addr */
 
2502
                /* If no active mac_id found, return first mac addr */
2400
2503
                *pmac_id_active = false;
2401
2504
                memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
2402
2505
                                                                ETH_ALEN);