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

« back to all changes in this revision

Viewing changes to drivers/net/bnx2x/bnx2x_dcb.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:
19
19
#include <linux/netdevice.h>
20
20
#include <linux/types.h>
21
21
#include <linux/errno.h>
 
22
#ifdef BCM_DCBNL
 
23
#include <linux/dcbnl.h>
 
24
#endif
22
25
 
23
26
#include "bnx2x.h"
24
27
#include "bnx2x_cmn.h"
508
511
        return 0;
509
512
}
510
513
 
 
514
 
 
515
#ifdef BCM_DCBNL
 
516
static inline
 
517
u8 bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry *ent)
 
518
{
 
519
        u8 pri;
 
520
 
 
521
        /* Choose the highest priority */
 
522
        for (pri = MAX_PFC_PRIORITIES - 1; pri > 0; pri--)
 
523
                if (ent->pri_bitmap & (1 << pri))
 
524
                        break;
 
525
        return pri;
 
526
}
 
527
 
 
528
static inline
 
529
u8 bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry *ent)
 
530
{
 
531
        return ((ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) ==
 
532
                DCBX_APP_SF_PORT) ? DCB_APP_IDTYPE_PORTNUM :
 
533
                DCB_APP_IDTYPE_ETHTYPE;
 
534
}
 
535
 
 
536
static inline
 
537
void bnx2x_dcbx_invalidate_local_apps(struct bnx2x *bp)
 
538
{
 
539
        int i;
 
540
        for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++)
 
541
                bp->dcbx_local_feat.app.app_pri_tbl[i].appBitfield &=
 
542
                                                        ~DCBX_APP_ENTRY_VALID;
 
543
}
 
544
 
 
545
int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall)
 
546
{
 
547
        int i, err = 0;
 
548
 
 
549
        for (i = 0; i < DCBX_MAX_APP_PROTOCOL && err == 0; i++) {
 
550
                struct dcbx_app_priority_entry *ent =
 
551
                        &bp->dcbx_local_feat.app.app_pri_tbl[i];
 
552
 
 
553
                if (ent->appBitfield & DCBX_APP_ENTRY_VALID) {
 
554
                        u8 up = bnx2x_dcbx_dcbnl_app_up(ent);
 
555
 
 
556
                        /* avoid invalid user-priority */
 
557
                        if (up) {
 
558
                                struct dcb_app app;
 
559
                                app.selector = bnx2x_dcbx_dcbnl_app_idtype(ent);
 
560
                                app.protocol = ent->app_id;
 
561
                                app.priority = delall ? 0 : up;
 
562
                                err = dcb_setapp(bp->dev, &app);
 
563
                        }
 
564
                }
 
565
        }
 
566
        return err;
 
567
}
 
568
#endif
 
569
 
511
570
void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
512
571
{
513
572
        switch (state) {
514
573
        case BNX2X_DCBX_STATE_NEG_RECEIVED:
515
574
                {
516
575
                        DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
517
 
 
 
576
#ifdef BCM_DCBNL
 
577
                        /**
 
578
                         * Delete app tlvs from dcbnl before reading new
 
579
                         * negotiation results
 
580
                         */
 
581
                        bnx2x_dcbnl_update_applist(bp, true);
 
582
#endif
518
583
                        /* Read neg results if dcbx is in the FW */
519
584
                        if (bnx2x_dcbx_read_shmem_neg_results(bp))
520
585
                                return;
526
591
                                                 bp->dcbx_error);
527
592
 
528
593
                        if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) {
 
594
#ifdef BCM_DCBNL
 
595
                                /**
 
596
                                 * Add new app tlvs to dcbnl
 
597
                                 */
 
598
                                bnx2x_dcbnl_update_applist(bp, false);
 
599
#endif
529
600
                                bnx2x_dcbx_stop_hw_tx(bp);
530
601
                                return;
531
602
                        }
532
603
                        /* fall through */
 
604
#ifdef BCM_DCBNL
 
605
                        /**
 
606
                         * Invalidate the local app tlvs if they are not added
 
607
                         * to the dcbnl app list to avoid deleting them from
 
608
                         * the list later on
 
609
                         */
 
610
                        bnx2x_dcbx_invalidate_local_apps(bp);
 
611
#endif
533
612
                }
