diff options
author | Dmitry Kravkov <dmitry@broadcom.com> | 2011-02-27 22:37:20 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-28 16:14:46 -0500 |
commit | faa6fcbbba110c7c4bc299bc90f59d9f7b51ac6e (patch) | |
tree | 7e4b38510a18b12df71e9b35269f4cfc4e7a94bf /drivers/net/bnx2x | |
parent | e3fa3aff0cb198e7c53d894f52146121d9592872 (diff) |
bnx2x: (NPAR mode) Fix FW initialization
Fix FW initialization according to max BW stored in percents
for NPAR mode. Protect HW from being configured to speed 0.
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x')
-rw-r--r-- | drivers/net/bnx2x/bnx2x_cmn.c | 17 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_cmn.h | 20 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_ethtool.c | 13 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_main.c | 15 |
4 files changed, 48 insertions, 17 deletions
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c index 710ce5d04c53..a58baf35d229 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.c +++ b/drivers/net/bnx2x/bnx2x_cmn.c | |||
@@ -703,19 +703,20 @@ u16 bnx2x_get_mf_speed(struct bnx2x *bp) | |||
703 | { | 703 | { |
704 | u16 line_speed = bp->link_vars.line_speed; | 704 | u16 line_speed = bp->link_vars.line_speed; |
705 | if (IS_MF(bp)) { | 705 | if (IS_MF(bp)) { |
706 | u16 maxCfg = (bp->mf_config[BP_VN(bp)] & | 706 | u16 maxCfg = bnx2x_extract_max_cfg(bp, |
707 | FUNC_MF_CFG_MAX_BW_MASK) >> | 707 | bp->mf_config[BP_VN(bp)]); |
708 | FUNC_MF_CFG_MAX_BW_SHIFT; | 708 | |
709 | /* Calculate the current MAX line speed limit for the DCC | 709 | /* Calculate the current MAX line speed limit for the MF |
710 | * capable devices | 710 | * devices |
711 | */ | 711 | */ |
712 | if (IS_MF_SD(bp)) { | 712 | if (IS_MF_SI(bp)) |
713 | line_speed = (line_speed * maxCfg) / 100; | ||
714 | else { /* SD mode */ | ||
713 | u16 vn_max_rate = maxCfg * 100; | 715 | u16 vn_max_rate = maxCfg * 100; |
714 | 716 | ||
715 | if (vn_max_rate < line_speed) | 717 | if (vn_max_rate < line_speed) |
716 | line_speed = vn_max_rate; | 718 | line_speed = vn_max_rate; |
717 | } else /* IS_MF_SI(bp)) */ | 719 | } |
718 | line_speed = (line_speed * maxCfg) / 100; | ||
719 | } | 720 | } |
720 | 721 | ||
721 | return line_speed; | 722 | return line_speed; |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h index 03eb4d68e6bb..326ba44b3ded 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.h +++ b/drivers/net/bnx2x/bnx2x_cmn.h | |||
@@ -1044,4 +1044,24 @@ static inline void storm_memset_cmng(struct bnx2x *bp, | |||
1044 | void bnx2x_acquire_phy_lock(struct bnx2x *bp); | 1044 | void bnx2x_acquire_phy_lock(struct bnx2x *bp); |
1045 | void bnx2x_release_phy_lock(struct bnx2x *bp); | 1045 | void bnx2x_release_phy_lock(struct bnx2x *bp); |
1046 | 1046 | ||
1047 | /** | ||
1048 | * Extracts MAX BW part from MF configuration. | ||
1049 | * | ||
1050 | * @param bp | ||
1051 | * @param mf_cfg | ||
1052 | * | ||
1053 | * @return u16 | ||
1054 | */ | ||
1055 | static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) | ||
1056 | { | ||
1057 | u16 max_cfg = (mf_cfg & FUNC_MF_CFG_MAX_BW_MASK) >> | ||
1058 | FUNC_MF_CFG_MAX_BW_SHIFT; | ||
1059 | if (!max_cfg) { | ||
1060 | BNX2X_ERR("Illegal configuration detected for Max BW - " | ||
1061 | "using 100 instead\n"); | ||
1062 | max_cfg = 100; | ||
1063 | } | ||
1064 | return max_cfg; | ||
1065 | } | ||
1066 | |||
1047 | #endif /* BNX2X_CMN_H */ | 1067 | #endif /* BNX2X_CMN_H */ |
diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c index 5b44a8b48509..b3da295c453c 100644 --- a/drivers/net/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/bnx2x/bnx2x_ethtool.c | |||
@@ -238,7 +238,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
238 | speed |= (cmd->speed_hi << 16); | 238 | speed |= (cmd->speed_hi << 16); |
239 | 239 | ||
240 | if (IS_MF_SI(bp)) { | 240 | if (IS_MF_SI(bp)) { |
241 | u32 param = 0; | 241 | u32 param = 0, part; |
242 | u32 line_speed = bp->link_vars.line_speed; | 242 | u32 line_speed = bp->link_vars.line_speed; |
243 | 243 | ||
244 | /* use 10G if no link detected */ | 244 | /* use 10G if no link detected */ |
@@ -251,9 +251,11 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
251 | REQ_BC_VER_4_SET_MF_BW); | 251 | REQ_BC_VER_4_SET_MF_BW); |
252 | return -EINVAL; | 252 | return -EINVAL; |
253 | } | 253 | } |
254 | if (line_speed < speed) { | 254 | part = (speed * 100) / line_speed; |
255 | BNX2X_DEV_INFO("New speed should be less or equal " | 255 | if (line_speed < speed || !part) { |
256 | "to actual line speed\n"); | 256 | BNX2X_DEV_INFO("Speed setting should be in a range " |
257 | "from 1%% to 100%% " | ||
258 | "of actual line speed\n"); | ||
257 | return -EINVAL; | 259 | return -EINVAL; |
258 | } | 260 | } |
259 | /* load old values */ | 261 | /* load old values */ |
@@ -263,8 +265,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
263 | param &= FUNC_MF_CFG_MIN_BW_MASK; | 265 | param &= FUNC_MF_CFG_MIN_BW_MASK; |
264 | 266 | ||
265 | /* set new MAX value */ | 267 | /* set new MAX value */ |
266 | param |= (((speed * 100) / line_speed) | 268 | param |= (part << FUNC_MF_CFG_MAX_BW_SHIFT) |
267 | << FUNC_MF_CFG_MAX_BW_SHIFT) | ||
268 | & FUNC_MF_CFG_MAX_BW_MASK; | 269 | & FUNC_MF_CFG_MAX_BW_MASK; |
269 | 270 | ||
270 | bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW, param); | 271 | bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW, param); |
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index d584d32c747d..203e9bf65875 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -1974,13 +1974,22 @@ static void bnx2x_init_vn_minmax(struct bnx2x *bp, int vn) | |||
1974 | vn_max_rate = 0; | 1974 | vn_max_rate = 0; |
1975 | 1975 | ||
1976 | } else { | 1976 | } else { |
1977 | u32 maxCfg = bnx2x_extract_max_cfg(bp, vn_cfg); | ||
1978 | |||
1977 | vn_min_rate = ((vn_cfg & FUNC_MF_CFG_MIN_BW_MASK) >> | 1979 | vn_min_rate = ((vn_cfg & FUNC_MF_CFG_MIN_BW_MASK) >> |
1978 | FUNC_MF_CFG_MIN_BW_SHIFT) * 100; | 1980 | FUNC_MF_CFG_MIN_BW_SHIFT) * 100; |
1979 | /* If min rate is zero - set it to 1 */ | 1981 | /* If fairness is enabled (not all min rates are zeroes) and |
1982 | if current min rate is zero - set it to 1. | ||
1983 | This is a requirement of the algorithm. */ | ||
1980 | if (bp->vn_weight_sum && (vn_min_rate == 0)) | 1984 | if (bp->vn_weight_sum && (vn_min_rate == 0)) |
1981 | vn_min_rate = DEF_MIN_RATE; | 1985 | vn_min_rate = DEF_MIN_RATE; |
1982 | vn_max_rate = ((vn_cfg & FUNC_MF_CFG_MAX_BW_MASK) >> | 1986 | |
1983 | FUNC_MF_CFG_MAX_BW_SHIFT) * 100; | 1987 | if (IS_MF_SI(bp)) |
1988 | /* maxCfg in percents of linkspeed */ | ||
1989 | vn_max_rate = (bp->link_vars.line_speed * maxCfg) / 100; | ||
1990 | else | ||
1991 | /* maxCfg is absolute in 100Mb units */ | ||
1992 | vn_max_rate = maxCfg * 100; | ||
1984 | } | 1993 | } |
1985 | 1994 | ||
1986 | DP(NETIF_MSG_IFUP, | 1995 | DP(NETIF_MSG_IFUP, |