diff options
-rw-r--r-- | drivers/net/bnx2x/bnx2x.h | 2 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_dcb.c | 137 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_dcb.h | 5 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_main.c | 7 |
4 files changed, 92 insertions, 59 deletions
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index c0dd30d870ae..1914026a7b63 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h | |||
@@ -31,7 +31,7 @@ | |||
31 | #define BNX2X_NEW_NAPI | 31 | #define BNX2X_NEW_NAPI |
32 | 32 | ||
33 | #if defined(CONFIG_DCB) | 33 | #if defined(CONFIG_DCB) |
34 | #define BCM_DCB | 34 | #define BCM_DCBNL |
35 | #endif | 35 | #endif |
36 | #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE) | 36 | #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE) |
37 | #define BCM_CNIC 1 | 37 | #define BCM_CNIC 1 |
diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c index fb60021f81fb..9a24d79c71d9 100644 --- a/drivers/net/bnx2x/bnx2x_dcb.c +++ b/drivers/net/bnx2x/bnx2x_dcb.c | |||
@@ -19,6 +19,9 @@ | |||
19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
22 | #ifdef BCM_DCBNL | ||
23 | #include <linux/dcbnl.h> | ||
24 | #endif | ||
22 | 25 | ||
23 | #include "bnx2x.h" | 26 | #include "bnx2x.h" |
24 | #include "bnx2x_cmn.h" | 27 | #include "bnx2x_cmn.h" |
@@ -508,13 +511,75 @@ static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x *bp) | |||
508 | return 0; | 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 | void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) | 570 | void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) |
512 | { | 571 | { |
513 | switch (state) { | 572 | switch (state) { |
514 | case BNX2X_DCBX_STATE_NEG_RECEIVED: | 573 | case BNX2X_DCBX_STATE_NEG_RECEIVED: |
515 | { | 574 | { |
516 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_NEG_RECEIVED\n"); | 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 | /* Read neg results if dcbx is in the FW */ | 583 | /* Read neg results if dcbx is in the FW */ |
519 | if (bnx2x_dcbx_read_shmem_neg_results(bp)) | 584 | if (bnx2x_dcbx_read_shmem_neg_results(bp)) |
520 | return; | 585 | return; |
@@ -526,10 +591,24 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) | |||
526 | bp->dcbx_error); | 591 | bp->dcbx_error); |
527 | 592 | ||
528 | if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) { | 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 | bnx2x_dcbx_stop_hw_tx(bp); | 600 | bnx2x_dcbx_stop_hw_tx(bp); |
530 | return; | 601 | return; |
531 | } | 602 | } |
532 | /* fall through */ | 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 | case BNX2X_DCBX_STATE_TX_PAUSED: | 613 | case BNX2X_DCBX_STATE_TX_PAUSED: |
535 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n"); | 614 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n"); |
@@ -1505,8 +1584,7 @@ static void bnx2x_pfc_fw_struct_e2(struct bnx2x *bp) | |||
1505 | bnx2x_dcbx_print_cos_params(bp, pfc_fw_cfg); | 1584 | bnx2x_dcbx_print_cos_params(bp, pfc_fw_cfg); |
1506 | } | 1585 | } |
1507 | /* DCB netlink */ | 1586 | /* DCB netlink */ |
1508 | #ifdef BCM_DCB | 1587 | #ifdef BCM_DCBNL |
1509 | #include <linux/dcbnl.h> | ||
1510 | 1588 | ||
1511 | #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \ | 1589 | #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \ |
1512 | DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC) | 1590 | DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC) |
@@ -1816,32 +1894,6 @@ static void bnx2x_dcbnl_set_pfc_state(struct net_device *netdev, u8 state) | |||
1816 | bp->dcbx_config_params.admin_pfc_enable = (state ? 1 : 0); | 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 | static void bnx2x_admin_app_set_ent( | 1897 | static void bnx2x_admin_app_set_ent( |
1846 | struct bnx2x_admin_priority_app_table *app_ent, | 1898 | struct bnx2x_admin_priority_app_table *app_ent, |
1847 | u8 idtype, u16 idval, u8 up) | 1899 | u8 idtype, u16 idval, u8 up) |
@@ -1943,30 +1995,6 @@ static u8 bnx2x_dcbnl_set_app_up(struct net_device *netdev, u8 idtype, | |||
1943 | return bnx2x_set_admin_app_up(bp, idtype, idval, up); | 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 | static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev) | 1998 | static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev) |
1971 | { | 1999 | { |
1972 | struct bnx2x *bp = netdev_priv(netdev); | 2000 | struct bnx2x *bp = netdev_priv(netdev); |
@@ -2107,7 +2135,6 @@ const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops = { | |||
2107 | .setnumtcs = bnx2x_dcbnl_set_numtcs, | 2135 | .setnumtcs = bnx2x_dcbnl_set_numtcs, |
2108 | .getpfcstate = bnx2x_dcbnl_get_pfc_state, | 2136 | .getpfcstate = bnx2x_dcbnl_get_pfc_state, |
2109 | .setpfcstate = bnx2x_dcbnl_set_pfc_state, | 2137 | .setpfcstate = bnx2x_dcbnl_set_pfc_state, |
2110 | .getapp = bnx2x_dcbnl_get_app_up, | ||
2111 | .setapp = bnx2x_dcbnl_set_app_up, | 2138 | .setapp = bnx2x_dcbnl_set_app_up, |
2112 | .getdcbx = bnx2x_dcbnl_get_dcbx, | 2139 | .getdcbx = bnx2x_dcbnl_get_dcbx, |
2113 | .setdcbx = bnx2x_dcbnl_set_dcbx, | 2140 | .setdcbx = bnx2x_dcbnl_set_dcbx, |
@@ -2115,4 +2142,4 @@ const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops = { | |||
2115 | .setfeatcfg = bnx2x_dcbnl_set_featcfg, | 2142 | .setfeatcfg = bnx2x_dcbnl_set_featcfg, |
2116 | }; | 2143 | }; |
2117 | 2144 | ||
2118 | #endif /* BCM_DCB */ | 2145 | #endif /* BCM_DCBNL */ |
diff --git a/drivers/net/bnx2x/bnx2x_dcb.h b/drivers/net/bnx2x/bnx2x_dcb.h index f650f98e4092..71b8eda43bd0 100644 --- a/drivers/net/bnx2x/bnx2x_dcb.h +++ b/drivers/net/bnx2x/bnx2x_dcb.h | |||
@@ -189,8 +189,9 @@ enum { | |||
189 | void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state); | 189 | void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state); |
190 | 190 | ||
191 | /* DCB netlink */ | 191 | /* DCB netlink */ |
192 | #ifdef BCM_DCB | 192 | #ifdef BCM_DCBNL |
193 | extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops; | 193 | extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops; |
194 | #endif /* BCM_DCB */ | 194 | int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall); |
195 | #endif /* BCM_DCBNL */ | ||
195 | 196 | ||
196 | #endif /* BNX2X_DCB_H */ | 197 | #endif /* BNX2X_DCB_H */ |
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index 6c7745eee00d..061733e5e5ca 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -9441,7 +9441,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, | |||
9441 | dev->vlan_features |= (NETIF_F_TSO | NETIF_F_TSO_ECN); | 9441 | dev->vlan_features |= (NETIF_F_TSO | NETIF_F_TSO_ECN); |
9442 | dev->vlan_features |= NETIF_F_TSO6; | 9442 | dev->vlan_features |= NETIF_F_TSO6; |
9443 | 9443 | ||
9444 | #ifdef BCM_DCB | 9444 | #ifdef BCM_DCBNL |
9445 | dev->dcbnl_ops = &bnx2x_dcbnl_ops; | 9445 | dev->dcbnl_ops = &bnx2x_dcbnl_ops; |
9446 | #endif | 9446 | #endif |
9447 | 9447 | ||
@@ -9848,6 +9848,11 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev) | |||
9848 | } | 9848 | } |
9849 | #endif | 9849 | #endif |
9850 | 9850 | ||
9851 | #ifdef BCM_DCBNL | ||
9852 | /* Delete app tlvs from dcbnl */ | ||
9853 | bnx2x_dcbnl_update_applist(bp, true); | ||
9854 | #endif | ||
9855 | |||
9851 | unregister_netdev(dev); | 9856 | unregister_netdev(dev); |
9852 | 9857 | ||
9853 | /* Delete all NAPI objects */ | 9858 | /* Delete all NAPI objects */ |