* [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void
@ 2023-08-04 11:28 Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 1/2] team: change return value of init " Zhengchao Shao
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zhengchao Shao @ 2023-08-04 11:28 UTC (permalink / raw)
To: netdev, bpf, davem, edumazet, kuba, pabeni
Cc: jiri, weiyongjun1, yuehaibing, shaozhengchao
Because the init and getter function always returns 0, so change return
value of init and getter in the team_option structure to void and remove
redundant code.
Zhengchao Shao (2):
team: change return value of init in the team_option structure to void
team: change return value of getter in the team_option structure to
void
drivers/net/team/team.c | 60 +++++++++--------------
drivers/net/team/team_mode_activebackup.c | 8 ++-
drivers/net/team/team_mode_loadbalance.c | 39 ++++++---------
include/linux/if_team.h | 4 +-
4 files changed, 44 insertions(+), 67 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/2] team: change return value of init in the team_option structure to void
2023-08-04 11:28 [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void Zhengchao Shao
@ 2023-08-04 11:28 ` Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 2/2] team: change return value of getter " Zhengchao Shao
2023-08-04 11:44 ` [PATCH net-next 0/2] team: change return value of init and " Jiri Pirko
2 siblings, 0 replies; 5+ messages in thread
From: Zhengchao Shao @ 2023-08-04 11:28 UTC (permalink / raw)
To: netdev, bpf, davem, edumazet, kuba, pabeni
Cc: jiri, weiyongjun1, yuehaibing, shaozhengchao
Because the init function always returns 0, so change return value of init
in the team_option structure to void and remove redundant code.
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/net/team/team.c | 8 ++------
drivers/net/team/team_mode_activebackup.c | 5 ++---
drivers/net/team/team_mode_loadbalance.c | 15 ++++++---------
include/linux/if_team.h | 2 +-
4 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index d4818be08c03..84a57dcddb8b 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -149,7 +149,6 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
struct team_option_inst *opt_inst;
unsigned int array_size;
unsigned int i;
- int err;
array_size = option->array_size;
if (!array_size)
@@ -165,11 +164,8 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
opt_inst->changed = true;
opt_inst->removed = false;
list_add_tail(&opt_inst->list, &team->option_inst_list);
- if (option->init) {
- err = option->init(team, &opt_inst->info);
- if (err)
- return err;
- }
+ if (option->init)
+ option->init(team, &opt_inst->info);
}
return 0;
diff --git a/drivers/net/team/team_mode_activebackup.c b/drivers/net/team/team_mode_activebackup.c
index 3147a4fdf8d9..44d604f1c512 100644
--- a/drivers/net/team/team_mode_activebackup.c
+++ b/drivers/net/team/team_mode_activebackup.c
@@ -57,11 +57,10 @@ static void ab_port_leave(struct team *team, struct team_port *port)
}
}
-static int ab_active_port_init(struct team *team,
- struct team_option_inst_info *info)
+static void ab_active_port_init(struct team *team,
+ struct team_option_inst_info *info)
{
ab_priv(team)->ap_opt_inst_info = info;
- return 0;
}
static int ab_active_port_get(struct team *team, struct team_gsetter_ctx *ctx)
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index 18d99fda997c..50c015cd0682 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -361,14 +361,13 @@ static int lb_tx_method_set(struct team *team, struct team_gsetter_ctx *ctx)
return 0;
}
-static int lb_tx_hash_to_port_mapping_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_tx_hash_to_port_mapping_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct lb_priv *lb_priv = get_lb_priv(team);
unsigned char hash = info->array_index;
LB_HTPM_OPT_INST_INFO_BY_HASH(lb_priv, hash) = info;
- return 0;
}
static int lb_tx_hash_to_port_mapping_get(struct team *team,
@@ -401,14 +400,13 @@ static int lb_tx_hash_to_port_mapping_set(struct team *team,
return -ENODEV;
}
-static int lb_hash_stats_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_hash_stats_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct lb_priv *lb_priv = get_lb_priv(team);
unsigned char hash = info->array_index;
lb_priv->ex->stats.info[hash].opt_inst_info = info;
- return 0;
}
static int lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
@@ -421,14 +419,13 @@ static int lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
return 0;
}
-static int lb_port_stats_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_port_stats_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct team_port *port = info->port;
struct lb_port_priv *lb_port_priv = get_lb_port_priv(port);
lb_port_priv->stats_info.opt_inst_info = info;
- return 0;
}
static int lb_port_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 8de6b6e67829..fc01c3cfe86d 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -162,7 +162,7 @@ struct team_option {
bool per_port;
unsigned int array_size; /* != 0 means the option is array */
enum team_option_type type;
- int (*init)(struct team *team, struct team_option_inst_info *info);
+ void (*init)(struct team *team, struct team_option_inst_info *info);
int (*getter)(struct team *team, struct team_gsetter_ctx *ctx);
int (*setter)(struct team *team, struct team_gsetter_ctx *ctx);
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] team: change return value of getter in the team_option structure to void
2023-08-04 11:28 [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 1/2] team: change return value of init " Zhengchao Shao
@ 2023-08-04 11:28 ` Zhengchao Shao
2023-08-04 11:44 ` [PATCH net-next 0/2] team: change return value of init and " Jiri Pirko
2 siblings, 0 replies; 5+ messages in thread
From: Zhengchao Shao @ 2023-08-04 11:28 UTC (permalink / raw)
To: netdev, bpf, davem, edumazet, kuba, pabeni
Cc: jiri, weiyongjun1, yuehaibing, shaozhengchao
Because the getter function always returns 0, so change return value of
getter in the team_option structure to void and remove redundant code.
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/net/team/team.c | 52 ++++++++++-------------
drivers/net/team/team_mode_activebackup.c | 3 +-
drivers/net/team/team_mode_loadbalance.c | 24 ++++-------
include/linux/if_team.h | 2 +-
4 files changed, 33 insertions(+), 48 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 84a57dcddb8b..8f8a3eabdbe7 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -358,7 +358,9 @@ static int team_option_get(struct team *team,
{
if (!opt_inst->option->getter)
return -EOPNOTSUPP;
- return opt_inst->option->getter(team, ctx);
+
+ opt_inst->option->getter(team, ctx);
+ return 0;
}
static int team_option_set(struct team *team,
@@ -1373,10 +1375,9 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
* Net device ops
*****************/
-static int team_mode_option_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void team_mode_option_get(struct team *team, struct team_gsetter_ctx *ctx)
{
ctx->data.str_val = team->mode->kind;
- return 0;
}
static int team_mode_option_set(struct team *team, struct team_gsetter_ctx *ctx)
@@ -1384,11 +1385,10 @@ static int team_mode_option_set(struct team *team, struct team_gsetter_ctx *ctx)
return team_change_mode(team, ctx->data.str_val);
}
-static int team_notify_peers_count_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_notify_peers_count_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
ctx->data.u32_val = team->notify_peers.count;
- return 0;
}
static int team_notify_peers_count_set(struct team *team,
@@ -1398,11 +1398,10 @@ static int team_notify_peers_count_set(struct team *team,
return 0;
}
-static int team_notify_peers_interval_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_notify_peers_interval_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
ctx->data.u32_val = team->notify_peers.interval;
- return 0;
}
static int team_notify_peers_interval_set(struct team *team,
@@ -1412,11 +1411,10 @@ static int team_notify_peers_interval_set(struct team *team,
return 0;
}
-static int team_mcast_rejoin_count_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_mcast_rejoin_count_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
ctx->data.u32_val = team->mcast_rejoin.count;
- return 0;
}
static int team_mcast_rejoin_count_set(struct team *team,
@@ -1426,11 +1424,10 @@ static int team_mcast_rejoin_count_set(struct team *team,
return 0;
}
-static int team_mcast_rejoin_interval_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_mcast_rejoin_interval_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
ctx->data.u32_val = team->mcast_rejoin.interval;
- return 0;
}
static int team_mcast_rejoin_interval_set(struct team *team,
@@ -1440,13 +1437,12 @@ static int team_mcast_rejoin_interval_set(struct team *team,
return 0;
}
-static int team_port_en_option_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_port_en_option_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
ctx->data.bool_val = team_port_enabled(port);
- return 0;
}
static int team_port_en_option_set(struct team *team,
@@ -1461,13 +1457,12 @@ static int team_port_en_option_set(struct team *team,
return 0;
}
-static int team_user_linkup_option_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_user_linkup_option_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
ctx->data.bool_val = port->user.linkup;
- return 0;
}
static void __team_carrier_check(struct team *team);
@@ -1483,13 +1478,12 @@ static int team_user_linkup_option_set(struct team *team,
return 0;
}
-static int team_user_linkup_en_option_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_user_linkup_en_option_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
ctx->data.bool_val = port->user.linkup_enabled;
- return 0;
}
static int team_user_linkup_en_option_set(struct team *team,
@@ -1503,13 +1497,12 @@ static int team_user_linkup_en_option_set(struct team *team,
return 0;
}
-static int team_priority_option_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_priority_option_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
ctx->data.s32_val = port->priority;
- return 0;
}
static int team_priority_option_set(struct team *team,
@@ -1525,13 +1518,12 @@ static int team_priority_option_set(struct team *team,
return 0;
}
-static int team_queue_id_option_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void team_queue_id_option_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
ctx->data.u32_val = port->queue_id;
- return 0;
}
static int team_queue_id_option_set(struct team *team,
diff --git a/drivers/net/team/team_mode_activebackup.c b/drivers/net/team/team_mode_activebackup.c
index 44d604f1c512..e0f599e2a51d 100644
--- a/drivers/net/team/team_mode_activebackup.c
+++ b/drivers/net/team/team_mode_activebackup.c
@@ -63,7 +63,7 @@ static void ab_active_port_init(struct team *team,
ab_priv(team)->ap_opt_inst_info = info;
}
-static int ab_active_port_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void ab_active_port_get(struct team *team, struct team_gsetter_ctx *ctx)
{
struct team_port *active_port;
@@ -73,7 +73,6 @@ static int ab_active_port_get(struct team *team, struct team_gsetter_ctx *ctx)
ctx->data.u32_val = active_port->dev->ifindex;
else
ctx->data.u32_val = 0;
- return 0;
}
static int ab_active_port_set(struct team *team, struct team_gsetter_ctx *ctx)
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index 50c015cd0682..2f1573f253ec 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -242,19 +242,18 @@ static bool lb_transmit(struct team *team, struct sk_buff *skb)
return false;
}
-static int lb_bpf_func_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void lb_bpf_func_get(struct team *team, struct team_gsetter_ctx *ctx)
{
struct lb_priv *lb_priv = get_lb_priv(team);
if (!lb_priv->ex->orig_fprog) {
ctx->data.bin_val.len = 0;
ctx->data.bin_val.ptr = NULL;
- return 0;
+ return;
}
ctx->data.bin_val.len = lb_priv->ex->orig_fprog->len *
sizeof(struct sock_filter);
ctx->data.bin_val.ptr = lb_priv->ex->orig_fprog->filter;
- return 0;
}
static int __fprog_create(struct sock_fprog_kern **pfprog, u32 data_len,
@@ -335,7 +334,7 @@ static void lb_bpf_func_free(struct team *team)
bpf_prog_destroy(fp);
}
-static int lb_tx_method_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void lb_tx_method_get(struct team *team, struct team_gsetter_ctx *ctx)
{
struct lb_priv *lb_priv = get_lb_priv(team);
lb_select_tx_port_func_t *func;
@@ -346,7 +345,6 @@ static int lb_tx_method_get(struct team *team, struct team_gsetter_ctx *ctx)
name = lb_select_tx_port_get_name(func);
BUG_ON(!name);
ctx->data.str_val = name;
- return 0;
}
static int lb_tx_method_set(struct team *team, struct team_gsetter_ctx *ctx)
@@ -370,8 +368,8 @@ static void lb_tx_hash_to_port_mapping_init(struct team *team,
LB_HTPM_OPT_INST_INFO_BY_HASH(lb_priv, hash) = info;
}
-static int lb_tx_hash_to_port_mapping_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void lb_tx_hash_to_port_mapping_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct lb_priv *lb_priv = get_lb_priv(team);
struct team_port *port;
@@ -379,7 +377,6 @@ static int lb_tx_hash_to_port_mapping_get(struct team *team,
port = LB_HTPM_PORT_BY_HASH(lb_priv, hash);
ctx->data.u32_val = port ? port->dev->ifindex : 0;
- return 0;
}
static int lb_tx_hash_to_port_mapping_set(struct team *team,
@@ -409,14 +406,13 @@ static void lb_hash_stats_init(struct team *team,
lb_priv->ex->stats.info[hash].opt_inst_info = info;
}
-static int lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
{
struct lb_priv *lb_priv = get_lb_priv(team);
unsigned char hash = ctx->info->array_index;
ctx->data.bin_val.ptr = &lb_priv->ex->stats.info[hash].stats;
ctx->data.bin_val.len = sizeof(struct lb_stats);
- return 0;
}
static void lb_port_stats_init(struct team *team,
@@ -428,14 +424,13 @@ static void lb_port_stats_init(struct team *team,
lb_port_priv->stats_info.opt_inst_info = info;
}
-static int lb_port_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
+static void lb_port_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
{
struct team_port *port = ctx->info->port;
struct lb_port_priv *lb_port_priv = get_lb_port_priv(port);
ctx->data.bin_val.ptr = &lb_port_priv->stats_info.stats;
ctx->data.bin_val.len = sizeof(struct lb_stats);
- return 0;
}
static void __lb_stats_info_refresh_prepare(struct lb_stats_info *s_info)
@@ -528,13 +523,12 @@ static void lb_stats_refresh(struct work_struct *work)
mutex_unlock(&team->lock);
}
-static int lb_stats_refresh_interval_get(struct team *team,
- struct team_gsetter_ctx *ctx)
+static void lb_stats_refresh_interval_get(struct team *team,
+ struct team_gsetter_ctx *ctx)
{
struct lb_priv *lb_priv = get_lb_priv(team);
ctx->data.u32_val = lb_priv->ex->stats.refresh_interval;
- return 0;
}
static int lb_stats_refresh_interval_set(struct team *team,
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index fc01c3cfe86d..1b9b15a492fa 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -163,7 +163,7 @@ struct team_option {
unsigned int array_size; /* != 0 means the option is array */
enum team_option_type type;
void (*init)(struct team *team, struct team_option_inst_info *info);
- int (*getter)(struct team *team, struct team_gsetter_ctx *ctx);
+ void (*getter)(struct team *team, struct team_gsetter_ctx *ctx);
int (*setter)(struct team *team, struct team_gsetter_ctx *ctx);
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void
2023-08-04 11:28 [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 1/2] team: change return value of init " Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 2/2] team: change return value of getter " Zhengchao Shao
@ 2023-08-04 11:44 ` Jiri Pirko
2023-08-04 12:06 ` shaozhengchao
2 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2023-08-04 11:44 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, bpf, davem, edumazet, kuba, pabeni, weiyongjun1,
yuehaibing
Fri, Aug 04, 2023 at 01:28:23PM CEST, shaozhengchao@huawei.com wrote:
>Because the init and getter function always returns 0, so change return
>value of init and getter in the team_option structure to void and remove
>redundant code.
Reading this 5 times, I don't understand the sentence :/
Also, why you send 2 patchsets and 2 seperate patches, all for team? Why
don't you send it as one 6-patch patchset?
>
>Zhengchao Shao (2):
> team: change return value of init in the team_option structure to void
> team: change return value of getter in the team_option structure to
> void
>
> drivers/net/team/team.c | 60 +++++++++--------------
> drivers/net/team/team_mode_activebackup.c | 8 ++-
> drivers/net/team/team_mode_loadbalance.c | 39 ++++++---------
> include/linux/if_team.h | 4 +-
> 4 files changed, 44 insertions(+), 67 deletions(-)
>
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void
2023-08-04 11:44 ` [PATCH net-next 0/2] team: change return value of init and " Jiri Pirko
@ 2023-08-04 12:06 ` shaozhengchao
0 siblings, 0 replies; 5+ messages in thread
From: shaozhengchao @ 2023-08-04 12:06 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, bpf, davem, edumazet, kuba, pabeni, weiyongjun1,
yuehaibing
On 2023/8/4 19:44, Jiri Pirko wrote:
> Fri, Aug 04, 2023 at 01:28:23PM CEST, shaozhengchao@huawei.com wrote:
>> Because the init and getter function always returns 0, so change return
>> value of init and getter in the team_option structure to void and remove
>> redundant code.
>
> Reading this 5 times, I don't understand the sentence :/
>
> Also, why you send 2 patchsets and 2 seperate patches, all for team? Why
> don't you send it as one 6-patch patchset?
>
Hi Jiri:
Thank you for review. I will send a patchset.
Zhengchao Shao
>
>>
>> Zhengchao Shao (2):
>> team: change return value of init in the team_option structure to void
>> team: change return value of getter in the team_option structure to
>> void
>>
>> drivers/net/team/team.c | 60 +++++++++--------------
>> drivers/net/team/team_mode_activebackup.c | 8 ++-
>> drivers/net/team/team_mode_loadbalance.c | 39 ++++++---------
>> include/linux/if_team.h | 4 +-
>> 4 files changed, 44 insertions(+), 67 deletions(-)
>>
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-04 12:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 11:28 [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 1/2] team: change return value of init " Zhengchao Shao
2023-08-04 11:28 ` [PATCH net-next 2/2] team: change return value of getter " Zhengchao Shao
2023-08-04 11:44 ` [PATCH net-next 0/2] team: change return value of init and " Jiri Pirko
2023-08-04 12:06 ` shaozhengchao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).