0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __CXGB4_DCB_H
0009 #define __CXGB4_DCB_H
0010
0011 #include <linux/netdevice.h>
0012 #include <linux/dcbnl.h>
0013 #include <net/dcbnl.h>
0014
0015 #ifdef CONFIG_CHELSIO_T4_DCB
0016
0017 #define CXGB4_DCBX_FW_SUPPORT \
0018 (DCB_CAP_DCBX_VER_CEE | \
0019 DCB_CAP_DCBX_VER_IEEE | \
0020 DCB_CAP_DCBX_LLD_MANAGED)
0021 #define CXGB4_DCBX_HOST_SUPPORT \
0022 (DCB_CAP_DCBX_VER_CEE | \
0023 DCB_CAP_DCBX_VER_IEEE | \
0024 DCB_CAP_DCBX_HOST)
0025
0026 #define CXGB4_MAX_PRIORITY CXGB4_MAX_DCBX_APP_SUPPORTED
0027 #define CXGB4_MAX_TCS CXGB4_MAX_DCBX_APP_SUPPORTED
0028
0029 #define INIT_PORT_DCB_CMD(__pcmd, __port, __op, __action) \
0030 do { \
0031 memset(&(__pcmd), 0, sizeof(__pcmd)); \
0032 (__pcmd).op_to_portid = \
0033 cpu_to_be32(FW_CMD_OP_V(FW_PORT_CMD) | \
0034 FW_CMD_REQUEST_F | \
0035 FW_CMD_##__op##_F | \
0036 FW_PORT_CMD_PORTID_V(__port)); \
0037 (__pcmd).action_to_len16 = \
0038 cpu_to_be32(FW_PORT_CMD_ACTION_V(__action) | \
0039 FW_LEN16(pcmd)); \
0040 } while (0)
0041
0042 #define INIT_PORT_DCB_READ_PEER_CMD(__pcmd, __port) \
0043 INIT_PORT_DCB_CMD(__pcmd, __port, READ, FW_PORT_ACTION_DCB_READ_RECV)
0044
0045 #define INIT_PORT_DCB_READ_LOCAL_CMD(__pcmd, __port) \
0046 INIT_PORT_DCB_CMD(__pcmd, __port, READ, FW_PORT_ACTION_DCB_READ_TRANS)
0047
0048 #define INIT_PORT_DCB_READ_SYNC_CMD(__pcmd, __port) \
0049 INIT_PORT_DCB_CMD(__pcmd, __port, READ, FW_PORT_ACTION_DCB_READ_DET)
0050
0051 #define INIT_PORT_DCB_WRITE_CMD(__pcmd, __port) \
0052 INIT_PORT_DCB_CMD(__pcmd, __port, EXEC, FW_PORT_ACTION_L2_DCB_CFG)
0053
0054 #define IEEE_FAUX_SYNC(__dev, __dcb) \
0055 do { \
0056 if ((__dcb)->dcb_version == FW_PORT_DCB_VER_IEEE) \
0057 cxgb4_dcb_state_fsm((__dev), \
0058 CXGB4_DCB_INPUT_FW_ALLSYNCED); \
0059 } while (0)
0060
0061
0062
0063 enum cxgb4_dcb_state {
0064 CXGB4_DCB_STATE_START,
0065 CXGB4_DCB_STATE_HOST,
0066 CXGB4_DCB_STATE_FW_INCOMPLETE,
0067 CXGB4_DCB_STATE_FW_ALLSYNCED,
0068 };
0069
0070
0071
0072 enum cxgb4_dcb_state_input {
0073
0074
0075 CXGB4_DCB_INPUT_FW_DISABLED,
0076 CXGB4_DCB_INPUT_FW_ENABLED,
0077 CXGB4_DCB_INPUT_FW_INCOMPLETE,
0078 CXGB4_DCB_INPUT_FW_ALLSYNCED,
0079
0080 };
0081
0082
0083
0084 enum cxgb4_dcb_fw_msgs {
0085 CXGB4_DCB_FW_PGID = 0x01,
0086 CXGB4_DCB_FW_PGRATE = 0x02,
0087 CXGB4_DCB_FW_PRIORATE = 0x04,
0088 CXGB4_DCB_FW_PFC = 0x08,
0089 CXGB4_DCB_FW_APP_ID = 0x10,
0090 };
0091
0092 #define CXGB4_MAX_DCBX_APP_SUPPORTED 8
0093
0094
0095
0096 struct port_dcb_info {
0097 enum cxgb4_dcb_state state;
0098 enum cxgb4_dcb_fw_msgs msgs;
0099 unsigned int supported;
0100 bool enabled;
0101
0102
0103
0104
0105 u32 pgid;
0106 u8 dcb_version;
0107 u8 pfcen;
0108 u8 pg_num_tcs_supported;
0109 u8 pfc_num_tcs_supported;
0110 u8 pgrate[8];
0111 u8 priorate[8];
0112 u8 tsa[8];
0113 struct app_priority {
0114 u8 user_prio_map;
0115 u8 sel_field;
0116 u16 protocolid;
0117 } app_priority[CXGB4_MAX_DCBX_APP_SUPPORTED];
0118 };
0119
0120 void cxgb4_dcb_state_init(struct net_device *);
0121 void cxgb4_dcb_version_init(struct net_device *);
0122 void cxgb4_dcb_reset(struct net_device *dev);
0123 void cxgb4_dcb_state_fsm(struct net_device *, enum cxgb4_dcb_state_input);
0124 void cxgb4_dcb_handle_fw_update(struct adapter *, const struct fw_port_cmd *);
0125 void cxgb4_dcb_set_caps(struct adapter *, const struct fw_port_cmd *);
0126 extern const struct dcbnl_rtnl_ops cxgb4_dcb_ops;
0127
0128 static inline __u8 bitswap_1(unsigned char val)
0129 {
0130 return ((val & 0x80) >> 7) |
0131 ((val & 0x40) >> 5) |
0132 ((val & 0x20) >> 3) |
0133 ((val & 0x10) >> 1) |
0134 ((val & 0x08) << 1) |
0135 ((val & 0x04) << 3) |
0136 ((val & 0x02) << 5) |
0137 ((val & 0x01) << 7);
0138 }
0139
0140 extern const char * const dcb_ver_array[];
0141
0142 #define CXGB4_DCB_ENABLED true
0143
0144 #else
0145
0146 static inline void cxgb4_dcb_state_init(struct net_device *dev)
0147 {
0148 }
0149
0150 #define CXGB4_DCB_ENABLED false
0151
0152 #endif
0153
0154 #endif