team: add per port priority option
authorJiri Pirko <jiri@resnulli.us>
Fri, 27 Jul 2012 06:28:54 +0000 (06:28 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 4 Aug 2012 03:40:12 +0000 (20:40 -0700)
Allow userspace to set port priority.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/team/team.c
include/linux/if_team.h

index 70752e631a126cd304e9b02d9b3971c396c2fb2a..a30b7c1bd9f68058b8b86a2661a89db713ddc668 100644 (file)
@@ -1092,6 +1092,24 @@ 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)
+{
+       struct team_port *port = ctx->info->port;
+
+       ctx->data.s32_val = port->priority;
+       return 0;
+}
+
+static int team_priority_option_set(struct team *team,
+                                   struct team_gsetter_ctx *ctx)
+{
+       struct team_port *port = ctx->info->port;
+
+       port->priority = ctx->data.s32_val;
+       return 0;
+}
+
 static const struct team_option team_options[] = {
        {
                .name = "mode",
@@ -1120,6 +1138,13 @@ static const struct team_option team_options[] = {
                .getter = team_user_linkup_en_option_get,
                .setter = team_user_linkup_en_option_set,
        },
+       {
+               .name = "priority",
+               .type = TEAM_OPTION_TYPE_S32,
+               .per_port = true,
+               .getter = team_priority_option_get,
+               .setter = team_priority_option_set,
+       },
 };
 
 static struct lock_class_key team_netdev_xmit_lock_key;
index e5571c4208000b14356015e8c76e9059ce6b28ae..06495b3e7a99b634dec7288dcf80b8d8896e4c56 100644 (file)
@@ -67,6 +67,7 @@ struct team_port {
        struct netpoll *np;
 #endif
 
+       s32 priority; /* lower number ~ higher priority */
        long mode_priv[0];
 };