11ef8019bSDavid S. Miller /* 21ef8019bSDavid S. Miller * drivers/net/bond/bond_options.h - bonding options 31ef8019bSDavid S. Miller * Copyright (c) 2013 Nikolay Aleksandrov <nikolay@redhat.com> 41ef8019bSDavid S. Miller * 51ef8019bSDavid S. Miller * This program is free software; you can redistribute it and/or modify 61ef8019bSDavid S. Miller * it under the terms of the GNU General Public License as published by 71ef8019bSDavid S. Miller * the Free Software Foundation; either version 2 of the License, or 81ef8019bSDavid S. Miller * (at your option) any later version. 91ef8019bSDavid S. Miller */ 101ef8019bSDavid S. Miller 111ef8019bSDavid S. Miller #ifndef _NET_BOND_OPTIONS_H 121ef8019bSDavid S. Miller #define _NET_BOND_OPTIONS_H 131ef8019bSDavid S. Miller 141ef8019bSDavid S. Miller #define BOND_OPT_MAX_NAMELEN 32 151ef8019bSDavid S. Miller #define BOND_OPT_VALID(opt) ((opt) < BOND_OPT_LAST) 161ef8019bSDavid S. Miller #define BOND_MODE_ALL_EX(x) (~(x)) 171ef8019bSDavid S. Miller 181ef8019bSDavid S. Miller /* Option flags: 191ef8019bSDavid S. Miller * BOND_OPTFLAG_NOSLAVES - check if the bond device is empty before setting 201ef8019bSDavid S. Miller * BOND_OPTFLAG_IFDOWN - check if the bond device is down before setting 211ef8019bSDavid S. Miller * BOND_OPTFLAG_RAWVAL - the option parses the value itself 221ef8019bSDavid S. Miller */ 231ef8019bSDavid S. Miller enum { 241ef8019bSDavid S. Miller BOND_OPTFLAG_NOSLAVES = BIT(0), 251ef8019bSDavid S. Miller BOND_OPTFLAG_IFDOWN = BIT(1), 261ef8019bSDavid S. Miller BOND_OPTFLAG_RAWVAL = BIT(2) 271ef8019bSDavid S. Miller }; 281ef8019bSDavid S. Miller 291ef8019bSDavid S. Miller /* Value type flags: 301ef8019bSDavid S. Miller * BOND_VALFLAG_DEFAULT - mark the value as default 311ef8019bSDavid S. Miller * BOND_VALFLAG_(MIN|MAX) - mark the value as min/max 321ef8019bSDavid S. Miller */ 331ef8019bSDavid S. Miller enum { 341ef8019bSDavid S. Miller BOND_VALFLAG_DEFAULT = BIT(0), 351ef8019bSDavid S. Miller BOND_VALFLAG_MIN = BIT(1), 361ef8019bSDavid S. Miller BOND_VALFLAG_MAX = BIT(2) 371ef8019bSDavid S. Miller }; 381ef8019bSDavid S. Miller 391ef8019bSDavid S. Miller /* Option IDs, their bit positions correspond to their IDs */ 401ef8019bSDavid S. Miller enum { 411ef8019bSDavid S. Miller BOND_OPT_MODE, 421ef8019bSDavid S. Miller BOND_OPT_PACKETS_PER_SLAVE, 431ef8019bSDavid S. Miller BOND_OPT_XMIT_HASH, 441ef8019bSDavid S. Miller BOND_OPT_ARP_VALIDATE, 451ef8019bSDavid S. Miller BOND_OPT_ARP_ALL_TARGETS, 461ef8019bSDavid S. Miller BOND_OPT_FAIL_OVER_MAC, 471ef8019bSDavid S. Miller BOND_OPT_ARP_INTERVAL, 481ef8019bSDavid S. Miller BOND_OPT_ARP_TARGETS, 491ef8019bSDavid S. Miller BOND_OPT_DOWNDELAY, 501ef8019bSDavid S. Miller BOND_OPT_UPDELAY, 511ef8019bSDavid S. Miller BOND_OPT_LACP_RATE, 521ef8019bSDavid S. Miller BOND_OPT_MINLINKS, 531ef8019bSDavid S. Miller BOND_OPT_AD_SELECT, 541ef8019bSDavid S. Miller BOND_OPT_NUM_PEER_NOTIF, 551ef8019bSDavid S. Miller BOND_OPT_MIIMON, 561ef8019bSDavid S. Miller BOND_OPT_PRIMARY, 571ef8019bSDavid S. Miller BOND_OPT_PRIMARY_RESELECT, 581ef8019bSDavid S. Miller BOND_OPT_USE_CARRIER, 591ef8019bSDavid S. Miller BOND_OPT_ACTIVE_SLAVE, 601ef8019bSDavid S. Miller BOND_OPT_QUEUE_ID, 611ef8019bSDavid S. Miller BOND_OPT_ALL_SLAVES_ACTIVE, 621ef8019bSDavid S. Miller BOND_OPT_RESEND_IGMP, 631ef8019bSDavid S. Miller BOND_OPT_LP_INTERVAL, 641ef8019bSDavid S. Miller BOND_OPT_SLAVES, 651ef8019bSDavid S. Miller BOND_OPT_TLB_DYNAMIC_LB, 66*6791e466SMahesh Bandewar BOND_OPT_AD_ACTOR_SYS_PRIO, 671ef8019bSDavid S. Miller BOND_OPT_LAST 681ef8019bSDavid S. Miller }; 691ef8019bSDavid S. Miller 701ef8019bSDavid S. Miller /* This structure is used for storing option values and for passing option 711ef8019bSDavid S. Miller * values when changing an option. The logic when used as an arg is as follows: 721ef8019bSDavid S. Miller * - if string != NULL -> parse it, if the opt is RAW type then return it, else 731ef8019bSDavid S. Miller * return the parse result 741ef8019bSDavid S. Miller * - if string == NULL -> parse value 751ef8019bSDavid S. Miller */ 761ef8019bSDavid S. Miller struct bond_opt_value { 771ef8019bSDavid S. Miller char *string; 781ef8019bSDavid S. Miller u64 value; 791ef8019bSDavid S. Miller u32 flags; 801ef8019bSDavid S. Miller }; 811ef8019bSDavid S. Miller 821ef8019bSDavid S. Miller struct bonding; 831ef8019bSDavid S. Miller 841ef8019bSDavid S. Miller struct bond_option { 851ef8019bSDavid S. Miller int id; 861ef8019bSDavid S. Miller const char *name; 871ef8019bSDavid S. Miller const char *desc; 881ef8019bSDavid S. Miller u32 flags; 891ef8019bSDavid S. Miller 901ef8019bSDavid S. Miller /* unsuppmodes is used to denote modes in which the option isn't 911ef8019bSDavid S. Miller * supported. 921ef8019bSDavid S. Miller */ 931ef8019bSDavid S. Miller unsigned long unsuppmodes; 941ef8019bSDavid S. Miller /* supported values which this option can have, can be a subset of 951ef8019bSDavid S. Miller * BOND_OPTVAL_RANGE's value range 961ef8019bSDavid S. Miller */ 971ef8019bSDavid S. Miller const struct bond_opt_value *values; 981ef8019bSDavid S. Miller 991ef8019bSDavid S. Miller int (*set)(struct bonding *bond, const struct bond_opt_value *val); 1001ef8019bSDavid S. Miller }; 1011ef8019bSDavid S. Miller 1021ef8019bSDavid S. Miller int __bond_opt_set(struct bonding *bond, unsigned int option, 1031ef8019bSDavid S. Miller struct bond_opt_value *val); 1041ef8019bSDavid S. Miller int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf); 1051ef8019bSDavid S. Miller 1061ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, 1071ef8019bSDavid S. Miller struct bond_opt_value *val); 1081ef8019bSDavid S. Miller const struct bond_option *bond_opt_get(unsigned int option); 1091ef8019bSDavid S. Miller const struct bond_option *bond_opt_get_by_name(const char *name); 1101ef8019bSDavid S. Miller const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); 1111ef8019bSDavid S. Miller 1121ef8019bSDavid S. Miller /* This helper is used to initialize a bond_opt_value structure for parameter 1131ef8019bSDavid S. Miller * passing. There should be either a valid string or value, but not both. 1141ef8019bSDavid S. Miller * When value is ULLONG_MAX then string will be used. 1151ef8019bSDavid S. Miller */ 1161ef8019bSDavid S. Miller static inline void __bond_opt_init(struct bond_opt_value *optval, 1171ef8019bSDavid S. Miller char *string, u64 value) 1181ef8019bSDavid S. Miller { 1191ef8019bSDavid S. Miller memset(optval, 0, sizeof(*optval)); 1201ef8019bSDavid S. Miller optval->value = ULLONG_MAX; 1211ef8019bSDavid S. Miller if (value == ULLONG_MAX) 1221ef8019bSDavid S. Miller optval->string = string; 1231ef8019bSDavid S. Miller else 1241ef8019bSDavid S. Miller optval->value = value; 1251ef8019bSDavid S. Miller } 1261ef8019bSDavid S. Miller #define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value) 1271ef8019bSDavid S. Miller #define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX) 1281ef8019bSDavid S. Miller 1291ef8019bSDavid S. Miller void bond_option_arp_ip_targets_clear(struct bonding *bond); 1301ef8019bSDavid S. Miller 1311ef8019bSDavid S. Miller #endif /* _NET_BOND_OPTIONS_H */ 132