534
613
        case BNX2X_DCBX_STATE_TX_PAUSED:
535
614
                DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n");
1505
1584
        bnx2x_dcbx_print_cos_params(bp, pfc_fw_cfg);
1506
1585
}
1507
1586
/* DCB netlink */
1508
 
#ifdef BCM_DCB
1509
 
#include <linux/dcbnl.h>
 
1587
#ifdef BCM_DCBNL
1510
1588
 
1511
1589
#define BNX2X_DCBX_CAPS         (DCB_CAP_DCBX_LLD_MANAGED | \
1512
1590
                                DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
1816
1894
        bp->dcbx_config_params.admin_pfc_enable = (state ? 1 : 0);
1817
1895
}
1818
1896
 
1819
 
static bool bnx2x_app_is_equal(struct dcbx_app_priority_entry *app_ent,
1820
 
                               u8 idtype, u16 idval)
1821
 
{
1822
 
        if (!(app_ent->appBitfield & DCBX_APP_ENTRY_VALID))
1823
 
                return false;
1824
 
 
1825
 
        switch (idtype) {
1826
 
        case DCB_APP_IDTYPE_ETHTYPE:
1827
 
                if ((app_ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) !=
1828
 
                        DCBX_APP_SF_ETH_TYPE)
1829
 
                        return false;
1830
 
                break;
1831
 
        case DCB_APP_IDTYPE_PORTNUM:
1832
 
                if ((app_ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) !=
1833
 
                        DCBX_APP_SF_PORT)
1834
 
                        return false;
1835
 
                break;
1836
 
        default:
1837
 
                return false;
1838
 
        }
1839
 
        if (app_ent->app_id != idval)
1840
 
                return false;
1841
 
 
1842
 
        return true;
1843
 
}
1844
 
 
1845
1897
static void bnx2x_admin_app_set_ent(
1846
1898
        struct bnx2x_admin_priority_app_table *app_ent,
1847
1899
        u8 idtype, u16 idval, u8 up)
1943
1995
        return bnx2x_set_admin_app_up(bp, idtype, idval, up);
1944
1996
}
1945
1997
 
1946
 
static u8 bnx2x_dcbnl_get_app_up(struct net_device *netdev, u8 idtype,
1947
 
                                 u16 idval)
1948
 
{
1949
 
        int i;
1950
 
        u8 up = 0;
1951
 
 
1952
 
        struct bnx2x *bp = netdev_priv(netdev);
1953
 
        DP(NETIF_MSG_LINK, "app_type %d, app_id 0x%x\n", idtype, idval);
1954
 
 
1955
 
        /* iterate over the app entries looking for idtype and idval */
1956
 
        for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++)
1957
 
                if (bnx2x_app_is_equal(&bp->dcbx_local_feat.app.app_pri_tbl[i],
1958
 
                                       idtype, idval))
1959
 
                        break;
1960
 
 
1961
 
        if (i < DCBX_MAX_APP_PROTOCOL)
1962
 
                /* if found return up */
1963
 
                up = bp->dcbx_local_feat.app.app_pri_tbl[i].pri_bitmap;
1964
 
        else
1965
 
                DP(NETIF_MSG_LINK, "app not found\n");
1966
 
 
1967
 
        return up;
1968
 
}
1969
 
 
1970
1998
static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev)
1971
1999
{
1972
2000
        struct bnx2x *bp = netdev_priv(netdev);
2107
2135
        .setnumtcs      = bnx2x_dcbnl_set_numtcs,
2108
2136
        .getpfcstate    = bnx2x_dcbnl_get_pfc_state,
2109
2137
        .setpfcstate    = bnx2x_dcbnl_set_pfc_state,
2110
 
        .getapp         = bnx2x_dcbnl_get_app_up,
2111
2138
        .setapp         = bnx2x_dcbnl_set_app_up,
2112
2139
        .getdcbx        = bnx2x_dcbnl_get_dcbx,
2113
2140
        .setdcbx        = bnx2x_dcbnl_set_dcbx,
2115
2142
        .setfeatcfg     = bnx2x_dcbnl_set_featcfg,
2116
2143
};
2117
2144
 
2118
 
#endif /* BCM_DCB */
 
2145
#endif /* BCM_DCBNL */