summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/intel/i40e/i40e_main.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-10-19 11:44:36 +0100
committerDavid S. Miller <davem@davemloft.net>2017-10-19 11:44:36 +0100
commit8f2e9ca837ecee50aa85e853299bf7e66431e071 (patch)
tree616924508c2fcb0b60331a4301a0c0aeb30c5261 /drivers/net/ethernet/intel/i40e/i40e_main.c
parentb9f1f1ce866c28e3d9b86202441b220244754a69 (diff)
parent6c32e0d9fdd56a7af54512aff700e20d85563499 (diff)
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 40GbE Intel Wired LAN Driver Updates 2017-10-17 This series contains updates to i40e and ethtool. Alan provides most of the changes in this series which are mainly fixes and cleanups. Renamed the ethtool "cmd" variable to "ks", since the new ethtool API passes us ksettings structs instead of command structs. Cleaned up an ifdef that was not accomplishing anything. Added function header comments to provide better documentation. Fixed two issues in i40e_get_link_ksettings(), by calling ethtool_link_ksettings_zero_link_mode() to ensure the advertising and link masks are cleared before we start setting bits. Cleaned up and fixed code comments which were incorrect. Separated the setting of autoneg in i40e_phy_types_to_ethtool() into its own conditional to clarify what PHYs support and advertise autoneg, and makes it easier to add new PHY types in the future. Added ethtool functionality to intersect two link masks together to find the common ground between them. Overhauled i40e to ensure that the new ethtool API macros are being used, instead of the old ones. Fixed the usage of unsigned 64-bit division which is not supported on all architectures. Sudheer adds support for 25G Active Optical Cables (AOC) and Active Copper Cables (ACC) PHY types. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_main.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 39989147b30b..54ff34faca37 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -5442,6 +5442,7 @@ int i40e_get_link_speed(struct i40e_vsi *vsi)
int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)
{
struct i40e_pf *pf = vsi->back;
+ u64 credits = 0;
int speed = 0;
int ret = 0;
@@ -5459,8 +5460,9 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)
}
/* Tx rate credits are in values of 50Mbps, 0 is disabled */
- ret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid,
- max_tx_rate / I40E_BW_CREDIT_DIVISOR,
+ credits = max_tx_rate;
+ do_div(credits, I40E_BW_CREDIT_DIVISOR);
+ ret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid, credits,
I40E_MAX_BW_INACTIVE_ACCUM, NULL);
if (ret)
dev_err(&pf->pdev->dev,
@@ -6063,13 +6065,17 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi,
/* configure VSI for BW limit */
if (ch->max_tx_rate) {
+ u64 credits = ch->max_tx_rate;
+
if (i40e_set_bw_limit(vsi, ch->seid, ch->max_tx_rate))
return -EINVAL;
+ do_div(credits, I40E_BW_CREDIT_DIVISOR);
dev_dbg(&pf->pdev->dev,
"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n",
ch->max_tx_rate,
- ch->max_tx_rate / I40E_BW_CREDIT_DIVISOR, ch->seid);
+ credits,
+ ch->seid);
}
/* in case of VF, this will be main SRIOV VSI */
@@ -6090,6 +6096,7 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi,
static int i40e_configure_queue_channels(struct i40e_vsi *vsi)
{
struct i40e_channel *ch;
+ u64 max_rate = 0;
int ret = 0, i;
/* Create app vsi with the TCs. Main VSI with TC0 is already set up */
@@ -6110,8 +6117,9 @@ static int i40e_configure_queue_channels(struct i40e_vsi *vsi)
/* Bandwidth limit through tc interface is in bytes/s,
* change to Mbit/s
*/
- ch->max_tx_rate =
- vsi->mqprio_qopt.max_rate[i] / (1000000 / 8);
+ max_rate = vsi->mqprio_qopt.max_rate[i];
+ do_div(max_rate, I40E_BW_MBPS_DIVISOR);
+ ch->max_tx_rate = max_rate;
list_add_tail(&ch->list, &vsi->ch_list);
@@ -6540,6 +6548,7 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,
struct tc_mqprio_qopt_offload *mqprio_qopt)
{
u64 sum_max_rate = 0;
+ u64 max_rate = 0;
int i;
if (mqprio_qopt->qopt.offset[0] != 0 ||
@@ -6554,7 +6563,9 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,
"Invalid min tx rate (greater than 0) specified\n");
return -EINVAL;
}
- sum_max_rate += (mqprio_qopt->max_rate[i] / (1000000 / 8));
+ max_rate = mqprio_qopt->max_rate[i];
+ do_div(max_rate, I40E_BW_MBPS_DIVISOR);
+ sum_max_rate += max_rate;
if (i >= mqprio_qopt->qopt.num_tc - 1)
break;
@@ -6698,14 +6709,18 @@ config_tc:
if (pf->flags & I40E_FLAG_TC_MQPRIO) {
if (vsi->mqprio_qopt.max_rate[0]) {
- u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] /
- (1000000 / 8);
+ u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];
+
+ do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);
ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);
if (!ret) {
+ u64 credits = max_tx_rate;
+
+ do_div(credits, I40E_BW_CREDIT_DIVISOR);
dev_dbg(&vsi->back->pdev->dev,
"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n",
max_tx_rate,
- max_tx_rate / I40E_BW_CREDIT_DIVISOR,
+ credits,
vsi->seid);
} else {
need_reset = true;
@@ -8166,14 +8181,17 @@ static int i40e_rebuild_channels(struct i40e_vsi *vsi)
return ret;
}
if (ch->max_tx_rate) {
+ u64 credits = ch->max_tx_rate;
+
if (i40e_set_bw_limit(vsi, ch->seid,
ch->max_tx_rate))
return -EINVAL;
+ do_div(credits, I40E_BW_CREDIT_DIVISOR);
dev_dbg(&vsi->back->pdev->dev,
"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n",
ch->max_tx_rate,
- ch->max_tx_rate / I40E_BW_CREDIT_DIVISOR,
+ credits,
ch->seid);
}
}
@@ -8446,17 +8464,21 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
}
if (vsi->mqprio_qopt.max_rate[0]) {
- u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] / (1000000 / 8);
+ u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0];
+ u64 credits = 0;
+ do_div(max_tx_rate, I40E_BW_MBPS_DIVISOR);
ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);
- if (!ret)
- dev_dbg(&vsi->back->pdev->dev,
- "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n",
- max_tx_rate,
- max_tx_rate / I40E_BW_CREDIT_DIVISOR,
- vsi->seid);
- else
+ if (ret)
goto end_unlock;
+
+ credits = max_tx_rate;
+ do_div(credits, I40E_BW_CREDIT_DIVISOR);
+ dev_dbg(&vsi->back->pdev->dev,
+ "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n",
+ max_tx_rate,
+ credits,
+ vsi->seid);
}
/* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs