2008-11-21 12:52:10 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
Intel 10 Gigabit PCI Express Linux driver
|
2014-07-22 14:51:08 +08:00
|
|
|
Copyright(c) 1999 - 2014 Intel Corporation.
|
2008-11-21 12:52:10 +08:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms and conditions of the GNU General Public License,
|
|
|
|
version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
The full GNU General Public License is included in this distribution in
|
|
|
|
the file called "COPYING".
|
|
|
|
|
|
|
|
Contact Information:
|
|
|
|
Linux NICS <linux.nics@intel.com>
|
|
|
|
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
|
|
|
|
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include "ixgbe.h"
|
|
|
|
#include <linux/dcbnl.h>
|
2009-05-17 20:35:57 +08:00
|
|
|
#include "ixgbe_dcb_82598.h"
|
|
|
|
#include "ixgbe_dcb_82599.h"
|
2012-10-19 10:34:34 +08:00
|
|
|
#include "ixgbe_sriov.h"
|
2008-11-21 12:52:10 +08:00
|
|
|
|
|
|
|
/* Callbacks for DCB netlink in the kernel */
|
|
|
|
#define BIT_DCB_MODE 0x01
|
|
|
|
#define BIT_PFC 0x02
|
|
|
|
#define BIT_PG_RX 0x04
|
|
|
|
#define BIT_PG_TX 0x08
|
2009-09-03 22:55:50 +08:00
|
|
|
#define BIT_APP_UPCHG 0x10
|
2009-02-27 23:44:48 +08:00
|
|
|
#define BIT_LINKSPEED 0x80
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2009-05-17 20:35:57 +08:00
|
|
|
/* Responses for the DCB_C_SET_ALL command */
|
|
|
|
#define DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
|
|
|
|
#define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
|
|
|
|
#define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
|
|
|
|
|
2012-04-19 06:42:27 +08:00
|
|
|
static int ixgbe_copy_dcb_cfg(struct ixgbe_adapter *adapter, int tc_max)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
2012-04-19 06:42:27 +08:00
|
|
|
struct ixgbe_dcb_config *scfg = &adapter->temp_dcb_cfg;
|
|
|
|
struct ixgbe_dcb_config *dcfg = &adapter->dcb_cfg;
|
2012-03-28 15:49:09 +08:00
|
|
|
struct tc_configuration *src = NULL;
|
|
|
|
struct tc_configuration *dst = NULL;
|
|
|
|
int i, j;
|
|
|
|
int tx = DCB_TX_CONFIG;
|
|
|
|
int rx = DCB_RX_CONFIG;
|
|
|
|
int changes = 0;
|
2012-04-19 06:42:27 +08:00
|
|
|
#ifdef IXGBE_FCOE
|
|
|
|
struct dcb_app app = {
|
|
|
|
.selector = DCB_APP_IDTYPE_ETHTYPE,
|
|
|
|
.protocol = ETH_P_FCOE,
|
|
|
|
};
|
|
|
|
u8 up = dcb_getapp(adapter->netdev, &app);
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2016-04-14 07:08:22 +08:00
|
|
|
if (up && !(up & BIT(adapter->fcoe.up)))
|
2012-04-19 06:42:27 +08:00
|
|
|
changes |= BIT_APP_UPCHG;
|
|
|
|
#endif
|
2008-11-21 12:52:10 +08:00
|
|
|
|
|
|
|
for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
|
2012-03-28 15:49:09 +08:00
|
|
|
src = &scfg->tc_config[i - DCB_PG_ATTR_TC_0];
|
|
|
|
dst = &dcfg->tc_config[i - DCB_PG_ATTR_TC_0];
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[tx].prio_type != src->path[tx].prio_type) {
|
|
|
|
dst->path[tx].prio_type = src->path[tx].prio_type;
|
|
|
|
changes |= BIT_PG_TX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[tx].bwg_id != src->path[tx].bwg_id) {
|
|
|
|
dst->path[tx].bwg_id = src->path[tx].bwg_id;
|
|
|
|
changes |= BIT_PG_TX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[tx].bwg_percent != src->path[tx].bwg_percent) {
|
|
|
|
dst->path[tx].bwg_percent = src->path[tx].bwg_percent;
|
|
|
|
changes |= BIT_PG_TX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[tx].up_to_tc_bitmap !=
|
|
|
|
src->path[tx].up_to_tc_bitmap) {
|
|
|
|
dst->path[tx].up_to_tc_bitmap =
|
|
|
|
src->path[tx].up_to_tc_bitmap;
|
|
|
|
changes |= (BIT_PG_TX | BIT_PFC | BIT_APP_UPCHG);
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[rx].prio_type != src->path[rx].prio_type) {
|
|
|
|
dst->path[rx].prio_type = src->path[rx].prio_type;
|
|
|
|
changes |= BIT_PG_RX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[rx].bwg_id != src->path[rx].bwg_id) {
|
|
|
|
dst->path[rx].bwg_id = src->path[rx].bwg_id;
|
|
|
|
changes |= BIT_PG_RX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[rx].bwg_percent != src->path[rx].bwg_percent) {
|
|
|
|
dst->path[rx].bwg_percent = src->path[rx].bwg_percent;
|
|
|
|
changes |= BIT_PG_RX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dst->path[rx].up_to_tc_bitmap !=
|
|
|
|
src->path[rx].up_to_tc_bitmap) {
|
|
|
|
dst->path[rx].up_to_tc_bitmap =
|
|
|
|
src->path[rx].up_to_tc_bitmap;
|
|
|
|
changes |= (BIT_PG_RX | BIT_PFC | BIT_APP_UPCHG);
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
|
2012-03-28 15:49:09 +08:00
|
|
|
j = i - DCB_PG_ATTR_BW_ID_0;
|
|
|
|
if (dcfg->bw_percentage[tx][j] != scfg->bw_percentage[tx][j]) {
|
|
|
|
dcfg->bw_percentage[tx][j] = scfg->bw_percentage[tx][j];
|
|
|
|
changes |= BIT_PG_TX;
|
|
|
|
}
|
|
|
|
if (dcfg->bw_percentage[rx][j] != scfg->bw_percentage[rx][j]) {
|
|
|
|
dcfg->bw_percentage[rx][j] = scfg->bw_percentage[rx][j];
|
|
|
|
changes |= BIT_PG_RX;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
|
2012-03-28 15:49:09 +08:00
|
|
|
j = i - DCB_PFC_UP_ATTR_0;
|
|
|
|
if (dcfg->tc_config[j].dcb_pfc != scfg->tc_config[j].dcb_pfc) {
|
|
|
|
dcfg->tc_config[j].dcb_pfc = scfg->tc_config[j].dcb_pfc;
|
|
|
|
changes |= BIT_PFC;
|
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
if (dcfg->pfc_mode_enable != scfg->pfc_mode_enable) {
|
|
|
|
dcfg->pfc_mode_enable = scfg->pfc_mode_enable;
|
|
|
|
changes |= BIT_PFC;
|
|
|
|
}
|
2009-04-01 05:33:25 +08:00
|
|
|
|
2012-03-28 15:49:09 +08:00
|
|
|
return changes;
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
|
|
|
|
}
|
|
|
|
|
2008-12-22 12:09:50 +08:00
|
|
|
static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2011-08-04 13:47:07 +08:00
|
|
|
/* Fail command if not in CEE mode */
|
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
|
|
|
|
return 1;
|
|
|
|
|
2011-05-20 15:36:17 +08:00
|
|
|
/* verify there is something to do, if not then exit */
|
2012-05-18 14:33:31 +08:00
|
|
|
if (!state == !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
|
2014-07-22 14:51:08 +08:00
|
|
|
return 0;
|
2011-05-20 15:36:17 +08:00
|
|
|
|
2014-07-22 14:51:08 +08:00
|
|
|
return !!ixgbe_setup_tc(netdev,
|
|
|
|
state ? adapter->dcb_cfg.num_tcs.pg_tcs : 0);
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
|
|
|
|
u8 *perm_addr)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
2009-05-17 20:32:48 +08:00
|
|
|
int i, j;
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2009-07-16 21:43:10 +08:00
|
|
|
memset(perm_addr, 0xff, MAX_ADDR_LEN);
|
|
|
|
|
2008-11-21 12:52:10 +08:00
|
|
|
for (i = 0; i < netdev->addr_len; i++)
|
|
|
|
perm_addr[i] = adapter->hw.mac.perm_addr[i];
|
2009-05-17 20:32:48 +08:00
|
|
|
|
2010-11-17 11:27:17 +08:00
|
|
|
switch (adapter->hw.mac.type) {
|
|
|
|
case ixgbe_mac_82599EB:
|
|
|
|
case ixgbe_mac_X540:
|
2014-11-07 11:53:35 +08:00
|
|
|
case ixgbe_mac_X550:
|
2009-05-17 20:32:48 +08:00
|
|
|
for (j = 0; j < netdev->addr_len; j++, i++)
|
|
|
|
perm_addr[i] = adapter->hw.mac.san_addr[j];
|
2010-11-17 11:27:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-05-17 20:32:48 +08:00
|
|
|
}
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 prio, u8 bwg_id, u8 bw_pct,
|
|
|
|
u8 up_map)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
if (prio != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
|
|
|
|
if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
|
|
|
|
if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
|
|
|
|
bw_pct;
|
|
|
|
if (up_map != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
|
|
|
|
up_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 bw_pct)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 prio, u8 bwg_id, u8 bw_pct,
|
|
|
|
u8 up_map)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
if (prio != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
|
|
|
|
if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
|
|
|
|
if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
|
|
|
|
bw_pct;
|
|
|
|
if (up_map != DCB_ATTR_VALUE_UNDEFINED)
|
|
|
|
adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
|
|
|
|
up_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 bw_pct)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 *prio, u8 *bwg_id, u8 *bw_pct,
|
|
|
|
u8 *up_map)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
*prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type;
|
|
|
|
*bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
|
|
|
|
*bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
|
|
|
|
*up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 *bw_pct)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
*bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 *prio, u8 *bwg_id, u8 *bw_pct,
|
|
|
|
u8 *up_map)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
*prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
|
|
|
|
*bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
|
|
|
|
*bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
|
|
|
|
*up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 *bw_pct)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
*bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 setting)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
|
|
|
|
if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
|
2012-03-28 15:49:09 +08:00
|
|
|
adapter->dcb_cfg.tc_config[priority].dcb_pfc)
|
2009-04-01 05:33:25 +08:00
|
|
|
adapter->temp_dcb_cfg.pfc_mode_enable = true;
|
2008-11-21 12:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
|
2014-04-09 14:03:10 +08:00
|
|
|
u8 *setting)
|
2008-11-21 12:52:10 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
*setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
|
|
|
|
}
|
|
|
|
|
2011-11-12 09:12:16 +08:00
|
|
|
static void ixgbe_dcbnl_devreset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
|
|
|
|
while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
|
|
|
|
usleep_range(1000, 2000);
|
|
|
|
|
|
|
|
if (netif_running(dev))
|
|
|
|
dev->netdev_ops->ndo_stop(dev);
|
|
|
|
|
|
|
|
ixgbe_clear_interrupt_scheme(adapter);
|
|
|
|
ixgbe_init_interrupt_scheme(adapter);
|
|
|
|
|
|
|
|
if (netif_running(dev))
|
|
|
|
dev->netdev_ops->ndo_open(dev);
|
|
|
|
|
|
|
|
clear_bit(__IXGBE_RESETTING, &adapter->state);
|
|
|
|
}
|
|
|
|
|
2008-11-21 12:52:10 +08:00
|
|
|
static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
2012-05-10 13:14:44 +08:00
|
|
|
struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg;
|
|
|
|
struct ixgbe_hw *hw = &adapter->hw;
|
2012-03-28 15:49:09 +08:00
|
|
|
int ret = DCB_NO_HW_CHG;
|
|
|
|
int i;
|
2008-11-21 12:52:10 +08:00
|
|
|
|
2011-08-04 13:47:07 +08:00
|
|
|
/* Fail command if not in CEE mode */
|
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
|
2014-07-22 14:51:08 +08:00
|
|
|
return DCB_NO_HW_CHG;
|
2011-08-04 13:47:07 +08:00
|
|
|
|
2012-04-19 06:42:27 +08:00
|
|
|
adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter,
|
2012-03-28 15:49:09 +08:00
|
|
|
MAX_TRAFFIC_CLASS);
|
|
|
|
if (!adapter->dcb_set_bitmap)
|
2014-07-22 14:51:08 +08:00
|
|
|
return DCB_NO_HW_CHG;
|
2010-01-28 00:38:06 +08:00
|
|
|
|
2011-01-22 14:07:05 +08:00
|
|
|
if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
|
|
|
|
u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
|
|
|
|
u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS];
|
2011-02-23 13:58:19 +08:00
|
|
|
/* Priority to TC mapping in CEE case default to 1:1 */
|
2011-09-27 11:51:56 +08:00
|
|
|
u8 prio_tc[MAX_USER_PRIORITY];
|
2011-01-22 14:07:05 +08:00
|
|
|
int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
|
|
|
|
|
2011-07-15 10:31:30 +08:00
|
|
|
#ifdef IXGBE_FCOE
|
2011-01-22 14:07:05 +08:00
|
|
|
if (adapter->netdev->features & NETIF_F_FCOE_MTU)
|
|
|
|
max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
|
|
|
|
#endif
|
|
|
|
|
2012-05-10 13:14:44 +08:00
|
|
|
ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame,
|
|
|
|
DCB_TX_CONFIG);
|
|
|
|
ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame,
|
|
|
|
DCB_RX_CONFIG);
|
2011-01-22 14:07:05 +08:00
|
|
|
|
2012-05-10 13:14:44 +08:00
|
|
|
ixgbe_dcb_unpack_refill(dcb_cfg, DCB_TX_CONFIG, refill);
|
|
|
|
ixgbe_dcb_unpack_max(dcb_cfg, max);
|
|
|
|
ixgbe_dcb_unpack_bwgid(dcb_cfg, DCB_TX_CONFIG, bwg_id);
|
|
|
|
ixgbe_dcb_unpack_prio(dcb_cfg, DCB_TX_CONFIG, prio_type);
|
|
|
|
ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc);
|
2011-01-22 14:07:05 +08:00
|
|
|
|
2012-05-10 13:14:44 +08:00
|
|
|
ixgbe_dcb_hw_ets_config(hw, refill, max, bwg_id,
|
|
|
|
prio_type, prio_tc);
|
2011-09-27 11:51:56 +08:00
|
|
|
|
|
|
|
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
|
|
|
|
netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
|
2012-03-28 15:49:09 +08:00
|
|
|
|
|
|
|
ret = DCB_HW_CHG_RST;
|
2011-09-27 11:51:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (adapter->dcb_set_bitmap & BIT_PFC) {
|
2012-05-10 13:14:44 +08:00
|
|
|
if (dcb_cfg->pfc_mode_enable) {
|
|
|
|
u8 pfc_en;
|
|
|
|
u8 prio_tc[MAX_USER_PRIORITY];
|
|
|
|
|
|
|
|
ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc);
|
|
|
|
ixgbe_dcb_unpack_pfc(dcb_cfg, &pfc_en);
|
|
|
|
ixgbe_dcb_hw_pfc_config(hw, pfc_en, prio_tc);
|
|
|
|
} else {
|
|
|
|
hw->mac.ops.fc_enable(hw);
|
|
|
|
}
|
2012-04-25 12:36:38 +08:00
|
|
|
|
|
|
|
ixgbe_set_rx_drop_en(adapter);
|
|
|
|
|
2012-05-10 13:14:44 +08:00
|
|
|
ret = DCB_HW_CHG;
|
2011-01-22 14:07:05 +08:00
|
|
|
}
|
|
|
|
|
2011-11-12 09:12:16 +08:00
|
|
|
#ifdef IXGBE_FCOE
|
2011-11-12 09:12:22 +08:00
|
|
|
/* Reprogam FCoE hardware offloads when the traffic class
|
|
|
|
* FCoE is using changes. This happens if the APP info
|
|
|
|
* changes or the up2tc mapping is updated.
|
|
|
|
*/
|
2012-04-19 06:42:27 +08:00
|
|
|
if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
|
|
|
|
struct dcb_app app = {
|
|
|
|
.selector = DCB_APP_IDTYPE_ETHTYPE,
|
|
|
|
.protocol = ETH_P_FCOE,
|
|
|
|
};
|
|
|
|
u8 up = dcb_getapp(netdev, &app);
|
|
|
|
|
2011-11-12 09:12:16 +08:00
|
|
|
adapter->fcoe.up = ffs(up) - 1;
|
|
|
|
ixgbe_dcbnl_devreset(netdev);
|
|
|
|
ret = DCB_HW_CHG_RST;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-21 12:52:10 +08:00
|
|
|
adapter->dcb_set_bitmap = 0x00;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-11-21 13:05:08 +08:00
|
|
|
static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
switch (capid) {
|
|
|
|
case DCB_CAP_ATTR_PG:
|
|
|
|
*cap = true;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_PFC:
|
|
|
|
*cap = true;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_UP2TC:
|
|
|
|
*cap = false;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_PG_TCS:
|
|
|
|
*cap = 0x80;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_PFC_TCS:
|
|
|
|
*cap = 0x80;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_GSP:
|
|
|
|
*cap = true;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_BCN:
|
|
|
|
*cap = false;
|
|
|
|
break;
|
|
|
|
case DCB_CAP_ATTR_DCBX:
|
|
|
|
*cap = adapter->dcbx_cap;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*cap = false;
|
|
|
|
break;
|
2008-11-21 13:05:08 +08:00
|
|
|
}
|
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
return 0;
|
2008-11-21 13:05:08 +08:00
|
|
|
}
|
|
|
|
|
2012-02-10 11:19:41 +08:00
|
|
|
static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
|
2008-11-21 13:08:19 +08:00
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
|
|
|
|
switch (tcid) {
|
|
|
|
case DCB_NUMTCS_ATTR_PG:
|
2011-09-27 11:51:56 +08:00
|
|
|
*num = adapter->dcb_cfg.num_tcs.pg_tcs;
|
2008-11-21 13:08:19 +08:00
|
|
|
break;
|
|
|
|
case DCB_NUMTCS_ATTR_PFC:
|
2011-09-27 11:51:56 +08:00
|
|
|
*num = adapter->dcb_cfg.num_tcs.pfc_tcs;
|
2008-11-21 13:08:19 +08:00
|
|
|
break;
|
|
|
|
default:
|
2013-01-04 11:34:42 +08:00
|
|
|
return -EINVAL;
|
2008-11-21 13:08:19 +08:00
|
|
|
}
|
|
|
|
} else {
|
2013-01-04 11:34:42 +08:00
|
|
|
return -EINVAL;
|
2008-11-21 13:08:19 +08:00
|
|
|
}
|
|
|
|
|
2013-01-04 11:34:42 +08:00
|
|
|
return 0;
|
2008-11-21 13:08:19 +08:00
|
|
|
}
|
|
|
|
|
2012-02-10 11:19:41 +08:00
|
|
|
static int ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
|
2008-11-21 13:08:19 +08:00
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-11-21 13:09:23 +08:00
|
|
|
static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2009-05-17 20:35:16 +08:00
|
|
|
return adapter->dcb_cfg.pfc_mode_enable;
|
2008-11-21 13:09:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
|
|
|
|
{
|
2009-05-17 20:35:16 +08:00
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
adapter->temp_dcb_cfg.pfc_mode_enable = state;
|
2008-11-21 13:09:23 +08:00
|
|
|
}
|
|
|
|
|
2009-08-31 20:34:28 +08:00
|
|
|
/**
|
|
|
|
* ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
|
|
|
|
* @netdev : the corresponding netdev
|
|
|
|
* @idtype : identifies the id as ether type or TCP/UDP port number
|
|
|
|
* @id: id is either ether type or TCP/UDP port number
|
|
|
|
*
|
|
|
|
* Returns : on success, returns a non-zero 802.1p user priority bitmap
|
2014-07-17 13:32:39 +08:00
|
|
|
* otherwise returns -EINVAL as the invalid user priority bitmap to indicate an
|
2009-08-31 20:34:28 +08:00
|
|
|
* error.
|
|
|
|
*/
|
2014-07-17 13:32:39 +08:00
|
|
|
static int ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
|
2009-08-31 20:34:28 +08:00
|
|
|
{
|
2011-03-01 13:25:35 +08:00
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
2011-02-23 13:57:52 +08:00
|
|
|
struct dcb_app app = {
|
|
|
|
.selector = idtype,
|
|
|
|
.protocol = id,
|
|
|
|
};
|
2009-08-31 20:34:28 +08:00
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
|
2014-07-17 13:32:39 +08:00
|
|
|
return -EINVAL;
|
2011-03-01 13:25:35 +08:00
|
|
|
|
2011-02-23 13:57:52 +08:00
|
|
|
return dcb_getapp(netdev, &app);
|
2009-08-31 20:34:28 +08:00
|
|
|
}
|
|
|
|
|
2011-02-10 22:40:01 +08:00
|
|
|
static int ixgbe_dcbnl_ieee_getets(struct net_device *dev,
|
|
|
|
struct ieee_ets *ets)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
struct ieee_ets *my_ets = adapter->ixgbe_ieee_ets;
|
|
|
|
|
2011-10-19 16:48:49 +08:00
|
|
|
ets->ets_cap = adapter->dcb_cfg.num_tcs.pg_tcs;
|
|
|
|
|
2011-02-10 22:40:01 +08:00
|
|
|
/* No IEEE PFC settings available */
|
|
|
|
if (!my_ets)
|
2011-10-19 16:48:49 +08:00
|
|
|
return 0;
|
2011-02-10 22:40:01 +08:00
|
|
|
|
|
|
|
ets->cbs = my_ets->cbs;
|
|
|
|
memcpy(ets->tc_tx_bw, my_ets->tc_tx_bw, sizeof(ets->tc_tx_bw));
|
|
|
|
memcpy(ets->tc_rx_bw, my_ets->tc_rx_bw, sizeof(ets->tc_rx_bw));
|
|
|
|
memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
|
|
|
|
memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
|
|
|
|
struct ieee_ets *ets)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
|
2014-07-22 14:51:08 +08:00
|
|
|
int i, err;
|
2011-08-04 13:47:07 +08:00
|
|
|
__u8 max_tc = 0;
|
2012-12-04 11:03:03 +08:00
|
|
|
__u8 map_chg = 0;
|
2011-02-10 22:40:01 +08:00
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-02-10 22:40:01 +08:00
|
|
|
if (!adapter->ixgbe_ieee_ets) {
|
|
|
|
adapter->ixgbe_ieee_ets = kmalloc(sizeof(struct ieee_ets),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!adapter->ixgbe_ieee_ets)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-12-04 11:03:03 +08:00
|
|
|
/* initialize UP2TC mappings to invalid value */
|
|
|
|
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
|
|
|
|
adapter->ixgbe_ieee_ets->prio_tc[i] =
|
|
|
|
IEEE_8021QAZ_MAX_TCS;
|
2013-04-18 12:23:52 +08:00
|
|
|
/* if possible update UP2TC mappings from HW */
|
|
|
|
ixgbe_dcb_read_rtrup2tc(&adapter->hw,
|
|
|
|
adapter->ixgbe_ieee_ets->prio_tc);
|
2012-12-04 11:03:03 +08:00
|
|
|
}
|
2011-02-10 22:40:01 +08:00
|
|
|
|
2011-02-23 13:58:14 +08:00
|
|
|
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
|
2011-08-04 13:47:07 +08:00
|
|
|
if (ets->prio_tc[i] > max_tc)
|
|
|
|
max_tc = ets->prio_tc[i];
|
2012-12-04 11:03:03 +08:00
|
|
|
if (ets->prio_tc[i] != adapter->ixgbe_ieee_ets->prio_tc[i])
|
|
|
|
map_chg = 1;
|
2011-02-23 13:58:14 +08:00
|
|
|
}
|
|
|
|
|
2012-12-04 11:03:03 +08:00
|
|
|
memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
|
|
|
|
|
2011-08-04 13:47:07 +08:00
|
|
|
if (max_tc)
|
|
|
|
max_tc++;
|
2011-02-23 13:58:19 +08:00
|
|
|
|
2011-09-27 11:51:56 +08:00
|
|
|
if (max_tc > adapter->dcb_cfg.num_tcs.pg_tcs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-07-22 14:51:08 +08:00
|
|
|
if (max_tc != netdev_get_num_tc(dev)) {
|
2012-02-10 11:19:35 +08:00
|
|
|
err = ixgbe_setup_tc(dev, max_tc);
|
2014-07-22 14:51:08 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
} else if (map_chg) {
|
2012-12-04 11:03:03 +08:00
|
|
|
ixgbe_dcbnl_devreset(dev);
|
2014-07-22 14:51:08 +08:00
|
|
|
}
|
2012-02-10 11:19:35 +08:00
|
|
|
|
2014-07-22 14:51:08 +08:00
|
|
|
return ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
|
2011-02-10 22:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
|
|
|
|
struct ieee_pfc *pfc)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
struct ieee_pfc *my_pfc = adapter->ixgbe_ieee_pfc;
|
|
|
|
int i;
|
|
|
|
|
2011-10-19 16:48:49 +08:00
|
|
|
pfc->pfc_cap = adapter->dcb_cfg.num_tcs.pfc_tcs;
|
|
|
|
|
2011-02-10 22:40:01 +08:00
|
|
|
/* No IEEE PFC settings available */
|
|
|
|
if (!my_pfc)
|
2011-10-19 16:48:49 +08:00
|
|
|
return 0;
|
2011-02-10 22:40:01 +08:00
|
|
|
|
|
|
|
pfc->pfc_en = my_pfc->pfc_en;
|
|
|
|
pfc->mbc = my_pfc->mbc;
|
|
|
|
pfc->delay = my_pfc->delay;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
|
|
|
|
pfc->requests[i] = adapter->stats.pxoffrxc[i];
|
|
|
|
pfc->indications[i] = adapter->stats.pxofftxc[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,
|
|
|
|
struct ieee_pfc *pfc)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
2012-05-10 13:14:44 +08:00
|
|
|
struct ixgbe_hw *hw = &adapter->hw;
|
2011-09-27 11:51:56 +08:00
|
|
|
u8 *prio_tc;
|
2012-05-10 13:14:44 +08:00
|
|
|
int err;
|
2011-02-10 22:40:01 +08:00
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-02-10 22:40:01 +08:00
|
|
|
if (!adapter->ixgbe_ieee_pfc) {
|
|
|
|
adapter->ixgbe_ieee_pfc = kmalloc(sizeof(struct ieee_pfc),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!adapter->ixgbe_ieee_pfc)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2011-09-27 11:51:56 +08:00
|
|
|
prio_tc = adapter->ixgbe_ieee_ets->prio_tc;
|
2011-02-10 22:40:01 +08:00
|
|
|
memcpy(adapter->ixgbe_ieee_pfc, pfc, sizeof(*adapter->ixgbe_ieee_pfc));
|
2012-05-10 13:14:44 +08:00
|
|
|
|
|
|
|
/* Enable link flow control parameters if PFC is disabled */
|
|
|
|
if (pfc->pfc_en)
|
|
|
|
err = ixgbe_dcb_hw_pfc_config(hw, pfc->pfc_en, prio_tc);
|
|
|
|
else
|
|
|
|
err = hw->mac.ops.fc_enable(hw);
|
|
|
|
|
2012-04-25 12:36:38 +08:00
|
|
|
ixgbe_set_rx_drop_en(adapter);
|
|
|
|
|
2012-05-10 13:14:44 +08:00
|
|
|
return err;
|
2011-02-10 22:40:01 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 13:57:47 +08:00
|
|
|
static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
|
|
|
|
struct dcb_app *app)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
2014-07-22 14:51:08 +08:00
|
|
|
int err;
|
2011-02-23 13:57:47 +08:00
|
|
|
|
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
|
2014-07-22 14:51:08 +08:00
|
|
|
return -EINVAL;
|
2011-02-23 13:57:47 +08:00
|
|
|
|
2011-06-18 15:39:52 +08:00
|
|
|
err = dcb_ieee_setapp(dev, app);
|
2012-10-19 10:34:34 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
2011-02-23 13:57:47 +08:00
|
|
|
|
2011-03-12 11:50:53 +08:00
|
|
|
#ifdef IXGBE_FCOE
|
2012-10-19 10:34:34 +08:00
|
|
|
if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
2011-06-18 15:39:52 +08:00
|
|
|
app->protocol == ETH_P_FCOE) {
|
|
|
|
u8 app_mask = dcb_ieee_getapp_mask(dev, app);
|
|
|
|
|
2016-04-14 07:08:22 +08:00
|
|
|
if (app_mask & BIT(adapter->fcoe.up))
|
2014-07-22 14:51:08 +08:00
|
|
|
return 0;
|
2011-06-18 15:39:52 +08:00
|
|
|
|
|
|
|
adapter->fcoe.up = app->priority;
|
2011-06-18 15:40:04 +08:00
|
|
|
ixgbe_dcbnl_devreset(dev);
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-19 10:34:34 +08:00
|
|
|
|
|
|
|
/* VF devices should use default UP when available */
|
|
|
|
if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
|
|
|
app->protocol == 0) {
|
|
|
|
int vf;
|
|
|
|
|
|
|
|
adapter->default_up = app->priority;
|
|
|
|
|
|
|
|
for (vf = 0; vf < adapter->num_vfs; vf++) {
|
|
|
|
struct vf_data_storage *vfinfo = &adapter->vfinfo[vf];
|
|
|
|
|
|
|
|
if (!vfinfo->pf_qos)
|
|
|
|
ixgbe_set_vmvir(adapter, vfinfo->pf_vlan,
|
|
|
|
app->priority, vf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-18 15:40:04 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,
|
|
|
|
struct dcb_app *app)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
|
|
|
|
return -EINVAL;
|
2011-06-18 15:39:52 +08:00
|
|
|
|
2011-06-18 15:40:04 +08:00
|
|
|
err = dcb_ieee_delapp(dev, app);
|
2011-06-18 15:39:52 +08:00
|
|
|
|
2011-06-18 15:40:04 +08:00
|
|
|
#ifdef IXGBE_FCOE
|
|
|
|
if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
|
|
|
app->protocol == ETH_P_FCOE) {
|
|
|
|
u8 app_mask = dcb_ieee_getapp_mask(dev, app);
|
|
|
|
|
2016-04-14 07:08:22 +08:00
|
|
|
if (app_mask & BIT(adapter->fcoe.up))
|
2014-07-22 14:51:08 +08:00
|
|
|
return 0;
|
2011-06-18 15:39:52 +08:00
|
|
|
|
2011-06-18 15:40:04 +08:00
|
|
|
adapter->fcoe.up = app_mask ?
|
|
|
|
ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC;
|
|
|
|
ixgbe_dcbnl_devreset(dev);
|
2011-06-18 15:39:52 +08:00
|
|
|
}
|
2011-02-23 13:57:47 +08:00
|
|
|
#endif
|
2012-10-19 10:34:34 +08:00
|
|
|
/* IF default priority is being removed clear VF default UP */
|
|
|
|
if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
|
|
|
app->protocol == 0 && adapter->default_up == app->priority) {
|
|
|
|
int vf;
|
|
|
|
long unsigned int app_mask = dcb_ieee_getapp_mask(dev, app);
|
|
|
|
int qos = app_mask ? find_first_bit(&app_mask, 8) : 0;
|
|
|
|
|
|
|
|
adapter->default_up = qos;
|
|
|
|
|
|
|
|
for (vf = 0; vf < adapter->num_vfs; vf++) {
|
|
|
|
struct vf_data_storage *vfinfo = &adapter->vfinfo[vf];
|
|
|
|
|
|
|
|
if (!vfinfo->pf_qos)
|
|
|
|
ixgbe_set_vmvir(adapter, vfinfo->pf_vlan,
|
|
|
|
qos, vf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-18 15:39:52 +08:00
|
|
|
return err;
|
2011-02-23 13:57:47 +08:00
|
|
|
}
|
|
|
|
|
2011-03-01 13:25:35 +08:00
|
|
|
static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
return adapter->dcbx_cap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
|
|
|
|
{
|
|
|
|
struct ixgbe_adapter *adapter = netdev_priv(dev);
|
|
|
|
struct ieee_ets ets = {0};
|
|
|
|
struct ieee_pfc pfc = {0};
|
2012-02-10 11:19:35 +08:00
|
|
|
int err = 0;
|
2011-03-01 13:25:35 +08:00
|
|
|
|
|
|
|
/* no support for LLD_MANAGED modes or CEE+IEEE */
|
|
|
|
if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
|
|
|
|
((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
|
|
|
|
!(mode & DCB_CAP_DCBX_HOST))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (mode == adapter->dcbx_cap)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
adapter->dcbx_cap = mode;
|
|
|
|
|
|
|
|
/* ETS and PFC defaults */
|
|
|
|
ets.ets_cap = 8;
|
|
|
|
pfc.pfc_cap = 8;
|
|
|
|
|
|
|
|
if (mode & DCB_CAP_DCBX_VER_IEEE) {
|
|
|
|
ixgbe_dcbnl_ieee_setets(dev, &ets);
|
|
|
|
ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
|
|
|
|
} else if (mode & DCB_CAP_DCBX_VER_CEE) {
|
2011-11-12 09:12:22 +08:00
|
|
|
u8 mask = BIT_PFC | BIT_PG_TX | BIT_PG_RX | BIT_APP_UPCHG;
|
|
|
|
|
|
|
|
adapter->dcb_set_bitmap |= mask;
|
2011-03-01 13:25:35 +08:00
|
|
|
ixgbe_dcbnl_set_all(dev);
|
|
|
|
} else {
|
|
|
|
/* Drop into single TC mode strict priority as this
|
|
|
|
* indicates CEE and IEEE versions are disabled
|
|
|
|
*/
|
|
|
|
ixgbe_dcbnl_ieee_setets(dev, &ets);
|
|
|
|
ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
|
2012-02-10 11:19:35 +08:00
|
|
|
err = ixgbe_setup_tc(dev, 0);
|
2011-03-01 13:25:35 +08:00
|
|
|
}
|
|
|
|
|
2012-02-10 11:19:35 +08:00
|
|
|
return err ? 1 : 0;
|
2011-03-01 13:25:35 +08:00
|
|
|
}
|
|
|
|
|
2009-10-05 14:01:03 +08:00
|
|
|
const struct dcbnl_rtnl_ops dcbnl_ops = {
|
2011-02-10 22:40:01 +08:00
|
|
|
.ieee_getets = ixgbe_dcbnl_ieee_getets,
|
|
|
|
.ieee_setets = ixgbe_dcbnl_ieee_setets,
|
|
|
|
.ieee_getpfc = ixgbe_dcbnl_ieee_getpfc,
|
|
|
|
.ieee_setpfc = ixgbe_dcbnl_ieee_setpfc,
|
2011-02-23 13:57:47 +08:00
|
|
|
.ieee_setapp = ixgbe_dcbnl_ieee_setapp,
|
2011-06-18 15:40:04 +08:00
|
|
|
.ieee_delapp = ixgbe_dcbnl_ieee_delapp,
|
2008-11-21 12:52:10 +08:00
|
|
|
.getstate = ixgbe_dcbnl_get_state,
|
|
|
|
.setstate = ixgbe_dcbnl_set_state,
|
|
|
|
.getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr,
|
|
|
|
.setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx,
|
|
|
|
.setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
|
|
|
|
.setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx,
|
|
|
|
.setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
|
|
|
|
.getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx,
|
|
|
|
.getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
|
|
|
|
.getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx,
|
|
|
|
.getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
|
|
|
|
.setpfccfg = ixgbe_dcbnl_set_pfc_cfg,
|
|
|
|
.getpfccfg = ixgbe_dcbnl_get_pfc_cfg,
|
2008-11-21 13:05:08 +08:00
|
|
|
.setall = ixgbe_dcbnl_set_all,
|
2008-11-21 13:08:19 +08:00
|
|
|
.getcap = ixgbe_dcbnl_getcap,
|
|
|
|
.getnumtcs = ixgbe_dcbnl_getnumtcs,
|
2008-11-21 13:09:23 +08:00
|
|
|
.setnumtcs = ixgbe_dcbnl_setnumtcs,
|
|
|
|
.getpfcstate = ixgbe_dcbnl_getpfcstate,
|
2008-11-21 13:10:23 +08:00
|
|
|
.setpfcstate = ixgbe_dcbnl_setpfcstate,
|
2009-08-31 20:34:28 +08:00
|
|
|
.getapp = ixgbe_dcbnl_getapp,
|
2011-03-01 13:25:35 +08:00
|
|
|
.getdcbx = ixgbe_dcbnl_getdcbx,
|
|
|
|
.setdcbx = ixgbe_dcbnl_setdcbx,
|
2008-11-21 12:52:10 +08:00
|
|
|
};
|