114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty/* 214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty * QLogic qlcnic NIC Driver 314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty * Copyright (c) 2009-2013 QLogic Corporation 414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty * 514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty * See LICENSE.qlcnic for copyright and licensing details. 614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty */ 714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 8fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#include <linux/types.h> 914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#include "qlcnic.h" 1014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 11fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_NUM_PARAM 3 1248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_LOCAL_IDX 0 1348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_OPER_IDX 1 1448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_PEER_IDX 2 1548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 1648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_GET_MAP(V) (1 << V) 17fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 18fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_FW_VER 0x2 1914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_MAX_TC 0x8 20fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_MAX_APP 0x8 2148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_MAX_PRIO QLC_DCB_MAX_TC 2248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty#define QLC_DCB_MAX_PG QLC_DCB_MAX_TC 2314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 2414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_TSA_SUPPORT(V) (V & 0x1) 2514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_ETS_SUPPORT(V) ((V >> 1) & 0x1) 2614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_VERSION_SUPPORT(V) ((V >> 2) & 0xf) 2714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_MAX_NUM_TC(V) ((V >> 20) & 0xf) 2814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_MAX_NUM_ETS_TC(V) ((V >> 24) & 0xf) 2914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty#define QLC_DCB_MAX_NUM_PFC_TC(V) ((V >> 28) & 0xf) 30fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_TC_PRIO(X, P) ((X >> (P * 3)) & 0x7) 31fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_PGID_PRIO(X, P) ((X >> (P * 8)) & 0xff) 32fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_BWPER_PG(X, P) ((X >> (P * 8)) & 0xff) 33fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_TSA_PG(X, P) ((X >> (P * 8)) & 0xff) 34fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_PFC_PRIO(X, P) (((X >> 24) >> P) & 0x1) 35fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_PROTO_ID_APP(X) ((X >> 8) & 0xffff) 36fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_GET_SELECTOR_APP(X) (X & 0xff) 37fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 38fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_LOCAL_PARAM_FWID 0x3 39fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_OPER_PARAM_FWID 0x1 40fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_DCB_PEER_PARAM_FWID 0x2 41fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 42fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_83XX_DCB_GET_NUMAPP(X) ((X >> 2) & 0xf) 43fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_83XX_DCB_TSA_VALID(X) (X & 0x1) 44fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_83XX_DCB_PFC_VALID(X) ((X >> 1) & 0x1) 45fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_83XX_DCB_GET_PRIOMAP_APP(X) (X >> 24) 46fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 47fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_GET_NUMAPP(X) ((X >> 12) & 0xf) 48fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_TSA_VALID(X) ((X >> 4) & 0x1) 49fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_PFC_VALID(X) ((X >> 5) & 0x1) 50fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_GET_PRIOVAL_APP(X) ((X >> 24) & 0x7) 51fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_GET_PRIOMAP_APP(X) (1 << X) 52fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty#define QLC_82XX_DCB_PRIO_TC_MAP (0x76543210) 5314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 5448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops; 5548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 562d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakrabortystatic void qlcnic_dcb_aen_work(struct work_struct *); 5748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *); 582d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 591de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic inline void __qlcnic_init_dcbnl_ops(struct qlcnic_dcb *); 601de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void __qlcnic_dcb_free(struct qlcnic_dcb *); 611de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int __qlcnic_dcb_attach(struct qlcnic_dcb *); 621de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int __qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *, char *); 631de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void __qlcnic_dcb_get_info(struct qlcnic_dcb *); 641de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty 651de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_dcb *); 661de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8); 671de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_dcb *); 681de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void qlcnic_82xx_dcb_aen_handler(struct qlcnic_dcb *, void *); 691de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty 701de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_dcb *); 711de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8); 721de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_dcb *); 731de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void qlcnic_83xx_dcb_aen_handler(struct qlcnic_dcb *, void *); 7414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 7514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakrabortystruct qlcnic_dcb_capability { 7614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty bool tsa_capability; 7714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty bool ets_capability; 7814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u8 max_num_tc; 7914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u8 max_ets_tc; 8014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u8 max_pfc_tc; 8114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u8 dcb_capability; 8214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty}; 8314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 84fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortystruct qlcnic_dcb_param { 85fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 hdr_prio_pfc_map[2]; 86fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 prio_pg_map[2]; 87fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 pg_bw_map[2]; 88fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 pg_tsa_map[2]; 89fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 app[QLC_DCB_MAX_APP]; 90fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty}; 91fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 92fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortystruct qlcnic_dcb_mbx_params { 93fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty /* 1st local, 2nd operational 3rd remote */ 94fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_dcb_param type[3]; 95fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 prio_tc_map; 96fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty}; 97fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 98fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortystruct qlcnic_82xx_dcb_param_mbx_le { 99fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty __le32 hdr_prio_pfc_map[2]; 100fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty __le32 prio_pg_map[2]; 101fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty __le32 pg_bw_map[2]; 102fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty __le32 pg_tsa_map[2]; 103fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty __le32 app[QLC_DCB_MAX_APP]; 104fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty}; 105fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 10648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyenum qlcnic_dcb_selector { 10748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_SELECTOR_DEF = 0x0, 10848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_SELECTOR_ETHER, 10948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_SELECTOR_TCP, 11048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_SELECTOR_UDP, 11148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 11248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 11348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyenum qlcnic_dcb_prio_type { 11448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PRIO_NONE = 0, 11548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PRIO_GROUP, 11648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PRIO_LINK, 11748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 11848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 11948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyenum qlcnic_dcb_pfc_type { 12048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PFC_DISABLED = 0, 12148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PFC_FULL, 12248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PFC_TX, 12348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty QLC_PFC_RX 12448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 12548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 12648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystruct qlcnic_dcb_prio_cfg { 12748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool valid; 12848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty enum qlcnic_dcb_pfc_type pfc_type; 12948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 13048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 13148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystruct qlcnic_dcb_pg_cfg { 13248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool valid; 13348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 total_bw_percent; /* of Link/ port BW */ 13448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 prio_count; 13548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 tsa_type; 13648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 13748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 13848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystruct qlcnic_dcb_tc_cfg { 13948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool valid; 14048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_prio_cfg prio_cfg[QLC_DCB_MAX_PRIO]; 14148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty enum qlcnic_dcb_prio_type prio_type; /* always prio_link */ 14248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 link_percent; /* % of link bandwidth */ 14348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 bwg_percent; /* % of BWG's bandwidth */ 14448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 up_tc_map; 14548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 pgid; 14648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 14748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 14848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystruct qlcnic_dcb_app { 14948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool valid; 15048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty enum qlcnic_dcb_selector selector; 15148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u16 protocol; 15248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 priority; 15348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 15448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 15548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystruct qlcnic_dcb_cee { 15648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_tc_cfg tc_cfg[QLC_DCB_MAX_TC]; 15748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_pg_cfg pg_cfg[QLC_DCB_MAX_PG]; 15848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_app app[QLC_DCB_MAX_APP]; 15948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool tc_param_valid; 16048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bool pfc_mode_enable; 16148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 16248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 16314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakrabortystruct qlcnic_dcb_cfg { 16448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty /* 0 - local, 1 - operational, 2 - remote */ 16548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee type[QLC_DCB_NUM_PARAM]; 16614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty struct qlcnic_dcb_capability capability; 16714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u32 version; 16814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty}; 16914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 17014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakrabortystatic struct qlcnic_dcb_ops qlcnic_83xx_dcb_ops = { 17148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .init_dcbnl_ops = __qlcnic_init_dcbnl_ops, 17214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .free = __qlcnic_dcb_free, 17314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .attach = __qlcnic_dcb_attach, 17414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .query_hw_capability = __qlcnic_dcb_query_hw_capability, 17514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .get_info = __qlcnic_dcb_get_info, 17614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 17714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .get_hw_capability = qlcnic_83xx_dcb_get_hw_capability, 178fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty .query_cee_param = qlcnic_83xx_dcb_query_cee_param, 179fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty .get_cee_cfg = qlcnic_83xx_dcb_get_cee_cfg, 1801de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty .aen_handler = qlcnic_83xx_dcb_aen_handler, 18114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty}; 18214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 18314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakrabortystatic struct qlcnic_dcb_ops qlcnic_82xx_dcb_ops = { 18448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .init_dcbnl_ops = __qlcnic_init_dcbnl_ops, 18514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .free = __qlcnic_dcb_free, 18614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .attach = __qlcnic_dcb_attach, 18714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .query_hw_capability = __qlcnic_dcb_query_hw_capability, 18814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .get_info = __qlcnic_dcb_get_info, 18914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 19014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty .get_hw_capability = qlcnic_82xx_dcb_get_hw_capability, 191fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty .query_cee_param = qlcnic_82xx_dcb_query_cee_param, 192fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty .get_cee_cfg = qlcnic_82xx_dcb_get_cee_cfg, 1931de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty .aen_handler = qlcnic_82xx_dcb_aen_handler, 19414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty}; 19514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 196fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortystatic u8 qlcnic_dcb_get_num_app(struct qlcnic_adapter *adapter, u32 val) 197fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty{ 198fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (qlcnic_82xx_check(adapter)) 199fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return QLC_82XX_DCB_GET_NUMAPP(val); 200fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty else 201fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return QLC_83XX_DCB_GET_NUMAPP(val); 202fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty} 203fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 20448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic inline u8 qlcnic_dcb_pfc_hdr_valid(struct qlcnic_adapter *adapter, 20548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u32 val) 20648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 20748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (qlcnic_82xx_check(adapter)) 20848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_82XX_DCB_PFC_VALID(val); 20948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty else 21048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_83XX_DCB_PFC_VALID(val); 21148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 21248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 21348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic inline u8 qlcnic_dcb_tsa_hdr_valid(struct qlcnic_adapter *adapter, 21448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u32 val) 21548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 21648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (qlcnic_82xx_check(adapter)) 21748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_82XX_DCB_TSA_VALID(val); 21848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty else 21948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_83XX_DCB_TSA_VALID(val); 22048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 22148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 22248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic inline u8 qlcnic_dcb_get_prio_map_app(struct qlcnic_adapter *adapter, 22348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u32 val) 22448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 22548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (qlcnic_82xx_check(adapter)) 22648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_82XX_DCB_GET_PRIOMAP_APP(val); 22748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty else 22848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return QLC_83XX_DCB_GET_PRIOMAP_APP(val); 22948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 23048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 23148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_prio_count(u8 up_tc_map) 23248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 23348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty int j; 23448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 23548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (j = 0; j < QLC_DCB_MAX_TC; j++) 23648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (up_tc_map & QLC_DCB_GET_MAP(j)) 23748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 23848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 23948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return j; 24048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 24148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 2421de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic inline void __qlcnic_init_dcbnl_ops(struct qlcnic_dcb *dcb) 24348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 2441de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (test_bit(QLCNIC_DCB_STATE, &dcb->state)) 2451de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty dcb->adapter->netdev->dcbnl_ops = &qlcnic_dcbnl_ops; 24648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 24748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 2480996b7dfc3858a497f2de24c233a560e30fe4a14Sucheta Chakrabortystatic void qlcnic_set_dcb_ops(struct qlcnic_adapter *adapter) 24914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 25014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (qlcnic_82xx_check(adapter)) 25114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty adapter->dcb->ops = &qlcnic_82xx_dcb_ops; 25214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty else if (qlcnic_83xx_check(adapter)) 25314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty adapter->dcb->ops = &qlcnic_83xx_dcb_ops; 25414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 25514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 2561de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortyint qlcnic_register_dcb(struct qlcnic_adapter *adapter) 25714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 25814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty struct qlcnic_dcb *dcb; 25914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 2603c44bba1d270cb1620b4fe76786d0968118cb86bSucheta Chakraborty if (qlcnic_sriov_vf_check(adapter)) 2613c44bba1d270cb1620b4fe76786d0968118cb86bSucheta Chakraborty return 0; 2623c44bba1d270cb1620b4fe76786d0968118cb86bSucheta Chakraborty 26314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty dcb = kzalloc(sizeof(struct qlcnic_dcb), GFP_ATOMIC); 26414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (!dcb) 26514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return -ENOMEM; 26614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 26714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty adapter->dcb = dcb; 2682d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty dcb->adapter = adapter; 26914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty qlcnic_set_dcb_ops(adapter); 2701de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty dcb->state = 0; 27114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 27214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return 0; 27314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 27414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 2751de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void __qlcnic_dcb_free(struct qlcnic_dcb *dcb) 27614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 2771de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_adapter *adapter; 27814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 27914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (!dcb) 28014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return; 28114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 2821de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty adapter = dcb->adapter; 2832d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 2841de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty while (test_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) 2852d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty usleep_range(10000, 11000); 2862d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 2872d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty cancel_delayed_work_sync(&dcb->aen_work); 2882d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 2892d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty if (dcb->wq) { 2902d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty destroy_workqueue(dcb->wq); 2912d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty dcb->wq = NULL; 2922d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty } 2932d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 29414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty kfree(dcb->cfg); 29514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty dcb->cfg = NULL; 296fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty kfree(dcb->param); 297fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dcb->param = NULL; 29814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty kfree(dcb); 29914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty adapter->dcb = NULL; 30014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 30114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3021de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void __qlcnic_dcb_get_info(struct qlcnic_dcb *dcb) 30314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 3041de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty qlcnic_dcb_get_hw_capability(dcb); 3051de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty qlcnic_dcb_get_cee_cfg(dcb); 30614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 30714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3081de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int __qlcnic_dcb_attach(struct qlcnic_dcb *dcb) 30914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 310fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty int err = 0; 31114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3122d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty INIT_DELAYED_WORK(&dcb->aen_work, qlcnic_dcb_aen_work); 3132d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 3142d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty dcb->wq = create_singlethread_workqueue("qlcnic-dcb"); 3152d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty if (!dcb->wq) { 3161de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty dev_err(&dcb->adapter->pdev->dev, 3172d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty "DCB workqueue allocation failed. DCB will be disabled\n"); 3182d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty return -1; 3192d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty } 3202d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 32114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty dcb->cfg = kzalloc(sizeof(struct qlcnic_dcb_cfg), GFP_ATOMIC); 3222d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty if (!dcb->cfg) { 3232d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty err = -ENOMEM; 3242d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty goto out_free_wq; 3252d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty } 32614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 327fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dcb->param = kzalloc(sizeof(struct qlcnic_dcb_mbx_params), GFP_ATOMIC); 328fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (!dcb->param) { 329fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty err = -ENOMEM; 330fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty goto out_free_cfg; 331fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty } 332fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 33314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return 0; 334fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortyout_free_cfg: 335fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty kfree(dcb->cfg); 336fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dcb->cfg = NULL; 337fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 3382d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakrabortyout_free_wq: 3392d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty destroy_workqueue(dcb->wq); 3402d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty dcb->wq = NULL; 3412d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 342fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 34314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 34414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3451de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int __qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf) 34614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 3471de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_adapter *adapter = dcb->adapter; 34814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty struct qlcnic_cmd_args cmd; 34914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u32 mbx_out; 35014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty int err; 35114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 35214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_CAP); 35314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (err) 35414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 35514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 35614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty err = qlcnic_issue_cmd(adapter, &cmd); 35714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (err) { 35814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty dev_err(&adapter->pdev->dev, 35914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty "Failed to query DCBX capability, err %d\n", err); 36014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty } else { 36114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty mbx_out = cmd.rsp.arg[1]; 36214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (buf) 36314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty memcpy(buf, &mbx_out, sizeof(u32)); 36414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty } 36514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 36614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty qlcnic_free_mbx_args(&cmd); 36714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 36814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 36914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 37014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3711de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int __qlcnic_dcb_get_capability(struct qlcnic_dcb *dcb, u32 *val) 37214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 3731de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_dcb_capability *cap = &dcb->cfg->capability; 37414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u32 mbx_out; 37514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty int err; 37614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 37714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty memset(cap, 0, sizeof(struct qlcnic_dcb_capability)); 37814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 3791de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = qlcnic_dcb_query_hw_capability(dcb, (char *)val); 38014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (err) 38114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 38214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 38314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty mbx_out = *val; 38414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (QLC_DCB_TSA_SUPPORT(mbx_out)) 38514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->tsa_capability = true; 38614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 38714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (QLC_DCB_ETS_SUPPORT(mbx_out)) 38814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->ets_capability = true; 38914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 39014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->max_num_tc = QLC_DCB_MAX_NUM_TC(mbx_out); 39114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->max_ets_tc = QLC_DCB_MAX_NUM_ETS_TC(mbx_out); 39214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->max_pfc_tc = QLC_DCB_MAX_NUM_PFC_TC(mbx_out); 39314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 39414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (cap->max_num_tc > QLC_DCB_MAX_TC || 39514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->max_ets_tc > cap->max_num_tc || 39614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->max_pfc_tc > cap->max_num_tc) { 3971de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty dev_err(&dcb->adapter->pdev->dev, "Invalid DCB configuration\n"); 39814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return -EINVAL; 39914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty } 40014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 40114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 40214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 40314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 4041de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_dcb *dcb) 40514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 4061de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_dcb_cfg *cfg = dcb->cfg; 40714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty struct qlcnic_dcb_capability *cap; 40814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u32 mbx_out; 40914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty int err; 41014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 4111de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = __qlcnic_dcb_get_capability(dcb, &mbx_out); 41214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (err) 41314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 41414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 41514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap = &cfg->capability; 41614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->dcb_capability = DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_LLD_MANAGED; 41714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 41814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) 4191de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty set_bit(QLCNIC_DCB_STATE, &dcb->state); 42014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 42114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 42214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 42314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 4241de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_dcb *dcb, 425fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty char *buf, u8 type) 426fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty{ 427fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u16 size = sizeof(struct qlcnic_82xx_dcb_param_mbx_le); 4281de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_adapter *adapter = dcb->adapter; 429fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_82xx_dcb_param_mbx_le *prsp_le; 430fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct device *dev = &adapter->pdev->dev; 431fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dma_addr_t cardrsp_phys_addr; 432fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_dcb_param rsp; 433fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_cmd_args cmd; 434fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u64 phys_addr; 435fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty void *addr; 436fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty int err, i; 437fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 438fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty switch (type) { 439fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty case QLC_DCB_LOCAL_PARAM_FWID: 440fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty case QLC_DCB_OPER_PARAM_FWID: 441fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty case QLC_DCB_PEER_PARAM_FWID: 442fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty break; 443fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty default: 444fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dev_err(dev, "Invalid parameter type %d\n", type); 445fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return -EINVAL; 446fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty } 447fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 4481de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty addr = dma_alloc_coherent(dev, size, &cardrsp_phys_addr, GFP_KERNEL); 449fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (addr == NULL) 450fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return -ENOMEM; 451fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 452fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty prsp_le = addr; 453fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 454fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_PARAM); 455fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) 456fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty goto out_free_rsp; 457fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 458fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty phys_addr = cardrsp_phys_addr; 459fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty cmd.req.arg[1] = size | (type << 16); 460fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty cmd.req.arg[2] = MSD(phys_addr); 461fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty cmd.req.arg[3] = LSD(phys_addr); 462fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 463fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty err = qlcnic_issue_cmd(adapter, &cmd); 464fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) { 465fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dev_err(dev, "Failed to query DCBX parameter, err %d\n", err); 466fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty goto out; 467fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty } 468fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 469fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty memset(&rsp, 0, sizeof(struct qlcnic_dcb_param)); 470fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.hdr_prio_pfc_map[0] = le32_to_cpu(prsp_le->hdr_prio_pfc_map[0]); 471fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.hdr_prio_pfc_map[1] = le32_to_cpu(prsp_le->hdr_prio_pfc_map[1]); 472fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.prio_pg_map[0] = le32_to_cpu(prsp_le->prio_pg_map[0]); 473fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.prio_pg_map[1] = le32_to_cpu(prsp_le->prio_pg_map[1]); 474fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.pg_bw_map[0] = le32_to_cpu(prsp_le->pg_bw_map[0]); 475fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.pg_bw_map[1] = le32_to_cpu(prsp_le->pg_bw_map[1]); 476fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.pg_tsa_map[0] = le32_to_cpu(prsp_le->pg_tsa_map[0]); 477fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.pg_tsa_map[1] = le32_to_cpu(prsp_le->pg_tsa_map[1]); 478fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 479fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_APP; i++) 480fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty rsp.app[i] = le32_to_cpu(prsp_le->app[i]); 481fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 482fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (buf) 483fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty memcpy(buf, &rsp, size); 484fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortyout: 485fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty qlcnic_free_mbx_args(&cmd); 486fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 487fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortyout_free_rsp: 4881de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty dma_free_coherent(dev, size, addr, cardrsp_phys_addr); 489fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 490fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 491fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty} 492fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 4931de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_dcb *dcb) 494fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty{ 495fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_dcb_mbx_params *mbx; 496fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty int err; 497fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 4981de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty mbx = dcb->param; 499fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (!mbx) 500fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return 0; 501fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5021de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[0], 503fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty QLC_DCB_LOCAL_PARAM_FWID); 504fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) 505fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 506fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5071de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[1], 508fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty QLC_DCB_OPER_PARAM_FWID); 509fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) 510fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 511fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5121de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[2], 513fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty QLC_DCB_PEER_PARAM_FWID); 514fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) 515fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 516fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 517fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty mbx->prio_tc_map = QLC_82XX_DCB_PRIO_TC_MAP; 518fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5191de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty qlcnic_dcb_data_cee_param_map(dcb->adapter); 52048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 521fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 522fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty} 523fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5242d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakrabortystatic void qlcnic_dcb_aen_work(struct work_struct *work) 5252d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty{ 5262d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty struct qlcnic_dcb *dcb; 5272d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 5282d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty dcb = container_of(work, struct qlcnic_dcb, aen_work.work); 5292d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 5301de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty qlcnic_dcb_get_cee_cfg(dcb); 5311de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty clear_bit(QLCNIC_DCB_AEN_MODE, &dcb->state); 5322d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty} 5332d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 5341de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void qlcnic_82xx_dcb_aen_handler(struct qlcnic_dcb *dcb, void *data) 5352d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty{ 5361de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (test_and_set_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) 5372d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty return; 5382d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 5392d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty queue_delayed_work(dcb->wq, &dcb->aen_work, 0); 5402d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty} 5412d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 5421de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_dcb *dcb) 54314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty{ 5441de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_dcb_capability *cap = &dcb->cfg->capability; 54514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty u32 mbx_out; 54614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty int err; 54714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 5481de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = __qlcnic_dcb_get_capability(dcb, &mbx_out); 54914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (err) 55014d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 55114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 55214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (mbx_out & BIT_2) 55314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->dcb_capability = DCB_CAP_DCBX_VER_CEE; 55414d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (mbx_out & BIT_3) 55514d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->dcb_capability |= DCB_CAP_DCBX_VER_IEEE; 55614d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (cap->dcb_capability) 55714d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty cap->dcb_capability |= DCB_CAP_DCBX_LLD_MANAGED; 55814d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 55914d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) 5601de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty set_bit(QLCNIC_DCB_STATE, &dcb->state); 56114d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty 56214d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty return err; 56314d385b9905920cc0136721316c185c45ee6e26cSucheta Chakraborty} 564fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 5651de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_dcb *dcb, 566fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty char *buf, u8 idx) 567fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty{ 5681de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty struct qlcnic_adapter *adapter = dcb->adapter; 569fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_dcb_mbx_params mbx_out; 570fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty int err, i, j, k, max_app, size; 571fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_dcb_param *each; 572fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty struct qlcnic_cmd_args cmd; 573fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty u32 val; 574fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty char *p; 575fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 576fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty size = 0; 577fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty memset(&mbx_out, 0, sizeof(struct qlcnic_dcb_mbx_params)); 578fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty memset(buf, 0, sizeof(struct qlcnic_dcb_mbx_params)); 579fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 580fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_PARAM); 581fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) 582fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 583fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 584fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty cmd.req.arg[0] |= QLC_DCB_FW_VER << 29; 585fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty err = qlcnic_issue_cmd(adapter, &cmd); 586fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (err) { 587fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty dev_err(&adapter->pdev->dev, 588fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty "Failed to query DCBX param, err %d\n", err); 589fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty goto out; 590fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty } 591fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 592fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty mbx_out.prio_tc_map = cmd.rsp.arg[1]; 593fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty p = memcpy(buf, &mbx_out, sizeof(u32)); 594fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty k = 2; 595fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty p += sizeof(u32); 596fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 597fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty for (j = 0; j < QLC_DCB_NUM_PARAM; j++) { 598fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each = &mbx_out.type[j]; 599fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 600fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->hdr_prio_pfc_map[0] = cmd.rsp.arg[k++]; 601fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->hdr_prio_pfc_map[1] = cmd.rsp.arg[k++]; 602fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->prio_pg_map[0] = cmd.rsp.arg[k++]; 603fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->prio_pg_map[1] = cmd.rsp.arg[k++]; 604fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->pg_bw_map[0] = cmd.rsp.arg[k++]; 605fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->pg_bw_map[1] = cmd.rsp.arg[k++]; 606fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->pg_tsa_map[0] = cmd.rsp.arg[k++]; 607fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->pg_tsa_map[1] = cmd.rsp.arg[k++]; 608fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty val = each->hdr_prio_pfc_map[0]; 609fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 610fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty max_app = qlcnic_dcb_get_num_app(adapter, val); 611fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty for (i = 0; i < max_app; i++) 612fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty each->app[i] = cmd.rsp.arg[i + k]; 613fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 614fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty size = 16 * sizeof(u32); 615fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty memcpy(p, &each->hdr_prio_pfc_map[0], size); 616fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty p += size; 617fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty if (j == 0) 618fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty k = 18; 619fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty else 620fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty k = 34; 621fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty } 622fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakrabortyout: 623fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty qlcnic_free_mbx_args(&cmd); 624fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 625fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty return err; 626fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty} 627fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 6281de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_dcb *dcb) 629fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty{ 63048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty int err; 631fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty 6321de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty err = qlcnic_dcb_query_cee_param(dcb, (char *)dcb->param, 0); 63348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (err) 63448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return err; 63548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 6361de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty qlcnic_dcb_data_cee_param_map(dcb->adapter); 63748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 63848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return err; 639fb859ed6916faeae6b44027d2e0738836a11e8c1Sucheta Chakraborty} 6402d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 6411de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakrabortystatic void qlcnic_83xx_dcb_aen_handler(struct qlcnic_dcb *dcb, void *data) 6422d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty{ 6432d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty u32 *val = data; 6442d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 6451de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (test_and_set_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) 6462d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty return; 6472d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 6482d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty if (*val & BIT_8) 6491de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty set_bit(QLCNIC_DCB_STATE, &dcb->state); 6502d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty else 6511de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty clear_bit(QLCNIC_DCB_STATE, &dcb->state); 6522d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty 6532d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty queue_delayed_work(dcb->wq, &dcb->aen_work, 0); 6542d8ebcab86051f2cd7f207edb513995348b78213Sucheta Chakraborty} 65548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 65648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_fill_cee_tc_params(struct qlcnic_dcb_mbx_params *mbx, 65748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_param *each, 65848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type) 65948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 66048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_tc_cfg *tc_cfg; 66148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, tc, pgid; 66248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 66348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_PRIO; i++) { 66448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc = QLC_DCB_GET_TC_PRIO(mbx->prio_tc_map, i); 66548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg = &type->tc_cfg[tc]; 66648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->valid = true; 66748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->up_tc_map |= QLC_DCB_GET_MAP(i); 66848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 66948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (QLC_DCB_GET_PFC_PRIO(each->hdr_prio_pfc_map[1], i) && 67048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->pfc_mode_enable) { 67148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->prio_cfg[i].valid = true; 67248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->prio_cfg[i].pfc_type = QLC_PFC_FULL; 67348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 67448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 67548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (i < 4) 67648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pgid = QLC_DCB_GET_PGID_PRIO(each->prio_pg_map[0], i); 67748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty else 67848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pgid = QLC_DCB_GET_PGID_PRIO(each->prio_pg_map[1], i); 67948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 68048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->pgid = pgid; 68148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 68248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->prio_type = QLC_PRIO_LINK; 68348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->pg_cfg[tc_cfg->pgid].prio_count++; 68448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 68548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 68648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 68748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_fill_cee_pg_params(struct qlcnic_dcb_param *each, 68848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type) 68948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 69048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_pg_cfg *pg_cfg; 69148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, tsa, bw_per; 69248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 69348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_PG; i++) { 69448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg_cfg = &type->pg_cfg[i]; 69548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg_cfg->valid = true; 69648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 69748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (i < 4) { 69848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bw_per = QLC_DCB_GET_BWPER_PG(each->pg_bw_map[0], i); 69948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tsa = QLC_DCB_GET_TSA_PG(each->pg_tsa_map[0], i); 70048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } else { 70148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty bw_per = QLC_DCB_GET_BWPER_PG(each->pg_bw_map[1], i); 70248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tsa = QLC_DCB_GET_TSA_PG(each->pg_tsa_map[1], i); 70348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 70448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 70548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg_cfg->total_bw_percent = bw_per; 70648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg_cfg->tsa_type = tsa; 70748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 70848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 70948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 71048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void 71148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyqlcnic_dcb_fill_cee_app_params(struct qlcnic_adapter *adapter, u8 idx, 71248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_param *each, 71348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type) 71448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 71548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_app *app; 71648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, num_app, map, cnt; 71748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct dcb_app new_app; 71848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 71948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty num_app = qlcnic_dcb_get_num_app(adapter, each->hdr_prio_pfc_map[0]); 72048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < num_app; i++) { 72148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app = &type->app[i]; 72248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app->valid = true; 72348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 72448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty /* Only for CEE (-1) */ 72548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app->selector = QLC_DCB_GET_SELECTOR_APP(each->app[i]) - 1; 72648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty new_app.selector = app->selector; 72748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app->protocol = QLC_DCB_GET_PROTO_ID_APP(each->app[i]); 72848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty new_app.protocol = app->protocol; 72948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty map = qlcnic_dcb_get_prio_map_app(adapter, each->app[i]); 73048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty cnt = qlcnic_dcb_prio_count(map); 73148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 73248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (cnt >= QLC_DCB_MAX_TC) 73348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty cnt = 0; 73448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 73548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app->priority = cnt; 73648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty new_app.priority = cnt; 73748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 73848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (idx == QLC_DCB_OPER_IDX && adapter->netdev->dcbnl_ops) 73948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty dcb_setapp(adapter->netdev, &new_app); 74048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 74148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 74248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 74348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_map_cee_params(struct qlcnic_adapter *adapter, u8 idx) 74448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 74548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_mbx_params *mbx = adapter->dcb->param; 74648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_param *each = &mbx->type[idx]; 74748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; 74848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type = &cfg->type[idx]; 74948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 75048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->tc_param_valid = false; 75148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->pfc_mode_enable = false; 75248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty memset(type->tc_cfg, 0, 75348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty sizeof(struct qlcnic_dcb_tc_cfg) * QLC_DCB_MAX_TC); 75448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty memset(type->pg_cfg, 0, 75548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty sizeof(struct qlcnic_dcb_pg_cfg) * QLC_DCB_MAX_TC); 75648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 75748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (qlcnic_dcb_pfc_hdr_valid(adapter, each->hdr_prio_pfc_map[0]) && 75848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty cfg->capability.max_pfc_tc) 75948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->pfc_mode_enable = true; 76048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 76148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (qlcnic_dcb_tsa_hdr_valid(adapter, each->hdr_prio_pfc_map[0]) && 76248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty cfg->capability.max_ets_tc) 76348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type->tc_param_valid = true; 76448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 76548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty qlcnic_dcb_fill_cee_tc_params(mbx, each, type); 76648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty qlcnic_dcb_fill_cee_pg_params(each, type); 76748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty qlcnic_dcb_fill_cee_app_params(adapter, idx, each, type); 76848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 76948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 77048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *adapter) 77148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 77248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty int i; 77348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 77448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_NUM_PARAM; i++) 77548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty qlcnic_dcb_map_cee_params(adapter, i); 77648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 77748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty dcbnl_cee_notify(adapter->netdev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0); 77848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 77948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 78048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic u8 qlcnic_dcb_get_state(struct net_device *netdev) 78148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 78248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 78348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 7841de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty return test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state); 78548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 78648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 78748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_get_perm_hw_addr(struct net_device *netdev, u8 *addr) 78848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 7891de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty memcpy(addr, netdev->perm_addr, netdev->addr_len); 79048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 79148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 79248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void 79348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyqlcnic_dcb_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 *prio, 79448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 *pgid, u8 *bw_per, u8 *up_tc_map) 79548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 79648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 79748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_tc_cfg *tc_cfg, *temp; 79848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type; 79948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, cnt, pg; 80048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 80148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; 80248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *prio = *pgid = *bw_per = *up_tc_map = 0; 80348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 8041de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || 80548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty !type->tc_param_valid) 80648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 80748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 808e842b068bf9a9eb7b38e0e1875357440a1fd2169Dan Carpenter if (tc < 0 || (tc >= QLC_DCB_MAX_TC)) 80948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 81048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 81148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg = &type->tc_cfg[tc]; 81248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (!tc_cfg->valid) 81348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 81448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 81548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *pgid = tc_cfg->pgid; 81648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *prio = tc_cfg->prio_type; 81748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *up_tc_map = tc_cfg->up_tc_map; 81848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg = *pgid; 81948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 82048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0, cnt = 0; i < QLC_DCB_MAX_TC; i++) { 82148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty temp = &type->tc_cfg[i]; 82248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (temp->valid && (pg == temp->pgid)) 82348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty cnt++; 82448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 82548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 82648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg->bwg_percent = (100 / cnt); 82748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *bw_per = tc_cfg->bwg_percent; 82848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 82948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 83048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_get_pg_bwg_cfg_tx(struct net_device *netdev, int pgid, 83148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 *bw_pct) 83248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 83348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 83448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_pg_cfg *pgcfg; 83548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type; 83648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 83748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *bw_pct = 0; 83848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; 83948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 8401de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || 84148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty !type->tc_param_valid) 84248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 84348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 844e842b068bf9a9eb7b38e0e1875357440a1fd2169Dan Carpenter if (pgid < 0 || pgid >= QLC_DCB_MAX_PG) 84548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 84648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 84748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pgcfg = &type->pg_cfg[pgid]; 84848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (!pgcfg->valid) 84948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 85048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 85148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *bw_pct = pgcfg->total_bw_percent; 85248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 85348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 85448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic void qlcnic_dcb_get_pfc_cfg(struct net_device *netdev, int prio, 85548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 *setting) 85648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 85748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 85848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_tc_cfg *tc_cfg; 85948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 val = QLC_DCB_GET_MAP(prio); 86048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type; 86148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i; 86248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 86348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *setting = 0; 86448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; 86548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 8661de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || 86748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty !type->pfc_mode_enable) 86848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return; 86948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 87048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_TC; i++) { 87148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc_cfg = &type->tc_cfg[i]; 87248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (!tc_cfg->valid) 87348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty continue; 87448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 87548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if ((val & tc_cfg->up_tc_map) && (tc_cfg->prio_cfg[prio].valid)) 87648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *setting = tc_cfg->prio_cfg[prio].pfc_type; 87748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 87848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 87948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 88048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic u8 qlcnic_dcb_get_capability(struct net_device *netdev, int capid, 88148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 *cap) 88248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 88348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 88448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 8851de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 88648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 88748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 88848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty switch (capid) { 88948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_PG: 89048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_UP2TC: 89148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_PFC: 89248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_GSP: 89348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *cap = true; 89448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 89548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_PG_TCS: 89648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_PFC_TCS: 89748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *cap = 0x80; /* 8 priorities for PGs */ 89848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 89948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_CAP_ATTR_DCBX: 90048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *cap = adapter->dcb->cfg->capability.dcb_capability; 90148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 90248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty default: 90348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *cap = false; 90448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 90548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 90648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 90748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 90848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 90948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_get_num_tcs(struct net_device *netdev, int attr, u8 *num) 91048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 91148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 91248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; 91348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 9141de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 91548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return -EINVAL; 91648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 91748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty switch (attr) { 91848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_NUMTCS_ATTR_PG: 91948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *num = cfg->capability.max_ets_tc; 92048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 92148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_NUMTCS_ATTR_PFC: 92248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *num = cfg->capability.max_pfc_tc; 92348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 92448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty default: 92548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return -EINVAL; 92648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 92748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 92848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 929c2659479f7865fb538493089bce3dd3d2abf90b0Anish Bhattstatic int qlcnic_dcb_get_app(struct net_device *netdev, u8 idtype, u16 id) 93048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 93148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 93248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct dcb_app app = { 93348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .selector = idtype, 93448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .protocol = id, 93548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty }; 93648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 9371de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 938c2659479f7865fb538493089bce3dd3d2abf90b0Anish Bhatt return -EINVAL; 93948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 94048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return dcb_getapp(netdev, &app); 94148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 94248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 94348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic u8 qlcnic_dcb_get_pfc_state(struct net_device *netdev) 94448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 94548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 94648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb *dcb = adapter->dcb; 94748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 9481de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &dcb->state)) 94948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 95048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 95148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return dcb->cfg->type[QLC_DCB_OPER_IDX].pfc_mode_enable; 95248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 95348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 95448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic u8 qlcnic_dcb_get_dcbx(struct net_device *netdev) 95548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 95648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 95748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; 95848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 9591de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 96048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 96148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 96248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return cfg->capability.dcb_capability; 96348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 96448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 96548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic u8 qlcnic_dcb_get_feat_cfg(struct net_device *netdev, int fid, u8 *flag) 96648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 96748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 96848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *type; 96948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 9701de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 97148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 1; 97248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 97348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; 97448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag = 0; 97548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 97648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty switch (fid) { 97748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_FEATCFG_ATTR_PG: 97848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (type->tc_param_valid) 97948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag |= DCB_FEATCFG_ENABLE; 98048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty else 98148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag |= DCB_FEATCFG_ERROR; 98248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 98348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_FEATCFG_ATTR_PFC: 98448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (type->pfc_mode_enable) { 98548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (type->tc_cfg[0].prio_cfg[0].pfc_type) 98648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag |= DCB_FEATCFG_ENABLE; 98748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } else { 98848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag |= DCB_FEATCFG_ERROR; 98948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 99048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 99148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty case DCB_FEATCFG_ATTR_APP: 99248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *flag |= DCB_FEATCFG_ENABLE; 99348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 99448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty default: 99548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty netdev_err(netdev, "Invalid Feature ID %d\n", fid); 99648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 1; 99748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 99848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 99948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 100048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 100148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 100248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic inline void 100348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyqlcnic_dcb_get_pg_tc_cfg_rx(struct net_device *netdev, int prio, u8 *prio_type, 100448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 *pgid, u8 *bw_pct, u8 *up_map) 100548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 100648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *prio_type = *pgid = *bw_pct = *up_map = 0; 100748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 100848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 100948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic inline void 101048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortyqlcnic_dcb_get_pg_bwg_cfg_rx(struct net_device *netdev, int pgid, u8 *bw_pct) 101148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 101248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *bw_pct = 0; 101348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 101448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 101548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_peer_app_info(struct net_device *netdev, 101648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct dcb_peer_app_info *info, 101748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u16 *app_count) 101848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 101948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 102048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *peer; 102148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty int i; 102248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 10237df566bbdd0af0785542b89466a937e94257fcfbDan Carpenter memset(info, 0, sizeof(*info)); 102448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty *app_count = 0; 102548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 10261de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 102748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 102848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 102948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; 103048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 103148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_APP; i++) { 103248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (peer->app[i].valid) 103348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty (*app_count)++; 103448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 103548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 103648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 103748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 103848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 103948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_peer_app_table(struct net_device *netdev, 104048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct dcb_app *table) 104148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 104248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 104348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *peer; 104448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_app *app; 104548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty int i, j; 104648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 10471de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 104848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 104948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 105048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; 105148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 105248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0, j = 0; i < QLC_DCB_MAX_APP; i++) { 105348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty app = &peer->app[i]; 105448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (!app->valid) 105548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty continue; 105648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 105748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty table[j].selector = app->selector; 105848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty table[j].priority = app->priority; 105948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty table[j++].protocol = app->protocol; 106048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 106148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 106248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 106348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 106448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 106548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_cee_peer_get_pg(struct net_device *netdev, 106648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct cee_pg *pg) 106748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 106848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 106948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *peer; 107048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, j, k, map; 107148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 10721de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 107348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 107448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 107548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; 107648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 107748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0, j = 0; i < QLC_DCB_MAX_PG; i++) { 107848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (!peer->pg_cfg[i].valid) 107948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty continue; 108048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 108148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg->pg_bw[j] = peer->pg_cfg[i].total_bw_percent; 108248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 108348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (k = 0; k < QLC_DCB_MAX_TC; k++) { 108448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (peer->tc_cfg[i].valid && 108548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty (peer->tc_cfg[i].pgid == i)) { 108648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty map = peer->tc_cfg[i].up_tc_map; 108748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pg->prio_pg[j++] = map; 108848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty break; 108948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 109048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 109148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 109248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 109348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 109448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 109548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 109648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic int qlcnic_dcb_cee_peer_get_pfc(struct net_device *netdev, 109748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct cee_pfc *pfc) 109848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty{ 109948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_adapter *adapter = netdev_priv(netdev); 110048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; 110148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_tc_cfg *tc; 110248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty struct qlcnic_dcb_cee *peer; 110348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty u8 i, setting, prio; 110448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 110548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pfc->pfc_en = 0; 110648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 11071de899d3815fd945b0c2285a4e07fea8eaedf2aaSucheta Chakraborty if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) 110848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 110948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 111048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty peer = &cfg->type[QLC_DCB_PEER_IDX]; 111148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 111248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty for (i = 0; i < QLC_DCB_MAX_TC; i++) { 111348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty tc = &peer->tc_cfg[i]; 111448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty prio = qlcnic_dcb_prio_count(tc->up_tc_map); 111548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 111648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty setting = 0; 111748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty qlcnic_dcb_get_pfc_cfg(netdev, prio, &setting); 111848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty if (setting) 111948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pfc->pfc_en |= QLC_DCB_GET_MAP(i); 112048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty } 112148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 112248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty pfc->tcs_supported = cfg->capability.max_pfc_tc; 112348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 112448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty return 0; 112548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty} 112648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 112748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakrabortystatic const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops = { 112848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getstate = qlcnic_dcb_get_state, 112948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpermhwaddr = qlcnic_dcb_get_perm_hw_addr, 113048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpgtccfgtx = qlcnic_dcb_get_pg_tc_cfg_tx, 113148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpgbwgcfgtx = qlcnic_dcb_get_pg_bwg_cfg_tx, 113248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpfccfg = qlcnic_dcb_get_pfc_cfg, 113348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getcap = qlcnic_dcb_get_capability, 113448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getnumtcs = qlcnic_dcb_get_num_tcs, 113548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getapp = qlcnic_dcb_get_app, 113648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpfcstate = qlcnic_dcb_get_pfc_state, 113748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getdcbx = qlcnic_dcb_get_dcbx, 113848365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getfeatcfg = qlcnic_dcb_get_feat_cfg, 113948365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 114048365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpgtccfgrx = qlcnic_dcb_get_pg_tc_cfg_rx, 114148365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .getpgbwgcfgrx = qlcnic_dcb_get_pg_bwg_cfg_rx, 114248365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty 114348365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .peer_getappinfo = qlcnic_dcb_peer_app_info, 114448365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .peer_getapptable = qlcnic_dcb_peer_app_table, 114548365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .cee_peer_getpg = qlcnic_dcb_cee_peer_get_pg, 114648365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty .cee_peer_getpfc = qlcnic_dcb_cee_peer_get_pfc, 114748365e4852759c4a3710490b0d647aac1321e8c9Sucheta Chakraborty}; 1148