/*
* Copyright (C) 2013-2014 Chelsio Communications. All rights reserved.
*
* Written by Anish Bhatt (anish@chelsio.com)
* Casey Leedom (leedom@chelsio.com)
*
* 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.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
*/
#include "cxgb4.h"
/* DCBx version control
*/
static const char * const dcb_ver_array[] = {
"Unknown",
"DCBx-CIN",
"DCBx-CEE 1.01",
"DCBx-IEEE",
"", "", "",
"Auto Negotiated"
};
static inline bool cxgb4_dcb_state_synced(enum cxgb4_dcb_state state)
{
if (state == CXGB4_DCB_STATE_FW_ALLSYNCED ||
state == CXGB4_DCB_STATE_HOST)
return true;
else
return false;
}
/* Initialize a port's Data Center Bridging state. Typically used after a
* Link Down event.
*/
void cxgb4_dcb_state_init(struct net_device *dev)
{
struct port_info *pi = netdev2pinfo(dev);
struct port_dcb_info *dcb = &pi->dcb;
int version_temp = dcb->dcb_version;
memset(dcb, 0, sizeof(struct port_dcb_info));
dcb->state = CXGB4_DCB_STATE_START;
if (version_temp)
dcb->dcb_version = version_temp;
netdev_dbg(dev, "%s: Initializing DCB state for port[%d]\n",
__func__, pi->port_id);
}
void cxgb4_dcb_version_init(struct net_device *dev)
{
struct port_info *pi = netdev2pinfo(dev);
struct port_dcb_info *dcb = &pi->dcb;
/* Any writes here are only done on kernels that exlicitly need
* a specific version, say < 2.6.38 which only support CEE
*/
dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
}
static void cxgb4_dcb_cleanup_apps(struct net_device *dev)
{
struct port_info *pi = netdev2pinfo(dev);
struct adapter *adap = pi->adapter;
struct port_dcb_info *dcb = &pi->dcb;
struct dcb_app app;
int i, err;
/* zero priority implies remove */
app.priority = 0;
for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) {
/* Check if app list is exhausted */
if (!dcb->app_priority[i].protocolid)
break;
app.protocol = dcb->app_priority[i].protocolid;
if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
app.priority = dcb->app_priority[