17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/pci.h>
22 #include <linux/netdevice.h>
24 #include <linux/ethtool.h>
33 #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
34 #define ETH_MIN_PACKET_SIZE 60
35 #define ETH_MAX_PACKET_SIZE 1500
36 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
37 #define MDIO_ACCESS_TIMEOUT 1000
39 #define I2C_SWITCH_WIDTH 2
42 #define I2C_WA_RETRY_CNT 3
43 #define I2C_WA_PWR_ITER (I2C_WA_RETRY_CNT - 1)
44 #define MCPR_IMC_COMMAND_READ_OP 1
45 #define MCPR_IMC_COMMAND_WRITE_OP 2
48 #define LED_BLINK_RATE_VAL_E3 354
49 #define LED_BLINK_RATE_VAL_E1X_E2 480
54 #define NIG_LATCH_BC_ENABLE_MI_INT 0
56 #define NIG_STATUS_EMAC0_MI_INT \
57 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT
58 #define NIG_STATUS_XGXS0_LINK10G \
59 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G
60 #define NIG_STATUS_XGXS0_LINK_STATUS \
61 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS
62 #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \
63 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE
64 #define NIG_STATUS_SERDES0_LINK_STATUS \
65 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS
66 #define NIG_MASK_MI_INT \
67 NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT
68 #define NIG_MASK_XGXS0_LINK10G \
69 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G
70 #define NIG_MASK_XGXS0_LINK_STATUS \
71 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS
72 #define NIG_MASK_SERDES0_LINK_STATUS \
73 NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS
75 #define MDIO_AN_CL73_OR_37_COMPLETE \
76 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \
77 MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE)
79 #define XGXS_RESET_BITS \
80 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \
81 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \
82 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \
83 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \
84 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB)
86 #define SERDES_RESET_BITS \
87 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \
88 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \
89 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \
90 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD)
92 #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37
93 #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73
94 #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM
95 #define AUTONEG_PARALLEL \
96 SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION
97 #define AUTONEG_SGMII_FIBER_AUTODET \
98 SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT
99 #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY
101 #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \
102 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE
103 #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \
104 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE
105 #define GP_STATUS_SPEED_MASK \
106 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK
107 #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M
108 #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M
109 #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G
110 #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G
111 #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G
112 #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G
113 #define GP_STATUS_10G_HIG \
114 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG
115 #define GP_STATUS_10G_CX4 \
116 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4
117 #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX
118 #define GP_STATUS_10G_KX4 \
119 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4
120 #define GP_STATUS_10G_KR MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KR
121 #define GP_STATUS_10G_XFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_XFI
122 #define GP_STATUS_20G_DXGXS MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_20G_DXGXS
123 #define GP_STATUS_10G_SFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_SFI
124 #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD
125 #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD
126 #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD
127 #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4
128 #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD
129 #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD
130 #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD
131 #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD
132 #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD
133 #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD
134 #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD
135 #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD
136 #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD
137 #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD
138 #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD
140 #define LINK_UPDATE_MASK \
141 (LINK_STATUS_SPEED_AND_DUPLEX_MASK | \
142 LINK_STATUS_LINK_UP | \
143 LINK_STATUS_PHYSICAL_LINK_FLAG | \
144 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | \
145 LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | \
146 LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | \
147 LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK | \
148 LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE | \
149 LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE)
151 #define SFP_EEPROM_CON_TYPE_ADDR 0x2
152 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7
153 #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21
156 #define SFP_EEPROM_COMP_CODE_ADDR 0x3
157 #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4)
158 #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5)
159 #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6)
161 #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8
162 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4
163 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8
165 #define SFP_EEPROM_OPTIONS_ADDR 0x40
166 #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1
167 #define SFP_EEPROM_OPTIONS_SIZE 2
169 #define EDC_MODE_LINEAR 0x0022
170 #define EDC_MODE_LIMITING 0x0044
171 #define EDC_MODE_PASSIVE_DAC 0x0055
174 #define DCBX_INVALID_COS (0xFF)
176 #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000)
177 #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000)
178 #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360)
179 #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720)
180 #define ETS_E3B0_PBF_MIN_W_VAL (10000)
182 #define MAX_PACKET_SIZE (9700)
183 #define MAX_KR_LINK_RETRY 4
189 #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \
190 bnx2x_cl45_write(_bp, _phy, \
191 (_phy)->def_md_devad, \
192 (_bank + (_addr & 0xf)), \
195 #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \
196 bnx2x_cl45_read(_bp, _phy, \
197 (_phy)->def_md_devad, \
198 (_bank + (_addr & 0xf)), \
230 u32 cur_speed_cap_mask, cur_req_fc_auto_adv, additional_config;
231 u32 saved_val, req_val, eee_status;
245 additional_config & ~NO_LFA_DUE_TO_DCC_MASK);
252 port_mb[params->
port].link_status));
266 lfa_mask = 0xffffffff;
276 if ((saved_val & lfa_mask) != (req_val & lfa_mask)) {
278 (saved_val & lfa_mask), (req_val & lfa_mask));
285 if ((saved_val & lfa_mask) != (req_val & lfa_mask)) {
287 (saved_val & lfa_mask), (req_val & lfa_mask));
294 if ((saved_val & lfa_mask) != (req_val & lfa_mask)) {
296 (saved_val & lfa_mask), (req_val & lfa_mask));
300 for (cfg_idx = 0; cfg_idx < cfg_size; cfg_idx++) {
303 speed_cap_mask[cfg_idx]));
313 cur_req_fc_auto_adv =
326 eee_status[params->
port]));
343 static void bnx2x_get_epio(
struct bnx2x *bp,
u32 epio_pin,
u32 *en)
345 u32 epio_mask, gp_oenable;
353 epio_mask = 1 << epio_pin;
360 static void bnx2x_set_epio(
struct bnx2x *bp,
u32 epio_pin,
u32 en)
362 u32 epio_mask, gp_output, gp_oenable;
370 epio_mask = 1 << epio_pin;
374 gp_output |= epio_mask;
376 gp_output &= ~epio_mask;
385 static void bnx2x_set_cfg_pin(
struct bnx2x *bp,
u32 pin_cfg,
u32 val)
398 static u32 bnx2x_get_cfg_pin(
struct bnx2x *bp,
u32 pin_cfg,
u32 *val)
415 static void bnx2x_ets_e2e3a0_disabled(
struct link_params *params)
473 static u32 bnx2x_ets_get_min_w_val_nig(
const struct link_vars *vars)
494 static u32 bnx2x_ets_get_credit_upper_bound(
const u32 min_w_val)
496 const u32 credit_upper_bound = (
u32)
MAXVAL((150 * min_w_val),
498 return credit_upper_bound;
505 static void bnx2x_ets_e3b0_set_credit_upper_bound_nig(
511 const u32 credit_upper_bound =
512 bnx2x_ets_get_credit_upper_bound(min_w_val);
544 static void bnx2x_ets_e3b0_nig_disabled(
const struct link_params *params,
548 const u8 port = params->
port;
549 const u32 min_w_val = bnx2x_ets_get_min_w_val_nig(vars);
620 bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val);
627 static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf(
632 const u32 credit_upper_bound =
633 bnx2x_ets_get_credit_upper_bound(min_w_val);
634 const u8 port = params->
port;
635 u32 base_upper_bound = 0;
650 REG_WR(bp, base_upper_bound + (i << 2), credit_upper_bound);
661 static void bnx2x_ets_e3b0_pbf_disabled(
const struct link_params *params)
664 const u8 port = params->
port;
710 REG_WR(bp, base_weight + (0x4 * i), 0);
712 bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf);
719 static int bnx2x_ets_e3b0_disabled(
const struct link_params *params,
726 "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n");
730 bnx2x_ets_e3b0_nig_disabled(params, vars);
732 bnx2x_ets_e3b0_pbf_disabled(params);
746 int bnx2x_status = 0;
749 bnx2x_ets_e2e3a0_disabled(params);
751 bnx2x_status = bnx2x_ets_e3b0_disabled(params, vars);
765 static int bnx2x_ets_e3b0_cli_map(
const struct link_params *params,
767 const u8 cos_sp_bitmap,
768 const u8 cos_bw_bitmap)
771 const u8 port = params->
port;
772 const u8 nig_cli_sp_bitmap = 0x7 | (cos_sp_bitmap << 3);
773 const u8 pbf_cli_sp_bitmap = cos_sp_bitmap;
774 const u8 nig_cli_subject2wfq_bitmap = cos_bw_bitmap << 3;
775 const u8 pbf_cli_subject2wfq_bitmap = cos_bw_bitmap;
785 nig_cli_subject2wfq_bitmap);
789 pbf_cli_subject2wfq_bitmap);
799 static int bnx2x_ets_e3b0_set_cos_bw(
struct bnx2x *bp,
801 const u32 min_w_val_nig,
802 const u32 min_w_val_pbf,
807 u32 nig_reg_adress_crd_weight = 0;
808 u32 pbf_reg_adress_crd_weight = 0;
810 const u32 cos_bw_nig = ((bw ? bw : 1) * min_w_val_nig) / total_bw;
811 const u32 cos_bw_pbf = ((bw ? bw : 1) * min_w_val_pbf) / total_bw;
815 nig_reg_adress_crd_weight =
818 pbf_reg_adress_crd_weight = (
port) ?
822 nig_reg_adress_crd_weight = (
port) ?
825 pbf_reg_adress_crd_weight = (
port) ?
829 nig_reg_adress_crd_weight = (
port) ?
833 pbf_reg_adress_crd_weight = (
port) ?
839 nig_reg_adress_crd_weight =
841 pbf_reg_adress_crd_weight =
847 nig_reg_adress_crd_weight =
854 nig_reg_adress_crd_weight =
860 REG_WR(bp, nig_reg_adress_crd_weight, cos_bw_nig);
862 REG_WR(bp, pbf_reg_adress_crd_weight, cos_bw_pbf);
871 static int bnx2x_ets_e3b0_get_total_bw(
878 u8 is_bw_cos_exist = 0;
882 for (cos_idx = 0; cos_idx < ets_params->
num_of_cos; cos_idx++) {
885 if (!ets_params->
cos[cos_idx].params.bw_params.bw) {
891 ets_params->
cos[cos_idx].params.bw_params.bw
895 ets_params->
cos[cos_idx].params.bw_params.bw;
900 if ((is_bw_cos_exist == 1) && (*total_bw != 100)) {
901 if (*total_bw == 0) {
903 "bnx2x_ets_E3B0_config total BW shouldn't be 0\n");
907 "bnx2x_ets_E3B0_config total BW should be 100\n");
920 static void bnx2x_ets_e3b0_sp_pri_to_cos_init(
u8 *sp_pri_to_cos)
932 static int bnx2x_ets_e3b0_sp_pri_to_cos_set(
const struct link_params *params,
933 u8 *sp_pri_to_cos,
const u8 pri,
937 const u8 port = params->
port;
941 if (pri >= max_num_of_cos) {
943 "parameter Illegal strict priority\n");
949 "parameter There can't be two COS's with "
950 "the same strict pri\n");
954 sp_pri_to_cos[
pri] = cos_entry;
965 static u64 bnx2x_e3b0_sp_get_pri_cli_reg(
const u8 cos,
const u8 cos_offset,
971 pri_cli_nig = ((
u64)(cos + cos_offset)) << (entry_size *
972 (pri_set + pri_offset));
982 static u64 bnx2x_e3b0_sp_get_pri_cli_reg_nig(
const u8 cos,
const u8 pri_set)
985 const u8 nig_cos_offset = 3;
986 const u8 nig_pri_offset = 3;
988 return bnx2x_e3b0_sp_get_pri_cli_reg(cos, nig_cos_offset, pri_set,
998 static u64 bnx2x_e3b0_sp_get_pri_cli_reg_pbf(
const u8 cos,
const u8 pri_set)
1000 const u8 pbf_cos_offset = 0;
1001 const u8 pbf_pri_offset = 0;
1003 return bnx2x_e3b0_sp_get_pri_cli_reg(cos, pbf_cos_offset, pri_set,
1014 static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(
const struct link_params *params,
1017 struct bnx2x *bp = params->
bp;
1019 const u8 port = params->
port;
1021 u64 pri_cli_nig = 0x210;
1022 u32 pri_cli_pbf = 0x0;
1028 u8 cos_bit_to_set = (1 << max_num_of_cos) - 1;
1031 for (i = 0; i < max_num_of_cos; i++) {
1035 "bnx2x_ets_e3b0_sp_set_pri_cli_reg "
1036 "invalid cos entry\n");
1040 pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig(
1041 sp_pri_to_cos[i], pri_set);
1043 pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf(
1044 sp_pri_to_cos[i], pri_set);
1045 pri_bitmask = 1 << sp_pri_to_cos[
i];
1047 if (!(pri_bitmask & cos_bit_to_set)) {
1049 "bnx2x_ets_e3b0_sp_set_pri_cli_reg "
1050 "invalid There can't be two COS's with"
1051 " the same strict pri\n");
1054 cos_bit_to_set &= ~pri_bitmask;
1060 for (i = 0; i < max_num_of_cos; i++) {
1061 pri_bitmask = 1 <<
i;
1063 if (pri_bitmask & cos_bit_to_set) {
1065 pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig(
1068 pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf(
1071 cos_bit_to_set &= ~pri_bitmask;
1076 if (pri_set != max_num_of_cos) {
1078 "entries were set\n");
1090 const u32 pri_cli_nig_lsb = (
u32) (pri_cli_nig);
1091 const u32 pri_cli_nig_msb = (
u32) ((pri_cli_nig >> 32) & 0xF);
1111 struct bnx2x *bp = params->
bp;
1112 int bnx2x_status = 0;
1113 const u8 port = params->
port;
1115 const u32 min_w_val_nig = bnx2x_ets_get_min_w_val_nig(vars);
1117 u8 cos_bw_bitmap = 0;
1118 u8 cos_sp_bitmap = 0;
1126 "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n");
1130 if ((ets_params->
num_of_cos > max_num_of_cos)) {
1132 "isn't supported\n");
1137 bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos);
1140 bnx2x_status = bnx2x_ets_e3b0_get_total_bw(params, ets_params,
1144 "bnx2x_ets_E3B0_config get_total_bw failed\n");
1151 bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val_nig);
1152 bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf);
1155 for (cos_entry = 0; cos_entry < ets_params->
num_of_cos; cos_entry++) {
1157 cos_bw_bitmap |= (1 << cos_entry);
1161 bnx2x_status = bnx2x_ets_e3b0_set_cos_bw(
1162 bp, cos_entry, min_w_val_nig, min_w_val_pbf,
1164 ets_params->
cos[cos_entry].params.bw_params.bw,
1167 ets_params->
cos[cos_entry].state){
1168 cos_sp_bitmap |= (1 << cos_entry);
1170 bnx2x_status = bnx2x_ets_e3b0_sp_pri_to_cos_set(
1173 ets_params->
cos[cos_entry].params.sp_params.pri,
1178 "bnx2x_ets_e3b0_config cos state not valid\n");
1183 "bnx2x_ets_e3b0_config set cos bw failed\n");
1184 return bnx2x_status;
1189 bnx2x_status = bnx2x_ets_e3b0_sp_set_pri_cli_reg(params,
1194 "bnx2x_ets_E3B0_config set_pri_cli_reg failed\n");
1195 return bnx2x_status;
1199 bnx2x_status = bnx2x_ets_e3b0_cli_map(params, ets_params,
1205 return bnx2x_status;
1209 static void bnx2x_ets_bw_limit_common(
const struct link_params *params)
1212 struct bnx2x *bp = params->
bp;
1257 struct bnx2x *bp = params->
bp;
1258 const u32 total_bw = cos0_bw + cos1_bw;
1259 u32 cos0_credit_weight = 0;
1260 u32 cos1_credit_weight = 0;
1276 bnx2x_ets_bw_limit_common(params);
1288 struct bnx2x *bp = params->
bp;
1319 val = (!strict_cos) ? 0x2318 : 0x22E0;
1328 static void bnx2x_update_pfc_xmac(
struct link_params *params,
1332 struct bnx2x *bp = params->
bp;
1334 u32 pause_val, pfc0_val, pfc1_val;
1340 pause_val = 0x18000;
1341 pfc0_val = 0xFFFF8000;
1390 static void bnx2x_emac_get_pfc_stat(
struct link_params *params,
1391 u32 pfc_frames_sent[2],
1392 u32 pfc_frames_received[2])
1395 struct bnx2x *bp = params->
bp;
1403 val_xoff =
REG_RD(bp, emac_base +
1409 pfc_frames_received[0] = val_xon + val_xoff;
1412 val_xoff =
REG_RD(bp, emac_base +
1418 pfc_frames_sent[0] = val_xon + val_xoff;
1423 u32 pfc_frames_sent[2],
1424 u32 pfc_frames_received[2])
1427 struct bnx2x *bp = params->
bp;
1436 bnx2x_emac_get_pfc_stat(params, pfc_frames_sent,
1437 pfc_frames_received);
1467 static u8 bnx2x_is_4_port_mode(
struct bnx2x *bp)
1469 u32 port4mode_ovwr_val;
1472 if (port4mode_ovwr_val & (1<<0)) {
1474 return ((port4mode_ovwr_val & (1<<1)) == (1<<1));
1480 static void bnx2x_emac_init(
struct link_params *params,
1484 struct bnx2x *bp = params->
bp;
1511 bnx2x_set_mdio_clk(bp, params->
chip_id, port);
1513 val = ((params->
mac_addr[0] << 8) |
1517 val = ((params->
mac_addr[2] << 24) |
1524 static void bnx2x_set_xumac_nig(
struct link_params *params,
1528 struct bnx2x *bp = params->
bp;
1538 static void bnx2x_set_umac_rxtx(
struct link_params *params,
u8 en)
1542 struct bnx2x *bp = params->
bp;
1557 static void bnx2x_umac_enable(
struct link_params *params,
1562 struct bnx2x *bp = params->
bp;
1649 bnx2x_set_xumac_nig(params,
1656 static void bnx2x_xmac_init(
struct link_params *params,
u32 max_speed)
1658 struct bnx2x *bp = params->
bp;
1659 u32 is_port4mode = bnx2x_is_4_port_mode(bp);
1671 "XMAC already out of reset in 4-port mode\n");
1677 MISC_REGISTERS_RESET_REG_2_XMAC);
1681 MISC_REGISTERS_RESET_REG_2_XMAC);
1695 "Init XMAC to 10G x 1 port per path\n");
1700 "Init XMAC to 20G x 2 ports per path\n");
1715 static void bnx2x_set_xmac_rxtx(
struct link_params *params,
u8 en)
1718 struct bnx2x *bp = params->
bp;
1730 (pfc_ctrl & ~(1<<1)));
1732 (pfc_ctrl | (1<<1)));
1743 static int bnx2x_xmac_enable(
struct link_params *params,
1747 struct bnx2x *bp = params->
bp;
1770 bnx2x_update_pfc_xmac(params, vars, 0);
1787 bnx2x_set_xumac_nig(params,
1795 static int bnx2x_emac_enable(
struct link_params *params,
1798 struct bnx2x *bp = params->
bp;
1845 bnx2x_bits_en(bp, emac_base +
1850 bnx2x_bits_en(bp, emac_base +
1928 static void bnx2x_update_pfc_bmac1(
struct link_params *params,
1932 struct bnx2x *bp = params->
bp;
1957 static void bnx2x_update_pfc_bmac2(
struct link_params *params,
1965 struct bnx2x *bp = params->
bp;
1994 wb_data[0] |= (1<<0);
1995 wb_data[0] |= (1<<1);
1996 wb_data[0] |= (1<<2);
1997 wb_data[0] |= (1<<3);
1998 wb_data[0] |= (1<<5);
2003 wb_data[0] &= ~(1<<2);
2035 val |= ((1<<6)|(1<<5));
2047 static int bnx2x_pfc_nig_rx_priority_mask(
struct bnx2x *bp,
2049 u32 priority_mask,
u8 port)
2051 u32 nig_reg_rx_priority_mask_add = 0;
2053 switch (cos_entry) {
2055 nig_reg_rx_priority_mask_add = (
port) ?
2060 nig_reg_rx_priority_mask_add = (
port) ?
2065 nig_reg_rx_priority_mask_add = (
port) ?
2086 REG_WR(bp, nig_reg_rx_priority_mask_add, priority_mask);
2090 static void bnx2x_update_mng(
struct link_params *params,
u32 link_status)
2092 struct bnx2x *bp = params->
bp;
2096 port_mb[params->
port].link_status), link_status);
2099 static void bnx2x_update_pfc_nig(
struct link_params *params,
2103 u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0;
2104 u32 llfc_enable = 0, xcm_out_en = 0, hwpfc_enable = 0;
2105 u32 pkt_priority_to_cos = 0;
2106 struct bnx2x *bp = params->
bp;
2179 bnx2x_pfc_nig_rx_priority_mask(bp, i,
2192 pkt_priority_to_cos);
2204 struct bnx2x *bp = params->
bp;
2205 int bnx2x_status = 0;
2216 bnx2x_update_pfc_nig(params, vars, pfc_params);
2219 return bnx2x_status;
2225 bnx2x_update_pfc_xmac(params, vars, 0);
2232 bnx2x_emac_enable(params, vars, 0);
2233 return bnx2x_status;
2236 bnx2x_update_pfc_bmac2(params, vars, bmac_loopback);
2238 bnx2x_update_pfc_bmac1(params, vars);
2247 return bnx2x_status;
2251 static int bnx2x_bmac1_enable(
struct link_params *params,
2255 struct bnx2x *bp = params->
bp;
2271 wb_data[0] = ((params->
mac_addr[2] << 24) |
2275 wb_data[1] = ((params->
mac_addr[0] << 8) |
2294 bnx2x_update_pfc_bmac1(params, vars);
2307 wb_data[0] = 0x1000200;
2315 static int bnx2x_bmac2_enable(
struct link_params *params,
2319 struct bnx2x *bp = params->
bp;
2341 wb_data[0] = ((params->
mac_addr[2] << 24) |
2345 wb_data[1] = ((params->
mac_addr[0] << 8) |
2353 wb_data[0] = 0x1000200;
2375 bnx2x_update_pfc_bmac2(params, vars, is_lb);
2380 static int bnx2x_bmac_enable(
struct link_params *params,
2382 u8 is_lb,
u8 reset_bmac)
2386 struct bnx2x *bp = params->
bp;
2403 rc = bnx2x_bmac2_enable(params, vars, is_lb);
2405 rc = bnx2x_bmac1_enable(params, vars, is_lb);
2425 static void bnx2x_set_bmac_rx(
struct bnx2x *bp,
u32 chip_id,
u8 port,
u8 en)
2454 struct bnx2x *bp = params->
bp;
2467 while ((init_crd != crd) && count) {
2473 if (init_crd != crd) {
2497 switch (line_speed) {
2499 init_crd = thresh + 553 - 22;
2509 line_speed, init_crd);
2536 static u32 bnx2x_get_emac_base(
struct bnx2x *bp,
2537 u32 mdc_mdio_access,
u8 port)
2540 switch (mdc_mdio_access) {
2571 static int bnx2x_cl22_write(
struct bnx2x *bp,
2584 tmp = ((phy->
addr << 21) | (reg << 16) | val |
2589 for (i = 0; i < 50; i++) {
2606 static int bnx2x_cl22_read(
struct bnx2x *bp,
2620 val = ((phy->
addr << 21) | (reg << 16) |
2625 for (i = 0; i < 50; i++) {
2635 if (val & EMAC_MDIO_COMM_START_BUSY) {
2648 static int bnx2x_cl45_read(
struct bnx2x *bp,
struct bnx2x_phy *phy,
2658 val = ((phy->
addr << 21) | (devad << 16) | reg |
2663 for (i = 0; i < 50; i++) {
2667 if (!(val & EMAC_MDIO_COMM_START_BUSY)) {
2672 if (val & EMAC_MDIO_COMM_START_BUSY) {
2674 netdev_err(bp->
dev,
"MDC/MDIO access timeout\n");
2679 val = ((phy->
addr << 21) | (devad << 16) |
2684 for (i = 0; i < 50; i++) {
2689 if (!(val & EMAC_MDIO_COMM_START_BUSY)) {
2694 if (val & EMAC_MDIO_COMM_START_BUSY) {
2696 netdev_err(bp->
dev,
"MDC/MDIO access timeout\n");
2706 bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val);
2716 static int bnx2x_cl45_write(
struct bnx2x *bp,
struct bnx2x_phy *phy,
2727 tmp = ((phy->
addr << 21) | (devad << 16) | reg |
2732 for (i = 0; i < 50; i++) {
2736 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) {
2741 if (tmp & EMAC_MDIO_COMM_START_BUSY) {
2743 netdev_err(bp->
dev,
"MDC/MDIO access timeout\n");
2747 tmp = ((phy->
addr << 21) | (devad << 16) | val |
2752 for (i = 0; i < 50; i++) {
2757 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) {
2762 if (tmp & EMAC_MDIO_COMM_START_BUSY) {
2764 netdev_err(bp->
dev,
"MDC/MDIO access timeout\n");
2773 bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val);
2787 struct bnx2x *bp = params->
bp;
2796 static int bnx2x_eee_nvram_to_time(
u32 nvram_mode,
u32 *idle_timer)
2798 switch (nvram_mode) {
2816 static int bnx2x_eee_time_to_nvram(
u32 idle_timer,
u32 *nvram_mode)
2818 switch (idle_timer) {
2838 u32 eee_mode, eee_idle;
2839 struct bnx2x *bp = params->
bp;
2847 if (bnx2x_eee_nvram_to_time(params->
eee_mode &
2856 port_feature_config[params->
port].
2861 if (bnx2x_eee_nvram_to_time(eee_mode, &eee_idle))
2868 static int bnx2x_eee_set_timers(
struct link_params *params,
2871 u32 eee_idle = 0, eee_mode;
2872 struct bnx2x *bp = params->
bp;
2874 eee_idle = bnx2x_eee_calc_timer(params);
2893 if (bnx2x_eee_time_to_nvram(eee_idle, &eee_mode))
2901 static int bnx2x_eee_initial_config(
struct link_params *params,
2910 vars->
eee_status &= ~SHMEM_EEE_LPI_REQUESTED_BIT;
2917 return bnx2x_eee_set_timers(params, vars);
2920 static int bnx2x_eee_disable(
struct bnx2x_phy *phy,
2924 struct bnx2x *bp = params->
bp;
2936 static int bnx2x_eee_advertise(
struct bnx2x_phy *phy,
2940 struct bnx2x *bp = params->
bp;
2963 static void bnx2x_update_mng_eee(
struct link_params *params,
u32 eee_status)
2965 struct bnx2x *bp = params->
bp;
2967 if (bnx2x_eee_has_cap(params))
2970 eee_status[params->
port]), eee_status);
2973 static void bnx2x_eee_an_resolve(
struct bnx2x_phy *phy,
2977 struct bnx2x *bp = params->
bp;
2978 u16 adv = 0,
lp = 0;
3023 static void bnx2x_bsc_module_sel(
struct link_params *params)
3026 u32 board_cfg, sfp_ctrl;
3028 struct bnx2x *bp = params->
bp;
3041 dev_info.port_hw_config[port].e3_cmn_pin_cfg));
3046 bnx2x_set_cfg_pin(bp, i2c_pins[idx], i2c_val[idx]);
3049 static int bnx2x_bsc_read(
struct link_params *params,
3059 struct bnx2x *bp = params->
bp;
3061 if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) {
3066 if (xfer_cnt > 16) {
3071 bnx2x_bsc_module_sel(params);
3073 xfer_cnt = 16 - lc_addr;
3081 val = (sl_devid << 16) | sl_addr;
3130 for (i = (lc_addr >> 2); i < 4; i++) {
3133 data_array[
i] = ((data_array[
i] & 0x000000ff) << 24) |
3134 ((data_array[
i] & 0x0000ff00) << 8) |
3135 ((data_array[
i] & 0x00ff0000) >> 8) |
3136 ((data_array[
i] & 0xff000000) >> 24);
3142 static void bnx2x_cl45_read_or_write(
struct bnx2x *bp,
struct bnx2x_phy *phy,
3146 bnx2x_cl45_read(bp, phy, devad, reg, &val);
3147 bnx2x_cl45_write(bp, phy, devad, reg, val | or_val);
3157 for (phy_index = 0; phy_index < params->
num_phys; phy_index++) {
3158 if (params->
phy[phy_index].addr == phy_addr) {
3159 return bnx2x_cl45_read(params->
bp,
3160 ¶ms->
phy[phy_index], devad,
3174 for (phy_index = 0; phy_index < params->
num_phys; phy_index++) {
3175 if (params->
phy[phy_index].addr == phy_addr) {
3176 return bnx2x_cl45_write(params->
bp,
3177 ¶ms->
phy[phy_index], devad,
3183 static u8 bnx2x_get_warpcore_lane(
struct bnx2x_phy *phy,
3187 struct bnx2x *bp = params->
bp;
3188 u32 path_swap, path_swap_ovr;
3192 port = params->
port;
3194 if (bnx2x_is_4_port_mode(bp)) {
3195 u32 port_swap, port_swap_ovr;
3199 if (path_swap_ovr & 0x1)
3200 path_swap = (path_swap_ovr & 0x2);
3209 if (port_swap_ovr & 0x1)
3210 port_swap = (port_swap_ovr & 0x2);
3217 lane = (port<<1) + path;
3223 if (path_swap_ovr & 0x1) {
3224 path_swap = (path_swap_ovr & 0x2);
3237 static void bnx2x_set_aer_mmd(
struct link_params *params,
3242 struct bnx2x *bp = params->
bp;
3248 (phy->
addr + ser_lane) : 0;
3251 aer_val = bnx2x_get_warpcore_lane(phy, params);
3259 aer_val = (aer_val >> 1) | 0x200;
3261 aer_val = 0x3800 + offset - 1;
3263 aer_val = 0x3800 +
offset;
3274 static void bnx2x_set_serdes_access(
struct bnx2x *bp,
u8 port)
3288 static void bnx2x_serdes_deassert(
struct bnx2x *bp,
u8 port)
3301 bnx2x_set_serdes_access(bp, port);
3307 static void bnx2x_xgxs_specific_func(
struct bnx2x_phy *phy,
3311 struct bnx2x *bp = params->
bp;
3322 static void bnx2x_xgxs_deassert(
struct link_params *params)
3324 struct bnx2x *bp = params->
bp;
3328 port = params->
port;
3336 bnx2x_xgxs_specific_func(¶ms->
phy[
INT_PHY], params,
3340 static void bnx2x_calc_ieee_aneg_adv(
struct bnx2x_phy *phy,
3343 struct bnx2x *bp = params->
bp;
3375 static void set_phy_vars(
struct link_params *params,
3378 struct bnx2x *bp = params->
bp;
3379 u8 actual_phy_idx, phy_index, link_cfg_idx;
3385 actual_phy_idx = phy_index;
3386 if (phy_config_swapped) {
3392 params->
phy[actual_phy_idx].req_flow_ctrl =
3395 params->
phy[actual_phy_idx].req_line_speed =
3398 params->
phy[actual_phy_idx].speed_cap_mask =
3401 params->
phy[actual_phy_idx].req_duplex =
3409 " speed_cap_mask %x\n",
3410 params->
phy[actual_phy_idx].req_flow_ctrl,
3411 params->
phy[actual_phy_idx].req_line_speed,
3412 params->
phy[actual_phy_idx].speed_cap_mask);
3416 static void bnx2x_ext_phy_set_pause(
struct link_params *params,
3421 struct bnx2x *bp = params->
bp;
3428 bnx2x_calc_ieee_aneg_adv(phy, params, &vars->
ieee_fc);
3443 static void bnx2x_pause_resolve(
struct link_vars *vars,
u32 pause_result)
3445 switch (pause_result) {
3464 if (pause_result & (1<<0))
3466 if (pause_result & (1<<1))
3471 static void bnx2x_ext_phy_update_adv_fc(
struct bnx2x_phy *phy,
3478 struct bnx2x *bp = params->
bp;
3480 bnx2x_cl22_read(bp, phy, 0x4, &ld_pause);
3481 bnx2x_cl22_read(bp, phy, 0x5, &lp_pause);
3484 u8 lane = bnx2x_get_warpcore_lane(phy, params);
3485 u16 gp_status, gp_mask;
3486 bnx2x_cl45_read(bp, phy,
3492 if ((gp_status & gp_mask) == gp_mask) {
3502 ld_pause = ((ld_pause &
3505 lp_pause = ((lp_pause &
3510 bnx2x_cl45_read(bp, phy,
3513 bnx2x_cl45_read(bp, phy,
3517 pause_result = (ld_pause &
3519 pause_result |= (lp_pause &
3522 bnx2x_pause_resolve(vars, pause_result);
3526 static u8 bnx2x_ext_phy_resolve_fc(
struct bnx2x_phy *phy,
3535 bnx2x_ext_phy_update_adv_fc(phy, params, vars);
3542 bnx2x_ext_phy_update_adv_fc(phy, params, vars);
3555 static void bnx2x_warpcore_set_lpi_passthrough(
struct bnx2x_phy *phy,
3558 struct bnx2x *bp = params->
bp;
3567 static void bnx2x_warpcore_enable_AN_KR(
struct bnx2x_phy *phy,
3570 u16 lane,
i, cl72_ctrl, an_adv = 0;
3572 struct bnx2x *bp = params->
bp;
3584 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg,
3589 cl72_ctrl &= 0xf8ff;
3590 cl72_ctrl |= 0x3800;
3602 bnx2x_cl45_read_or_write(bp, phy,
MDIO_WC_DEVAD, addr, 0x1);
3616 bnx2x_set_aer_mmd(params, phy);
3621 lane = bnx2x_get_warpcore_lane(phy, params);
3647 port_hw_config[params->
port].default_cfg)) &
3656 bnx2x_ext_phy_set_pause(params, phy, vars);
3661 if (ucode_ver < 0xd108) {
3679 static void bnx2x_warpcore_set_10G_KR(
struct bnx2x_phy *phy,
3683 struct bnx2x *bp = params->
bp;
3701 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg,
3704 lane = bnx2x_get_warpcore_lane(phy, params);
3711 val16 &= ~(0x0011 << lane);
3717 val16 |= (0x0303 << (lane << 1));
3721 bnx2x_set_aer_mmd(params, phy);
3749 static void bnx2x_warpcore_set_10G_XFI(
struct bnx2x_phy *phy,
3753 struct bnx2x *bp = params->
bp;
3754 u16 misc1_val, tap_val, tx_driver_val, lane,
val;
3794 ((val | 0x0006) & 0xFFFE));
3800 misc1_val &= ~(0x1f);
3826 lane = bnx2x_get_warpcore_lane(phy, params);
3842 bnx2x_warpcore_set_lpi_passthrough(phy, params);
3861 static void bnx2x_warpcore_set_20G_KR2(
struct bnx2x *bp,
3867 static void bnx2x_warpcore_set_20G_DXGXS(
struct bnx2x *bp,
3925 static void bnx2x_warpcore_set_sgmii_speed(
struct bnx2x_phy *phy,
3930 struct bnx2x *bp = params->
bp;
3931 u16 val16, digctrl_kx1, digctrl_kx2;
3939 bnx2x_warpcore_set_lpi_passthrough(phy, params);
3987 digctrl_kx1 &= 0xff4a;
3998 (digctrl_kx2 & ~(1<<2)));
4003 (digctrl_kx2 | (1<<2)));
4008 (digctrl_kx1 | 0x10));
4011 static void bnx2x_warpcore_reset_lane(
struct bnx2x *bp,
4029 static void bnx2x_warpcore_clear_regs(
struct bnx2x_phy *phy,
4033 struct bnx2x *bp = params->
bp;
4055 for (i = 0; i <
sizeof(wc_regs)/
sizeof(
struct bnx2x_reg_set); i++)
4056 bnx2x_cl45_write(bp, phy, wc_regs[i].devad, wc_regs[i].reg,
4059 lane = bnx2x_get_warpcore_lane(phy, params);
4065 static int bnx2x_get_mod_abs_int_cfg(
struct bnx2x *bp,
4067 u32 shmem_base,
u8 port,
4068 u8 *gpio_num,
u8 *gpio_port)
4074 cfg_pin = (
REG_RD(bp, shmem_base +
4076 dev_info.port_hw_config[port].e3_sfp_ctrl)) &
4089 "ERROR: Invalid cfg pin %x for module detect indication\n",
4104 static int bnx2x_is_sfp_module_plugged(
struct bnx2x_phy *phy,
4107 struct bnx2x *bp = params->
bp;
4108 u8 gpio_num, gpio_port;
4110 if (bnx2x_get_mod_abs_int_cfg(bp, params->
chip_id,
4112 &gpio_num, &gpio_port) != 0)
4122 static int bnx2x_warpcore_get_sigdet(
struct bnx2x_phy *phy,
4125 u16 gp2_status_reg0, lane;
4126 struct bnx2x *bp = params->
bp;
4128 lane = bnx2x_get_warpcore_lane(phy, params);
4133 return (gp2_status_reg0 >> (8+lane)) & 0x1;
4136 static void bnx2x_warpcore_config_runtime(
struct bnx2x_phy *phy,
4140 struct bnx2x *bp = params->
bp;
4142 u16 gp_status1 = 0, lnkup = 0, lnkup_kr = 0;
4143 u16 lane = bnx2x_get_warpcore_lane(phy, params);
4151 if (!(bnx2x_warpcore_get_sigdet(phy, params))) {
4159 port_hw_config[params->
port].default_cfg)) &
4162 switch (serdes_net_if) {
4167 lnkup = (gp_status1 >> (8+lane)) & 0x1;
4169 lnkup_kr = (gp_status1 >> (12+lane)) & 0x1;
4172 "gp_status1 0x%x\n", gp_status1);
4174 if (lnkup_kr || lnkup) {
4177 "link up, rx_tx_asic_rst 0x%x\n",
4181 bnx2x_warpcore_reset_lane(bp, phy, 1);
4182 bnx2x_warpcore_reset_lane(bp, phy, 0);
4201 static void bnx2x_warpcore_config_sfi(
struct bnx2x_phy *phy,
4204 u16 lane = bnx2x_get_warpcore_lane(phy, params);
4205 struct bnx2x *bp = params->
bp;
4206 bnx2x_warpcore_clear_regs(phy, params, lane);
4211 bnx2x_warpcore_set_10G_XFI(phy, params, 0);
4214 bnx2x_warpcore_set_sgmii_speed(phy, params, 1, 0);
4218 static void bnx2x_warpcore_config_init(
struct bnx2x_phy *phy,
4222 struct bnx2x *bp = params->
bp;
4225 u16 lane = bnx2x_get_warpcore_lane(phy, params);
4228 port_hw_config[params->
port].default_cfg)) &
4231 "serdes_net_if = 0x%x\n",
4233 bnx2x_set_aer_mmd(params, phy);
4234 bnx2x_warpcore_reset_lane(bp, phy, 1);
4242 bnx2x_warpcore_clear_regs(phy, params, lane);
4243 bnx2x_warpcore_set_sgmii_speed(phy, params, 0, 1);
4245 switch (serdes_net_if) {
4249 bnx2x_warpcore_enable_AN_KR(phy, params, vars);
4252 bnx2x_warpcore_set_10G_KR(phy, params, vars);
4257 bnx2x_warpcore_clear_regs(phy, params, lane);
4260 bnx2x_warpcore_set_10G_XFI(phy, params, 1);
4269 bnx2x_warpcore_set_sgmii_speed(phy,
4279 if (bnx2x_is_sfp_module_plugged(phy, params))
4282 bnx2x_warpcore_config_sfi(phy, params);
4291 bnx2x_warpcore_set_20G_DXGXS(bp, phy, lane);
4303 bnx2x_warpcore_set_20G_KR2(bp, phy);
4308 "Unsupported Serdes Net Interface 0x%x\n",
4315 bnx2x_warpcore_reset_lane(bp, phy, 0);
4319 static void bnx2x_sfp_e3_set_transmitter(
struct link_params *params,
4323 struct bnx2x *bp = params->
bp;
4329 dev_info.port_hw_config[port].e3_sfp_ctrl)) &
4335 bnx2x_set_cfg_pin(bp, cfg_pin, tx_en ^ 1);
4337 bnx2x_set_cfg_pin(bp, cfg_pin + 3, tx_en ^ 1);
4340 static void bnx2x_warpcore_link_reset(
struct bnx2x_phy *phy,
4343 struct bnx2x *bp = params->
bp;
4345 bnx2x_sfp_e3_set_transmitter(params, phy, 0);
4346 bnx2x_set_mdio_clk(bp, params->
chip_id, params->
port);
4347 bnx2x_set_aer_mmd(params, phy);
4349 bnx2x_warpcore_reset_lane(bp, phy, 1);
4381 lane = bnx2x_get_warpcore_lane(phy, params);
4385 val16 |= (0x11 << lane);
4387 val16 |= (0x22 << lane);
4393 val16 &= ~(0x0303 << (lane << 1));
4394 val16 |= (0x0101 << (lane << 1));
4396 val16 &= ~(0x0c0c << (lane << 1));
4397 val16 |= (0x0404 << (lane << 1));
4403 bnx2x_set_aer_mmd(params, phy);
4407 static void bnx2x_set_warpcore_loopback(
struct bnx2x_phy *phy,
4410 struct bnx2x *bp = params->
bp;
4427 lane = bnx2x_get_warpcore_lane(phy, params);
4435 bnx2x_set_aer_mmd(params, phy);
4449 static void bnx2x_sync_link(
struct link_params *params,
4452 struct bnx2x *bp = params->
bp;
4526 if (link_10g_plus) {
4558 struct bnx2x *bp = params->
bp;
4562 set_phy_vars(params, vars);
4566 port_mb[port].link_status));
4567 if (bnx2x_eee_has_cap(params))
4570 eee_status[params->
port]));
4573 bnx2x_sync_link(params, vars);
4577 dev_info.port_hw_config[port].media_type);
4578 media_types =
REG_RD(bp, sync_offset);
4594 dev_info.port_hw_config[port].aeu_int_mask);
4612 static void bnx2x_set_master_ln(
struct link_params *params,
4615 struct bnx2x *bp = params->
bp;
4616 u16 new_master_ln, ser_lane;
4630 (new_master_ln | ser_lane));
4633 static int bnx2x_reset_unicore(
struct link_params *params,
4637 struct bnx2x *bp = params->
bp;
4651 bnx2x_set_serdes_access(bp, params->
port);
4669 netdev_err(bp->
dev,
"Warning: PHY was not initialized,"
4677 static void bnx2x_set_swap_lanes(
struct link_params *params,
4680 struct bnx2x *bp = params->
bp;
4684 u16 rx_lane_swap, tx_lane_swap;
4693 if (rx_lane_swap != 0x1b) {
4706 if (tx_lane_swap != 0x1b) {
4719 static void bnx2x_set_parallel_detection(
struct bnx2x_phy *phy,
4722 struct bnx2x *bp = params->
bp;
4772 static void bnx2x_set_autoneg(
struct bnx2x_phy *phy,
4777 struct bnx2x *bp = params->
bp;
4876 static void bnx2x_program_serdes(
struct bnx2x_phy *phy,
4880 struct bnx2x *bp = params->
bp;
4925 static void bnx2x_set_brcm_cl37_advertisement(
struct bnx2x_phy *phy,
4928 struct bnx2x *bp = params->
bp;
4945 static void bnx2x_set_ieee_aneg_advertisement(
struct bnx2x_phy *phy,
4949 struct bnx2x *bp = params->
bp;
4966 static void bnx2x_restart_autoneg(
struct bnx2x_phy *phy,
4970 struct bnx2x *bp = params->
bp;
4995 "bnx2x_restart_autoneg mii_control before = 0x%x\n",
5006 static void bnx2x_initialize_sgmii_process(
struct bnx2x_phy *phy,
5010 struct bnx2x *bp = params->
bp;
5072 bnx2x_restart_autoneg(phy, params, 0);
5078 static int bnx2x_direct_parallel_detect_used(
struct bnx2x_phy *phy,
5081 struct bnx2x *bp = params->
bp;
5082 u16 pd_10g, status2_1000x;
5112 static void bnx2x_update_adv_fc(
struct bnx2x_phy *phy,
5120 struct bnx2x *bp = params->
bp;
5135 pause_result = (ld_pause &
5137 pause_result |= (lp_pause &
5149 pause_result = (ld_pause &
5151 pause_result |= (lp_pause &
5155 bnx2x_pause_resolve(vars, pause_result);
5159 static void bnx2x_flow_ctrl_resolve(
struct bnx2x_phy *phy,
5164 struct bnx2x *bp = params->
bp;
5171 bnx2x_update_adv_fc(phy, params, vars, gp_status);
5178 if (bnx2x_direct_parallel_detect_used(phy, params)) {
5182 bnx2x_update_adv_fc(phy, params, vars, gp_status);
5187 static void bnx2x_check_fallback_to_cl37(
struct bnx2x_phy *phy,
5190 struct bnx2x *bp = params->
bp;
5199 (MDIO_RX0_RX_STATUS_SIGDET)) {
5201 "rx_status(0x80b0) = 0x%x\n", rx_status);
5219 "ustat_val(0x8371) = 0x%x\n", ustat_val);
5228 &cl37_fsm_received);
5229 if ((cl37_fsm_received &
5235 "misc_rx_status(0x8330) = 0x%x\n",
5251 bnx2x_restart_autoneg(phy, params, 0);
5255 static void bnx2x_xgxs_an_resolve(
struct bnx2x_phy *phy,
5260 if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE)
5264 if (bnx2x_direct_parallel_detect_used(phy, params))
5268 static int bnx2x_get_link_speed_duplex(
struct bnx2x_phy *phy,
5275 struct bnx2x *bp = params->
bp;
5284 switch (speed_mask) {
5321 "link speed unsupported gp_status 0x%x\n",
5340 "link speed unsupported gp_status 0x%x\n",
5358 static int bnx2x_link_settings_status(
struct bnx2x_phy *phy,
5362 struct bnx2x *bp = params->
bp;
5378 gp_status, link_up, speed_mask);
5379 rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, speed_mask,
5384 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) {
5387 bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status);
5389 bnx2x_xgxs_an_resolve(phy, params, vars,
5396 bnx2x_check_fallback_to_cl37(phy, params);