aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-01-22 02:19:26 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 02:19:26 -0500
commit374d1125237e94f16ffa3185cff62df03977a988 (patch)
tree3bb15ec5b897df4ea197339478bb5d76049a2761 /drivers/net/bonding/bond_main.c
parent6cd28f044b47aeeba91807d97d6f3ea5a048e88d (diff)
parent809fa972fd90ff27225294b17a027e908b2d7b7a (diff)
Merge branch 'reciprocal'
Hannes Frederic Sowa says: ==================== reciprocal_divide update This patch is on top of aee636c4809fa5 ("bpf: do not use reciprocal divide") from Eric that sits in net tree. It will not create a merge conflict, but it depends on this one, so we suggest, if possible, to merge net into net-next. We are proposing this change with only small modifications from the v2 version, namely updating the name of trim to reciprocal_scale (as commented on by Ben Hutchings and Eric Dumazet, thanks!). We thought about introducing the reciprocal_divide algorithm in parallel to the one already used by the kernel but faced organizational issues, leading us to the conclusion that it is best to just replace the old one: We could not come up with names for the different implementations and also with a way to describe the differences to guide developers which one to choose in which situation. This is because we cannot specify the correct semantics for the version which is currently used by the kernel. Altough it seems to not be causing problems in the kernel, we cannot surely say so in the case of flex_array for the future. Current usage seems ok, but future users could run into problems. Changelog: v1->v2: - changed name to prandom_u32_max in p1 - changed name to trim in p2 - reworked code in p3 v2->v3: - p1 and p3 stays unchanged, only small update in commit message in p3 - changed name to reciprocal_scale in p2 - fixed kernel doc format v3->v4: - pseduo -> pseudo (thanks to Tilman Schmidt) v4->v5: - fix pseduo -> pseudo for real now, sorry for the noise ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3220b488dd1e..f100bd958b88 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -79,7 +79,6 @@
79#include <net/pkt_sched.h> 79#include <net/pkt_sched.h>
80#include <linux/rculist.h> 80#include <linux/rculist.h>
81#include <net/flow_keys.h> 81#include <net/flow_keys.h>
82#include <linux/reciprocal_div.h>
83#include "bonding.h" 82#include "bonding.h"
84#include "bond_3ad.h" 83#include "bond_3ad.h"
85#include "bond_alb.h" 84#include "bond_alb.h"
@@ -3596,8 +3595,9 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
3596 */ 3595 */
3597static u32 bond_rr_gen_slave_id(struct bonding *bond) 3596static u32 bond_rr_gen_slave_id(struct bonding *bond)
3598{ 3597{
3599 int packets_per_slave = bond->params.packets_per_slave;
3600 u32 slave_id; 3598 u32 slave_id;
3599 struct reciprocal_value reciprocal_packets_per_slave;
3600 int packets_per_slave = bond->params.packets_per_slave;
3601 3601
3602 switch (packets_per_slave) { 3602 switch (packets_per_slave) {
3603 case 0: 3603 case 0:
@@ -3607,8 +3607,10 @@ static u32 bond_rr_gen_slave_id(struct bonding *bond)
3607 slave_id = bond->rr_tx_counter; 3607 slave_id = bond->rr_tx_counter;
3608 break; 3608 break;
3609 default: 3609 default:
3610 reciprocal_packets_per_slave =
3611 bond->params.reciprocal_packets_per_slave;
3610 slave_id = reciprocal_divide(bond->rr_tx_counter, 3612 slave_id = reciprocal_divide(bond->rr_tx_counter,
3611 packets_per_slave); 3613 reciprocal_packets_per_slave);
3612 break; 3614 break;
3613 } 3615 }
3614 bond->rr_tx_counter++; 3616 bond->rr_tx_counter++;
@@ -4343,10 +4345,18 @@ static int bond_check_params(struct bond_params *params)
4343 params->resend_igmp = resend_igmp; 4345 params->resend_igmp = resend_igmp;
4344 params->min_links = min_links; 4346 params->min_links = min_links;
4345 params->lp_interval = lp_interval; 4347 params->lp_interval = lp_interval;
4346 if (packets_per_slave > 1) 4348 params->packets_per_slave = packets_per_slave;
4347 params->packets_per_slave = reciprocal_value(packets_per_slave); 4349 if (packets_per_slave > 0) {
4348 else 4350 params->reciprocal_packets_per_slave =
4349 params->packets_per_slave = packets_per_slave; 4351 reciprocal_value(packets_per_slave);
4352 } else {
4353 /* reciprocal_packets_per_slave is unused if
4354 * packets_per_slave is 0 or 1, just initialize it
4355 */
4356 params->reciprocal_packets_per_slave =
4357 (struct reciprocal_value) { 0 };
4358 }
4359
4350 if (primary) { 4360 if (primary) {
4351 strncpy(params->primary, primary, IFNAMSIZ); 4361 strncpy(params->primary, primary, IFNAMSIZ);
4352 params->primary[IFNAMSIZ - 1] = 0; 4362 params->primary[IFNAMSIZ - 1] = 0;