Skip to content

Commit

Permalink
cxgb4: fix the wrong conversion of Mbps to Kbps
Browse files Browse the repository at this point in the history
fix the wrong conversion where 1 Mbps was converted to
1024 Kbps.

Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ganesh Goudar authored and David S. Miller committed May 10, 2018
1 parent ccb0263 commit b3c594a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2886,13 +2886,13 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
}

/* Convert from Mbps to Kbps */
req_rate = rate << 10;
req_rate = rate * 1000;

/* Max rate is 100 Gbps */
if (req_rate >= SCHED_MAX_RATE_KBPS) {
if (req_rate > SCHED_MAX_RATE_KBPS) {
dev_err(adap->pdev_dev,
"Invalid rate %u Mbps, Max rate is %u Mbps\n",
rate, SCHED_MAX_RATE_KBPS >> 10);
rate, SCHED_MAX_RATE_KBPS / 1000);
return -ERANGE;
}

Expand Down

0 comments on commit b3c594a

Please sign in to comment.