517
u8 bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry *ent)
521
/* Choose the highest priority */
522
for (pri = MAX_PFC_PRIORITIES - 1; pri > 0; pri--)
523
if (ent->pri_bitmap & (1 << pri))
529
u8 bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry *ent)
531
return ((ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) ==
532
DCBX_APP_SF_PORT) ? DCB_APP_IDTYPE_PORTNUM :
533
DCB_APP_IDTYPE_ETHTYPE;
537
void bnx2x_dcbx_invalidate_local_apps(struct bnx2x *bp)
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;
545
int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall)
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];
553
if (ent->appBitfield & DCBX_APP_ENTRY_VALID) {
554
u8 up = bnx2x_dcbx_dcbnl_app_up(ent);
556
/* avoid invalid user-priority */
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);
511
570
void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
514
573
case BNX2X_DCBX_STATE_NEG_RECEIVED:
516
575
DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
578
* Delete app tlvs from dcbnl before reading new
579
* negotiation results
581
bnx2x_dcbnl_update_applist(bp, true);
518
583
/* Read neg results if dcbx is in the FW */
519
584
if (bnx2x_dcbx_read_shmem_neg_results(bp))
528
593
if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) {
596
* Add new app tlvs to dcbnl
598
bnx2x_dcbnl_update_applist(bp, false);
529
600
bnx2x_dcbx_stop_hw_tx(bp);
532
603
/* fall through */
606
* Invalidate the local app tlvs if they are not added
607
* to the dcbnl app list to avoid deleting them from
610
bnx2x_dcbx_invalidate_local_apps(bp);
534
613
case BNX2X_DCBX_STATE_TX_PAUSED:
535
614
DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n");
1816
1894
bp->dcbx_config_params.admin_pfc_enable = (state ? 1 : 0);
1819
static bool bnx2x_app_is_equal(struct dcbx_app_priority_entry *app_ent,
1820
u8 idtype, u16 idval)
1822
if (!(app_ent->appBitfield & DCBX_APP_ENTRY_VALID))
1826
case DCB_APP_IDTYPE_ETHTYPE:
1827
if ((app_ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) !=
1828
DCBX_APP_SF_ETH_TYPE)
1831
case DCB_APP_IDTYPE_PORTNUM:
1832
if ((app_ent->appBitfield & DCBX_APP_ENTRY_SF_MASK) !=
1839
if (app_ent->app_id != idval)
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);
1946
static u8 bnx2x_dcbnl_get_app_up(struct net_device *netdev, u8 idtype,
1952
struct bnx2x *bp = netdev_priv(netdev);
1953
DP(NETIF_MSG_LINK, "app_type %d, app_id 0x%x\n", idtype, idval);
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],
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;
1965
DP(NETIF_MSG_LINK, "app not found\n");
1970
1998
static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev)
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,