/*
* QLogic qlcnic NIC Driver
* Copyright (c) 2009-2013 QLogic Corporation
*
* See LICENSE.qlcnic for copyright and licensing details.
*/
#include <linux/types.h>
#include "qlcnic.h"
#define QLC_DCB_NUM_PARAM 3
#define QLC_DCB_LOCAL_IDX 0
#define QLC_DCB_OPER_IDX 1
#define QLC_DCB_PEER_IDX 2
#define QLC_DCB_GET_MAP(V) (1 << V)
#define QLC_DCB_AEN_BIT 0x2
#define QLC_DCB_FW_VER 0x2
#define QLC_DCB_MAX_TC 0x8
#define QLC_DCB_MAX_APP 0x8
#define QLC_DCB_MAX_PRIO QLC_DCB_MAX_TC
#define QLC_DCB_MAX_PG QLC_DCB_MAX_TC
#define QLC_DCB_TSA_SUPPORT(V) (V & 0x1)
#define QLC_DCB_ETS_SUPPORT(V) ((V >> 1) & 0x1)
#define QLC_DCB_VERSION_SUPPORT(V) ((V >> 2) & 0xf)
#define QLC_DCB_MAX_NUM_TC(V) ((V >> 20) & 0xf)
#define QLC_DCB_MAX_NUM_ETS_TC(V) ((V >> 24) & 0xf)
#define QLC_DCB_MAX_NUM_PFC_TC(V) ((V >> 28) & 0xf)
#define QLC_DCB_GET_TC_PRIO(X, P) ((X >> (P * 3)) & 0x7)
#define QLC_DCB_GET_PGID_PRIO(X, P) ((X >> (P * 8)) & 0xff)
#define QLC_DCB_GET_BWPER_PG(X, P) ((X >> (P * 8)) & 0xff)
#define QLC_DCB_GET_TSA_PG(X, P) ((X >> (P * 8)) & 0xff)
#define QLC_DCB_GET_PFC_PRIO(X, P) (((X >> 24) >> P) & 0x1)
#define QLC_DCB_GET_PROTO_ID_APP(X) ((X >> 8) & 0xffff)
#define QLC_DCB_GET_SELECTOR_APP(X) (X & 0xff)
#define QLC_DCB_LOCAL_PARAM_FWID 0x3
#define QLC_DCB_OPER_PARAM_FWID 0x1
#define QLC_DCB_PEER_PARAM_FWID 0x2
#define QLC_83XX_DCB_GET_NUMAPP(X) ((X >> 2) & 0xf)
#define QLC_83XX_DCB_TSA_VALID(X) (X & 0x1)
#define QLC_83XX_DCB_PFC_VALID(X) ((X >> 1) & 0x1)
#define QLC_83XX_DCB_GET_PRIOMAP_APP(X) (X >> 24)
#define QLC_82XX_DCB_GET_NUMAPP(X) ((X >> 12) & 0xf)
#define QLC_82XX_DCB_TSA_VALID(X) ((X >> 4) & 0x1)
#define QLC_82XX_DCB_PFC_VALID(X) ((X >> 5) & 0x1)
#define QLC_82XX_DCB_GET_PRIOVAL_APP(X) ((X >> 24) & 0x7)
#define QLC_82XX_DCB_GET_PRIOMAP_APP(X) (1 << X)
#define QLC_82XX_DCB_PRIO_TC_MAP (0x76543210)
static const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops;
static void qlcnic_dcb_aen_work(struct work_struct *);
static void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *);
static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_dcb *);
static void __qlcnic_dcb_free(struct qlcnic_dcb *);
static int __qlcnic_dcb_attach(struct qlcnic_dcb *);
static int __qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *, char *);
static void __qlcnic_dcb_get_info(struct qlcnic_dcb *);
static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_dcb *);
static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8);
static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_dcb *);
static void qlcnic_82xx_dcb_aen_handler(struct qlcnic_dcb *, void *);
static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_dcb *);
static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8);
static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_dcb *);
static int qlcnic_83xx_dcb_register_aen(struct qlcnic_dcb *, bool);
static void qlcnic_83xx_dcb_aen_handler(struct qlcnic_dcb *, void *);
struct qlcnic_dcb_capability {
bool tsa_capability;
bool ets_capability;
u8 max_num_tc;
u8 max_ets_tc;
u8 max_pfc_tc;
u8 dcb_capability;
};
struct qlcnic_dcb_param {
u32 hdr_prio_pfc_map[2];
u32 prio_pg_map[2];
u32 pg_bw_map[2];
u32 pg_tsa_map[2];
u32 app[QLC_DCB_MAX_APP];
};
struct qlcnic_dcb_mbx_params {
/* 1st local, 2nd operational 3rd remote */
struct qlcnic_dcb_param type[3];
u32 prio_tc_map;
};
struct qlcnic_82xx_dcb_param_mbx_le {
__le32 hdr_prio_pfc_map[2];
__le32 prio_pg_map[2];
__le32 pg_bw_map[2];
__le32 pg_tsa_map[2];
__le32 app[QLC_DCB_MAX_APP];
};
enum qlcnic_dcb_selector {
QLC_SELECTOR_DEF = 0x0,
QLC_SELECTOR_ETHER,
QLC_SELECTOR_TCP,
QLC_SELECTOR_UDP,
};
enum qlcnic_dcb_prio_type {
QLC_PRIO_NONE = 0,
QLC_PRIO_GROUP,
QLC_PRIO_LINK,
};
enum qlcnic_dcb_pfc_type {
QLC_PFC_DISABLED = 0,
QLC_PFC_FULL,
QLC_PFC_TX,
QLC_PFC_RX
};
struct qlcnic_dcb_prio_cfg {
bool valid;
enum qlcnic_dcb_pfc_type pfc_type;
};
struct qlcnic_dcb_pg_cfg {